/* One-screen arcade shell: HUD, ticker, popup, scrims and cards float around a full-height canvas. */

.app { height: 100%; display: flex; flex-direction: column; max-width: 540px; margin: 0 auto; }

/* HUD */
.hud { flex: none; background: var(--bg); border-bottom: 1px solid var(--line); }
.hud-inner {
  display: flex; align-items: center; gap: 12px;
  padding-block: 9px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.hearts { display: flex; gap: 5px; }
.hearts svg { width: 30px; height: 27px; display: block; transition: transform .15s ease; }
.hearts.low svg { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.score { flex: 1; font-family: var(--font-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; text-align: center; }
.icon-button {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
  display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none;
}
.icon-button:focus-visible, .button:focus-visible, .chip-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Playfield */
.stage { flex: 1; position: relative; min-height: 0; overflow: hidden; background: var(--field-bottom); }
#field { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }

/* Ticker: one message at a time, in its own strip under the HUD, so nothing covers the play area */
.ticker {
  height: 40px; border-top: 1px solid var(--line); display: flex; align-items: center; overflow: hidden;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.ticker .inner { display: flex; align-items: center; gap: 8px; min-width: 0; width: 100%; font-weight: 700; font-size: 13.5px; animation: ticker-in .2s ease both; }
.ticker .inner.leaving { opacity: 0; transition: opacity .25s ease; }
.ticker .inner.good { color: var(--good); }
.ticker .inner.mid { color: var(--mid); }
.ticker .inner.bad { color: var(--bad); }
.ticker .inner.hint { color: var(--accent); }
.ticker img { width: 24px; height: 24px; flex: none; }
.ticker .text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.ticker .text > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticker small { font-weight: 500; font-size: 11.5px; color: var(--muted); }
@keyframes ticker-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Bad-food popup: timed card, play continues under it */
.popup {
  position: absolute; top: 14%; left: 50%; transform: translateX(-50%); width: min(92%, 340px);
  background: var(--panel); color: var(--fg); border: 1px solid var(--bad); border-radius: 16px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--shade) 22%, transparent);
  padding: 12px 14px 10px; pointer-events: none; animation: pop-in .25s cubic-bezier(.2,.9,.3,1.3) both;
  overflow: hidden;
}
.popup .row { display: flex; gap: 12px; align-items: center; }
.popup img { width: 52px; height: 52px; flex: none; }
.popup .body { min-width: 0; }
.popup h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 18px; font-weight: 800; line-height: 1.15; text-wrap: balance; }
.popup .fodmap { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--bad); background: var(--bad-soft); padding: 2px 9px 2px 3px; border-radius: 999px; line-height: 1; }
.popup .letter { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: var(--panel); font-size: 11px; font-weight: 800; font-family: system-ui, sans-serif; }
.popup p { margin: 6px 0 0; font-size: 14px; line-height: 1.35; color: var(--fg); }
.popup .timer { position: absolute; right: 0; bottom: 0; height: 4px; background: var(--bad); width: 100%; animation: shrink var(--dur, 3.2s) linear forwards; transform-origin: right; }
@keyframes shrink { to { transform: scaleX(0); } }
@keyframes pop-in { from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.9); } to { opacity: 1; transform: translateX(-50%); } }

/* Big-moment card: centred, gold, play continues under it */
.banner {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%); width: min(88%, 320px);
  display: flex; gap: 12px; align-items: center;
  background: var(--panel); color: var(--fg); border: 2px solid var(--mid); border-radius: 18px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--mid) 22%, transparent), 0 14px 34px color-mix(in srgb, var(--shade) 26%, transparent);
  padding: 12px 16px; pointer-events: none; animation: pop-in .3s cubic-bezier(.2,.9,.3,1.4) both;
}
.banner img { width: 64px; height: 64px; flex: none; object-fit: contain; }
.banner h2 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--mid); }
.banner strong { display: block; font-size: 15px; font-weight: 800; margin-top: 2px; }
.banner p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.3; color: var(--muted); }

