@font-face {
  font-family: 'Display';
  src: url('./assets/fonts/michroma-latin-400.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Mono';
  src: url('./assets/fonts/ibm-plex-mono-latin-400.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Mono';
  font-weight: 600;
  src: url('./assets/fonts/ibm-plex-mono-latin-600.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Body';
  src: url('./assets/fonts/ibm-plex-sans-latin-400.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Body';
  font-weight: 600;
  src: url('./assets/fonts/ibm-plex-sans-latin-600.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg-panel: rgba(7, 13, 23, 0.86);
  --bg-panel-hi: rgba(13, 22, 38, 0.92);
  --line: rgba(120, 160, 210, 0.22);
  --line-hi: rgba(150, 200, 255, 0.45);
  --txt: #e6ecf6;
  --muted: #8b99af;
  --amber: #ff9a3c;
  --amber-hi: #ffc078;
  --cyan: #6fd6ff;
  --red: #ff5040;
  --chamfer: polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 13px 100%, 0 calc(100% - 13px));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: #020409;
  color: var(--txt);
  font-family: 'Body', system-ui, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#gl:active { cursor: grabbing; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud button, #hud input, #hud .panel, #hud nav { pointer-events: auto; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px 10px;
  background: linear-gradient(180deg, rgba(3,6,12,0.85), rgba(3,6,12,0));
}
#brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-family: 'Display', monospace;
  font-size: 17px; letter-spacing: 0.14em; color: var(--txt);
}
.brand-title b { color: var(--amber); font-weight: 400; }
.brand-sub {
  font-family: 'Mono', monospace; font-size: 8.5px;
  letter-spacing: 0.34em; color: var(--muted); margin-top: 3px;
}

#phases { display: flex; gap: 4px; margin: 0 auto; flex-wrap: wrap; justify-content: center; }
.phase-chip {
  font-family: 'Mono', monospace; font-size: 9.5px; letter-spacing: 0.16em;
  padding: 5px 9px 4px; color: var(--muted);
  border: 1px solid transparent;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  background: rgba(20, 32, 52, 0.5);
  transition: all 0.25s;
  white-space: nowrap;
}
.phase-chip.done { color: #b9c6d9; background: rgba(40, 58, 88, 0.55); }
.phase-chip.active {
  color: #0a0f18; background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 154, 60, 0.45);
}

#topbtns { display: flex; gap: 6px; }
.chipbtn {
  font-family: 'Mono', monospace; font-size: 9.5px; letter-spacing: 0.14em;
  color: var(--cyan); background: rgba(14, 26, 44, 0.7);
  border: 1px solid var(--line);
  padding: 6px 10px; cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: all 0.2s;
}
.chipbtn:hover { border-color: var(--line-hi); color: #cfeeff; background: rgba(24, 44, 72, 0.85); }

/* ---------- panels ---------- */
.panel {
  position: absolute;
  background:
    repeating-linear-gradient(0deg, rgba(140,180,230,0.028) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, var(--bg-panel-hi), var(--bg-panel));
  border: 1px solid var(--line);
  clip-path: var(--chamfer);
  padding: 16px 16px 14px;
  backdrop-filter: blur(5px);
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.35s;
}
.panel-title {
  font-family: 'Display', monospace; font-size: 10.5px; font-weight: 400;
  letter-spacing: 0.22em; color: var(--amber);
  margin: 14px 0 10px; display: flex; align-items: center; gap: 8px;
}
.panel-title:first-child { margin-top: 0; }
.panel-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

#config { left: 14px; top: 66px; width: 292px; max-height: calc(100vh - 172px); overflow-y: auto; }
#config.hidden-panel { transform: translateX(-115%); opacity: 0; pointer-events: none; }
#telemetry { right: 14px; top: 66px; width: 268px; max-height: calc(100vh - 172px); overflow-y: auto; }
#telemetry.hidden-panel { transform: translateX(115%); opacity: 0; pointer-events: none; }

.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-thumb { background: rgba(120,160,210,0.3); }

.ctl { margin-bottom: 13px; }
.ctl label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'Mono', monospace; font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--muted); margin-bottom: 6px;
}
.ctl output { color: var(--cyan); font-size: 11.5px; letter-spacing: 0.05em; font-weight: 600; }
.scale-note {
  font-family: 'Mono', monospace; font-size: 8.5px; letter-spacing: 0.08em;
  color: var(--muted); margin-top: 5px; opacity: 0.85;
}

input[type='range'] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; background: transparent; cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, rgba(111,214,255,0.55), rgba(255,154,60,0.55));
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; margin-top: -5px;
  background: #0b1420; border: 2px solid var(--cyan);
  transform: rotate(45deg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type='range']:hover::-webkit-slider-thumb {
  border-color: var(--amber-hi);
  box-shadow: 0 0 10px rgba(255,180,100,0.5);
}
input[type='range']::-moz-range-track { height: 3px; background: rgba(140,190,240,0.4); }
input[type='range']::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 0;
  background: #0b1420; border: 2px solid var(--cyan); transform: rotate(45deg);
}

.seg { display: flex; gap: 4px; }
.seg button {
  flex: 1; font-family: 'Mono', monospace; font-size: 9px; letter-spacing: 0.1em;
  color: var(--muted); background: rgba(16, 28, 48, 0.7);
  border: 1px solid var(--line); padding: 6px 2px; cursor: pointer;
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
  transition: all 0.18s;
}
.seg button:hover { color: var(--txt); border-color: var(--line-hi); }
.seg button.on { color: #08101c; background: var(--cyan); border-color: var(--cyan); font-weight: 600; }
.seg.small button { padding: 5px 6px; flex: 0 0 auto; }

.site-readout {
  border: 1px dashed var(--line);
  padding: 8px 10px; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 3px;
}
#siteLabel { font-family: 'Mono', monospace; font-size: 10px; letter-spacing: 0.1em; color: var(--amber-hi); }
#siteCoords { font-family: 'Mono', monospace; font-size: 9px; color: var(--muted); letter-spacing: 0.08em; }

.quick-sites { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.quick-sites button {
  font-family: 'Mono', monospace; font-size: 8.5px; letter-spacing: 0.1em;
  color: var(--cyan); background: transparent; border: 1px solid var(--line);
  padding: 4px 7px; cursor: pointer; transition: all 0.18s;
}
.quick-sites button:hover { border-color: var(--cyan); background: rgba(111,214,255,0.1); }

.preview { border-top: 1px solid var(--line); padding-top: 10px; margin-bottom: 12px; }
.pv-row {
  display: flex; justify-content: space-between; padding: 3px 0;
  font-family: 'Mono', monospace; font-size: 9.5px; letter-spacing: 0.1em;
}
.pv-row span { color: var(--muted); }
.pv-row b { color: var(--txt); font-weight: 600; }
.pv-row b.warn { color: var(--red); }

#btnLaunch {
  width: 100%;
  font-family: 'Display', monospace; font-size: 12px; letter-spacing: 0.18em;
  color: #140a02; background: linear-gradient(180deg, var(--amber-hi), var(--amber));
  border: none; padding: 13px 10px 12px; cursor: pointer;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  transition: filter 0.2s, transform 0.15s;
  box-shadow: 0 0 26px rgba(255, 154, 60, 0.35);
}
#btnLaunch:hover { filter: brightness(1.12); transform: translateY(-1px); }
#btnLaunch:active { transform: translateY(1px); }
#fxNote { margin-top: 8px; text-align: center; }

/* ---------- telemetry ---------- */
.tm-clock {
  display: flex; justify-content: space-between; align-items: baseline;
  border: 1px solid var(--line); padding: 7px 10px; margin-bottom: 10px;
  background: rgba(10, 20, 36, 0.6);
}
#tmPhase { font-family: 'Display', monospace; font-size: 10px; letter-spacing: 0.2em; color: var(--amber); }
#tmClock { font-family: 'Mono', monospace; font-size: 15px; color: var(--cyan); font-weight: 600; letter-spacing: 0.06em; }

.tm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.tm {
  border: 1px solid rgba(120,160,210,0.14); padding: 6px 8px 5px;
  background: rgba(12, 22, 40, 0.5);
  display: flex; flex-direction: column; gap: 2px;
}
.tm span { font-family: 'Mono', monospace; font-size: 7.5px; letter-spacing: 0.14em; color: var(--muted); }
.tm b { font-family: 'Mono', monospace; font-size: 11px; color: var(--txt); font-weight: 600; letter-spacing: 0.02em; }
.tm.live b { color: var(--cyan); }
.tm.live { border-color: rgba(111,214,255,0.25); }

.tm-compare {
  margin-top: 10px; padding: 8px 10px;
  border-left: 2px solid var(--amber);
  background: rgba(255, 154, 60, 0.06);
  font-size: 11px; line-height: 1.45; color: #d7dfeb;
  min-height: 52px;
  transition: opacity 0.4s;
}
.fold {
  font-family: 'Mono', monospace; background: none; border: 1px solid var(--line);
  color: var(--muted); width: 18px; height: 18px; line-height: 1; cursor: pointer; font-size: 11px;
}
#telemetry.folded #telemetryBody { display: none; }

/* ---------- bottom deck ---------- */
#deck {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px 14px;
  background: linear-gradient(0deg, rgba(3,6,12,0.88), rgba(3,6,12,0));
}
#deckLeft { display: flex; gap: 6px; align-items: center; }
.deckbtn {
  font-family: 'Mono', monospace; font-size: 12px;
  color: var(--txt); background: rgba(14, 26, 44, 0.75);
  border: 1px solid var(--line); width: 38px; height: 34px; cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: all 0.18s;
}
.deckbtn:hover { border-color: var(--amber); color: var(--amber-hi); }
.deckbtn.wide { width: auto; padding: 0 12px; font-size: 9px; letter-spacing: 0.14em; }

#deckMid { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
#scrubWrap { position: relative; padding: 0 2px; }
#scrubTicks {
  position: absolute; left: 2px; right: 2px; top: -4px; height: 4px;
  pointer-events: none;
}
.scrub-tick {
  position: absolute; top: 0; width: 1px; height: 4px;
  background: rgba(150, 190, 235, 0.5);
}
.scrub-tick.major { height: 6px; top: -2px; background: var(--amber); width: 2px; }
#scrub { width: 100%; }

