/* ==========================================================================
   Game to Learn — design system
   Single stylesheet, no framework, no build step.
   Dark theme is the default; light theme via prefers-color-scheme.
   ========================================================================== */

:root {
  --bg: #0b0d14;
  --bg-elev: #11141d;
  --bg-elev-2: #171b26;
  --surface: #141824;
  --surface-hover: #1b2030;
  --border: #242a3a;
  --border-strong: #313850;

  --text: #e9ecf5;
  --text-dim: #9aa3bd;
  --text-faint: #6b7490;

  --brand: #6b7cff;
  --brand-soft: #8b98ff;
  --brand-bg: rgba(107, 124, 255, 0.13);
  --accent: #ffb454;
  --accent-bg: rgba(255, 180, 84, 0.13);
  --teal: #34d3b8;
  --teal-bg: rgba(52, 211, 184, 0.13);
  --rose: #ff6b8a;
  --rose-bg: rgba(255, 107, 138, 0.13);
  --violet: #b78bff;
  --violet-bg: rgba(183, 139, 255, 0.13);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 6px 24px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.7);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji", "Twemoji Mozilla", sans-serif;

  --maxw: 1180px;
  --gutter: 24px;
  --header-h: 64px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fc;
    --bg-elev: #ffffff;
    --bg-elev-2: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f4f6fb;
    --border: #e4e8f2;
    --border-strong: #d3d9e8;

    --text: #131725;
    --text-dim: #5a6280;
    --text-faint: #8b93ab;

    --brand: #4051e8;
    --brand-soft: #3242cf;
    --brand-bg: rgba(64, 81, 232, 0.08);
    --accent: #c2710c;
    --accent-bg: rgba(194, 113, 12, 0.09);
    --teal: #0d8f7c;
    --teal-bg: rgba(13, 143, 124, 0.09);
    --rose: #d6336c;
    --rose-bg: rgba(214, 51, 108, 0.08);
    --violet: #7048c8;
    --violet-bg: rgba(112, 72, 200, 0.09);

    --shadow-sm: 0 1px 2px rgba(16, 24, 48, 0.06);
    --shadow: 0 6px 24px -10px rgba(16, 24, 48, 0.18);
    --shadow-lg: 0 24px 60px -20px rgba(16, 24, 48, 0.22);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(107, 124, 255, 0.14), transparent 60%),
    radial-gradient(760px 460px at 92% 4%, rgba(183, 139, 255, 0.11), transparent 62%),
    radial-gradient(700px 420px at 50% 100%, rgba(52, 211, 184, 0.07), transparent 65%);
}

@media (prefers-color-scheme: light) {
  body::before {
    background:
      radial-gradient(900px 500px at 12% -10%, rgba(64, 81, 232, 0.09), transparent 60%),
      radial-gradient(760px 460px at 92% 4%, rgba(112, 72, 200, 0.07), transparent 62%),
      radial-gradient(700px 420px at 50% 100%, rgba(13, 143, 124, 0.05), transparent 65%);
  }
}

main {
  position: relative;
  z-index: 1;
}

img {
  max-width: 100%;
  display: block;
}

/* Emoji are load-bearing here — they are the pictures in every vocabulary
   drill. Pin an explicit colour-emoji stack so a system without the default
   fallback does not render them as tofu boxes. */
.scene-icon,
.demo-opt,
.opt-emoji,
.line-avatar,
.w-emoji,
.hero-stat .n {
  font-family: var(--font-emoji);
}

.w-emoji,
.opt-emoji {
  font-variant-emoji: emoji;
}

a {
  color: var(--brand-soft);
  text-decoration: none;
  transition: color 0.16s var(--ease);
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.022em;
  margin: 0 0 0.5em;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.035em;
}

h2 {
  font-size: clamp(1.5rem, 3.2vw, 2.2rem);
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.4rem);
}

