:root {
  --orange: #f9a826;
  --deep: #c8551b;
  --ink: #2a1608;
  --cream: #fff6e3;
  --green: #36c25b;
  --red: #e5383b;
  --display: 'Lilita One', 'Arial Black', Impact, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6c27a; font-family: var(--body); color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; cursor: pointer; color: inherit; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .round { pointer-events: auto; position: absolute; top: max(12px, env(safe-area-inset-top)); width: 52px; height: 52px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); background: rgba(255,255,255,.35); display: grid; place-items: center; backdrop-filter: blur(4px); }
#hud .round svg { width: 26px; fill: #fff; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
#btn-restart { left: max(12px, env(safe-area-inset-left)); }
#btn-pause { right: max(12px, env(safe-area-inset-right)); }
.hud-center { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; color: #fff; text-shadow: 0 2px 0 var(--deep), 0 3px 6px rgba(0,0,0,.25); }
#hud-level { font: 15px var(--display); letter-spacing: .5px; opacity: .9; }
#hud-time { font: 38px/1 var(--display); }
#hint { position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%); width: min(90vw, 560px); text-align: center; font: 22px var(--display); color: #fff; text-shadow: 0 2px 0 var(--deep), 0 4px 8px rgba(0,0,0,.3); transition: opacity .5s; }
#popups { position: absolute; inset: 0; }
.popup { position: absolute; left: 50%; top: 32%; transform: translate(-50%, 0); font: 40px var(--display); color: #ffe14d; -webkit-text-stroke: 2px var(--deep); text-shadow: 0 4px 0 var(--deep); animation: pop 1.1s ease-out forwards; white-space: nowrap; }
.popup.bad { color: #fff; -webkit-text-stroke-color: #8e1b1b; text-shadow: 0 4px 0 #8e1b1b; }
.popup.small { font-size: 26px; top: 40%; }
@keyframes pop { 0% { transform: translate(-50%, 20px) scale(.4); opacity: 0; } 20% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 35% { transform: translate(-50%, 0) scale(1); } 100% { transform: translate(-50%, -60px) scale(1); opacity: 0; } }

/* Touch */
#touch { position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 0 max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); pointer-events: none; }
#touch .pad { display: flex; gap: 14px; pointer-events: auto; }
#touch button { width: 84px; height: 84px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); background: rgba(255,255,255,.28); color: #fff; font: 30px var(--display); text-shadow: 0 2px 2px rgba(0,0,0,.3); touch-action: none; backdrop-filter: blur(3px); }
#touch button.go { background: rgba(54,194,91,.65); font-size: 26px; width: 96px; height: 96px; }
#touch button.brake { background: rgba(229,56,59,.55); font-size: 17px; }
#touch button.down { transform: scale(.92); background: rgba(255,255,255,.55); }

/* start.ng player card */
.startng-card { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; border-radius: 999px; background: #292a23; color: #fffefa; font-family: var(--body); z-index: 5; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.startng-card img { width: 46px; height: 46px; border-radius: 50%; background: #d8fd71; object-fit: cover; }
.startng-card b { display: block; font-size: 16px; }
.startng-card span { font-size: 12px; opacity: .7; }
.startng-card button { margin-left: 6px; border: 0; border-radius: 999px; padding: 7px 14px; background: #d8fd71; color: #292a23; font-weight: 800; }

/* Screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 76px 16px 24px; overflow-y: auto; }
.screen.dim { background: rgba(42, 22, 8, .45); backdrop-filter: blur(3px); }
#menu { background: linear-gradient(to bottom, rgba(255,225,140,.0) 30%, rgba(200,85,27,.35)); justify-content: flex-start; padding-top: max(84px, 9vh); }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .85; transform: rotate(-4deg); filter: drop-shadow(0 6px 0 rgba(120,40,10,.35)); }
.logo span { font-family: var(--display); color: #fff; -webkit-text-stroke: 3px var(--deep); paint-order: stroke fill; text-shadow: 0 6px 0 var(--deep); }
.logo-top { font-size: clamp(44px, 9vw, 86px); }
.logo-bottom { font-size: clamp(56px, 12vw, 116px); color: #ffe14d !important; }
.tagline { margin: 0; font: 20px var(--display); color: #fff; text-shadow: 0 2px 0 var(--deep); }
.levels { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: auto; }
.level { width: 168px; padding: 12px 12px 14px; border-radius: 18px; border: 0; background: var(--cream); box-shadow: 0 6px 0 var(--deep); text-align: center; transition: transform .1s; }
.level:hover { transform: translateY(-3px); }
.level:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--deep); }
.level .num { font: 34px/1 var(--display); color: var(--deep); }
.level .name { font: 18px var(--display); margin: 2px 0 4px; }
.level .lstars { font-size: 22px; letter-spacing: 2px; color: #d9c7a4; }
.level .lstars .on { color: #ffb400; text-shadow: 0 1px 0 var(--deep); }
.level .best { font-size: 13px; opacity: .7; min-height: 1.2em; }
.level.locked { opacity: .55; cursor: not-allowed; }
.menu-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pill { text-decoration: none; color: inherit; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 11px 20px; background: #fff; box-shadow: 0 4px 0 rgba(120,40,10,.45); font-weight: 800; }
.pill:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(120,40,10,.45); }
.big { border: 0; border-radius: 999px; padding: 12px 30px; background: var(--green); color: #fff; font: 22px var(--display); box-shadow: 0 5px 0 #1f7a37; text-shadow: 0 2px 0 #1f7a37; }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #1f7a37; }
.controls-help { margin: 0; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); font-size: 14px; text-align: center; }
.panel { background: var(--cream); border-radius: 22px; padding: 22px 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 8px 0 var(--deep); min-width: min(320px, 92vw); max-width: 92vw; }
.panel h2 { margin: 0; font: 34px var(--display); color: var(--deep); }
.panel.wide { width: min(560px, 94vw); }

/* Stage clear */
#finish { background: rgba(42, 22, 8, .25); }
.banner { font: clamp(40px, 8vw, 72px) var(--display); color: #fff; -webkit-text-stroke: 3px var(--deep); paint-order: stroke fill; text-shadow: 0 6px 0 var(--deep); transform: rotate(-3deg); animation: drop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes drop { from { transform: translateY(-120px) rotate(-3deg); opacity: 0; } }
.stars { display: flex; gap: 10px; font-size: 64px; line-height: 1; }
.stars span { color: #d9c7a4; transform: scale(.6); transition: transform .25s cubic-bezier(.2,1.8,.4,1), color .2s; }
.stars span.on { color: #ffb400; transform: scale(1); text-shadow: 0 4px 0 var(--deep); }
.result { display: flex; gap: 26px; text-align: center; }
.result small { display: block; font-weight: 800; opacity: .6; text-transform: uppercase; font-size: 12px; }
.result b { font: 26px var(--display); }
#res-note, #res-save { margin: 0; text-align: center; font-weight: 800; min-height: 1.2em; }
#res-save { font-size: 14px; opacity: .8; }

/* Leaderboard */
table { width: 100%; border-collapse: collapse; font-weight: 800; }
th { text-align: left; font-size: 12px; opacity: .6; text-transform: uppercase; padding: 4px 6px; }
td { padding: 7px 6px; border-top: 2px solid #f0e0c2; }
td .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
tr.me td { background: #ffe9a8; }
#board-note { margin: 0; font-weight: 800; opacity: .7; text-align: center; }

/* Phones held upright */
#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: var(--orange); color: #fff; font: 28px/1.4 var(--display); text-align: center; padding: 30vh 16px 0; text-shadow: 0 3px 0 var(--deep); }
@media (orientation: portrait) and (pointer: coarse) { body.playing #rotate { display: block; } }

@media (max-height: 520px) {
  .screen { padding-top: 64px; gap: 8px; }
  #menu { padding-top: 12px; }
  .logo-top { font-size: 40px; } .logo-bottom { font-size: 52px; }
  .tagline, .controls-help { display: none; }
  .level { width: 140px; padding: 8px; }
  .level .num { font-size: 26px; }
  .stars { font-size: 46px; }
  .panel { padding: 14px 18px; gap: 8px; }
  #touch button { width: 72px; height: 72px; }
  #touch button.go { width: 84px; height: 84px; }
}
@media (max-width: 560px) { .startng-card { transform: scale(.85); transform-origin: top left; } }

/* Settings */
.settings { gap: 10px; max-height: calc(100vh - 32px); overflow-y: auto; }
.settings fieldset { width: 100%; border: 0; border-top: 2px solid #f0e0c2; margin: 0; padding: 10px 0 2px; }
.settings legend { font: 18px var(--display); color: var(--deep); padding: 0 8px 0 0; }
.settings .row { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-weight: 800; }
.settings .row > span { flex: 0 0 132px; }
.settings .row input[type=text] { flex: 1; min-width: 0; font: 800 16px var(--body); padding: 9px 12px; border-radius: 12px; border: 2px solid #e7cfa4; background: #fff; color: var(--ink); }
.settings .row input[type=text]:focus { outline: none; border-color: var(--orange); }
.settings .row input[type=range] { flex: 1; accent-color: var(--orange); height: 28px; }
.settings .row output { width: 34px; text-align: right; font-variant-numeric: tabular-nums; opacity: .7; }
.settings .row.check input { width: 22px; height: 22px; accent-color: var(--green); }
.settings .note { margin: 2px 0 4px; font-size: 13px; opacity: .65; font-weight: 700; }
.seg { display: flex; background: #f0e0c2; border-radius: 999px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 800; }
.seg button.on { background: #fff; box-shadow: 0 2px 0 rgba(120,40,10,.3); }
.pill.danger { color: #b3261e; }
input { user-select: text; -webkit-user-select: text; }

/* Name tag above the rider */
#nametag { position: fixed; left: 0; top: 0; transform: translate(-50%, -100%); pointer-events: none; padding: 3px 10px; border-radius: 999px; background: rgba(41,42,35,.78); color: #fff; font: 14px var(--display); letter-spacing: .3px; white-space: nowrap; will-change: transform; }

/* Flip HUD */
.hud-flips { position: absolute; top: max(76px, calc(env(safe-area-inset-top) + 70px)); right: max(14px, env(safe-area-inset-right)); text-align: right; color: #fff; text-shadow: 0 2px 0 var(--deep), 0 3px 6px rgba(0,0,0,.25); }
.flip-count { font: 34px/1 var(--display); display: flex; align-items: baseline; justify-content: flex-end; gap: 4px; }
.flip-count .flip-icon { font-size: 26px; opacity: .9; }
.flip-count small { font-size: 18px; opacity: .85; }
.flip-count.done small { color: #b6ff8a; }
.flip-count.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 100% { transform: scale(1); } }
.flip-score { font: 18px var(--display); opacity: .95; }
.combo { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); text-align: center; color: #ffe14d; -webkit-text-stroke: 2px var(--deep); paint-order: stroke fill; text-shadow: 0 3px 0 var(--deep); }
.combo-x { font: 48px/1 var(--display); }
.combo-x.bump { animation: bump .35s ease-out; }
.combo-label { font: 15px var(--display); letter-spacing: 3px; color: #fff; -webkit-text-stroke: 0; }
.combo-bar { width: 120px; height: 7px; margin: 5px auto 0; border-radius: 9px; background: rgba(0,0,0,.25); overflow: hidden; }
.combo-bar i { display: block; height: 100%; width: 100%; background: #ffe14d; border-radius: 9px; transform-origin: left; }
.popup .pts { display: block; font-size: 24px; color: #fff; -webkit-text-stroke: 1.5px var(--deep); }
.popup .perfect { display: block; font-size: 22px; color: #b6ff8a; -webkit-text-stroke: 1.5px #1f7a37; text-shadow: 0 3px 0 #1f7a37; }
.popup.big { font-size: 56px; top: 26%; }
.popup.gold { color: #ffd23f; font-size: 34px; top: 46%; }

/* Spin ring */
#spin { position: fixed; left: 0; top: 0; width: 150px; height: 150px; pointer-events: none; transform-origin: 0 0; will-change: transform; }
#spin circle { fill: none; stroke-width: 5; }
#spin .badge { fill: var(--deep); stroke: #fff; stroke-width: 3; }
#spin .track { stroke: rgba(255,255,255,.35); }
#spin .fill { stroke: #ffe14d; stroke-linecap: round; stroke-dasharray: 0 100; transform: rotate(-90deg); transform-origin: 50% 50%; filter: drop-shadow(0 0 3px rgba(255,180,0,.7)); }
#spin text { font: 17px var(--display); fill: #fff; text-anchor: middle; dominant-baseline: central; }
#spin.full .fill { stroke: #b6ff8a; }
#spin.full .badge { fill: var(--green); }

/* PERFECT flash */
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle, rgba(255,255,220,.0) 30%, rgba(255,240,170,.55)); opacity: 0; }
#flash.on { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* Results goals */
.goals { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; }
.goals li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: #f6e9cf; font-weight: 800; }
.goals li .tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #d9c7a4; color: #fff; font-size: 14px; }
.goals li.ok .tick { background: var(--green); }
.goals li.ok.new { animation: bump .45s ease-out; }
.goals li small { opacity: .65; font-size: 13px; }
.goals li .val { font: 18px var(--display); }
.lifetime, .lifetime-menu { margin: 0; font-weight: 800; text-align: center; }
.lifetime-menu { color: #fff; text-shadow: 0 2px 0 var(--deep); font: 18px var(--display); }
.level .best .fl { margin-left: 6px; }
@media (max-height: 520px) { .hud-flips { top: 64px; } .flip-count { font-size: 26px; } .combo { top: 70px; } .combo-x { font-size: 36px; } .lifetime-menu { display: none !important; } }
@media (prefers-reduced-motion: reduce) { #flash.on, .flip-count.bump, .combo-x.bump { animation: none; } }

/* Coins */
.coins { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 6px; padding: 7px 14px 7px 10px; border-radius: 999px; background: #292a23; color: #ffe14d; font: 20px var(--display); z-index: 5; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.coin { display: inline-block; width: .9em; height: .9em; margin-left: .2em; vertical-align: -.08em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff4b0, #f7c21b 45%, #c68a00 100%); box-shadow: inset 0 -2px 0 rgba(120,70,0,.35), 0 1px 0 rgba(0,0,0,.2); }
.coins .coin { width: 20px; height: 20px; margin: 0; }
.coins.bump { animation: bump .45s ease-out; }

/* Mode cards */
.modes { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: auto; }
.modes + .levels { margin-top: 0; }
.mode { position: relative; width: 254px; padding: 12px 14px; border: 0; border-radius: 18px; text-align: left; color: #fff; display: grid; gap: 2px; box-shadow: 0 6px 0 rgba(0,0,0,.25); transition: transform .1s; }
.mode:hover { transform: translateY(-3px); }
.mode:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.mode.daily { background: linear-gradient(135deg, #ff7a29, #e5383b); }
.mode.frenzy { background: linear-gradient(135deg, #7b2ff7, #3a86ff); }
.mode-tag { justify-self: start; font: 12px var(--display); letter-spacing: 1.5px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.25); }
.mode-title { font: 24px var(--display); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.mode-sub { font-weight: 800; font-size: 13px; opacity: .92; }
.mode-streak { position: absolute; top: 10px; right: 12px; font: 20px var(--display); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; margin-left: 4px; }

/* Missions */
.note-center { margin: 0; text-align: center; font-weight: 700; opacity: .7; font-size: 14px; }
.mission-list { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 8px; }
.mission-list li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 14px; border-radius: 14px; background: #f6e9cf; font-weight: 800; }
.mission-list li .reward { color: #a26a00; font: 17px var(--display); }
.mission-list li .bar { grid-column: 1 / -1; height: 8px; border-radius: 9px; background: #e6d3ad; overflow: hidden; }
.mission-list li .bar i { display: block; height: 100%; background: var(--orange); border-radius: 9px; }
.mission-list li .count { grid-column: 1 / -1; font-size: 12px; opacity: .6; }
.mission-list li.done { background: #dff5d9; }
.mission-list li.done .bar i { background: var(--green); }
.mission-list.compact li { padding: 6px 10px; font-size: 13px; }
.mission-list.compact li .count { display: none; }
.mission-list.compact:empty { display: none; }
.res-extra { display: flex; gap: 14px; justify-content: center; font: 20px var(--display); }
.res-extra .earned { color: #a26a00; }
.res-extra .streak { color: var(--red); }
.hud-time-low { color: #ffd0d0; animation: bump .5s ease-out infinite; }
@media (max-height: 520px) { .mode { width: 200px; padding: 8px 10px; } .mode-title { font-size: 19px; } .mode-sub { display: none; } .coins { transform: scale(.85); transform-origin: top right; } }

/* Worlds */
.worlds { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.worldcard { position: relative; width: 168px; min-height: 104px; padding: 12px 14px; border: 0; border-radius: 18px; text-align: left; color: #fff; display: grid; align-content: end; gap: 2px; box-shadow: 0 6px 0 rgba(0,0,0,.25); overflow: hidden; transition: transform .1s; }
.worldcard:hover { transform: translateY(-3px); }
.worldcard:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.worldcard.desert { background: linear-gradient(160deg, #f9c74f, #e07a3a 70%, #9a4422); }
.worldcard.lagos { background: linear-gradient(160deg, #4fb3e8, #2f8fb3 60%, #f7c600 140%); }
.worldcard.ice { background: linear-gradient(160deg, #e9f6ff, #8fc6ef 60%, #3d7cc6); }
.worldcard .wname { font: 22px var(--display); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.worldcard .wsub { font-weight: 800; font-size: 13px; opacity: .95; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.worldcard .wstars { position: absolute; top: 10px; right: 12px; font: 16px var(--display); text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.worldcard.locked { filter: grayscale(.85) brightness(.85); cursor: not-allowed; }
.world-head { display: flex; align-items: center; gap: 16px; width: min(760px, 100%); }
.world-head h2 { margin: 0; font: 34px var(--display); color: #fff; text-shadow: 0 3px 0 var(--deep); }
.world-head p { margin: 0; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.level-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 132px)); gap: 12px; justify-content: center; width: min(760px, 100%); }
.level-grid .level { width: auto; padding: 10px 8px 12px; }
.level-grid .level .num { font-size: 28px; }
.level-grid .level .name { font-size: 15px; min-height: 2.3em; display: grid; place-items: center; }
.level-grid .level .lstars { font-size: 18px; }
.level-grid .level .best { font-size: 11px; }
#world { background: linear-gradient(to bottom, rgba(42,22,8,.15), rgba(42,22,8,.45)); justify-content: flex-start; }
@media (max-width: 700px) { .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-height: 520px) {
  .worldcard { width: 150px; min-height: 76px; padding: 8px 10px; }
  .worldcard .wname { font-size: 18px; }
  .worldcard .wsub { display: none; }
  .level-grid { gap: 8px; }
  .level-grid .level { padding: 6px; }
  .level-grid .level .name { font-size: 13px; min-height: 0; }
  .world-head h2 { font-size: 26px; }
}

/* Garage */
.garage { justify-content: space-between; padding: max(14px, env(safe-area-inset-top)) 16px 16px; background: none; }
.garage-top { display: flex; align-items: center; gap: 14px; width: min(980px, 100%); }
.garage-top h2 { margin: 0; font: 36px var(--display); color: #fff; text-shadow: 0 3px 0 #0a1450; }
.garage-hint { margin-left: auto; margin-right: 120px; color: #cfe0ff; font-weight: 800; font-size: 13px; }
.garage-panel { width: min(980px, 100%); max-height: 48vh; align-items: stretch; gap: 10px; padding: 14px 16px; box-shadow: 0 8px 0 #0a1450; }
.garage-panel .seg { align-self: center; }
.garage-body { display: grid; grid-template-columns: 1fr 300px; gap: 14px; min-height: 0; overflow: hidden; }
.garage-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; overflow-y: auto; align-content: start; padding: 2px; }
.gitem { display: grid; justify-items: center; gap: 4px; padding: 10px 6px; border: 3px solid transparent; border-radius: 14px; background: #f6e9cf; font-weight: 800; }
.gitem.picked { border-color: var(--orange); background: #fff; }
.gicon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; background: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.gname { font-size: 14px; text-align: center; }
.gtag { font-size: 12px; opacity: .75; display: inline-flex; align-items: center; }
.gtag.eq { color: #1f7a37; opacity: 1; }
.garage-detail { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.garage-detail h3 { margin: 0; font: 26px var(--display); color: var(--deep); }
.garage-detail p { margin: 0; font-weight: 700; }
.garage-detail .gfair { font-size: 12px; opacity: .65; }
.garage-detail .big { margin-top: auto; display: inline-flex; justify-content: center; align-items: center; }
.garage-detail .big:disabled { background: #9bb8a4; box-shadow: none; cursor: default; }
.garage-detail .big.nope { animation: nope .4s; }
@keyframes nope { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.gstats { display: grid; gap: 4px; }
.gstats div { display: grid; grid-template-columns: 64px 1fr; align-items: center; font-weight: 800; font-size: 13px; }
.gstats i { display: flex; gap: 3px; }
.gstats b { flex: 1; height: 9px; border-radius: 3px; background: #e6d3ad; }
.gstats b.on { background: var(--orange); }
@media (min-aspect-ratio: 5/4) {
  .garage { flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; }
  .garage-top { width: auto; }
  .garage-panel { width: min(520px, 48vw); max-height: calc(100vh - 80px); margin: 52px 0 0 auto; }
  .garage-body { grid-template-columns: 1fr; overflow-y: auto; }
  .garage-hint { display: none; }
}
@media (max-height: 520px) {
  .garage-top h2 { font-size: 26px; }
  .garage-panel { padding: 10px; }
  .gitem { padding: 6px 4px; }
  .gicon { width: 30px; height: 30px; font-size: 18px; }
  .garage-detail h3 { font-size: 20px; }
}
/* Garage on short landscape screens (phones on their side): items and details side by side */
@media (max-height: 520px) and (min-aspect-ratio: 5/4) {
  .garage-panel { width: min(560px, 62vw); margin-top: 44px; max-height: calc(100vh - 56px); gap: 6px; }
  .garage-body { grid-template-columns: 1fr 1fr; gap: 10px; overflow: hidden; }
  .garage-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .gitem { grid-template-columns: auto 1fr; justify-items: start; text-align: left; padding: 5px 7px; gap: 0 6px; }
  .gitem .gicon { grid-row: span 2; width: 26px; height: 26px; font-size: 15px; }
  .gname { font-size: 12px; text-align: left; }
  .gtag { font-size: 11px; }
  .garage-detail { gap: 4px; }
  .garage-detail p { font-size: 12px; }
  .garage-detail .gfair { display: none; }
  .gstats div { grid-template-columns: 48px 1fr; font-size: 11px; }
  .garage-detail .big { font-size: 16px; padding: 8px 14px; }
  .garage-panel .seg button { padding: 4px 10px; }
}

/* Accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.calm .popup { animation: calm-pop 1.1s ease-out forwards; }
@keyframes calm-pop { 0%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 0); } }
body.calm .flip-count.bump, body.calm .combo-x.bump, body.calm .coins.bump, body.calm .goals li.ok.new, body.calm .banner { animation: none; }
body.calm .hud-time-low { animation: none; }
body.left-handed #touch { flex-direction: row-reverse; }
body.big-buttons #touch button { width: 106px; height: 106px; font-size: 34px; }
body.big-buttons #touch button.go { width: 120px; height: 120px; }
body.big-buttons #touch button.brake { font-size: 20px; }
:focus-visible { outline: 3px solid #3a86ff; outline-offset: 2px; }

/* Sharing, challenges and live races */
.center-text { margin: 0; text-align: center; font-weight: 800; max-width: 420px; }
.live-count { margin: 0; font: 16px var(--display); color: #fff; text-shadow: 0 2px 0 var(--deep); }
.pill.race { background: #36c25b; color: #fff; box-shadow: 0 4px 0 #1f7a37; }
.lobby-time { font: 64px/1 var(--display); color: var(--deep); }
.invite { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; border-radius: 999px; background: #292a23; color: #fff; font-weight: 800; box-shadow: 0 6px 0 rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
.invite .big { padding: 8px 20px; font-size: 18px; }
.invite .pill { padding: 6px 12px; }
#countdown { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; font: 160px var(--display); color: #fff; -webkit-text-stroke: 5px var(--deep); paint-order: stroke fill; text-shadow: 0 10px 0 var(--deep); z-index: 8; }
#tags { position: fixed; inset: 0; pointer-events: none; }
#tags .tag { position: absolute; left: 0; top: 0; padding: 2px 9px; border-radius: 999px; background: rgba(58,134,255,.85); color: #fff; font: 13px var(--display); white-space: nowrap; will-change: transform; }
#tags .tag.friend { background: rgba(229,56,59,.9); }
.race-results { margin: 0; padding: 0 0 0 22px; font-weight: 800; width: 100%; }
.race-results li.me { color: var(--deep); }

/* Full screen button and the top-right corner */
.corner { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); display: flex; gap: 8px; align-items: center; z-index: 6; }
.corner .coins { position: static; }
.fs-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #292a23; color: #ffe14d; font: 22px/1 var(--display); box-shadow: 0 4px 0 rgba(0,0,0,.2); }
body.playing .corner .fs-btn { display: none; }
.tip-steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-weight: 700; max-width: 380px; }
.share-glyph { display: inline-block; padding: 0 6px; border-radius: 6px; background: #e8f0ff; color: #1f6feb; }

/* Size everything to the part of the screen you can actually see (browser bars come and go). */
.screen { height: 100vh; height: 100dvh; inset: auto 0 auto 0; top: 0; }

/* Results: two columns that stack on tall screens and sit side by side on short ones. */
.res-cols { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.res-col { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
@media (max-height: 520px) and (orientation: landscape) {
  #finish { justify-content: flex-start; padding: max(6px, env(safe-area-inset-top)) 12px 8px; gap: 4px; }
  #finish .banner { font-size: 28px; -webkit-text-stroke-width: 2px; text-shadow: 0 3px 0 var(--deep); }
  #finish .panel.card { width: min(900px, 100%); max-height: calc(100dvh - 50px); padding: 10px 14px; overflow: hidden; }
  .res-cols { flex-direction: row; align-items: stretch; height: 100%; min-height: 0; }
  .res-col { flex: 1; gap: 6px; overflow-y: auto; }
  #finish #stars { font-size: 30px; }
  #finish .goals { gap: 4px; }
  #finish .goals li { padding: 4px 10px; }
  #finish .goals li .val { font-size: 15px; }
  #finish .result { gap: 14px; }
  #finish .result b { font-size: 19px; }
  #finish .lifetime, #finish #res-note { font-size: 13px; }
  #finish .menu-row { gap: 6px; }
  #finish .menu-row .pill { padding: 7px 11px; font-size: 14px; }
  #finish .menu-row .big { padding: 7px 16px; font-size: 17px; }
  #finish .res-extra { font-size: 17px; }
}

/* Your ghost: cyan, labelled, with a live gap and an arrow when it's off screen */
#tags .tag.mine { background: rgba(0, 170, 210, .88); }
.hud-gap { display: inline-block; font: 16px var(--display); margin-top: 3px; padding: 2px 10px; border-radius: 999px; background: rgba(20, 24, 40, .6); text-shadow: none; }
.hud-gap.ahead { color: #b6ff8a; }
.hud-gap.behind { color: #ffb3b3; }
.ghost-edge { position: fixed; left: 0; top: 0; padding: 4px 10px; border-radius: 999px; background: rgba(0, 170, 210, .9); color: #fff; font: 14px var(--display); white-space: nowrap; pointer-events: none; will-change: transform; z-index: 4; }
.coach { position: fixed; left: 0; top: 0; padding: 8px 14px; border-radius: 14px; background: #fff; color: #00718c; font: 16px/1.25 var(--display); text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; will-change: transform; z-index: 9; animation: coach-in .35s ease-out; }
.coach::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -8px; border: 8px solid transparent; border-bottom: 0; border-top-color: #fff; }
.coach b { color: var(--deep); }
@keyframes coach-in { from { opacity: 0; } }
.res-ghost { margin: 0; text-align: center; font-weight: 800; color: #00718c; }
