html, body {
  margin: 0;
  height: 100%;
  background: #ffffff;
  color: #222222;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

body {
  position: fixed;
  inset: 0;
}

[hidden] {
  display: none !important;
}

#app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* 上:ステージ番号と条件表示 */
#top {
  flex: none;
  min-height: 44px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 8px calc(16px + env(safe-area-inset-left));
}

#stage-no {
  flex: none;
  font-size: 13px;
  color: #9a9a9a;
}

#goal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#goal span {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  background: #f2f2f2;
  color: #666666;
}

#goal span.ok {
  background: #e3f3e3;
  color: #2a7a2a;
}

/* 条件どおりの白:その項目がポンと大きくなる */
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

#goal span.bump {
  animation: bump 0.45s ease-out;
}

/* canvasの大きさは js/main.js が #stage を測って px で決める */
#stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#cv {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
}

#bar {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
}

#bar button {
  padding: 8px 10px;
  white-space: nowrap;
}

#bar .buttons {
  display: flex;
  gap: 6px;
}

#info {
  font-size: 13px;
  color: #666666;
  white-space: nowrap;
}

button {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border: 1px solid #cccccc;
  border-radius: 8px;
  background: #ffffff;
  color: #222222;
  touch-action: manipulation;
}

/* タイトル */
#title {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  background: #ffffff;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#title h1 {
  margin: 0;
  font-size: 44px;
  font-weight: 700;
  color: #222222;
}

#title .panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 220px;
}

#title button {
  font-size: 17px;
  padding: 14px;
}

/* ステージ選び:この画面だけ縦にスクロールできる */
#select {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #ffffff;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}

#select-back {
  display: block;
  margin: 0 auto 0 0;
}

#select-list {
  max-width: 360px;
  margin: 0 auto;
}

#select h2 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: #666666;
}

#select .grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

#select .grid button {
  aspect-ratio: 1;
  padding: 0;
  font-size: 18px;
  font-weight: 700;
}

#select .grid button.cleared {
  color: #2a7a2a;
}

#select .grid button:disabled {
  color: #cccccc;
  border-color: #eeeeee;
}

/* 結果:ゲームの上に重ねる */
#result {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
}

#result .panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 200px;
}

#result-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: 40px;
  font-weight: 700;
}

#result button {
  font-size: 16px;
  padding: 12px;
}
