/* Copyright (c) 2026 Yoda Games. All rights reserved.
   Dirt Flip — the play page. The canvas fills the frame; the clock, the buttons and the cards
   sit over it. Nunito is the site's own font file (already cached by the shell page). */
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 800 900; font-display: swap; src: url(/fonts/nunito-v32-latin.woff2) format('woff2'); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f9be0; overscroll-behavior: none; }
body { font: 800 16px/1.3 Nunito, system-ui, -apple-system, 'Segoe UI', sans-serif; color: #fff; -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#app:focus { outline: none; }                     /* the frame holds the focus while riding (keys are the game's) */
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.hbtn:focus-visible { box-shadow: 0 0 0 7px rgba(8, 14, 28, .85); }   /* a dark rim each side of the white ring: it shows over a white cloud too */

/* ── the track so far */
#prog { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: rgba(8, 14, 28, .28); z-index: 3; }
#prog-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #ffd21f; }
#prog-dot { position: absolute; top: -2px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px #1a2233; left: 0; }
#prog .tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255, 255, 255, .7); }

/* ── clock and buttons */
#hud { position: absolute; left: 0; right: 0; top: 5px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); z-index: 3; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-l { display: flex; justify-content: flex-start; min-width: 0; }
.hud-c { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 14px 5px; border-radius: 14px; background: rgba(8, 14, 28, .6); text-shadow: 0 2px 0 rgba(8, 14, 28, .45); pointer-events: none !important; }   /* a backing: white text stays readable (4.5:1) over the day theme's white clouds */
.hud-r { display: flex; justify-content: flex-end; gap: 7px; }
.pill { padding: 7px 12px; border-radius: 999px; background: rgba(8, 14, 28, .6); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pill b, .pill i { font: inherit; }
/* narrow phones: the number alone; under 340 px the clock and buttons need the whole row */
@media (max-width: 480px) { .pill i { display: none; } .pill { padding: 6px 10px; } }
@media (max-width: 340px) { .hud-l { visibility: hidden; } }
#clock { font-size: 34px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .5px; -webkit-text-stroke: 1px rgba(8, 14, 28, .35); }
#clock.gain { animation: gain .5s ease-out; }
@keyframes gain { 0% { color: #ffe14d; transform: scale(1.28); } 100% { color: #fff; transform: scale(1); } }
.goal { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-variant-numeric: tabular-nums; opacity: .96; }
.st { display: inline-flex; gap: 1px; }
.st i { width: 15px; height: 15px; background: #ffd21f; clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%); display: block; }
.st i.off { background: rgba(255, 255, 255, .34); }
.hbtn { width: 40px; height: 40px; border-radius: 12px; background: rgba(8, 14, 28, .5); display: grid; place-items: center; }
.hbtn svg { width: 22px; height: 22px; fill: currentColor; }
.hbtn:hover { background: rgba(8, 14, 28, .66); }
.hbtn.dark { background: rgba(255, 255, 255, .12); }
#btn-sound[aria-pressed='true'] .cross, #btn-sound[aria-pressed='false'] .wave { display: none; }

/* ── the tip over the start line */
.tip { position: absolute; left: 50%; top: 27%; transform: translateX(-50%); padding: 10px 18px; border-radius: 14px; background: rgba(8, 14, 28, .62); font-size: 18px; text-align: center; white-space: nowrap; z-index: 3; animation: bob 1.4s ease-in-out infinite; }
.tip kbd { display: inline-block; min-width: 26px; padding: 2px 6px; margin: 0 2px; border-radius: 7px; background: #fff; color: #17202f; font: inherit; font-size: 15px; box-shadow: 0 2px 0 #9aa4b5; }
.tip small { display: block; margin-top: 4px; font-size: 13px; opacity: .85; }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }

/* ── touch controls */
.pad { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); z-index: 3; pointer-events: none; }
.pad-l, .pad-r { display: flex; gap: 12px; align-items: flex-end; pointer-events: auto; }
.pbtn { width: 74px; height: 74px; border-radius: 50%; background: rgba(8, 14, 28, .42); border: 2px solid rgba(255, 255, 255, .5); display: grid; place-items: center; font-size: 13px; letter-spacing: .5px; touch-action: none; }
.pbtn svg { width: 40px; height: 40px; fill: currentColor; }
.pbtn.big { width: 92px; height: 92px; background: rgba(18, 168, 112, .62); font-size: 17px; }
.pbtn.small { width: 66px; height: 66px; background: rgba(215, 60, 60, .5); font-size: 12px; }
.pbtn.on { background: rgba(255, 255, 255, .5); transform: scale(.94); }
.pbtn.big.on { background: rgba(18, 168, 112, .95); }
.pbtn.small.on { background: rgba(215, 60, 60, .9); }

/* ── cards */
.card { position: absolute; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 28px)); padding: 20px 20px 18px; border-radius: 22px; background: rgba(13, 20, 36, .9); box-shadow: 0 14px 44px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(255, 255, 255, .08); text-align: center; z-index: 5; }
.card.dock { bottom: max(22px, env(safe-area-inset-bottom)); }
.card.mid { top: 50%; transform: translate(-50%, -50%); }
.card.wide { top: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100% - 20px)); max-height: calc(100% - 20px); display: flex; flex-direction: column; padding: 16px; }
.card h1, .card h2 { margin: 0; font-weight: 900; }
.card h2 { font-size: 26px; }
.logo { font-size: 44px; line-height: 1; letter-spacing: 1px; text-transform: uppercase; font-style: italic; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.logo em { color: #ffd21f; font-style: inherit; }
.sub { margin: 8px 0 14px; font-size: 15px; opacity: .88; }
.hint { margin: 12px 0 0; font-size: 13px; opacity: .7; }
.btn-main { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 56px; padding: 0 34px 0 28px; border-radius: 999px; background: #12A870; color: #04210F; font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; box-shadow: 0 4px 0 #0E8C5C, 0 8px 22px rgba(18, 168, 112, .35); }
.btn-main svg { width: 16px; height: 20px; fill: #04210F; }
.btn-main:hover { transform: translateY(-1px); }
.btn-main:active { transform: translateY(2px); box-shadow: 0 2px 0 #0E8C5C; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.btn-ghost { height: 42px; padding: 0 18px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-size: 15px; }
.btn-ghost:hover { background: rgba(255, 255, 255, .2); }

/* the result */
.badge { position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(-3deg); padding: 5px 14px; border-radius: 999px; background: #ffd21f; color: #2a1c00; font-size: 14px; font-weight: 900; text-transform: uppercase; white-space: nowrap; }
.bigstars { display: flex; justify-content: center; gap: 6px; margin: 10px 0 2px; }
.bigstars i { width: 54px; height: 54px; background: rgba(255, 255, 255, .16); clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%); display: block; }
.bigstars i:nth-child(2) { width: 66px; height: 66px; margin-top: -8px; }
.bigstars i.on { background: #ffd21f; animation: star .45s cubic-bezier(.2, 1.6, .4, 1) both; }
.bigstars i.on:nth-child(2) { animation-delay: .18s; }
.bigstars i.on:nth-child(3) { animation-delay: .36s; }
@keyframes star { 0% { transform: scale(.2) rotate(-40deg); background: #fff; } 100% { transform: none; } }
.time { font-size: 44px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.lines { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 10px 0 16px; }
.lines div { display: flex; justify-content: space-between; gap: 8px; padding: 7px 11px; border-radius: 11px; background: rgba(255, 255, 255, .08); font-size: 15px; }
.lines dt { opacity: .72; }
.lines dd { margin: 0; font-variant-numeric: tabular-nums; }

/* the level grid */
.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-top h2 { flex: none; }
.total { flex: 1; text-align: left; font-size: 15px; opacity: .85; display: inline-flex; align-items: center; gap: 5px; }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; overflow-y: auto; padding: 7px; margin: -5px; }   /* room for the focus ring */
.tile { position: relative; aspect-ratio: 1 / .86; border-radius: 15px; background: rgba(255, 255, 255, .1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 4px; }
.tile:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.tile b { font-size: 26px; line-height: 1; font-weight: 900; }
.tile .nm { font-size: 12.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile .bt { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .9; min-height: 15px; }
.tile .st i { width: 13px; height: 13px; }
.tile.cur { box-shadow: inset 0 0 0 3px #ffd21f; }
.tile:disabled { opacity: .42; cursor: default; }
.tile .lock { width: 20px; height: 20px; fill: currentColor; }

.boot-error { position: fixed; inset: auto 12px 12px 12px; padding: 12px 14px; border-radius: 12px; background: #b3261e; color: #fff; text-align: center; z-index: 9; }

@media (max-width: 640px), (max-height: 460px) {
  #clock { font-size: 27px; }
  .pill { font-size: 12.5px; padding: 6px 10px; }
  .hbtn { width: 36px; height: 36px; border-radius: 10px; }
  .hbtn svg { width: 20px; height: 20px; }
  .logo { font-size: 36px; }
  .tip { font-size: 15px; top: 22%; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .time { font-size: 38px; }
  .bigstars i { width: 44px; height: 44px; }
  .bigstars i:nth-child(2) { width: 54px; height: 54px; }
}
@media (max-height: 460px) {
  .card { padding: 12px 16px; }
  .card.dock { bottom: 10px; }
  .sub { margin: 4px 0 8px; }
  .hint { display: none; }
  .btn-main { height: 46px; font-size: 17px; }
  .bigstars i { width: 34px; height: 34px; }
  .bigstars i:nth-child(2) { width: 42px; height: 42px; margin-top: -5px; }
  .time { font-size: 30px; }
  .lines { margin: 6px 0 10px; }
  .lines div { padding: 4px 10px; }
  .pbtn { width: 62px; height: 62px; }
  .pbtn.big { width: 76px; height: 76px; }
  .pbtn.small { width: 56px; height: 56px; }
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .tip, .bigstars i.on, #clock.gain { animation: none; } }

/* ── back to the flag (stuck) */
.flagbtn { position: absolute; left: 50%; top: 86px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px 9px 12px; border-radius: 999px; background: rgba(13, 20, 36, .82); box-shadow: 0 6px 18px rgba(0, 0, 0, .3), inset 0 0 0 1px rgba(255, 255, 255, .14); font-size: 15px; z-index: 4; white-space: nowrap; animation: pop .25s ease-out; }
.flagbtn svg { width: 20px; height: 20px; fill: #3ddc5a; }
.flagbtn kbd { padding: 1px 6px; border-radius: 6px; background: #fff; color: #17202f; font: inherit; font-size: 12px; box-shadow: 0 2px 0 #9aa4b5; }
.flagbtn:hover { background: rgba(13, 20, 36, .95); }
@keyframes pop { 0% { transform: translateX(-50%) scale(.7); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (pointer: coarse) { .flagbtn kbd { display: none; } }
@media (max-width: 640px), (max-height: 460px) { .flagbtn { top: 74px; font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { .flagbtn { animation: none; } }

/* ── narrow phones: room for the level number beside the clock (360 px, levels 10–12) */
@media (max-width: 480px) { .pill { padding: 6px 8px; } .hud-c { padding-left: 7px; padding-right: 7px; } }
/* ── touch: the small buttons at the top answer a finger 4 px outside them, and stand a little apart */
@media (pointer: coarse) { .hud-r { gap: 10px; } .hbtn { position: relative; } .hbtn::after { content: ''; position: absolute; inset: -4px; } }
/* ── upright phones under 380 px: the two thumb groups keep a gap and GAS stays on screen */
@media (max-width: 380px) { .pbtn { width: 62px; height: 62px; } .pbtn.big { width: 78px; height: 78px; } .pbtn.small { width: 56px; height: 56px; } .pad-l, .pad-r { gap: 8px; } }
/* ── forced colours (Windows High Contrast): the stars are painted shapes, keep the earned ones */
@media (forced-colors: active) { .st i:not(.off), .bigstars i.on { forced-color-adjust: none; background: CanvasText; } }
