:root {
  --soil: #163040;
  --soil-deep: #0b1822;
  --moss: #2a7a6a;
  --moss-bright: #3a9a86;
  --gold: #d98a3a;
  --gold-deep: #b86c22;
  --cream: #eef4f6;
  --card: #f7fbfc;
  --ink: #12202a;
  --muted: #5d7380;
  --claw: #c45c2a;
  --vowel: #d4533a;
  --magic: #3d6d8c;
  --sky: #2f7d8a;
  --ok: #2a7a6a;
  --line: rgba(18, 32, 42, 0.1);
  --shadow: 0 18px 40px rgba(8, 18, 26, 0.32);
  --font: "Outfit", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 12% 8%, rgba(232, 177, 74, 0.16), transparent 50%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(47, 106, 74, 0.35), transparent 55%),
    var(--soil-deep);
  color: var(--ink);
  font-family: var(--font);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.shell {
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 1600px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.03), transparent 30%),
    var(--soil);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.15rem;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent);
  border-bottom: 1px solid rgba(247, 241, 227, 0.08);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.brand small {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.brand h1 {
  font-size: clamp(1.05rem, 1.8vw, 1.45rem);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.pager-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: rgba(247, 241, 227, 0.85);
  font-size: 0.92rem;
}

.deck {
  min-height: 0;
  position: relative;
}

.page {
  display: none;
  height: 100%;
  padding: 0.75rem 1.1rem 0.35rem;
}

.page.is-on { display: block; }

.spread {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(340px, 1.08fr);
  gap: 0.9rem;
}

.art-col,
.talk-col {
  min-height: 0;
  height: 100%;
}

.art-col {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.art-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #2a1c12;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

.art-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.45s ease, transform 0.55s ease;
}

.art-frame img.is-on {
  opacity: 1;
  transform: scale(1);
}

.art-caption {
  color: rgba(247, 241, 227, 0.72);
  font-size: 0.82rem;
  font-weight: 650;
  text-align: center;
}

.talk-col {
  background: var(--card);
  border-radius: 18px;
  padding: 0.95rem 1.05rem 0.9rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(28, 36, 31, 0.05);
}

.kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--moss);
  margin-bottom: 0.35rem;
}

