/* Individual raster assets keep their intrinsic ratios. 9-slice preserves the wood frames. */
#game{container-type:inline-size;--ink:#321708;--honey:#ffe38d;--edge:clamp(10px,1.55cqw,24px)}
#game:is([data-state=flight],[data-state=result]) .garage-only,
#game[data-state=ready] .record-chip{display:none!important}
.workshop-top .brand{margin:0;flex:none;filter:drop-shadow(0 3px 2px #27180099)}
.workshop-top .brand img{width:100%;height:auto;max-height:none;display:block!important}
.wood{position:relative;background:none;border:var(--edge) solid transparent;border-image:url("assets/ui-woodplate.webp") 42 fill / var(--edge) / 0 stretch;border-radius:0;text-shadow:0 2px 1px #2f1408,1px 0 #331a0c,-1px 0 #331a0c;color:#fff5e8;filter:drop-shadow(0 2px 1px #271009b8)}
#game .workshop-top{z-index:4;gap:1cqw}
.profile{display:flex;align-items:flex-start;flex:1 1 auto;max-width:27%;min-width:0;gap:.65cqw;padding-top:.1cqw;align-self:flex-start}
.profile>img{width:6.25cqw;height:auto;object-fit:contain;flex:none;filter:drop-shadow(0 2px 2px #27140091)}
.profile-copy{min-width:0;flex:1;display:grid;gap:.38cqw;padding-top:.24cqw}
.profile-copy strong{font-size:clamp(12px,2.02cqw,30px);line-height:1.13;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:950;text-shadow:0 2px #291b10,1px 0 #312414,-1px 0 #312414}
.profile-level{display:flex;align-items:center;position:relative;gap:0;min-width:0}
.profile-level>b{display:grid;place-items:center;flex:none;position:relative;z-index:1;background:linear-gradient(#ffe69c,#c96f10);color:#321707;width:clamp(21px,3.25cqw,52px);aspect-ratio:1;border:2px solid #793b15;clip-path:polygon(20% 8%,50% 0%,80% 8%,100% 36%,96% 74%,72% 94%,50% 100%,26% 94%,4% 74%,0% 36%);font-size:clamp(11px,1.72cqw,26px)}
.xp{position:relative;isolation:isolate;flex:1;min-width:0;overflow:hidden;border:2px solid #f5aa42;border-radius:999px;background:#43251a;height:clamp(13px,2.05cqw,34px);margin-left:-.45cqw;text-align:center;box-shadow:0 2px 2px #150e09ad}
.xp i{position:absolute;inset:0 auto 0 0;background:linear-gradient(#78e7ff,#1591fa 53%,#007dc8);width:0%;z-index:-1}
.xp span{font-size:clamp(9px,1.24cqw,19px);font-weight:950;display:block;line-height:1.25;text-shadow:0 1px 2px #271a15;white-space:nowrap}
.workshop-top .wallet{gap:clamp(4px,1.1cqw,18px);margin-left:auto;align-self:flex-start}
.wallet-action,.record-chip{font-variant-numeric:tabular-nums;font-size:clamp(12px,1.75cqw,26px);font-weight:950;line-height:1;gap:.47cqw;background:linear-gradient(#356285,#152e47 80%);border:1px solid #152333;box-shadow:0 2px 2px #10222891,inset 0 1px #a2d8ff64;border-radius:9px;padding:0 .35cqw 0 .28cqw;text-shadow:0 2px 1px #151c28;min-height:44px}
.wallet-action img,.record-chip img{width:clamp(18px,3.95cqw,62px);height:clamp(18px,3.95cqw,62px);margin-block:-.3cqw;object-fit:contain;filter:drop-shadow(0 1px 1px #17121d)}
.wallet-action b{min-width:3cqw;text-align:center}
.plus{display:inline-grid;place-items:center;flex:none;width:clamp(15px,2.3cqw,36px);aspect-ratio:1;font-weight:1000;border:2px solid #264a0d;border-radius:22%;background:linear-gradient(#9fea68,#42aa14);box-shadow:inset 0 1px #e0ffae;color:white;text-shadow:0 1px 2px #15380f}
.gear{background:none;border:0;padding:0;min-height:44px;min-width:44px;width:5cqw;height:5cqw;filter:drop-shadow(0 2px 1px #1a1a24aa)}
.gear img{width:100%;height:100%;object-fit:contain}
#game:is([data-state=flight],[data-state=result]) .workshop-top .brand{width:clamp(60px,9.5cqw,147px)}
#game:is([data-state=flight],[data-state=result]) .workshop-top{align-items:center}
#game:is([data-state=flight],[data-state=result]) .record-chip{display:inline-flex;padding-inline:.6cqw}
#game:is([data-state=flight],[data-state=result]) .wallet-action{min-height:36px;cursor:default;padding-inline:.6cqw;opacity:1;filter:none}
#game:is([data-state=flight],[data-state=result]) .wallet-action .plus{display:none}
.wheel-display{position:absolute;inset:0;pointer-events:none}
.nameplate{position:absolute;top:11.55%;left:56.5%;translate:-50% 0;width:29%;min-width:0;text-align:center;display:grid;justify-items:center;gap:.22cqw;line-height:1.04;--edge:clamp(7px,1.05cqw,18px)}
.nameplate strong{display:block;font-size:clamp(14px,2.21cqw,34px);font-weight:1000;letter-spacing:-.025em;white-space:nowrap}
.nameplate #wheelStatus{font-size:clamp(9px,1.05cqw,14px);font-weight:900;color:#ffde8b}
.wheel-stars{display:flex;justify-content:center;gap:.28cqw}
.wheel-stars img{width:clamp(12px,2.33cqw,34px);height:clamp(12px,2.33cqw,34px);object-fit:contain}
.wheel-stars img.dim{filter:grayscale(1) brightness(.55) drop-shadow(0 1px 1px #251a18)}
.wheel-arrow{position:absolute;top:40.7%;translate:-50% -50%;width:5.35%;height:11.3%;min-width:44px;min-height:44px;background:none;border:0;padding:0;pointer-events:auto;filter:drop-shadow(0 2px 2px #2518079f)}
.wheel-arrow.prev{left:43.1%}
.wheel-arrow.next{left:68.9%}
.wheel-arrow img{width:62%;height:100%;object-fit:contain}
.wheel-arrow.prev img{scale:-1 1}
.side-rail{display:grid;position:absolute;top:19%;bottom:23%;left:max(1%,env(safe-area-inset-left));width:9%;grid-template-rows:repeat(4,minmax(0,1fr));gap:.63cqw;z-index:3}
.side-rail button,.garage-tabs button{position:relative;isolation:isolate;min-width:0;width:100%;height:100%;display:grid;grid-template-rows:minmax(0,1fr) auto;justify-items:center;align-items:center;gap:0;padding:0;font-weight:1000;white-space:nowrap;font-size:clamp(12px,1.61cqw,24px);letter-spacing:-.035em}
.side-rail button{--edge:clamp(8px,1.13cqw,18px)}
.side-rail button img,.garage-tabs button img{width:100%;height:100%;min-height:0;max-width:78%;object-fit:contain;filter:drop-shadow(0 2px 1px #301509)}
.side-rail button span,.garage-tabs button span{line-height:1.08}
.red-badge{position:absolute;top:-.65cqw;right:-.42cqw;z-index:1;display:grid;place-items:center;width:clamp(15px,2cqw,32px);aspect-ratio:1;background:linear-gradient(#ff7470,#d21923 70%);border:2px solid #771319;color:white;border-radius:50%;font-weight:950;font-style:normal;font-size:clamp(11px,1.55cqw,22px);line-height:1;text-shadow:0 1px #8b1120}
.performance{position:absolute;left:29.4%;top:68.5%;width:49.8%;height:10%;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));--edge:clamp(7px,1.08cqw,17px);z-index:2}
.performance>div{min-width:0;display:flex;justify-content:center;align-items:center;gap:.35cqw;text-align:center;border-right:1px solid #c884425c}
.performance>div:last-child{border-right:0}
.performance img{width:3.6cqw;height:3.45cqw;object-fit:contain;flex:none}
.performance span{min-width:0;display:grid;gap:.15cqw;font-weight:850;font-size:clamp(9px,1.11cqw,17px);line-height:1.07;white-space:nowrap;letter-spacing:-.025em}
.performance b{font-size:clamp(12px,1.82cqw,28px);font-weight:1000}
#game[data-state=ready] .controls{background:none;position:absolute;inset:auto max(1%,env(safe-area-inset-right)) max(1.1%,env(safe-area-inset-bottom)) max(1%,env(safe-area-inset-left));height:17.8%;padding:0;z-index:3}
#prepControls,.actions,.garage-tabs{height:100%;min-height:0}
#prepControls .actions{display:grid;grid-template-columns:minmax(0,1fr) 26%;gap:.85cqw;align-items:stretch}
#prepControls .garage-tabs{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:.35cqw}
#prepControls .motor-tab{filter:brightness(1.23) drop-shadow(0 0 4px #ffc340ba)}
#prepControls .motor-tab img{filter:drop-shadow(0 2px 1px #301509)}
#launch{position:relative;min-width:0;width:100%;height:100%;background:transparent url("assets/ui-launchplate.webp") center center / contain no-repeat;border:0;box-shadow:none;color:white;text-shadow:0 2px #5e270a,2px 0 #5e270a,-2px 0 #5e270a,0 -1px #5e270a;font-weight:1000;text-transform:uppercase;padding:12% 6%;align-content:center;justify-items:center;filter:drop-shadow(0 2px 2px #2c130d);font-size:clamp(16px,3.4cqw,49px);line-height:1}
#launch small{font-size:clamp(9px,1.23cqw,17px);line-height:1.18;text-transform:none;margin-top:.26cqw}
#launchText{display:flex;align-items:center;gap:.55cqw}
#launchText::before{content:"";background:url("assets/ui-chevron.webp") center/contain no-repeat;width:.6em;height:.82em;filter:drop-shadow(0 1px 1px #532400)}
.rpm-label{font-size:clamp(9px,1.05cqw,16px);line-height:1}
#hint{font-size:clamp(8px,1cqw,15px);line-height:1.05;letter-spacing:-.01em}
#prepControls .meter{height:clamp(7px,1.08cqw,15px);margin:.31cqw 0}
@media (orientation:landscape){
  #game[data-state=ready] .workshop-top{inset:max(.5%,env(safe-area-inset-top)) max(1%,env(safe-area-inset-right)) auto max(.55%,env(safe-area-inset-left));align-items:flex-start}
  #game[data-state=ready] .brand{width:13.6%}
  #game[data-state=ready] .wallet{padding-top:.5cqw}
}
@media (orientation:landscape) and (max-height:375px){
  .nameplate{width:31%;top:13.5%}
  .nameplate strong{font-size:clamp(13px,2.35cqw,22px)}
  .performance{left:28%;width:52%;top:69%;height:11%}
  .performance img{width:2.75cqw;height:2.75cqw}
  #hint{display:none}
  #game[data-state=charge] #hint{display:block}
  .workshop-top .wallet{gap:.65cqw}
}
@media (orientation:portrait){
  #game[data-state=ready]{background:#251a12}
  #game[data-state=ready] .workshop-top{display:grid;grid-template-columns:76px minmax(0,1fr);gap:3px 6px;padding:6px 7px 4px;background:radial-gradient(ellipse at 10% 0,#604021,#26190e 70%)}
  #game[data-state=ready] .brand{width:70px}
  .profile{max-width:none;gap:6px;align-items:center;align-self:center}
  .profile>img{width:36px}
  .profile-copy{max-width:185px;gap:2px}
  .profile-copy strong{font-size:15px}
  .profile-level>b{width:20px}
  .xp{height:15px}
  .xp span{font-size:9px}
  #game[data-state=ready] .wallet{grid-column:1/-1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) 44px;gap:4px;width:100%;margin:0}
  .wallet-action,.record-chip{padding-inline:3px;font-size:13px;gap:3px}
  .wallet-action img{width:23px;height:23px}
  .wallet-action .plus{width:14px;font-size:12px}
  .gear{width:44px;height:44px}
  .wheel-arrow.prev{left:42.5%}
  .wheel-arrow.next{left:70.5%}
  .nameplate{top:4%;width:auto;max-width:74%;padding-inline:7px}
  .nameplate strong{font-size:clamp(13px,4cqw,22px)}
  .nameplate #wheelStatus{font-size:9px}
  .side-rail{position:relative;inset:auto;width:auto;display:grid;grid-template:1fr/repeat(4,minmax(0,1fr));height:56px;margin:5px 7px 0;gap:4px}
  .side-rail button,.garage-tabs button{font-size:clamp(11px,3.5cqw,16px);border-width:7px;--edge:7px}
  .red-badge{top:-6px;right:-4px}
  .performance{position:relative;inset:auto;width:auto;height:auto;min-height:37px;margin:4px 7px 0;--edge:6px}
  .performance>div{gap:2px}
  .performance img{width:clamp(12px,4.1cqw,22px);height:clamp(12px,4.1cqw,22px)}
  .performance span{font-size:clamp(8px,2.45cqw,12px);letter-spacing:-.031em}
  .performance b{font-size:clamp(11px,3.4cqw,17px)}
  #game[data-state=ready] .controls{position:relative;inset:auto;height:auto;padding:4px 7px 8px}
  .rpm-label{font-size:10px}
  #hint{font-size:10px}
  #prepControls .actions{height:auto;grid-template-columns:1fr;gap:1px}
  #prepControls .garage-tabs{height:auto;grid-row:2;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(2,53px);gap:3px}
  #launch{height:64px;padding:5px 8px;font-size:23px}
}
#garageDialog{background:radial-gradient(ellipse at 40% 0,#70411f,#2c1a12 88%);border:2px solid #df9a53;color:#fff5e8;box-shadow:0 5px 0 #6c3e23,inset 0 0 0 2px #8d542c,0 18px 80px #23110dc4}
#garageDialog .eyebrow{color:#ffd471}
#garageDialog .tile{background:linear-gradient(#51301dd6,#331e12);border-color:#ae754f77}
#garageDialog .tile p{color:#f0d3b3}
#garageDialog button,#garageDialog .small-button{background:linear-gradient(#804c29,#512b16);border-color:#c89051;box-shadow:inset 0 1px #e4a86b77}
#garageDialog .settings-form{grid-column:1/-1;display:grid;gap:10px}
.settings-form label{display:grid;gap:4px;font-size:14px;font-weight:800;color:#ffe1bc}
.settings-form input{background:#29180f;border:1px solid #b68052;border-radius:7px;padding:9px;color:white;font:inherit;min-height:44px}
.profile-copy strong,.wallet-action b{font-variant-numeric:tabular-nums}
/* Leave a separate lane for the tachometer beside the four wheel stats. */
@media (orientation:landscape){
 .performance{width:48.7%}
}
@media (orientation:landscape) and (max-height:375px){
 .performance{left:28%;width:50.1%}
 .side-rail button,.garage-tabs button{font-size:clamp(10px,1.9cqw,14px);letter-spacing:-.045em}
 .performance span{font-size:clamp(8px,1.43cqw,12px)}
}
@media (orientation:portrait) and (max-height:650px){
 #game[data-state=ready] .workshop-top{padding-block:4px;grid-template-columns:63px minmax(0,1fr)}
 #game[data-state=ready] .brand{width:58px}
 .side-rail{height:48px;margin-top:3px}
 .side-rail button,.garage-tabs button{border-width:6px;--edge:6px}
 .performance{min-height:34px;margin-top:3px}
 #prepControls .actions{gap:0}
 #prepControls .garage-tabs{grid-template-rows:repeat(2,45px)}
 #launch{height:54px;font-size:20px}
}

.start-actions{display:grid;grid-template-columns:minmax(0,1fr);min-width:0;min-height:0;align-items:stretch}
.start-actions:has(#openRoutes:not([hidden])){grid-template-columns:clamp(53px,5.6cqw,80px) minmax(0,1fr);gap:3px}
#openRoutes{
 --edge:6px;display:grid;place-content:center;justify-items:center;line-height:1.1;min-width:0;min-height:44px;
 padding:3px 0;font-size:clamp(10px,1.05cqw,14px);font-weight:900;overflow:hidden
}
#openRoutes img{width:clamp(20px,2.6cqw,39px);aspect-ratio:1;object-fit:contain}
.start-actions:has(#openRoutes:not([hidden])) #launch{font-size:clamp(14px,2.75cqw,43px)}
@media(orientation:portrait){
 .start-actions:has(#openRoutes:not([hidden])){grid-template-columns:62px minmax(0,1fr);gap:5px}
 .start-actions:has(#openRoutes:not([hidden])) #launch{font-size:22px}
}
