/*
 * language.css — scoped to /language/ via the .lang-scope class on <html>.
 *
 * Aesthetic: "inked seal-paper". Warm rice-paper field, ink-warm-black type,
 * a single cinnabar accent used sparingly like a seal stamp. Characters are
 * the protagonists; Latin type stays small and restrained.
 *
 * Three faces:
 *   - Noto Serif TC : the only face that touches Hanzi; correct HK glyphs.
 *   - Fraunces      : Latin display (opsz 144). Editorial and slightly quirky.
 *   - IBM Plex Sans : body. IBM Plex Mono for Jyutping tone digits.
 */

.lang-scope {
  /* Always reserve the vertical scrollbar's space so the page never shifts
     sideways when content height changes (e.g. corpus search swapping the
     result list grows/shrinks the page and would otherwise toggle the
     scrollbar). */
  scrollbar-gutter: stable;

  /* Override base tokens only within /language/. RycaFin's slate/blue palette
     is otherwise untouched. */
  --paper: #f4ede2;
  --paper-deep: #ede3d3;
  --paper-soft: #faf5ec;
  --ink: #1a1410;
  --ink-2: #5b4f44;
  --ink-3: #8c7f72;
  --rule: #d8c9b1;
  --rule-soft: #e6d9c0;
  --seal: #b8462c;
  --seal-deep: #8c2f1d;
  --seal-wash: rgba(184, 70, 44, 0.07);
  --seal-glow: rgba(184, 70, 44, 0.18);
  --ok: #5c7a3e;
  --warn: #b07a2c;
  --shadow-paper:
    0 1px 0 rgba(0, 0, 0, 0.02), 0 2px 8px rgba(60, 40, 20, 0.04),
    0 12px 28px rgba(60, 40, 20, 0.05);
  --shadow-card: 0 14px 40px rgba(40, 25, 10, 0.08);

  --font-han: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --font-display: "Fraunces", "Iowan Old Style", "Georgia", serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", "Menlo", monospace;
}

.lang-scope body {
  background: var(--paper);
  background-image:
    radial-gradient(
      circle at 12% 18%,
      rgba(184, 70, 44, 0.025),
      transparent 40%
    ),
    radial-gradient(circle at 88% 78%, rgba(120, 80, 40, 0.04), transparent 50%);
  color: var(--ink);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "kern";
  font-size: 15px;
  line-height: 1.55;
}

/* A tactile paper grain. Pure CSS so we don't ship a noise PNG. */
.lang-scope body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent 0 2px,
      rgba(120, 80, 40, 0.012) 2px 3px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0 2px,
      rgba(120, 80, 40, 0.012) 2px 3px
    );
}

.lang-scope #app {
  position: relative;
  z-index: 1;
}

/* ── Top bar ───────────────────────────────────────── */

.lang-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}

.lang-bar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.lang-mark {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  font-variation-settings: "opsz" 14;
  letter-spacing: -0.01em;
}

.lang-mark-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--seal);
  color: #fbf6ec;
  font-family: var(--font-han);
  font-size: 16px;
  font-weight: 700;
  border-radius: 3px;
  transform: rotate(-2deg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
}

.lang-bar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 13.5px;
}

.lang-bar-link {
  color: var(--ink-2);
  padding: 6px 12px;
  border-radius: 4px;
  position: relative;
  transition: color 0.18s;
}

.lang-bar-link:hover {
  color: var(--ink);
}

.lang-bar-link.is-active {
  color: var(--ink);
  font-weight: 500;
}

.lang-bar-link.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 1px;
  height: 2px;
  background: var(--seal);
}

.lang-bar-back {
  color: var(--ink-3);
  font-size: 12.5px;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

.lang-bar-back:hover {
  color: var(--seal);
}

/* ── Page frame ────────────────────────────────────── */

.lang-page {
  max-width: 1080px;
  width: 80vw;
  margin: 0 auto;
  padding: 56px 32px 96px;
}

.lang-page--narrow {
  max-width: 760px;
}

/* ── Eyebrow + headline (used at top of hub + saved) ── */

.lang-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.lang-eyebrow::before {
  content: "";
  display: block;
  width: 24px;
  height: 1px;
  background: var(--seal);
}

.lang-headline {
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 144,
    "wght" 380,
    "SOFT" 30;
  font-size: clamp(42px, 6vw, 68px);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 16px 0 0;
  max-width: 18ch;
}

.lang-headline em {
  font-style: italic;
  font-variation-settings:
    "opsz" 144,
    "wght" 380,
    "SOFT" 100;
  color: var(--seal);
}

.lang-subhead {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink-2);
  margin-top: 14px;
  max-width: 54ch;
  line-height: 1.55;
}

