:root {
  --bg: #0a1120;
  --bg-alt: #0f1a2e;
  --surface: #131f36;
  --surface-hi: #1b2a47;
  --border: #253a5e;
  --text: #eaf1fb;
  --text-dim: #9db0cc;
  --amber: #f5a623;
  --amber-soft: #f5a62333;
  --sky: #38bdf8;
  --green: #34d399;
  --red: #f87171;
  --radius: 16px;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
}

.sky-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 15% -10%, #1c3a63 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 10%, #2a2350 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}
.sky-glow {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(circle, var(--amber-soft) 0%, transparent 70%);
  filter: blur(10px);
}
.flight-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
}
.flight-path path {
  fill: none;
  stroke: var(--sky);
  stroke-width: 2;
  stroke-dasharray: 6 10;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(10, 17, 32, 0.7);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand-mark { color: var(--amber); font-size: 1.2rem; }
.topnav a {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}
.topnav a:hover { color: var(--text); }

main#app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 80px;
  min-height: 70vh;
}

.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 28px 24px 48px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Home / Hero ---------- */
.hero {
  padding: 64px 0 40px;
  text-align: center;
}
.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--amber);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--amber-soft);
  border: 1px solid #f5a62355;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 16px;
}
.hero h1 span { color: var(--sky); }
.hero p.lede {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}

.overall-progress {
  max-width: 520px;
  margin: 32px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
}
.overall-progress .ring { flex-shrink: 0; }
.overall-progress .label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.overall-progress .value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

.sim-promo {
  display: flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(120deg, #16233d 0%, #1b1440 100%);
  border: 1px solid #38bdf855;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 32px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.sim-promo:hover {
  transform: translateY(-3px);
  border-color: var(--sky);
}
.sim-promo-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.sim-promo h3 {
  font-family: var(--font-display);
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.sim-promo p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.45;
}
.sim-promo-arrow {
  margin-left: auto;
  font-size: 1.3rem;
  color: var(--sky);
  flex-shrink: 0;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 36px;
}

.topic-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(160deg, var(--surface) 0%, var(--bg-alt) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}
.topic-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(240px 120px at 90% -10%, var(--card-color, var(--amber)) 0%, transparent 70%);
  opacity: 0.18;
  pointer-events: none;
}
.topic-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-color, var(--amber));
  box-shadow: 0 12px 30px -12px rgba(0,0,0,0.5);
}
.topic-card .top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.topic-card .icon {
  font-size: 1.8rem;
  line-height: 1;
}
.topic-card h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 14px 0 6px;
}
.topic-card p {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.45;
}
.mastery-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  background: conic-gradient(var(--card-color, var(--amber)) calc(var(--pct, 0) * 1%), var(--border) 0);
  flex-shrink: 0;
}
.mastery-ring::after {
  content: attr(data-pct) "%";
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Topic detail ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  margin: 28px 0 10px;
}
.back-link:hover { color: var(--text); }

.topic-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0 8px;
}
.topic-header .icon-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  background: var(--card-color, var(--amber));
  background: color-mix(in srgb, var(--card-color, var(--amber)) 22%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--card-color, var(--amber)) 50%, var(--border));
}
.topic-header h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0 0 4px;
}
.topic-header p {
  color: var(--text-dim);
  margin: 0;
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--card-color, var(--amber));
  margin: 40px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.big-ideas {
  display: grid;
  gap: 12px;
}
.big-idea-item {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.94rem;
  line-height: 1.55;
}
.big-idea-item .num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--card-color, var(--amber));
  flex-shrink: 0;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-color, var(--sky));
  border-radius: 12px;
  padding: 16px 18px;
}
.example-card h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-family: var(--font-display);
}
.example-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ---------- Quiz ---------- */
.quiz-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.difficulty-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
}
.difficulty-pill.easy { background: #34d39922; color: var(--green); }
.difficulty-pill.medium { background: #f5a62322; color: var(--amber); }
.difficulty-pill.hard { background: #f8717122; color: var(--red); }

.streak {
  font-size: 0.82rem;
  color: var(--text-dim);
}
.streak strong { color: var(--text); }

.question-text {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 18px;
}

.choices {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.choice-btn {
  text-align: left;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.94rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-family: var(--font-body);
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--sky);
}
.choice-btn:disabled { cursor: default; }
.choice-btn.correct {
  border-color: var(--green);
  background: #34d39918;
}
.choice-btn.incorrect {
  border-color: var(--red);
  background: #f8717118;
}
.choice-btn.reveal-correct {
  border-color: var(--green);
}

.feedback {
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 16px;
}
.feedback.correct { background: #34d39915; border: 1px solid #34d39944; }
.feedback.incorrect { background: #f8717115; border: 1px solid #f8717144; }
.feedback strong { display: block; margin-bottom: 4px; }

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.btn:hover { border-color: var(--sky); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--amber), #ffcc66);
  color: #241a00;
  border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.05); }

.mastery-bar-wrap {
  margin-top: 22px;
}
.mastery-bar-wrap .label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.mastery-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}
.mastery-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sky), var(--green));
  transition: width 0.3s ease;
}

/* ---------- Flight Simulator ---------- */
.sim-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.sim-canvas-wrap {
  flex: 1 1 480px;
  max-width: 640px;
  position: relative;
  aspect-ratio: 640 / 420;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  overflow: hidden;
}
.sim-3d-mount {
  width: 100%;
  height: 100%;
  touch-action: none;
}
.sim-3d-mount canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.sim-minimap {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 96px;
  height: 96px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.sim-hud {
  flex: 1 1 240px;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sim-gauge-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}
.alt-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.alt-gauge-track {
  width: 22px;
  height: 120px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.alt-gauge-fill {
  width: 100%;
  height: 12%;
  background: linear-gradient(180deg, var(--red), var(--amber) 60%, var(--sky));
  transition: height 0.1s linear;
}
.alt-gauge-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.heading-readout {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.heading-readout .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.heading-readout .value {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
}
.sim-warning {
  background: #f8717118;
  border: 1px solid #f8717155;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.keypad-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.keypad-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 180px;
}
.key-btn {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.08s ease, border-color 0.08s ease, transform 0.08s ease;
}
.key-btn:hover { border-color: var(--sky); }
.key-btn.active {
  background: var(--sky);
  border-color: var(--sky);
  color: #041322;
  transform: scale(0.94);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

@media (max-width: 560px) {
  .topbar { padding: 16px 18px; }
  main#app { padding: 0 16px 60px; }
  .hero { padding: 40px 0 24px; }
  .overall-progress { flex-direction: column; text-align: center; }
}
