:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #5e6d68;
  --line: #d8e1dd;
  --paper: #f7faf8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #075e59;
  --gold: #b88718;
  --red: #b42318;
  --blue: #2763b6;
  --lav: #6750a4;
  --shadow: 0 18px 50px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--accent-dark);
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.topbar h1,
.panel h2,
.question-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.95;
}

.topline {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

select,
input[type="date"],
input[type="number"],
input[type="search"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  padding: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  background: rgba(247, 250, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.tab {
  flex: 1 0 auto;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
}

.tab.active {
  background: var(--ink);
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel + .panel,
.focus-grid,
.skills-layout {
  margin-top: 16px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.dashboard-grid,
.skills-layout,
.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.command-panel {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 0.8fr);
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.hud-grid,
.mission-stats,
.badge-list {
  display: grid;
  gap: 10px;
}

.hud-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.hud-grid div,
.mission-card,
.badge,
.scenario-card,
.skill-score {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.hud-grid div {
  min-width: 0;
  padding: 12px;
}

.hud-grid strong {
  display: block;
  font-size: 1.25rem;
}

.hud-grid span,
.mission-card span,
.badge span,
.skill-score span {
  color: var(--muted);
  font-size: 0.84rem;
}

.game-grid {
  margin-bottom: 16px;
}

.unit-map {
  width: 100%;
  min-height: 250px;
  margin-top: 4px;
}

.unit-map text {
  fill: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.map-floor {
  fill: #f1f6f3;
  stroke: var(--line);
  stroke-width: 3;
}

.map-room {
  fill: #ffffff;
  stroke: #a9bbb5;
  stroke-width: 2;
}

.map-room-blue {
  fill: #edf4ff;
}

.map-room-gold {
  fill: #fff8e6;
}

.map-path {
  fill: none;
  stroke: #92a7a0;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 10 10;
}

.map-player {
  fill: var(--accent);
  stroke: white;
  stroke-width: 6;
}

.map-player-text {
  fill: white !important;
  font-size: 14px !important;
}

.mission-list {
  display: grid;
  gap: 10px;
}

.mission-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.mission-card strong,
.badge strong {
  display: block;
}

.mission-card p {
  margin: 4px 0 0;
}

.mission-card.complete {
  border-color: rgba(15, 118, 110, 0.4);
  background: #edf9f5;
}

.mission-card button {
  white-space: nowrap;
}

.badge-panel {
  margin-top: 16px;
}

.badge-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.badge {
  padding: 12px;
}

.badge.locked {
  opacity: 0.5;
}

.badge strong::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.badge.locked strong::before {
  background: #bcc9c4;
}

.score-ring {
  --score: 0%;
  display: grid;
  width: 104px;
  height: 104px;
  flex: 0 0 104px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--score), #e8efec 0);
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: white;
}

.score-ring span {
  position: relative;
  z-index: 1;
  font-weight: 900;
}

.stat-grid,
.exam-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.exam-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-grid div,
.exam-facts div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.stat-grid strong,
.exam-facts strong {
  display: block;
  font-size: 1.35rem;
}

.stat-grid span,
.exam-facts span {
  color: var(--muted);
  font-size: 0.86rem;
}

.primary,
.ghost {
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.blueprint-list {
  display: grid;
  gap: 10px;
}

.blueprint-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.9fr) minmax(160px, 2fr) 54px;
  align-items: center;
  gap: 12px;
}

.blueprint-label {
  min-width: 0;
}

.blueprint-label strong {
  display: block;
}

.blueprint-label span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9efed;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--width);
  border-radius: inherit;
  background: var(--accent);
}

.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.focus-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.focus-card h3 {
  margin: 0 0 8px;
}

.focus-card p {
  min-height: 48px;
}

.practice-builder {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr) minmax(180px, 0.45fr);
  gap: 18px;
  align-items: end;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  min-height: 108px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.mode-card strong,
.mode-card span {
  display: block;
}

.mode-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-card:hover {
  border-color: var(--accent);
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.toggle-row {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.quiz-topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.timer {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-weight: 900;
}

.progress-track {
  height: 10px;
  margin: 16px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efec;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 160ms ease;
}

.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 18px;
}

.domain-chip {
  display: inline-flex;
  margin: 0 0 12px;
  border-radius: 999px;
  background: #e6f3f1;
  color: var(--accent-dark);
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.answers {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.answer-button {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
}

.answer-button:disabled,
.scenario-option:disabled {
  cursor: default;
  opacity: 1;
}

.answer-button strong {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
  background: #eef3f1;
}

.answer-button.correct {
  border-color: var(--accent);
  background: #edf9f5;
}

.answer-button.incorrect {
  border-color: var(--red);
  background: #fff1f0;
}

.explanation {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.results-panel h2 {
  margin-top: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.result-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.scenario-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: start;
}

.safety-meter {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8efec;
}

.safety-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.scenario-card {
  margin-top: 16px;
  padding: 18px;
}

.scenario-card h3 {
  margin: 0 0 10px;
}

.scenario-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.scenario-option {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 64px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
}

.scenario-option strong {
  color: var(--ink);
}

.scenario-option.correct {
  border-color: var(--accent);
  background: #edf9f5;
}

.scenario-option.incorrect {
  border-color: var(--red);
  background: #fff1f0;
}

.scenario-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.skill-draw-list,
.skill-card-grid,
.source-list,
.plan-breakdown {
  display: grid;
  gap: 12px;
}

.skill-draw-list {
  margin: 16px 0;
}

.draw-item,
.source-item,
.plan-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
}

.draw-item strong,
.source-item strong {
  display: block;
}

.skill-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.skill-timer strong {
  font-size: 2rem;
}

.sequence-visual {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0;
}

.sequence-visual span {
  min-height: 72px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.13), rgba(39, 99, 182, 0.1)),
    white;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  padding: 8px;
}

.skill-card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.skill-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 14px;
}

.skill-card.mastered {
  border-color: rgba(15, 118, 110, 0.45);
  background: #edf9f5;
}

.skill-card h3 {
  margin: 0 0 8px;
}

.skill-card ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.critical {
  color: var(--red);
  font-weight: 900;
}

.skill-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
}

.planner {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 18px;
}

.planner-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

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

.plan-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.plan-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.plan-summary strong {
  display: block;
  font-size: 1.3rem;
}

.source-item p {
  margin: 6px 0 0;
}

@media (max-width: 940px) {
  .dashboard-grid,
  .skills-layout,
  .practice-builder,
  .planner,
  .command-panel,
  .game-grid,
  .scenario-shell {
    grid-template-columns: 1fr;
  }

  .focus-grid,
  .skill-card-grid,
  .badge-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-grid,
  .plan-summary,
  .planner-controls,
  .hud-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel {
    padding: 16px;
  }

  .panel-heading,
  .quiz-topline,
  .skill-timer {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-grid,
  .exam-facts,
  .focus-grid,
  .skill-card-grid,
  .result-grid,
  .sequence-visual,
  .badge-list {
    grid-template-columns: 1fr;
  }

  .blueprint-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .mission-card,
  .scenario-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}
