/* Smithers Race – game UI, "Late-Night CRT" style (a 1996 console on the living-room TV).
   Layout: one full-window WebGL stage behind DOM screens; each screen is an absolutely positioned layer.
   A CRT layer (scanlines, aperture grille, rolling bar, glare, rounded tube) sits over everything.
   Single dark look on purpose, so colours are set explicitly and never follow the host theme. */
:root {
  --night: #07090b;        /* the TV set, and screens with no picture */
  --crt: #0b0f14;          /* setup screens */
  --glass: rgba(14, 20, 30, .9);   /* game windows */
  --glass-solid: #0e141e;
  --cream: #d9d4c7;        /* borders, primary text */
  --cream-dim: #aaa69b;    /* unselected text */
  --grey: #7d878d;         /* quiet text */
  --line: #5f6b73;         /* inner rules, dotted dividers */
  --phos: #e0a44a;         /* amber phosphor: primary accent */
  --rust: #b0603a;
  --plum: #8e4d66;         /* selection dither */
  --teal: #7fb3ad;         /* secondary text */
  --osd: #8fbf7f;          /* channel / OSD green */
  --p1: #6fc3c0;           /* player 1 */
  --p2: #d9798f;           /* player 2 */
  --ink: #07090b;          /* text on light fills */
  --f-pixel: "Press Start 2P", "Courier New", monospace;
  --f-term: "VT323", "Courier New", monospace;
  --dither: conic-gradient(rgba(142,77,102,.9) 25%, rgba(142,77,102,.35) 0 50%, rgba(142,77,102,.9) 0 75%, rgba(142,77,102,.35) 0) 0 0 / 4px 4px;
  --pixel-corners: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px), 0 8px, 4px 8px, 4px 4px, 8px 4px);
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='1' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncR type='linear' slope='1.6' intercept='-.3'/><feFuncG type='linear' slope='1.6' intercept='-.3'/><feFuncB type='linear' slope='1.6' intercept='-.3'/></feComponentTransfer></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--night); color: var(--cream); font-family: var(--f-term); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#app { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--night); }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }
button { font: inherit; color: inherit; }
kbd { font: 400 22px/1 var(--f-term); color: var(--phos); background: transparent; border: 2px solid rgba(217,212,199,.35); padding: 1px 6px 0; margin: 0 2px; }
.pad-glyph { font: 400 20px/1 var(--f-term); letter-spacing: .08em; text-transform: uppercase; border: 2px solid currentColor; border-radius: 99px; padding: 0 8px; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; padding-inline: max(16px, 4vw); padding-block: max(14px, 3.5vh); z-index: 2; }
.screen[hidden] { display: none !important; }

/* channel flick used between screens: a bright band of broken signal */
#flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; z-index: 6; transition: opacity .3s steps(4, end);
  background: var(--noise) 0 0 / 240px 240px, repeating-linear-gradient(180deg, rgba(231,226,212,.55) 0 3px, rgba(231,226,212,.1) 3px 7px); }
#flash.on { opacity: .75; transition: none; }