/* ── Stat strip (hub) ──────────────────────────────── */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 44px 0 56px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.stat-cell {
  padding: 20px 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.stat-cell + .stat-cell {
  border-left: 1px solid var(--rule-soft);
  padding-left: 28px;
}

.stat-cell-num {
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 144,
    "wght" 360;
  font-size: 42px;
  line-height: 1;
  color: var(--ink);
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.02em;
}

.stat-cell-num.is-due {
  color: var(--seal);
}

.stat-cell-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── Continue learning hero (hub) ──────────────────── */

.continue-card {
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 40px 44px 36px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: end;
  position: relative;
  box-shadow: var(--shadow-paper);
}

/* A faint character mark in the corner, like a watermark on stationery */
.continue-card::after {
  content: "學";
  position: absolute;
  top: 24px;
  right: 32px;
  font-family: var(--font-han);
  font-size: 80px;
  color: var(--ink);
  opacity: 0.04;
  line-height: 1;
  pointer-events: none;
}

.continue-card-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}

.continue-card-title {
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 144,
    "wght" 380;
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  max-width: 16ch;
}

.continue-card-meta {
  color: var(--ink-2);
  font-size: 14px;
  margin-top: 12px;
  max-width: 38ch;
}

.continue-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--seal);
  color: #fbf6ec;
  padding: 14px 22px 14px 28px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition:
    background 0.18s,
    transform 0.12s,
    box-shadow 0.18s;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

.continue-cta:hover {
  background: var(--seal-deep);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--seal-glow);
}

.continue-cta:active {
  transform: translateY(0);
}

.continue-cta-arrow {
  font-family: var(--font-han);
  font-size: 16px;
  transform: translateY(-1px);
}

/* ── Section split (hub) ──────────────────────────── */

.hub-split {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  margin-top: 72px;
}

.hub-col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
  margin-bottom: 18px;
}

.hub-col-title {
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 36,
    "wght" 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.hub-col-link {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.hub-col-link:hover {
  color: var(--seal);
}

/* ── Word card (browse + saved) ────────────────────── */

.word-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Fixed-height scroll viewport for the browse column. The result set swings
   from 10 rows (random sample) to up to 20 (a search) — or down to an empty /
   dictionary-lookup state — and each row is ~100px tall. Without a fixed height
   that ~1170px swing reflows the whole lower half of the page on every search.
   Capping the panel and scrolling inside keeps the layout stable. */
.lang-browse-results {
  height: 660px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 24px;
  padding: 14px 4px 14px;
  border-bottom: 1px dotted var(--rule);
  cursor: pointer;
  transition: background 0.15s;
}

.word-row:hover {
  background: var(--seal-wash);
  border-bottom-color: var(--seal);
}

.word-row-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.word-row-han {
  font-family: var(--font-han);
  font-size: 28px;
  line-height: 1.15;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.word-row-jyut {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.word-row-eng {
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 14,
    "wght" 400;
  font-style: italic;
  font-size: 15.5px;
  color: var(--ink-2);
}

.word-row-tail {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--ink-3);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.word-row-saved {
  color: var(--seal);
  font-family: var(--font-han);
  font-size: 14px;
}

.word-row-speak,
.word-row-save {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  opacity: 0;
  transition:
    opacity 0.15s,
    border-color 0.18s,
    color 0.18s;
}

.word-row:hover .word-row-speak,
.word-row:hover .word-row-save {
  opacity: 1;
}

.word-row-speak:hover,
.word-row-save:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.word-row-save.is-saved {
  color: var(--seal);
  border-color: var(--seal);
  opacity: 1;
}

.word-row-speak:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.word-empty {
  padding: 56px 0;
  text-align: center;
  color: var(--ink-3);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 17px;
}

/* ── Search input (hub + saved + browse) ───────────── */

.lang-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper-soft);
  margin-bottom: 24px;
  transition: border-color 0.18s;
}

.lang-search:focus-within {
  border-color: var(--seal);
}

.lang-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}

.lang-search input::placeholder {
  color: var(--ink-3);
}

.lang-search-key {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  padding: 2px 6px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--paper);
}

/* ── HanziText component ───────────────────────────── */

.han-text {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  align-items: baseline;
}

.han-char {
  display: inline-block;
  font-family: var(--font-han);
  color: inherit;
  cursor: pointer;
  padding: 0 0.04em;
  border-radius: 2px;
  position: relative;
  transition:
    color 0.16s,
    background 0.16s,
    transform 0.12s;
}

.han-char:hover {
  color: var(--seal);
  background: var(--seal-wash);
}

.han-char.is-active {
  color: var(--seal);
}

.han-char.is-saved::after {
  content: "";
  position: absolute;
  bottom: 0.06em;
  left: 0.18em;
  right: 0.18em;
  height: 2px;
  background: var(--seal);
  opacity: 0.85;
}

.han-char-anim {
  animation: ink-drop 0.22s ease-out;
}

@keyframes ink-drop {
  0% {
    transform: scale(0.94);
    color: var(--seal-deep);
  }
  100% {
    transform: scale(1);
  }
}

/* ── Learn mode ────────────────────────────────────── */

.learn-frame {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 32px 96px;
}

.learn-progress {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 56px;
}

.learn-progress-bar {
  flex: 1;
  height: 2px;
  background: var(--rule-soft);
  position: relative;
  overflow: hidden;
}

.learn-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--seal);
  transition: width 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.learn-progress-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.learn-card {
  text-align: center;
  padding: 32px 16px 16px;
  position: relative;
}

