/* まぜのび！おったんちゃん — くすみパステルの和の食卓トーン */
/* 寸法の方針: #stage をコンテナとし、文字・余白・枠線は cqw（ステージ幅の1%）で統一。
   ウィンドウがどんなサイズでもステージごと均一に拡縮し、折り返し崩れが起きない。
   数値は幅390pxのスマホでの見た目（≒旧vmin指定時のスマホ実機）を基準に較正。 */
:root {
  --soy: #f0e0be;        /* 大豆ベージュ */
  --straw: #c9a24b;      /* 藁の黄土 */
  --karashi: #e3b322;    /* からし黄 */
  --ink: #5a3d24;        /* 醤油こげ茶（線・文字） */
  --paper: #fdf6e6;
  --accent: #e0705a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #7a6248;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--ink);
}

#stage {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  height: 100dvh;
  aspect-ratio: 9 / 16;
  max-width: 100vw;
  overflow: hidden;
  background: var(--paper);
  container-type: inline-size; /* 子孫のcqwをステージ幅基準にする */
}
/* 横長すぎる画面では幅基準に */
@media (min-aspect-ratio: 9/16) {
  #stage { height: 100dvh; width: calc(100dvh * 9 / 16); }
}
@media (max-aspect-ratio: 9/16) {
  #stage { width: 100vw; height: calc(100vw * 16 / 9); }
}

canvas#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(4%, env(safe-area-inset-top)) 5% max(5%, env(safe-area-inset-bottom));
}
.screen.passthrough { pointer-events: none; }
.screen.passthrough button { pointer-events: auto; }
.hidden { display: none !important; }

