:root {
  color-scheme: light;
  --ink: #1f2a37;
  --muted: #64748b;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: #d8dee9;
  --teal: #3cb6a3;
  --teal-dark: #2f6f64;
  --coral: #ff6b5f;
  --yellow: #ffd166;
  --violet: #7768d8;
  --sky: #7bdff2;
  --shadow: 0 20px 55px rgba(36, 44, 58, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "Nunito", "Arial", sans-serif;
  background:
    linear-gradient(120deg, rgba(123, 223, 242, 0.32), rgba(255, 209, 102, 0.24)),
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(119, 104, 216, 0.44);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.mission-panel,
.play-panel {
  border: 1px solid rgba(31, 42, 55, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.mission-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  overflow: hidden;
}

.play-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: #172033;
}

.logo-mark svg {
  width: 42px;
  height: 42px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.1;
}

.pilot-scene {
  position: relative;
  min-height: 238px;
  border: 1px solid rgba(31, 42, 55, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(160deg, #172033 0%, #263a5c 58%, #244f61 100%);
  overflow: hidden;
}

.pilot-scene::before {
  position: absolute;
  inset: 14px;
  content: "";
  background-image:
    radial-gradient(circle at 18px 28px, #fffaf0 0 2px, transparent 3px),
    radial-gradient(circle at 120px 52px, #ffd166 0 2px, transparent 3px),
    radial-gradient(circle at 240px 38px, #fffaf0 0 1px, transparent 2px),
    radial-gradient(circle at 190px 142px, #7bdff2 0 2px, transparent 3px);
  opacity: 0.85;
}

.rocket {
  position: absolute;
  right: 54px;
  bottom: 12px;
  width: 128px;
  transform-origin: 50% 90%;
  animation: floatRocket 4s ease-in-out infinite;
}

.rocket svg {
  display: block;
  width: 100%;
}

.planet {
  position: absolute;
  border-radius: 50%;
}

.planet-one {
  left: 25px;
  top: 42px;
  width: 66px;
  height: 66px;
  background:
    linear-gradient(140deg, #ffd166, #ff9f1c);
}

.planet-two {
  right: 24px;
  top: 24px;
  width: 34px;
  height: 34px;
  background:
    linear-gradient(140deg, #7bdff2, #3cb6a3);
}

.star {
  position: absolute;
  width: 26px;
  height: 26px;
  background: var(--yellow);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 35%);
}

.star-one {
  left: 112px;
  bottom: 55px;
}

.star-two {
  right: 152px;
  top: 38px;
  width: 18px;
  height: 18px;
  background: var(--sky);
}

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

.stat-block {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat-block span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-block strong {
  display: block;
  margin-top: 2px;
  font-size: 1.45rem;
}

.trail {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.trail-step {
  position: relative;
  height: 22px;
  border-radius: 8px;
  background: #e8edf3;
  overflow: hidden;
}

.trail-step::after {
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  background: #cfd7e3;
  content: "";
}

.trail-step.is-done {
  background: rgba(255, 209, 102, 0.42);
}

.trail-step.is-done::after {
  background: var(--yellow);
}

.small-actions,
.bottom-bar,
.top-controls,
.dialog-actions,
.dialog-header {
  display: flex;
  align-items: center;
}

.small-actions {
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--ink);
  background: #eef7f6;
}

.icon-button svg,
.secondary-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.text-button,
.secondary-button,
.primary-button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
}

.text-button {
  padding: 0 14px;
  color: var(--teal-dark);
  background: #eef7f6;
}

.top-controls {
  justify-content: space-between;
  gap: 16px;
}

.control-group,
.level-switch {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.control-group {
  flex-wrap: wrap;
}

.mode-button,
.level-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.mode-button {
  min-width: 116px;
  padding: 0 12px;
}

.level-button {
  min-width: 78px;
  padding: 0 10px;
}

.mode-button.is-active,
.level-button.is-active {
  color: #fff;
  border-color: transparent;
  background: var(--violet);
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--yellow);
  font-weight: 900;
}

.question-wrap {
  display: grid;
  grid-template-rows: auto minmax(110px, 170px) auto auto auto;
  gap: 16px;
  min-height: 560px;
  padding: 28px;
  border: 1px solid rgba(31, 42, 55, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 250, 240, 0.9));
}

.mission-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.question-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 110px;
}

.visual-group {
  display: grid;
  grid-template-columns: repeat(5, 26px);
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.token {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--teal);
  box-shadow: inset 0 -4px 0 rgba(31, 42, 55, 0.12);
}

.token:nth-child(3n) {
  background: var(--coral);
}

.token:nth-child(4n) {
  background: var(--yellow);
}

.visual-sign {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  color: #fff;
  background: var(--violet);
  font-size: 2rem;
  font-weight: 900;
}

.question-text {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  color: var(--ink);
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
}

.feedback {
  min-height: 30px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
}

.feedback.is-good {
  color: var(--teal-dark);
}

.feedback.is-try {
  color: #9b4c2f;
}

.answers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.question-wrap.is-result {
  grid-template-rows: auto 1fr;
}

.question-wrap.is-result .question-visual,
.question-wrap.is-result .question-text,
.question-wrap.is-result .feedback {
  display: none;
}

.answers.is-result {
  grid-template-columns: 1fr;
}

.answer-button {
  min-height: 86px;
  border: 2px solid rgba(31, 42, 55, 0.08);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(31, 42, 55, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.answer-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 0 rgba(31, 42, 55, 0.08);
}

.answer-button.is-correct {
  color: #12332f;
  border-color: var(--teal);
  background: rgba(60, 182, 163, 0.22);
}

.answer-button.is-wrong {
  color: #58221d;
  border-color: var(--coral);
  background: rgba(255, 107, 95, 0.18);
}

.bottom-bar {
  justify-content: space-between;
  gap: 12px;
}

.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
}

.secondary-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.primary-button {
  color: #fff;
  background: var(--teal-dark);
}

.score-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.score-line span:first-child {
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
}

.grownup-dialog {
  width: min(520px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.grownup-dialog::backdrop {
  background: rgba(31, 42, 55, 0.38);
}

.grownup-dialog form {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.dialog-header {
  justify-content: space-between;
  gap: 12px;
}

.dialog-header h2 {
  margin: 0;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.setting-row input[type="number"] {
  width: 86px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.setting-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--teal-dark);
}

.dialog-actions {
  justify-content: space-between;
  gap: 12px;
}

.result-screen {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 520px;
  text-align: center;
}

.result-badge {
  width: 104px;
  height: 104px;
}

.result-badge svg {
  width: 100%;
  height: 100%;
}

.result-screen h2 {
  margin: 0;
  font-size: 2.2rem;
}

.result-screen p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
}

@keyframes floatRocket {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-10px) rotate(3deg);
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mission-panel {
    min-height: auto;
  }

  .pilot-scene {
    display: none;
  }

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

  .level-switch {
    flex-wrap: wrap;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin: 10px auto;
  }

  .mission-panel,
  .play-panel {
    padding: 14px;
  }

  .brand-row {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.32rem;
  }

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

  .control-group,
  .level-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-button,
  .level-button {
    min-width: 0;
    width: 100%;
  }

  .question-wrap {
    min-height: 520px;
    padding: 16px;
    grid-template-rows: auto minmax(86px, 120px) auto auto auto;
  }

  .question-visual {
    gap: 8px;
  }

  .visual-group {
    grid-template-columns: repeat(4, 18px);
    gap: 6px;
    padding: 10px;
  }

  .token {
    width: 18px;
    height: 18px;
  }

  .visual-sign {
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
  }

  .question-text {
    min-height: 72px;
    font-size: 2.25rem;
  }

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

  .answer-button {
    min-height: 74px;
    font-size: 1.65rem;
  }

  .bottom-bar,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .score-line {
    justify-content: center;
  }
}
