:root {
  color-scheme: dark;
  --bg: #111;
  --panel: #17191b;
  --panel-strong: #202327;
  --text: #eeeeee;
  --muted: #a8adb4;
  --line: #2d3237;
  --accent: #35c2b4;
  --accent-strong: #49dbc9;
  --gold: #d9a441;
  --rose: #e06471;
  --shadow: rgba(0, 0, 0, 0.28);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f1e8;
  --panel: #fffaf0;
  --panel-strong: #ebe4d6;
  --text: #242321;
  --muted: #706a61;
  --line: #d6cbbb;
  --accent: #168f87;
  --accent-strong: #0f716a;
  --gold: #a56b10;
  --rose: #b84c5d;
  --shadow: rgba(55, 38, 17, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(53, 194, 180, 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
}

button,
a {
  color: inherit;
}

button {
  font: inherit;
}

.app-shell {
  width: min(920px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 24px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 6.2vw, 3.6rem);
  line-height: 0.96;
  font-weight: 500;
}

.theme-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.progress-strip {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 5px;
}

.progress-cell {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
}

.progress-cell.is-seen {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  color: var(--accent);
}

.progress-cell.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #071715;
  font-weight: 800;
}

.quiz-stage {
  position: relative;
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 420px;
}

.meta-row {
  color: var(--muted);
  font-size: 0.92rem;
}

.hand-frame {
  position: relative;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 54px var(--shadow);
  overflow: hidden;
}

.hand-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  background: #fff;
}

.quiz-stage.is-loading .hand-frame {
  aspect-ratio: 1040 / 248;
}

.quiz-stage.is-loading .hand-frame::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 4px;
  background:
    linear-gradient(
      105deg,
      color-mix(in srgb, var(--panel-strong) 72%, #fff) 0%,
      color-mix(in srgb, var(--accent) 18%, #fff) 42%,
      color-mix(in srgb, var(--panel-strong) 72%, #fff) 76%
    );
  background-size: 220% 100%;
  animation: shimmer 1.15s ease-in-out infinite;
}

.quiz-stage.is-loading .hand-frame img {
  opacity: 0;
  visibility: hidden;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--panel-strong);
  border-color: var(--accent);
  color: var(--text);
}

.question-panel {
  min-height: 92px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.question-text {
  margin: 0;
  font-size: clamp(1.26rem, 3.2vw, 2rem);
  line-height: 1.42;
  font-weight: 650;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.choice-tile {
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.35;
}

.choice-tile.is-answer {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent-strong);
  font-weight: 700;
}

.answer-panel {
  border-left: 4px solid var(--accent);
  padding: 14px 0 14px 18px;
}

.answer-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.answer-text {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3.1rem);
  line-height: 1;
  font-weight: 800;
}

.answer-summary,
.answer-note {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.answer-note {
  color: var(--gold);
}

.stage-loader {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  min-height: 100%;
  padding: 28px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(3px);
}

.quiz-stage.is-loading .stage-loader {
  display: grid;
  animation: loader-fade 0.16s ease-out;
}

.quiz-stage.is-loading .controls,
.quiz-stage.is-loading .mode-tabs,
.quiz-stage.is-loading .question-panel,
.quiz-stage.is-loading .answer-panel {
  opacity: 0.22;
}

.loader-card {
  min-width: min(260px, 82vw);
  padding: 22px 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, #000);
  box-shadow: 0 22px 60px var(--shadow);
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
}

.loader-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font-size: 1.9rem;
  animation: tile-pulse 1s ease-in-out infinite;
}

.loading-bar {
  width: 168px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.loading-bar::after {
  content: '';
  display: block;
  width: 46%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loading-scan 1s ease-in-out infinite;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 10px;
}

.nav-button,
.reveal-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.nav-button:hover,
.reveal-button:hover {
  border-color: var(--accent);
}

.reveal-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #061816;
  font-weight: 800;
}

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

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }

  to {
    background-position: -120% 0;
  }
}

@keyframes loader-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes tile-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

@keyframes loading-scan {
  0% {
    transform: translateX(-110%);
  }

  100% {
    transform: translateX(230%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-stage.is-loading .hand-frame::before,
  .loader-mark,
  .loading-bar::after,
  .quiz-stage.is-loading .stage-loader {
    animation: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 920px);
    padding-top: 18px;
    gap: 14px;
  }

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

  .progress-cell {
    font-size: 0.68rem;
  }

  .hand-frame {
    padding: 7px;
  }

  .question-panel {
    min-height: 120px;
  }

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

  .reveal-button {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

@media (max-width: 420px) {
  .topbar {
    align-items: center;
  }

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

  .nav-button,
  .reveal-button,
  .tab {
    min-height: 46px;
  }
}
