/* CSS Variables */
:root {
  --bg:    #0a0e1a;
  --surf:  #111827;
  --surf2: #1a2235;
  --surf3: #1f2d42;
  --bdr:   rgba(99,179,237,0.18);
  --bdr2:  rgba(99,179,237,0.35);
  --acc:   #38bdf8;
  --gold:  #fbbf24;
  --grn:   #34d399;
  --red:   #f87171;
  --org:   #fb923c;
  --pur:   #a78bfa;
  --txt:   #e2e8f0;
  --txt2:  #94a3b8;
  --txt3:  #64748b;
  --fh:    'Syne', sans-serif;
  --fm:    'Space Mono', monospace;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--fm);
  background: var(--bg);
  color: var(--txt);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
  padding: 24px;
}

.hidden {
  display: none !important;
}

/* Screen 1: Title / Level Select */
#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 48px;
}

.title-container {
  text-align: center;
  margin-bottom: 48px;
}

.logo {
  font-family: var(--fh);
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 800;
  color: var(--acc);
  letter-spacing: 0.08em;
  text-shadow: 0 0 30px rgba(56, 189, 248, 0.4);
}

.tagline {
  font-size: 0.875rem;
  color: var(--txt2);
  margin-top: 8px;
  letter-spacing: 0.05em;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 680px;
  margin-bottom: 32px;
}

.level-card {
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
}

.level-card:hover {
  background: var(--surf2);
  border-color: var(--bdr2);
}

.level-card.selected {
  border-color: var(--acc);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.level-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.level-info h3 {
  font-family: var(--fh);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--txt);
  margin-bottom: 4px;
}

.level-info p {
  font-size: 0.75rem;
  color: var(--txt3);
}

.api-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.api-section label {
  font-size: 0.75rem;
  color: var(--txt3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.api-input-row {
  display: flex;
  gap: 8px;
}

#api-key-input {
  width: 280px;
  padding: 10px 14px;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  color: var(--txt);
  font-family: var(--fm);
  font-size: 0.85rem;
}

#api-key-input:focus {
  outline: none;
  border-color: var(--acc);
}

#save-key-btn {
  padding: 10px 16px;
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  color: var(--txt);
  font-family: var(--fm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

#save-key-btn:hover {
  background: var(--surf3);
}

#key-status {
  font-size: 0.75rem;
  min-height: 1em;
}

#key-status.valid {
  color: var(--grn);
}

#key-status.invalid {
  color: var(--red);
}

.launch-btn {
  padding: 16px 48px;
  background: linear-gradient(135deg, var(--acc), #0ea5e9);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-family: var(--fh);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
}

.launch-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.4);
}

.launch-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-note {
  margin-top: 24px;
  font-size: 0.75rem;
  color: var(--txt3);
}

/* Screen 2: Game Screen */
#game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

.hud-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surf);
  border-bottom: 1px solid var(--bdr);
  flex-wrap: wrap;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hud-left {
  flex: 0 1 auto;
}

.hud-center {
  flex: 1 1 220px;
  min-width: 180px;
}

.hud-right {
  flex: 0 0 auto;
}

.hud-logo {
  color: var(--acc);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-level {
  padding: 4px 10px;
  background: var(--surf2);
  border-radius: 4px;
  color: var(--txt2);
  white-space: nowrap;
}

.hud-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 120px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surf2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar.small {
  flex: 1;
  height: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--acc), var(--grn));
  border-radius: 4px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  color: var(--txt2);
  min-width: 36px;
  text-align: right;
}

.hud-score {
  color: var(--gold);
  white-space: nowrap;
}

.hud-q {
  color: var(--txt2);
  white-space: nowrap;
}

.hud-acc {
  color: var(--pur);
  white-space: nowrap;
}

.hud-sections-btn {
  padding: 6px 12px;
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 4px;
  color: var(--txt);
  font-family: var(--fm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.hud-sections-btn:hover {
  background: var(--surf3);
  border-color: var(--bdr2);
}

.game-body {
  display: flex;
  flex: 1;
  overflow: auto;
  gap: 16px;
  padding: 16px;
  flex-direction: row;
  min-height: 0;
  width: 100%;
}

.map-panel {
  flex: 1.7;
  position: relative;
  background: var(--bg);
  min-height: 350px;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 1;
  min-width: 0;
}

.decision-column {
  width: min(380px, 28vw);
  display: flex;
  flex-direction: column;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 18px;
  overflow: auto;
  flex-shrink: 0;
}

.right-panel {
  width: clamp(270px, 28vw, 360px);
  background: var(--surf);
  border-left: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  overflow: auto;
  flex-shrink: 0;
  min-width: 0;
}

#satellite-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.map-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: calc(100% - 24px);
  max-width: 680px;
  padding-right: 12px;
}

.map-scenario-header {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 14px;
  padding: 14px 16px;
}

.map-day-time {
  display: block;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.85);
  margin-bottom: 6px;
}

