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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b192c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f8fafc;
}

#canvasContainer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

#canvasContainer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hud-left-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-panel {
  background: rgba(10, 18, 32, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 11px 15px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.instruments {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 10px 18px;
  align-items: center;
}

.metric {
  display: flex;
  flex-direction: column;
}

.metric .label,
.lift-header .label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 700;
}

.metric .value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
  white-space: nowrap;
}

.metric .value small {
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;
}

.lift-box {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lift-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lift-pct {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.lift-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.lift-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 999px;
  transition: width 0.08s linear, background-color 0.15s ease;
}

.lift-bar-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.lift-bar-fill.danger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Mission panel */
.mission-panel {
  max-width: 295px;
  pointer-events: auto;
  border-left: 3px solid #38bdf8;
}

.mission-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.badge-mini {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #38bdf8;
  text-transform: uppercase;
}

.mission-progress {
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
}

.mission-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 2px;
}

.mission-desc {
  font-size: 12px;
  line-height: 1.35;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.mission-actions {
  display: flex;
  gap: 6px;
}

/* Warning & Mission Toasts */
.warning-banner {
  align-self: center;
  margin-top: 8px;
  background: rgba(220, 38, 38, 0.92);
  border: 2px solid #fca5a5;
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.05em;
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.65);
  animation: pulseWarn 0.55s infinite alternate;
  text-align: center;
}

.warning-banner.caution {
  background: rgba(217, 119, 6, 0.9);
  border-color: #fde68a;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.45);
}

.mission-toast {
  align-self: center;
  background: rgba(21, 128, 61, 0.92);
  border: 2px solid #86efac;
  color: #ffffff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.04em;
  padding: 12px 24px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.45);
  text-align: center;
}

@keyframes pulseWarn {
  from { transform: scale(1); opacity: 0.92; }
  to { transform: scale(1.04); opacity: 1; }
}

.right-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#radarCanvas {
  border-radius: 12px;
  border: 1.5px solid rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.85);
}

#attitudeCanvas {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: #1e293b;
}

.right-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-stat {
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
}

.mini-stat strong {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.hud-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Bottom controls hint */
.hud-bottom {
  margin-top: auto;
  display: flex;
  justify-content: center;
}

.controls-pill {
  background: rgba(10, 18, 32, 0.68);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 7px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  color: #cbd5e1;
}

kbd {
  display: inline-block;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  color: #ffffff;
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 15, 28, 0.64);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}

.card {
  width: 100%;
  max-width: 590px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 24px 28px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  max-height: 94vh;
  overflow-y: auto;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.badge.danger {
  color: #f87171;
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
}

.card h1 {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 8px;
}

.card h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 14px;
  line-height: 1.48;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.mission-picker {
  text-align: left;
  margin-bottom: 16px;
}

.picker-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 7px;
}

.mission-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mission-opt {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 9px 11px;
  text-align: left;
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s ease;
}

.mission-opt strong {
  font-size: 13px;
  color: #ffffff;
}

.mission-opt span {
  font-size: 11px;
  color: #94a3b8;
}

.mission-opt:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
}

.mission-opt.active {
  background: rgba(14, 165, 233, 0.22);
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.24);
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  text-align: left;
}

.ctrl-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  padding: 8px 11px;
}

.ctrl-item .keys {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #f8fafc;
}

.ctrl-item .desc {
  font-size: 11px;
  color: #94a3b8;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box .label {
  font-size: 11px;
  color: #94a3b8;
}

.stat-box strong {
  font-size: 20px;
  color: #ffffff;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
  transition: transform 0.12s ease, filter 0.15s ease;
}

.primary-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
}

@media (max-width: 720px) {
  .controls-grid, .mission-options {
    grid-template-columns: 1fr;
  }
  #radarCanvas {
    display: none;
  }
  .controls-pill {
    display: none;
  }
}
