:root {
  --bg: #0b1220;
  --panel: #11192b;
  --ink: #e6ecff;
  --muted: #93a0c3;
  --accent: #3bd6ff;
  --accent-2: #6b8cff;
  --danger: #ff5b5b;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 14px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 70% -10%, #1a2850 0%, #0f1730 45%, var(--bg) 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}

.topbar {
  position: fixed; inset: 0 0 auto 0; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  background: linear-gradient(180deg, rgba(11,18,32,0.9), rgba(11,18,32,0.3));
  backdrop-filter: blur(8px);
  z-index: 10;
}
.brand { font-weight: 800; letter-spacing: 0.5px; color: white; }
.hud { display: flex; gap: var(--space-4); align-items: center; font-size: 14px; color: var(--muted); }
.btn { appearance: none; border: 0; border-radius: 10px; padding: 8px 12px; background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #021; font-weight: 700; box-shadow: var(--shadow); cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid #2b3b63; }

.stage { position: fixed; inset: 56px 0 40px 0; }
canvas#c { width: 100%; height: 100%; display: block; }

.joysticks { position: absolute; inset: auto 0 10px 0; display: flex; justify-content: space-between; padding: 0 var(--space-6); z-index: 9; user-select: none; -webkit-user-select: none; }
.stick { width: 40vw; max-width: 220px; aspect-ratio: 1/1; border-radius: 999px; background: radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,0.06), rgba(255,255,255,0.02)); border: 1px solid rgba(255,255,255,0.1); position: relative; box-shadow: var(--shadow); pointer-events: auto; touch-action: none; }
.stick-inner { position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1/1; transform: translate(-50%,-50%); border-radius: 999px; background: linear-gradient(180deg, #9feaff, #69a7ff); box-shadow: 0 6px 12px rgba(0,0,0,0.35), inset 0 0 10px rgba(255,255,255,0.5); }
.stick-label { position: absolute; inset: auto 0 8px 0; text-align: center; font-size: 12px; color: var(--muted); display: grid; gap: 2px; }
.stick b { color: var(--ink); font-weight: 700; }

.help { position: absolute; left: 12px; bottom: 36%; color: var(--muted); font-size: 13px; opacity: 0.9; }
.help details { background: rgba(15, 23, 46, 0.6); border: 1px solid rgba(255,255,255,0.08); padding: 8px 10px; border-radius: 10px; }
.help summary { cursor: pointer; }

.footer { position: fixed; inset: auto 0 0 0; height: 40px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: linear-gradient(0deg, rgba(11,18,32,0.9), rgba(11,18,32,0.3)); z-index: 5; }

@media (min-width: 760px) {
  .joysticks { padding: 0 40px; }
  .stick { max-width: 240px; }
}

/* Start screen */
.start-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 800px at 70% -10%, #1a2850 0%, #0f1730 45%, var(--bg) 100%);
  z-index: 100;
  transition: opacity 300ms ease, visibility 300ms ease;
}
.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.start-content {
  text-align: center;
  padding: var(--space-6);
  max-width: 420px;
}
.start-content h1 {
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 800;
  margin: 0 0 var(--space-2);
  background: linear-gradient(90deg, var(--accent), #fff, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 1px;
}
.start-content p {
  color: var(--muted);
  margin: 0 0 var(--space-6);
  font-size: 1.1rem;
}
.btn-play {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  padding: 16px 48px;
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #021;
  box-shadow: var(--shadow), 0 0 40px rgba(59, 214, 255, 0.3);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 200ms ease, filter 200ms ease;
}
.btn-play:hover { transform: scale(1.03); filter: brightness(1.1); box-shadow: var(--shadow), 0 0 60px rgba(59, 214, 255, 0.5); }
.btn-play:active { transform: scale(0.98); }
.btn-play:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.sensitivity-control {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: 0.875rem;
  text-align: left;
}
.sensitivity-control input { accent-color: var(--accent); min-height: 32px; }
.sensitivity-control output { color: var(--ink); font-variant-numeric: tabular-nums; }

.btn-secondary {
  background: linear-gradient(180deg, #2a3a5c, #1e2a4a);
  color: var(--ink);
  box-shadow: var(--shadow), 0 0 20px rgba(59, 214, 255, 0.1);
}
.btn-secondary:hover { filter: brightness(1.1); box-shadow: var(--shadow), 0 0 40px rgba(59, 214, 255, 0.2); }
.btn-secondary:active { transform: scale(0.98); }
.btn-secondary:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.controls-preview {
  margin-top: var(--space-6);
  text-align: left;
}
.controls-preview summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.controls-preview ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.8;
}
.controls-preview li { opacity: 0.85; }

/* Interactive affordances */
.btn, .stick-inner { transition: transform 120ms ease, box-shadow 120ms ease, background 200ms ease; }
.btn:hover { filter: brightness(1.05); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Telemetry HUD - simple text line at bottom */
#telemetry {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-6);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(180deg, rgba(11,18,32,0.9), rgba(11,18,32,0.6));
  backdrop-filter: blur(8px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--shadow);
  z-index: 8;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}

#telemetry span {
  display: flex;
  align-items: center;
  gap: 6px;
}

#telemetry b {
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 480px) {
  .topbar { padding: 0 var(--space-2); }
  .brand { font-size: 13px; }
  .hud { gap: 4px; }
  .btn { padding: 8px 7px; font-size: 12px; }
  #telemetry {
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
  }
  .sensitivity-control { grid-template-columns: 1fr auto; }
  .sensitivity-control input { grid-column: 1 / -1; }
}

