/* Baked Mochocho griddle game. Layout targets iPhone portrait first (390–430 CSS px). */
:root {
  --bm-night: #1b130e;
  --bm-wood: #2b1d14;
  --bm-cream: #fff4dc;
  --bm-gold: #f2b54a;
  --bm-brown: #9a5424;
  --bm-red: #d8462d;
  --bm-ink: #fff9ee;
  --bm-muted: #e9d6b8;
  --bm-glass: rgb(27 19 14 / 72%);
  --bm-line: rgb(255 236 204 / 18%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --heat: 0.6;
  --temp: 0.5;
  color-scheme: dark;
}

html,
body.game-body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bm-night);
  color: var(--bm-ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.game-body {
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

button,
input,
a {
  touch-action: manipulation;
}

.hud-top {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  display: grid;
  grid-template-columns: 44px 1fr auto 44px;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.hud-back,
.hud-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--bm-line);
  background: var(--bm-glass);
  color: var(--bm-ink);
  font-size: 1.25rem;
  text-decoration: none;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.order-card,
.hud-stats {
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 14px;
  border: 1px solid var(--bm-line);
  background: var(--bm-glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.order-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.order-label,
.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--bm-muted);
}

.order-items {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-count {
  font-size: 0.68rem;
  color: var(--bm-muted);
  font-variant-numeric: tabular-nums;
}

.hud-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.stat {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.hud-side {
  position: fixed;
  right: calc(var(--safe-right) + 12px);
  top: calc(var(--safe-top) + 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.thermo {
  position: relative;
  width: 14px;
  height: 120px;
  border-radius: 7px;
  background: rgb(255 255 255 / 12%);
  border: 1px solid var(--bm-line);
  overflow: hidden;
}

.thermo-fill {
  position: absolute;
  inset: auto 0 0;
  height: calc(var(--temp) * 100%);
  background: linear-gradient(to top, #f6d36b, #f08a2c 55%, #d8462d);
  transition: height 0.25s linear;
}

.thermo-value {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px #000;
}

.tool.is-next {
  border-color: var(--bm-gold);
  box-shadow:
    0 0 0 2px var(--bm-gold),
    0 0 18px rgb(255 200 90 / 55%);
}

@media (prefers-reduced-motion: no-preference) {
  .tool.is-next {
    animation: next-pulse 1.2s ease-in-out infinite;
  }
}

@keyframes next-pulse {
  50% {
    box-shadow:
      0 0 0 3px var(--bm-gold),
      0 0 26px rgb(255 200 90 / 75%);
  }
}

.guide {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 64px);
  transform: translateX(-50%);
  max-width: min(86vw, 420px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgb(255 244 220 / 92%);
  color: #3a2212;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  box-shadow: 0 6px 22px rgb(0 0 0 / 35%);
  pointer-events: none;
}

.guide:empty,
.caption:empty {
  display: none;
}

.caption {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 172px);
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgb(0 0 0 / 55%);
  color: var(--bm-cream);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.pair-chips {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.pair-chip {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--bm-glass);
  border: 1px solid var(--bm-line);
  font-size: 0.72rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.pair-chip[data-tone='good'] {
  border-color: #f2b54a;
  color: #ffe2a3;
}

.pair-chip[data-tone='warn'] {
  border-color: #ff7b52;
  color: #ffc1a8;
}

.hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 10px)
    calc(var(--safe-left) + 10px);
  background: linear-gradient(to top, rgb(20 13 9 / 92%), rgb(20 13 9 / 0%));
}

.heat-row {
  display: grid;
  grid-template-columns: auto 1fr 28px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.heat-label {
  font-size: 0.8rem;
  color: var(--bm-muted);
}

.heat {
  width: 100%;
  height: 44px;
  accent-color: var(--bm-gold);
  margin: 0;
}

.heat-flame {
  width: 22px;
  height: calc(10px + var(--heat) * 18px);
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 50% 75%, #fff6c8 0 18%, #6fb3ff 19% 38%, #2f62e0 70%);
  opacity: calc(0.35 + var(--heat) * 0.65);
  justify-self: center;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 6px 2px;
  border-radius: 14px;
  border: 1px solid var(--bm-line);
  background: rgb(43 29 20 / 86%);
  color: var(--bm-ink);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  transition:
    transform 0.08s ease-out,
    background-color 0.15s;
}

.tool:active {
  transform: scale(0.94);
}

.tool[aria-pressed='true'] {
  background: linear-gradient(#f6c46a, #e09a3b);
  color: #2d1608;
  border-color: #ffdca0;
}

.tool:disabled {
  opacity: 0.4;
}

.tool-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.tool-icon-oil {
  background: radial-gradient(circle at 35% 30%, #fff8c0, #e9c34b 45%, #a77a12);
}

.tool-icon-batter {
  background: radial-gradient(circle at 40% 35%, #fffaf0, #f3dfb4 55%, #d9bd85);
}

.tool-icon-filling {
  background: var(--filling-color, #5a2523);
  box-shadow: inset 0 -3px 6px rgb(0 0 0 / 35%);
}

.tool-icon-flip {
  border-radius: 6px;
  background: linear-gradient(135deg, #e0e0e0, #8a8f96);
  transform: rotate(-20deg);
}

.tool-icon-serve {
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(#c9762f, #8b4a1c 55%, #f6e6c2 56%, #f0d9a8);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: radial-gradient(circle at 50% 30%, rgb(60 34 18 / 55%), rgb(10 7 5 / 82%));
  overflow-y: auto;
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  margin: auto;
  width: min(100%, 420px);
  box-sizing: border-box;
  padding: 24px 20px;
  border-radius: 24px;
  border: 1px solid var(--bm-line);
  background: rgb(36 24 17 / 94%);
  box-shadow: 0 24px 60px rgb(0 0 0 / 45%);
  text-align: center;
}

.overlay-card .eyebrow {
  color: var(--bm-gold);
  margin: 0 0 6px;
}

.title-logo {
  margin: 0;
  line-height: 1;
}

.title-small {
  display: block;
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  color: var(--bm-muted);
}

.title-main {
  display: block;
  margin-top: 6px;
  font-size: clamp(2.1rem, 11vw, 3rem);
  font-weight: 900;
  color: #ffd27a;
  text-shadow:
    0 2px 0 #8b4a1c,
    0 6px 18px rgb(242 140 40 / 45%);
}

.title-copy,
.result-comment,
.menu-note {
  color: var(--bm-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.engine-line,
.save-line {
  min-height: 1.2em;
  font-size: 0.78rem;
  color: var(--bm-muted);
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
}

.primary-button {
  background: linear-gradient(#ffd27a, #f09a37);
  color: #2d1608;
  box-shadow: 0 8px 24px rgb(240 154 55 / 35%);
}

.primary-button:disabled {
  opacity: 0.5;
}

.secondary-button {
  background: transparent;
  color: var(--bm-ink);
  border: 1px solid var(--bm-line);
}

.text-button {
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--bm-muted);
  font: inherit;
  text-decoration: underline;
}

.result-title {
  margin: 0;
  font-size: 1.6rem;
}

.result-stars {
  margin: 6px 0 0;
  font-size: 1.8rem;
  letter-spacing: 0.15em;
  color: #ffd27a;
}

.result-score {
  margin: 4px 0 10px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.result-preview {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 10;
  height: auto;
  border-radius: 16px;
  background: #120c08;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  margin: 12px 0;
  text-align: left;
  font-size: 0.85rem;
}

.result-grid dt {
  color: var(--bm-muted);
}

.result-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  text-align: left;
}

.switch-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--bm-gold);
}

.menu-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 112px);
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: #fff4dc;
  color: #3a2212;
  font-weight: 700;
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
}

.load-error {
  position: fixed;
  inset: auto 16px calc(var(--safe-bottom) + 16px);
  padding: 12px;
  border-radius: 12px;
  background: #5a1b14;
  color: #ffe3dc;
}

#requirements .requirement-banner {
  margin: 12px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgb(0 0 0 / 25%);
  text-align: left;
  font-size: 0.78rem;
  color: var(--bm-cream);
}

#requirements .requirement-banner h2 {
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--bm-gold);
}

#requirements .requirement-banner ul {
  margin: 0;
  padding-left: 1.2em;
}

#requirements .requirement-banner a {
  color: var(--bm-gold);
}

#requirements .requirement-banner.is-required {
  border: 1px solid var(--bm-red);
}

@media (orientation: landscape) and (max-height: 520px) {
  .hud-bottom {
    left: auto;
    width: min(46vw, 420px);
    background: none;
  }

  .caption {
    bottom: calc(var(--safe-bottom) + 12px);
    left: 30%;
  }

  .tool.is-next {
    border-color: var(--bm-gold);
    box-shadow:
      0 0 0 2px var(--bm-gold),
      0 0 18px rgb(255 200 90 / 55%);
  }

  @media (prefers-reduced-motion: no-preference) {
    .tool.is-next {
      animation: next-pulse 1.2s ease-in-out infinite;
    }
  }

  @keyframes next-pulse {
    50% {
      box-shadow:
        0 0 0 3px var(--bm-gold),
        0 0 26px rgb(255 200 90 / 75%);
    }
  }

  .guide {
    top: auto;
    bottom: calc(var(--safe-bottom) + 56px);
    left: calc(var(--safe-left) + 12px);
    transform: none;
    max-width: min(40vw, 320px);
    border-radius: 16px;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool,
  .thermo-fill {
    transition: none;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .overlay-card {
    width: min(100%, 560px);
    padding: 14px 18px;
  }

  .title-logo {
    font-size: 2.2rem;
  }

  .title-copy {
    font-size: 0.85rem;
    margin: 6px 0;
  }

  .result-title {
    font-size: 1.25rem;
    margin: 2px 0;
  }

  .result-stars {
    font-size: 1.1rem;
    margin: 2px 0;
  }

  .result-score {
    margin: 2px 0;
  }

  .result-preview {
    max-width: 190px;
    margin: 6px auto;
  }

  .result-grid {
    margin: 6px 0;
    font-size: 0.78rem;
    gap: 2px 12px;
  }

  .result-comment {
    font-size: 0.8rem;
    margin: 6px 0 10px;
  }
}

/* Action judgement labels float over the griddle and must never intercept
   pointer input — everything is anchored to the stage overlay. */
.judges {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}
.judge {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 3px rgb(0 0 0 / 65%);
  pointer-events: none;
  animation: judge-pop 0.9s ease-out forwards;
}
.judge-perfect {
  color: var(--bm-gold);
  background: rgb(46 30 6 / 72%);
  box-shadow: 0 0 16px rgb(255 200 90 / 60%);
}
.judge-good {
  color: var(--bm-cream);
  background: rgb(30 24 14 / 70%);
  font-size: 1rem;
}
.judge-miss {
  color: #ff9a7a;
  background: rgb(40 14 6 / 72%);
  font-size: 1rem;
}
@keyframes judge-pop {
  0% {
    opacity: 0;
    scale: 0.5;
  }
  18% {
    opacity: 1;
    scale: 1.25;
  }
  30% {
    scale: 1;
  }
  75% {
    opacity: 1;
    translate: 0 -18px;
  }
  100% {
    opacity: 0;
    translate: 0 -42px;
  }
}
