/* Cook & Run — page shell & layout, Round 3 "dark glass" (HUD, cook lab and lobby have their own stylesheets).
   Owns: the boot splash fallback (LOBBY owns the #boot markup + lobby.css), the game shell, the pause / notice
   overlay, the pills, the touch controls. Tokens: css/tokens.css (index.html links fonts.css + tokens.css first). */
:root {
  /* legacy palette — still read by cook.css / lobby.css / van.css / onfoot.css; keep the names */
  --charcoal: #22262a; --cream: #f1ead8; --teal: #4f8f8a; --mustard: #d9a83a; --rust: #9c4a32; --sky: #a7c7d6;
  --red: #d8433a; --blue: #3a6fd8;
  --font: var(--g-font, system-ui), system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
  --font-head: Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Black", var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--g-solid, #0E0F11); color: var(--g-text-1, #F1ECE4); font-family: var(--font); overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { touch-action: none; }
[hidden] { display: none !important; }

/* ── boot splash (fallback look; lobby.css styles LOBBY's live scene inside #boot) ── */
#boot { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; transition: opacity var(--g-slow, 200ms) var(--g-ease, ease);
  background: radial-gradient(120% 70% at 50% 115%, #6b3a24 0%, #2a1a14 38%, var(--g-solid, #0E0F11) 72%); }
#boot.gone { opacity: 0; pointer-events: none; }
.boot-card { text-align: center; padding: 16px; }
.boot-logo { font-family: var(--g-font, sans-serif); font-weight: 900; font-stretch: 62%; font-size: clamp(44px, 9vw, 96px); line-height: .9; letter-spacing: .01em; text-transform: uppercase; color: #D9A83A;
  -webkit-text-stroke: .03em #22262A; paint-order: stroke fill; text-shadow: .05em .06em 0 #22262A; }
.boot-logo span { display: inline-block; margin: 0 .12em; font-family: var(--g-font-display, serif); font-size: .72em; font-variation-settings: 'SOFT' 100, 'opsz' 144; color: #F1EAD8; }
.boot-msg { margin-top: 18px; font-family: var(--g-font, sans-serif); font-stretch: 75%; font-weight: 700; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--g-text-2, #BDB8B0); }
.boot-bar { position: relative; width: min(280px, 70vw); height: 5px; margin: 14px auto 0; border-radius: 3px; background: var(--g-track, rgba(255,255,255,.14)); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--g-amber, #F2B90F); border-radius: 3px; animation: bootbar 1.1s ease-in-out infinite; }
#boot.det .boot-bar i, .boot-bar.det i { width: calc(var(--boot-p, 0) * 100%); animation: none; transition: width var(--g-slow, 200ms) linear; }   /* determinate: set --boot-p 0..1 */
@keyframes bootbar { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
#boot.error .boot-bar { display: none; }
#boot.error .boot-msg { color: var(--g-red-text, #FF7F70); text-transform: none; letter-spacing: 0; font-stretch: 100%; font-weight: 500; font-size: 14px; max-width: 520px; line-height: 1.45; }

/* ── game shell ─────────────────────────────────────────────────────────── */
#game { position: fixed; inset: 0; }
#viewWrap { position: absolute; inset: 0; overflow: hidden; background: #8fb4c4; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#labWrap { display: none; position: absolute; z-index: 6; }
#lab { position: absolute; inset: 0; }
#labToggle { display: none; }

/* Driver online: the road fills the screen. */
body.role-driver:not(.lab-local) #labWrap { display: none; }

/* Solo with the 2D lab (or a driver who took over the lab): docked at the right edge, under the top row. */
body.lab-local #labWrap {
  display: block; right: 16px; top: 112px; bottom: 96px; width: min(500px, 38vw); min-width: 420px;
  border-radius: var(--g-radius-lg, 12px); box-shadow: 0 10px 40px rgba(0,0,0,.45), 0 0 0 1px var(--g-line, rgba(255,255,255,.1));
  overflow: visible; transition: transform var(--g-slow, 200ms) var(--g-ease, ease), opacity var(--g-slow, 200ms) var(--g-ease, ease);
}
body.lab-local #lab { border-radius: var(--g-radius-lg, 12px); overflow: hidden; }
body.lab-local #labToggle {
  display: block; position: absolute; left: -36px; top: 50%; transform: translateY(-50%); width: 32px; height: 84px; border: 1px solid var(--g-line, rgba(255,255,255,.1)); border-right: 0; border-radius: 8px 0 0 8px;
  background: var(--g-glass-hi, rgba(14,15,17,.84)); color: var(--g-teal-text, #86D0C6); font: 700 10px/1 var(--font); font-stretch: 75%; letter-spacing: .12em; writing-mode: vertical-rl; cursor: pointer;
}
body.lab-local.lab-hidden #labWrap { transform: translateX(calc(100% + 14px)); }
body.lab-local.lab-hidden #labToggle { color: var(--g-amber, #F2B90F); }
@media (max-height: 560px) { body.lab-local #labWrap { top: 72px; bottom: 88px; } }
@media (max-width: 760px) {
  body.lab-local #labWrap { left: 8px; right: 8px; width: auto; min-width: 0; top: auto; bottom: 8px; height: 46%; }
  body.lab-local #labToggle { left: 50%; top: -30px; transform: translateX(-50%); width: 84px; height: 28px; writing-mode: horizontal-tb; border: 1px solid var(--g-line, rgba(255,255,255,.1)); border-bottom: 0; border-radius: 8px 8px 0 0; }
  body.lab-local.lab-hidden #labWrap { transform: translateY(calc(100% + 14px)); }
  body.lab-local:not(.lab-hidden) #touch { display: none !important; }
}

/* Cook online with the 2D lab: rear-window view on top, the lab below. */
body.role-cook #viewWrap { bottom: auto; height: 40%; }
body.role-cook #labWrap { display: block; left: 0; right: 0; bottom: 0; top: 40%; border-top: 1px solid var(--g-line-2, rgba(255,255,255,.18)); }
@media (min-aspect-ratio: 21/10) { body.role-cook #viewWrap { height: 36%; } body.role-cook #labWrap { top: 36%; } }
@media (max-aspect-ratio: 4/5) { body.role-cook #viewWrap { height: 32%; } body.role-cook #labWrap { top: 32%; } }

/* ── pause menu / notices (main.js showNotice: .ov-card > .ov-title .ov-sub .ov-keys .ov-btns) ── */
#overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 9, 11, .58); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: ovFade var(--g-slow, 200ms) var(--g-ease, ease) both; }
@keyframes ovFade { from { opacity: 0; } }
.ov-card { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 20px 18px;
  background: var(--g-glass-hi, rgba(14,15,17,.84)); border: 1px solid var(--g-line, rgba(255,255,255,.1)); border-radius: var(--g-radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5); color: var(--g-text-1, #F1ECE4); font-family: var(--font); animation: ovRise var(--g-slow, 200ms) var(--g-ease, ease) both; }
@keyframes ovRise { from { opacity: 0; transform: translateY(6px); } }
.ov-title { margin: 0 0 8px; font-family: var(--g-font, sans-serif); font-stretch: 75%; font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: .01em; color: var(--g-text-1, #F1ECE4); }
.ov-sub { margin: 0 0 16px; font-size: 13.5px; font-weight: 500; line-height: 1.45; color: var(--g-text-2, #BDB8B0); }
.ov-keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; align-items: center; margin: 0 0 18px; padding-top: 14px; border-top: 1px solid var(--g-line, rgba(255,255,255,.1)); font-size: 13px; font-weight: 500; color: var(--g-text-2, #BDB8B0); }
.ov-keys > span:nth-child(odd) { justify-self: start; }
.ov-keys kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 4px; box-sizing: border-box;
  background: var(--g-key-bg, rgba(255,255,255,.1)); border: 1px solid var(--g-key-line, rgba(255,255,255,.26)); border-bottom-width: 2px;
  font: 700 11px/1 var(--font); font-stretch: 85%; color: var(--g-text-1, #F1ECE4); white-space: nowrap; }
.ov-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.ov-btn { flex: 1 1 140px; height: 46px; padding: 0 16px; border-radius: var(--g-radius-sm, 8px); cursor: pointer;
  border: 1px solid var(--g-line-2, rgba(255,255,255,.18)); background: rgba(255, 255, 255, .06); color: var(--g-text-1, #F1ECE4);
  font: 700 15px/1 var(--font); font-stretch: 92%; letter-spacing: .005em; transition: background var(--g-fast, 140ms) var(--g-ease, ease); }
.ov-btn:hover { background: rgba(255, 255, 255, .11); }
.ov-btn.primary { background: var(--g-amber, #F2B90F); border-color: transparent; color: var(--g-ink, #17130A); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .22); }
.ov-btn.primary:hover { background: #FFC62A; }
.ov-btn:focus-visible { outline: 2px solid var(--g-amber, #F2B90F); outline-offset: 2px; }

/* ── pills (latency, mute, pause) — bottom-left, above the health panel ── */
#pills { position: absolute; z-index: 8; left: 16px; bottom: 88px; display: flex; gap: 6px; pointer-events: auto; }
/* a shop run: the run's controls card owns the bottom-left and the bars move bottom-right — the pills follow them */
body.in-shop #pills { left: auto; right: 16px; }
.pill { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: var(--g-radius-sm, 8px); cursor: pointer;
  border: 1px solid var(--g-line, rgba(255,255,255,.1)); background: var(--g-glass, rgba(14,15,17,.72)); -webkit-backdrop-filter: blur(var(--g-blur, 10px)); backdrop-filter: blur(var(--g-blur, 10px));
  color: var(--g-text-2, #BDB8B0); font: 700 10px/1 var(--font); font-stretch: 75%; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  transition: color var(--g-fast, 140ms) var(--g-ease, ease), border-color var(--g-fast, 140ms) var(--g-ease, ease); }
.pill:hover { color: var(--g-text-1, #F1ECE4); border-color: var(--g-line-2, rgba(255,255,255,.18)); }
.pill.static { cursor: default; }
.pill.static:hover { color: var(--g-text-2, #BDB8B0); border-color: var(--g-line, rgba(255,255,255,.1)); }
.pill.bad { color: var(--g-red-text, #FF7F70); border-color: rgba(229, 72, 58, .55); }
body.touch.role-driver #pills, body.touch.lab-local #pills { bottom: auto; top: 152px; }
@media (max-width: 900px), (max-height: 520px) {
  #pills { left: 8px; bottom: 80px; }
  body.touch.role-driver #pills, body.touch.lab-local #pills { top: 144px; }
}

/* ── touch controls (driver on phones / tablets) ──────────────────────── */
#touch { display: none; position: absolute; inset: 0; z-index: 7; pointer-events: none; }
body.touch.role-driver #touch, body.touch.lab-local #touch { display: block; }
.tc { position: absolute; pointer-events: auto; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none;
  border: 1px solid var(--g-line-2, rgba(255,255,255,.18)); border-radius: 12px; background: var(--g-glass-lo, rgba(14,15,17,.56));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: var(--g-text-1, #F1ECE4);
  font: 700 11px/1 var(--font); font-stretch: 80%; letter-spacing: .08em; text-transform: uppercase; }
.tc.on { background: rgba(242, 185, 15, .85); border-color: transparent; color: var(--g-ink, #17130A); }
.tc-left  { left: 16px; bottom: 16px; width: 74px; height: 92px; }
.tc-right { left: 98px; bottom: 16px; width: 74px; height: 92px; }
.tc-gas   { right: 16px; bottom: 16px; width: 82px; height: 112px; background: rgba(91, 191, 106, .26); border-color: rgba(91, 191, 106, .5); }
.tc-brake { right: 106px; bottom: 16px; width: 74px; height: 80px; background: rgba(229, 72, 58, .2); border-color: rgba(229, 72, 58, .45); }
.tc-small { width: 54px; height: 44px; border-radius: 10px; font-size: 10px; }
.tc-horn  { left: 16px; bottom: 116px; }
.tc-smoke { right: 16px; bottom: 136px; }
.tc-oil   { right: 76px; bottom: 136px; }
.tc-nitro { right: 136px; bottom: 136px; }
.tc-hb    { right: 188px; bottom: 16px; }

/* rotate hint for phones in portrait (driver) */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  body.touch.role-driver:not(.lab-local) #rotate { display: grid; position: absolute; z-index: 9; left: 50%; top: 52%; transform: translate(-50%, -50%); padding: 10px 14px; border-radius: var(--g-radius-sm, 8px);
    background: var(--g-glass-hi, rgba(14,15,17,.84)); border: 1px solid var(--g-line, rgba(255,255,255,.1)); font: 600 12px/1.35 var(--font); color: var(--g-text-1, #F1ECE4); text-align: center; pointer-events: none; }
}

/* ── 3D van lab ─────────────────────────────────────────────────────────── */
/* Online cook: the 3D van fills the screen (no 2D panel). */
body.lab3d #labWrap { display: none !important; }
body.role-cook.lab3d #viewWrap { bottom: 0; height: auto; }
/* Solo, cooking in the back: the HUD hides its driving pieces itself (hud.setMode('lab'), or body.in-lab in hud.css). */
body.mode-solo .vh-step, body.mode-solo .vh-result { top: 80px; }   /* just under the HUD's top row */
/* touch: seat-swap button; in the lab the driving buttons go away (tap/drag drives Doc) */
.tc-seat { left: 50%; transform: translateX(-50%); bottom: 16px; width: 76px; background: rgba(95, 179, 168, .3); border-color: rgba(95, 179, 168, .55); }
body.lab3d.touch #touch { display: block; }
body.in-lab #touch .tc:not(.tc-seat) { display: none; }
body.in-lab .tc-seat { bottom: auto; top: 152px; }
