@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/nunito-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/nunito-700.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("../fonts/nunito-800.woff2") format("woff2");
}

:root {
  --bg: #f4f1ea;
  --ink: #1c2430;
  --muted: #5d6b73;
  --line: #e3dccf;
  --pine: #0f6e56;
  --pine-dark: #084c3c;
  --pine-soft: #e5f4ee;
  --gold: #e9a825;
  --gold-soft: #fff4d6;
  --good: #157a45;
  --good-soft: #e5f6ec;
  --bad: #c4382f;
  --bad-soft: #fdecea;
  --card: #fffcf7;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.06);
  --tab: calc(64px + env(safe-area-inset-bottom));
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  font-family: "Nunito", "Segoe UI", sans-serif;
  font-weight: 600;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 50% -10%, #d7efe4, transparent 55%),
    #dfeae4;
}
button, input { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.app {
  width: min(480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}
@media (min-width: 560px) {
  body { padding: 24px 0; }
  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(15, 60, 45, 0.16);
  }
}

#view { padding-bottom: var(--tab); }
.tabs:empty { display: none; }
body:has(.tabs:empty) #view { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
body.lesson-mode { overflow: hidden; height: 100dvh; background: var(--bg); }
body.lesson-mode .app { height: 100dvh; min-height: 0; border-radius: 0; box-shadow: none; }
body.lesson-mode #view { height: 100%; padding-bottom: 0; overflow: auto; }
.tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fffdf9;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabs a {
  text-decoration: none;
  text-align: center;
  padding: 10px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.tabs a.on { color: var(--pine); }

.screen { padding: 18px 18px 8px; }
.topbar { padding-top: env(safe-area-inset-top); }
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand h1 { font-size: 22px; line-height: 1; margin: 0; font-weight: 800; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.stats-row {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.pill, .goal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  font-weight: 800;
}
.flame { width: 18px; height: 18px; display: inline-flex; color: #e07a14; }
.flame svg { width: 18px; height: 18px; }
.goal {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 8px;
}
.goal b { display: block; font-size: 14px; }
.goal span { color: var(--muted); font-size: 12px; }
.ring { width: 40px; height: 40px; display: block; }
.ring-track { fill: none; stroke: #efe8da; stroke-width: 4; }
.ring-value {
  fill: none;
  stroke: var(--pine);
  stroke-width: 4;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 22px 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.continue {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--pine);
  color: white;
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 12px 24px rgba(15, 110, 86, 0.22);
}
.continue small { display: block; opacity: 0.85; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 11px; }
.continue strong { display: block; font-size: 22px; font-weight: 800; margin: 4px 0; }
.continue em { font-style: normal; font-weight: 700; opacity: 0.92; }
.section-label {
  margin: 22px 2px 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.path { display: flex; flex-direction: column; gap: 10px; }
.unit {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 18px;
  padding: 12px 12px 12px 14px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  box-shadow: var(--shadow);
}
.unit.current { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233, 168, 37, 0.25); }
.unit.locked { opacity: 0.72; }
.unit.done { background: #f3faf6; }
.marker {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--pine-soft);
  color: var(--pine-dark);
  font-weight: 800;
}
.unit.done .marker { background: var(--pine); color: white; }
.unit.locked .marker { background: #efeae2; color: #8a8175; }
.unit h2 { margin: 0; font-size: 17px; font-weight: 800; }
.unit p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 99px;
  background: #efe8da;
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--pine); border-radius: 99px; }
.fine { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }

.btn {
  appearance: none;
  border: 0;
  background: var(--pine);
  color: white;
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 17px;
  padding: 12px 16px;
}
.btn:disabled { opacity: 0.45; }
.btn.ghost {
  background: transparent;
  color: var(--pine-dark);
  border: 2px solid var(--line);
}
.btn.bad { background: var(--bad); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.text-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--pine);
  font-weight: 800;
  padding: 8px 0;
}

.lesson {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.lesson-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
}
.track {
  flex: 1;
  height: 12px;
  background: #e7e0d4;
  border-radius: 99px;
  overflow: hidden;
}
.track span { display: block; height: 100%; background: var(--pine); border-radius: 99px; transition: width 0.25s ease; }
.hearts { display: flex; gap: 2px; color: var(--bad); }
.heart { width: 16px; height: 16px; display: block; opacity: 0.28; }
.heart.on { opacity: 1; }
.heart svg, .ico svg { width: 100%; height: 100%; display: block; }
.combo {
  margin: 0 18px;
  color: var(--pine-dark);
  font-size: 13px;
  font-weight: 800;
}
.lesson-body {
  flex: 1;
  overflow: auto;
  padding: 8px 18px 12px;
}
.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pine);
  font-size: 12px;
  font-weight: 800;
}
.prompt {
  margin: 6px 0 14px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.capital-hero { margin: 0 0 6px; font-size: 22px; font-weight: 800; color: var(--pine-dark); }
.hint { margin: 6px 0 0; color: var(--muted); }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  width: 100%;
  text-align: left;
  background: white;
  border: 2px solid var(--line);
  border-radius: 16px;
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 17px;
}
.choice .key {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: #f3efe6;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  flex: none;
}
.choice.selected { border-color: var(--pine); background: var(--pine-soft); }
.choice.good { border-color: var(--good); background: var(--good-soft); }
.choice.bad { border-color: var(--bad); background: var(--bad-soft); }
.answer-input {
  width: 100%;
  border: 2px solid var(--line);
  background: white;
  border-radius: 16px;
  min-height: 58px;
  padding: 12px 14px;
  font-size: 18px;
  font-weight: 700;
}
.answer-input:focus { border-color: var(--pine); outline: none; }
.letter-hint { min-height: 1.2em; color: var(--muted); font-weight: 800; }

.map-slot { margin: 4px 0 12px; }
.map {
  background: #e7f3ed;
  border-radius: 18px;
  padding: 6px;
  overflow: hidden;
}
.map svg { width: 100%; height: auto; display: block; }
.map.shape { background: transparent; padding: 0; }
.map.shape svg { height: 190px; }
.map .state path {
  fill: #d5e6de;
  stroke: #fff;
  stroke-width: 1.4px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.map .dc path {
  fill: #d9d3c7;
  stroke: #fff;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}
.map .state.s1 path { fill: #b7ddd0; }
.map .state.s2 path { fill: #6fbfa4; }
.map .state.s3 path { fill: #1f8f6e; }
.map .state.s4 path { fill: #0c5c46; }
.map .state.is-hot path { fill: var(--gold); }
.map .state.is-on path { fill: var(--pine); }
.map .state.is-good path { fill: var(--good); }
.map .state.is-bad path { fill: var(--bad); }
.map.interactive .state { cursor: pointer; }
@media (hover: hover) {
  .map.interactive .state:hover path { fill: #8fceba; }
  .map.interactive .state.is-on:hover path { fill: var(--pine); }
}

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match button {
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: white;
  font-weight: 800;
  font-size: 15px;
  line-height: 1.2;
  padding: 8px;
}
.match button.sel { border-color: var(--pine); background: var(--pine-soft); }
.match button.done { background: var(--pine); color: white; border-color: var(--pine); }
.match button.flash { border-color: var(--bad); background: var(--bad-soft); }

.dock {
  flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #f7f4ee;
  border-top: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dock.good { background: var(--good-soft); }
.dock.bad { background: var(--bad-soft); }
.dock-note { margin: 0; text-align: center; color: var(--muted); }
.feedback-copy strong { font-size: 20px; font-weight: 800; }
.feedback-copy p { margin: 4px 0 0; white-space: pre-wrap; }
.xp-pop { float: right; font-weight: 800; color: var(--pine-dark); }
.dock.bad .xp-pop { color: var(--bad); }

.sheet {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 26, 0.4);
  display: flex;
  align-items: flex-end;
  padding: 16px;
  z-index: 4;
}
.sheet .card { width: 100%; margin-bottom: env(safe-area-inset-bottom); }
.sheet h2 { margin: 0 0 6px; }

.hero-mark { width: 72px; height: 72px; border-radius: 20px; }
.welcome h1 { font-size: 36px; margin: 12px 0 8px; letter-spacing: -0.03em; }
.welcome p { font-size: 17px; line-height: 1.4; }
.welcome { padding-top: calc(28px + env(safe-area-inset-top)); }

.back {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
  margin-bottom: 8px;
}
.skill-row { margin: 10px 0; }
.skill-row .who { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.meters { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.meter { display: grid; grid-template-columns: 72px 1fr 32px; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.meter-track {
  position: relative;
  height: 8px;
  background: #efe8da;
  border-radius: 99px;
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--pine);
}
.meter-num { text-align: right; font-weight: 800; color: var(--ink); }

.search {
  width: 100%;
  border: 2px solid var(--line);
  background: white;
  border-radius: 14px;
  min-height: 48px;
  padding: 10px 12px;
  font-size: 16px;
  margin: 8px 0 12px;
}
.atlas-list { display: flex; flex-direction: column; gap: 8px; }
.atlas-list a, .weak a {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}
.atlas-list strong, .weak strong { display: block; }
.atlas-list small, .weak small { color: var(--muted); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; margin-right: 4px; vertical-align: -2px; }
.swatch-0 { background: #d5e6de; }
.swatch-1 { background: #b7ddd0; }
.swatch-2 { background: #6fbfa4; }
.swatch-3 { background: #1f8f6e; }
.swatch-4 { background: #0c5c46; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.stat-grid b { display: block; font-size: 22px; }
.stat-grid span { color: var(--muted); font-size: 13px; }
.choice-row { display: flex; gap: 8px; }
.choice-row button { flex: 1; }
.seg { min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: white; font-weight: 800; }
.seg.on { border-color: var(--pine); background: var(--pine-soft); color: var(--pine-dark); }
.toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  font-weight: 800;
}
.switch { width: 42px; height: 26px; border-radius: 99px; background: #ddd4c6; position: relative; flex: none; }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  transition: transform 0.15s ease;
}
.switch.on { background: var(--pine); }
.switch.on::after { transform: translateX(16px); }
.file input { display: none; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti i {
  position: absolute;
  top: -10px;
  left: var(--x);
  width: 8px;
  height: 12px;
  background: var(--c, var(--gold));
  border-radius: 2px;
  animation: fall 0.9s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(100dvh) rotate(180deg); opacity: 0.2; }
}
@media (prefers-reduced-motion: reduce) {
  .track span, .switch::after, .confetti i { transition: none; animation: none; }
}

.result-score { font-size: 56px; font-weight: 800; letter-spacing: -0.04em; margin: 0; }
.result-score small { font-size: 20px; color: var(--muted); letter-spacing: 0; }
.banner {
  background: var(--gold-soft);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 800;
  margin: 8px 0;
}
.map-missing { color: var(--muted); }
