:root {
  --ink: #3d2a24;
  --wood: #c45c3a;
  --cream: #fff8f4;
  --paper: #fff1ea;
  --gold: #ffc857;
  --leaf: #3db87a;
  --leaf2: #2f9a64;
  --sky: #ffd3c4;
  --danger: #e45b4a;
  --line: #f3e4dc;
  --peach: #ff7a4a;
  --peach2: #ff9a6b;
  --muted: #8a6e64;
  --top: 64px;
  --shadow: 0 8px 24px rgba(196, 92, 58, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  min-height: 100%;
  background: #fff6f0;
  color: var(--ink);
  font-family: "Be Vietnam Pro", sans-serif;
}
body { overflow: auto; }
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
a { color: var(--peach); font-weight: 700; text-decoration: none; }
.hidden { display: none !important; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff6f0;
}

#top {
  height: var(--top);
  flex: 0 0 var(--top);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: #fff;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(196, 92, 58, 0.06);
  z-index: 10;
  position: sticky;
  top: 0;
}
#top .brand {
  font-family: Fredoka, sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--peach);
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
#top .brand:hover { color: #e06a3c; }
#nav {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
}
#nav.hidden { display: none !important; }
#nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 999px;
  white-space: nowrap;
}
#nav button .ico { font-size: 16px; line-height: 1; }
#nav button:hover { background: var(--paper); color: var(--ink); }
#nav button.on {
  color: #fff;
  background: linear-gradient(180deg, var(--peach2), var(--peach));
}
#hud {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
  align-items: center;
}
.chip {
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 4px 10px 4px 6px;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip img { width: 20px; height: 20px; object-fit: contain; }
.chip.gold { background: #fff4d6; }
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: 0;
  color: var(--ink);
}
.user-pill img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #ffe8dc;
}

#view {
  flex: 1 1 auto;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 48px;
  position: relative;
  z-index: 5;
}
#view.book-wide {
  width: min(1680px, calc(100vw - 24px));
  max-width: none;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 0;
}
.split > .pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.split > .card,
.split > .pane > .card { margin-bottom: 0; }

.card {
  background: #fff;
  border: 0;
  border-radius: 20px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
h1, h2 { font-family: Fredoka, sans-serif; }
h1 { font-size: 28px; color: var(--ink); }
h2 { font-size: 18px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.muted a, .auth-card a { color: var(--peach); font-weight: 700; }
.err { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 1.2em; margin-top: 8px; }
.auth-side .tree-wrap { min-height: 240px; }
.auth-side .tree-wrap img { width: min(280px, 40vh); height: auto; object-fit: contain; }
.kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--peach);
}

.btn {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: none;
  transition: transform 0.08s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(0.98); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--peach2), var(--peach));
  color: #fff;
}
.btn.leaf { background: linear-gradient(180deg, #6ed39a, var(--leaf)); color: #fff; }
.btn.danger { background: #ffd4ce; color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.tiny { padding: 7px 12px; font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .btn { flex: 1; }
.row input { flex: 1 1 auto; width: auto; }

input, textarea, select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  background: #fff;
  font-size: 15px;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(255, 122, 74, 0.25);
  border-color: var(--peach2);
}
select { cursor: pointer; appearance: auto; }
label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 6px; color: var(--muted); }

.species {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.species button {
  border: 2px solid transparent;
  background: var(--paper);
  border-radius: 16px;
  padding: 8px 6px;
  font-weight: 700;
  font-size: 13px;
}
.species button img {
  display: block;
  width: 100%;
  height: 88px;
  object-fit: contain;
  margin-bottom: 4px;
}
.species button.on { background: #fff; border-color: var(--peach); box-shadow: 0 0 0 3px rgba(255, 122, 74, 0.18); }

.tree-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}
.tree-art {
  position: relative;
  width: min(280px, 38vh);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.tree-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(196, 92, 58, 0.18));
  animation: sway 4.5s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.tree-art.mood-lush img { filter: drop-shadow(0 0 18px rgba(255, 200, 120, 0.7)); }
.tree-art.mood-wilted img { filter: grayscale(0.25) saturate(0.75); animation: none; transform: rotate(2deg) translateY(6px); }
.tree-art.mood-sulk img { filter: saturate(0.7); }
.tree-art.aura-firefly::after { content: ""; position: absolute; inset: 10%; border-radius: 50%; box-shadow: 0 0 24px 8px rgba(255, 240, 150, 0.4); pointer-events: none; }
.tree-art.aura-rainbow::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,247,174,0.3), transparent 70%);
  pointer-events: none;
}
.tree-art .hat { position: absolute; top: 6%; font-size: 42px; pointer-events: none; }
@keyframes sway {
  0%, 100% { transform: rotate(-1.2deg); }
  50% { transform: rotate(1.4deg); }
}

