/* Chakra Petch (SIL OFL 1.1, see assets/LICENSES.md): display face for title, HUD numbers, headings and buttons. */
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/chakra-petch-400.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 600; font-display: swap; src: url("../assets/fonts/chakra-petch-600.woff2") format("woff2"); }
@font-face { font-family: "Chakra Petch"; font-style: normal; font-weight: 700; font-display: swap; src: url("../assets/fonts/chakra-petch-700.woff2") format("woff2"); }

:root {
  --bg: #0b1020;
  --panel: #121a33;
  --panel-2: #182244;
  --line: rgba(255, 255, 255, .09);
  --ink: #e8ecf8;
  --muted: #8892b0;
  --accent: #ffb347;
  --accent-ink: #1b1204;
  --danger: #ff5e7a;
  --ok: #5ee0a0;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Chakra Petch", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: radial-gradient(ellipse at 50% -10%, #1a2342, var(--bg) 65%) fixed;
  color: var(--ink); font: 15px/1.4 var(--font);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
kbd { font: 600 12px var(--font); padding: 2px 7px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; color: var(--ink); white-space: nowrap; }

#app {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 8px;
}

/* ---------- HUD ---------- */
.hud {
  width: 100%; max-width: 1100px; margin: 0 auto;
  display: grid; align-items: center; gap: 8px 18px;
  grid-template-columns: auto auto auto minmax(150px, 1fr) auto auto auto;
  padding: 8px 14px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-variant-numeric: tabular-nums; position: relative; }
