:root {
  --bg-top: #113c70;
  --bg-bottom: #081d38;
  --panel: rgba(9, 22, 46, 0.84);
  --panel-border: rgba(255, 255, 255, 0.11);
  --text-main: #f5f8ff;
  --text-soft: #c7d9ff;
  --accent-yellow: #ffd84f;
  --accent-coral: #ff7a59;
  --accent-sky: #4fd1ff;
  --accent-mint: #6fe6ae;
  --maze-wall: #1b4fff;
  --maze-floor: #081528;
  --danger: #ff5f76;
  --success: #73f2a4;
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.3);
}

body[data-theme="light"] {
  --bg-top: #dff3ff;
  --bg-bottom: #f9fbff;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(17, 60, 112, 0.14);
  --text-main: #153156;
  --text-soft: #4e678a;
  --accent-yellow: #ffbe2f;
  --accent-coral: #f46a4f;
  --accent-sky: #2ea7dc;
  --accent-mint: #40b787;
  --shadow: 0 18px 42px rgba(33, 76, 134, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(79, 209, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 216, 79, 0.24), transparent 18%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 36px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-yellow);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: "Marker Felt", "Trebuchet MS", sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 4.6rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 720px;
  line-height: 1.6;
  color: var(--text-soft);
  font-size: 1.02rem;
  margin: 14px 0 0;
}

.hero-card {
  display: grid;
  gap: 10px;
  min-width: 250px;
}

.hero-chip {
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  font-weight: 700;
  text-align: center;
}

.toolbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 22px;
}

.toggle-card {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  width: min(100%, 720px);
}

.toggle-copy {
  display: grid;
  gap: 5px;
}

.toggle-copy small {
  color: var(--text-soft);
}

.toggle {
  position: relative;
  width: 72px;
  height: 40px;
  flex: 0 0 auto;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  transition: 180ms ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  left: 6px;
  top: 6px;
  border-radius: 50%;
  background: #fff;
  transition: 180ms ease;
}

.toggle input:checked + .slider {
  background: linear-gradient(90deg, var(--accent-mint), var(--accent-sky));
}

.toggle input:checked + .slider::before {
  transform: translateX(32px);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: end;
  align-items: center;
}

.speed-card {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
  min-width: 150px;
}

.speed-card select {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(6, 17, 32, 0.9);
  color: var(--text-main);
}

.primary-button,
.secondary-button,
.choice-button,
.level-button,
.control-button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.choice-button:hover,
.level-button:hover,
.control-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.choice-button:active,
.level-button:active,
.control-button:active {
  transform: translateY(1px);
}

.primary-button {
  padding: 13px 20px;
  background: linear-gradient(135deg, var(--accent-yellow), #ffb347);
  color: #222133;
  font-weight: 800;
}

.secondary-button {
  padding: 13px 20px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 290px minmax(420px, 1fr) 320px;
  gap: 22px;
}

.panel {
  padding: 20px;
}

.panel-header {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.panel-header p {
  margin: 0;
  color: var(--text-soft);
}

.level-road {
  display: grid;
  gap: 10px;
}

.level-button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
}

.level-button small {
  display: block;
  margin-top: 2px;
  color: var(--text-soft);
}

.level-button.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-button.current {
  outline: 2px solid var(--accent-yellow);
  background: rgba(255, 216, 79, 0.12);
}

.level-button.complete {
  background: rgba(111, 230, 174, 0.18);
}

.difficulty-card,
.tip-card,
.status-card {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 18px;
}

.difficulty-card {
  margin-top: 16px;
  line-height: 1.55;
}

.board-panel {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 18px;
}

.board-wrap {
  position: relative;
  padding: 14px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    linear-gradient(180deg, rgba(4, 12, 26, 0.95), rgba(7, 20, 43, 0.98));
}

canvas {
  width: min(100%, 525px);
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: #071222;
}

.banner {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  min-width: 220px;
  max-width: calc(100% - 30px);
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--text-main);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.banner.visible {
  opacity: 1;
}

.control-pad {
  display: grid;
  gap: 10px;
  justify-items: center;
}

.control-row {
  display: flex;
  gap: 10px;
}

.control-button {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 1.4rem;
  font-weight: 800;
}

.learn-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

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

.score-box {
  border-radius: 18px;
  padding: 14px 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

.score-label {
  display: block;
  color: var(--text-soft);
  margin-bottom: 4px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.power-label,
.parent-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(79, 209, 255, 0.18);
}

.hearts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.heart {
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(255, 76, 107, 0.28));
}

.heart.empty {
  opacity: 0.28;
  filter: none;
}

.question-tracker,
.answer-key {
  display: grid;
  gap: 10px;
}

.question-card,
.answer-card {
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
}

.question-card strong,
.answer-card strong {
  display: block;
  margin-bottom: 4px;
}

.question-card.pending {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.question-card.done {
  border: 1px solid rgba(111, 230, 174, 0.5);
}

.question-card.missed {
  border: 1px solid rgba(255, 95, 118, 0.5);
}

.question-card small,
.answer-card small,
.tip-card p {
  color: var(--text-soft);
}

.tip-card h3 {
  margin-bottom: 8px;
}

.tip-card p {
  margin: 8px 0 0;
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.modal.hidden,
.hidden {
  display: none !important;
}

.modal-card {
  width: min(640px, 100%);
  background: linear-gradient(180deg, rgba(13, 31, 61, 0.98), rgba(9, 22, 46, 0.98));
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 26px;
  box-shadow: var(--shadow);
}

.modal-topper {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 216, 79, 0.18);
  color: var(--accent-yellow);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.modal-card h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  margin-bottom: 10px;
}

.modal-card p {
  margin: 0;
  line-height: 1.65;
  color: var(--text-soft);
}

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

.choice-button {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

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

  .hero,
  .toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .hero-card,
  .toolbar-actions {
    justify-content: stretch;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 18px, 1000px);
    margin: 14px auto 26px;
  }

  .toolbar,
  .panel {
    border-radius: 20px;
  }

  .score-strip {
    grid-template-columns: 1fr;
  }

  .control-button {
    width: 56px;
    height: 56px;
  }
}
