:root {
  --bg: #000000;
  --hud: #00ff88;
  --hud-dim: #00c46a;
  --hud-warn: #ff9f43;
  --hud-danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  color: var(--hud);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.start-error {
  padding: 12px 20px;
  margin: 0 24px 4px;
  border: 1px solid var(--hud-danger);
  color: var(--hud-danger);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.1em;
}

.nav-item[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Screens --- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

/* --- Focus rings (D-pad) --- */
.focusable {
  outline: none;
  border: 2px solid transparent;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  cursor: pointer;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 18px var(--focus-glow);
}

/* ============================================================
   START SCREEN
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.2);
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2em;
}
.header-meta {
  font-size: 14px;
  color: var(--hud-dim);
  letter-spacing: 0.2em;
}

.content.start-content {
  flex: 1;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  text-align: center;
}
.start-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.6);
}
.start-sub {
  font-size: 14px;
  color: var(--hud-dim);
  line-height: 1.6;
  max-width: 440px;
}
.readout-row {
  display: flex;
  gap: 14px;
  margin-top: 8px;
}
.readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  border: 1px solid rgba(0, 255, 136, 0.35);
  border-radius: 6px;
  min-width: 96px;
}
.readout-label {
  font-size: 11px;
  color: var(--hud-dim);
  letter-spacing: 0.2em;
}
.readout-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}

.nav-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px 22px;
  border-top: 1px solid rgba(0, 255, 136, 0.2);
}
.nav-item {
  flex: 1;
  min-height: 56px;
  background: transparent;
  color: var(--hud);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2em;
  border-radius: 8px;
  border: 2px solid var(--hud-dim);
}
.nav-item.primary {
  border-color: var(--hud);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.35);
}

/* ============================================================
   HUD SCREEN
   ============================================================ */
#hud {
  background: #000;
}

/* Heading tape (top) */
.hud-heading {
  position: relative;
  height: 56px;
  flex: 0 0 56px;
  border-bottom: 1px solid rgba(0, 255, 136, 0.25);
}
.hud-heading svg {
  width: 100%;
  height: 100%;
  display: block;
}
.heading-tape-tick {
  stroke: var(--hud);
  stroke-width: 1.5;
}
.heading-tape-tick.major { stroke-width: 2; }
.heading-tape-label {
  fill: var(--hud);
  font: 12px 'SF Mono', monospace;
  text-anchor: middle;
}
.heading-caret {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--hud);
  font-size: 14px;
}
.heading-value {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  padding: 0 6px;
  font-size: 15px;
  font-weight: 700;
}

/* Center: attitude indicator fills the middle */
.hud-center {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.hud-center svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pitch ladder lines (drawn via JS) */
.pitch-line {
  stroke: var(--hud);
  stroke-width: 1.5;
  fill: none;
}
.pitch-line.dashed {
  stroke-dasharray: 6 6;
  stroke: var(--hud-dim);
}
.pitch-line.horizon {
  stroke-width: 2.5;
}
.pitch-label {
  fill: var(--hud);
  font: 11px 'SF Mono', monospace;
}

/* Fixed pipper / crosshair */
.pipper line {
  stroke: var(--hud);
  stroke-width: 2.5;
  stroke-linecap: round;
}
.pipper circle {
  fill: var(--hud);
}

/* Roll arc and caret */
.roll-scale path {
  stroke: var(--hud-dim);
  stroke-width: 1.5;
}
.roll-scale .roll-tick {
  stroke: var(--hud-dim);
  stroke-width: 1.5;
}
.roll-scale .roll-tick-major {
  stroke: var(--hud);
  stroke-width: 2;
}
.roll-caret polygon {
  fill: var(--hud);
}

/* --- Mode overlays (A/A, A/G) --- */
.mode-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* A/A: air-to-air target / aim ring */
.aa-ring {
  fill: none;
  stroke: var(--hud);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
  opacity: 0.75;
}
.aa-ring-tick {
  stroke: var(--hud);
  stroke-width: 1.5;
}
.aa-td-box {
  fill: none;
  stroke: var(--hud-dim);
  stroke-width: 2;
  transition: stroke 120ms ease;
}
.aa-td-tick {
  stroke: var(--hud-dim);
  stroke-width: 2;
  transition: stroke 120ms ease;
}
#aa-target.locked .aa-td-box,
#aa-target.locked .aa-td-tick {
  stroke: var(--hud-danger);
}
.aa-shoot {
  fill: var(--hud-warn);
  font: 700 18px 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.35em;
}
.aa-shoot.hidden { display: none; }

/* A/G: air-to-ground CCIP */
.ag-bombfall {
  stroke: var(--hud);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
  opacity: 0.75;
}
.ag-ccip-ring {
  fill: none;
  stroke: var(--hud);
  stroke-width: 2;
}
.ag-ccip-tick {
  stroke: var(--hud);
  stroke-width: 2;
}
.ag-ccip-dot {
  fill: var(--hud);
}
.ag-td-diamond {
  fill: none;
  stroke: var(--hud);
  stroke-width: 2;
}
.ag-inrange {
  fill: var(--hud-warn);
  font: 700 16px 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.3em;
}
.ag-inrange.hidden { display: none; }

.mode-label {
  fill: var(--hud);
  font: 700 12px 'SF Mono', 'Menlo', monospace;
  letter-spacing: 0.15em;
}

/* Left/right tapes (speed / altitude) */
.hud-tape {
  position: absolute;
  top: 72px;
  width: 88px;
  height: calc(100% - 72px - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.hud-tape-left { left: 16px; border: 1px solid rgba(0, 255, 136, 0.35); border-radius: 6px; background: rgba(0,0,0,0.3); }
.hud-tape-right { right: 16px; border: 1px solid rgba(0, 255, 136, 0.35); border-radius: 6px; background: rgba(0,0,0,0.3); }
.tape-label {
  font-size: 11px;
  color: var(--hud-dim);
  letter-spacing: 0.2em;
}
.tape-value {
  font-size: 28px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

/* Bottom status */
.hud-status {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: 64px;
  flex: 0 0 64px;
  border-top: 1px solid rgba(0, 255, 136, 0.25);
  padding: 6px 12px;
  gap: 6px;
}
.status-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  min-width: 0;
}
.status-label {
  font-size: 11px;
  color: var(--hud-dim);
  letter-spacing: 0.2em;
}
.status-value {
  font-size: 18px;
  font-weight: 700;
}
.status-value.warn { color: var(--hud-warn); }
.status-value.danger { color: var(--hud-danger); }

/* Focusable variant (MODE / EXIT buttons) */
.status-btn {
  background: transparent;
  color: var(--hud);
  font-family: inherit;
  border: 1px solid rgba(0, 255, 136, 0.35);
  border-radius: 6px;
  cursor: pointer;
}
.status-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 14px var(--focus-glow);
  outline: none;
}

.hidden { display: none !important; }