p {
  margin: 0 0 1.1em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--brand-bg);
  padding: 0.15em 0.42em;
  border-radius: 5px;
  color: var(--brand-soft);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

::selection {
  background: var(--brand);
  color: #fff;
}

/* ---------- Layout ---------- */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.wrap-narrow {
  max-width: 760px;
}

.section {
  padding: clamp(48px, 8vw, 92px) 0;
}

.section-tight {
  padding: clamp(34px, 5vw, 56px) 0;
}

.stack > * + * {
  margin-top: 1rem;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.muted {
  color: var(--text-dim);
}

.faint {
  color: var(--text-faint);
}

.center {
  text-align: center;
}

.lead {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 68ch;
}

.small {
  font-size: 0.875rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: var(--maxw);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.06rem;
  color: var(--text);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  display: grid;
  place-items: center;
  font-size: 15px;
  box-shadow: 0 3px 12px -3px rgba(107, 124, 255, 0.7);
  flex-shrink: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav a[aria-current="page"] {
  color: var(--brand-soft);
  background: var(--brand-bg);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-toggle,
.icon-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s var(--ease);
}

.lang-toggle:hover,
.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-hover);
}

.lang-toggle .globe {
  font-size: 0.95rem;
  line-height: 1;
}

.xp-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-bg);
  border: 1px solid rgba(255, 180, 84, 0.28);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.xp-chip .lvl {
  font-weight: 600;
  opacity: 0.85;
}

.menu-btn {
  display: none;
  width: 36px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.nav-scrim {
  display: none;
}

@media (max-width: 900px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 14px var(--gutter) 22px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  }

  .nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav a {
    padding: 11px 12px;
    font-size: 0.98rem;
  }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s var(--ease);
    z-index: 90;
  }

  .nav-scrim.open {
    opacity: 1;
    pointer-events: auto;
  }

  .xp-chip {
    display: none;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.14s var(--ease), box-shadow 0.14s var(--ease),
    background 0.14s var(--ease), border-color 0.14s var(--ease);
  line-height: 1.3;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 22px -10px rgba(107, 124, 255, 0.9);
}

.btn-primary:hover {
  color: #fff;
  background: var(--brand-soft);
  box-shadow: 0 12px 28px -10px rgba(107, 124, 255, 1);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.btn-accent {
  background: var(--accent);
  color: #1a1206;
}

.btn-accent:hover {
  color: #1a1206;
  filter: brightness(1.08);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.card-link {
  display: block;
  color: inherit;
}

.card-link:hover {
  color: inherit;
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

/* Scene card */
.scene-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  color: inherit;
}

.scene-card::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: var(--scene-color, var(--brand));
  opacity: 0.14;
  filter: blur(26px);
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}

.scene-card:hover {
  transform: translateY(-4px);
  border-color: var(--scene-color, var(--brand));
  box-shadow: var(--shadow);
  color: inherit;
}

.scene-card:hover::after {
  opacity: 0.24;
}

.scene-icon {
  font-size: 2.1rem;
  line-height: 1;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: color-mix(in srgb, var(--scene-color, var(--brand)) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--scene-color, var(--brand)) 30%, transparent);
}

.scene-card h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.scene-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.93rem;
}

.scene-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

/* ---------- Badges & pills ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-brand {
  background: var(--brand-bg);
  color: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
}

.badge-accent {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.badge-teal {
  background: var(--teal-bg);
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 30%, transparent);
}

.badge-rose {
  background: var(--rose-bg);
  color: var(--rose);
  border-color: color-mix(in srgb, var(--rose) 30%, transparent);
}

.badge-violet {
  background: var(--violet-bg);
  color: var(--violet);
  border-color: color-mix(in srgb, var(--violet) 30%, transparent);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-soft);
  margin-bottom: 14px;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

/* ---------- Hero ---------- */

.hero {
  padding: clamp(56px, 9vw, 108px) 0 clamp(40px, 6vw, 72px);
  position: relative;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: clamp(30px, 5vw, 60px);
  align-items: center;
}

