:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #173329;
  background: radial-gradient(ellipse at top left, #fff9e9, #f0f3e8 58%, #e9f1e8);
  --forest: #14392e;
  --dark: #102b23;
  --lime: #e5f47e;
  --muted: #50665a;
  --paper: #fffdf5;
  --border: #d5ddcc;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0 auto; max-width: 1540px; min-height: 100vh; padding: 0 clamp(16px, 4vw, 64px) 24px; }
button { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #387ade; outline-offset: 4px; }
button:disabled { opacity: .62; cursor: default; }
button:not(:disabled) { cursor: pointer; }

.topbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vw, 33px) 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 790;
  font-size: clamp(.98rem, 2vw, 1.15rem);
  line-height: 1.1;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  background: var(--forest);
  border-radius: 13px;
  color: var(--lime);
  font-size: 1.6rem;
}

.episode-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
}

.episode-nav a {
  min-height: 44px;
  padding: 0 13px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--dark);
  font-size: .9rem;
  font-weight: 740;
  text-decoration: none;
}

.episode-nav a[aria-current="page"] { background: var(--forest); color: #fffef6; }
.episode-nav a:not([aria-current]):hover { background: #d9e5dc; }
.episode-nav a:focus-visible { outline: 3px solid #387ade; outline-offset: 2px; }

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 740;
}

progress {
  width: clamp(56px, 11vw, 110px);
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  background: #d8e2cc;
  overflow: hidden;
}

progress::-webkit-progress-bar { background: #d8e2cc; }
progress::-webkit-progress-value { background: #587c42; border-radius: 99px; }
progress::-moz-progress-bar { background: #587c42; border-radius: 99px; }

@media (max-width: 600px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .episode-nav { grid-row: 2; grid-column: 1 / -1; justify-self: start; }
  .progress { grid-row: 1; grid-column: 2; }
}

.embedded-episode { background: transparent; }
.embedded-episode body { min-height: 0; padding: 0 2px 14px; }
.embedded-episode .topbar { display: flex; justify-content: flex-end; padding: 4px 4px 14px; }
.embedded-episode .brand, .embedded-episode .episode-nav { display: none; }

.game {
  display: grid;
  grid-template-columns: minmax(0, 1.74fr) minmax(310px, 1fr);
  gap: clamp(14px, 2vw, 25px);
  align-items: stretch;
}

.scene {
  align-self: start;
  min-width: 0;
  margin: 0;
  padding: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 7px 28px #263b2510;
}

.frame {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-radius: 16px;
  aspect-ratio: 1672 / 941;
  background: #b7d2a2;
}

.frame img { width: 100%; height: 100%; display: block; object-fit: cover; }
.finale-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #173329;
}
.splash-frame {
  position: absolute;
  inset: 0;
  animation: reveal-splash 380ms ease-out both;
}
@keyframes reveal-splash {
  from { opacity: 0; }
  to { opacity: 1; }
}
figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 10px 6px;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.25;
  font-weight: 670;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
}
.hotspot-elephant { left: 80%; top: 31%; width: 21%; height: 37%; }
.hotspot-trunk { left: 61%; top: 38%; width: 13%; height: 22%; }

.hotspot span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--dark);
  box-shadow: 0 0 0 4px #e5f47e87, 0 2px 12px #102b2380;
}
.hotspot:hover span, .hotspot:focus-visible span { background: #fff; }
.hotspot[data-found] span { background: #fff; box-shadow: 0 0 0 4px #ffffff99; }

.water-clue {
  position: absolute;
  left: 57%;
  top: 48.5%;
  display: flex;
  align-items: start;
  gap: clamp(2px, .5vw, 7px);
  pointer-events: none;
}
.water-clue i {
  width: clamp(7px, .9vw, 12px);
  aspect-ratio: 1;
  border: 1px solid #f5fdff;
  border-radius: 65% 12% 65% 65%;
  background: #78dafc;
  box-shadow: 0 0 0 1px #1a566c9c;
  transform: rotate(-35deg);
}
.water-clue i:nth-child(2) { margin-top: -9px; }
.water-clue i:nth-child(3) { margin-top: 4px; }

.panel {
  padding: clamp(22px, 3vw, 40px);
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  background: radial-gradient(ellipse at top right, #255141, var(--forest) 66%);
  color: #fffef6;
  border-radius: 24px;
  box-shadow: 0 7px 28px #263b2519;
}

.chapter {
  color: var(--lime);
  font-size: .9rem;
  font-weight: 770;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3.65vw, 3.75rem);
  letter-spacing: -.055em;
  line-height: 1;
  text-wrap: balance;
}
h1:focus { outline: none; }

.instruction {
  margin: 16px 0 0;
  color: #e3ede3;
  font-size: clamp(1rem, 1.6vw, 1.16rem);
  line-height: 1.48;
  max-width: 36ch;
}

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls:empty, #activity:empty { display: none; }

.button {
  min-height: 48px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 760;
  color: #fffef6;
}
.button-primary {
  background: var(--lime);
  color: var(--dark);
  min-width: 115px;
}
.button-primary:hover:not(:disabled) { background: #f4ffad; }
.button-secondary { background: #ffffff0b; border-color: #ffffff52; }
.button-secondary:hover { background: #ffffff22; }
.sound::before { content: '♪'; margin-right: .45em; color: var(--lime); font-weight: 800; }

.characters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.character-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 13px 4px 5px;
  border: 1px solid #ffffff45;
  border-radius: 999px;
  background: #ffffff0b;
  color: #fffef6;
  font-weight: 730;
}
.character-button:hover { background: #ffffff22; }
.avatar {
  display: block;
  position: relative;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 50%;
  background: #cdddaf;
}
.avatar img { display: block; position: absolute; top: -2px; left: 0; width: 200%; }

.dad-question {
  margin-top: 4px;
  padding: 14px;
  border-left: 3px solid var(--lime);
  border-radius: 4px 13px 13px 4px;
  background: #ffffff0c;
}
.dad-question p {
  margin: 10px 0;
  font-size: 1.12rem;
  font-weight: 680;
  line-height: 1.45;
}
.dad-question .dad-caption { font-size: 1rem; font-weight: 480; color: #e3ede3; }
.dad-hint { margin-top: 12px; }
.dad-hint summary {
  min-height: 44px;
  width: fit-content;
  padding: 10px 5px 8px 0;
  color: var(--lime);
  font-weight: 720;
  cursor: pointer;
}
.dad-hint summary:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.word {
  width: 100%;
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 15px;
  border: 1px solid #ffffff45;
  color: #fffef6;
  border-radius: 14px;
  background: #ffffff10;
  text-align: left;
}
.word:hover { background: #ffffff20; }
.word strong { display: block; font-size: clamp(1.1rem, 2vw, 1.5rem); }
.word .meaning { display: block; margin-top: 4px; color: #dbead9; font-size: .9rem; }
.word .play-symbol { color: var(--lime); font-size: 1.6rem; }

.practice-count { margin: 18px 0 0; color: #e3ede3; font-weight: 700; }
.practice-board { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.practice-board span { display: grid; place-items: center; width: 23px; height: 23px; border: 2px solid #b9cdbd; border-radius: 50%; color: #19372d; font-size: .8rem; }
.practice-board .passed { background: #a9ce9a; }
.practice-board .current { background: #e5f47e; border-color: #fffdf5; transform: scale(1.18); }
.practice-board + .word { margin-top: 12px; }
.practice-prompt { margin: 14px 0 8px; color: #e3ede3; }
.practice-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.practice-choice {
  min-width: 70px;
  min-height: 70px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: #fffdf5;
  font-size: 2.3rem;
}
.practice-choice.correct { border-color: #d4ed78; background: #edf9b4; }
.practice-feedback { min-height: 1.4em; margin: 9px 0 0; color: #f2f8cd; }

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 19px;
}
.choice {
  min-height: 85px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  gap: 3px;
  padding: 9px 3px;
  border: 2px solid transparent;
  border-radius: 13px;
  background: #f4f4e9;
  color: var(--dark);
  font-size: .9rem;
  font-weight: 770;
}
.choice:hover { background: #eff8c1; }
.choice:focus-visible { outline-color: var(--lime); outline-offset: 2px; }
.choice[data-tried] { border-color: #afc5ad; color: #41574f; }
.choice .picture { font-size: 1.8rem; line-height: 1.15; }
.feedback { color: #f2f8cd; margin: 11px 0 0; line-height: 1.4; }
.feedback:empty { display: none; }


dialog {
  width: min(640px, calc(100% - 26px));
  max-height: calc(100% - 26px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--dark);
  background: var(--paper);
  box-shadow: 0 16px 65px #102b2355;
}
dialog::backdrop { background: #102b23ba; }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dialog-head h2 { margin: 0; font-size: 1.65rem; }
.dialog-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  color: var(--dark);
  background: #e8eedc;
  font-size: 1.65rem;
}
dialog img { display: block; width: 100%; height: auto; border-radius: 10px; }
.dialog-caption {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  text-align: center;
  padding: 10px 0 2px;
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 850px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .panel { gap: 18px; }
  h1 { max-width: 19ch; }
}

@media (max-width: 440px) {
  .scene { border-radius: 17px; padding: 6px; }
  .frame { border-radius: 11px; }
  figcaption { font-size: .8rem; padding: 10px 5px 5px; }
  .panel { padding: 20px; border-radius: 18px; }
  .controls .button { flex-grow: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .splash-frame { animation: none; }
}

.trunk-picture { display: block; width: 62px; height: 62px; border-radius: 8px; background: url("assets/sochi-elephant.jpg") 72% 27% / 300% auto no-repeat; }
.practice-choice svg { display:block; width:62px; height:62px; margin:auto; }