.lbl { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; white-space: nowrap; }
.lbl small { font-size: inherit; opacity: .8; letter-spacing: .06em; }
.stat > b { font-size: 21px; line-height: 1.1; font-weight: 700; }
.lives { display: flex; align-items: center; gap: 5px; height: 23px; }
.life { width: 13px; height: 13px; border-radius: 50%; display: inline-block; transition: transform .2s, opacity .2s; }
.life.on { background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 55%, #d9822b); box-shadow: 0 0 8px rgba(255, 179, 71, .55); }
.life.off { border: 2px solid rgba(255,255,255,.18); opacity: .7; }
.lives-n { font-weight: 700; font-size: 17px; margin-left: 2px; }
.stat.hit .lives { animation: shake .45s; }
.stat.hit .life.off:last-of-type { border-color: var(--danger); }

.claimed { align-self: stretch; justify-content: center; }
.meter { position: relative; height: 10px; border-radius: 6px; background: rgba(255,255,255,.08); overflow: visible; margin: 3px 0; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, #e86a3a, var(--accent)); transition: width .35s cubic-bezier(.2, .8, .2, 1); }
.meter u { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #fff; opacity: .85; border-radius: 1px; text-decoration: none; }
.claimed > b { position: absolute; right: 0; top: -1px; font-size: 13px; color: var(--ink); }
.claimed .lbl { padding-right: 38px; }
.claimed.reached .meter i { background: linear-gradient(90deg, #35c98a, var(--ok)); box-shadow: 0 0 12px rgba(94, 224, 160, .5); }
.claimed.reached > b { color: var(--ok); }

.stat.low > b { color: var(--danger); animation: pulse .7s infinite; }
.stat.low .lbl { color: var(--danger); }
.stat.pop > b { animation: pop .38s cubic-bezier(.2, 1.6, .4, 1); color: var(--accent); }
.score { min-width: 92px; }
.score em { position: absolute; left: 0; top: 100%; font-style: normal; font-size: 12px; font-weight: 700; color: var(--accent); opacity: 0; pointer-events: none; white-space: nowrap; }
.score em.show { animation: float 1s ease-out; }

.actions { display: flex; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; color: var(--ink);
  font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s, transform .1s;
}
.chip:hover:not(:disabled) { border-color: rgba(255, 179, 71, .55); background: #1f2b57; }
.chip:active:not(:disabled) { transform: scale(.95); }
.chip:disabled { opacity: .4; cursor: default; }
.chip.icon { padding: 0; width: 34px; }
.orient { min-width: 112px; justify-content: flex-start; padding-left: 9px; }
.orient-ico { transition: transform .22s cubic-bezier(.3, 1.4, .5, 1); flex: none; color: var(--accent); }
[data-orient="h"] .orient-ico { transform: rotate(90deg); }
#btn-mute .slash { display: none; }
#btn-mute.off .slash { display: block; }
#btn-mute.off .waves { display: none; }
#btn-mute.off { color: var(--muted); }
.chip:focus-visible, .btn:focus-visible, .toggle:focus-visible, .bigturn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- field ---------- */
.stage { flex: 1 1 0; min-height: 0; display: grid; place-items: center; padding: 2px; }
.frame { position: relative; line-height: 0; border-radius: 8px; box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.08), 0 0 60px rgba(255, 179, 71, .05); max-width: 100%; max-height: 100%; }
#field {
  display: block; width: 100% !important; height: 100% !important; border-radius: 8px; cursor: crosshair;
  touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
#field:not(.idle) { cursor: none; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; min-height: 18px; }
.foot i { font-style: normal; opacity: .5; margin: 0 4px; }
.hint-touch, .hint-rotate { display: none; }
.touchbar { display: none; }

/* ---------- touch ---------- */
body.touch .hint-desk { display: none; }
body.touch .hint-touch { display: inline; }
body.touch .touchbar { display: flex; justify-content: center; }
.bigturn {
  display: flex; align-items: center; gap: 12px; width: min(100%, 420px); height: 56px; padding: 0 20px; cursor: pointer;
  background: linear-gradient(180deg, #243061, #1a2348); border: 1px solid rgba(255, 179, 71, .45); border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); touch-action: manipulation; text-align: left;
}
.bigturn:active { transform: scale(.98); background: #2a3870; }
.bigturn span { display: flex; flex-direction: column; line-height: 1.2; }
.bigturn b { font-size: 16px; }
.bigturn small { color: var(--muted); font-size: 12px; }
@media (orientation: portrait) { body.touch .hint-rotate { display: inline; } body.touch .hint-touch { display: none; } }
/* Landscape phone: a round turn button in the side margin (the field is narrower than the screen), never over the field. */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch .touchbar { position: fixed; right: max(12px, env(safe-area-inset-right)); top: 50%; transform: translateY(-30%); }
  body.touch .bigturn { width: 64px; height: 64px; padding: 0; justify-content: center; border-radius: 50%; }
  body.touch .bigturn span { display: none; }
  .foot { display: none; }
  body.touch .stage { padding-right: calc(64px + 16px + env(safe-area-inset-right)); padding-left: calc(64px + 16px + env(safe-area-inset-left)); }
}
body.touch .orient { min-width: 34px; padding: 0 8px; }

/* ---------- responsive HUD ---------- */
@media (max-width: 860px) {
  .hud { grid-template-columns: auto auto 1fr auto auto; padding: 8px 12px; gap: 8px 14px; }
  .brand { grid-column: 1 / 3; }
  .actions { grid-column: 3 / -1; justify-self: end; }
  #stat-level { grid-row: 2; grid-column: 1; } #stat-lives { grid-row: 2; grid-column: 2; } #stat-claimed { grid-row: 2; grid-column: 3; }
  #stat-time { grid-row: 2; grid-column: 4; } #stat-score { grid-row: 2; grid-column: 5; }
  h1 { font-size: 15px; }
}
@media (max-width: 640px) {
  .hud { grid-template-columns: repeat(4, auto) ; justify-content: space-between; gap: 8px 10px; }
  .brand { grid-column: 1 / 3; }
  .actions { grid-column: 3 / -1; justify-self: end; }
  #stat-level { grid-row: 2; grid-column: 1; }
  #stat-lives { grid-row: 2; grid-column: 2; }
  #stat-time { grid-row: 2; grid-column: 3; }
  #stat-score { grid-row: 2; grid-column: 4; }
  #stat-claimed { grid-row: 3; grid-column: 1 / -1; }
  .claimed > b { top: -2px; }
  .stat > b { font-size: 18px; }
  .orient span { display: none; }
  .orient { min-width: 34px; padding: 0 8px; }
  .score { min-width: 0; }
}
@media (max-height: 520px) {
  #app { gap: 4px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .hud { max-width: none !important; display: flex; align-items: center; gap: 4px 16px; padding: 4px 10px; }
  .brand h1 { display: none; }
  .brand { order: 0; }
  .claimed { flex: 1 1 120px; align-self: center; }
  .claimed > b { top: -3px; }
  .actions { margin-left: auto; }
  .stat > b { font-size: 16px; }
  .lives { height: 19px; }
  .lbl { font-size: 9px; }
  .chip { height: 30px; }
  .orient span { display: none; }
  .orient { min-width: 30px; padding: 0 7px; }
  .card { padding: 16px 18px 14px; gap: 8px; }
  .card h2 { font-size: 24px; }
  .wordmark { font-size: 28px !important; }
  .big-logo { width: 40px; height: 40px; }
  .bigstat b { font-size: 36px; }
  .tally { gap: 3px; } .tally div { padding: 3px 12px; font-size: 14px; }
  .btn { min-height: 42px; }
  .title-card { width: min(100%, 560px); }
  .title-card .stack { flex-direction: row; }
  .title-card .stack .btn { padding: 0 8px; font-size: 15px; }
  .title-card .pitch { max-width: none; font-size: 14px; }
  .steps { gap: 4px; font-size: 13.5px; }
  .controls { padding-top: 8px; }
  .scores td { padding: 4px 8px; }
}

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(7, 10, 22, .74); backdrop-filter: blur(5px) saturate(1.1); -webkit-backdrop-filter: blur(5px) saturate(1.1);
  overflow-y: auto; user-select: none;
}
.overlay[hidden] { display: none; }
.overlay[data-screen="title"] { background: radial-gradient(ellipse at 50% 30%, rgba(26, 35, 66, .86), rgba(7, 10, 22, .93)); }
.overlay[data-screen="pause"] { background: rgba(7, 10, 22, .9); }
.card {
  width: min(100%, 400px); margin: auto; padding: 26px 26px 22px; text-align: center;
  background: linear-gradient(180deg, #172044, #101733); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.card.wide { width: min(100%, 560px); }
.card.enter { animation: rise .32s cubic-bezier(.2, .9, .3, 1); }
.card h2 { margin: 0; font-size: 32px; line-height: 1.05; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
.card h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.card p { margin: 0; }
.wordmark { font-size: 40px !important; letter-spacing: .18em !important; margin-right: -.18em; }
.big-logo { filter: drop-shadow(0 6px 18px rgba(255, 179, 71, .3)); }
.pitch { color: #c4cbe4; max-width: 30ch; font-size: 16px; }
.fine { color: var(--muted); font-size: 13.5px; }
.fine b { color: var(--ink); }
.eyebrow { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 4px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; margin-top: 6px; }
.btn {
  min-height: 48px; padding: 0 22px; border-radius: 12px; cursor: pointer; font-size: 16px; font-weight: 700; letter-spacing: .02em;
  background: var(--panel-2); border: 1px solid var(--line); transition: transform .1s, background .15s, border-color .15s, box-shadow .15s;
}
.stack .btn { width: 100%; }
.btn:hover { border-color: rgba(255, 179, 71, .5); background: #1f2b57; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffc267, var(--accent)); color: var(--accent-ink); border-color: #ffd08a; box-shadow: 0 6px 22px rgba(255, 179, 71, .28); }
.btn.primary:hover { background: linear-gradient(180deg, #ffcb7c, #ffb94f); box-shadow: 0 8px 28px rgba(255, 179, 71, .4); }
.btn.danger.armed { background: #5b1a2b; border-color: var(--danger); color: #ffd7de; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); min-height: 38px; font-size: 14px; font-weight: 600; }
.btn.ghost:hover { color: var(--ink); background: rgba(255,255,255,.05); }

.settings { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; align-items: center; margin-top: 4px; }
.toggle { display: inline-flex; align-items: center; gap: 9px; background: none; border: 0; padding: 6px 4px; cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
.toggle:hover { color: var(--ink); }
.toggle .sw { width: 34px; height: 20px; border-radius: 11px; background: var(--accent); position: relative; transition: background .2s; flex: none; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 17px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle[aria-pressed="true"] .sw { background: #3a4570; }
.toggle[aria-pressed="true"] .sw::after { left: 3px; }
.vol { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
.vol input { width: 110px; accent-color: var(--accent); }

.steps { text-align: left; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; color: #c4cbe4; font-size: 15px; }
.steps b { color: var(--ink); }
.steps li::marker { color: var(--accent); font-weight: 700; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; text-align: left; padding-top: 12px; border-top: 1px solid var(--line); }
.controls p { color: #c4cbe4; font-size: 13.5px; margin-bottom: 5px; }
@media (max-width: 520px) { .controls { grid-template-columns: 1fr; } .card { padding: 22px 18px 18px; } .card h2 { font-size: 27px; } .wordmark { font-size: 32px !important; } }

.bigstat { display: flex; flex-direction: column; align-items: center; margin: 2px 0 4px; }
.bigstat b { font-size: 52px; line-height: 1; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(255, 179, 71, .35); }
.bigstat span { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.tally { margin: 4px 0 2px; width: 100%; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.tally div { display: flex; justify-content: space-between; padding: 6px 12px; border-radius: 9px; background: rgba(255,255,255,.04); font-size: 15px; }
.tally dt { color: var(--muted); } .tally dd { margin: 0; font-weight: 700; }
.tally .sub { background: none; padding: 0 12px; font-size: 13.5px; } .tally .sub dd { font-weight: 600; color: #c4cbe4; }
.tally .bonus dd { color: var(--accent); }
.tally .total { background: rgba(255, 179, 71, .1); border: 1px solid rgba(255, 179, 71, .3); font-size: 17px; } .tally .total dt { color: var(--ink); }

.banner { color: var(--accent); font-weight: 700; padding: 6px 14px; border-radius: 999px; background: rgba(255, 179, 71, .1); border: 1px solid rgba(255, 179, 71, .3); font-size: 14px; }
.nameform { width: 100%; text-align: left; }
.nameform label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.namerow { display: flex; gap: 8px; margin-top: 6px; }
.namerow input { flex: 1; min-width: 0; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #0b1020; color: var(--ink); font: 700 18px var(--font); padding: 0 14px; user-select: text; -webkit-user-select: text; }
.namerow input:focus { border-color: var(--accent); }

.scores { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14.5px; text-align: left; }
.scores th { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 4px 8px; }
.scores td { padding: 7px 8px; border-top: 1px solid var(--line); }
.scores .rank { color: var(--muted); width: 28px; text-align: right; }
.scores .nm { font-weight: 700; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores .sc, .scores th:nth-child(3) { text-align: right; }
.scores .lv, .scores th:nth-child(4) { text-align: center; color: var(--muted); }
.scores .dt { color: var(--muted); text-align: right; font-size: 13px; }
.scores tr:first-child .rank { color: var(--accent); font-weight: 800; }
.scores tr.fresh td { background: rgba(255, 179, 71, .14); color: var(--accent); border-top-color: rgba(255, 179, 71, .35); }
.scores tr.fresh td:first-child { border-radius: 8px 0 0 8px; } .scores tr.fresh td:last-child { border-radius: 0 8px 8px 0; }
.scores tr.fresh { animation: glow 1.4s ease-out; }
.empty { color: var(--muted); padding: 18px 0; }
@media (max-width: 420px) { .scores .dt, .scores th:nth-child(5) { display: none; } }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(1.12); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes float { 0% { opacity: 0; transform: translateY(-2px); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }
@keyframes glow { 0% { box-shadow: inset 0 0 0 999px rgba(255, 179, 71, .35); } 100% { box-shadow: inset 0 0 0 999px rgba(255, 179, 71, 0); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- juice (polish slice) ---------- */
h1, .stat > b, .claimed > b, .card h2, .bigstat b, .btn, .eyebrow, .wordmark, .tally .total, .banner, .score em, .bigturn b, .chip { font-family: var(--display); }
h1, .card h2, .bigstat b { font-weight: 700; }
.stat > b, .bigstat b { font-variant-numeric: tabular-nums; }

/* The level-clear and game-over cards must not hide the confetti, shimmer and desaturation playing behind them. */
.overlay[data-screen="levelClear"] { background: radial-gradient(ellipse at 50% 50%, rgba(7, 10, 22, .5), rgba(7, 10, 22, .28)); backdrop-filter: none; -webkit-backdrop-filter: none; }
.overlay[data-screen="gameOver"] { background: rgba(7, 10, 22, .5); backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px); }

/* Level-clear tally lines arrive one by one. */
.overlay[data-screen="levelClear"] .tally > div { opacity: 0; animation: tallyIn .32s cubic-bezier(.2, .9, .3, 1) forwards; animation-delay: calc(.75s + var(--i, 0) * .12s); }
.overlay[data-screen="levelClear"] .card > h2 { animation: stamp .5s cubic-bezier(.2, 1.5, .4, 1) .05s both; }
.overlay[data-screen="levelClear"] .bigstat b { animation: stamp .5s cubic-bezier(.2, 1.5, .4, 1) .25s both; }
.overlay[data-screen="gameOver"] .card > h2 { animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) .05s both; }

/* New best: gold shimmer on the score and the banner. */
.bigstat.best b { background: linear-gradient(100deg, #ffb347 20%, #fff3cf 45%, #ffb347 70%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; animation: shine 2.2s linear infinite; filter: drop-shadow(0 0 14px rgba(255, 179, 71, .55)); }
.banner.best { color: #1b1204; background: linear-gradient(180deg, #ffd08a, var(--accent)); border-color: #ffe0ae; animation: stamp .55s cubic-bezier(.2, 1.5, .4, 1) .3s both, glowpulse 1.6s ease-in-out 1s infinite; }

/* HUD: the claim meter flares when it grows. */
.claimed.pop .meter i { animation: meterflare .5s ease-out; }
.stat.pop > b { transform-origin: 50% 70%; }

@keyframes tallyIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes stamp { 0% { opacity: 0; transform: scale(1.5); } 60% { opacity: 1; transform: scale(.94); } 100% { opacity: 1; transform: none; } }
@keyframes drop { 0% { opacity: 0; transform: translateY(-26px); } 100% { opacity: 1; transform: none; } }
@keyframes shine { to { background-position: -220% 0; } }
@keyframes glowpulse { 0%, 100% { box-shadow: 0 0 0 rgba(255, 179, 71, 0); } 50% { box-shadow: 0 0 22px rgba(255, 179, 71, .55); } }
@keyframes meterflare { 0% { filter: brightness(1.9) saturate(1.3); box-shadow: 0 0 16px rgba(255, 200, 120, .9); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) {
  .overlay[data-screen="levelClear"] .tally > div { opacity: 1; animation: none; }
  .bigstat.best b, .banner.best { animation: none; }
}
.btn-sub { font-size: .72em; font-weight: 600; opacity: .7; margin-left: 6px; letter-spacing: .02em; }

/* ---------- short screens (QA pass) ----------
   The compact card rules in the earlier (max-height: 520px) block lose to the base .card rules above (same specificity,
   later wins), so on a landscape phone the level-clear card was taller than the screen and its Next button sat below the fold.
   These come last so they apply. The result cards go two-column instead of just shrinking. */
@media (max-height: 520px) {
  .overlay { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .card { padding: 14px 18px 12px; gap: 6px; border-radius: 14px; }
  .card h2 { font-size: 24px; }
  .card h3 { margin-bottom: 3px; }
  .eyebrow { font-size: 11px; }
  .wordmark { font-size: 28px !important; }
  .pitch { font-size: 14px; max-width: none; }
  .big-logo { width: 40px; height: 40px; }
  .btn { min-height: 40px; padding: 0 18px; font-size: 15px; }
  .btn.ghost { min-height: 32px; }
  .row { margin-top: 2px; }
  .stack { gap: 6px; margin-top: 0; }
  .bigstat { margin: 0; }
  .bigstat b { font-size: 36px; }
  .bigstat span { margin-top: 2px; font-size: 12.5px; }
  .tally { gap: 3px; margin: 0; }
  .tally div { padding: 3px 12px; font-size: 14px; }
  .tally .total { font-size: 15px; }
  .banner { padding: 3px 12px; font-size: 13px; }
  .namerow { margin-top: 3px; }
  .namerow input { height: 40px; font-size: 16px; }
  .settings { gap: 2px 12px; margin-top: 0; }
  .toggle { padding: 3px 4px; }
  .scores td { padding: 4px 8px; }
  .steps { gap: 4px; font-size: 13.5px; }
  .controls p { font-size: 13px; margin-bottom: 3px; }
  .title-card { width: min(100%, 560px); }
}
/* The two-column layouts need width as well as shortness (a narrow window with the keyboard up is also short). */
@media (max-height: 520px) and (min-width: 560px) {
  /* How to play: instructions on the left, controls on the right. */
  .card.wide:has(.steps) { width: min(100%, 780px); display: grid; grid-template-columns: 1.15fr 1fr; column-gap: 20px; text-align: left; align-items: start; }
  .card.wide:has(.steps) > h2 { grid-column: 1 / -1; text-align: center; }
  .card.wide:has(.steps) > .steps { grid-column: 1; }
  .card.wide:has(.steps) > .controls { grid-column: 2; grid-template-columns: 1fr; border-top: 0; padding-top: 0; }
  .card.wide:has(.steps) > .row { grid-column: 1 / -1; }
  /* Pause: the four buttons in two columns. */
  .overlay[data-screen="pause"] .stack { display: grid; grid-template-columns: 1fr 1fr; }
  /* Level clear: headline and score on the left, tally on the right, the button under both. */
  .overlay[data-screen="levelClear"] .card { width: min(100%, 640px); display: grid; grid-template-columns: 1fr 1.25fr; column-gap: 22px; align-items: center; justify-items: center; }
  .overlay[data-screen="levelClear"] .card > .eyebrow { grid-column: 1; grid-row: 1; }
  .overlay[data-screen="levelClear"] .card > h2 { grid-column: 1; grid-row: 2; }
  .overlay[data-screen="levelClear"] .card > .bigstat { grid-column: 1; grid-row: 3; }
  .overlay[data-screen="levelClear"] .card > .tally { grid-column: 2; grid-row: 1 / 4; }
  .overlay[data-screen="levelClear"] .card > .row { grid-column: 1 / -1; grid-row: 4; }
}