.learn-kind {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 36px;
}

.learn-kind::before,
.learn-kind::after {
  content: "";
  display: block;
  width: 28px;
  height: 1px;
  background: var(--rule);
}

.learn-hanzi {
  font-family: var(--font-han);
  font-size: clamp(80px, 14vw, 132px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--ink);
  display: flex;
  justify-content: center;
  gap: 0.06em;
  flex-wrap: wrap;
}

.learn-jyut {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

.learn-jyut .tone {
  color: var(--seal);
  font-weight: 500;
}

.learn-speak {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.18s,
    color 0.18s;
}

.learn-speak:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.learn-eng {
  margin-top: 36px;
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 36,
    "wght" 400;
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.3;
}

.learn-eng.is-hidden {
  filter: blur(7px);
  cursor: pointer;
  user-select: none;
  transition: filter 0.25s;
}

.learn-eng.is-hidden:hover {
  filter: blur(2px);
}

.learn-divider {
  margin: 56px auto 36px;
  width: 1px;
  height: 36px;
  background: var(--rule);
  position: relative;
}

.learn-divider::before {
  content: "句";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-han);
  font-size: 13px;
  color: var(--ink-3);
  background: var(--paper);
  padding: 4px 0;
  line-height: 1;
}

.learn-sentence-han-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.learn-sentence-han {
  font-family: var(--font-han);
  font-size: 32px;
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.04em;
}

.learn-sentence-jyut {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
  letter-spacing: 0.04em;
}

.learn-sentence-eng {
  margin-top: 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-2);
  text-align: center;
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
}

.learn-grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 56px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.grade-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 12px;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  transition:
    background 0.16s,
    border-color 0.16s,
    transform 0.1s;
  font-family: var(--font-body);
}

.grade-btn:hover {
  border-color: var(--ink-2);
  background: var(--paper);
  transform: translateY(-1px);
}

.grade-btn[data-grade="1"]:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.grade-btn[data-grade="4"]:hover {
  border-color: var(--ok);
  color: var(--ok);
}

.grade-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.grade-key {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
}

.learn-done {
  text-align: center;
  padding: 96px 0;
}

.learn-done-han {
  font-family: var(--font-han);
  font-size: 80px;
  color: var(--seal);
  line-height: 1;
}

.learn-done-msg {
  margin-top: 28px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
}

.learn-done-sub {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: 14px;
}

.learn-done-cta {
  margin-top: 32px;
  display: inline-flex;
  gap: 14px;
}

/* ── Character popover ─────────────────────────────── */

.char-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.28);
  backdrop-filter: blur(2px);
  z-index: 80;
}

.char-popover {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(520px, 96vw);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -24px 0 60px rgba(40, 25, 10, 0.18);
}

.char-popover-head {
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  position: relative;
}

.char-popover-han {
  font-family: var(--font-han);
  font-size: 96px;
  line-height: 1;
  color: var(--ink);
}

.char-popover-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.char-popover-jyut {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}

.char-popover-jyut .tone {
  color: var(--seal);
  font-weight: 500;
}

.char-popover-gloss {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
  line-height: 1.3;
}

.char-popover-radicals {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.char-radical {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-han);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--paper-soft);
}

.char-save-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.16s;
}

.char-save-btn:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.char-save-btn.is-saved {
  background: var(--seal);
  color: #fbf6ec;
  border-color: var(--seal);
}

.char-popover-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.16s;
}

.char-popover-close:hover {
  color: var(--seal);
  background: var(--seal-wash);
}

.char-popover-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 40px;
}

.char-section-head {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.char-section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule-soft);
}

.char-section-head:first-child {
  margin-top: 0;
}

.char-compounds {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.char-compound {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px dotted var(--rule);
}

.char-compound-han {
  font-family: var(--font-han);
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.03em;
  min-width: 2.5em;
}

.char-compound-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.char-compound-jyut {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}

.char-compound-eng {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-2);
}

.char-example {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px dotted var(--rule);
}

.char-example-han-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-example-save {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.18s,
    color 0.18s;
  line-height: 1;
  flex-shrink: 0;
}

.char-example-save:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.char-example-save.is-saved {
  color: var(--seal);
  border-color: var(--seal);
}

.char-example-speak {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    border-color 0.18s,
    color 0.18s;
  line-height: 1;
  flex-shrink: 0;
}

.char-example-speak:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.char-example:last-child {
  border-bottom: none;
}

.char-example-han {
  font-family: var(--font-han);
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.char-example-jyut {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.char-example-eng {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 4px;
}

.char-empty {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-3);
  text-align: center;
  padding: 14px 0;
  font-size: 14px;
}

/* ── Saved page ────────────────────────────────────── */

.saved-count {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  background: var(--seal-wash);
  color: var(--seal);
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 999px;
  vertical-align: middle;
}

.saved-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.saved-char-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-soft);
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s;
  text-align: center;
  gap: 4px;
}

.saved-char-cell:hover {
  border-color: var(--seal);
  background: var(--seal-wash);
}