#warpRow, #deckRight { display: flex; align-items: center; gap: 8px; }
.warp-label { font-family: 'Mono', monospace; font-size: 8.5px; letter-spacing: 0.2em; color: var(--muted); white-space: nowrap; }
#warpNow { font-family: 'Mono', monospace; font-size: 10px; color: var(--amber-hi); min-width: 52px; }

/* ---------- letterbox ---------- */
.letterbox {
  position: fixed; left: 0; right: 0; height: 0;
  background: #000; z-index: 4; transition: height 0.8s cubic-bezier(0.3, 0.8, 0.3, 1);
}
#letterboxTop { top: 0; } #letterboxBot { bottom: 0; }
body.cinema .letterbox { height: 5.5vh; }
body.cinema #topbar, body.cinema #deck { opacity: 0.25; transition: opacity 0.4s; }
body.cinema #topbar:hover, body.cinema #deck:hover { opacity: 1; }

/* ---------- intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 45%, rgba(6,12,24,0.25), rgba(2,4,9,0.82) 75%);
  transition: opacity 0.9s;
}
#intro.gone { opacity: 0; pointer-events: none; }
#introCard {
  max-width: 620px; width: calc(100% - 48px);
  padding: 38px 42px 32px;
  background: linear-gradient(155deg, rgba(10,18,32,0.92), rgba(5,9,17,0.9));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
  animation: cardIn 1.1s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}
.intro-eyebrow {
  font-family: 'Mono', monospace; font-size: 9px; letter-spacing: 0.3em;
  color: var(--cyan); margin-bottom: 16px;
}
#introCard h1 {
  font-family: 'Display', monospace; font-weight: 400;
  font-size: clamp(28px, 5.4vw, 44px); letter-spacing: 0.03em; line-height: 1.02;
  margin-bottom: 18px;
}
#introCard h1 b { color: var(--amber); font-weight: 400; }
.intro-lede { color: #b9c4d6; line-height: 1.6; font-size: 13.5px; margin-bottom: 20px; max-width: 52ch; }
.intro-points { list-style: none; margin-bottom: 26px; display: flex; flex-direction: column; gap: 7px; }
.intro-points li { font-family: 'Mono', monospace; font-size: 10.5px; letter-spacing: 0.06em; color: var(--muted); }
.intro-points b { color: var(--amber-hi); font-weight: 600; margin-right: 8px; letter-spacing: 0.14em; }
#btnEnter {
  font-family: 'Display', monospace; font-size: 13px; letter-spacing: 0.2em;
  color: #140a02; background: linear-gradient(180deg, var(--amber-hi), var(--amber));
  border: none; padding: 15px 30px 14px; cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  box-shadow: 0 0 34px rgba(255,154,60,0.4);
  transition: filter 0.2s, transform 0.15s;
}
#btnEnter:hover { filter: brightness(1.12); transform: translateY(-1px); }
.intro-hint { margin-top: 14px; font-family: 'Mono', monospace; font-size: 8.5px; letter-spacing: 0.2em; color: var(--muted); }

/* ---------- help / toast / misc ---------- */
#help {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 4, 9, 0.7); backdrop-filter: blur(3px);
}
#helpCard {
  width: min(460px, calc(100% - 40px));
  padding: 26px 30px;
  background: linear-gradient(155deg, rgba(12,20,36,0.96), rgba(6,10,19,0.96));
  border: 1px solid var(--line-hi);
  clip-path: var(--chamfer);
}
#helpCard h2 { font-family: 'Display', monospace; font-size: 13px; font-weight: 400; letter-spacing: 0.24em; color: var(--amber); margin-bottom: 16px; }
.help-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; margin-bottom: 20px; }
.help-grid span:nth-child(odd) { font-family: 'Mono', monospace; font-size: 10px; color: var(--cyan); letter-spacing: 0.08em; white-space: nowrap; }
.help-grid span:nth-child(even) { font-size: 11.5px; color: #c3cddd; }
#btnHelpClose {
  font-family: 'Mono', monospace; font-size: 10px; letter-spacing: 0.18em;
  color: var(--txt); background: rgba(20,34,56,0.8); border: 1px solid var(--line);
  padding: 8px 18px; cursor: pointer;
}
.hidden { display: none !important; }