/* Scrims: start, pause, summary */
.scrim {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: auto;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding-block: 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.card { width: 100%; max-width: 380px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* The title and its sentence read as one block; the rules and the action each get room of their own. */
.card h1 + p { margin-top: -6px; }
.card .legend { margin-top: 4px; }
.card .legend + .button, .card .legend + .stats { margin-top: 8px; }
.card .beti { width: min(44vw, 170px); height: auto; filter: drop-shadow(0 10px 16px color-mix(in srgb, var(--shade) 20%, transparent)); }
.card h1, .card h2 { margin: 0; font-family: var(--font-display); font-weight: 800; text-wrap: balance; line-height: 1.15; }
.card h1 { font-size: clamp(28px, 7.5vw, 36px); color: var(--accent); }
.card h2 { font-size: 26px; color: var(--accent); }
.card p { margin: 0; color: var(--muted); max-width: 30ch; }
/* The rules as a two-column grid in reading order, not a cloud of pills. An odd last rule takes the whole row. */
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
.legend > .chip:last-child:nth-child(odd) { grid-column: 1 / -1; }
.chip {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border-radius: 14px; border: 1.5px solid;
  font-size: 13.5px; font-weight: 700; line-height: 1.2; text-align: start; text-wrap: balance;
}
.chip img { width: 28px; height: 28px; flex: none; object-fit: contain; }
.chip.good { color: var(--good); background: var(--good-soft); border-color: var(--good-signal); }
.chip.mid { color: var(--mid); background: var(--mid-soft); border-color: var(--mid-signal); }
.chip.bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad-signal); }
/* Rules as short sentences in groups: the bold part says what happened, in its level's colour; the rest says what it does. */
.rules { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.card .rules { margin-top: 4px; }
.card .rules + .button, .card .rules + .stats { margin-top: 8px; }
.rule-group { list-style: none; margin: 0; padding: 4px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.rule { display: flex; align-items: center; gap: 10px; min-height: 36px; padding-block: 3px; font-size: 14px; line-height: 1.3; text-align: start; color: var(--fg); }
.rule + .rule { border-top: 1px solid var(--line); }
.rule img { width: 26px; height: 26px; flex: none; object-fit: contain; }
.rule b { font-weight: 800; }
.rule.good b { color: var(--good); }
.rule.mid b { color: var(--mid); }
.rule.bad b { color: var(--bad); }
.button {
  border: 0; border-radius: 999px; padding: 13px 36px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 800; font-size: 18px; cursor: pointer; transition: transform .15s ease, filter .15s ease;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.button:hover { filter: brightness(1.05); }
.button:active { transform: scale(.97); }
.sub { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip-button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px; font-size: 13.5px; font-weight: 700; cursor: pointer; color: var(--fg);
}
.chip-button svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip-button:active { transform: scale(.97); }
.chip-button[aria-pressed="false"] { color: var(--muted); }
.stats { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fg); }
.stats b { color: var(--accent); font-size: 30px; font-weight: 800; display: block; line-height: 1; font-variant-numeric: tabular-nums; }
.culprits { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: start; }
.culprits li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 14px; min-width: 0; }
.culprits img { width: 30px; height: 30px; flex: none; }
.culprits .name { font-weight: 700; }
.culprits .why { color: var(--muted); font-size: 13px; }
.culprits .count { margin-inline-start: auto; font-weight: 800; color: var(--bad); font-variant-numeric: tabular-nums; }
.culprits-title { font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 4px; }

@media (min-width: 600px) {
  .app { padding-block: 12px; }
  .hud { border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
  .stage { border: 1px solid var(--line); border-radius: 0 0 18px 18px; }
}
/* Short phones: a smaller Beti keeps the play button on the first screen. */
@media (max-height: 720px) {
  .card .beti { width: min(30vw, 112px); }
  .card { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker .inner, .popup, .banner { animation-duration: .01s; }
  .button, .chip-button { transition: none; }
  .button:active, .chip-button:active { transform: none; }
  .popup .timer { animation-duration: var(--dur, 3.2s); }
  .hearts.low svg { animation: none; }
}

/* Arrow buttons get their own strip under the stage, so they never cover the game. */
.arrows { flex: none; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; padding: 10px 12px; background: var(--bg); border-top: 1px solid var(--line); }
.arrow { display: grid; place-items: center; height: 68px; padding: 0; border: 0; border-radius: 18px; background: var(--accent); color: var(--accent-ink); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.arrow:active { filter: brightness(1.2); transform: scale(.97); }
.arrow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.arrow svg { width: 40px; height: 40px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
