:root {
  --paper: #f3ecdf;
  --card: #fffaf3;
  --ink: #2a241b;
  --muted: #6e6456;
  --green: #1f6b45;
  --green-d: #144a30;
  --gold: #c8922a;
  --line: #e4d8c4;
  --blue: #2c5f86;
  --danger: #9a3b2f;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: Nunito, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 8% -10%, #fff 0, transparent 36%),
    linear-gradient(180deg, #f7f1e6, #efe4d2);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(rgba(31, 107, 69, 0.055) 1.1px, transparent 1.1px);
  background-size: 22px 22px;
}

body.modal-open { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: inherit; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  z-index: 30;
}

.skip:focus { top: 8px; }

.wrap {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 56px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  background: rgba(243, 236, 223, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  font-family: Literata, Georgia, serif;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.nav a, .nav button {
  background: transparent;
  border: 0;
  text-decoration: none;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 999px;
}

.nav a[aria-current="page"],
.nav button[aria-current="page"] {
  background: #fff;
}

h1, h2, h3 {
  font-family: Literata, Georgia, serif;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

h1 { font-size: clamp(34px, 5vw, 52px); margin: 0 0 8px; }

h2 { font-size: 28px; margin: 0; }

.eyebrow {
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--green-d);
}

.lead { margin: 0; color: var(--muted); max-width: 46ch; }

.muted { color: var(--muted); }

.hero, .panel, .game, .chapter, .reward, .choice, .page-tile, .kid {
  background: var(--card);
  box-shadow: 0 12px 30px rgba(42, 36, 27, 0.05);
}

.hero {
  border-radius: 32px;
  padding: 26px 26px 22px;
  margin-top: 8px;
}

.trail { width: 100%; height: auto; display: block; margin: 8px 0 4px; }

.bar {
  height: 12px;
  background: #efe6d6;
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #3d9a68);
  border-radius: inherit;
}

.kids {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 16px;
}

.kid {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 18px;
  padding: 10px 12px;
  text-align: left;
  box-shadow: inset 0 0 0 2px transparent;
}

.kid.on { box-shadow: inset 0 0 0 2px var(--green); }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.kid small { display: block; color: var(--muted); font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  appearance: none;
  border: 0;
  background: var(--green);
  color: #f6f3ea;
  font-weight: 800;
  border-radius: 999px;
  padding: 14px 20px;
  min-height: 52px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.secondary {
  background: transparent;
  color: var(--green-d);
  box-shadow: inset 0 0 0 2px var(--green);
}

.btn.quiet {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  box-shadow: inset 0 0 0 2px #e7c6c0;
}

.games {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.game {
  border-radius: 24px;
  padding: 16px 18px;
  min-height: 112px;
}

.game h2 { font-size: 24px; margin-bottom: 4px; }

.game p { margin: 0; color: var(--muted); }

.game.on {
  background: var(--green);
  color: #f6f3ea;
}

.game.on p { color: rgba(246, 243, 234, 0.82); }

.game.soon { opacity: 0.72; }

.notice {
  background: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  margin: 0 0 14px;
  box-shadow: inset 4px 0 0 var(--gold);
}

.back {
  display: inline-block;
  margin: 8px 0 10px;
  font-weight: 800;
  text-decoration: none;
  color: var(--green-d);
}

.chapter { border-radius: 28px; padding: 16px; margin-top: 14px; }

.chapter-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #e7f3ec;
  color: var(--green-d);
  font-weight: 800;
  flex: 0 0 auto;
}

.chapter-head p { margin: 2px 0 0; color: var(--muted); }

.score { margin-left: auto; font-weight: 800; }

.lessons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.pill {
  display: block;
  text-decoration: none;
  background: #fff;
  border-radius: 16px;
  padding: 10px 10px 12px;
  box-shadow: inset 0 0 0 2px var(--line);
  min-height: 74px;
}

.pill b, .pill span { display: block; }

.pill span { color: var(--muted); font-size: 14px; font-weight: 700; }

.pill.current { box-shadow: inset 0 0 0 2px var(--green); background: #f3faf6; }

.pill.done { background: #f7f1e2; }

.pill.locked { opacity: 0.48; }

.pages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.page-tile {
  border: 0;
  border-radius: 24px;
  min-height: 148px;
  padding: 14px;
  text-align: left;
  box-shadow: inset 0 0 0 2px var(--line);
}

.page-tile span, .page-tile em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.page-tile strong {
  display: block;
  font-family: Literata, Georgia, serif;
  font-size: 44px;
  line-height: 1.1;
  margin: 6px 0;
}

.page-tile.current { box-shadow: inset 0 0 0 3px var(--green); }

.page-tile.done { background: #f8f3e6; }

.page-tile.done strong { color: var(--green-d); }
.page-tile.done em { color: var(--gold); }

.page-tile.just { animation: pop 0.45s ease; }

.dock {
  position: sticky;
  bottom: 12px;
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.dock .btn { width: 100%; }

.hint { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }

.panel {
  border-radius: 24px;
  padding: 18px;
  margin-top: 14px;
}

.panel h2 { font-size: 24px; margin-bottom: 6px; }

label { display: block; font-weight: 800; margin: 12px 0 6px; }

input[type="text"],
input[type="number"],
input[type="password"],
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
}

.row-2, .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row { grid-template-columns: 1fr auto; align-items: end; }

.stack { display: grid; gap: 8px; margin-top: 12px; }

.vid-list, .reward-list { list-style: none; padding: 0; margin: 12px 0 0; }

.vid-list li, .reward {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.reward {
  border-radius: 20px;
  padding: 14px;
  margin-top: 10px;
  border-top: 0;
}

.choice {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  margin-top: 8px;
  box-shadow: inset 0 0 0 2px var(--line);
  cursor: pointer;
}

.choice b, .choice span { display: block; }

.choice span { color: var(--muted); font-weight: 700; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(42, 36, 27, 0.46);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 28px;
  padding: 22px;
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
}

.modal.wide { width: min(760px, 100%); }

.dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }

.dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--green);
}

.dots i.on { background: var(--green); }

.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pad button {
  min-height: 64px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  font-size: 24px;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px var(--line);
}

.frame {
  position: relative;
  padding-top: 56.25%;
  border-radius: 18px;
  overflow: hidden;
  background: #1b1b1b;
  margin: 12px 0;
}

.frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.shake { animation: shake 0.35s linear; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

@keyframes pop {
  from { transform: scale(0.96); }
  50% { transform: scale(1.03); }
  to { transform: scale(1); }
}

@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@media (max-width: 720px) {
  .games, .lessons, .pages { grid-template-columns: 1fr 1fr; }
  .row-2, .form-row { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; align-items: flex-start; }
  .nav { width: 100%; justify-content: flex-start; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
  .hero, .chapter, .panel { border-radius: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .page-tile.just, .shake { animation: none; }
}
