:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel-border: #263652;
  --text: #e7edf7;
  --text-dim: #93a3bf;
  --accent: #ffb340;
  --accent-dim: #a8792b;
  --green: #3ddc84;
  --red: #ff5d5d;
  --blue: #4da3ff;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top, #16223a 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 480px) 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .reset-btn { margin-left: 0; }
}

.diagram-panel,
.quiz-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  flex: 1;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #182338;
  color: var(--text-dim);
  cursor: pointer;
}

.mode-btn:hover {
  border-color: var(--blue);
  color: var(--text);
}

.mode-btn.active {
  background: rgba(77, 163, 255, 0.16);
  border-color: var(--blue);
  color: var(--blue);
}

#diagram {
  width: 100%;
  height: auto;
  display: block;
}

#diagram.sectors-draggable {
  cursor: grab;
}

#diagram.dragging {
  cursor: grabbing;
}

.rotate-hint {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

.rotate-hint[hidden] {
  display: none;
}

#rotate-offset {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#rotate-reset-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.hint-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.hint-btn {
  display: block;
  flex: 1;
  padding: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px dashed var(--accent-dim);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.hint-btn[hidden] {
  display: none;
}

.hint-btn:hover {
  background: rgba(255, 179, 64, 0.1);
  border-style: solid;
}

.hint-btn.active {
  background: rgba(255, 179, 64, 0.16);
  border-style: solid;
}

.math-hint {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0e1727;
  border: 1px solid var(--accent-dim);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-dim);
}

.math-hint[hidden] {
  display: none;
}

.math-hint strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.math-hint-list {
  margin: 0;
  padding-left: 18px;
}

.math-hint-list li + li {
  margin-top: 4px;
}

.math-hint-bands {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.band-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.band-row.active {
  color: var(--text);
  font-weight: 700;
}

.prompt {
  line-height: 1.5;
  font-size: 1.02rem;
}

.prompt strong {
  color: var(--accent);
}

.atc-line {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92rem;
  color: var(--text-dim);
  background: #0e1727;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.atc-line strong {
  color: var(--blue);
}

.prompt-question {
  font-weight: 600;
  margin-bottom: 0;
}

.answer-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.answer-btn {
  padding: 14px 8px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: #182338;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--blue);
  background: #1c2c4a;
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.correct {
  background: rgba(61, 220, 132, 0.18);
  border-color: var(--green);
  color: var(--green);
}

.answer-btn.incorrect {
  background: rgba(255, 93, 93, 0.18);
  border-color: var(--red);
  color: var(--red);
}

.feedback {
  min-height: 66px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0e1727;
  border: 1px solid var(--panel-border);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.feedback.correct { border-color: var(--green); color: var(--text); }
.feedback.incorrect { border-color: var(--red); color: var(--text); }

.heading-quiz {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0e1727;
  border: 1px solid var(--accent-dim);
}

.heading-quiz[hidden] {
  display: none;
}

.heading-quiz-label {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 8px;
}

.heading-quiz-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#heading-input {
  width: 80px;
  padding: 8px 10px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: #182338;
  color: var(--text);
}

#heading-input:disabled {
  opacity: 0.7;
}

.heading-quiz-deg {
  color: var(--text-dim);
}

#heading-submit-btn {
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--blue);
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

#heading-submit-btn:hover:not(:disabled) {
  background: rgba(77, 163, 255, 0.12);
}

#heading-submit-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.heading-feedback {
  margin-top: 8px;
  font-size: 0.85rem;
  min-height: 1em;
}

.heading-feedback.correct { color: var(--green); }
.heading-feedback.incorrect { color: var(--red); }

.five-ts {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0e1727;
  border: 1px solid var(--accent-dim);
}

.five-ts[hidden] {
  display: none;
}

.five-ts-label {
  margin: 0 0 10px;
  font-size: 0.88rem;
}

.five-ts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.five-ts-chip {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: #182338;
  color: var(--text);
  cursor: pointer;
}

.five-ts-chip:hover:not(:disabled) {
  border-color: var(--blue);
  background: #1c2c4a;
}

.five-ts-chip:disabled {
  cursor: default;
}

.five-ts-chip.placed {
  border-color: var(--green);
  color: var(--green);
  opacity: 0.4;
}

.five-ts-chip.shake {
  animation: five-ts-shake 0.3s;
  border-color: var(--red);
}

@keyframes five-ts-shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.five-ts-twist {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #182338;
  border: 1px solid var(--blue);
}

.five-ts-twist[hidden] {
  display: none;
}

.five-ts-twist-label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.five-ts-twist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#five-ts-twist-input {
  width: 80px;
  padding: 8px 10px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: #0e1727;
  color: var(--text);
}

