:root {
  --bg: #f7fafc;
  --ink: #3c3c3c;
  --muted: #777777;
  --line: #e5e5e5;
  --green: #58cc02;
  --green-dk: #58a700;
  --blue: #1cb0f6;
  --orange: #ff9600;
  --red: #ff4b4b;
  --card: #ffffff;
  --shadow: 0 8px 0 rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --font: "Nunito", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #eef9e4 0%, var(--bg) 180px);
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 14px 16px 8px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 14px;
}

.stat.xp {
  color: var(--orange);
}
.stat.heart {
  color: var(--red);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-size: 18px;
  font-weight: 900;
  color: var(--green-dk);
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.screen {
  flex: 1;
  padding: 8px 16px calc(24px + var(--safe-bottom));
}

.hero {
  background: linear-gradient(145deg, #58cc02, #89e219);
  color: #fff;
  border-radius: 24px;
  padding: 20px 18px;
  box-shadow: 0 10px 0 #469a01;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  opacity: 0.95;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
}

.unit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unit-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  color: inherit;
  transition: transform 0.12s ease;
}

.unit-card:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}

.unit-emoji {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: #f0fff0;
}

.unit-copy strong {
  display: block;
  font-size: 16px;
  font-weight: 900;
  margin-bottom: 2px;
}

.unit-copy small {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.progress-ring {
  width: 46px;
  height: 46px;
}

.progress-ring circle {
  fill: none;
  stroke-width: 5;
}

.progress-ring .track {
  stroke: #e8e8e8;
}

.progress-ring .fill {
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.35s ease;
}

.unit-meta {
  margin: 4px 0 14px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 20px;
}

.node {
  width: min(100%, 280px);
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  position: relative;
}

.node:nth-child(odd) {
  transform: translateX(-18px);
}
.node:nth-child(even) {
  transform: translateX(18px);
}

.node.done {
  opacity: 0.85;
}
.node.locked {
  background: #cfcfcf !important;
  box-shadow: 0 6px 0 #b0b0b0;
  color: #666;
}

.node small {
  display: block;
  font-size: 11px;
  opacity: 0.9;
  font-weight: 800;
}

.back-btn,
.ghost-btn {
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  padding: 8px 0;
  margin-bottom: 6px;
}

.quiz-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.bar {
  flex: 1;
  height: 14px;
  background: #e5e5e5;
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.prompt {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.prompt .tag {
  display: inline-block;
  background: #eef9e4;
  color: var(--green-dk);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 10px;
}

.prompt .stem {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.45;
  white-space: pre-wrap;
}

.prompt .stem .quote {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
  background: #f3fbf0;
  border-radius: 0 12px 12px 0;
  font-weight: 700;
  color: #3d5c2a;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  text-align: left;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
}

.choice:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.06);
}

.choice .key {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: #f2f2f2;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.choice.correct {
  border-color: var(--green);
  background: #e9fbd4;
}
.choice.wrong {
  border-color: var(--red);
  background: #ffe6e6;
}
.choice:disabled {
  cursor: default;
}

.feedback {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px;
  font-weight: 800;
}

.feedback.ok {
  background: #e9fbd4;
  color: #3c7a00;
}
.feedback.bad {
  background: #ffe6e6;
  color: #b00000;
}

.primary {
  width: 100%;
  margin-top: 12px;
  background: var(--green);
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 6px 0 var(--green-dk);
}

.primary:disabled {
  opacity: 0.5;
}

.primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--green-dk);
}

.result {
  text-align: center;
  padding: 28px 10px;
}

.result .trophy {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
}

.result h2 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 900;
}

.result p {
  margin: 0 0 18px;
  color: var(--muted);
  font-weight: 700;
}

.link-md {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  font-size: 13px;
}