/* 2026 flight-deck interface */
:root {
  --glass: rgba(7, 15, 25, 0.78);
  --line: rgba(118, 225, 255, 0.24);
  --warning: #ffbe3d;
  --success: #55f2a8;
}

body { overflow: hidden; background: #07101a; }
.topbar { height: 64px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(4, 10, 18, .94), rgba(4, 10, 18, .55)); }
.brand { font-size: 15px; letter-spacing: .16em; }
.brand span { color: var(--accent); font-weight: 500; }
.stage { inset: 64px 0 34px; }
.footer { height: 34px; background: #050b12; border-top: 1px solid rgba(255,255,255,.06); }
.hud { gap: 8px; }
.btn { min-height: 44px; padding: 9px 13px; color: #041119; border: 1px solid transparent; border-radius: 4px; box-shadow: none; letter-spacing: .04em; }
.btn-ghost { color: var(--ink); border-color: var(--line); background: rgba(10, 25, 40, .75); }
.btn-vision { color: var(--success); border: 1px solid rgba(85,242,168,.4); background: rgba(11, 52, 42, .72); }
.btn-vision.active { color: #02120c; background: var(--success); box-shadow: 0 0 22px rgba(85,242,168,.32); }
.btn:hover { filter: brightness(1.15); }

#vision-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }
.vision-status { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 8; display: none; padding: 6px 12px; border: 1px solid rgba(85,242,168,.45); border-radius: 3px; color: var(--success); background: rgba(2,16,12,.82); font: 700 11px/1 ui-monospace, monospace; letter-spacing: .12em; }
.vision-status.visible { display: block; }

.fpv-hud { position: absolute; inset: 0; z-index: 5; display: none; pointer-events: none; color: var(--success); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; box-shadow: inset 0 0 130px rgba(0,0,0,.72); }
.fpv-hud.visible { display: block; }
.fpv-hud::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.08) 3px 4px); mix-blend-mode: multiply; }
.fpv-corners { position: absolute; inset: 24px; border: 1px solid rgba(85,242,168,.22); background: none; }
.horizon { position: absolute; top: 50%; left: 50%; width: min(42vw, 520px); height: 1px; transform: translate(-50%,-50%); background: rgba(85,242,168,.72); transition: transform 70ms linear; }
.horizon::before,.horizon::after { content:""; position:absolute; top:-16px; height:32px; width:1px; background:currentColor; }
.horizon::before { left:30%; } .horizon::after { right:30%; }
.horizon span { position:absolute; left:50%; top:-5px; width:44px; height:10px; border:1px solid currentColor; border-top:0; transform:translateX(-50%); }
.fpv-readout { position:absolute; top:50%; display:grid; gap:5px; transform:translateY(-50%); }
.fpv-readout span,.fpv-heading span { font-size:10px; opacity:.72; letter-spacing:.15em; }
.fpv-readout b,.fpv-heading b { font-size:18px; font-weight:500; }
.fpv-left { left:5vw; text-align:left; } .fpv-right { right:5vw; text-align:right; }
.fpv-heading { position:absolute; top:5vh; left:50%; display:grid; gap:4px; text-align:center; transform:translateX(-50%); }
.reticle { position:absolute; left:50%; top:50%; width:10px; height:10px; border:1px solid currentColor; border-radius:50%; transform:translate(-50%,-50%); }