.saved-char-han {
  font-family: var(--font-han);
  font-size: 40px;
  line-height: 1;
  color: var(--ink);
}

.saved-char-jyut {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.saved-char-jyut .tone {
  color: var(--seal);
  font-weight: 500;
}

.saved-char-gloss {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.3;
}

.saved-sentence-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.saved-sentence {
  padding: 16px 0;
  border-bottom: 1px dotted var(--rule);
}

.saved-sentence:last-child {
  border-bottom: none;
}

.saved-sentence-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Word drawer ───────────────────────────────────── */

.word-drawer .char-popover-head {
  grid-template-columns: 1fr auto auto;
}

.word-drawer-han {
  font-family: var(--font-han);
  font-size: 52px;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.word-drawer-han .han-char {
  font-size: 52px;
  cursor: pointer;
}

.word-drawer-han .han-char:hover {
  color: var(--seal);
}

.word-drawer-pos {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-top: 4px;
  align-self: flex-start;
}

.word-drawer-eng {
  padding: 14px 32px 0;
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 36,
    "wght" 400;
  font-style: italic;
  font-size: 19px;
  color: var(--ink-2);
  line-height: 1.35;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 18px;
}

.word-drawer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.word-drawer-nav-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 16px;
  border-radius: 2px;
  cursor: pointer;
  transition:
    border-color 0.18s,
    color 0.18s;
}

.word-drawer-nav-btn:hover:not(:disabled) {
  border-color: var(--seal);
  color: var(--seal);
}

.word-drawer-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ── Vue transitions ───────────────────────────────── */

.popover-enter-active,
.popover-leave-active {
  transition:
    transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 0.26s;
}

.popover-enter-from,
.popover-leave-to {
  transform: translateX(40px);
  opacity: 0;
}

.backdrop-enter-active,
.backdrop-leave-active {
  transition: opacity 0.22s;
}

.backdrop-enter-from,
.backdrop-leave-to {
  opacity: 0;
}

.card-enter-active {
  transition:
    opacity 0.32s ease-out,
    transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card-leave-active {
  transition:
    opacity 0.18s,
    transform 0.18s ease-in;
  position: absolute;
  left: 0;
  right: 0;
}

.card-enter-from {
  opacity: 0;
  transform: translateY(14px);
}

.card-leave-to {
  opacity: 0;
  transform: translateY(-14px);
}

/* ── Staggered reveal on first hub paint ───────────── */

.reveal {
  opacity: 0;
  transform: translateY(8px);
  animation: lift 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

.reveal-1 {
  animation-delay: 0.05s;
}
.reveal-2 {
  animation-delay: 0.13s;
}
.reveal-3 {
  animation-delay: 0.22s;
}
.reveal-4 {
  animation-delay: 0.32s;
}
.reveal-5 {
  animation-delay: 0.42s;
}

@keyframes lift {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Toast (errors) ─────────────────────────────────── */

.lang-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  font-size: 13px;
  border-radius: 2px;
  z-index: 200;
  box-shadow: var(--shadow-card);
  font-family: var(--font-body);
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 760px) {
  .lang-page {
    padding: 36px 22px 64px;
  }
  .continue-card {
    grid-template-columns: 1fr;
    padding: 28px 24px;
    gap: 24px;
  }
  .continue-card::after {
    font-size: 56px;
    top: 14px;
    right: 18px;
  }
  .hub-split {
    grid-template-columns: 1fr;
    gap: 48px;
  }
  .stat-strip {
    grid-template-columns: 1fr;
  }
  .stat-cell + .stat-cell {
    border-left: none;
    border-top: 1px solid var(--rule-soft);
    padding-left: 4px;
  }
  .char-popover {
    width: 100vw;
  }
  .learn-grades {
    grid-template-columns: repeat(2, 1fr);
  }
  .lang-bar-inner {
    padding: 12px 20px;
  }
}

/* ── Mobile nav: two-row bar (logo+auth / nav-links) ── */

@media (max-width: 600px) {
  .lang-bar-inner {
    flex-wrap: wrap;
    padding: 10px 16px 0;
    gap: 0;
  }
  .lang-mark {
    flex: 1;
    order: 1;
  }
  .lang-bar-auth {
    order: 2;
    margin-left: auto;
  }
  .lang-bar-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0 8px;
    gap: 0;
    font-size: 12.5px;
  }
  .lang-bar-links::-webkit-scrollbar {
    display: none;
  }
  .lang-bar-link {
    white-space: nowrap;
    padding: 5px 8px;
    flex-shrink: 0;
  }
}

/* ── Hide v-cloak content until Vue mounts ─────────── */

.lang-scope [v-cloak] {
  display: none !important;
}

/* ── Dictionary lookup affordance ─────────────────── */

.lookup-affordance {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--rule-soft);
}

.lookup-label {
  font-size: 0.8rem;
  color: var(--text-3);
  flex: 1;
}

.lookup-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s,
    color 0.15s;
}

.lookup-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
}

.lookup-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.lookup-result {
  border-left: 2px solid var(--accent);
  margin-top: 4px;
}

