@import url('https://fonts.googleapis.com/css2?family=Changa+One:ital@0;1&family=DM+Mono:wght@500&family=Manrope:wght@600;700;800&display=swap');

:root {
  --ink: #10243f;
  --navy: #17375f;
  --red: #e93448;
  --red-dark: #a91732;
  --blue: #33a8e8;
  --cream: #fff4d2;
  --yellow: #ffd84d;
  --mint: #54d69b;
  --paper: #fffdf4;
  --shadow: #071628;
  --pixel: 3px;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper); }

body {
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: "Manrope", system-ui, sans-serif;
  image-rendering: pixelated;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    #0b1d34;
  background-size: 8px 8px;
}

button { font: inherit; }
button, [role="button"] { touch-action: manipulation; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    var(--shadow);
  background-size: 8px 8px;
  transition: opacity .35s ease, visibility .35s ease;
}
.loading-screen.ready { opacity: 0; visibility: hidden; }
.loading-card { width: min(440px, 92vw); text-align: center; }
.loading-card img { display: block; width: min(330px, 75vw); max-height: 52vh; margin: 0 auto 22px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(8px 9px 0 rgba(0,0,0,.28)); }
.loading-card p { margin: 0 0 13px; color: var(--paper); font: 700 .78rem/1 "DM Mono", monospace; letter-spacing: .11em; }
.loading-track { height: 20px; padding: 3px; border: 3px solid var(--paper); background: var(--ink); box-shadow: 4px 4px 0 var(--red-dark); }
.loading-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--red), #ff6fa1, var(--yellow)); transition: width .12s linear; }
.loading-card small { display: block; margin-top: 10px; color: var(--yellow); font: 700 .65rem/1 "DM Mono", monospace; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

button:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }

#app { height: 100dvh; min-height: 0; display: grid; grid-template-rows: 74px minmax(0, 1fr) auto; overflow: hidden; }

.topbar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 74px;
  padding: 8px clamp(14px, 2.5vw, 38px);
  background: var(--paper);
  color: var(--ink);
  border-bottom: 6px solid var(--red);
  box-shadow: 0 5px 0 var(--shadow);
  z-index: 20;
}

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.brand > img { width: 50px; height: 50px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(3px 3px 0 rgba(16,36,63,.16)); }

.brand strong, .brand em { display: block; font-family: "Changa One", Impact, sans-serif; line-height: .88; letter-spacing: .04em; }
.brand strong { color: var(--red); font-size: 1.35rem; }
.brand em { color: var(--ink); font-size: 1rem; font-style: normal; }