@media (max-width: 940px) {
  .hero-inner {
    grid-template-columns: 1fr;
  }
}

.hero h1 {
  margin-bottom: 20px;
}

.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand-soft), var(--violet) 45%, var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .lead {
  font-size: 1.12rem;
  margin-bottom: 28px;
}

.hero-stats {
  display: flex;
  gap: 28px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.hero-stat .n {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.hero-stat .l {
  font-size: 0.8rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Hero device mock */
.hero-demo {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-demo::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--violet), var(--teal));
}

.demo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.demo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.demo-title {
  margin-left: 6px;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-weight: 600;
}

.demo-word {
  text-align: center;
  padding: 22px 10px 18px;
}

.demo-word .term {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.demo-word .zh {
  font-size: 1.15rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.demo-word .py {
  font-size: 0.85rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.demo-opts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.demo-opt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 8px;
  text-align: center;
  font-size: 1.9rem;
  transition: all 0.16s var(--ease);
}

.demo-opt.hit {
  border-color: var(--teal);
  background: var(--teal-bg);
  transform: scale(1.04);
}

.demo-foot {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.demo-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.demo-bar i {
  display: block;
  height: 100%;
  width: 62%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

/* ---------- Section headings ---------- */

.section-head {
  max-width: 720px;
  margin-bottom: 36px;
}

.section-head p {
  color: var(--text-dim);
  font-size: 1.04rem;
  margin-bottom: 0;
}

/* ---------- Word table ---------- */

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.word-table th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
}

.word-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.word-table tr:last-child td {
  border-bottom: 0;
}

.word-table tbody tr:hover {
  background: var(--surface-hover);
}

.w-en {
  font-weight: 650;
}

.w-py {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.w-emoji {
  font-size: 1.3rem;
  text-align: center;
  width: 52px;
}

.pos-tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-faint);
  white-space: nowrap;
}

.speak-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 0.86rem;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}

.speak-btn:hover {
  color: var(--brand-soft);
  border-color: var(--brand);
  background: var(--brand-bg);
}

.speak-btn.playing {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; }
}

/* ---------- Data table (grammar) ---------- */

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 560px;
}

.data-table caption {
  caption-side: top;
  text-align: left;
  padding: 16px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 700;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table td:first-child {
  font-weight: 620;
}

/* ---------- Feature list ---------- */

.feature {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.feature-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: var(--brand-bg);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
}

.feature h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.feature p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* ---------- Steps ---------- */

.steps {
  counter-reset: step;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.step {
  position: relative;
  padding: 26px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: -14px;
  left: 22px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px -4px rgba(107, 124, 255, 0.8);
}

.step h3 {
  margin: 8px 0 6px;
  font-size: 1.05rem;
}

.step p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.93rem;
}

/* ---------- Prose (article) ---------- */

.prose {
  max-width: 74ch;
}

/* Two-column editorial layout: narrative on the left, a sticky reference
   rail on the right. Keeps long-form sections from stranding half the
   viewport as empty space on wide screens. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.85fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}

@media (max-width: 960px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.split-rail {
  position: sticky;
  top: calc(var(--header-h) + 22px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 960px) {
  .split-rail {
    position: static;
  }
}

.rail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.rail-card h4 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 14px;
  font-weight: 700;
}

.rail-facts {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.rail-fact {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.rail-fact:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rail-fact .k {
  color: var(--text-dim);
}

.rail-fact .v {
  font-weight: 700;
  text-align: right;
}

.rail-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail-links a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s var(--ease);
}

.rail-links a:hover {
  color: var(--text);
  border-color: var(--border-strong);
  transform: translateX(2px);
}

.prose h2 {
  margin-top: 2.4em;
  margin-bottom: 0.6em;
  font-size: 1.5rem;
}

.prose h3 {
  margin-top: 1.9em;
  margin-bottom: 0.5em;
  font-size: 1.16rem;
}

.prose p,
.prose li {
  color: var(--text-dim);
}

.prose strong {
  color: var(--text);
  font-weight: 650;
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
  margin: 0 0 1.2em;
}

.prose li {
  margin-bottom: 0.5em;
}

.prose li::marker {
  color: var(--brand);
}

.quote-block {
  border-left: 3px solid var(--brand);
  padding: 4px 0 4px 20px;
  margin: 1.6em 0;
  color: var(--text);
  font-style: italic;
}

.note-block {
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 1.5em 0;
}

.note-block p:last-child {
  margin-bottom: 0;
}

.note-block .note-title {
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Dialogue ---------- */

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

.line {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.16s var(--ease);
}

.line:hover {
  border-color: var(--border-strong);
}

.line-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}