.beat { display: none; }
.beat.is-on { display: block; animation: rise 0.35s ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.en {
  font-size: clamp(1.22rem, 2.05vw, 1.62rem);
  line-height: 1.45;
  font-weight: 700;
  color: var(--ink);
}

.en em,
.bullet em {
  font-style: normal;
  color: var(--claw);
  background: rgba(196, 92, 42, 0.1);
  padding: 0 0.2em;
  border-radius: 6px;
}

.en strong { color: var(--moss); }

.zh {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.hint {
  margin-top: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-left: 4px solid var(--gold);
  background: rgba(232, 177, 74, 0.14);
  border-radius: 0 10px 10px 0;
  font-size: 0.88rem;
  font-weight: 650;
  color: #6a4d12;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding-top: 0.55rem;
  background: linear-gradient(180deg, rgba(255,250,241,0), var(--card) 28%);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 750;
  font-size: 0.95rem;
  padding: 0.62rem 0.95rem;
  border-radius: 999px;
  background: #e7eee8;
  color: var(--ink);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.gold { background: var(--gold); color: #3d2a05; }
.btn.moss { background: var(--moss); color: #fff; }
.btn.ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 1.5px rgba(247,241,227,0.28); }
.btn.speak {
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border-radius: 50%;
  background: #dceee3;
  font-size: 1rem;
}
.btn.speak.is-talking,
.en.is-talking,
[data-speak].is-talking {
  box-shadow: inset 0 0 0 2px var(--moss);
  background: #e8f6ee;
}
.line-speak {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}
.line-speak .en,
.line-speak .qbox,
.line-speak .big-word {
  flex: 1;
  min-width: 0;
}
.line-speak .btn.speak {
  flex: none;
  margin-top: 0.12rem;
}

.letters {
  display: grid;
  grid-template-columns: repeat(4, minmax(4.6rem, 1fr));
  gap: 0.55rem;
  margin-top: 0.9rem;
  max-width: 26rem;
}
.letters.letters-6 {
  grid-template-columns: repeat(6, minmax(3.2rem, 1fr));
  max-width: 38rem;
}
.boxes.boxes-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.jobs.jobs-5 { grid-template-columns: repeat(3, 1fr); }

.tile {
  width: auto;
  min-height: 6.1rem;
  border-radius: 14px;
  background: #efe7d6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  box-shadow: inset 0 0 0 2px rgba(28,36,31,0.06);
  transition: transform 0.18s ease, background 0.18s ease;
}

.tile .ipa { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.tile .ch { font-size: 2rem; line-height: 1; }
.tile.is-on { background: #fff; transform: translateY(-3px); box-shadow: 0 8px 18px rgba(28,36,31,0.12); }
.tile[data-kind="vowel"].is-on { background: #ffe8d8; }
.tile[data-kind="magic"].is-on { background: #ece4ff; }
.tile[data-kind="magic"] .ch { color: var(--magic); }
.tile[data-kind="vowel"] .ch { color: var(--vowel); }
.tile .tag {
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--magic);
}

.magic-note {
  margin-top: 0.85rem;
  display: none;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #f4efff, #fff);
  box-shadow: inset 0 0 0 1px rgba(107, 79, 214, 0.16);
}

.magic-note.is-on { display: block; }

.magic-note p {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.45;
}

.arrow-o {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  color: var(--vowel);
  font-weight: 800;
}

.bullets {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.bullet {
  display: none;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: #f4efe3;
  font-weight: 750;
  font-size: 1.05rem;
}

.bullet.is-on { display: flex; animation: rise 0.3s ease; }
.bullet b {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: var(--moss);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.feelings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.feel {
  display: none;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  background: #e8f4ee;
  font-weight: 750;
  font-size: 1rem;
}

.feel.is-on {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  animation: rise 0.3s ease;
}
.feel .btn.speak {
  flex: none;
  margin-top: 0.02rem;
}

.bridge {
  display: none;
  margin-top: 0.8rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #fff4d6;
  font-weight: 750;
  line-height: 1.45;
}

.bridge.is-on { display: block; }

.word-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0 0.7rem;
  flex-wrap: wrap;
}

.big-word {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.big-word.is-secret {
  color: var(--muted);
  letter-spacing: 0.28em;
}

.quote {
  margin-top: 0.8rem;
  padding: 0.75rem 0.85rem;
  border-left: 4px solid var(--moss);
  background: #eef6f0;
  border-radius: 0 12px 12px 0;
}

.quote p[lang="en"] {
  font-weight: 750;
  line-height: 1.5;
}

.sent.is-now {
  background: #fff3c4;
  border-radius: 6px;
  box-shadow: inset 0 -0.28em 0 rgba(232, 177, 74, 0.45);
}

.btn.ghost-ink {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(28, 36, 31, 0.16);
}

.actions .btn.is-on {
  box-shadow: inset 0 0 0 2px var(--moss);
}

.job-name { min-height: 1.2em; }

.wordlist button small {
  opacity: 0.72;
  font-size: 0.68rem;
  margin-right: 0.15rem;
}

.boxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.box {
  min-width: 0;
  min-height: 7.4rem;
  border-radius: 14px;
  background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(28,36,31,0.06) 28px), #fff;
  box-shadow: inset 0 0 0 2px rgba(28,36,31,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.3rem;
}

.box .letters-en {
  font-size: 1.35rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(6px);
  transition: 0.25s ease;
}

.box .ipa,
.box .map {
  opacity: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  line-height: 1.25;
}

.box.is-on .letters-en,
.box.is-on .ipa,
.box.is-on .map {
  opacity: 1;
  transform: none;
}

.box.is-on { background: #fff8e6; box-shadow: inset 0 0 0 2px rgba(232, 177, 74, 0.55); }
.box.is-stem.is-on { background: #e8f4ee; box-shadow: inset 0 0 0 2px rgba(47, 106, 74, 0.45); }

.word-pill {
  display: none;
  margin-top: 0.7rem;
  align-self: flex-start;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--moss);
  color: #fff;
  font-weight: 800;
}

.word-pill.is-on { display: inline-flex; }

.map-board {
  display: none;
  margin-top: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  background: #f3eee2;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.55;
}

.map-board.is-on { display: block; }
.map-board span { color: var(--vowel); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 1rem 0.7rem;
}

.dots {
  display: flex;
  gap: 0.4rem;
}

.dot {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: rgba(247,241,227,0.25);
  border: 0;
  cursor: pointer;
}

.dot.is-on { background: var(--gold); }

.bar-right,
.bar-left {
  display: flex;
  gap: 0.45rem;
  min-width: 9rem;
}

.bar-right { justify-content: flex-end; }

.sec-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sec-link {
  color: rgba(247,241,227,0.78);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 750;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
}
.sec-link.is-on, .sec-link:hover { background: rgba(232,177,74,0.2); color: var(--gold); }

.jobs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-top: 0.75rem; }
.job {
  border: 0;
  background: #f4efe3;
  border-radius: 14px;
  padding: 0.45rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.job img { width: 100%; aspect-ratio: 4/3; max-height: 14rem; object-fit: contain; background: #efe7d6; border-radius: 10px; display: block; }
#g-board .jobs { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); max-width: 56rem; }
.job b { display: block; margin-top: 0.35rem; font-size: 0.92rem; }
.job.is-on { box-shadow: inset 0 0 0 3px var(--gold); }
.job.is-pick, .btn.is-pick { box-shadow: inset 0 0 0 3px var(--moss); background: #e8f4ee; }
.job.is-dim { opacity: 0.42; }

.keys { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.keychip {
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: #efe7d6;
  font-weight: 750;
  font-size: 0.88rem;
}
.scramble { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }
.scramble button {
  font-family: inherit;
  font-weight: 750;
  border: 0;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(28,36,31,0.12);
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
}
.score-box {
  margin-top: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: #e8f4ee;
  font-weight: 800;
  font-size: 1.15rem;
}

.phase-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.phase {
  font-family: inherit;
  font-weight: 750;
  font-size: 0.78rem;
  border: 0;
  background: #efe7d6;
  border-radius: 999px;
  padding: 0.32rem 0.65rem;
  cursor: pointer;
}
.phase.is-on { background: var(--moss); color: #fff; }

.word-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.45rem 0; }

.score-card {
  display: none;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: #e8f4ee;
}
.score-card.is-on { display: flex; }
.score-num {
  min-width: 3.4rem;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--moss);
}
.score-card.is-good { background: #d9f3e4; }
.score-card.is-ok { background: #fff3c4; }
.score-card.is-ok .score-num { color: var(--gold-deep); }
.score-card.is-low { background: #ffe4d6; }
.score-card.is-low .score-num { color: var(--claw); }
.btn.is-rec {
  background: var(--claw);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(196, 92, 42, 0.22);
  animation: rec-pulse 1.1s ease-in-out infinite;
}
@keyframes rec-pulse {
  50% { box-shadow: 0 0 0 8px rgba(196, 92, 42, 0.08); }
}

.bg-thumbs,
.film-strip {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  flex: none;
  padding-bottom: 0.1rem;
}
.film-thumb,
.bg-thumb {
  flex: 0 0 4.4rem;
  border: 0;
  background: #2a1c12;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px transparent;
}
.film-thumb img,
.bg-thumb img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.film-thumb.is-on,
.bg-thumb.is-on { box-shadow: inset 0 0 0 2px var(--gold); }
.pic-cap {
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 0;
  background: linear-gradient(180deg, transparent 58%, rgba(12, 18, 16, 0.88) 92%);
  color: #fff;
  text-align: left;
  padding: 0.7rem 2.6rem 0.85rem 0.95rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
}
.pic-cap.is-open {
  background: linear-gradient(180deg, transparent 36%, rgba(12, 18, 16, 0.92) 78%);
}
.pic-cap #bg-cap-hint {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}
.pic-cap #bg-cap-hint[hidden],
.pic-cap .en[hidden] { display: none; }
.pic-cap .en {
  color: #fff;
  font-size: clamp(0.95rem, 1.5vw, 1.18rem);
  line-height: 1.4;
  max-width: 36rem;
}
.film-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 2rem;
  height: 2.4rem;
  border: 0;
  border-radius: 10px;
  background: rgba(15, 20, 18, 0.55);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.film-nav.prev { left: 0.45rem; }
.film-nav.next { right: 0.45rem; }
.film-dots {
  position: absolute;
  left: 0;
  right: 0;
  top: 0.5rem;
  bottom: auto;
  display: flex;
  justify-content: center;
  gap: 0.28rem;
  z-index: 5;
  pointer-events: none;
}
.film-dots span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
}
.film-dots span.is-on { background: var(--gold); }
.story-gate {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.7rem 0.8rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f6f1e6;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  min-height: 3.2rem;
}
.story-gate #bg-story-hint {
  color: var(--moss);
  font-weight: 800;
  font-size: 0.92rem;
}
.story-gate .story-body {
  font-size: 1.05rem;
  line-height: 1.45;
}
.event-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
}
#bg-arc {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--muted);
}
.event-chip {
  border: 0;
  background: #efe7d6;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 750;
  cursor: pointer;
}
.event-chip.is-on { background: var(--moss); color: #fff; }
.ask-overlay[hidden] { display: none !important; }
.ask-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 5.4rem 0.95rem 0.85rem;
  background: linear-gradient(180deg, transparent 6%, rgba(12, 18, 16, 0.38) 40%, rgba(12, 18, 16, 0.94) 78%);
  color: #fff;
}
.art-frame.is-ask img { object-position: center 22%; }
.ask-overlay .ask-count {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.25rem;
}
.ask-overlay .en {
  color: #fff;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  margin-bottom: 0.55rem;
}
.ask-overlay .zh { color: #efe7d6; margin-top: 0.4rem; }
.ask-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ask-overlay .btn {
  height: auto;
  min-height: 2.15rem;
  font-size: 0.82rem;
  padding: 0.38rem 0.7rem;
}
.grammar-lab { width: min(920px, 100%); }
.gram-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0.7rem;
}
.gram-tab {
  border: 0;
  background: #efe7d6;
  border-radius: 12px;
  padding: 0.35rem 0.65rem;
  font-family: inherit;
  font-weight: 750;
  cursor: pointer;
  text-align: left;
}
.gram-tab small {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
}
.gram-tab.is-on { background: var(--moss); color: #fff; }
.gram-tab.is-on small { color: #e8f4ee; }
.gram-tab.is-here { box-shadow: inset 0 0 0 2px var(--gold); }
.gram-marks {
  display: grid;
  gap: 0.4rem;
  margin: 0.35rem 0 0.7rem;
}
.gram-marks p {
  margin: 0;
  padding: 0.45rem 0.65rem;
  background: #fff3cc;
  border-radius: 10px;
}
.gram-marks b { display: block; color: var(--ink); }
.gram-marks span { display: block; color: var(--muted); font-weight: 650; font-size: 0.88rem; margin-top: 0.15rem; }
.gram-teach { margin: 0.15rem 0 0.55rem; }
.gram-source {
  margin: 0 0 0.7rem;
  padding: 0.55rem 0.7rem;
  background: #e8f4ee;
  border-left: 4px solid var(--moss);
  border-radius: 0 10px 10px 0;
  font-weight: 750;
  line-height: 1.45;
}
.gram-labline mark {
  display: inline;
  padding: 0.05em 0.15em;
  border-radius: 6px;
  font-weight: 800;
  background: #fff3cc;
}
.gram-labline mark small {
  display: inline-block;
  margin-left: 0.28em;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  font-weight: 800;
  vertical-align: 0.15em;
}
.gram-labline .mk-n { background: #e8f0ff; color: var(--sky); }
.gram-labline .mk-rel { background: #fff3cc; color: #8a5a10; }
.gram-labline .mk-ing { background: #fde8d8; color: var(--claw); }
.gram-parts, .gram-fns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0 0 0.75rem;
}
.gram-parts p, .gram-fn {
  margin: 0;
  padding: 0.55rem 0.65rem;
  background: #fff7e8;
  border-radius: 12px;
}
.gram-parts small, .gram-fn small {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
  font-weight: 800;
  margin-bottom: 0.2rem;
}
.gram-parts b, .gram-fn .en { display: block; font-weight: 800; }
.gram-parts span, .gram-fn span {
  display: block;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.86rem;
  margin-top: 0.2rem;
}
.gram-fn img {
  width: 100%;
  height: 7.2rem;
  object-fit: contain;
  background: #efe7d6;
  border-radius: 8px;
  margin: 0.25rem 0 0.4rem;
  display: block;
}
.gram-tab.gram-more { background: #e8f0ff; color: var(--sky); }

.gram-compare {
  margin: 0.2rem 0 0.85rem;
  padding: 0.7rem 0.75rem 0.8rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: inset 0 0 0 1.5px rgba(47, 106, 74, 0.16);
}
.gram-compare > .kicker { margin-bottom: 0.35rem; }
.gram-alts {
  margin: 0.65rem 0 0;
  padding: 0.65rem 0.7rem 0.75rem;
  background: #f4f7ff;
  border-radius: 14px;
}
.gram-alt-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.25rem 0 0.55rem; }
.gram-alt {
  border: 0;
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  color: var(--sky);
}
.gram-alt.is-on { background: var(--sky); color: #fff; }
.gram-alt-note {
  margin: 0.35rem 0 0;
  color: #3d5348;
  font-weight: 700;
  line-height: 1.5;
}

.gram-pic figcaption small {
  display: block;
  font-weight: 650;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.12rem;
}
.gram-shot {
  position: relative;
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: #2a1c12;
}
.gram-shot img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gram-shot-hint {
  position: absolute;
  left: 0.55rem;
  bottom: 0.45rem;
  color: var(--gold);
  font-weight: 800;
  font-size: 0.78rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.55);
}
.gram-pic.is-open .gram-shot-hint { display: none; }
.gram-score {
  font-weight: 800;
  color: var(--moss);
  margin: 0.2rem 0 0.45rem;
}
.gram-pics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}
.gram-pics.is-one { grid-template-columns: minmax(0, 22rem); }
.gram-pic {
  background: #f6f1e6;
  border-radius: 14px;
  overflow: hidden;
  padding: 0 0 0.7rem;
}
.gram-pic img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gram-pic figcaption {
  font-weight: 800;
  padding: 0.4rem 0.7rem 0.2rem;
}
.gram-pic .btn { margin: 0.25rem 0.7rem 0; display: inline-flex; width: calc(100% - 1.4rem); height: auto; border-radius: 12px; white-space: normal; text-align: left; line-height: 1.3; }
.gram-target { padding: 0.35rem 0.7rem 0; font-size: 1.05rem; }
.gram-words {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}
.gram-word {
  border: 0;
  background: #f6f1e6;
  border-radius: 12px;
  overflow: hidden;
  font-family: inherit;
  cursor: pointer;
  padding: 0 0 0.45rem;
}
.gram-word img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.gram-word b { display: block; padding: 0.3rem 0.4rem 0; font-size: 0.92rem; }
.gram-word small { display: block; padding: 0 0.4rem; color: var(--muted); }
.gram-opts { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.gram-opts .btn.is-right { background: var(--moss); color: #fff; }
.gram-opts .btn.is-wrong { background: #e8b4a0; }

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 20;
}
.drawer[hidden] { display: none; }
.drawer-card {
  width: min(720px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: var(--card);
  border-radius: 18px;
  padding: 1rem 1.1rem;
}
.art-frame.bg-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  border-radius: 0;
}
.credit { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.para {
  font-size: 1.15rem;
  line-height: 1.7;
  font-weight: 650;
}
.para mark { background: #ffe08a; padding: 0 0.15em; border-radius: 4px; }
.qbox { margin-top: 0.55rem; padding: 0.55rem 0.7rem; background: #f4efe3; border-radius: 10px; font-weight: 700; }
.word-drawer { position: relative; margin-bottom: 0.45rem; z-index: 4; }
.word-drawer-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-family: inherit;
  font-weight: 750;
  font-size: 0.92rem;
  color: var(--ink);
  background: #efe7d6;
  border: 0;
  border-radius: 12px;
  padding: 0.48rem 0.75rem;
  cursor: pointer;
  text-align: left;
}
.word-drawer-toggle .chev {
  color: var(--moss);
  font-size: 0.85rem;
  transition: transform 0.16s ease;
}
.word-drawer.is-open .word-drawer-toggle .chev { transform: rotate(180deg); }
.word-drawer-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  max-height: min(46vh, 22rem);
  overflow: auto;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.7rem 0.75rem;
  box-shadow: 0 14px 32px rgba(8, 14, 11, 0.16);
}
.word-drawer-kicker {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
  margin: 0.35rem 0 0.3rem;
}
.word-drawer-kicker:first-child { margin-top: 0; }
.wordlist { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.wordlist button {
  font-family: inherit;
  border: 0;
  background: #efe7d6;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font-weight: 750;
  cursor: pointer;
}
.wordlist button.is-on { background: var(--moss); color: #fff; }
.omit-line { line-height: 1.85; }
.omit-word {
  display: inline-block;
  font: inherit;
  font-weight: 750;
  padding: 0.05rem 0.28rem;
  margin: 0.08rem 0.04rem;
  border: 0;
  border-radius: 8px;
  background: #efe7d6;
  color: var(--ink);
  cursor: pointer;
}
.omit-word.is-off {
  background: #1c241f;
  color: #8ec8e8;
  min-width: 2.1em;
}
.blank {
  display: inline-block;
  min-width: 2.1em;
  letter-spacing: 0.08em;
  color: var(--sky);
  background: #eef6f8;
  border-radius: 6px;
  padding: 0 0.15em;
}
@media (max-width: 960px), (max-aspect-ratio: 4/5), (max-height: 640px) and (pointer: coarse) {
  html {
    height: auto;
    min-height: 100dvh;
    overflow-x: clip;
    overflow-y: auto;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  html, body {
    height: auto;
    min-height: 100dvh;
  }
  body {
    display: block;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
    overflow-x: clip;
  }
  .shell {
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 100dvh;
    border-radius: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
  }
  .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand pager"
      "nav nav";
    align-items: center;
    gap: 0.4rem 0.55rem;
    padding: 0.5rem 0.75rem 0.45rem;
  }
  .brand { grid-area: brand; min-width: 0; }
  .brand small {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .brand h1 {
    font-size: 1.05rem;
    line-height: 1.15;
  }
  .pager-meta {
    grid-area: pager;
    flex-shrink: 0;
    gap: 0.3rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .pager-meta #page-label { display: none; }
  #sec-nav-slot {
    grid-area: nav;
    min-width: 0;
    width: 100%;
  }
  .sec-nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.28rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.05rem 0 0.2rem;
  }
  .sec-nav::-webkit-scrollbar { display: none; }
  .sec-link {
    flex: 0 0 auto;
    font-size: 0.74rem;
    padding: 0.32rem 0.58rem;
  }
  .deck {
    flex: 1 1 auto;
    min-height: 0;
  }
  .deck,
  .page,
  .spread,
  .art-col,
  .talk-col {
    height: auto;
    min-width: 0;
  }
  .page { padding: 0.5rem 0.7rem 0.35rem; }
  .page.is-on { display: block; }
  #bg-page.page.is-on {
    display: flex;
    flex-direction: column;
  }
  .spread {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .art-frame {
    min-height: 0;
    max-height: min(34vh, 13.5rem);
    aspect-ratio: 4 / 3;
    flex: none;
  }
  body:has(#sh-text) .art-frame {
    max-height: min(28vh, 11rem);
    aspect-ratio: 16 / 10;
  }
  .art-frame.is-ask { max-height: min(48vh, 18rem); }
  .talk-col {
    overflow: visible;
    padding: 0.75rem 0.8rem 0.85rem;
  }
  .en {
    font-size: 1.08rem;
    overflow-wrap: break-word;
  }
  .para { font-size: 1.02rem; line-height: 1.6; }
  .jobs { grid-template-columns: 1fr; }
  .gram-pics, .gram-words, .gram-parts, .gram-fns { grid-template-columns: 1fr; }
  .feelings { grid-template-columns: 1fr; }
  .letters { grid-template-columns: repeat(4, minmax(3.2rem, 1fr)); }
  .letters.letters-6 {
    grid-template-columns: repeat(3, minmax(3.2rem, 1fr));
    max-width: none;
  }
  .boxes { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .phase-rail { gap: 0.28rem; }
  .phase {
    font-size: 0.72rem;
    padding: 0.28rem 0.5rem;
  }
  .omit-line {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .omit-word.is-off,
  .blank { min-width: 1.35em; }
  .actions {
    position: static;
    margin-top: 0.65rem;
  }
  .ask-overlay { padding: 2.6rem 0.7rem 0.7rem; }
  .bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    background: var(--soil);
    z-index: 6;
  }
  .bar-left,
  .bar-right {
    min-width: 0;
    gap: 0.3rem;
  }
  .bar-right { flex-wrap: wrap; }
  .bar .btn {
    font-size: 13px;
    padding: 8px 11px;
    min-height: 34px;
  }
  .dots { justify-content: center; }
  #sclass-tts-settings {
    bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px));
  }
  html {
    scroll-padding-bottom: calc(4.8rem + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-height: 500px) and (pointer: coarse) {
  .art-frame,
  body:has(#sh-text) .art-frame {
    max-height: min(18vh, 5.2rem);
    aspect-ratio: 16 / 9;
  }
  .art-caption { display: none; }
  .kicker { margin-bottom: 0.12rem; }
  .phase-rail { margin-bottom: 0.28rem; gap: 0.2rem; }
  .hint { margin-top: 0.28rem; padding: 0.28rem 0.45rem; font-size: 0.76rem; }
  .talk-col { padding: 0.5rem 0.7rem 0.65rem; }
  .page { padding: 0.3rem 0.55rem 0.2rem; }
  .bar,
  .studio-bar { position: static; }
}

/* games.html 不用 16:9 shell，避免配图和卡片被裁切 */
html:has(body.games-app),
html:has(body.games-app) body,
body.games-app {
  height: auto;
  min-height: 100dvh;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.gram-kind { font-size: 0.75rem; font-weight: 800; color: #6b4fd6; margin-right: 0.35rem; }
.gram-write { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.45rem; }
.gram-write .gram-bank { flex: 1 0 100%; margin: 0; font-weight: 750; color: #2f6a4a; }
.gram-write-in {
  flex: 1 1 12rem;
  min-width: 8rem;
  font: inherit;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  border: 1.5px solid rgba(47,106,74,0.35);
  background: #fff;
  color: inherit;
}
.gram-write-in.is-right { border-color: #2f6a4a; background: #e7f6ee; }
.gram-write-in.is-wrong { border-color: #c45c2a; background: #fff1ea; }
