/* Layout: one-screen app. Menu = minimal title card with one button, game = full-bleed canvas with a thin HUD. */
:root {
  --bg: #0b0c0f;
  --bg-2: #15171c;
  --panel: #1b1e25;
  --line: #2b2f3a;
  --fg: #eef0f4;
  --muted: #9aa0ad;
  --accent: #e82127;        /* Tesla red */
  --accent-2: #ff6b5a;
  --air: #6fd3ff;           /* cold gas */
  --air-low: #ffb347;
  --good: #7ee787;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --body: "Barlow", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.45;
  overflow: hidden;
}
h1, h2, h3 { font-family: var(--display); letter-spacing: .01em; margin: 0; text-wrap: balance; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font-family: var(--body); font-size: .85em; padding: .05em .4em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--bg-2); }
a { color: var(--air); }
#app { height: 100%; }
.screen { height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.screen[hidden] { display: none !important; }

/* ---- Menu ---- */
#menu {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: relative;
  padding-block: 36px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  background:
    radial-gradient(900px 420px at 50% 110%, rgba(232,33,39,.22), transparent 60%),
    linear-gradient(180deg, #06070b 0%, #0f1117 100%);
}
.menu-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 640px; }
.eyebrow { font-family: var(--display); text-transform: uppercase; letter-spacing: .22em; font-size: 13px; color: var(--muted); }
.menu-inner h1 { font-size: clamp(64px, 14vw, 140px); line-height: .88; font-weight: 800; text-transform: uppercase; }
.menu-inner h1 span { color: var(--accent); }
.lede { color: var(--muted); font-size: 17px; margin: 0; max-width: 40ch; }
.btn { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; font-family: var(--display); text-transform: uppercase; letter-spacing: .08em; font-size: 16px; }
.btn:hover, .btn:focus-visible { border-color: var(--fg); outline: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff2f36; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 6px 10px; font-size: 13px; }
.btn.big { font-size: 28px; padding: 18px 56px; border-radius: 14px; letter-spacing: .14em; margin-top: 14px; box-shadow: 0 10px 34px rgba(232,33,39,.38); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.04) } }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--muted); font-size: 14px; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.menu-sound { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* ---- Game ---- */
#game { position: relative; overflow: hidden; background: #000; touch-action: none; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
#menu, #hud, .overlay { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: absolute; inset: 0; pointer-events: none; padding-block: 14px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); font-family: var(--display); }
.hud-left { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: 14px; display: flex; flex-direction: column; gap: 8px; }
.hud-right { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: 14px; text-align: right; }
.gauge { width: min(300px, 44vw); background: rgba(10,12,16,.55); border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 8px 10px; backdrop-filter: blur(4px); }
.gauge-label { display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; color: var(--muted); }
.gauge-label b { color: var(--fg); font-size: 18px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.gauge-bar { height: 10px; margin-top: 6px; border-radius: 5px; background: rgba(255,255,255,.08); overflow: hidden; position: relative; }
.gauge-bar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 9.5%, rgba(0,0,0,.45) 9.5% 10%); }
#air-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #3aa9e0, var(--air)); transition: width .08s linear, background .3s; }
#air-fill.low { background: linear-gradient(90deg, #d9742a, var(--air-low)); }
.stat { font-size: 30px; font-weight: 700; line-height: 1; text-shadow: 0 2px 8px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.stat small { font-size: 13px; font-weight: 500; margin-left: 5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stat.big { font-size: 48px; }
.stat.dim { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.stat.dim b { color: var(--fg); }
.hud-center { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; width: 90%; }
.popup { font-size: clamp(28px, 5vw, 52px); font-weight: 800; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px rgba(232,33,39,.8), 0 2px 6px rgba(0,0,0,.7); animation: pop .9s ease-out forwards; }
.popup.good { color: var(--good); text-shadow: 0 0 18px rgba(126,231,135,.7), 0 2px 6px rgba(0,0,0,.7); }
.popup.warn { color: var(--air-low); }
@keyframes pop { 0% { transform: scale(.6); opacity: 0 } 15% { transform: scale(1.08); opacity: 1 } 70% { opacity: 1 } 100% { transform: translateY(-30px) scale(1); opacity: 0 } }
.hud-hint { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.75); font-size: 16px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#btn-exit { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); pointer-events: auto; }
.tree { display: inline-grid; grid-auto-flow: column; gap: 14px; padding: 12px 18px; background: rgba(10,12,16,.6); border-radius: 12px; border: 1px solid rgba(255,255,255,.12); }
.tree .lamp { width: 26px; height: 26px; border-radius: 50%; background: #2a2d35; border: 2px solid #3a3e48; box-shadow: inset 0 0 6px #000; }
.tree .lamp.amber.on { background: #ffb000; box-shadow: 0 0 18px #ffb000; border-color: #ffd36b; }
.tree .lamp.green.on { background: #2ee86a; box-shadow: 0 0 22px #2ee86a; border-color: #9cffb7; }
.tree .lamp.red.on { background: #ff2a2a; box-shadow: 0 0 22px #ff2a2a; }
.drag-readout { margin-top: 10px; font-size: 22px; font-weight: 600; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.8); letter-spacing: .04em; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(5,6,9,.62); backdrop-filter: blur(3px); text-align: center; padding: 20px; }
.overlay h2 { font-size: clamp(44px, 9vw, 92px); text-transform: uppercase; font-weight: 800; line-height: 1; }
.overlay p { margin: 0; color: var(--fg); font-size: 18px; max-width: 48ch; white-space: pre-line; }
.ov-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 640px) {
  .stat.big { font-size: 34px; }
  .gauge { width: 46vw; }
}
@media (prefers-reduced-motion: reduce) {
  .popup { animation-duration: .01s; }
  .phone-icon { animation: none; transform: rotate(-90deg); }
  .btn.big { animation: none; }
}