#five-ts-twist-input:disabled {
  opacity: 0.7;
}

.five-ts-twist-deg {
  color: var(--text-dim);
}

#five-ts-twist-submit-btn {
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--blue);
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

#five-ts-twist-submit-btn:hover:not(:disabled) {
  background: rgba(77, 163, 255, 0.12);
}

#five-ts-twist-submit-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.five-ts-twist-feedback {
  margin-top: 8px;
  font-size: 0.85rem;
  min-height: 1em;
}

.five-ts-twist-feedback.correct { color: var(--green); }
.five-ts-twist-feedback.incorrect { color: var(--red); }

.five-ts-sequence {
  margin: 12px 0 0;
  padding-left: 20px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.five-ts-sequence strong {
  color: var(--accent);
}

.five-ts-feedback {
  margin-top: 8px;
  font-size: 0.85rem;
  min-height: 1em;
  color: var(--green);
}

.next-btn {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  font-size: 0.98rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #1a1200;
  cursor: pointer;
}

.next-btn:hover { background: #ffc266; }

.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.reset-btn {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.reset-btn:hover { color: var(--red); border-color: var(--red); }

.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.settings label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.training-mix {
  flex: 0 0 100%;
  margin: 0;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.035em;
}

.settings select {
  background: #182338;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 2px 6px;
}

.reference {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.reference summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
}

.reference dl {
  margin: 10px 0 0;
}

.reference dt {
  color: var(--text);
  font-weight: 600;
  margin-top: 8px;
}

.reference dd {
  margin: 2px 0 0;
  line-height: 1.5;
}

.disclaimer {
  max-width: 760px;
  margin: 28px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---------- Pilot Arcade mission skin ---------- */

:root {
  --bg: #050b12;
  --panel: rgba(9, 22, 35, 0.82);
  --panel-border: #243b58;
  --text: #eaf1ff;
  --text-dim: #8396b1;
  --accent: #ffb020;
  --accent-dim: #91651b;
  --green: #37ff9a;
  --red: #ff5d67;
  --blue: #2ce0ff;
  --radius: 6px;
  --font-display: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

html,
body {
  min-height: 100%;
}

body {
  background: #050b12;
  font-family: var(--font-display);
}

button,
input,
select {
  font: inherit;
}

.arcade-nav {
  position: relative;
  z-index: 10;
  width: 100%;
  min-height: 76px;
  padding: 0 clamp(18px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(255, 176, 32, 0.25);
  background: rgba(5, 24, 35, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

.arcade-nav a {
  color: inherit;
  text-decoration: none;
}

.arcade-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  white-space: nowrap;
}

.arcade-brand img {
  display: block;
  width: 78px;
  height: auto;
  filter: drop-shadow(0 0 8px rgba(44, 224, 255, 0.25));
}

.arcade-brand strong {
  color: var(--accent);
}

.all-missions {
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(255, 176, 32, 0.5);
  border-radius: 4px;
  background: rgba(255, 176, 32, 0.08);
  color: var(--accent) !important;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.all-missions:hover,
.all-missions:focus-visible {
  color: #161000 !important;
  background: var(--accent);
  box-shadow: 0 0 20px rgba(255, 176, 32, 0.3);
  outline: 0;
}

.app-stage {
  position: relative;
  min-height: calc(100vh - 76px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 35% 22%, rgba(31, 139, 174, 0.13), transparent 30%),
    linear-gradient(180deg, rgba(6, 29, 42, 0.56), transparent 44%),
    #050b12;
}

.app-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(44, 224, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44, 224, 255, 0.16) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 78% 66% at 50% 32%, black 5%, transparent 78%);
}

.app-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 80px;
  left: 31%;
  width: min(72vw, 760px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  opacity: 0.2;
  background:
    repeating-radial-gradient(circle, transparent 0 86px, rgba(44, 224, 255, 0.2) 87px 88px),
    conic-gradient(from 0deg, transparent 0 24.5%, rgba(255, 176, 32, 0.2) 25% 25.3%, transparent 25.5% 49.5%, rgba(44, 224, 255, 0.15) 50% 50.3%, transparent 50.5% 74.5%, rgba(44, 224, 255, 0.15) 75% 75.3%, transparent 75.5%);
  mask-image: radial-gradient(circle, black 0 48%, transparent 75%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  padding: 34px 24px 64px;
}

.app-header {
  margin-bottom: 26px;
}

.mission-id {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.app-header h1 {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--blue);
  font-size: clamp(1.3rem, 3vw, 1.85rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(44, 224, 255, 0.3);
}

.brand-hair {
  flex: 1;
  max-width: 90px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(44, 224, 255, 0.45));
}

.brand-hair:last-child {
  background: linear-gradient(90deg, rgba(44, 224, 255, 0.45), transparent);
}

.subtitle {
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.layout {
  grid-template-columns: minmax(340px, 500px) minmax(0, 1fr);
  gap: 28px;
}

.diagram-panel,
.quiz-panel {
  border-color: rgba(52, 81, 118, 0.78);
  background: rgba(7, 17, 29, 0.66);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.diagram-panel {
  background: rgba(6, 15, 26, 0.38);
}

.mode-btn,
.answer-btn,
.hint-btn,
.next-btn,
.reset-btn,
#heading-submit-btn,
#five-ts-twist-submit-btn {
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.mode-btn {
  border-radius: 5px;
  background: rgba(12, 25, 42, 0.88);
  font-size: 0.72rem;
}

.mode-btn.active {
  color: #1a1100;
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffd069, var(--accent));
  box-shadow: 0 0 16px rgba(255, 176, 32, 0.32);
}

.atc-line,
.feedback,
.math-hint,
.heading-quiz,
.five-ts {
  background: rgba(6, 15, 27, 0.74);
  border-color: #2a4262;
}

.atc-line {
  border-left: 2px solid var(--blue);
  font-family: var(--font-mono);
}

.answer-btn {
  position: relative;
  overflow: visible;
  border-radius: 5px;
  background: linear-gradient(180deg, #13223a, #0c1728);
}

.answer-bubble {
  position: absolute;
  z-index: 20;
  bottom: calc(100% + 11px);
  left: 50%;
  min-width: max-content;
  padding: 7px 11px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: #07111d;
  font-family: var(--font-mono);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(0.85);
  animation: answer-bubble-pop 1.9s ease-out forwards;
}

.answer-bubble::after {
  content: "";
  position: absolute;
  top: calc(100% - 3px);
  left: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  background: #07111d;
  transform: translateX(-50%) rotate(45deg);
}

.answer-bubble.correct {
  color: var(--green);
  box-shadow: 0 0 18px rgba(55, 255, 154, 0.34);
}

.answer-bubble.incorrect {
  color: var(--red);
  box-shadow: 0 0 18px rgba(255, 93, 103, 0.34);
}

@keyframes answer-bubble-pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.85); }
  14%, 72% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -7px) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .answer-bubble {
    animation: none;
    transform: translate(-50%, 0);
  }
}

.answer-btn:hover:not(:disabled) {
  color: var(--blue);
  border-color: var(--blue);
  background: #132943;
  box-shadow: 0 0 14px rgba(44, 224, 255, 0.12);
}

.next-btn {
  color: #181000;
  border-radius: 5px;
  background: linear-gradient(180deg, #ffd069, var(--accent));
  box-shadow: 0 0 16px rgba(255, 176, 32, 0.18);
}

.stats {
  position: relative;
  gap: 18px;
  margin-top: 30px;
  padding: 28px 14px 12px;
  border: 1px solid #263d5c;
  background: rgba(7, 18, 31, 0.62);
}

.stats::before {
  content: "SESSION DATA";
  position: absolute;
  top: 9px;
  left: 14px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.stat {
  min-width: 58px;
}

.stat-value {
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 1rem;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.07em;
}

.settings {
  padding: 14px;
  border-left: 2px solid #2b496c;
  background: rgba(8, 18, 30, 0.46);
}

.settings input {
  accent-color: var(--accent);
}

.settings select,
#heading-input,
#five-ts-twist-input {
  border-color: #30496b;
  background: #0c1a2c;
}

.reference {
  padding: 12px 14px;
  border: 1px solid rgba(42, 66, 98, 0.7);
  background: rgba(7, 17, 29, 0.38);
}

.reference summary {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.disclaimer {
  border-color: rgba(54, 78, 108, 0.55);
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .app-stage::after {
    left: 50%;
  }
}

@media (max-width: 560px) {
  .arcade-nav {
    min-height: 68px;
    padding: 0 14px;
  }

  .arcade-brand {
    gap: 8px;
    font-size: 0.61rem;
    letter-spacing: 0.2em;
  }

  .arcade-brand img {
    width: 58px;
  }

  .all-missions {
    padding: 0 10px;
    font-size: 0.58rem;
  }

  .app {
    padding: 22px 12px 48px;
  }

  .app-header h1 {
    font-size: 1.12rem;
  }

  .brand-hair {
    max-width: 34px;
  }

  .diagram-panel { padding: 8px; }
  .quiz-panel { padding: 14px; }

  .answer-buttons {
    gap: 7px;
  }

  .answer-btn {
    padding: 12px 5px;
    font-size: 0.84rem;
  }
}