.lookup-source {
  font-size: 0.7rem;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.lookup-miss {
  margin-top: 4px;
  font-style: italic;
}

/* ── Auth + Friends ──────────────────────────────────────────────────────── */

.lang-bar-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.auth-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--ink-3);
}

.auth-handle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-2);
}

.auth-link {
  font-size: 0.82rem;
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.auth-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink-3);
}

.friend-row .word-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--paper-deep);
}

.friend-name {
  font-weight: 500;
  color: var(--ink);
}

.friend-handle {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
}

.friend-state {
  font-size: 0.78rem;
  color: var(--ink-3);
  font-style: italic;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  opacity: 0.35;
  flex-shrink: 0;
}

.presence-dot.is-online {
  background: #3d8a4e;
  opacity: 1;
}

.friend-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 0.88rem;
  box-shadow: 0 8px 28px rgba(26, 20, 16, 0.35);
  z-index: 60;
  cursor: pointer;
}

/* ============================================================
   Games — catalogue + horse race
   ============================================================ */

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 48px;
}

.game-card {
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 28px 26px;
  box-shadow: var(--shadow-paper);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.game-card--soon {
  opacity: 0.55;
}

.game-card-han {
  font-family: var(--font-han);
  font-size: 3rem;
  line-height: 1;
  color: var(--seal);
}

.game-card--soon .game-card-han {
  color: var(--ink-3);
}

.game-card-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  margin: 0;
}

.game-card-blurb {
  color: var(--ink-2);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
  flex: 1;
}

.game-card-best {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.game-card-best-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.game-card-best-time {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--ink);
}

.game-card-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 6px;
}

.game-card-secondary {
  font-size: 0.88rem;
  color: var(--seal);
  text-decoration: none;
}

.game-card-secondary:hover {
  color: var(--seal-deep);
}

/* --- race page ------------------------------------------------ */

.race-frame {
  position: relative;
}

.race-timer {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 4px;
  margin: 8px auto 28px;
  font-family: var(--font-mono);
  color: var(--ink-3);
  transition: color 0.3s;
}

.race-timer.is-running {
  color: var(--ink);
}

.race-timer-value {
  font-size: 3.4rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.race-timer-unit {
  font-size: 1.3rem;
  color: var(--ink-3);
}

.race-idle {
  text-align: center;
  padding: 24px 0 60px;
}

.race-idle-han {
  font-family: var(--font-han);
  font-size: 4rem;
  color: var(--seal);
  margin-bottom: 12px;
}

.race-idle .lang-subhead {
  margin: 14px auto 26px;
  max-width: 480px;
}

.race-idle-best {
  font-size: 0.95rem;
  color: var(--ink-2);
  margin-bottom: 22px;
}

.race-notice {
  margin-top: 16px;
  color: var(--seal-deep);
  font-size: 0.88rem;
}

.race-track {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 36px;
}

.race-lane-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.race-lane-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow-paper);
}

.race-lane-course {
  position: relative;
  flex: 1;
  height: 40px;
  /* Leave the horse's own width at the end so 100% sits at the post. */
  margin-right: 36px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 calc(10% - 1px),
    var(--rule-soft) calc(10% - 1px) 10%
  );
  border-radius: 999px;
}

.race-horse {
  position: absolute;
  top: 50%;
  transform: translateY(-50%) scaleX(-1); /* face the finish line */
  font-family: var(--font-han);
  font-size: 1.7rem;
  line-height: 1;
  transition: left 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.race-horse--mine {
  color: var(--seal);
}

.race-horse--theirs {
  color: var(--ink-2);
}

.race-finish-post {
  font-size: 1.1rem;
  color: var(--seal-deep);
}

.race-question {
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  padding: 26px 26px 20px;
  box-shadow: var(--shadow-card);
}

.race-question-prompt {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.race-question-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.race-question-eng {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
}

.race-question-jyut {
  font-family: var(--font-mono);
  font-size: 1rem;
}

.race-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.race-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--ink);
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.1s;
  user-select: none;
}

.race-option:hover:not(.is-locked) {
  border-color: var(--seal);
  background: var(--seal-wash);
}

.race-option.is-locked {
  cursor: default;
}

.race-option.is-locked:not(.is-correct):not(.is-wrong) {
  opacity: 0.6;
}

.race-option-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.race-option-speak {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.race-option-speak:hover {
  color: var(--seal);
}

.race-explanation {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: race-reveal 0.2s ease-out;
}

.race-explanation.is-correct {
  border-color: var(--ok);
  background: rgba(92, 122, 62, 0.08);
}

.race-explanation.is-wrong {
  border-color: var(--seal);
  background: var(--seal-wash);
}

.race-explanation-verdict {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.race-explanation.is-correct .race-explanation-verdict {
  color: var(--ok);
}
.race-explanation.is-wrong .race-explanation-verdict {
  color: var(--seal);
}

.race-explanation-sentence {
  display: flex;
  align-items: center;
  gap: 10px;
}

.race-explanation-han {
  font-family: var(--font-han);
  font-size: 1.05rem;
  color: var(--ink);
  flex: 1;
  line-height: 1.5;
}

@keyframes race-reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.race-option.is-correct {
  border-color: var(--ok);
  background: rgba(92, 122, 62, 0.12);
}

.race-option.is-wrong {
  border-color: var(--seal);
  background: var(--seal-glow);
  animation: race-shake 0.3s;
}

@keyframes race-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.race-option-han {
  font-family: var(--font-han);
  font-size: 1.25rem;
  line-height: 1.4;
}

.race-option-jyut {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-2);
}

.race-question-footing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  min-height: 20px;
}