.bar {
  height: 10px;
  background: var(--paper);
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #ffb347, var(--peach)); }
.bar.wilted > i { background: #c49a72; }
.bar.sulk > i { background: #e0b84a; }
.bar.happy > i, .bar.lush > i { background: linear-gradient(90deg, #7ed957, var(--leaf)); }

.chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 160px;
  max-height: min(360px, 42vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  margin-bottom: 8px;
  padding: 4px 6px 8px 0;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #e8c4b4 transparent;
}
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb {
  background: #e8c4b4;
  border-radius: 999px;
}
.bubble {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 16px;
  border: 0;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.me { align-self: flex-end; background: #ffe1d4; }
.bubble.tree { align-self: flex-start; background: var(--paper); }

.boss-hero { text-align: center; margin: 8px 0 12px; }
.boss-hero img { width: min(280px, 70%); height: auto; }
.battle {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 10px;
  background: linear-gradient(180deg, #ffe8d8, #fff6f0);
  border-radius: 16px;
}
.battle .fighter { flex: 1; text-align: center; min-width: 0; }
.battle .fighter img { height: 120px; width: auto; max-width: 100%; object-fit: contain; }
.battle .fighter b { display: block; font-size: 13px; margin-top: 4px; }
.battle .vs { font-family: Fredoka, sans-serif; color: var(--peach); font-size: 18px; padding-bottom: 40px; }
.hp-pips { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }
.hp-pips i {
  width: 22px;
  height: 10px;
  border-radius: 4px;
  background: #ead8ce;
}
.hp-pips.leaf i.on { background: var(--leaf); }
.hp-pips.fire i.on { background: var(--danger); }
.battle.hit-boss .fighter.boss img { animation: boss-hit 0.35s ease; }
.battle.hit-player .fighter.you img { animation: boss-hit 0.35s ease; }
@keyframes boss-hit {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.battle-log { text-align: center; margin-bottom: 8px; }
.arena-slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.arena-slot {
  background: var(--paper);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
  min-height: 92px;
}
.arena-slot.on { background: #ffe1d4; }
.arena-slot .av { font-size: 26px; line-height: 1.2; }
.arena-slot b { display: block; font-size: 12px; word-break: break-word; }
.invite-banner {
  background: #fff4d6;
  border-radius: 16px;
  padding: 12px;
  margin: 10px 0;
}
.letter-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #fff7ea;
  border-radius: 18px;
  padding: 12px 14px;
  margin: 10px 0;
  box-shadow: var(--shadow);
  text-align: left;
}
.letter-card img {
  width: 86px;
  height: 86px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 12px;
}
.letter-card .kicker { margin-bottom: 2px; }
.letter-card p { margin: 0 0 8px; }
.letter-chip {
  background: #fff4d6;
  animation: letter-pulse 1.6s ease-in-out infinite;
}
.letter-chip img { width: 26px; height: 26px; }
@keyframes letter-pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.nav-mail {
  width: 10px;
  height: 10px;
  background: var(--peach2);
  border-radius: 50%;
  display: inline-block;
  margin-left: 4px;
  vertical-align: super;
}
@media (max-width: 700px) {
  .arena-slots { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.arena-pick { grid-template-columns: 1fr 1fr; }
.pick-ico { font-size: 52px; line-height: 1; }
.speak-line {
  font-family: Fredoka, sans-serif;
  font-size: 28px;
  line-height: 1.35;
  text-align: center;
  margin: 14px 8px 8px;
  color: var(--ink);
}
.speak-card .ipa { text-align: center; }
.speak-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 18px 0 8px;
}
.mic-btn {
  width: 128px;
  height: 128px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #6ed39a, var(--leaf));
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(61, 184, 122, 0.35);
}
.mic-btn .mic-ico { font-size: 36px; line-height: 1; }
.mic-btn.on {
  background: linear-gradient(180deg, #ff9a6b, var(--peach));
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.chat-file {
  display: inline-block;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  margin: 0 4px 4px 0;
}
.attach-preview { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}
.attach-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
}
.attach-chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.chat-row { align-items: center; }
.chat-row #attach { flex: 0 0 auto; }

.list { display: flex; flex-direction: column; gap: 8px; }
.play-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.course-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
}
.course-head h2 { margin: 0; flex: 1; }
.course-card {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 210px;
  cursor: pointer;
  border: 0;
  text-align: left;
  padding: 0;
  color: inherit;
}
.course-card:hover { transform: translateY(-3px); }
.course-cover {
  height: 110px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #ffd8c8, #ffe9b8);
}
.course-cover img { height: 88px; width: auto; object-fit: contain; }
.course-body { padding: 12px 14px 14px; }
.course-body b { display: block; font-size: 15px; margin-bottom: 4px; }

#view.has-hint-fab { padding-bottom: 168px; }
.hint-dock {
  position: fixed;
  right: 20px;
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  pointer-events: none;
}
.hint-dock > * { pointer-events: auto; }
.hint-fab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
  color: inherit;
}
.hint-fab:hover { filter: none; transform: none; }
.hint-fab:hover .hint-fab-label { filter: brightness(1.05); transform: translateY(-1px); }
.hint-tree .tree-art {
  width: 118px;
  height: 118px;
  aspect-ratio: 1;
}
.hint-tree .tree-art img {
  filter: drop-shadow(0 8px 14px rgba(61, 42, 36, 0.2));
}
.hint-tree .tree-art .hat { font-size: 20px; top: 2%; }
.hint-fab-label {
  display: inline-block;
  background: linear-gradient(180deg, #6ed39a, var(--leaf));
  color: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(61, 184, 122, 0.35);
  margin-top: -10px;
  position: relative;
  z-index: 1;
}
.hint-pop {
  position: relative;
  width: min(280px, calc(100vw - 48px));
  background: #fff;
  color: var(--ink);
  border-radius: 18px;
  padding: 14px 16px 12px;
  box-shadow: 0 12px 32px rgba(61, 42, 36, 0.16);
  margin-right: 18px;
}
.hint-pop::after {
  content: "";
  position: absolute;
  right: 42px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
}
.hint-pop p { font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.hint-pop .kicker { margin-bottom: 6px; }
.hint-pop .btn { margin-top: 2px; }
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  margin-bottom: 20px;
}
.hero-banner {
  background: linear-gradient(120deg, #ff8a5b 0%, #ffb347 55%, #ffd56a 100%);
  border-radius: 24px;
  padding: 28px 32px;
  color: #fff;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
}
.hero-banner h1 { color: #fff; font-size: 32px; }
.hero-banner .muted { color: rgba(255,255,255,0.92); }
.hero-banner .btn { margin-top: 16px; max-width: 220px; background: #fff; color: var(--peach); }
.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 16px; }
.stat {
  background: rgba(255,255,255,0.22);
  border-radius: 14px;
  padding: 10px 12px;
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; opacity: 0.9; }

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.item b { flex: 1; }
.word-pic {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  flex: 0 0 56px;
  font-size: 30px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}
.word-pic.lg {
  width: 120px;
  height: 120px;
  border-radius: 28px;
  font-size: 64px;
  margin: 8px auto 12px;
}
.word-pic.pack-animal { background: #ffe4c4; }
.word-pic.pack-food { background: #ffd6e0; }
.word-pic.pack-school { background: #d6e8ff; }
.word-pic.pack-home { background: #d8f5e5; }
.word-pic.pack-verb { background: #fff3c4; }
.word-pic.pack-adj { background: #e8d6ff; }
.word-pic.pack-mix { background: var(--paper); }
.vocab-row { align-items: flex-start; }
.vocab-body { flex: 1; min-width: 0; }
.vocab-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vocab-top b { flex: 1; font-size: 16px; }
.ctx { margin-top: 4px; }
.tag {
  font-size: 11px;
  font-weight: 700;
  background: var(--paper);
  color: var(--wood);
  border-radius: 999px;
  padding: 3px 8px;
}

.q-prompt { font-size: 22px; font-weight: 800; margin: 8px 0 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices button { text-align: left; }
.timer {
  height: 8px;
  background: var(--paper);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}
.timer > i { display: block; height: 100%; background: var(--peach); width: 100%; transform-origin: left; }

.comic-frame {
  min-height: 140px;
  background: var(--paper);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
}
.speaker { font-weight: 800; color: var(--peach); margin-bottom: 4px; }
.comic-panel {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 260px;
  padding: 12px 16px 0;
  margin-bottom: 12px;
  border-radius: 20px;
  border: 3px solid #3d2a24;
  background:
    radial-gradient(circle at 20% 10%, #fff 0 8px, transparent 9px),
    linear-gradient(180deg, #fff6ea 0%, #ffe4d0 100%);
  overflow: hidden;
}
.comic-panel.right { flex-direction: row-reverse; }
.comic-char {
  height: 240px;
  width: auto;
  max-width: 42%;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 0 rgba(61,42,36,0.08));
}
.comic-bubble {
  position: relative;
  flex: 1;
  background: #fff;
  border: 3px solid #3d2a24;
  border-radius: 22px;
  padding: 14px 16px 16px;
  margin-bottom: 28px;
  min-width: 0;
}
.comic-bubble:after {
  content: "";
  position: absolute;
  bottom: -14px;
  left: 28px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-right: 3px solid #3d2a24;
  border-bottom: 3px solid #3d2a24;
  transform: rotate(45deg);
}
.comic-panel.right .comic-bubble:after { left: auto; right: 28px; }
.comic-bubble .en { font-size: 17px; font-weight: 700; line-height: 1.45; margin: 0 0 6px; }
.comic-bubble .vi { margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 700px) {
  .comic-panel { min-height: 200px; }
  .comic-char { height: 180px; }
}

.sgk-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.book-stage {
  background: #efe6dc;
  border-radius: 16px;
  padding: 12px;
  min-height: 360px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(61, 42, 36, 0.08);
}
.flip-stage {
  position: relative;
  background:
    linear-gradient(180deg, rgba(62, 32, 12, 0.16) 0%, rgba(28, 14, 6, 0.28) 100%),
    url("../assets/ui/wood.jpg") center center / cover no-repeat;
  background-color: #6b3d1e;
  border-radius: 18px;
  padding: 28px 56px 16px;
  min-height: 420px;
  box-shadow: inset 0 0 0 1px rgba(92, 48, 18, 0.45), 0 14px 28px rgba(70, 35, 12, 0.22);
  overflow: hidden;
}
.flip-stage.zoomed { overflow: auto; }
.card:has(.flip-stage) { padding-bottom: 12px; }
.flip-host {
  width: min(100%, 1480px);
  margin: 0 auto;
  aspect-ratio: 1.46 / 1;
  min-height: 280px;
  height: auto;
  filter: drop-shadow(0 16px 22px rgba(40, 18, 6, 0.5));
}
.flip-stage.spread .flip-host {
  width: 100%;
}
.flip-page.flip-blank {
  background: #f3ebe3;
}
#flipbook { width: 100%; }
.flip-host .stf__parent {
  margin: 0 auto;
}
.flip-page,
.stf__item {
  background: #fff;
  overflow: hidden;
}
.stf__item img,
.stf__item canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  pointer-events: none;
}
.flip-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-58%);
  z-index: 6;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 248, 244, 0.92);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}
.flip-nav:hover { background: #fff; color: var(--peach); }
.flip-nav:disabled,
.flip-nav:disabled:hover {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--ink);
  background: rgba(255, 248, 244, 0.92);
  box-shadow: none;
  transform: translateY(-58%);
}
.flip-nav.prev { left: 8px; }
.flip-nav.next { right: 8px; }
.item.locked { opacity: 0.72; }
.flip-stage #sgk-msg {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 18px;
  text-align: center;
  color: #fff8ee;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(40, 18, 6, 0.65);
  pointer-events: none;
}
.flip-bar {
  justify-content: center;
  margin: 14px 0 0;
  padding: 8px 10px;
  background: rgba(255, 248, 244, 0.92);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.flip-bar .btn { flex: 0 0 auto; }
.flip-bar #pg { font-weight: 700; font-size: 13px; }
.flip-hint { text-align: center; margin-top: 10px; font-size: 13px; }
body.sgk-full { overflow: hidden; }
body.sgk-full #top { visibility: hidden; }
.flip-stage.is-full,
.flip-stage:fullscreen,
.flip-stage:-webkit-full-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  border-radius: 0;
  margin: 0;
  padding: 12px 52px 12px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.flip-stage.is-full .flip-host,
.flip-stage:fullscreen .flip-host,
.flip-stage:-webkit-full-screen .flip-host {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: auto;
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flip-stage.is-full #flipbook,
.flip-stage:fullscreen #flipbook,
.flip-stage:-webkit-full-screen #flipbook {
  width: 100%;
  height: 100%;
}
.flip-stage.is-full .flip-bar,
.flip-stage:fullscreen .flip-bar,
.flip-stage:-webkit-full-screen .flip-bar {
  flex: 0 0 auto;
  margin-top: 8px;
}
.book-stage code { font-size: 12px; background: #fff; padding: 1px 6px; border-radius: 6px; }
.dict-hero .dict-search {
  display: flex;
  gap: 8px;
  margin: 14px 0 10px;
}
.dict-search input {
  flex: 1;
  font-size: 17px;
  padding: 14px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
}
.dict-search input:focus { border-color: var(--peach); }
.dict-search .btn { flex: 0 0 auto; border-radius: 999px; padding: 12px 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip-word {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.chip-word:hover { background: #ffe1d4; }
.chip-word.phrase { background: #e7f6ee; color: #166534; }
.chip-word.phrase:hover { background: #d1fae5; }
.phrase-unit { margin-top: 16px; }
.phrase-unit h3 { font-size: 15px; margin-bottom: 8px; }
.phrase-unit h3 .muted { font-weight: 500; font-size: 13px; }
.phrase-grid .vocab-row { background: #f3fbf6; }
.az-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 12px;
}
.az-bar button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.az-bar button:hover, .az-bar button.on { background: #ffd4c2; color: #9a3412; }
.browse-list { margin-top: 10px; }
.ac-list {
  margin-top: 6px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ac-list button {
  display: flex;
  width: 100%;
  border: 0;
  background: #fff;
  padding: 10px 14px;
  text-align: left;
  gap: 8px;
  font-size: 14px;
}
.ac-list button:hover { background: var(--paper); }
.ac-list button span { color: var(--muted); }
.ac-list button.near b { color: var(--peach); }
.near-hint {
  background: #fff6e8;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--ink);
}
.dict-entry .hw {
  font-family: Fredoka, sans-serif;
  font-size: 32px;
  font-weight: 700;
}
.dict-entry .pos {
  color: #c45c3a;
  font-style: italic;
  font-weight: 700;
  margin-left: 8px;
}
.dict-entry .ipa { color: var(--muted); margin: 4px 0 10px; }
.dict-entry .sense { font-size: 16px; line-height: 1.5; margin-bottom: 12px; }
.hw-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.lesson-sec { margin: 18px 0; }
.lesson-sec h2 { color: var(--peach); }
.lesson-sec ul { padding-left: 18px; }
.vocab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grammar-box {
  background: #fff4ec;
  border-radius: 14px;
  padding: 14px 16px;
  line-height: 1.55;
  font-weight: 600;
}
.q-block { margin-bottom: 14px; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.book p {
  background: var(--cream);
  border-radius: 12px;
  padding: 10px;
  line-height: 1.7;
  user-select: text;
  border: 1px solid var(--line);
}
.explain-pop {
  background: #fff4d6;
  border-radius: 12px;
  padding: 10px;
  margin-top: 8px;
}
.ebook-quote {
  font-style: italic;
  color: var(--ink);
  margin: 4px 0 8px;
}
.ebook-ai { margin: 0; line-height: 1.5; }
#back-units { margin-bottom: 8px; }
.book.ebook p::selection { background: #ffd4c2; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 168px;
  padding-top: 28px;
}
.chart .col-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  cursor: default;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  border-radius: 8px 8px 0 0;
}
.chart .col-wrap:hover .col,
.chart .col-wrap.on .col { filter: brightness(1.08); }
.chart .col {
  display: block;
  font-style: normal;
  width: 100%;
  background: linear-gradient(#ffb347, var(--peach));
  border-radius: 8px 8px 0 0;
  min-height: 4px;
  pointer-events: none;
}
.chart.stars .col { background: linear-gradient(#fff1b8, var(--gold)); }
.chart .tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  padding: 5px 7px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
}
.chart .col-wrap:hover .tip,
.chart .col-wrap:focus-visible .tip { opacity: 1; }
.chart-readout {
  min-height: 1.4em;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.chart-readout.on { color: var(--ink); }
.axis { display: flex; gap: 4px; font-size: 10px; opacity: 0.7; }
.axis span { flex: 1; text-align: center; }

.board { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.board .item.me { background: #ffe8dc; border-color: var(--peach2); }
.badge {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--paper);
  font-size: 18px;
}
.badge.on { background: linear-gradient(#fff1b8, var(--gold)); }
.achieve-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.achieve-grid h2 .muted { font-family: "Be Vietnam Pro", sans-serif; font-size: 13px; font-weight: 600; }
.me-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 12px; }

#toast {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  z-index: 30;
  font-size: 13px;
  display: none;
}
#toast.show { display: block; }

.dev {
  position: fixed;
  right: 12px;
  bottom: 12px;
  background: #3d2a24;
  color: #fff6e4;
  border-radius: 12px;
  padding: 8px;
  font-size: 12px;
  max-width: 46%;
  z-index: 20;
}
.dev .row { margin-top: 6px; }
.dev .btn { background: #555; color: #fff; flex: 0 1 auto; }

.page-narrow { max-width: 480px; margin: 40px auto; }

@media (max-width: 900px) {
  .split, .hero, .me-grid, .charts, .achieve-grid, .book, .board, .play-grid, .arena-pick { grid-template-columns: 1fr; }
  .battle .fighter img { height: 88px; }
  #view { width: calc(100% - 24px); }
  #top { padding: 0 12px; }
  .hint-dock { right: 16px; }
  #nav button span:not(.ico) { display: none; }
  .flip-stage { padding: 16px 10px 12px; }
  .flip-host { min-height: 220px; }
  .flip-nav { width: 36px; height: 36px; font-size: 22px; }
  .flip-nav.prev { left: 2px; }
  .flip-nav.next { right: 2px; }
}
