:root {
  --bg: #1A1A2E;
  --gold: #FFD54F;
  --red: #E53935;
  --ink: #424242;
  --muted: rgba(255, 255, 255, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e0e1a;
  color: white;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.app {
  min-height: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--bg);
  overflow-x: hidden;
}

.home, .screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom));
}
.hero {
  position: relative;
  flex: 1;
  min-height: 240px;
  border-radius: 28px;
  overflow: hidden;
  background: #111;
}
.hero video, .call-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.35);
  transform-origin: center 92%;
}
.call-video { transform: none; object-fit: cover; }
.fox {
  width: 100%;
  height: 180px;
  margin: 8px 0 12px;
  border-radius: 24px;
  overflow: hidden;
  background: #12122a;
}
.fox video { width: 100%; height: 100%; object-fit: cover; object-position: center 28%; }
.hero-copy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 20px 0;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.streak {
  background: #FF6F00;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
}
.welcome {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}
.avatar {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  padding: 4px;
  background: rgba(255, 255, 255, 0.16);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.bo-btn, .wide, .gold, .green, .dark {
  border: 0;
  border-radius: 22px;
  min-height: 56px;
  font-weight: 800;
}
.bo-btn {
  position: relative;
  margin-top: 14px;
  height: 76px;
  background: var(--red);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  text-align: left;
}
.bo-btn strong { display: block; font-size: 20px; }
.bo-btn small { display: block; font-weight: 600; opacity: 0.9; }
.bo-btn.calling::before,
.bo-btn.calling::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid white;
  border-radius: 22px;
  animation: pulse 1.1s linear infinite;
}
.bo-btn.calling::after { animation-delay: 0.55s; }
@keyframes pulse {
  from { transform: scale(1); opacity: 0.85; }
  to { transform: scale(1.08); opacity: 0; }
}
.bo-btn img { width: 52px; height: 52px; border-radius: 16px; object-fit: cover; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile {
  min-height: 108px;
  border: 0;
  border-radius: 22px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.tile img { width: 42px; height: 42px; object-fit: contain; }
.tile strong { font-size: 16px; }
.tile small { font-size: 13px; opacity: 0.9; }
.parents-link, .text-btn {
  background: transparent;
  border: 0;
  color: var(--gold);
  font-weight: 700;
  min-height: 44px;
}
.parents-link { color: rgba(255, 255, 255, 0.72); width: 100%; }

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.back, .icon-btn {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  font-size: 20px;
  overflow: hidden;
  padding: 0;
}
.icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.title { flex: 1; text-align: center; }
.title h1 { margin: 0; font-size: 26px; }
.title h1 span { color: var(--gold); }
.title p, .lead { margin: 6px 0 0; color: var(--muted); }
.menu { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; overflow: auto; }
.card {
  border: 0;
  border-radius: 22px;
  min-height: 92px;
  padding: 14px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  text-align: left;
  align-items: center;
}
.card img { width: 64px; height: 64px; object-fit: contain; }
.card b { display: block; font-size: 18px; }
.card span { display: block; margin-top: 4px; font-size: 14px; opacity: 0.92; }
.badge { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 800; }

.list, .grid { overflow: auto; padding-bottom: 12px; }
.row {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 12px;
  margin-top: 10px;
}
.row img { width: 56px; height: 56px; object-fit: contain; }
.row.locked { opacity: 0.55; }
.row small { display: block; color: var(--muted); }
.lesson-row { justify-content: space-between; }
.hanzi { color: #FF8A80; font-weight: 800; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}
.stage img.big { width: min(72vw, 280px); height: min(72vw, 280px); object-fit: contain; }
.caption { font-size: 24px; font-weight: 800; line-height: 1.25; margin: 8px 0; }
.choices { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.choice {
  flex: 1;
  border: 3px solid transparent;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  min-height: 90px;
}
.choice img { width: 100%; height: 100%; object-fit: contain; }
.choice.hit { border-color: #66BB6A; }
.choice.miss { border-color: #EF5350; }
.dots { display: flex; gap: 8px; justify-content: center; margin: 8px 0; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.3); display: block; }
.dots i.on { background: var(--gold); }

.word-card {
  background: white;
  color: var(--ink);
  border-radius: 28px;
  padding: 18px 16px 12px;
  text-align: center;
  width: min(100%, 420px);
}
.word-card img { width: 104px; height: 104px; object-fit: contain; }
.word-card .ru { font-size: 22px; font-weight: 800; margin: 6px 0; }
.word-card .hz { font-size: 48px; color: #C62828; margin: 0; font-family: "Songti SC", "Noto Serif SC", serif; }
.word-card .speak { color: #1565C0; font-size: 26px; font-weight: 800; margin: 4px 0; }
.word-card .py { color: #757575; margin: 0 0 8px; }
.trace {
  width: min(100%, 320px);
  height: 220px;
  border-radius: 18px;
  background: #FAFAFA;
  touch-action: none;
}
.actions { display: flex; gap: 10px; width: 100%; margin-top: 12px; }
.wide { flex: 1; background: #43A047; }
.dark { background: rgba(255,255,255,0.22); padding: 0 18px; }
.gold { background: #FF6F00; width: 100%; }
.red { background: var(--red); width: 100%; border: 0; border-radius: 24px; min-height: 56px; font-weight: 800; }
.mic {
  width: 84px;
  height: 84px;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  font-size: 36px;
  margin: 12px auto;
}
.mic.live { background: #C62828; box-shadow: 0 0 0 8px rgba(229, 57, 53, 0.35); }
.heard { min-height: 22px; color: var(--muted); }

.sheet, .modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 5;
}
.panel {
  width: min(100%, 420px);
  background: #2D2B55;
  border-radius: 20px;
  padding: 20px;
  text-align: center;
}
.panel input {
  width: 100%;
  margin: 12px 0;
  border-radius: 14px;
  border: 0;
  padding: 14px;
  background: white;
  color: #222;
}
.pay {
  background: #1B3A4B;
  border-radius: 20px;
  padding: 16px;
  margin-top: 16px;
}
.pay h2 { color: var(--gold); font-size: 18px; margin: 0 0 8px; }
.album-title { color: #FF5252; font-size: 20px; }
.album-count { color: var(--gold); margin: 2px 0 0; }
.album-progress {
  background: #2D2B55;
  border-radius: 20px;
  padding: 16px;
  margin: 8px 0 16px;
}
.album-progress b { display: block; margin-bottom: 10px; line-height: 1.35; }
.bar.gold i { background: var(--gold); }
.album-note {
  margin: 0 0 12px;
  color: var(--gold);
  font-weight: 700;
}
.album-theme { margin-bottom: 18px; }
.album-theme-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.album-theme-head b { flex: 1; font-size: 17px; }
.album-theme-head .count { border-radius: 12px; padding: 4px 10px; font-size: 13px; font-weight: 800; }
.album {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stamp {
  aspect-ratio: 1;
  border: 0;
  border-radius: 16px;
  padding: 2px;
  background: #252347;
  overflow: hidden;
}
.stamp img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; background: #252347; }
.stamp.got img { background: #FFFDE7; }
.stamp.off img { opacity: 0.35; }
.sticker-card img { width: 160px; height: 160px; object-fit: contain; }
.sticker-card .hz { color: #C62828; font-size: 48px; margin: 8px 0 0; }
.sticker-card .ru { color: #37474F; }
.section-title { margin: 18px 0 0; font-size: 18px; }
.call {
  background: #071833;
}
.five { background: #1A1040; }
.error { color: #FFCDD2; }
.section-head, .theme-head { display: flex; gap: 10px; align-items: center; text-align: left; }
.section-head { margin: 18px 0 8px; }
.section-head img { width: 44px; height: 44px; }
.section-head small, .theme-head small { display: block; color: var(--gold); font-size: 12px; }
.theme-card { background: #2D2B55; border-radius: 22px; padding: 14px; margin-bottom: 12px; }
.theme-head .emoji { font-size: 32px; }
.lesson-line {
  width: 100%;
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  color: white;
  background: rgba(0,0,0,0.25);
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
}
.lesson-line small, .lesson-line b { display: block; }
.lesson-line.locked { opacity: 0.4; }
.chips { display: flex; gap: 8px; overflow: auto; padding: 8px 0; }
.chip {
  border: 0;
  border-radius: 20px;
  background: #2D2B55;
  color: white;
  padding: 8px 12px;
  white-space: nowrap;
}
.chip.on { background: #8E24AA; font-weight: 800; }
.chip.locked { opacity: 0.4; }
.chip img { width: 28px; height: 28px; vertical-align: middle; }
.transport { display: flex; align-items: center; justify-content: space-evenly; padding: 8px 0 12px; }
.nav {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(142, 36, 170, 0.92);
  color: white;
  font-size: 22px;
  font-weight: 800;
}
.summary, .panel { background: #2D2B55; border-radius: 20px; padding: 16px; }

.scene {
  position: relative;
  min-height: 100dvh;
  background: #1A1A2E;
  overflow: hidden;
}
.scene-fox {
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  bottom: 0;
  width: 100%;
  height: calc(100% - 64px);
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  z-index: 0;
  background: #0b1c3d;
}
.scene.has-dock .scene-fox { bottom: 148px; height: calc(100% - 212px); }
.scene-bar {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: #1A1A2E;
}
.scene-bar h1 { margin: 0; text-align: center; font-size: 18px; }
.scene-bar h1.theme { color: #FF5252; font-size: 16px; }
.scene-bar .progress { min-width: 36px; text-align: right; font-size: 14px; color: #FFD54F; }
.scene-bar .back {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 20px;
}
.scene-stack {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 0;
}
.scene-line {
  margin: 0;
  max-width: 420px;
  padding: 6px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}
.tag {
  background: #E53935;
  border-radius: 10px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 800;
}
.float-card, .speech-card, .trace-card {
  width: min(100%, 420px);
  background: white;
  color: #37474F;
  border-radius: 22px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.float-card img, .speech-card img { width: 88px; height: 88px; object-fit: contain; }
.float-card .ru, .speech-card .ru { margin: 8px 0 0; font-size: 20px; font-weight: 800; }
.speech-card .emo { margin: 0; font-size: 28px; }
.speech-card.proverb .ru { color: #546E7A; font-weight: 600; font-size: 16px; }
.speech-card .big-hanzi {
  margin: 8px 0;
  font-size: 32px;
  font-weight: 800;
  color: #C62828;
  font-family: "Songti SC", "Noto Serif SC", serif;
}
.speak-pill {
  margin: 8px 0 0;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 20px;
  font-weight: 800;
}
.speak-pill.phrase { background: #E8F5E9; color: #2E7D32; }
.speak-pill.proverb { background: #FFF3E0; color: #E65100; }
.trace-card {
  position: relative;
  padding: 8px;
  background:
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 25% 25%,
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 25% 25%,
    white;
}
.trace-card .glyph {
  position: absolute;
  inset: 8px;
  z-index: 1;
  margin: 0;
  display: grid;
  place-items: center;
  font-size: min(42vw, 168px);
  line-height: 1;
  color: #111;
  opacity: 0.28;
  pointer-events: none;
  font-family: "Songti SC", "Noto Serif SC", serif;
}
.trace-card canvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 230px;
  background: transparent;
  border-radius: 16px;
  touch-action: none;
}
.scene-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  background: rgba(26, 26, 46, 0.94);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.scene-dock.bare {
  background: transparent;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-left: 16px;
  padding-right: 16px;
}
.scene-dock .chips { padding-top: 0; }
.scene-dock .chip.on.phrase { background: #43A047; }
.scene-dock .chip.on.proverb { background: #FF8F00; }
.scene-dock .transport { padding-bottom: 0; }
.scene-dock .nav.red { background: rgba(229, 57, 53, 0.92); }
.scene-dock .count { color: #FFD54F; min-width: 64px; text-align: center; }
.go, .later, .say {
  border: 0;
  border-radius: 28px;
  min-height: 58px;
  font-weight: 800;
  font-size: 18px;
}
.go { flex: 1; background: #43A047; color: white; }
.later { width: 120px; background: #5C6370; color: white; }
.say {
  min-width: 220px;
  background: #FFB300;
  color: #3E2723;
  font-size: 22px;
}
.say.live { box-shadow: 0 0 0 8px rgba(255, 179, 0, 0.35); }
.quiz-card {
  width: min(100%, 440px);
  display: flex;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: white;
  color: #212121;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}
.quiz-card img { width: 72px; height: 72px; object-fit: contain; }
.quiz-card b { display: block; font-size: 22px; }
.quiz-card p { margin: 2px 0 0; font-size: 16px; font-weight: 700; }
.quiz-card .heard { color: #1565C0; }
.song-hero { text-align: center; color: white; }
.song-hero img { width: 72px; height: 72px; object-fit: contain; border-radius: 16px; background: rgba(255,255,255,0.12); }
.song-hero h2 { margin: 8px 0 0; font-size: 28px; }
.song-hero .hanzi { margin: 4px 0 0; color: white; font-size: 22px; font-weight: 700; }
.phrase-title { color: #81C784; }
.proverb-title { color: #FFB300; }
.cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.cells b, .cells small { display: block; }
.bar { height: 8px; background: rgba(255,255,255,0.12); border-radius: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #66BB6A; }
.ok { color: #66BB6A; font-weight: 800; }
.tip { background: #1B3A4B; color: #B3E5FC; border-radius: 16px; padding: 14px; }
input { width: 100%; border: 0; border-radius: 14px; padding: 14px; color: #222; margin: 8px 0; }