.race-question-footing .race-notice {
  margin-top: 0;
}

.race-forfeit {
  margin-left: auto;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.race-forfeit:hover {
  color: var(--seal-deep);
}

.race-countdown {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 237, 226, 0.88);
  backdrop-filter: blur(2px);
  z-index: 70;
}

.race-countdown-num {
  font-family: var(--font-han);
  font-size: 7rem;
  color: var(--seal);
  animation: race-count-pop 0.9s ease-out infinite;
}

@keyframes race-count-pop {
  0% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  35% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.race-finish {
  text-align: center;
  padding: 28px 0 60px;
}

.race-finish-han {
  font-family: var(--font-han);
  font-size: 4rem;
  color: var(--seal);
  margin-bottom: 8px;
}

.race-finish-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 500;
  margin: 0 0 8px;
}

.race-finish-best {
  color: var(--ink-2);
  margin-bottom: 24px;
}

.race-finish-best.is-new {
  color: var(--ok);
  font-weight: 600;
}

.race-finish-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

@media (min-width: 640px) {
  .race-options {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- cloze prompt ---------------------------------------------- */

.race-question-han {
  font-family: var(--font-han);
  font-size: 1.8rem;
  line-height: 1;
  color: var(--ink);
}

.race-speak {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--seal);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.race-speak:hover {
  border-color: var(--seal);
  background: var(--seal-wash);
}

.race-blank {
  color: var(--seal);
  font-weight: 600;
  letter-spacing: 2px;
  padding: 0 2px;
}

/* --- Connect Four ---------------------------------------------- */

.c4-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0 18px;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.c4-status-side {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.c4-status-turn {
  font-weight: 600;
  color: var(--ink);
}

.c4-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 12px 10px 8px;
  box-shadow: var(--shadow-paper);
  margin-bottom: 26px;
}

.c4-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 2px;
  border-radius: 8px;
  transition: background 0.15s;
}

.c4-col.is-open {
  cursor: pointer;
}

.c4-col.is-open:hover {
  background: var(--seal-wash);
}

.c4-col.is-selected {
  background: var(--seal-glow);
}

.c4-cell {
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.c4-coin {
  display: block;
  width: 82%;
  height: 82%;
  border-radius: 50%;
}

.c4-coin--mine {
  background: radial-gradient(circle at 32% 30%, #d4684b, var(--seal-deep));
}

.c4-coin--theirs {
  background: radial-gradient(circle at 32% 30%, #6b5e51, var(--ink));
}

.c4-coin--chip {
  width: 14px;
  height: 14px;
}

.c4-coin.is-new {
  animation: c4-drop 0.4s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes c4-drop {
  0% {
    transform: translateY(-220%);
    opacity: 0.6;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.c4-col-word {
  font-size: 0.66rem;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-2);
  min-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding: 2px 1px 0;
  border-top: 1px solid var(--rule-soft);
}

.c4-col.is-open .c4-col-word {
  color: var(--seal-deep);
  font-weight: 600;
}

.c4-board.is-waiting {
  opacity: 0.82;
}

.c4-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--paper-soft);
  border: 1px dashed var(--rule);
  border-radius: 10px;
  padding: 14px 18px;
  color: var(--ink-2);
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .c4-col-word {
    font-size: 0.56rem;
  }
}

/* ── Dialogues ──────────────────────────────────────────────────────────────
   Curated two-person scripts. A list of dialogue cards on the left, the reader
   on the right; the reader shows chat-style turns, a coverage line, and the
   featured-word chips (known vs. new). */

.dlg-signed-out {
  font-size: 14px;
  color: var(--ink-2, #5c5147);
}
.dlg-signed-out a {
  color: var(--seal);
  text-decoration: underline;
}

/* Home-page promo strip */
.dlg-promo {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 22px;
  padding: 20px 24px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  box-shadow: var(--shadow-paper);
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.15s ease,
    transform 0.15s ease;
}
.dlg-promo:hover {
  border-color: var(--seal);
  transform: translateY(-1px);
}
.dlg-promo-han {
  font-family: var(--font-han);
  font-size: 30px;
  color: var(--seal);
  flex: none;
}
.dlg-promo-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dlg-promo-title {
  font-family: var(--font-display);
  font-size: 17px;
}
.dlg-promo-meta {
  font-size: 13px;
  color: var(--ink-2, #5c5147);
}
.dlg-promo-arrow {
  margin-left: auto;
  color: var(--seal);
  font-size: 18px;
}

/* Two-column layout */
.dlg-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 28px;
  margin-top: 28px;
  align-items: start;
}

/* Category tabs */
.dlg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.dlg-tab {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
}
.dlg-tab:hover {
  border-color: var(--seal);
}
.dlg-tab.is-active {
  background: var(--seal);
  border-color: var(--seal);
  color: #fbf6ec;
}

/* Dialogue cards (list) */
.dlg-list {
  display: flex;
  flex-direction: column;
}
.dlg-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    transform 0.12s ease;
}
.dlg-card:hover {
  border-color: var(--seal);
  transform: translateY(-1px);
}
.dlg-card.is-active {
  border-color: var(--seal);
  box-shadow: 0 0 0 1px var(--seal) inset;
}
.dlg-card-han {
  font-family: var(--font-han);
  font-size: 22px;
  color: var(--seal);
  flex: none;
}
.dlg-card-title {
  font-family: var(--font-display);
  font-size: 15px;
}
.dlg-card-meta {
  font-size: 12px;
  color: var(--ink-2, #5c5147);
  margin-top: 2px;
}
.dlg-empty {
  font-size: 14px;
  color: var(--ink-2, #5c5147);
  padding: 12px 0;
}

/* Reader */
.dlg-reader {
  min-width: 0;
}
.dlg-reader-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-2, #5c5147);
  border: 1px dashed var(--rule);
  border-radius: 10px;
}
.dlg-reader-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.dlg-reader-title {
  font-family: var(--font-display);
  font-size: 22px;
}
.dlg-reader-han {
  font-family: var(--font-han);
  font-size: 16px;
  color: var(--seal);
  margin-top: 2px;
}
.dlg-play {
  flex: none;
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--seal);
  background: var(--seal);
  color: #fbf6ec;
  cursor: pointer;
}
.dlg-play:hover {
  background: var(--seal-deep);
}
.dlg-coverage {
  font-size: 13px;
  color: var(--ink-2, #5c5147);
  margin: 8px 0 18px;
}

/* Turns */
.dlg-turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dlg-turn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.dlg-turn--b {
  flex-direction: row-reverse;
}
.dlg-turn-who {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--paper-deep);
  color: var(--ink);
}
.dlg-turn--a .dlg-turn-who {
  background: var(--seal-wash);
  color: var(--seal-deep);
}
.dlg-turn-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.dlg-turn--b .dlg-turn-bubble {
  background: var(--paper-deep);
}
.dlg-turn.is-playing .dlg-turn-bubble {
  border-color: var(--seal);
  box-shadow: 0 0 0 1px var(--seal) inset;
}
.dlg-turn-hanzi {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-han);
  font-size: 19px;
}
.dlg-turn-speak {
  flex: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.55;
  padding: 0;
}
.dlg-turn-speak:hover {
  opacity: 1;
}
.dlg-turn-jyut {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--seal-deep);
  margin-top: 4px;
}
.dlg-turn-en {
  font-size: 13px;
  color: var(--ink-2, #5c5147);
  margin-top: 3px;
}

/* Featured-word chips */
.dlg-vocab {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
}
.dlg-vocab-label {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2, #5c5147);
  margin-bottom: 10px;
}
.dlg-vocab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.dlg-chip {
  font-family: var(--font-han);
  font-size: 15px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper-soft);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dlg-chip:not(:disabled):hover {
  border-color: var(--seal);
}
.dlg-chip.is-known {
  border-color: var(--ok);
  background: rgba(92, 122, 62, 0.08);
}
.dlg-chip.is-new {
  border-style: dashed;
}
.dlg-chip.is-plain {
  cursor: default;
  opacity: 0.6;
}
.dlg-chip-tick {
  color: var(--ok);
  font-size: 12px;
}

@media (max-width: 760px) {
  .dlg-layout {
    grid-template-columns: 1fr;
  }
  .dlg-turn-bubble {
    max-width: 88%;
  }
}

/* ── Menus (food-menu reader) ──────────────────────────
   Reuses the dialogue list/reader shell (.dlg-layout/.dlg-list/.dlg-tabs/
   .dlg-card/.dlg-reader…); the classes below style the menu-specific parts:
   the shorthand cheat-sheet link, the view toggle, the immersive menu card,
   the saveable list view, and the decoder cards. */

/* Left-rail link to the shorthand decoder */
.menu-decoder-link {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--seal-wash);
  border: 1px dashed var(--seal);
  border-radius: 10px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    background 0.12s ease;
}
.menu-decoder-link:hover {
  transform: translateY(-1px);
}
.menu-decoder-link.is-active {
  background: var(--seal);
}
.menu-decoder-link.is-active .menu-decoder-link-han,
.menu-decoder-link.is-active .menu-decoder-link-title,
.menu-decoder-link.is-active .menu-decoder-link-meta {
  color: #fbf6ec;
}
.menu-decoder-link-han {
  font-family: var(--font-han);
  font-size: 22px;
  color: var(--seal);
  flex: none;
}
.menu-decoder-link-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-decoder-link-title {
  font-family: var(--font-display);
  font-size: 15px;
}
.menu-decoder-link-meta {
  font-family: var(--font-han);
  font-size: 12px;
  color: var(--ink-2, #5c5147);
}

/* Menu / List view toggle */
.menu-view-toggle {
  flex: none;
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.menu-view-btn {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 16px;
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.menu-view-btn.is-active {
  background: var(--seal);
  color: #fbf6ec;
}

.menu-blurb {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2, #5c5147);
  margin: 6px 0 0;
}

/* Shared speak button */
.menu-speak {
  flex: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.55;
  padding: 0;
}
.menu-speak:hover {
  opacity: 1;
}

/* ── Immersive menu card ── */
.menu-card {
  margin-top: 16px;
  padding: 26px 26px 18px;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow-paper);
}
.menu-section + .menu-section {
  margin-top: 26px;
}
.menu-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--seal);
}
.menu-section-han {
  font-family: var(--font-han);
  font-size: 20px;
  color: var(--seal-deep);
  letter-spacing: 0.04em;
}
.menu-section-en {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2, #5c5147);
}
.menu-section-note {
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-2, #5c5147);
  margin-top: 6px;
}
.menu-item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dotted var(--rule);
}
.menu-item-han {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-han);
  font-size: 19px;
  color: var(--ink);
}
.menu-item-jyut {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--seal-deep);
  margin-top: 3px;
}
.menu-item-en {
  font-size: 13.5px;
  color: var(--ink-2, #5c5147);
  margin-top: 2px;
}
.menu-item-note {
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-3, #8c7f72);
  margin-top: 4px;
  max-width: 52ch;
}
.menu-item-price {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--seal-deep);
  align-self: start;
  padding-top: 2px;
}

