:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --green: #10b981;
  --mint: #6ee7b7;
  --amber: #f59e0b;
  --red: #ef4444;
  --text: #f8fafc;
  --muted: #94a3b8;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
  background: #0a1020;
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--mint); }
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 4px;
}
h1, h2, h3, p { margin: 0; }
h1[tabindex="-1"]:focus, #answer-result:focus { outline: none; }

.shell {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  border-inline: 1px solid #1e2b3f;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: calc(10px + env(safe-area-inset-top)) 20px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-row, .stats, .level-row, .map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 1.32rem;
  font-weight: 800;
  letter-spacing: -.055em;
  text-decoration: none;
}
.brand-accent { color: var(--mint); }
.icon-button {
  display: grid;
  width: 44px;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #182235;
  color: var(--text);
}
.icon-button svg, .streak svg, .phase-icon svg, .phase-end svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stats { gap: 12px; margin-top: 9px; }
.level { flex: 1; min-width: 0; }
.level-row { gap: 8px; font-size: .78rem; }
.level-row strong { color: #fcd78a; }
.level-row span { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  appearance: none;
  overflow: hidden;
  border: 0;
  border-radius: 30px;
  background: var(--border);
}
progress::-webkit-progress-bar { background: var(--border); border-radius: 30px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 30px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 30px; }
.streak {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border: 1px solid #694819;
  border-radius: 10px;
  color: #fcd78a;
  background: #332719;
  font-size: .85rem;
  font-weight: 750;
}
.streak svg { width: 15px; height: 15px; color: var(--amber); }
main { padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); }
.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  min-height: 189px;
  overflow: hidden;
  padding: 21px 18px;
  border: 1px solid #285449;
  border-radius: 20px;
  background: linear-gradient(115deg, #12272f 18%, #153730);
}
.hero h1 {
  font-size: clamp(1.78rem, 6.7vw, 2.27rem);
  font-weight: 820;
  line-height: 1.07;
  letter-spacing: -.063em;
}
.hero h1 em { color: var(--mint); font-style: normal; }
.hero p { max-width: 185px; margin-top: 12px; color: #c0d0d4; font-size: .84rem; }
.hero-art {
  position: absolute;
  z-index: -1;
  right: -7px;
  bottom: -10px;
  width: 174px;
  color: #6ee7b7;
  opacity: .32;
}
.trails { margin-top: 22px; }
.trails h2 { font-size: 1.12rem; letter-spacing: -.025em; }
.track-label { display: block; margin-top: 7px; color: var(--muted); font-size: .76rem; }
.track-select {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid #2b6f59;
  border-radius: 12px;
  background: #143329;
  color: var(--mint);
  font: 650 .88rem/1.3 system-ui, sans-serif;
}
.track-select:focus-visible { outline: 2px solid var(--mint); outline-offset: 4px; }
.map-heading { gap: 8px; margin: 23px 0 9px; }
.map-heading h3 { font-size: .99rem; }
.map-heading span, #load-status { color: var(--muted); font-size: .82rem; }
.phase-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.phase {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 73px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
}
.phase:not(:disabled) { border-color: #326354; }
.phase:disabled { background: #172133; color: #c1cada; }
.phase-icon, .phase-end {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #253249;
  color: var(--muted);
}
.phase:not(:disabled) .phase-icon { color: var(--mint); background: #173a32; }
.phase-end { width: 30px; height: 34px; background: transparent; }
.phase:not(:disabled) .phase-end { color: var(--mint); }
.phase strong, .phase small { display: block; }
.phase strong { font-size: .91rem; }
.phase small { margin-top: 3px; color: var(--muted); font-size: .76rem; }
.phase .stars { color: #fcd78a; letter-spacing: .08em; }
.review-button {
  width: 100%;
  min-height: 49px;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid #725025;
  border-radius: 12px;
  color: #fcd78a;
  background: #34271b;
  font-weight: 720;
}
.site-footer { margin-top: 22px; padding-top: 4px; border-top: 1px solid var(--border); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 23px; }
.site-footer a { display: grid; align-items: center; min-height: 44px; color: var(--muted); font-size: .78rem; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.round-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.round-top > span { font-size: .86rem; font-weight: 700; }
.text-button {
  justify-self: start;
  min-height: 44px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.combo { justify-self: end; color: #fcd78a; }
.question-card, .result-card, .feedback, .promo, .legal-card {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.question-card { margin-top: 15px; }
.question-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
#question-reference { color: var(--muted); font-size: .74rem; }
.question-card h1 { margin-top: 11px; font-size: clamp(1.14rem, 4.8vw, 1.42rem); line-height: 1.28; letter-spacing: -.025em; }
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 7px;
  background: #153b31;
  color: var(--mint);
  font-size: .7rem;
  font-weight: 730;
}
.options { display: grid; gap: 8px; margin-top: 15px; }
.option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid #475569;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  font-size: .9rem;
}
.option span:first-child {
  display: grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: #26334a;
  font-weight: 700;
}
.option .option-mark { margin-left: auto; font-weight: 800; }
.option.correct { border-color: var(--green); background: #14352d; color: #a7f3d0; }
.option.wrong { border-color: var(--red); background: #3b2129; color: #fecaca; }
.feedback { margin-top: 10px; padding: 13px 15px; }
.answer-result { color: var(--mint); font-weight: 750; }
.answer-result.wrong { color: #fca5a5; }
.feedback strong { display: block; margin-top: 5px; font-size: .86rem; }
.feedback p { margin: 2px 0 10px; font-size: .81rem; color: #cbd5e1; }
#legal-note { color: #fcd78a; }
#legal-source { display: inline-flex; align-items: center; min-height: 36px; margin-bottom: 6px; font-size: .78rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 13px;
  border: 1px solid #52627a;
  border-radius: 11px;
  background: #172236;
  color: var(--text);
  font-size: .9rem;
  font-weight: 730;
  text-align: center;
  text-decoration: none;
}
.button.primary { border-color: var(--green); background: var(--green); color: #061d16; }
.button:hover, .option:not(:disabled):hover, .phase:not(:disabled):hover { filter: brightness(1.13); }
.feedback .button, .result-card .button, dialog .button { width: 100%; }
.result-card { text-align: center; }
.result-symbol {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  border: 1px solid #2b6f59;
  border-radius: 15px;
  background: #153b31;
  color: var(--mint);
  font-size: 1.65rem;
}
.result-context { color: var(--muted); font-size: .83rem; }
.result-card h1 { margin-top: 3px; font-size: 1.55rem; letter-spacing: -.045em; }
.score { display: block; margin-top: 2px; font-size: 3.2rem; line-height: 1.1; letter-spacing: -.06em; }
.result-grid { margin: 7px 0; letter-spacing: .13em; }
.xp-award { color: var(--mint); font-size: .93rem; }
.xp-award span { color: var(--muted); font-size: .77rem; }
#result-note { margin: 9px 0 12px; color: #cbd5e1; font-size: .84rem; }
.result-card .button + .button, #back-to-map { margin-top: 8px; }
#share-fallback { margin-top: 10px; text-align: left; }
#share-fallback label { font-size: .82rem; }
#share-text { display: block; width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.ad-slot { min-height: 84px; margin-block: 10px; }
.promo { border-color: #2b6f59; }
.promo h2 { margin-top: 6px; font-size: 1.1rem; }
.promo p { margin: 3px 0 10px; color: var(--muted); font-size: .85rem; }
#toast {
  position: fixed;
  z-index: 3;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border: 1px solid #2b6f59;
  border-radius: 12px;
  background: #143329;
  color: var(--text);
  font-size: .86rem;
  text-align: center;
}
#toast:empty { display: none; }
dialog {
  width: min(calc(100% - 40px), 350px);
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}
dialog::backdrop { background: #080f1be0; }
dialog h2 { font-size: 1.2rem; }
dialog p { margin: 7px 0 13px; color: #cbd5e1; font-size: .87rem; }
.dialog-actions { display: grid; gap: 8px; }
.legal-card h1 { margin: 0 0 10px; font-size: 1.65rem; }
.legal-card h2 { margin: 17px 0 5px; font-size: 1.04rem; }
.legal-card p { margin-bottom: 10px; color: #cbd5e1; }
.legal-back { margin-bottom: 12px; }

@media (min-width: 420px) {
  .hero-art { right: 8px; width: 192px; opacity: .41; }
  .hero { padding-inline: 22px; }
}
@media (max-width: 360px) {
  main, .app-header { padding-inline: 13px; }
  .hero-art { right: -19px; width: 147px; }
  .question-card { padding: 13px; }
}
