/* Original toy-dashboard palette; no animated or filtered game surround. */
:root{font-family:"Trebuchet MS",Arial,Helvetica,sans-serif;color:#f7f4df;background:#171e2a;color-scheme:dark}
*{box-sizing:border-box}
body{margin:0}
a{color:#ffdd5b}
button,input{font:inherit}
button{min-height:44px;padding:9px 16px;border:2px solid #222b3b;border-radius:9px;background:linear-gradient(#e7ebef,#a9b3c0);box-shadow:inset 0 1px 0 #fff,0 3px 0 #080e19;color:#1a2434;font-weight:bold;cursor:pointer;touch-action:manipulation}
button:active,button[aria-pressed=true]{background:#ffb43d;transform:translateY(2px);box-shadow:inset 0 1px 2px #5b340755,0 1px 0 #080e19}
button:focus-visible,input:focus-visible,a:focus-visible,[data-steering]:focus-visible{outline:3px solid #ffe76b;outline-offset:4px}
button:disabled{opacity:.65;cursor:wait}
.game-page{min-height:100svh;display:flex;flex-direction:column;justify-content:flex-start;padding:24px 16px 18px;background:radial-gradient(ellipse at 50% 12%,#354061 0,transparent 62%),repeating-linear-gradient(135deg,#ffffff03 0 2px,transparent 2px 12px),#171e2a}
.site-header{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;width:min(820px,100%);margin:0 auto 20px;gap:16px}
.home-link{display:flex;align-items:center;justify-self:start;gap:7px;color:#c7cfdf;font-size:12px;font-weight:bold;text-decoration:none;white-space:nowrap}
.home-link svg{width:25px;height:25px;fill:none;stroke:#ffbb43;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
.home-link:hover{color:#fff}
.brand{position:relative;margin:0;padding:8px 19px 9px;border:5px solid #8592a5;border-radius:14px;background:#f5f5ed;box-shadow:inset 0 0 0 3px #e51b23,inset 0 0 0 5px #fff,0 3px 0 #080b14,0 0 0 2px #394357;color:#071b83;font-family:"Arial Black",Arial,sans-serif;font-size:29px;font-weight:900;font-style:italic;text-transform:uppercase;line-height:.85;letter-spacing:-1.8px;text-align:left;transform:skew(-4deg)}
.brand span{display:block}
.game-page main{width:min(820px,100%);max-width:100%;margin:0 auto;padding:0}
#game-intro{margin:0 0 20px;text-align:center;font-size:15px;line-height:1.5;color:#e3e6ed}
[hidden]{display:none!important}
#player{position:relative;padding:18px 20px 23px;border:3px solid #a3acba;border-radius:20px;background:linear-gradient(100deg,#343b50,#4f5870 50%,#30394c);box-shadow:inset 0 0 0 3px #67738a,inset 0 8px 0 #ffaa37,0 6px 0 #070c16,0 0 0 2px #0a101e,0 16px 32px #0005}
#player::before{content:"";position:absolute;inset:9px;pointer-events:none;background:radial-gradient(circle at 0 0,#dfe5ea 0 2px,#1a2232 3px 4px,transparent 5px),radial-gradient(circle at 100% 0,#dfe5ea 0 2px,#1a2232 3px 4px,transparent 5px),radial-gradient(circle at 0 100%,#dfe5ea 0 2px,#1a2232 3px 4px,transparent 5px),radial-gradient(circle at 100% 100%,#dfe5ea 0 2px,#1a2232 3px 4px,transparent 5px)}
#player::after{content:"";position:absolute;left:25px;right:25px;bottom:7px;height:5px;border-radius:2px;background:repeating-linear-gradient(125deg,#ff9b28 0 9px,#1c2538 9px 17px);pointer-events:none}
#stage{position:relative;width:100%;max-width:640px;aspect-ratio:4/3;background:#000;margin:auto;overflow:hidden;border-radius:7px;box-shadow:0 0 0 3px #111727,0 0 0 5px #7a8497;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
#stage_canvas_container{position:absolute;inset:0;touch-action:none}
#stage canvas{width:100%;height:100%;display:block;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
#media{position:absolute;inset:0;pointer-events:none;overflow:hidden}
#media video,#media canvas{position:absolute;object-fit:fill}
#cover{position:absolute;inset:0;display:flex;align-items:center;justify-content:flex-end;flex-direction:column;padding:20px 20px 7%;background:url('./art/title.png') center/100% 100% no-repeat #111827;text-align:center;color:#fff}
#cover::before{content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(transparent 45%,#060c1a26 65%,#060c1a9c)}
#cover>*{position:relative}
#cover h2,#cover-note{display:none}
#cover.has-message{justify-content:center;background:#121c31f5}
#cover.has-message::before{display:none}
#cover.has-message h2{display:block;margin:0 0 12px;color:#ffdb50;font-size:clamp(20px,4vw,28px)}
#cover.has-message #cover-note{display:block;margin:0 0 16px;max-width:440px;font-size:14px;line-height:1.5}
#loading{max-width:440px;margin:14px 0 0;padding:8px 12px;border-radius:7px;background:#101a2feb;font-size:13px;line-height:1.45;color:#fff}
#loading:empty{display:none}
#start{min-height:60px;min-width:154px;padding:12px 32px;border:3px solid #634210;border-radius:14px;background:linear-gradient(#ffe978,#ffbd29);box-shadow:inset 0 2px 0 #fff6c8,0 5px 0 #8f4210,0 7px 0 #251506,0 10px 18px #0009;font-size:24px;font-weight:900;color:#35230d;text-shadow:0 1px #fff7bc}
#start::before{content:"▶";display:inline-block;margin-right:12px;font-size:17px;vertical-align:2px}
#start:active{transform:translateY(3px);box-shadow:inset 0 2px 0 #fff6c8,0 2px 0 #8f4210,0 4px 0 #251506}
#start:disabled{cursor:wait}
.toolbar{display:flex;gap:9px;justify-content:center;flex-wrap:wrap;padding-top:18px}
.toolbar button{min-height:44px;font-size:13px;padding:8px 14px}
.game-page:not(.is-playing) .toolbar{display:none}
#mobile-controls{display:flex;align-items:center;justify-content:center;gap:18px;max-width:430px;margin:0 auto;padding-top:14px;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.steering-control{display:flex;flex-direction:column;align-items:center;gap:5px;flex:0 0 112px;font-size:.78rem;font-weight:bold;color:#f0ecdc}
[data-steering]{position:relative;width:112px;height:136px;overflow:hidden;border:3px solid #121a2b;border-radius:42px;background:linear-gradient(100deg,#26223e,#4d3d7a,#26223e);box-shadow:inset 0 0 0 2px #8276a0,0 2px 0 #818a9a;touch-action:none;cursor:ns-resize}
.steering-track{position:absolute;top:24px;bottom:24px;left:calc(50% - 2px);width:4px;border-radius:3px;background:#171529}
.steering-arrow{position:absolute;left:0;width:100%;text-align:center;font-size:12px;color:#c9c3d9;line-height:1}
.steering-up{top:7px}.steering-down{bottom:7px}
[data-steering-thumb]{position:absolute;width:48px;height:48px;left:calc(50% - 24px);top:calc(50% - 24px);border:3px solid #372419;border-radius:50%;background:linear-gradient(#ffd55b,#f28519);box-shadow:inset 0 2px 0 #fff0aa,0 3px 0 #100f1a;transform:translate(var(--steering-x,0px),var(--steering-y,0px));pointer-events:none}
[data-steering][data-active=true]{background:#443369}
[data-steering][data-direction=up] .steering-up,[data-steering][data-direction=down] .steering-down{color:#ffda55}
[data-steering][data-active=true] [data-steering-thumb]{background:#ffcc3d}
.driving-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;flex:1;max-width:250px;min-width:0}
#mobile-controls button{min-width:0;min-height:56px;padding:8px 10px;font-weight:bold;touch-action:none}
#mobile-controls button.gas{background:linear-gradient(#c0eb5b,#6ab52c);color:#143509}
#mobile-controls button[data-key="ArrowLeft"]{background:linear-gradient(#ffb04c,#e96a26);color:#361b0a}
#mobile-controls button[data-held=true]{background:#ffe15e;transform:translateY(2px)}
#mobile-controls button:disabled{cursor:default}
#mobile-controls[data-enabled=false] [data-steering]{opacity:.5;cursor:default}
small{font-size:.7rem;opacity:.7;margin-left:4px}
html.has-touch #mobile-controls small{display:none}
#typing{display:flex;gap:8px;flex-wrap:wrap;align-items:center;justify-content:center;margin-top:14px}
#typing label{width:100%;text-align:center;font-size:.85rem;color:#f3eedc}
input{font-size:18px;width:min(240px,65%);padding:9px;border:2px solid #7888a4;border-radius:7px;background:#f5f5ec;color:#192233}
#save-status{margin:12px 0 0;text-align:center;font-size:.8rem}
#save-status:not(.error):not(.notice){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0}
#save-status.error,#save-status.notice{padding:10px 12px;border-radius:7px;background:#10192d;color:#ffe6a2;font-weight:bold;line-height:1.5}
#save-status.error{border:1px solid #ef8b66;color:#ffd6c2}
#retry-save{display:block;margin:10px auto}
#help{max-width:640px;margin:16px auto 0;padding:12px 16px;border:1px solid #68758d;border-radius:10px;background:#232d40;line-height:1.6;color:#dce2ed;font-size:13px}
#help p{margin:6px 0}
#help strong{display:inline-block;min-width:76px;color:#ffda55}
footer{display:flex;justify-content:center;gap:12px;margin:24px 0 0;font-size:11px;line-height:1.6;color:#98a4bb}
footer a{color:#bec8db;text-underline-offset:3px}
footer span::after{content:"·";margin-left:12px;color:#697791}
.game-page.is-playing{justify-content:flex-start;padding-top:14px}
.is-playing .site-header{margin-bottom:16px}
.is-playing .brand{font-size:20px;padding:7px 16px 8px;letter-spacing:-1px;border-width:4px;border-radius:10px}
#player:fullscreen{display:flex;flex-direction:column;justify-content:center;border:0;border-radius:0;padding:8px;background:#141b2b;overflow:auto;box-shadow:none}
#player:fullscreen::before,#player:fullscreen::after{display:none}
#player:fullscreen #stage{flex-shrink:0;max-width:min(100vw,calc((100dvh - 160px)*4/3))}
html.has-touch #player:fullscreen #stage{max-width:min(100%,calc((100dvh - 290px)*4/3))}
#player:fullscreen #save-status,#player:fullscreen .steering-control,#player:fullscreen #typing{color:#fff}
/* The source/license page shares this stylesheet but has no game shell. */
body:not(.game-page){max-width:820px;margin:36px auto;padding:0 24px;line-height:1.7}
body:not(.game-page) header{display:flex;gap:24px;align-items:center;flex-wrap:wrap;margin-bottom:24px}
body:not(.game-page) h1{font-size:26px;color:#ffe270;margin:0}
body:not(.game-page) main{padding:18px 24px;background:#242f43;border:1px solid #66738a;border-radius:14px}

@media(max-width:600px){
 header{padding:16px;gap:6px 16px}header>span{width:100%}
 main{padding:0 6px}#player{padding:6px;border-width:2px}
 .toolbar button{font-size:.8rem;padding:8px 9px}.toolbar{gap:5px}
 #mobile-controls{gap:12px}#mobile-controls button{font-size:.9rem;padding:8px 6px}
 footer{margin:18px auto}
 #help table,#help tbody{display:block}#help tr{display:grid;grid-template-columns:1fr 1fr}#help th,#help td{overflow-wrap:anywhere}
}
@media(hover:hover) and (pointer:fine){html:not(.has-touch) #mobile-controls{display:none}}
/* Keep both hands beside the original 4:3 picture in a short viewport. The
   gutters belong to the host, so no driving control covers a game hotspot. */
@media(max-height:500px) and (orientation:landscape){
 html.has-touch header{padding:6px 14px;gap:8px}
 html.has-touch h1{font-size:1.3rem}html.has-touch header>span{font-size:.75rem}
 html.has-touch main{padding:0 6px}
 html.has-touch #player{padding:6px 170px 6px 122px}
 html.has-touch #stage{max-width:min(640px,calc((100svh - 130px)*4/3))}
 html.has-touch .toolbar{padding-top:6px;gap:6px}
 html.has-touch .toolbar button{padding:4px;font-size:.7rem}
 html.has-touch #mobile-controls{position:absolute;inset:0;max-width:none;padding:0;margin:0;pointer-events:none}
 html.has-touch .steering-control{position:absolute;left:max(6px,env(safe-area-inset-left));top:50%;width:108px;transform:translateY(-50%);pointer-events:auto}
 html.has-touch [data-steering]{width:104px;height:136px}
 html.has-touch .driving-actions{position:absolute;right:max(6px,env(safe-area-inset-right));top:50%;width:150px;transform:translateY(-50%);pointer-events:auto}
 html.has-touch #mobile-controls button{min-height:54px;font-size:.8rem;padding:7px 3px}
 html.has-touch #mobile-controls small{font-size:.65rem;margin-left:2px}
 html.has-touch #save-status{margin:6px 0 0}
 html.has-touch #player:fullscreen{padding:8px 172px 8px 124px;justify-content:center;overflow:auto}
 html.has-touch #player:fullscreen #stage{max-width:min(100%,calc((100dvh - 16px)*4/3))}
 html.has-touch #player:fullscreen .toolbar{position:absolute;right:max(8px,env(safe-area-inset-right));top:max(8px,env(safe-area-inset-top));width:150px;display:grid;grid-template-columns:1fr 1fr;padding:0;gap:5px}
 html.has-touch #player:fullscreen .toolbar button{min-height:38px;padding:5px 3px}
 html.has-touch #player:fullscreen .driving-actions{top:auto;bottom:max(12px,env(safe-area-inset-bottom));transform:none}
 html.has-touch #player:fullscreen #save-status{position:absolute;left:max(8px,env(safe-area-inset-left));bottom:max(8px,env(safe-area-inset-bottom));width:104px;margin:0;font-size:.7rem}
 html.has-touch #player:fullscreen:has(#typing:not([hidden])) #stage{max-width:min(100%,calc((100dvh - 120px)*4/3))}
 html.has-touch #player:fullscreen #typing{margin-top:8px;gap:5px}
 html.has-touch #player:fullscreen #typing label{font-size:.7rem}
}

/* Driving controls have no role in the original menus or track editor. */
#player:not(.is-driving) #mobile-controls{display:none}
#native-menu{max-width:640px;margin:12px auto 0;padding:10px;border:1px solid #78869e;border-radius:8px;background:#263249}
#native-menu[hidden],html:not(.has-touch) #native-menu{display:none}
#native-menu [data-menu-title]{margin:0 0 8px;font-size:.9rem;font-weight:bold;text-align:center}
#native-menu [data-menu-actions]{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
#native-menu button{min-height:46px;padding:8px;font-size:.9rem}
#native-menu [data-menu-action=practice],#native-menu [data-menu-action=back]{grid-column:1/-1}
#native-menu [data-menu-note]{margin:8px 0 0;font-size:.75rem;line-height:1.4;text-align:center}
#native-menu button:disabled{cursor:default}
html.has-touch #player:not(.is-driving):fullscreen #stage{max-width:min(100%,calc((100dvh - 110px)*4/3))}
html.has-touch #player.has-native-menu:not(.is-driving):fullscreen #stage{max-width:min(100%,calc((100dvh - 310px)*4/3))}
html.has-touch #player:not(.is-driving):fullscreen:has(#typing:not([hidden])) #stage{max-width:min(100%,calc((100dvh - 210px)*4/3))}
@media(max-height:500px) and (orientation:landscape){
 html.has-touch #player:not(.is-driving){padding:6px}
 html.has-touch #player.has-native-menu:not(.is-driving){padding-right:190px}
 html.has-touch #native-menu{position:absolute;top:8px;right:max(8px,env(safe-area-inset-right));width:174px;max-height:calc(100% - 16px);overflow:auto;margin:0;padding:8px}
 html.has-touch #native-menu [data-menu-actions]{grid-template-columns:1fr;gap:6px}
 html.has-touch #native-menu button{min-height:42px;font-size:.8rem;padding:6px}
 html.has-touch #native-menu [data-menu-title]{font-size:.8rem;margin-bottom:6px}
 html.has-touch #native-menu [data-menu-note]{font-size:.7rem}
 html.has-touch #player:not(.is-driving):fullscreen{padding:8px 172px 8px 8px}
 html.has-touch #player.has-native-menu:not(.is-driving):fullscreen{padding-right:190px}
 html.has-touch #player:not(.is-driving):fullscreen #stage,html.has-touch #player.has-native-menu:not(.is-driving):fullscreen #stage{max-width:min(100%,calc((100dvh - 16px)*4/3))}
 html.has-touch #player:not(.is-driving):fullscreen #save-status{left:auto;right:max(8px,env(safe-area-inset-right));width:150px}
 html.has-touch #player:fullscreen #native-menu{top:100px;max-height:calc(100% - 148px)}
}

@media(max-width:600px){
 .game-page{padding:18px 10px 16px}
 .site-header{margin-bottom:18px;gap:8px}
 .home-link{font-size:11px;gap:3px}.home-link span{display:none}
 .brand{font-size:26px;padding:8px 16px 9px}
 .game-page main{padding:0}
 #game-intro{font-size:13px;margin-bottom:17px}
 #player{padding:11px 10px 18px;border-width:3px;border-radius:15px}
 #player::before{inset:6px}#player::after{left:18px;right:18px;bottom:6px;height:4px}
 .toolbar{padding-top:14px;gap:6px}.toolbar button{font-size:12px;padding:8px 10px}
 #start{min-height:53px;min-width:138px;font-size:21px;padding:9px 26px}
 .is-playing .site-header{margin-bottom:13px}
 #help{padding:10px 12px}#help strong{min-width:65px}
 footer{font-size:10px;margin-top:20px;gap:9px}
 footer span::after{margin-left:9px}
}
@media(max-height:500px) and (orientation:landscape){
 .game-page,.game-page.is-playing{padding:7px 10px}
 .game-page .site-header{margin-bottom:9px;padding:0;min-height:24px}
 .game-page .brand,.game-page.is-playing .brand{font-size:14px;padding:4px 14px 5px;border-width:3px;border-radius:8px;line-height:.8;letter-spacing:-.5px}
 #game-intro{font-size:12px;margin-bottom:10px}
 .game-page main{padding:0}
 .game-page footer{margin-top:10px;font-size:10px}
 .game-page #player::after{display:none}
}
#player:fullscreen #save-status.error,#player:fullscreen #save-status.notice{position:absolute;left:12px;right:12px;bottom:8px;width:auto;max-height:40%;overflow:auto;z-index:5;margin:0;background:#171f33f5}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}