.map-scenario-title {
  font-family: var(--fh);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #e2e8f0;
}

.map-region-tag {
  font-size: 0.82rem;
  color: var(--acc);
}

.map-label {
  font-size: 0.7rem;
  color: var(--txt3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.map-region {
  font-family: var(--fh);
  font-size: 1rem;
  font-weight: 600;
  color: var(--acc);
}

.band-buttons {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.band-btn {
  padding: 6px 10px;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 4px;
  color: var(--txt2);
  font-family: var(--fm);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.band-btn:hover {
  background: var(--surf2);
}

.band-btn.active {
  background: var(--acc);
  color: var(--bg);
  border-color: var(--acc);
}

.color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.65rem;
  color: var(--txt2);
}

.legend-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.right-panel {
  width: clamp(270px, 28vw, 360px);
  background: var(--surf);
  border-left: 1px solid var(--bdr);
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.scenario-header {
  padding: 16px;
  border-bottom: 1px solid var(--bdr);
}

.briefing-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--grn);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.briefing-label {
  font-size: 0.65rem;
  color: var(--txt3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.briefing-text {
  font-size: 0.85rem;
  color: var(--txt);
  line-height: 1.6;
  max-height: 110px;
  overflow-y: auto;
}

.hint-btn {
  margin-top: 10px;
  padding: 6px 12px;
  background: transparent;
  border: 1px dashed var(--bdr2);
  border-radius: 4px;
  color: var(--txt2);
  font-family: var(--fm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.hint-btn:hover {
  border-color: var(--acc);
  color: var(--acc);
}

.satellite-readings {
  padding: 16px;
  border-bottom: 1px solid var(--bdr);
}

.briefing-box {
  padding: 16px;
  border-bottom: 1px solid var(--bdr);
}

.readings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.data-card {
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  position: relative;
  cursor: help;
}

.data-card:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surf3);
  border: 1px solid var(--bdr2);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.7rem;
  color: var(--txt2);
  white-space: nowrap;
  z-index: 100;
  max-width: 200px;
  white-space: normal;
}

.data-label {
  font-size: 0.65rem;
  color: var(--txt3);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.data-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.progress-readings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-item {
  display: block;
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: var(--txt2);
}

.progress-label {
  font-size: 0.65rem;
  color: var(--txt3);
  min-width: 70px;
}

.progress-value {
  font-size: 0.7rem;
  color: var(--txt2);
  min-width: 55px;
  text-align: right;
}

.decision-panel {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.answer-feedback {
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  color: var(--acc);
  border: 1px solid rgba(56, 189, 248, 0.15);
  font-size: 0.9rem;
  font-weight: 600;
}

.answer-feedback.hidden {
  display: none;
}

.next-btn {
  margin-top: 14px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--acc), #0ea5e9);
  border: none;
  border-radius: 8px;
  color: var(--bg);
  font-family: var(--fm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.2);
}

.next-btn.hidden {
  display: none;
}

.explanation-box {
  margin-top: 16px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--bdr2);
  border-radius: 10px;
}

.explanation-text,
.explanation-ref {
  color: var(--txt2);
}

.explanation-header {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

@media (max-width: 1200px) {
  .game-body {
    flex-direction: column;
    padding: 12px;
    gap: 16px;
  }

  .map-panel {
    width: 100%;
    min-height: 350px;
    flex: auto;
    flex-basis: auto;
  }

  .decision-column {
    width: 100%;
    min-height: auto;
  }

  .right-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--bdr);
    min-height: auto;
    border-radius: 18px;
  }

  .map-overlay {
    max-width: 100%;
    width: calc(100% - 24px);
  }
}

@media (max-width: 900px) {
  .hud-bar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
  }

  .hud-center {
    width: 100%;
    order: 3;
    flex-basis: 100%;
  }

  .hud-left {
    flex: 1;
    min-width: 200px;
  }

  .hud-right {
    order: 2;
    white-space: nowrap;
  }

  .map-scenario-header {
    padding: 12px 14px;
  }

  .decision-panel {
    padding: 16px;
  }

  .briefing-text {
    max-height: 90px;
  }

  .choice-btn {
    padding: 14px;
  }
}

@media (max-width: 680px) {
  .screen {
    padding: 14px;
  }

  #title-screen {
    padding-top: 32px;
  }

  .level-grid {
    grid-template-columns: 1fr;
    max-width: 420px;
  }

  .level-card {
    padding: 16px;
  }

  .launch-btn {
    width: min(100%, 340px);
    padding: 14px 18px;
    font-size: 0.95rem;
  }

  .game-body {
    flex-direction: column;
    padding: 10px;
    gap: 12px;
    height: auto;
  }

  .hud-bar {
    gap: 8px;
    padding: 10px 12px;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .hud-left,
  .hud-right,
  .hud-center {
    width: 100%;
  }

  .hud-left,
  .hud-right {
    justify-content: space-between;
  }

  .hud-logo {
    font-size: 0.82rem;
  }

  .hud-level {
    font-size: 0.75rem;
  }

  .hud-progress,
  .hud-center {
    order: 10;
    width: 100%;
    flex-basis: 100%;
    gap: 6px;
  }

  .progress-bar {
    flex: 1;
    height: 6px;
  }

  .map-panel {
    min-height: 360px;
    max-height: none;
    width: 100%;
    border-radius: 12px;
  }

  .map-overlay {
    top: 8px;
    left: 8px;
    gap: 10px;
    width: calc(100% - 16px);
    max-width: 100%;
  }

  .map-scenario-header {
    padding: 10px 12px;
    max-width: 100%;
  }

  .map-scenario-title {
    font-size: 1rem;
  }

  .map-day-time {
    font-size: 0.7rem;
  }

  .band-buttons {
    gap: 3px;
  }

  .band-btn {
    flex: 1 1 76px;
    padding: 5px 8px;
    font-size: 0.65rem;
  }

  .color-legend {
    font-size: 0.6rem;
    gap: 8px;
    padding: 6px 8px;
    width: fit-content;
    max-width: 100%;
    background: rgba(15, 23, 42, 0.72);
    border-radius: 8px;
  }

  .decision-column {
    width: 100%;
    min-height: auto;
    border-radius: 12px;
  }

  .decision-panel {
    padding: 14px;
    gap: 12px;
  }

  .decision-label {
    font-size: 0.65rem;
  }

  .question-text {
    font-size: 0.85rem;
    margin-bottom: 12px;
  }

  .choices-container {
    gap: 8px;
  }

  .choice-btn {
    padding: 12px;
    gap: 10px;
  }

  .choice-text {
    font-size: 0.8rem;
  }

  .next-btn,
  .skip-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .explanation-box {
    padding: 12px;
    margin-top: 12px;
  }

  .explanation-header {
    font-size: 0.85rem;
  }

  .explanation-text,
  .explanation-ref {
    font-size: 0.8rem;
  }

  .right-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--bdr);
    min-height: auto;
    border-radius: 12px;
  }

  .briefing-box {
    padding: 12px;
    border-bottom: 1px solid var(--bdr);
  }

  .briefing-text {
    font-size: 0.8rem;
    max-height: 80px;
  }

  .hint-btn {
    padding: 5px 10px;
    font-size: 0.7rem;
    margin-top: 8px;
  }

  .satellite-readings {
    padding: 12px;
  }

  .readings-grid {
    gap: 6px;
    margin-bottom: 10px;
  }

  .data-card {
    padding: 8px;
  }

  .data-label {
    font-size: 0.6rem;
  }

  .data-value {
    font-size: 1rem;
  }

  .progress-readings {
    gap: 8px;
  }

  .modal-content {
    padding: 20px;
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .game-body {
    padding: 8px;
    gap: 10px;
  }

  .hud-bar {
    padding: 8px 10px;
  }

  .map-panel {
    min-height: 390px;
  }

  .map-overlay {
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
  }

  .decision-panel {
    padding: 12px;
    gap: 10px;
  }

  .question-text {
    font-size: 0.8rem;
  }

  .choice-btn {
    align-items: flex-start;
    padding: 10px;
    font-size: 0.8rem;
    gap: 8px;
  }

  .choice-tag {
    min-width: 42px;
    font-size: 0.58rem;
  }

  .next-btn,
  .skip-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .logo {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    letter-spacing: 0.04em;
  }

  .tagline {
    font-size: 0.75rem;
  }

  .readings-grid {
    grid-template-columns: 1fr;
  }

  .debrief-buttons {
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  .screen {
    padding: 10px;
  }

  .game-body {
    padding: 6px;
  }

  .map-panel {
    min-height: 420px;
  }

  .map-scenario-title {
    font-size: 0.9rem;
  }

  .band-btn {
    flex-basis: 100%;
  }

  .hud-logo {
    max-width: 100%;
  }
}


.decision-label {
  font-size: 0.7rem;
  color: var(--org);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.question-text {
  font-size: 0.9rem;
  color: var(--txt);
  margin-bottom: 16px;
  line-height: 1.5;
}

.choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95), rgba(17, 24, 39, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  text-align: left;
  color: #f8fafc;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
  width: 100%;
  min-width: 0;
}

.choice-btn:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(56, 189, 248, 0.25);
  transform: translateY(-1px);
}

.choice-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.choice-btn.correct {
  border-color: var(--grn);
  background: rgba(52, 211, 153, 0.1);
}

.choice-btn.wrong {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

.choice-tag {
  font-size: 0.65rem;
  color: var(--acc);
  text-transform: uppercase;
  min-width: 50px;
}

.choice-text {
  flex: 1;
  font-size: 0.85rem;
  color: #f8fafc;
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: anywhere;
}

.risk-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}

.risk-badge.low {
  background: rgba(52, 211, 153, 0.2);
  color: var(--grn);
}

.risk-badge.medium {
  background: rgba(251, 191, 36, 0.2);
  color: var(--gold);
}

.risk-badge.high {
  background: rgba(248, 113, 113, 0.2);
  color: var(--red);
}

.skip-btn {
  margin-top: 16px;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--bdr);
  border-radius: 6px;
  color: var(--txt3);
  font-family: var(--fm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.skip-btn:hover {
  border-color: var(--bdr2);
  color: var(--txt2);
}

.skip-btn.hidden {
  display: none;
}

.explanation-box {
  margin-top: 16px;
  padding: 16px;
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 6px;
}

.explanation-header {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.explanation-header.correct {
  color: var(--grn);
}

.explanation-header.wrong {
  color: var(--red);
}

.explanation-text {
  font-size: 0.8rem;
  color: var(--txt2);
  line-height: 1.6;
  margin-bottom: 8px;
}

.explanation-ref {
  font-size: 0.7rem;
  color: var(--txt3);
  font-style: italic;
}

.next-btn {
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--acc);
  border: none;
  border-radius: 6px;
  color: var(--bg);
  font-family: var(--fm);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.next-btn:hover {
  background: #0ea5e9;
}

/* Screen 3: Section Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 26, 0.85);
}

.modal-content {
  position: relative;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-family: var(--fh);
  font-size: 1.3rem;
  color: var(--txt);
  margin-bottom: 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--txt3);
  font-size: 1.2rem;
  cursor: pointer;
}

.section-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-card {
  padding: 14px;
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.section-card:hover {
  background: var(--surf3);
  border-color: var(--bdr2);
}

.section-card.current {
  border-color: var(--acc);
}

.section-card-header {
  font-size: 0.85rem;
  color: var(--txt);
  font-weight: 600;
}

.section-card-status {
  font-size: 0.75rem;
  color: var(--txt2);
  margin-top: 4px;
}

/* Screen 4: Debrief */
#debrief-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
}

.debrief-content {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.debrief-title {
  font-family: var(--fh);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 32px;
}

.score-ring-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 24px;
}

.score-ring {
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surf2);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s ease;
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--fh);
  font-size: 2rem;
  font-weight: 700;
  color: var(--txt);
}

.accuracy-summary {
  font-size: 1rem;
  color: var(--txt2);
  margin-bottom: 32px;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 32px;
  text-align: left;
}

.history-card {
  padding: 8px;
  background: var(--surf);
  border: 1px solid var(--bdr);
  border-radius: 4px;
}

.history-q {
  font-size: 0.7rem;
  color: var(--txt3);
}

.history-title {
  font-size: 0.65rem;
  color: var(--txt2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 4px 0;
}

.history-points {
  font-size: 0.7rem;
  font-weight: 700;
}

.history-points.correct {
  color: var(--grn);
}

.history-points.wrong {
  color: var(--red);
}

.debrief-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.debrief-btn {
  padding: 12px 24px;
  background: var(--surf2);
  border: 1px solid var(--bdr);
  border-radius: 6px;
  color: var(--txt);
  font-family: var(--fm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.debrief-btn:hover {
  background: var(--surf3);
  border-color: var(--bdr2);
}

.credits {
  font-size: 0.7rem;
  color: var(--txt3);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surf);
}

::-webkit-scrollbar-thumb {
  background: var(--surf3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bdr2);
}

@media (max-width: 680px) {
  .decision-label {
    font-size: 0.65rem;
    margin-bottom: 8px;
  }

  .question-text {
    font-size: 0.85rem;
    margin-bottom: 12px;
  }

  .choices-container {
    gap: 8px;
  }

  .choice-btn {
    padding: 12px;
    gap: 10px;
  }

  .choice-text {
    font-size: 0.8rem;
  }

  .next-btn,
  .skip-btn {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  .explanation-box {
    padding: 12px;
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  .choice-btn {
    gap: 8px;
    padding: 10px;
  }

  .choice-tag {
    min-width: 42px;
    font-size: 0.58rem;
  }

  .question-text {
    font-size: 0.8rem;
  }

  .next-btn,
  .skip-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .debrief-buttons {
    flex-direction: column;
  }

  .debrief-btn {
    width: 100%;
  }
}