.btn {
  border: 1cqw solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: bold;
  font-size: 5.5cqw;
  padding: 0.6em 1.6em;
  min-height: 13.3cqw;
  box-shadow: 0 1.3cqw 0 rgba(90, 61, 36, 0.45);
  cursor: pointer;
  transition: transform 0.05s;
}
.btn:active { transform: translateY(1cqw); box-shadow: 0 0.26cqw 0 rgba(90, 61, 36, 0.45); }
.btn-primary { background: var(--karashi); }
.btn-share { background: #333; color: #fff; border-color: #111; }
.btn-share2 { background: #fff; }
.btn-tare { background: #8c5a33; color: #fff; font-size: 4cqw; line-height: 1.2; }
.btn-stop { background: var(--accent); color: #fff; font-size: 6cqw; padding: 0.7em 1.4em; }

/* ---- タイトル ---- */
#screen-title { justify-content: space-between; text-align: center; }
.title-block { margin-top: 10%; }
.game-logo {
  font-size: 9cqw;
  line-height: 1.25;
  text-shadow: 0.08em 0.08em 0 #fff, -0.055em 0.055em 0 #fff, 0.055em -0.055em 0 #fff;
  letter-spacing: 0.05em;
  transform: rotate(-3deg);
}
.game-logo .logo-big { font-size: 1.25em; color: #a0642d; }
.tagline { margin-top: 0.8em; font-size: 4.2cqw; font-weight: bold; }
.title-bottom { display: flex; flex-direction: column; gap: 3.6cqw; align-items: center; margin-bottom: 26%; }
.best-line { font-weight: bold; font-size: 4cqw; min-height: 1.4em; }
.fan-note { font-size: 3cqw; opacity: 0.75; }
.fan-note a { color: inherit; }

/* ---- トッピング選択 ---- */
#screen-topping { justify-content: space-between; background: rgba(253, 246, 230, 0.72); }
.topping-head { text-align: center; margin-top: 2%; }
.topping-head h2 { font-size: 6.5cqw; }
#topping-count { font-weight: bold; margin-top: 0.3em; font-size: 3.8cqw; }
#topping-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.6cqw;
  width: 100%;
}
.top-btn {
  border: 1cqw solid var(--ink);
  border-radius: 4.6cqw;
  background: #fff;
  font-family: inherit;
  color: var(--ink);
  padding: 2.6cqw 2cqw;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2.6cqw;
  min-height: 15.9cqw;
  box-shadow: 0 1cqw 0 rgba(90, 61, 36, 0.35);
}
.top-btn .swatch {
  width: 8.7cqw; height: 8.7cqw; border-radius: 50%;
  border: 0.77cqw solid var(--ink); flex-shrink: 0;
}
.top-btn .t-name { font-weight: bold; font-size: 4.6cqw; display: block; }
.top-btn .t-desc { font-size: 2.9cqw; opacity: 0.75; display: block; }
.top-btn.selected {
  background: var(--karashi);
  transform: translateY(0.77cqw);
  box-shadow: 0 0.26cqw 0 rgba(90, 61, 36, 0.35);
}
.topping-foot { margin-bottom: 4%; }

/* ---- まぜ・のばしHUD ---- */
#hud-mix, #hud-stretch { justify-content: flex-start; }
#mix-counter, #stretch-cm {
  margin-top: 4%;
  font-size: 15cqw;
  font-weight: bold;
  text-shadow: 0.05em 0.05em 0 #fff, -0.035em 0.035em 0 #fff, 0.035em -0.035em 0 #fff, -0.035em -0.035em 0 #fff;
  font-variant-numeric: tabular-nums;
}
#mix-counter .unit, #stretch-cm .unit { font-size: 0.4em; margin-left: 0.1em; }
#mix-hint, #stretch-hint {
  font-weight: bold;
  font-size: 4.2cqw;
  text-shadow: 0.12em 0.12em 0 #fff, -0.06em 0.06em 0 #fff;
  margin-top: 0.4em;
  transition: opacity 0.4s;
}
.mix-buttons {
  position: absolute;
  bottom: max(4%, env(safe-area-inset-bottom));
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
}

/* ---- 結果 ---- */
#screen-result { justify-content: center; gap: 4.6cqw; background: rgba(90, 61, 36, 0.35); }
.result-card {
  background: var(--paper);
  border: 1.3cqw solid var(--ink);
  border-radius: 6.2cqw;
  width: 100%;
  padding: 4.6cqw 5.1cqw;
  text-align: center;
  box-shadow: 0 2.1cqw 0 rgba(40, 25, 12, 0.4);
}
.result-head {
  font-weight: bold;
  letter-spacing: 0.3em;
  font-size: 3.6cqw;
  border-bottom: 0.77cqw dashed var(--straw);
  padding-bottom: 1.5cqw;
}
.result-stretch { font-size: 16cqw; font-weight: bold; line-height: 1.15; font-variant-numeric: tabular-nums; }
.result-stretch .unit { font-size: 0.38em; }
.result-compare { font-weight: bold; font-size: 4.4cqw; color: #a0642d; }
.result-rows { margin-top: 2.6cqw; display: flex; justify-content: space-evenly; }
.result-rows .row { font-size: 3.8cqw; }
.result-rows b { font-size: 6cqw; margin: 0 0.5cqw; font-variant-numeric: tabular-nums; }
.result-title { margin-top: 2.1cqw; font-weight: bold; font-size: 5.4cqw; color: #8c2f1b; }
.result-recipe {
  margin-top: 1.5cqw;
  font-family: ui-monospace, "BIZ UDGothic", monospace;
  font-size: 3.4cqw;
  background: #f3e7c9;
  border-radius: 2.1cqw;
  padding: 1cqw;
}
.result-best {
  margin-top: 2.1cqw; font-weight: bold; color: #fff;
  background: var(--accent); border-radius: 999px; padding: 1cqw 2.6cqw;
  font-size: 3.8cqw;
  display: inline-block;
  animation: pulse 0.8s infinite alternate;
}
.result-badge {
  margin-top: 1.5cqw; font-weight: bold;
  font-size: 3.5cqw;
  color: #5a3d24; background: #ffe9a8; border: 0.51cqw solid var(--straw);
  border-radius: 999px; padding: 0.77cqw 2.6cqw; display: inline-block;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.result-buttons { display: flex; flex-direction: column; gap: 3.1cqw; width: 100%; }
.result-buttons .btn { width: 100%; }

/* ---- サウンド切替（全画面共通・右上） ---- */
#btn-mute {
  position: absolute;
  top: max(2.5%, env(safe-area-inset-top));
  right: 3%;
  z-index: 10;
  width: 11cqw;
  height: 11cqw;
  padding: 0;
  border: 0.77cqw solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  font-size: 5cqw;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0.77cqw 0 rgba(90, 61, 36, 0.35);
}
#btn-mute:active { transform: translateY(0.5cqw); box-shadow: 0 0.26cqw 0 rgba(90, 61, 36, 0.35); }