#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.toast-msg {
  font-family: 'Mono', monospace; font-size: 10.5px; letter-spacing: 0.16em;
  color: var(--amber-hi); background: rgba(8,14,26,0.9);
  border: 1px solid rgba(255,154,60,0.4);
  padding: 8px 16px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  animation: toastIn 0.35s cubic-bezier(0.2,0.9,0.3,1) both;
}
.toast-msg.out { animation: toastOut 0.5s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

#fallback {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px;
}
#fallback h2 { font-family: 'Display', monospace; letter-spacing: 0.2em; color: var(--red); }

.mobile-toggle { display: none; }

@media (max-width: 920px) {
  #config { transform: translateX(-115%); opacity: 0; pointer-events: none; width: min(300px, 84vw); top: 58px; }
  #config.show-mobile { transform: none; opacity: 1; pointer-events: auto; }
  #telemetry { transform: translateX(115%); opacity: 0; pointer-events: none; width: min(280px, 80vw); top: 58px; }
  #telemetry.show-mobile { transform: none; opacity: 1; pointer-events: auto; }
  .mobile-toggle {
    display: block; position: absolute; top: 60px; z-index: 6;
    font-family: 'Mono', monospace; font-size: 9px; letter-spacing: 0.14em;
    color: var(--cyan); background: rgba(10,20,36,0.85); border: 1px solid var(--line);
    padding: 7px 9px; cursor: pointer;
  }
  .mobile-toggle.left { left: 0; border-left: none; }
  .mobile-toggle.right { right: 0; border-right: none; }
  #phases { display: none; }
  #deck { flex-wrap: wrap; gap: 8px; }
  #deckMid { order: 3; flex-basis: 100%; }
  #warpRow { flex-wrap: wrap; }
  .brand-sub { display: none; }
}