.line-body {
  flex: 1;
  min-width: 0;
}

.line-speaker {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 3px;
}

.line-en {
  font-weight: 550;
  margin-bottom: 2px;
}

.line-zh {
  color: var(--text-dim);
  font-size: 0.93rem;
}

/* ---------- Story ---------- */

.story-body p {
  font-size: 1.03rem;
  line-height: 1.85;
}

.story-body p:first-of-type::first-letter {
  font-size: 3.1rem;
  font-weight: 800;
  float: left;
  line-height: 0.86;
  padding: 6px 12px 0 0;
  color: var(--brand-soft);
}

/* ---------- Game shell ---------- */

.game-shell {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: clamp(18px, 3vw, 32px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--game-color, var(--brand)), transparent 70%);
}

.game-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.game-round {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.game-progress {
  flex: 1;
  min-width: 120px;
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.game-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--game-color, var(--brand)), var(--teal));
  transition: width 0.3s var(--ease);
}

.game-score {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.game-timer {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--rose);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}

.game-prompt {
  text-align: center;
  padding: 12px 0 22px;
}

.game-prompt .q-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.game-prompt .q-main {
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.game-prompt .q-sub {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 1rem;
}

.game-prompt .q-py {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.game-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.game-options.two {
  grid-template-columns: repeat(2, 1fr);
}

.opt {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  cursor: pointer;
  text-align: center;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  transition: all 0.16s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 78px;
  justify-content: center;
}

.opt:hover:not(.locked) {
  border-color: var(--game-color, var(--brand));
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.opt .opt-emoji {
  font-size: 2rem;
  line-height: 1;
}

.opt .opt-py {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}

.opt.correct {
  border-color: var(--teal);
  background: var(--teal-bg);
  color: var(--teal);
}

.opt.wrong {
  border-color: var(--rose);
  background: var(--rose-bg);
  color: var(--rose);
}

.opt.locked {
  cursor: default;
}

.opt.dim {
  opacity: 0.35;
}

/* Type-answer */
.type-answer {
  display: flex;
  gap: 10px;
  max-width: 460px;
  margin: 0 auto;
}

.type-answer input {
  flex: 1;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.16s var(--ease);
}

.type-answer input:focus {
  border-color: var(--game-color, var(--brand));
}

.type-answer input.correct {
  border-color: var(--teal);
  background: var(--teal-bg);
}

.type-answer input.wrong {
  border-color: var(--rose);
  background: var(--rose-bg);
}

/* Word tiles (sentence builder) */
.tile-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.tile {
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.tile:hover:not(:disabled) {
  border-color: var(--game-color, var(--brand));
  transform: translateY(-2px);
}

.tile.used {
  opacity: 0.28;
  pointer-events: none;
}

.tile-slot {
  min-height: 58px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.tile-slot .tile {
  border-style: solid;
  border-color: var(--game-color, var(--brand));
  background: var(--game-color, var(--brand));
  color: #fff;
}

.tile-slot .slot-empty {
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* Match pairs grid */
.pairs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 11px;
}

.pair-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  min-height: 92px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
}

.pair-card:hover:not(.locked) {
  border-color: var(--game-color, var(--brand));
}

.pair-card .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: var(--radius);
  backface-visibility: hidden;
}

.pair-card .back {
  background: var(--bg-elev-2);
  color: var(--text-faint);
  font-size: 1.6rem;
  border: 1.5px dashed var(--border-strong);
}

.pair-card.flipped .back {
  display: none;
}

.pair-card:not(.flipped) .front {
  display: none;
}

.pair-card.matched {
  border-color: var(--teal);
  background: var(--teal-bg);
  opacity: 0.6;
  pointer-events: none;
}

.pair-card.matched::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 9px;
  color: var(--teal);
  font-weight: 800;
}

/* Feedback banner */
.feedback {
  margin-top: 18px;
  padding: 13px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  display: none;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.feedback.show {
  display: flex;
  animation: slideUp 0.24s var(--ease);
}

.feedback.ok {
  background: var(--teal-bg);
  border: 1px solid color-mix(in srgb, var(--teal) 34%, transparent);
  color: var(--teal);
}

.feedback.no {
  background: var(--rose-bg);
  border: 1px solid color-mix(in srgb, var(--rose) 34%, transparent);
  color: var(--rose);
}

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

/* Results */
.results {
  text-align: center;
  padding: 22px 0 8px;
}

.results .big-score {
  font-size: 3.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(120deg, var(--brand-soft), var(--teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.results .verdict {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 8px 0 4px;
}

.results .sub {
  color: var(--text-dim);
  margin-bottom: 20px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ---------- Progress page ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.stat-box .n {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  background: linear-gradient(120deg, var(--brand-soft), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-box .l {
  font-size: 0.78rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin-top: 4px;
}

.level-track {
  margin: 24px 0;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.level-track .lv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.level-track .lv-num {
  font-weight: 800;
  font-size: 1.15rem;
}

.word-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.wp-chip {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wp-chip:hover {
  border-color: var(--border-strong);
}

.wp-chip.mastered {
  background: var(--teal-bg);
  border-color: color-mix(in srgb, var(--teal) 32%, transparent);
  color: var(--teal);
}

.wp-chip.learning {
  background: var(--accent-bg);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  color: var(--accent);
}

.wp-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

/* ---------- Vocabulary browser ---------- */

.vocab-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.94rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--brand);
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.6;
  pointer-events: none;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.filter-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.filter-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---------- FAQ ---------- */

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}

.faq-item summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 620;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  transition: background 0.15s var(--ease);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary:hover {
  background: var(--surface-hover);
}

.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--brand-soft);
  font-weight: 400;
  flex-shrink: 0;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item .faq-body {
  padding: 0 20px 18px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 56px 0 32px;
  margin-top: 60px;
  position: relative;
  z-index: 1;
  background: color-mix(in srgb, var(--bg-elev) 45%, transparent);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: 32px;
}

@media (max-width: 860px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.footer-brand p {
  color: var(--text-dim);
  font-size: 0.9rem;
  max-width: 34ch;
  margin-top: 14px;
}

.footer-col h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer-col a:hover {
  color: var(--brand-soft);
}

.footer-bottom {
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--text-faint);
}

.footer-bottom a {
  color: var(--text-faint);
}

.footer-bottom a:hover {
  color: var(--brand-soft);
}

/* ---------- Utility ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 1001;
  background: var(--brand);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  left: 12px;
  color: #fff;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 550;
}

.callout {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 26px;
}

.callout-accent {
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-bg);
}

.callout-title {
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

@media print {
  .site-header,
  .site-footer,
  .no-print,
  .game-shell {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  body::before {
    display: none;
  }

  .print-only {
    display: block !important;
  }

  .word-table th,
  .word-table td {
    border-color: #ccc;
  }
}

.print-only {
  display: none;
}