/* TV static: loading, and the flick at every title cut (driven by title.js) */
.tv-static { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; background: #333 var(--noise) 0 0 / 240px 240px; animation: static-jitter .3s steps(6, end) infinite; transition: opacity .6s steps(6, end); }
.tv-static.on { opacity: 1; }
.tv-static.burst { opacity: .6; transition: none; }
@keyframes static-jitter { 0% { background-position: 0 0; } 20% { background-position: -83px 41px; } 40% { background-position: 57px -112px; } 60% { background-position: -140px -27px; } 80% { background-position: 101px 88px; } 100% { background-position: 13px -66px; } }

.boot { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: #333 var(--noise) 0 0 / 240px 240px; animation: static-jitter .3s steps(6, end) infinite; transition: opacity .5s steps(5, end); }
.boot p { margin: 0; padding: 8px 18px; background: rgba(7,9,11,.7); font: 400 40px/1 var(--f-term); letter-spacing: .12em; color: var(--osd); text-shadow: 0 0 10px rgba(143,191,127,.6); text-transform: uppercase; }
.boot.gone { opacity: 0; pointer-events: none; }

/* ---------------------------------------------------------------- shared type */
.osd { position: absolute; left: max(40px, 4.5vw); top: max(28px, 5vh); z-index: 4; margin: 0; display: none; font: 400 clamp(30px, 3.4vw, 48px)/1 var(--f-term); letter-spacing: .06em; color: var(--osd); text-shadow: 0 0 10px rgba(143,191,127,.6), 3px 3px 0 rgba(7,9,11,.6); pointer-events: none; }
#scr-title:not([hidden]) ~ .osd, #scr-main:not([hidden]) ~ .osd { display: block; }
.osd small { display: block; margin-top: 8px; font-size: .62em; color: var(--cream); text-shadow: 0 0 8px rgba(217,212,199,.4), 2px 2px 0 rgba(7,9,11,.7); }
.osd small[hidden] { display: none; }
@keyframes blink { 0%, 54% { opacity: 1; } 55%, 100% { opacity: 0; } }

/* ---------------------------------------------------------------- title */
#scr-title { align-items: center; justify-content: center; gap: clamp(18px, 4.2vh, 44px); }
.logo-wrap { position: relative; width: min(760px, 86vw); margin: 0; display: flex; flex-direction: column; align-items: center; font-weight: 400; animation: logo-in .5s steps(5, end) both; }
.logo-top { font: 400 clamp(22px, 3.5vw, 50px)/1 var(--f-pixel); letter-spacing: .16em; color: var(--phos); text-shadow: .1em .1em 0 #4a2418, 0 0 14px rgba(224,164,74,.35); }
.logo { display: block; width: 100%; height: auto; margin-top: 10px; overflow: visible; }
.logo-place { margin: clamp(10px, 2.4vh, 22px) 0 0; font: 400 clamp(18px, 2.5vw, 36px)/1 var(--f-term); letter-spacing: .3em; text-align: center; text-transform: uppercase; color: var(--teal); text-shadow: 0 0 10px rgba(127,179,173,.45), 3px 3px 0 rgba(7,9,11,.6); }
@keyframes logo-in { from { transform: translateY(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
.press-start { display: flex; align-items: center; gap: clamp(14px, 1.8vw, 26px); background: none; border: 0; cursor: pointer; padding: 12px 20px; }
.press-start > span { font: 400 clamp(20px, 2.4vw, 34px)/1 var(--f-pixel); letter-spacing: .12em; text-transform: uppercase; color: #e7e2d4; text-shadow: -2px 0 rgba(255,80,80,.4), 2px 0 rgba(80,200,255,.4), 0 0 12px rgba(231,226,212,.35), 3px 3px 0 rgba(7,9,11,.6); animation: blink 1s steps(1, end) infinite; }
.press-start svg { width: clamp(16px, 1.7vw, 24px); height: auto; flex: none; }
.press-start:focus-visible { outline: 4px solid var(--phos); outline-offset: 6px; }
.title-foot, .title-copy { margin: 0; text-align: center; font: 400 clamp(20px, 2.1vw, 30px)/1.1 var(--f-term); letter-spacing: .12em; text-transform: uppercase; color: #a9bcb9; text-shadow: 0 0 8px rgba(169,188,185,.3), 2px 2px 0 rgba(7,9,11,.75); }
.title-copy { margin-top: calc(clamp(18px, 4.2vh, 44px) * -0.5); font-size: clamp(18px, 1.9vw, 28px); color: var(--grey); }
.title-foot .pad-glyph { font-size: .9em; }

/* the TV's picture button: cycles the colour grade on the title video (title.js wires it) */
.tv-picture { position: absolute; right: max(40px, 4.5vw); bottom: max(28px, 5vh); text-transform: uppercase; z-index: 4; display: none; align-items: center; gap: 12px; padding: 6px 12px; background: rgba(7,9,11,.55); border: 2px solid rgba(143,191,127,.55); color: var(--osd); font: 400 clamp(20px, 1.9vw, 28px)/1 var(--f-term); letter-spacing: .08em; cursor: pointer; text-shadow: 0 0 8px rgba(143,191,127,.5); }
#scr-title:not([hidden]) ~ .tv-picture, #scr-main:not([hidden]) ~ .tv-picture { display: flex; }
.tv-picture kbd { font-size: 1em; color: var(--cream); border: 0; padding: 0; margin: 0; }
.tv-picture:focus-visible { outline: 3px solid var(--osd); outline-offset: 3px; }

/* ---------------------------------------------------------------- windows, banners, menus */
.banner { margin: 0; display: inline-block; font: 400 clamp(16px, 1.7vw, 24px)/1 var(--f-pixel); letter-spacing: .12em; text-transform: uppercase; color: var(--phos); text-shadow: 0 0 12px rgba(224,164,74,.4), 3px 3px 0 rgba(7,9,11,.7); }
.banner > span { display: inline-block; }

#scr-main { justify-content: center; }
.menu-col { position: relative; width: min(588px, 100%); box-sizing: border-box; margin: auto 0 auto clamp(0px, 4vw, 70px); padding: 34px 40px 30px; display: flex; flex-direction: column; background: var(--glass); border: 4px solid var(--cream); box-shadow: inset 0 0 0 4px var(--glass-solid), inset 0 0 0 6px var(--line); clip-path: var(--pixel-corners); }
.menu-col .banner, .pause-card .banner { display: block; }
.menu-col .banner::after, .pause-card .banner::after { content: ""; display: block; height: 4px; margin: 20px 0 22px; background: repeating-linear-gradient(90deg, var(--line) 0 4px, transparent 4px 8px); }
.menu-list { display: flex; flex-direction: column; gap: 12px; }
.menu-item { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; width: 100%; box-sizing: border-box; text-align: left; cursor: pointer; background: transparent; border: 0; padding: 12px 20px 14px 66px; color: var(--cream-dim); }
.mi-title { font: 400 clamp(48px, 5.2vw, 76px)/.8 var(--f-term); letter-spacing: .04em; text-transform: uppercase; }
.mi-sub { font: 400 clamp(22px, 2.1vw, 30px)/1 var(--f-term); letter-spacing: .14em; text-transform: uppercase; color: var(--grey); }
.menu-item::before { content: ""; position: absolute; left: 22px; top: 22px; width: 24px; height: 28px; background: var(--phos); clip-path: polygon(0 0, 33.3% 0, 33.3% 14.3%, 66.6% 14.3%, 66.6% 28.6%, 83.3% 28.6%, 83.3% 42.9%, 100% 42.9%, 100% 57.1%, 83.3% 57.1%, 83.3% 71.4%, 66.6% 71.4%, 66.6% 85.7%, 33.3% 85.7%, 33.3% 100%, 0 100%); visibility: hidden; animation: blink .8s steps(1, end) infinite; }
.menu-item.sel { background: var(--dither); color: var(--phos); }
.menu-item.sel .mi-title { text-shadow: 0 0 12px rgba(224,164,74,.35); }
.menu-item.sel .mi-sub { color: #b9d3cf; }
.menu-item.sel::before { visibility: visible; }
.menu-item:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.menu-item.small { padding: 10px 18px 12px 56px; }
.menu-item.small .mi-title { font-size: clamp(36px, 3.6vw, 52px); }
.menu-item.small::before { left: 18px; top: 14px; width: 18px; height: 21px; }

.hint-bar { position: relative; z-index: 1; margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px 26px; justify-content: center; font: 400 clamp(20px, 1.8vw, 26px)/1.4 var(--f-term); letter-spacing: .08em; text-transform: uppercase; color: var(--cream-dim); text-shadow: 2px 2px 0 rgba(7,9,11,.8); }
#scr-main .hint-bar { justify-content: flex-start; padding-left: clamp(0px, 4vw, 70px); }

/* ---------------------------------------------------------------- setup screens */
#scr-names, #scr-mode, #scr-env { background: radial-gradient(ellipse 80% 70% at 50% 45%, #121a24 0%, var(--crt) 70%); }
#scr-kids, #scr-cars { background: linear-gradient(180deg, rgba(11,15,20,.7), rgba(11,15,20,0) 20%, rgba(11,15,20,0) 80%, rgba(11,15,20,.75)); }
.scr-head { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; position: relative; z-index: 1; padding-left: clamp(0px, 6vw, 110px); }
.scr-head .banner { font-size: clamp(18px, 2vw, 28px); }
.back { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; background: var(--glass); border: 3px solid var(--cream); padding: 6px 14px 4px 12px; font: 400 26px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; color: var(--cream); }
.back::before { content: ""; width: 12px; height: 14px; background: currentColor; clip-path: polygon(100% 0, 66% 0, 66% 14%, 33% 14%, 33% 43%, 0 43%, 0 57%, 33% 57%, 33% 86%, 66% 86%, 66% 100%, 100% 100%); }
.back:hover, .back:focus-visible { border-color: var(--phos); color: var(--phos); outline: none; }

.panes { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; padding-block: 18px; position: relative; }
.panes.one { grid-template-columns: minmax(0, 560px); justify-content: center; }
.pane { --pc: var(--p1); position: relative; min-width: 0; display: flex; flex-direction: column; border: 4px solid var(--pc); background: linear-gradient(180deg, rgba(14,20,30,.35), rgba(14,20,30,.1) 45%, rgba(14,20,30,.55)); box-shadow: inset 0 0 0 4px rgba(7,9,11,.6); }
.pane.p2 { --pc: var(--p2); }
.pane-tag { position: absolute; left: 14px; top: 12px; z-index: 2; display: flex; align-items: baseline; gap: 10px; font: 400 14px/1 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; background: var(--pc); color: var(--ink); padding: 8px 12px 7px; }
.pane-tag b { font: 400 24px/.7 var(--f-term); letter-spacing: .08em; opacity: 1; }

/* names */
#scr-names .panes { align-content: center; }
#scr-names .pane { padding: 64px 26px 26px; gap: 14px; max-height: 340px; align-self: center; background: var(--glass); }
.name-label { font: 400 26px/1.1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; color: var(--teal); }
.name-row { display: flex; gap: 12px; }
.name-input { flex: 1; min-width: 0; font: 400 clamp(40px, 4vw, 56px)/1 var(--f-term); letter-spacing: .06em; text-transform: uppercase; color: var(--phos); caret-color: var(--phos); background: var(--night); border: 4px solid var(--cream); padding: 8px 14px 4px; text-shadow: 0 0 10px rgba(224,164,74,.35); }
.name-input::placeholder { color: #4d565c; text-shadow: none; }
.name-input:focus { outline: 4px solid var(--pc); outline-offset: 2px; }
.dice { cursor: pointer; flex: none; width: 66px; border: 4px solid var(--cream); background: var(--pc); display: grid; place-items: center; }
.dice svg { width: 34px; height: 34px; }
.dice:active { transform: translate(2px, 2px); }
.dice:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.name-tip { margin: 0; font: 400 22px/1.3 var(--f-term); letter-spacing: .06em; color: var(--grey); }
.scr-foot { display: flex; justify-content: center; padding-bottom: 8px; position: relative; }
.go-btn { cursor: pointer; font: 400 clamp(14px, 1.4vw, 20px)/1 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; background: var(--glass); color: var(--phos); border: 4px solid var(--cream); padding: 18px 28px 16px; text-shadow: 0 0 10px rgba(224,164,74,.35); }
.go-btn:hover, .go-btn:focus-visible { background: var(--phos); color: var(--ink); text-shadow: none; outline: none; }

/* character + vehicle select */
.view { position: relative; flex: 1; min-height: 150px; }      /* the 3D preview is drawn into this box */
.plate { position: relative; z-index: 1; margin: 0 14px; padding: 12px 16px; background: var(--glass); border: 2px solid var(--line); display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 12px; }
.arrow { cursor: pointer; width: 46px; height: 46px; border: 3px solid var(--cream); background: var(--glass-solid); color: var(--phos); font: 400 40px/1 var(--f-term); display: grid; place-items: center; padding: 0 0 4px; }
.arrow:hover { background: var(--phos); color: var(--ink); }
.arrow:active { transform: translate(2px, 2px); }
.arrow:focus-visible { outline: 3px solid var(--pc); outline-offset: 2px; }
.plate-mid { min-width: 0; text-align: center; }
.plate-name { margin: 0; font: 400 clamp(18px, 1.9vw, 26px)/1.1 var(--f-pixel); letter-spacing: .06em; text-transform: uppercase; color: var(--cream); text-wrap: balance; }
.plate-tag { margin: 6px 0 0; font: 400 22px/1 var(--f-term); letter-spacing: .14em; text-transform: uppercase; color: var(--pc); }
.plate-blurb { grid-column: 1 / -1; margin: 4px 0 0; font: 400 22px/1.2 var(--f-term); letter-spacing: .03em; color: var(--cream-dim); text-align: center; text-wrap: pretty; }
.thumbs { position: relative; z-index: 1; display: flex; justify-content: center; gap: 10px; padding: 12px 14px 14px; flex-wrap: wrap; }
.thumb { cursor: pointer; width: 66px; height: 66px; padding: 0; border: 3px solid var(--line); background: var(--glass-solid); overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; display: block; object-fit: cover; image-rendering: pixelated; }
.thumb.sel { border-color: var(--pc); transform: translateY(-4px); box-shadow: 0 0 0 3px var(--night), 0 0 16px color-mix(in srgb, var(--pc) 70%, transparent); }
.thumb:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.thumb .mini-name { position: absolute; left: 0; right: 0; bottom: 0; font: 400 16px/1.1 var(--f-term); letter-spacing: .06em; text-transform: uppercase; color: var(--cream); background: rgba(7,9,11,.78); }
.ready-btn { position: relative; z-index: 1; margin: 0 14px 14px; cursor: pointer; font: 400 clamp(14px, 1.3vw, 18px)/1 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; background: var(--glass); color: var(--cream); border: 4px solid var(--cream); padding: 16px 10px 14px; }
.ready-btn:hover, .ready-btn:focus-visible { background: var(--phos); color: var(--ink); outline: none; }
.pane.ready .ready-btn { background: var(--pc); color: var(--ink); }
.stamp { position: absolute; z-index: 3; left: 50%; top: 34%; transform: translate(-50%, -50%) rotate(-8deg) scale(.4); opacity: 0; font: 400 clamp(30px, 4vw, 54px)/1 var(--f-pixel); letter-spacing: .06em; text-transform: uppercase; color: var(--phos); text-shadow: 5px 5px 0 #4a2418, -2px 0 rgba(255,80,80,.45), 2px 0 rgba(80,200,255,.45); pointer-events: none; transition: transform .25s steps(4, end), opacity .15s steps(2, end); }
.pane.ready .stamp { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
.stats { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 6px 10px; margin: 6px 0 0; align-items: center; }
.stats dt { font: 400 20px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; color: var(--teal); text-align: right; }
.stats dd { margin: 0; display: flex; gap: 4px; }
.stats dd i { flex: 1; height: 12px; background: rgba(217,212,199,.14); }
.stats dd i.on { background: var(--phos); box-shadow: 0 0 6px rgba(224,164,74,.45); }
#scr-cars .thumb { width: 56px; height: 56px; }
#scr-cars .thumbs { padding-top: 6px; }
#scr-cars .swatches { padding: 8px 14px 8px; }
#scr-cars .swatch { width: 28px; height: 28px; }
@media (max-height: 820px) { #scr-cars .plate-blurb { display: none; } #scr-kids .plate-blurb { font-size: 20px; } }
.swatches { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px 14px; position: relative; z-index: 1; }
.swatch { cursor: pointer; width: 34px; height: 34px; border: 3px solid rgba(217,212,199,.35); padding: 0; }
.swatch.sel { border-color: var(--cream); box-shadow: 0 0 0 3px var(--pc); transform: translateY(-3px); }
.swatch:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.paint-name { position: relative; z-index: 1; text-align: center; margin: -6px 0 6px; font: 400 22px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; color: var(--cream-dim); }

/* modes: cartridges */
.modes { flex: 1; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2.5vw, 30px); flex-wrap: wrap; position: relative; }
.mode-card { cursor: pointer; width: clamp(200px, 25vw, 280px); aspect-ratio: 4 / 5; max-width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; padding: 18px 16px 24px; background: var(--glass); border: 4px solid var(--cream); box-shadow: inset 0 0 0 4px var(--glass-solid), inset 0 0 0 6px var(--line); clip-path: var(--pixel-corners); position: relative; overflow: hidden; color: var(--cream-dim); }
.mode-card svg { width: 64%; height: auto; margin-bottom: auto; margin-top: 10%; image-rendering: pixelated; }
.mc-title { font: 400 clamp(16px, 1.7vw, 24px)/1 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; }
.mc-sub { font: 400 22px/1.1 var(--f-term); letter-spacing: .06em; text-transform: uppercase; text-align: center; color: var(--grey); }
.mode-card.sel { background: var(--dither); color: var(--phos); transform: translateY(-8px); }
.mode-card.sel .mc-sub { color: #b9d3cf; }
.mode-card.sel .mc-title { text-shadow: 0 0 12px rgba(224,164,74,.4); }
.mode-card.locked svg { filter: grayscale(1) brightness(.6); }
.mode-card.locked::after { content: "SOON"; position: absolute; top: 20px; right: -36px; transform: rotate(35deg); background: var(--plum); color: var(--cream); font: 400 12px/1 var(--f-pixel); letter-spacing: .1em; padding: 7px 42px 6px; border-block: 3px solid var(--cream); }
.mode-card.locked.sel { background: repeating-linear-gradient(180deg, rgba(95,107,115,.25) 0 2px, transparent 2px 4px), var(--glass); color: var(--cream); }
.mode-card.locked.sel .mc-sub { color: var(--grey); }
.mode-card.shake { animation: shake .35s steps(4, end); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.mode-card:focus-visible { outline: 3px solid var(--phos); outline-offset: 4px; }

/* around town (environment settings): one game window per setting */
.env { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: clamp(14px, 2.4vh, 24px); width: min(960px, 100%); margin-inline: auto; padding: 16px 14px 16px 4px; }
.env-row { position: relative; overflow: hidden; display: grid; grid-template-columns: clamp(150px, 21vw, 220px) minmax(0, 1fr) auto; align-items: center; gap: 10px 22px; padding: 16px 24px 16px 54px; background: var(--glass); border: 4px solid var(--cream); box-shadow: inset 0 0 0 4px var(--glass-solid), inset 0 0 0 6px var(--line); clip-path: var(--pixel-corners); transition: transform .15s steps(3, end); }
.env-row::before { content: ""; position: absolute; left: 20px; top: 50%; width: 18px; height: 21px; margin-top: -10px; background: var(--phos); clip-path: polygon(0 0, 33.3% 0, 33.3% 14.3%, 66.6% 14.3%, 66.6% 28.6%, 83.3% 28.6%, 83.3% 42.9%, 100% 42.9%, 100% 57.1%, 83.3% 57.1%, 83.3% 71.4%, 66.6% 71.4%, 66.6% 85.7%, 33.3% 85.7%, 33.3% 100%, 0 100%); visibility: hidden; animation: blink .8s steps(1, end) infinite; }
.env-row.sel { border-color: var(--phos); transform: translateX(10px); }
.env-row.sel::before { visibility: visible; }
.env-row.sel .env-title { color: var(--phos); text-shadow: 0 0 12px rgba(224,164,74,.4); }
.env-art { width: 100%; height: auto; display: block; image-rendering: pixelated; filter: saturate(.7) sepia(.15) drop-shadow(0 4px 0 rgba(0,0,0,.35)); }
.env-title { margin: 0; font: 400 clamp(16px, 1.6vw, 22px)/1.1 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; color: var(--cream); }
.env-sub { margin: 8px 0 0; font: 400 22px/1.2 var(--f-term); letter-spacing: .03em; color: var(--cream-dim); text-wrap: pretty; }
.env-opts { display: flex; gap: 8px; }
.env-opts button { cursor: pointer; min-width: 70px; font: 400 26px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; padding: 8px 12px 6px; border: 3px solid var(--cream); background: var(--glass-solid); color: var(--cream-dim); }
.env-opts button:hover:not(:disabled) { color: var(--phos); border-color: var(--phos); }
.env-opts button[aria-checked="true"] { background: var(--phos); border-color: var(--phos); color: var(--ink); }
.env-opts button:active:not(:disabled) { transform: translate(2px, 2px); }
.env-opts button:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.env-row.locked { background: repeating-linear-gradient(180deg, rgba(95,107,115,.18) 0 2px, transparent 2px 4px), var(--glass); }
.env-row.locked .env-art { filter: grayscale(1) brightness(.6); }
.env-row.locked .env-opts button { cursor: not-allowed; opacity: .55; }
.env-row.locked::after { content: "SOON"; position: absolute; top: 16px; right: -38px; transform: rotate(35deg); background: var(--plum); color: var(--cream); font: 400 12px/1 var(--f-pixel); letter-spacing: .1em; padding: 7px 44px 6px; border-block: 3px solid var(--cream); }
.env-row.shake { animation: shake .35s steps(4, end); }
#scr-env .scr-foot { padding-block: 4px 12px; }
#env-go.sel { background: var(--phos); color: var(--ink); text-shadow: none; }
@media (max-width: 760px) { .env-row { grid-template-columns: 1fr; justify-items: start; } .env-art { width: min(260px, 100%); } }

/* loading: tuning in */
#scr-load { background: var(--crt); align-items: center; justify-content: center; }
.load-card { width: min(760px, 100%); display: flex; flex-direction: column; gap: 14px; }
.load-kicker { margin: 0; font: 400 32px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; color: var(--osd); text-shadow: 0 0 10px rgba(143,191,127,.55); }
.load-kicker::before { content: "CH 03 · "; }
.load-title { margin: 0; font: 400 clamp(22px, 3vw, 40px)/1.2 var(--f-pixel); letter-spacing: .06em; text-transform: uppercase; color: var(--phos); text-shadow: 4px 4px 0 #4a2418, 0 0 14px rgba(224,164,74,.35); text-wrap: balance; }
.bar { height: 30px; border: 4px solid var(--cream); background: var(--night); padding: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--phos) 0 18px, transparent 18px 24px); transition: width .3s steps(6, end); }
.load-step { margin: 0; font: 400 26px/1.2 var(--f-term); letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 16px; margin-top: 16px; }
.ctl { --pc: var(--p1); border: 3px solid var(--pc); padding: 14px 18px; background: var(--glass); min-width: 0; }
.ctl.p2 { --pc: var(--p2); }
.ctl h3 { margin: 0 0 10px; font: 400 14px/1.2 var(--f-pixel); letter-spacing: .08em; text-transform: uppercase; color: var(--pc); }
.ctl dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font: 400 21px/1.25 var(--f-term); letter-spacing: .03em; align-items: center; }
.ctl dt { white-space: nowrap; }
.ctl dd { margin: 0; color: var(--cream-dim); }

/* ---------------------------------------------------------------- in-game HUD */
.play { padding: 0; }
#hud { position: absolute; inset: 0; pointer-events: none; }
.vp { position: absolute; left: 0; right: 0; overflow: hidden; }
.vp.full { top: 0; bottom: 0; }
.vp.top { top: 0; height: 50%; }
.vp.bottom { bottom: 0; height: 50%; }
.vp.bottom::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--cream); box-shadow: 0 0 0 2px var(--night); z-index: 1; }
.hud-tl { position: absolute; left: max(28px, 3vw); top: max(20px, 3vh); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.who { --pc: var(--p1); display: flex; align-items: center; gap: 10px; background: var(--pc); color: var(--ink); padding: 4px 12px 4px 4px; font: 400 14px/1 var(--f-pixel); letter-spacing: .06em; text-transform: uppercase; }
.who.p2 { --pc: var(--p2); }
.who img { width: 30px; height: 30px; background: rgba(7,9,11,.25); image-rendering: pixelated; }
.who span { display: inline-block; }
.speedo { background: var(--glass); border: 2px solid var(--line); padding: 6px 12px 8px; min-width: 150px; }
.speedo b { font: 400 60px/.8 var(--f-term); font-variant-numeric: tabular-nums; color: var(--phos); text-shadow: 0 0 10px rgba(224,164,74,.4); }
.speedo small { font: 400 20px/1 var(--f-term); letter-spacing: .1em; color: var(--teal); margin-left: 6px; }
.speedo .street { font: 400 20px/1.1 var(--f-term); letter-spacing: .12em; text-transform: uppercase; color: var(--osd); margin-top: 4px; max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--glass); border: 3px solid var(--cream); padding: 4px 16px 4px 8px; font: 400 26px/1 var(--f-term); letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; opacity: 0; transition: opacity .2s steps(2, end); }
.prompt.on { opacity: 1; }
.vp.top .prompt, .vp.bottom .prompt { bottom: 12px; }
.prompt kbd { font-size: 24px; background: var(--phos); color: var(--ink); border-color: var(--phos); }
.splash { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; animation: splash 3.4s steps(24, end) forwards; }
.splash h2 { margin: 0; font: 400 clamp(22px, 3.6vw, 48px)/1.1 var(--f-pixel); letter-spacing: .06em; text-transform: uppercase; color: var(--phos); text-shadow: 5px 5px 0 #4a2418, 0 0 16px rgba(224,164,74,.4); }
.splash p { margin: 12px 0 0; font: 400 clamp(22px, 2.2vw, 30px)/1.2 var(--f-term); letter-spacing: .06em; color: var(--cream); text-shadow: 2px 2px 0 rgba(7,9,11,.85); }
@keyframes splash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.minimap { position: absolute; right: max(28px, 3vw); background: var(--glass); border: 3px solid var(--cream); padding: 4px; }
.minimap canvas { display: block; width: 120px; height: auto; image-rendering: pixelated; }
.minimap.solo { top: max(20px, 3vh); }
.minimap.split { top: 50%; transform: translateY(-50%); z-index: 2; }
.hud-keys { position: absolute; right: max(28px, 3vw); bottom: max(20px, 3vh); font: 400 20px/1.7 var(--f-term); letter-spacing: .04em; color: var(--cream-dim); background: var(--glass); padding: 4px 12px; border: 2px solid var(--line); }
.hud-keys kbd { font-size: 20px; }
.vp.top .hud-keys, .vp.bottom .hud-keys { display: none; }

.pause { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(7,9,11,.62); pointer-events: auto; padding-inline: 16px; }
.pause-card { width: min(520px, 100%); box-sizing: border-box; padding: 30px 36px 26px; display: flex; flex-direction: column; background: var(--glass); border: 4px solid var(--cream); box-shadow: inset 0 0 0 4px var(--glass-solid), inset 0 0 0 6px var(--line); clip-path: var(--pixel-corners); }

.mute { position: absolute; z-index: 7; right: max(40px, 4.5vw); top: max(28px, 5vh); width: 46px; height: 46px; border: 3px solid var(--cream); background: rgba(14,20,30,.7); color: var(--cream); cursor: pointer; display: grid; place-items: center; }
.mute svg { width: 24px; height: 24px; }
.mute .x { display: none; }
.mute[aria-pressed="true"] .x { display: inline; }
.mute[aria-pressed="true"] .waves { display: none; }
.mute:focus-visible { outline: 3px solid var(--phos); outline-offset: 2px; }
body.playing .mute { top: auto; bottom: max(20px, 3vh); right: auto; left: max(28px, 3vw); }

/* ---------------------------------------------------------------- the CRT tube over everything */
.crt { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
.crt-scan { background: repeating-linear-gradient(180deg, rgba(0,0,0,.3) 0 2px, transparent 2px 4px); }
.crt-grille { background: repeating-linear-gradient(90deg, rgba(255,60,60,.05) 0 1px, rgba(60,255,120,.04) 1px 2px, rgba(80,120,255,.05) 2px 3px); }
.crt-roll { bottom: auto; height: 120px; background: linear-gradient(180deg, transparent, rgba(255,255,255,.045), transparent); animation: roll 9s linear infinite; }
@keyframes roll { from { transform: translateY(-120px); } to { transform: translateY(100vh); } }
.crt-glare { background: radial-gradient(ellipse 60% 42% at 28% 14%, rgba(255,255,255,.07), transparent 70%); }
.crt-tube { inset: 10px; border-radius: 4.5vmin / 3.6vmin; box-shadow: 0 0 0 60vmax var(--night), inset 0 0 12vmin 3vmin rgba(0,0,0,.66), inset 0 0 14px 3px rgba(0,0,0,.9); }
body.playing .crt-scan { opacity: .55; }
body.playing .crt-tube { box-shadow: 0 0 0 60vmax var(--night), inset 0 0 8vmin 1.5vmin rgba(0,0,0,.5), inset 0 0 14px 3px rgba(0,0,0,.9); }

@media (max-width: 700px) {
  .pane-tag { font-size: 12px; }
  .thumb { width: 54px; height: 54px; }
  .hint-bar { display: none; }
  .speedo b { font-size: 44px; }
  .minimap canvas { width: 84px; }
  .menu-col { padding: 24px 22px 22px; }
  .menu-item { padding-left: 52px; }
  .menu-item::before { left: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .tv-static, .boot { animation: none !important; }
}
