/* Layout: full-bleed WebGL canvas with 1950s pulp-poster overlays (title card, orrery map, HUD gauges). */
:root {
  --void: #0d1424;        /* deep space */
  --void-2: #17223a;      /* panel */
  --cream: #f4e9cf;       /* poster paper text */
  --tomato: #e8503a;      /* rocket red */
  --raygun: #ffd23f;      /* ray-gun yellow */
  --teal: #4fd1c5;        /* robot glow */
  --muted: #9aa6bf;
  --line: rgba(244, 233, 207, 0.18);
  --font-display: "Bungee", "Impact", "Arial Black", sans-serif;
  --font-shade: "Bungee Shade", "Bungee", "Impact", sans-serif;
  --font-body: "Chakra Petch", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--void);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font: 700 15px/1 var(--font-body);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cream); background: var(--void-2);
  border: 2px solid var(--line); border-radius: 999px;
  padding: 13px 22px; cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--cream); transform: translateY(-1px); }
.btn:focus-visible { outline: 3px solid var(--raygun); outline-offset: 3px; }
.btn.primary { background: var(--tomato); border-color: var(--tomato); color: #fff8ec; box-shadow: 0 4px 0 #8c2a1d; }
.btn.primary:hover { background: #f2604a; }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #8c2a1d; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn-row.col { flex-direction: column; align-items: stretch; }
.fs-icon {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; pointer-events: auto;
  font: 400 20px/1 var(--font-body); color: var(--cream);
  background: rgba(13, 20, 36, .6); border: 2px solid var(--line);
}
.fs-icon:hover { border-color: var(--cream); }
.fs-icon:focus-visible { outline: 3px solid var(--raygun); outline-offset: 2px; }
body.no-fs .fs-toggle { display: none !important; }
#hud-fs { position: absolute; left: 50%; margin-left: -20px; top: max(14px, env(safe-area-inset-top, 0px)); }
body.touch #hud-fs { margin-left: 30px; top: max(14px, env(safe-area-inset-top, 0px)); }
.map-right { display: flex; align-items: center; gap: 12px; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  overflow-y: auto;
}
.screen > * { margin: auto; }
.screen.dim { background: rgba(8, 12, 22, 0.72); backdrop-filter: blur(3px); }

#title {
  background:
    radial-gradient(ellipse at 50% 120%, rgba(232, 80, 58, .35), transparent 60%),
    radial-gradient(ellipse at 50% 0%, rgba(79, 209, 197, .12), transparent 55%);
}
.title-card { max-width: 680px; text-align: center; display: grid; gap: 18px; justify-items: center; }
.eyebrow { margin: 0; font: 700 13px var(--font-body); letter-spacing: .32em; text-transform: uppercase; color: var(--raygun); }
.logo {
  margin: 0; font-family: var(--font-shade); font-weight: 400;
  font-size: clamp(44px, 11vw, 112px); line-height: .9; color: var(--cream);
  text-shadow: 0 6px 0 var(--tomato), 0 12px 30px rgba(0,0,0,.6);
  animation: hover 4s ease-in-out infinite;
}
.logo span { color: var(--raygun); }
@keyframes hover { 50% { transform: translateY(-6px) rotate(-1deg); } }
.lede { margin: 0; text-shadow: 0 2px 6px rgba(0,0,0,.9); max-width: 56ch; font-size: 17px; line-height: 1.55; color: var(--cream); opacity: .9; text-wrap: pretty; }
.controls {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px;
  font-size: 13px; color: var(--cream); width: 100%;
  padding: 12px 16px; border-radius: 14px; background: rgba(13, 20, 36, .78); border: 1px dashed var(--line);
}
kbd {
  font: 600 12px var(--font-body); color: var(--cream);
  border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 5px;
  padding: 2px 6px; margin-right: 3px; background: var(--void-2);
}
.fine { margin: 0; font-size: 13px; color: var(--muted); }

.card {
  width: min(420px, 100%); background: var(--void-2);
  border: 2px solid var(--line); border-radius: 18px; padding: 28px 24px;
  display: grid; gap: 14px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.card h2 { margin: 0; font: 400 32px/1 var(--font-display); color: var(--raygun); text-wrap: balance; }
.card small { font-weight: 700; letter-spacing: .25em; color: var(--teal); }
.card p { margin: 0; line-height: 1.5; }
#res-stats { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; text-align: left; font-variant-numeric: tabular-nums; }
#res-stats dt { color: var(--muted); }
#res-stats dd { margin: 0; font-weight: 700; text-align: right; }
#res-stats .total { color: var(--raygun); font-size: 18px; border-top: 1px solid var(--line); padding-top: 6px; }

/* ---------- solar map ---------- */
#map { display: block; padding: 0; background: var(--void); }
#map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.map-head {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.map-head h2 { margin: 0; font: 400 clamp(20px, 3.4vw, 30px) var(--font-display); color: var(--cream); }
.map-head h2 small { font: 600 14px var(--font-body); color: var(--muted); letter-spacing: .05em; }
.map-score { font-weight: 700; letter-spacing: .2em; font-size: 12px; color: var(--muted); }
.map-score b { color: var(--raygun); font-size: 18px; letter-spacing: .05em; margin-left: 6px; font-variant-numeric: tabular-nums; }
#map-panel {
  position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  width: min(330px, calc(100% - 32px));
  background: rgba(23, 34, 58, .92); border: 2px solid var(--line); border-radius: 18px;
  padding: 18px 20px; display: grid; gap: 8px;
}
#map-panel small { font-weight: 700; letter-spacing: .25em; color: var(--teal); font-size: 11px; }
#map-panel h3 { margin: 0; font: 400 28px/1 var(--font-display); color: var(--raygun); }
#map-panel p { margin: 0; line-height: 1.45; font-size: 14px; }
#map-panel .was { color: var(--muted); font-style: italic; font-size: 13px; }
#map-panel dl { margin: 4px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#map-panel dl div { background: rgba(0,0,0,.25); border-radius: 10px; padding: 6px 8px; min-width: 0; }
#map-panel dt { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
#map-panel dd { margin: 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
#map-panel .gimmick { color: var(--teal); font-size: 13px; }
.map-tip {
  position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  margin: 0; font-size: 12px; color: var(--muted); max-width: 30ch;
}
@media (max-width: 640px) {
  .map-tip { display: none; }
  #map-panel { left: max(16px, env(safe-area-inset-left, 0px)); width: auto; padding: 14px 16px; gap: 6px; }
  #map-panel h3 { font-size: 22px; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--font-body); }
#hud-tl, #hud-tr {
  position: absolute; top: max(14px, env(safe-area-inset-top, 0px));
  display: grid; gap: 6px;
  text-shadow: 0 2px 4px rgba(0,0,0,.8);
}
#hud-tl { left: max(16px, env(safe-area-inset-left, 0px)); }
#hud-tr { right: max(16px, env(safe-area-inset-right, 0px)); justify-items: end; }
#hud-planet { font: 400 20px var(--font-display); color: var(--raygun); }
#hud-hp { display: flex; gap: 4px; padding: 4px; border: 2px solid var(--cream); border-radius: 6px; width: max-content; background: rgba(0,0,0,.35); }
#hud-hp i { width: 16px; height: 20px; border-radius: 2px; background: var(--teal); box-shadow: 0 0 8px var(--teal); }
#hud-hp i.empty { background: rgba(255,255,255,.1); box-shadow: none; }
#hud-hp.low i:not(.empty) { background: var(--tomato); box-shadow: 0 0 8px var(--tomato); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }
#hud-lives { font-weight: 700; font-size: 13px; letter-spacing: .12em; }
.stat { display: flex; gap: 10px; align-items: baseline; }
.stat span { font-size: 11px; letter-spacing: .2em; color: var(--muted); font-weight: 700; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
#hud-power { font-weight: 700; color: var(--raygun); letter-spacing: .12em; font-size: 13px; }
#radar {
  position: absolute; width: 132px; height: 132px;
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  border-radius: 50%; border: 2px solid var(--line);
}
#hud-msg {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  width: min(560px, calc(100% - 32px)); text-align: center;
  font: 400 clamp(16px, 2.6vw, 24px)/1.25 var(--font-display); color: var(--cream);
  text-shadow: 0 3px 0 rgba(0,0,0,.6); opacity: 0; transition: opacity .3s ease;
}
#hud-msg.show { opacity: 1; }
#boss-bar {
  position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(460px, calc(100% - 200px)); display: grid; gap: 4px; text-align: center;
  font: 400 13px var(--font-display); color: var(--tomato); letter-spacing: .08em;
}
#boss-bar .track { height: 12px; border: 2px solid var(--cream); border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.4); }
#boss-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--tomato), var(--raygun)); transition: width .15s; }
#hud-hint {
  position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  font-size: 12px; color: var(--cream); opacity: .7; max-width: 52ch; text-shadow: 0 1px 3px #000;
  transition: opacity 1s ease;
}
#floaters { position: absolute; inset: 0; overflow: hidden; }
.floater {
  position: absolute; transform: translate(-50%, -50%);
  font: 400 16px var(--font-display); white-space: nowrap; text-shadow: 0 2px 0 rgba(0,0,0,.7);
}