.brand-cone { position: relative; width: 29px; height: 42px; filter: drop-shadow(3px 3px 0 rgba(16,36,63,.16)); }
.brand-cone::before { content: ""; position: absolute; top: 0; left: 2px; width: 25px; height: 25px; background: var(--paper); border: 4px solid var(--ink); box-shadow: inset -5px 0 0 #d9e6ee; clip-path: polygon(20% 100%, 4% 74%, 23% 55%, 12% 35%, 36% 20%, 51% 0, 67% 20%, 90% 34%, 79% 54%, 96% 74%, 78% 100%); }
.brand-cone::after { content: ""; position: absolute; left: 7px; top: 24px; width: 17px; height: 17px; background: #f2ad3c; border: 3px solid var(--ink); clip-path: polygon(0 0,100% 0,50% 100%); }

.top-stats { display: grid; grid-auto-flow: column; gap: clamp(18px, 3vw, 44px); }
.top-stats span { display: grid; text-align: center; }
.top-stats small, .bank-card small, .score-stamp small, .result-grid small { font: 700 .68rem/1 "DM Mono", monospace; letter-spacing: .11em; color: #55708a; }
.top-stats b { font: 500 1.15rem/1.2 "DM Mono", monospace; color: var(--ink); }
.top-stats span:first-child b { color: var(--red); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.header-link { min-height: 40px; padding: 0 10px; border: 3px solid var(--ink); background: #eaf6fa; color: var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; font: 700 .62rem/1 "DM Mono", monospace; letter-spacing: .03em; white-space: nowrap; }
.header-link:hover { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); background: var(--yellow); }
.header-link.danger-link { background: #ffe1e1; color: #a51f35; }
.header-link.danger-link:hover { background: #ffb6b6; }
.icon-btn { width: 40px; height: 40px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; font-weight: 900; }
.icon-btn:hover { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }

.game-frame { position: relative; width: min(100%, 1440px); height: 100%; min-height: 0; align-self: center; justify-self: center; overflow: hidden; background: #56bde9; border-inline: 4px solid #071628; }
#gameCanvas { display: block; width: 100%; height: 100%; max-height: calc(100dvh - 202px); aspect-ratio: 16/9; object-fit: contain; background: #56bde9; image-rendering: pixelated; }
.game-frame:not(:has(.screen.active)) { width: min(100%, 1440px, calc(177.78dvh - 359.11px)); }
.game-frame:has(.screen.active) { height: calc(100dvh - 74px); max-height: 900px; }
.game-frame:has(.screen.active) #gameCanvas { height: 100%; max-height: none; object-fit: cover; }
.game-frame:has(.screen.active) + .service-deck { display: none; }

.screen { position: absolute; inset: 0; z-index: 10; display: none; }
.screen.active { display: flex; }
.title-screen { align-items: stretch; background: url('assets/scenes/seaside-van-complete.png') center/cover no-repeat; }
.title-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(7,22,40,.88) 0%, rgba(7,22,40,.69) 33%, rgba(7,22,40,.08) 66%, rgba(7,22,40,.02) 100%); }
.title-copy { position: relative; z-index: 1; align-self: center; margin-left: clamp(28px, 6vw, 86px); max-width: min(510px, 43vw); padding-block: 25px; }
.title-logo { display: block; width: min(390px, 38vw); max-height: 47vh; object-fit: contain; object-position: left center; image-rendering: pixelated; filter: drop-shadow(8px 8px 0 rgba(7,22,40,.28)); }
.title-actions { display: flex; align-items: center; gap: 20px; }
.eyebrow { margin: 0 0 12px; font: 700 .75rem/1 "DM Mono", monospace; letter-spacing: .16em; color: var(--yellow); }
h1, h2 { margin: 0; font-family: "Changa One", Impact, sans-serif; font-weight: 400; letter-spacing: .02em; }
h1 { font-size: clamp(3.4rem, 7vw, 7rem); line-height: .75; color: var(--paper); text-shadow: 6px 6px 0 var(--red-dark), 10px 10px 0 var(--shadow); }
h1 span { color: var(--yellow); }
.title-sub { margin: 25px 0; font-size: clamp(1rem, 1.65vw, 1.35rem); line-height: 1.45; font-weight: 800; text-shadow: 2px 2px 0 var(--shadow); }
.title-copy .text-btn { margin-left: 0; }
.title-record { position: absolute; right: 22px; bottom: 20px; z-index: 2; display: grid; text-align: right; padding: 10px 14px; background: rgba(7,22,40,.84); border-left: 5px solid var(--yellow); }
.title-record small { font: 700 .7rem/1 "DM Mono", monospace; color: var(--yellow); }
.title-record strong { font: 500 1.45rem/1.3 "DM Mono", monospace; }

.menu-screen { align-items: center; justify-content: center; padding: clamp(12px, 3vw, 32px); background: rgba(7,22,40,.86); backdrop-filter: blur(2px); }
.menu-panel { width: min(550px, 96%); max-height: 95%; overflow: auto; padding: clamp(22px, 3vw, 38px); background: var(--paper); color: var(--ink); border: 5px solid var(--ink); box-shadow: 9px 9px 0 var(--red); }
.menu-panel.wide { width: min(1050px, 98%); }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.menu-panel .eyebrow { color: var(--red); }
h2 { color: var(--ink); font-size: clamp(2rem, 4vw, 3.5rem); line-height: .95; }
.bank-card { min-width: 108px; padding: 11px 14px; border: 3px solid var(--ink); background: var(--yellow); text-align: right; box-shadow: 4px 4px 0 var(--ink); }
.bank-card small, .bank-card strong { display: block; color: var(--ink); }
.bank-card strong { font: 500 1.3rem/1.2 "DM Mono", monospace; }

.location-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.location-card { position: relative; min-height: 210px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 16px; color: var(--paper); border: 4px solid var(--ink); background: var(--navy) center/cover no-repeat; box-shadow: 5px 5px 0 var(--ink); cursor: pointer; text-align: left; }
.location-card::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 72%; background: linear-gradient(transparent, rgba(7,22,40,.97) 56%); }
.location-card > * { position: relative; z-index: 1; }
.location-card strong { font-family: "Changa One", Impact, sans-serif; font-size: 1.6rem; line-height: 1; }
.location-card small { margin-top: 5px; font: 500 .68rem/1.35 "DM Mono", monospace; color: #cbeaff; }
.location-card .record { margin-top: 14px; color: var(--yellow); }
.location-card .pitch-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.location-card .pitch-meta em { font: 700 .58rem/1 "DM Mono", monospace; font-style: normal; letter-spacing: .06em; color: #d6edfa; }
.location-card .pitch-meta em:first-child { color: var(--yellow); }
.location-card .unlock-progress { height: 8px; margin-top: 8px; overflow: hidden; border: 2px solid var(--paper); background: rgba(7,22,40,.68); }
.location-card .unlock-progress i { display: block; height: 100%; background: var(--yellow); }
.location-card:hover:not([disabled]) { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.location-card.selected { outline: 5px solid var(--red); outline-offset: -9px; }
.location-card[disabled] { cursor: not-allowed; filter: grayscale(.7) brightness(.64); }
.location-card .lock { align-self: flex-start; margin-bottom: auto; padding: 5px 8px; background: var(--ink); color: var(--yellow); font: 700 .64rem/1.2 "DM Mono", monospace; }
.location-card .featured { align-self: flex-start; margin-bottom: auto; padding: 5px 8px; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); font: 700 .58rem/1.2 "DM Mono", monospace; box-shadow: 2px 2px 0 var(--red); }

.livery-workshop { margin-bottom: 24px; padding: 16px; border: 3px solid var(--ink); background: #eaf6fa; box-shadow: 4px 4px 0 #a8c5d6; }
.livery-workshop > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.livery-workshop .eyebrow { margin: 0; }
.livery-workshop h3, .equipment-heading { margin: 0; color: var(--ink); font: 400 1.35rem/1 "Changa One", Impact, sans-serif; letter-spacing: .03em; }
.equipment-heading { margin: 0 0 12px; }
.van-skin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.van-skin-card { min-width: 0; padding: 8px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.van-skin-card:hover { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.van-skin-card.selected { outline: 4px solid var(--mint); outline-offset: -7px; background: #dff5e8; }
.van-skin-card img { display: block; width: 100%; height: 64px; object-fit: contain; image-rendering: pixelated; }
.van-skin-card span, .van-skin-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.van-skin-card span { margin-top: 5px; font: 400 1rem/1 "Changa One", Impact, sans-serif; }
.van-skin-card small { margin-top: 3px; color: #61788c; font: 700 .52rem/1 "DM Mono", monospace; }

.upgrade-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.upgrade-card { display: grid; grid-template-columns: 45px 1fr; gap: 10px; min-height: 145px; padding: 15px; border: 3px solid var(--ink); background: #edf8fc; box-shadow: 4px 4px 0 #a8c5d6; }
.upgrade-card.has-art { grid-template-columns: 74px 1fr; }
.upgrade-card .upgrade-icon { width: 43px; height: 43px; display: grid; place-items: center; color: var(--paper); background: var(--red); border: 3px solid var(--ink); font: 900 1.25rem/1 "DM Mono", monospace; }
.upgrade-card .upgrade-icon.art { width: 72px; height: 72px; border: 0; background: transparent; }
.upgrade-art { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.upgrade-card h3 { margin: 0; font: 400 1.35rem/1 "Changa One", Impact, sans-serif; }
.upgrade-card p { margin: 6px 0 10px; font-size: .76rem; line-height: 1.3; color: #526b80; }
.level-pips { display: flex; gap: 3px; margin-bottom: 10px; }
.level-pips i { width: 15px; height: 7px; background: #c4d7e0; border: 1px solid var(--ink); }
.level-pips i.on { background: var(--mint); }
.buy-btn { grid-column: 1 / -1; padding: 8px; border: 2px solid var(--ink); background: var(--yellow); color: var(--ink); font: 700 .75rem/1 "DM Mono", monospace; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; }
.buy-btn[disabled] { background: #c8d1d7; color: #637281; cursor: not-allowed; box-shadow: none; }

.panel-actions { margin-top: 24px; display: flex; gap: 18px; align-items: center; justify-content: center; }
.panel-actions.stacked { flex-direction: column; gap: 10px; }
.pixel-btn { min-height: 48px; padding: 11px 22px; border: 4px solid var(--ink); color: var(--paper); font: 700 .83rem/1 "DM Mono", monospace; letter-spacing: .05em; box-shadow: 5px 5px 0 var(--ink); cursor: pointer; }
.pixel-btn:hover { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.pixel-btn.primary { background: var(--red); }
.pixel-btn.secondary { background: var(--blue); }
.pixel-btn.tertiary { background: var(--yellow); color: var(--ink); }
.pixel-btn.danger { background: #a51f35; }
.text-btn { border: 0; border-bottom: 2px solid currentColor; background: transparent; color: inherit; padding: 6px 0; font: 700 .75rem/1 "DM Mono", monospace; cursor: pointer; }

.reset-panel { width: min(620px, 96%); text-align: center; }
.reset-copy { max-width: 510px; margin: 20px auto; color: #43586c; font-weight: 700; line-height: 1.55; }
.reset-warning { display: grid; gap: 7px; margin: 22px 0; padding: 16px; border: 4px solid #a51f35; background: #ffe1e1; color: #751326; box-shadow: 5px 5px 0 var(--ink); }
.reset-warning strong { font: 700 .86rem/1 "DM Mono", monospace; letter-spacing: .1em; }
.reset-warning span { font-size: .85rem; font-weight: 700; }

.results-panel { text-align: center; }
.score-stamp { width: 80%; margin: 22px auto 10px; padding: 15px; border: 4px solid var(--ink); background: var(--yellow); box-shadow: 6px 6px 0 var(--red); }
.score-stamp small, .score-stamp strong { display: block; color: var(--ink); }
.score-stamp strong { font: 500 clamp(2.4rem, 6vw, 4.5rem)/1 "DM Mono", monospace; }
.new-best { margin: 13px 0; font: 700 .75rem/1 "DM Mono", monospace; color: var(--red); animation: flash .7s steps(2,end) infinite; }
.hidden { display: none !important; }
.result-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 22px 0; }
.result-grid span { padding: 10px 4px; border-right: 2px solid #ccd9df; border-bottom: 2px solid #ccd9df; }
.result-grid span:nth-child(3n) { border-right: 0; }
.result-grid span:nth-last-child(-n+3) { border-bottom: 0; }
.result-grid small, .result-grid b { display: block; }
.result-grid b { font: 500 1.25rem/1.5 "DM Mono", monospace; }
.unlock-notice { padding: 10px; background: var(--mint); border: 3px solid var(--ink); font: 700 .8rem/1.3 "DM Mono", monospace; }

.score-entry { margin-top: 16px; padding: 13px; border: 3px solid var(--ink); background: #eaf6fa; text-align: left; }
.score-entry label { display: block; color: var(--ink); font: 700 .68rem/1.2 "DM Mono", monospace; }
.score-entry small { display: block; margin-top: 5px; color: #5b7183; font-size: .7rem; }
.score-entry-controls { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 11px; }
.score-entry input { min-width: 0; height: 48px; padding: 0 12px; border: 3px solid var(--ink); background: var(--paper); color: var(--ink); font: 700 .82rem/1 "DM Mono", monospace; text-transform: uppercase; }
.score-entry .pixel-btn { min-height: 48px; padding-inline: 15px; }
.score-entry p { min-height: 1.1em; margin: 8px 0 0; color: var(--red-dark); font: 700 .64rem/1.3 "DM Mono", monospace; }
.score-entry.disabled { opacity: .7; }
.results-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.results-actions .pixel-btn { width: 100%; min-width: 0; min-height: 58px; display: flex; align-items: center; justify-content: center; padding: 10px 8px; line-height: 1.2; }

.leaderboard-panel { width: min(720px, 96%); }
.leaderboard-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.leaderboard-badge { padding: 8px 10px; border: 3px solid var(--ink); background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); font: 700 .58rem/1 "DM Mono", monospace; }
.leaderboard-intro { margin: 10px 0 18px; color: #536a7d; font-size: .8rem; }
.leaderboard-list { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: none; }
.leaderboard-list li { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; min-height: 57px; padding: 8px 12px; border: 3px solid var(--ink); border-bottom: 0; background: #eaf6fa; }
.leaderboard-list li:last-child { border-bottom: 3px solid var(--ink); }
.leaderboard-list li:first-child { background: var(--yellow); }
.leaderboard-list li > b { width: 30px; height: 30px; display: grid; place-items: center; border: 2px solid var(--ink); background: var(--red); color: var(--paper); font: 500 .75rem/1 "DM Mono", monospace; }
.leaderboard-list strong, .leaderboard-list small { display: block; }
.leaderboard-list strong { font: 400 1.15rem/1 "Changa One", Impact, sans-serif; }
.leaderboard-list small { margin-top: 4px; color: #536a7d; font: 700 .55rem/1 "DM Mono", monospace; }
.leaderboard-list em { color: var(--red); font: 500 1rem/1 "DM Mono", monospace; font-style: normal; }
.leaderboard-empty { margin: 22px 0; padding: 18px; border: 3px dashed #9ab0be; color: #536a7d; text-align: center; font: 700 .7rem/1.4 "DM Mono", monospace; }
.leaderboard-panel > .pixel-btn { display: block; margin: 0 auto; }

.help-panel { width: min(680px, 97%); }
.help-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin: 22px 0; }
.help-steps article { display: flex; gap: 12px; padding: 13px; background: #eaf6fa; border: 3px solid var(--ink); }
.help-steps article > b { flex: 0 0 35px; height: 35px; display: grid; place-items: center; color: var(--paper); background: var(--red); border: 2px solid var(--ink); font: 500 1rem/1 "DM Mono", monospace; }
.help-steps strong { font: 700 .76rem/1 "DM Mono", monospace; }
.help-steps p { margin: 5px 0 0; color: #536a7d; font-size: .78rem; line-height: 1.35; }
.help-panel > .pixel-btn { display: block; margin: auto; }
.pause-panel { text-align: center; display: grid; justify-items: center; gap: 16px; }

.service-deck { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(520px,3fr) minmax(140px,.7fr); align-items: center; gap: 14px; padding: 9px clamp(14px,2.2vw,32px) max(11px, env(safe-area-inset-bottom)); background: var(--paper); color: var(--ink); border-top: 6px solid var(--red); }
.deck-label span, .deck-label small { display: block; }
.deck-label span { font-family: "Changa One", Impact, sans-serif; font-size: 1.4rem; color: var(--red); }
.deck-label small, .deck-meter small { font: 700 .62rem/1.3 "DM Mono", monospace; color: #61788c; }
.menu-console { min-width: 0; }
.menu-rail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 5px 2px; color: #61788c; }
.menu-rail-head span { color: var(--red); font: 400 .78rem/1 "Changa One", Impact, sans-serif; letter-spacing: .04em; }
.menu-rail-head small { font: 700 .55rem/1 "DM Mono", monospace; }
.product-buttons { display: flex; gap: 7px; width: 100%; padding: 2px 7px 8px 2px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-inline: contain; scroll-snap-type: x proximity; scrollbar-color: var(--red) #dceaf0; scrollbar-width: thin; }
.product-buttons:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.product-buttons::-webkit-scrollbar { height: 9px; }
.product-buttons::-webkit-scrollbar-track { background: #dceaf0; border: 2px solid var(--ink); }
.product-buttons::-webkit-scrollbar-thumb { background: var(--red); border: 2px solid var(--ink); }
.product-btn { position: relative; flex: 0 0 clamp(138px,12vw,160px); min-height: 60px; display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 6px; align-items: center; padding: 5px 7px; border: 3px solid var(--ink); background: #edf8fc; color: var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; overflow: hidden; text-align: left; scroll-snap-align: start; }
.product-btn:hover:not([disabled]) { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }
.product-btn canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.product-btn span strong, .product-btn span small { display: block; }
.product-btn span { min-width: 0; }
.product-btn span strong { overflow: hidden; font: 400 .9rem/1 "Changa One", Impact, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.product-btn span small { margin-top: 3px; font: 700 .56rem/1 "DM Mono", monospace; color: #6b7e8c; }
.product-btn span em { display: block; overflow: hidden; margin-top: 3px; color: var(--red); font: 700 .44rem/1 "DM Mono", monospace; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.product-btn .key { position: absolute; right: 3px; top: 3px; width: 15px; height: 15px; text-align: center; background: var(--ink); color: var(--paper); font: 500 .52rem/15px "DM Mono", monospace; }
.restock-art { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
.product-btn[disabled] { filter: grayscale(1); opacity: .45; cursor: not-allowed; }
.product-btn.busy { background: var(--yellow); }
.restock-btn { background: #dff5e8; }
.restock-icon { width: 42px; height: 42px; display: grid !important; place-items: center; border: 3px solid var(--ink); background: var(--mint); font: 700 1.5rem/1 "DM Mono", monospace; }
.deck-meter { justify-self: end; min-width: 150px; }
.queue-pips { display: flex; gap: 3px; margin: 5px 0; }
.queue-pips i { width: 14px; height: 10px; border: 2px solid var(--ink); background: #d5e0e6; }
.queue-pips i.on { background: var(--red); }
.deck-meter > span { font: 500 .72rem/1 "DM Mono", monospace; }
.toast { position: absolute; left: 50%; top: 18px; z-index: 30; transform: translate(-50%,-100px); padding: 10px 18px; background: var(--yellow); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font: 700 .75rem/1 "DM Mono", monospace; transition: transform .18s steps(3,end); pointer-events: none; }
.toast.show { transform: translate(-50%,0); }

@keyframes flash { 50% { opacity: .45; } }

@media (max-width: 900px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  #app { height: 100dvh; min-height: 0; grid-template-rows: 56px minmax(0, 1fr) auto; overflow: hidden; }
  .topbar { grid-template-columns: auto 1fr auto; min-height: 56px; padding: 5px 10px; border-bottom-width: 4px; box-shadow: 0 3px 0 var(--shadow); }
  .brand em { display: none; }
  .brand strong { font-size: 1.05rem; }
  .brand > img { width: 38px; height: 38px; }
  .top-stats { gap: 12px; justify-self: center; }
  .top-stats small { font-size: .55rem; }
  .top-stats b { font-size: .83rem; }
  .combo-stat { display: none !important; }
  .icon-btn { width: 32px; height: 32px; }
  .header-link { min-height: 32px; padding-inline: 6px; font-size: .5rem; }
  .game-frame,
  .game-frame:not(:has(.screen.active)),
  .game-frame:has(.screen.active) { width: 100%; height: 100%; min-height: 0; max-height: none; align-self: stretch; border: 0; }
  #gameCanvas,
  .game-frame:has(.screen.active) #gameCanvas { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: cover; object-position: center center; }
  .menu-screen { padding: 8px; }
  .menu-panel { max-height: calc(100% - 8px); overscroll-behavior: contain; border-width: 3px; box-shadow: 4px 4px 0 var(--red); }
  .location-grid { grid-template-columns: 1fr 1fr; }
  .upgrade-grid { grid-template-columns: 1fr 1fr; }
  .van-skin-grid { grid-template-columns: 1fr 1fr; }
  .service-deck { position: relative; grid-template-columns: 1fr; min-height: 78px; gap: 0; padding: 5px 7px max(7px, env(safe-area-inset-bottom)); border-top-width: 4px; }
  .deck-label { display: none; }
  .deck-meter { position: absolute; right: 8px; top: -40px; z-index: 5; display: block; min-width: 0; padding: 5px 8px; border: 2px solid var(--ink); border-bottom: 0; border-radius: 10px 10px 0 0; background: rgba(255,253,244,.95); box-shadow: 2px -2px 0 var(--ink); }
  .deck-meter small { display: none; }
  .queue-pips { gap: 2px; margin: 0 0 3px; }
  .queue-pips i { width: 9px; height: 7px; border-width: 1px; }
  .deck-meter > span { display: block; font-size: .53rem; text-align: center; }
  .product-buttons { width: 100%; gap: 6px; padding: 2px 5px 5px 2px; touch-action: pan-x; scrollbar-width: none; }
  .product-buttons::-webkit-scrollbar { display: none; }
  .menu-rail-head { min-height: 12px; margin: 0 2px 3px; }
  .product-btn { flex-basis: 118px; min-height: 50px; grid-template-columns: 32px minmax(0,1fr); padding: 3px 5px; border-width: 2px; box-shadow: 2px 2px 0 var(--ink); }
  .product-btn canvas, .restock-art { width: 32px; height: 32px; }
  .product-btn span strong { font-size: .8rem; }
  .product-btn span small { font-size: .48rem; }
  .product-btn span em, .product-btn .key { display: none; }
}

@media (max-width: 900px) and (orientation: landscape) {
  #app { grid-template-rows: 48px minmax(0, 1fr); }
  .topbar { min-height: 48px; padding-block: 3px; }
  .brand > img { width: 34px; height: 34px; }
  .game-frame { grid-row: 2; }
  #gameCanvas,
  .game-frame:has(.screen.active) #gameCanvas { object-position: center bottom; }
  .service-deck { position: fixed; left: 10vw; right: 10vw; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 22; min-height: 62px; padding: 4px 7px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(255,253,244,.96); box-shadow: 4px 4px 0 var(--ink); }
  .menu-rail-head { display: none; }
  .product-buttons { padding-bottom: 2px; }
  .product-btn { flex-basis: 112px; min-height: 48px; }
  .deck-meter { top: -37px; }
  .game-frame:has(.screen.active) + .service-deck { display: none; }
}

@media (max-width: 570px) {
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand span:last-child { display: none; }
  .brand > img { width: 34px; height: 34px; }
  .top-stats { gap: 8px; }
  .top-stats span:nth-child(3) { display: none; }
  .top-actions { gap: 5px; }
  .header-link { width: 32px; min-height: 32px; padding: 0; font-size: 0; }
  #topHelpBtn::after { content: "?"; font: 900 .78rem/1 "DM Mono", monospace; }
  #topGarageBtn::after { content: "G"; font: 900 .72rem/1 "DM Mono", monospace; }
  #topLeaderboardBtn::after { content: "★"; font: 900 .72rem/1 "DM Mono", monospace; }
  #topResetBtn::after { content: "R"; font: 900 .72rem/1 "DM Mono", monospace; }
  .icon-btn { width: 32px; height: 32px; border-width: 2px; box-shadow: 2px 2px 0 var(--ink); }
  .title-copy { margin: auto 22px; padding-block: 5px; }
  .title-shade { background: linear-gradient(90deg, rgba(7,22,40,.82), rgba(7,22,40,.46)); }
  .title-copy .eyebrow { margin-bottom: 6px; font-size: .55rem; }
  .title-copy { max-width: 72vw; }
  .title-logo { width: min(290px, 68vw); max-height: 35vh; }
  h1 { font-size: clamp(2.6rem, 11.5vw, 3.55rem); text-shadow: 4px 4px 0 var(--red-dark), 7px 7px 0 var(--shadow); }
  .title-sub { margin: 10px 0 12px; font-size: .78rem; line-height: 1.3; }
  .title-copy .pixel-btn { width: 100%; min-height: 39px; padding: 8px 12px; }
  .title-actions { display: grid; justify-items: start; gap: 7px; }
  .title-copy .text-btn { margin: 0; display: block; font-size: .62rem; }
  .title-record { display: none; }
  .location-grid, .upgrade-grid { grid-template-columns: 1fr; }
  .livery-workshop > div:first-child { display: block; }
  .livery-workshop h3 { margin-top: 6px; }
  .location-card { min-height: 145px; }
  .panel-heading { display: grid; }
  .bank-card { justify-self: start; }
  .help-steps { grid-template-columns: 1fr; }
  .menu-panel { padding: 19px; }
  .reset-actions { display: grid; grid-template-columns: 1fr; }
  .menu-rail-head small { font-size: .48rem; }
  .product-buttons { gap: 5px; padding-bottom: 5px; }
  .product-btn { flex-basis: 114px; min-height: 49px; }
  .result-grid { gap: 0; }
  .results-actions { gap: 7px; }
  .results-actions .pixel-btn { min-height: 52px; padding-inline: 4px; border-width: 3px; box-shadow: 3px 3px 0 var(--ink); font-size: clamp(.52rem, 2.5vw, .68rem); letter-spacing: 0; }
  .score-entry-controls { grid-template-columns: 1fr; }
  .leaderboard-heading { display: grid; }
  .leaderboard-badge { justify-self: start; }
  .leaderboard-list li { grid-template-columns: 32px 1fr; gap: 8px; padding-inline: 8px; }
  .leaderboard-list em { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
