 /* ── Design Tokens ──────────────────────────────────── */
    :root, [data-theme="light"] {
      --color-bg:               #f7f6f2;
      --color-surface:          #f9f8f5;
      --color-surface-2:        #fbfbf9;
      --color-surface-offset:   #f0ede8;
      --color-divider:          #dcd9d5;
      --color-border:           #d4d1ca;
      --color-text:             #28251d;
      --color-text-muted:       #7a7974;
      --color-text-faint:       #bab9b4;
      --color-text-inverse:     #f9f8f4;
      --color-primary:          #01696f;
      --color-primary-hover:    #0c4e54;
      --color-primary-highlight:#cedcd8;
      --color-success:          #437a22;
      --color-success-hover:    #2e5c10;
      --color-success-highlight:#d4dfcc;
      --color-error:            #a12c7b;
      --color-error-hover:      #7d1e5e;
      --color-error-highlight:  #e0ced7;
      --color-warning:          #964219;
      --shadow-sm:   0 1px 2px oklch(0.2 0.01 80 / 0.06);
      --shadow-md:   0 4px 16px oklch(0.2 0.01 80 / 0.09);
      --shadow-lg:   0 12px 40px oklch(0.2 0.01 80 / 0.13);
      --shadow-card: 0 2px 4px oklch(0.2 0.01 80 / 0.06), 0 8px 28px oklch(0.2 0.01 80 / 0.08);
      --radius-sm:   0.375rem;
      --radius-md:   0.5rem;
      --radius-lg:   0.75rem;
      --radius-xl:   1rem;
      --radius-2xl:  1.5rem;
      --transition-fast: 140ms cubic-bezier(0.16, 1, 0.3, 1);
      --transition-std:  220ms cubic-bezier(0.16, 1, 0.3, 1);
      --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
      --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
      --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
      --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
      --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
      --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
    }

    [data-theme="dark"] {
      --color-bg:               #171614;
      --color-surface:          #1c1b19;
      --color-surface-2:        #201f1d;
      --color-surface-offset:   #2d2c2a;
      --color-divider:          #262523;
      --color-border:           #393836;
      --color-text:             #cdccca;
      --color-text-muted:       #797876;
      --color-text-faint:       #5a5957;
      --color-text-inverse:     #2b2a28;
      --color-primary:          #4f98a3;
      --color-primary-hover:    #227f8b;
      --color-primary-highlight:#313b3b;
      --color-success:          #6daa45;
      --color-success-hover:    #4d8f25;
      --color-success-highlight:#3a4435;
      --color-error:            #d163a7;
      --color-error-hover:      #b9478f;
      --color-error-highlight:  #4c3d46;
      --color-warning:          #bb653b;
      --shadow-sm:   0 1px 2px oklch(0 0 0 / 0.25);
      --shadow-md:   0 4px 16px oklch(0 0 0 / 0.35);
      --shadow-lg:   0 12px 40px oklch(0 0 0 / 0.45);
      --shadow-card: 0 2px 4px oklch(0 0 0 / 0.3), 0 8px 28px oklch(0 0 0 / 0.25);
    }

    @media (prefers-color-scheme: dark) {
      :root:not([data-theme]) {
        --color-bg:#171614; --color-surface:#1c1b19; --color-surface-2:#201f1d;
        --color-surface-offset:#2d2c2a; --color-divider:#262523; --color-border:#393836;
        --color-text:#cdccca; --color-text-muted:#797876; --color-text-faint:#5a5957;
        --color-text-inverse:#2b2a28; --color-primary:#4f98a3; --color-primary-hover:#227f8b;
        --color-primary-highlight:#313b3b; --color-success:#6daa45; --color-success-hover:#4d8f25;
        --color-success-highlight:#3a4435; --color-error:#d163a7; --color-error-hover:#b9478f;
        --color-error-highlight:#4c3d46; --color-warning:#bb653b;
        --shadow-sm:0 1px 2px oklch(0 0 0/0.25); --shadow-md:0 4px 16px oklch(0 0 0/0.35);
        --shadow-lg:0 12px 40px oklch(0 0 0/0.45);
        --shadow-card:0 2px 4px oklch(0 0 0/0.3),0 8px 28px oklch(0 0 0/0.25);
      }
    }

    /* ── Base Reset ─────────────────────────────────────── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; scroll-behavior: smooth; }
    body { min-height: 100dvh; font-family: var(--font-body, sans-serif); font-size: var(--text-base); color: var(--color-text); background-color: var(--color-bg); transition: background-color var(--transition-slow), color var(--transition-slow); }
    button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
    img, svg { display: block; max-width: 100%; }
    ::selection { background: oklch(from var(--color-primary) l c h / 0.2); color: var(--color-text); }
    :focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    }

    /* ── App Shell ──────────────────────────────────────── */
    #app { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; }

    /* ── Header ─────────────────────────────────────────── */
    .site-header {
      width: 100%; padding: 1rem 1.5rem;
      display: flex; align-items: center; justify-content: space-between;
      border-bottom: 1px solid var(--color-divider);
      background: var(--color-surface);
      position: sticky; top: 0; z-index: 10;
    }
    .logo {
      display: flex; align-items: center; gap: 0.5rem;
      font-family: var(--font-display); font-size: var(--text-lg);
      color: var(--color-text); text-decoration: none;
    }
    .logo svg { color: var(--color-primary); }
    .theme-btn {
      width: 2.5rem; height: 2.5rem;
      display: flex; align-items: center; justify-content: center;
      border-radius: var(--radius-md); color: var(--color-text-muted);
      transition: background var(--transition-fast), color var(--transition-fast);
    }
    .theme-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }

    /* ── Screens ─────────────────────────────────────────── */
    .screen {
      display: none; width: 100%; flex: 1;
      flex-direction: column; align-items: center; justify-content: center;
      padding: clamp(1.5rem, 5vw, 4rem) 1.5rem;
    }
    .screen.active { display: flex; }

    /* ── Animations ─────────────────────────────────────── */
    @keyframes fadeScaleIn {
      from { opacity: 0; transform: scale(0.96) translateY(8px); }
      to   { opacity: 1; transform: scale(1) translateY(0); }
    }
    @keyframes slideDown {
      from { opacity: 0; transform: translateY(-10px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes cardEnter {
      from { opacity: 0; transform: translateY(14px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes revealIn {
      from { opacity: 0; transform: translateY(8px); }
      to   { opacity: 1; transform: translateY(0); }
    }
    @keyframes trophyBounce {
      from { opacity: 0; transform: scale(0.5) rotate(-10deg); }
      60%  { transform: scale(1.1) rotate(3deg); }
      to   { opacity: 1; transform: scale(1) rotate(0deg); }
    }

    /* ── Start Card ──────────────────────────────────────── */
    .start-card {
      max-width: 460px; width: 100%;
      background: var(--color-surface);
      border: 1px solid oklch(from var(--color-text) l c h / 0.08);
      border-radius: var(--radius-2xl);
      padding: clamp(2rem, 5vw, 3rem);
      box-shadow: var(--shadow-card);
      text-align: center;
      animation: fadeScaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    .start-icon {
      width: 4rem; height: 4rem; border-radius: var(--radius-xl);
      background: var(--color-primary-highlight); color: var(--color-primary);
      display: flex; align-items: center; justify-content: center;
      margin: 0 auto 1.5rem;
    }
    .start-title {
      font-family: var(--font-display); font-size: var(--text-xl);
      color: var(--color-text); margin-bottom: 0.5rem; line-height: 1.2;
    }
    .start-subtitle {
      font-size: var(--text-sm); color: var(--color-text-muted);
      margin-bottom: 2rem; max-width: 36ch; margin-inline: auto;
    }

    /* ── Mode Selector ──────────────────────────────────── */
    .mode-label {
      font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em;
      text-transform: uppercase; color: var(--color-text-muted);
      margin-bottom: 0.75rem; display: block;
    }
    .mode-grid {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 0.5rem; margin-bottom: 1.75rem;
    }
    .mode-btn {
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      gap: 0.2rem; padding: 0.875rem 0.5rem;
      border-radius: var(--radius-lg);
      border: 1.5px solid oklch(from var(--color-text) l c h / 0.1);
      background: var(--color-surface-2);
      color: var(--color-text-muted);
      font-size: var(--text-sm); font-weight: 500;
      transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
      cursor: pointer;
    }
    .mode-btn .mode-num {
      font-family: var(--font-display); font-size: var(--text-lg);
      color: var(--color-text); line-height: 1;
    }
    .mode-btn .mode-sub {
      font-size: var(--text-xs); color: var(--color-text-faint);
    }
    .mode-btn:hover {
      border-color: oklch(from var(--color-primary) l c h / 0.4);
      background: var(--color-primary-highlight);
      color: var(--color-primary);
    }
    .mode-btn:hover .mode-num { color: var(--color-primary); }
    .mode-btn.selected {
      border-color: var(--color-primary);
      background: var(--color-primary-highlight);
      color: var(--color-primary);
      box-shadow: 0 0 0 3px oklch(from var(--color-primary) l c h / 0.15);
    }
    .mode-btn.selected .mode-num { color: var(--color-primary); }
    .mode-btn.selected .mode-sub { color: var(--color-primary); opacity: 0.7; }

    /* ── Shared Buttons ─────────────────────────────────── */
    .btn-primary {
      display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
      background: var(--color-primary); color: var(--color-text-inverse);
      font-size: var(--text-sm); font-weight: 600;
      padding: 0.75rem 2rem; border-radius: var(--radius-full);
      box-shadow: var(--shadow-sm); width: 100%;
      transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    }
    .btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }
    .btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

    .btn-ghost {
      display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
      background: transparent; color: var(--color-text-muted);
      font-size: var(--text-sm); font-weight: 500;
      padding: 0.75rem 1.5rem; border-radius: var(--radius-full);
      border: 1px solid oklch(from var(--color-text) l c h / 0.12);
      transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    }
    .btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); border-color: oklch(from var(--color-text) l c h / 0.2); }

    /* ── Quiz Layout ────────────────────────────────────── */
    .quiz-layout {
      max-width: 600px; width: 100%;
      display: flex; flex-direction: column;
      gap: 1.25rem; align-items: stretch;
    }

    /* ── Progress ───────────────────────────────────────── */
    .progress-meta {
      display: flex; align-items: center; justify-content: space-between;
      font-size: var(--text-xs); color: var(--color-text-muted);
    }
    .progress-current { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); }
    .score-pills { display: flex; gap: 0.5rem; }
    .pill {
      display: flex; align-items: center; gap: 0.25rem;
      font-size: var(--text-xs); font-weight: 600;
      padding: 0.2rem 0.55rem; border-radius: var(--radius-full);
    }
    .pill-correct { background: var(--color-success-highlight); color: var(--color-success); }
    .pill-wrong   { background: var(--color-error-highlight);   color: var(--color-error); }

    .progress-bar-wrap {
      width: 100%; height: 4px;
      background: var(--color-surface-offset);
      border-radius: var(--radius-full); overflow: hidden;
    }
    .progress-bar-fill {
      height: 100%; background: var(--color-primary);
      border-radius: var(--radius-full);
      transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* ── Flashcard (no flip) ────────────────────────────── */
    .flashcard {
      width: 100%;
      background: var(--color-surface);
      border: 1px solid oklch(from var(--color-text) l c h / 0.08);
      border-radius: var(--radius-2xl);
      box-shadow: var(--shadow-card);
      overflow: hidden;
      transition: box-shadow var(--transition-std);
    }
    .flashcard.card-enter {
      animation: cardEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    }

    /* Question section */
    .card-question-wrap {
      padding: clamp(1.75rem, 4vw, 2.5rem);
      display: flex; flex-direction: column; align-items: center;
      text-align: center; gap: 0.75rem;
    }
    .card-q-label {
      font-size: var(--text-xs); font-weight: 600;
      letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--color-primary); opacity: 0.75;
    }
    .card-q-text {
      font-family: var(--font-display); font-size: var(--text-xl);
      color: var(--color-text); line-height: 1.3; max-width: 52ch;
    }
    .card-hint {
      font-size: var(--text-xs); color: var(--color-text-faint);
      display: flex; align-items: center; gap: 0.3rem;
      margin-top: 0.25rem;
    }

    /* Reveal button */
    .btn-reveal {
      width: calc(100% - 3rem); margin: 0 1.5rem 1.5rem;
      display: flex; align-items: center; justify-content: center; gap: 0.5rem;
      padding: 0.7rem 1.5rem;
      border-radius: var(--radius-xl);
      border: 1.5px dashed oklch(from var(--color-text) l c h / 0.18);
      background: transparent; color: var(--color-text-muted);
      font-size: var(--text-sm); font-weight: 500;
      transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    }
    .btn-reveal:hover {
      background: var(--color-primary-highlight);
      border-color: var(--color-primary);
      color: var(--color-primary);
    }

    /* Answer section */
    .card-answer-wrap {
      border-top: 1px solid oklch(from var(--color-text) l c h / 0.07);
      padding: clamp(1.5rem, 4vw, 2rem);
      display: flex; flex-direction: column; align-items: center;
      text-align: center; gap: 0.75rem;
      background: var(--color-surface-2);
      animation: revealIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    .card-a-label {
      font-size: var(--text-xs); font-weight: 600;
      letter-spacing: 0.08em; text-transform: uppercase;
      color: var(--color-success); opacity: 0.75;
    }
    .card-a-text {
      font-family: var(--font-display); font-size: var(--text-lg);
      color: var(--color-text); line-height: 1.35; max-width: 52ch;
    }

    /* ── Answer Buttons ─────────────────────────────────── */
    .answer-btns {
      display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
      animation: revealIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
    }
    .btn-knew, .btn-didnt {
      display: flex; align-items: center; justify-content: center; gap: 0.5rem;
      padding: 0.875rem 1.25rem; border-radius: var(--radius-xl);
      font-size: var(--text-sm); font-weight: 600;
      border: 1.5px solid transparent;
      transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    }
    .btn-knew {
      background: var(--color-success-highlight); color: var(--color-success);
      border-color: oklch(from var(--color-success) l c h / 0.25);
    }
    .btn-knew:hover { background: var(--color-success); color: var(--color-text-inverse); transform: translateY(-2px); box-shadow: var(--shadow-md); }
    .btn-knew:active { transform: translateY(0); }
    .btn-didnt {
      background: var(--color-error-highlight); color: var(--color-error);
      border-color: oklch(from var(--color-error) l c h / 0.25);
    }
    .btn-didnt:hover { background: var(--color-error); color: var(--color-text-inverse); transform: translateY(-2px); box-shadow: var(--shadow-md); }
    .btn-didnt:active { transform: translateY(0); }

    .kbd {
      display: inline-flex; align-items: center; justify-content: center;
      background: oklch(from var(--color-text) l c h / 0.08);
      border-radius: 4px; padding: 0.05rem 0.35rem;
      font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em;
      opacity: 0.65; font-family: monospace;
    }

    /* ── Stats Screen ───────────────────────────────────── */
    .stats-card {
      max-width: 520px; width: 100%;
      background: var(--color-surface);
      border: 1px solid oklch(from var(--color-text) l c h / 0.08);
      border-radius: var(--radius-2xl);
      padding: clamp(2rem, 5vw, 3rem);
      box-shadow: var(--shadow-card);
      animation: fadeScaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    .stats-header { text-align: center; margin-bottom: 2rem; }
    .stats-trophy {
      width: 5rem; height: 5rem; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 2.25rem; margin: 0 auto 1.25rem;
      animation: trophyBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
    }
    .stats-title { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-text); margin-bottom: 0.375rem; }
    .stats-subtitle { font-size: var(--text-sm); color: var(--color-text-muted); }

    .ring-wrap { display: flex; justify-content: center; margin-bottom: 2rem; }
    .ring-container { position: relative; width: 8rem; height: 8rem; }
    .ring-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
    .ring-track { fill: none; stroke: var(--color-surface-offset); stroke-width: 8; }
    .ring-progress { fill: none; stroke: var(--color-primary); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.4s; }
    .ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
    .ring-pct { font-family: var(--font-display); font-size: var(--text-xl); color: var(--color-text); line-height: 1; }
    .ring-pct-label { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.2rem; }

    .stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; margin-bottom: 2rem; }
    .stat-box { background: var(--color-surface-2); border: 1px solid oklch(from var(--color-text) l c h / 0.06); border-radius: var(--radius-lg); padding: 1rem 0.75rem; text-align: center; }
    .stat-num { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1; margin-bottom: 0.25rem; }
    .stat-lbl { font-size: var(--text-xs); color: var(--color-text-muted); }
    .stat-correct .stat-num { color: var(--color-success); }
    .stat-wrong   .stat-num { color: var(--color-error); }
    .stat-total   .stat-num { color: var(--color-primary); }

    .result-msg { text-align: center; font-size: var(--text-sm); color: var(--color-text-muted); padding: 1rem 1.25rem; background: var(--color-surface-offset); border-radius: var(--radius-lg); margin-bottom: 1.5rem; font-style: italic; }
    .stats-actions { display: flex; flex-direction: column; gap: 0.75rem; }

    /* Confetti */
    #confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }

    @media (max-width: 480px) {
      .card-q-text { font-size: var(--text-lg); }
      .stats-grid { grid-template-columns: 1fr 1fr; }
      .stat-box:last-child { grid-column: 1 / -1; }
      .mode-btn .mode-num { font-size: var(--text-base); }
    }