/* ---------- banner ---------- */
#banner {
  position: fixed; left: 0; right: 0; top: 30%; z-index: 15; text-align: center; pointer-events: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  animation: banner 4.2s ease forwards;
}
#banner small { font-weight: 700; letter-spacing: .4em; color: var(--teal); }
#banner h2 { margin: 6px 0; font: 400 clamp(36px, 8vw, 80px)/1 var(--font-shade); color: var(--raygun); text-shadow: 0 5px 0 var(--tomato); }
#banner p { margin: 0 auto; max-width: 46ch; font-size: 17px; text-shadow: 0 2px 4px #000; }
@keyframes banner { 0% { opacity: 0; transform: scale(.9); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- touch ---------- */
#touch { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 60%; pointer-events: auto; }
#stick {
  position: absolute; width: 120px; height: 120px; border-radius: 50%;
  left: max(28px, env(safe-area-inset-left, 0px)); bottom: max(28px, env(safe-area-inset-bottom, 0px));
  border: 2px solid rgba(244,233,207,.35); background: rgba(0,0,0,.2);
}
#stick i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(244,233,207,.5); }
.tbtn {
  position: absolute; pointer-events: auto; width: 76px; height: 76px; border-radius: 50%;
  font: 400 14px var(--font-display); color: var(--cream);
  background: rgba(23,34,58,.6); border: 2px solid rgba(244,233,207,.45);
}
#t-jump { right: max(116px, calc(env(safe-area-inset-right, 0px) + 100px)); bottom: max(30px, env(safe-area-inset-bottom, 0px)); }
#t-zap { right: max(24px, env(safe-area-inset-right, 0px)); bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 70px)); background: rgba(232,80,58,.55); }
#t-pause { width: 44px; height: 44px; font-size: 14px; left: 50%; margin-left: -22px; top: max(12px, env(safe-area-inset-top, 0px)); }
body.touch #radar { width: 96px; height: 96px; top: 150px; bottom: auto; }
body.touch #hud-hint { display: none; }
body.touch #boss-bar { width: calc(100% - 220px); bottom: 150px; }

@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
  #banner { animation-duration: 4.2s; animation-timing-function: steps(1); }
}