/* ── Saveable list view ── */
.menu-listview {
  margin-top: 16px;
}
.menu-listview-head {
  font-family: var(--font-han);
  font-size: 14px;
  color: var(--seal-deep);
  letter-spacing: 0.04em;
  margin: 18px 0 4px;
}
.menu-listview-head:first-child {
  margin-top: 0;
}
.menu-listrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px dotted var(--rule);
}
.menu-listrow.is-openable {
  cursor: pointer;
}
.menu-listrow.is-openable:hover {
  background: var(--seal-wash);
}
.menu-listrow-han {
  font-family: var(--font-han);
  font-size: 18px;
}
.menu-listrow-jyut {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--seal-deep);
  margin-top: 2px;
}
.menu-listrow-en {
  font-size: 13px;
  color: var(--ink-2, #5c5147);
  margin-top: 1px;
}
.menu-listrow-tail {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-tag {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}
.menu-tag.is-known {
  color: var(--ok);
  background: rgba(92, 122, 62, 0.1);
}
.menu-tag.is-new {
  color: var(--seal-deep);
  border: 1px dashed var(--seal);
}
.menu-listview-hint {
  font-size: 12.5px;
  color: var(--ink-3, #8c7f72);
  margin-top: 14px;
}

/* ── Shorthand decoder ── */
.menu-decoder-group + .menu-decoder-group {
  margin-top: 24px;
}
.menu-decoder-group-label {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2, #5c5147);
  margin-bottom: 10px;
}
.menu-decoder-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.menu-decoder-card {
  padding: 14px 16px;
  background: var(--paper-soft);
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
}
.menu-decoder-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-han);
  font-size: 22px;
  color: var(--seal-deep);
}
.menu-decoder-card-jyut {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2, #5c5147);
}
.menu-decoder-card-meaning {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  margin-top: 8px;
}
.menu-decoder-card-eg {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dotted var(--rule);
}
.menu-decoder-card-eg-han {
  font-family: var(--font-han);
  font-size: 15px;
  color: var(--seal-deep);
}
.menu-decoder-card-eg-en {
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-2, #5c5147);
}

@media (max-width: 760px) {
  .menu-card {
    padding: 20px 18px 14px;
  }
  .menu-decoder-cards {
    grid-template-columns: 1fr;
  }
}

/* ── Guest + invite-by-link (games page) ─────────────── */
.auth-guest-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--seal-deep);
  background: var(--seal-wash);
  border: 1px solid var(--seal);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Invite-link host card */
.invite-host {
  margin-top: 22px;
  padding: 22px 24px;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow-paper);
}
.invite-host-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.invite-host-head .game-card-han {
  font-size: 30px;
  flex: none;
}
.invite-link-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.invite-link-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.invite-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-2, #5c5147);
  margin: 10px 0;
}
.invite-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--rule);
  border-top-color: var(--seal);
  border-radius: 50%;
  display: inline-block;
  animation: invite-spin 0.8s linear infinite;
}
@keyframes invite-spin {
  to {
    transform: rotate(360deg);
  }
}
.invite-guest-note {
  font-size: 12.5px;
  font-style: italic;
  color: var(--ink-3, #8c7f72);
  margin-top: 10px;
}

/* Invite-join landing (?join=…) */
.invite-join {
  text-align: center;
  padding: 48px 20px;
  max-width: 620px;
  margin: 0 auto;
}
.invite-join-han {
  font-family: var(--font-han);
  font-size: 64px;
  color: var(--seal);
  margin-bottom: 8px;
}
.invite-join-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 22px;
}