.control-legend,.settings-panel,.players-panel { position:absolute; z-index:9; border:1px solid var(--line); border-radius:4px; background:var(--glass); backdrop-filter:blur(10px); box-shadow:0 10px 36px rgba(0,0,0,.25); }
.control-legend { left:16px; top:16px; display:grid; grid-template-columns:repeat(2,auto); gap:8px 16px; max-width:360px; padding:14px; color:var(--muted); font-size:11px; }
.control-legend.hidden { display:none; }
.control-legend strong { grid-column:1 / -1; color:var(--accent); letter-spacing:.14em; }
.control-legend kbd { display:inline-grid; place-items:center; min-width:36px; min-height:24px; margin-right:4px; padding:2px 5px; border:1px solid rgba(255,255,255,.18); border-radius:3px; color:var(--ink); background:rgba(255,255,255,.06); font:inherit; }
.panel-close { position:absolute; right:5px; top:5px; min-width:28px; min-height:28px; border:0; color:var(--muted); background:transparent; cursor:pointer; }
.settings-panel { right:16px; bottom:62px; width:220px; overflow:hidden; }
.panel-toggle { width:100%; min-height:44px; padding:0 12px; border:0; color:var(--accent); background:transparent; text-align:left; font-weight:800; letter-spacing:.1em; cursor:pointer; }
#settings-body { padding:0 12px 14px; }
#settings-body label { display:flex; justify-content:space-between; margin-bottom:8px; color:var(--muted); font-size:11px; }
#settings-body input { width:100%; min-height:32px; accent-color:var(--accent); }
.players-panel { right:16px; top:16px; width:190px; padding:12px; }
.players-panel strong { color:var(--success); font-size:10px; letter-spacing:.12em; }
.players-panel ul { display:grid; gap:6px; margin:9px 0 0; padding:0; list-style:none; color:var(--ink); font-size:12px; }
.players-panel li { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.players-panel li::before { content:""; display:inline-block; width:6px; height:6px; margin-right:7px; border-radius:50%; background:var(--success); box-shadow:0 0 8px var(--success); }

.start-screen { background:linear-gradient(115deg,rgba(4,12,22,.94),rgba(6,18,33,.74)),radial-gradient(circle at 75% 20%,#12466c,#06111f 55%); }
.start-screen::before { content:""; position:absolute; inset:0; opacity:.18; background-image:linear-gradient(rgba(59,214,255,.15) 1px,transparent 1px),linear-gradient(90deg,rgba(59,214,255,.15) 1px,transparent 1px); background-size:44px 44px; mask-image:linear-gradient(to right,black,transparent 75%); }
.start-content { position:relative; width:min(92vw,560px); max-width:560px; text-align:left; }
.start-content .eyebrow { margin:0 0 8px; color:var(--accent); font:700 11px/1.4 ui-monospace,monospace; letter-spacing:.2em; }
.start-content h1 { margin-bottom:14px; font-size:clamp(2.75rem,8vw,5.5rem); line-height:.93; letter-spacing:-.045em; text-wrap:balance; }
.start-content>p:not(.eyebrow) { max-width:52ch; line-height:1.55; }
.pilot-name { display:grid; gap:6px; margin-bottom:16px; color:var(--muted); font-size:10px; letter-spacing:.14em; }
.pilot-name input { min-height:48px; padding:0 14px; border:1px solid var(--line); border-radius:4px; outline:0; color:var(--ink); background:rgba(5,14,24,.8); font:600 16px/1 system-ui; }
.pilot-name input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(59,214,255,.13); }
.pilot-name small { min-height:14px; color:#ff8d8d; letter-spacing:0; }
.start-buttons { display:grid; grid-template-columns:1.3fr 1fr; }
.btn-play { min-height:52px; padding:12px 20px; border-radius:4px; font-size:15px; }

#telemetry { bottom:43px; max-width:calc(100vw - 24px); gap:18px; border-radius:4px; background:rgba(3,10,17,.84); font-size:12px; }
#tel-detections { color:var(--success); }
.joysticks { display:none; }
.touch-only { display:none; }

@media (pointer:coarse) {
  .joysticks { display:flex; bottom:18px; }
  .stick { width:34vw; max-width:160px; background:rgba(4,15,25,.38); }
  .touch-only { display:inline-flex; }
  .control-legend { display:none; }
  .settings-panel { bottom:180px; }
}

@media (max-width:760px) {
  .topbar { height:56px; padding:0 8px; }
  .stage { inset:56px 0 30px; }
  .brand span { display:none; }
  .hud { gap:4px; }
  .hud .btn { min-width:44px; padding:7px; font-size:0; }
  #btn-camera::after { content:"CAM"; font-size:10px; }
  #btn-vision::after { content:"CV"; font-size:10px; }
  #btn-gyro::after { content:"GYRO"; font-size:10px; }
  #btn-pause::after { content:"PAUSE"; font-size:10px; }
  #btn-reset { display:none; }
  .players-panel { right:8px; top:8px; width:145px; }
  .settings-panel { right:8px; width:190px; }
  .start-buttons { grid-template-columns:1fr; }
  .start-content { padding:20px; }
  .controls-preview { display:none; }
  #telemetry { bottom:36px; gap:10px; overflow-x:auto; justify-content:flex-start; }
  #tel-vspeed,#tel-heading,#tel-detections { display:none; }
}
