/**
 * Flashcard Module – Liquid macOS 26 Design System
 * 
 * Philosophy: translucent materials · mesh gradients · layered glass · vibrant depth
 * Inspired by macOS 26 vibrancy + Apple SF aesthetic
 * Mobile-first responsive
 * 
 * @version 5.0.0 — 2026-03-13
 */

/* ═══════════════════════════════════════════════════════════
   0.  DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */

:root {
    /* ── Palette (macOS 26 Liquid) ── */
    --fc-ink:           #1d1d1f;
    --fc-ink-soft:      #424245;
    --fc-ink-muted:     #86868b;
    --fc-paper:         #fbfbfd;
    --fc-paper-warm:    #f5f5f7;
    --fc-paper-bright:  #ffffff;

    --fc-primary:       #007aff;
    --fc-primary-vivid: #0a84ff;
    --fc-primary-deep:  #0062cc;
    --fc-primary-light: #40a9ff;
    --fc-primary-dark:  #003d99;
    --fc-secondary:     #ff6f00;
    --fc-accent:        #ff375f;
    --fc-teal:          #30d158;
    --fc-purple:        #bf5af2;
    --fc-success:       #30d158;
    --fc-danger:        #ff3b30;
    --fc-warning:       #ff9f0a;

    /* ── Liquid Materials (macOS vibrancy) ── */
    --fc-glass:         rgba(255, 255, 255, 0.55);
    --fc-glass-solid:   rgba(255, 255, 255, 0.78);
    --fc-glass-border:  rgba(0, 0, 0, 0.06);
    --fc-glass-glow:    rgba(0, 122, 255, 0.18);
    --fc-bg:            #fbfbfd;
    --fc-bg-dark:       #f5f5f7;
    --fc-bg-card:       rgba(255, 255, 255, 0.72);
    --fc-surface:       rgba(255, 255, 255, 0.65);
    --fc-surface-hover: rgba(255, 255, 255, 0.90);
    --fc-border:        rgba(0, 0, 0, 0.06);
    --fc-border-glow:   rgba(0, 122, 255, 0.24);
    --fc-text:          #1d1d1f;
    --fc-text-secondary:#424245;
    --fc-text-muted:    #86868b;

    /* ── Depth (macOS layered) ── */
    --fc-shadow-xs:     0 0.5px 1px rgba(0, 0, 0, 0.04);
    --fc-shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --fc-shadow:        0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
    --fc-shadow-lg:     0 8px 28px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --fc-shadow-xl:     0 16px 48px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.04);
    --fc-shadow-card:   0 8px 24px rgba(0, 0, 0, 0.06),
                        0 0 0 0.5px rgba(0, 0, 0, 0.08);
    --fc-card-shadow:   0 8px 24px rgba(0, 0, 0, 0.06);
    --fc-card-shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.10);

    /* ── Shape ── */
    --fc-radius-sm:  10px;
    --fc-radius:     16px;
    --fc-radius-lg:  24px;
    --fc-radius-xl:  32px;
    --fc-radius-full: 9999px;
    --fc-r-sm:  10px;
    --fc-r:     16px;
    --fc-r-lg:  24px;
    --fc-r-xl:  32px;
    --fc-r-2xl: 40px;
    --fc-r-pill: 9999px;

    /* ── Spacing ── */
    --fc-space-xs: 4px;  --fc-space-sm: 8px;
    --fc-space-md: 16px; --fc-space-lg: 24px;
    --fc-space-xl: 32px; --fc-space-2xl: 48px;

    /* ── Typography ── */
    --fc-font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fc-font-chinese: 'Noto Serif SC', 'Songti SC', serif;
    --fc-sans:    var(--fc-font-family);
    --fc-serif:   var(--fc-font-chinese);

    /* ── Motion ── */
    --fc-transition:      .25s cubic-bezier(.4, 0, .2, 1);
    --fc-transition-slow: .45s cubic-bezier(.4, 0, .2, 1);
    --fc-bounce:          cubic-bezier(.34, 1.56, .64, 1);
    --fc-ease:        cubic-bezier(.4, 0, .2, 1);
    --fc-ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
    --fc-ease-spring: cubic-bezier(.175, .885, .32, 1.275);
    --fc-dur:         .25s;
    --fc-dur-slow:    .45s;

    /* Glow (macOS accent) */
    --fc-glow-sm:  0 0 0 transparent;
    --fc-glow:     0 4px 16px rgba(0,122,255,.12);
    --fc-glow-lg:  0 8px 28px rgba(0,122,255,.14);
    --fc-glow-intense: 0 10px 36px rgba(255,55,95,.16);
}

/* ═══════════════════════════════════════════════════════════
   1.  RESET & BASE
   ═══════════════════════════════════════════════════════════ */

html, body {
    margin: 0; padding: 0;
    font-family: var(--fc-sans);
    color: var(--fc-ink);
    background: #f5f5f7;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

body, .flashcard-module, .selection-screen, .flashcard-module * {
    font-family: var(--fc-sans);
}

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

/* ═══════════════════════════════════════════════════════════
   2.  LIQUID BACKGROUND EFFECTS
   ═══════════════════════════════════════════════════════════ */

@keyframes liquid-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    25%      { transform: translate(80px, -40px) scale(1.15) rotate(45deg); }
    50%      { transform: translate(-30px, 60px) scale(.92) rotate(120deg); }
    75%      { transform: translate(50px, 30px) scale(1.08) rotate(200deg); }
}
@keyframes liquid-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(-60px, 50px) scale(1.2); }
    66%      { transform: translate(40px, -70px) scale(.85); }
}
@keyframes liquid-morph {
    0%   { border-radius: 40% 60% 60% 40% / 60% 30% 70% 40%; }
    25%  { border-radius: 60% 40% 30% 70% / 40% 60% 40% 60%; }
    50%  { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    75%  { border-radius: 50% 40% 50% 60% / 60% 40% 60% 30%; }
    100% { border-radius: 40% 60% 60% 40% / 60% 30% 70% 40%; }
}

/* Suppress old background systems */
.bg-particles, .bg-canvas { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   3.  SELECTION SCREEN
   ═══════════════════════════════════════════════════════════ */

.selection-screen {
    position: relative;
    min-height: 100dvh;
    overflow-x: hidden;
    background: #f5f5f7 !important;
}

/* ── macOS 26 mesh gradient blobs ── */
.selection-screen::before {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none; z-index: 0;
    background:
        radial-gradient(ellipse 600px 500px at 15% 8%, rgba(0,122,255,.15), transparent),
        radial-gradient(ellipse 500px 600px at 85% 15%, rgba(191,90,242,.12), transparent),
        radial-gradient(ellipse 600px 400px at 50% 65%, rgba(48,209,88,.08), transparent),
        radial-gradient(ellipse 400px 500px at 75% 85%, rgba(255,55,95,.07), transparent),
        radial-gradient(ellipse 500px 400px at 20% 90%, rgba(255,159,10,.06), transparent);
    animation: mesh-shift 30s ease-in-out infinite alternate;
}
.selection-screen::after {
    content: '';
    position: fixed;
    width: 36rem; height: 36rem;
    top: -14rem; right: -10rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,122,255,.10) 0%, transparent 65%);
    filter: blur(60px);
    pointer-events: none; z-index: 0;
    animation: liquid-drift-2 26s ease-in-out infinite, liquid-morph 18s ease-in-out infinite;
}

@keyframes mesh-shift {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: .85; transform: scale(1.05) translate(-2%, 3%); }
    100% { opacity: 1; transform: scale(1) translate(1%, -1%); }
}

/* — Shell — */
.fc-shell {
    position: relative; z-index: 1;
    width: min(1140px, calc(100% - 24px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

/* — Header — */
.fc-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 16px;
    align-items: start;
    margin-bottom: 24px;
    padding: 0;
}

.back-btn {
    display: grid; place-items: center;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--fc-glass) !important;
    border: 0.5px solid rgba(0,0,0,.08) !important;
    color: var(--fc-primary) !important;
    text-decoration: none;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: var(--fc-shadow-xs);
    transition: all var(--fc-dur) var(--fc-ease);
}
.back-btn:hover {
    transform: translateX(-3px);
    box-shadow: var(--fc-shadow-sm);
    background: var(--fc-surface-hover) !important;
}
.back-btn svg { width: 20px; height: 20px; }

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

.title-icon {
    flex-shrink: 0;
    display: grid; place-items: center;
    width: 60px; height: 60px;
    border-radius: 16px;
    background: linear-gradient(145deg, #007aff, #5856d6) !important;
    color: #fff !important;
    font-family: var(--fc-serif);
    font-size: 1.8rem; font-weight: 700;
    box-shadow: 0 6px 20px rgba(0,122,255,.25);
    animation: none;
}

.title-text { display: flex; flex-direction: column; gap: 6px; }
.title-kicker, .section-kicker, .hero-eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .72rem; font-weight: 800;
    letter-spacing: .16em; text-transform: uppercase;
    color: var(--fc-primary);
}
.title-text h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.06; font-weight: 800;
    letter-spacing: -.04em;
    color: var(--fc-ink);
    text-shadow: none;
}
.title-text p {
    margin: 0; max-width: 56ch;
    font-size: .95rem; line-height: 1.6;
    color: var(--fc-ink-soft);
}

.header-tag {
    align-self: center; justify-self: end;
    padding: 8px 14px;
    border-radius: var(--fc-r-pill);
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--fc-primary);
    font-size: .76rem; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase;
}

/* — Main — */
.fc-main { display: grid; gap: 20px; padding: 0; }
.fc-section { position: relative; z-index: 1; margin-bottom: 0; }

/* Glass panels */
.fc-panel, .fc-hero {
    border: 0.5px solid rgba(0,0,0,.06);
    border-radius: 20px;
    background: rgba(255,255,255,.60);
    box-shadow: var(--fc-shadow-sm);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    transition: box-shadow var(--fc-dur-slow) var(--fc-ease);
}

/* — Hero — */
.fc-hero {
    display: grid;
    grid-template-columns: 1.6fr .9fr;
    gap: 24px;
    padding: 32px;
    position: relative;
    overflow: hidden;
}
/* Liquid blob on hero */
.fc-hero::before {
    content: '';
    position: absolute;
    width: 320px; height: 320px;
    top: -100px; right: -80px;
    background: radial-gradient(circle, rgba(191,90,242,.14), transparent 60%);
    border-radius: 50%;
    filter: blur(60px);
    animation: liquid-drift-1 20s ease-in-out infinite;
    pointer-events: none;
}
.fc-hero-copy h2 {
    margin: 8px 0 10px;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    line-height: 1.1; letter-spacing: -.04em;
    color: var(--fc-ink);
}
.fc-hero-copy > p {
    margin: 0; max-width: 60ch;
    font-size: .95rem; line-height: 1.7;
    color: var(--fc-ink-soft);
}

/* — Stats — */
.fc-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 24px;
}
.fc-stat-card {
    padding: 16px;
    border: 0.5px solid rgba(0,0,0,.06);
    border-radius: 14px;
    background: rgba(255,255,255,.50);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: var(--fc-shadow-xs);
    transition: transform var(--fc-dur) var(--fc-ease-bounce),
                box-shadow var(--fc-dur) var(--fc-ease);
}
.fc-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--fc-shadow-sm);
}
.fc-stat-label {
    display: block; margin-bottom: 6px;
    font-size: .72rem; font-weight: 800;
    letter-spacing: .12em; text-transform: uppercase;
    color: var(--fc-ink-muted);
}
.fc-stat-value {
    display: block;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    line-height: 1; font-weight: 800;
    letter-spacing: -.04em;
    color: var(--fc-primary);
}
.fc-stat-note {
    display: block; margin-top: 4px;
    font-size: .85rem; color: var(--fc-ink-soft);
}

/* — Hero aside — */
.fc-hero-aside { display: grid; gap: 16px; align-content: start; }
.hero-note, .hero-shortcuts {
    padding: 18px;
    border-radius: 14px;
    border: 0.5px solid rgba(0,0,0,.05);
    background: rgba(255,255,255,.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.hero-note-label {
    display: inline-block; margin-bottom: 8px;
    color: var(--fc-primary); font-size: .76rem; font-weight: 700;
    letter-spacing: .10em; text-transform: uppercase;
}
.hero-note-list {
    margin: 0; padding-left: 18px;
    color: var(--fc-ink-soft); line-height: 1.7; font-size: .9rem;
}
.hero-shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.shortcut-chip {
    display: inline-flex; align-items: center;
    padding: 6px 11px; border-radius: 8px;
    background: rgba(255,255,255,.60);
    border: 0.5px solid rgba(0,0,0,.06);
    color: var(--fc-ink-soft);
    font-size: .80rem; font-weight: 600;
}

/* — Section heads — */
.fc-panel { padding: 24px; }
.section-head {
    display: flex; align-items: flex-end;
    justify-content: space-between;
    gap: 16px; margin-bottom: 16px;
}
.section-head h3 {
    margin: 4px 0 0;
    font-size: 1.3rem; line-height: 1.1;
    letter-spacing: -.03em; color: var(--fc-ink);
}

.section-title {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 16px; font-size: 1rem;
    font-weight: 600; color: var(--fc-ink-soft);
}

/* — Category tabs — */
.fc-category-tabs { margin-bottom: 0; }
.category-tabs {
    display: flex; gap: 10px;
    padding: 0; background: none; border: none;
    backdrop-filter: none;
}
.category-tab {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    color: var(--fc-ink-soft);
    font-size: .90rem; font-weight: 600;
    cursor: pointer;
    transition: all var(--fc-dur) var(--fc-ease);
}
.category-tab:hover {
    background: rgba(255,255,255,.70);
    transform: translateY(-1px);
}
.category-tab.active {
    background: var(--fc-primary);
    color: #fff; border-color: transparent;
    box-shadow: 0 4px 14px rgba(0,122,255,.24);
}
.cat-icon { font-size: 1.2rem; }
.cat-name { font-weight: 700; }

/* — Total badge — */
.total-badge {
    display: inline-flex; align-items: center;
    padding: 8px 12px; border-radius: var(--fc-r-pill);
    background: rgba(0,122,255,.08) !important;
    border: 0.5px solid rgba(0,122,255,.12) !important;
    color: var(--fc-primary) !important;
    font-size: .78rem; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase;
}

/* — Level grid — */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.level-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0 16px;
    min-height: 110px;
    padding: 18px;
    border-radius: 16px;
    border: 0.5px solid rgba(0,0,0,.06) !important;
    background: rgba(255,255,255,.55) !important;
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: var(--fc-shadow-xs) !important;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--fc-dur) var(--fc-ease);
}
.level-card::before, .level-card::after { display: none !important; }

.level-card:hover {
    transform: translateY(-4px) scale(1.01) !important;
    box-shadow: var(--fc-shadow-lg) !important;
    background: rgba(255,255,255,.75) !important;
}
.level-card:active { transform: translateY(-1px) scale(.99) !important; }

.level-num {
    grid-row: 1 / span 2;
    display: grid; place-items: center;
    width: 50px; height: 50px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0,122,255,.12), rgba(191,90,242,.10)) !important;
    color: var(--fc-primary) !important;
    font-size: 1.4rem; font-weight: 800;
    box-shadow: none !important;
    transition: transform var(--fc-dur) var(--fc-ease-spring);
    margin-bottom: 0;
}
.level-card:hover .level-num { transform: scale(1.06) rotate(-2deg); }

.level-label {
    display: block !important;
    color: var(--fc-ink); font-size: 1rem; font-weight: 800;
    margin-bottom: 2px;
}
.level-count { color: var(--fc-ink-muted); font-size: .85rem; font-weight: 600; }

.level-progress-track {
    grid-column: 1 / -1;
    display: block;
    width: 100%; height: 4px; margin-top: 12px;
    border-radius: var(--fc-r-pill);
    background: rgba(0,0,0,.04);
    overflow: hidden;
}
.level-progress {
    display: block; width: 0; height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--fc-primary), var(--fc-purple));
    transition: width .6s var(--fc-ease);
    position: relative;
    bottom: auto; left: auto;
}

/* TOCFL */
.tocfl-card { opacity: .72; }
.tocfl-card .level-num {
    background: linear-gradient(135deg, rgba(244,114,182,.15), rgba(139,92,246,.15)) !important;
}
.tocfl-notice {
    grid-column: 1 / -1;
    padding: 16px; border-radius: 14px;
    border: 0.5px dashed rgba(0,0,0,.10);
    background: rgba(255,255,255,.40);
    color: var(--fc-ink-muted); font-weight: 600;
    text-align: center; font-size: .88rem; font-style: italic;
}

/* — Options — */
.fc-options { display: flex; flex-direction: column; gap: 20px; }
.fc-option-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.option-group {
    padding: 16px;
    border: 0.5px solid rgba(0,0,0,.05);
    border-radius: 14px;
    background: rgba(255,255,255,.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.option-label {
    display: block; margin-bottom: 10px;
    color: var(--fc-ink-muted); font-size: .76rem; font-weight: 800;
    letter-spacing: .10em; text-transform: uppercase;
}
.option-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.opt-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; min-height: 38px; padding: 7px 14px;
    border-radius: 10px;
    border: 0.5px solid rgba(0,0,0,.06) !important;
    background: rgba(255,255,255,.65) !important;
    color: var(--fc-ink-soft) !important;
    font-size: .86rem; font-weight: 600;
    cursor: pointer;
    transition: all var(--fc-dur) var(--fc-ease);
}
.opt-btn:hover {
    background: rgba(255,255,255,.85) !important;
    color: var(--fc-ink) !important;
    transform: translateY(-1px);
    box-shadow: var(--fc-shadow-xs);
}
.opt-btn.active {
    background: var(--fc-primary) !important;
    color: #fff !important; border-color: transparent !important;
    box-shadow: 0 4px 14px rgba(0,122,255,.22);
    transform: translateY(-1px);
}
.opt-btn svg, .opt-btn span { position: relative; z-index: 1; }
.count-btns .opt-btn { min-width: 48px; }
.script-btns .opt-btn { font-family: var(--fc-serif); font-weight: 700; }

/* — Footer — */
.fc-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 10px; margin-top: 16px; padding: 0 8px;
    color: var(--fc-ink-muted); font-size: .88rem;
    background: none !important; border: none !important; box-shadow: none !important;
}
.footer-dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(0,0,0,.15); }

/* ═══════════════════════════════════════════════════════════
   4.  FLASHCARD SESSION MODULE
   ═══════════════════════════════════════════════════════════ */

.flashcard-module {
    display: flex; flex-direction: column;
    min-height: 100dvh;
    padding: 24px 16px 32px;
    background:
        radial-gradient(ellipse at 15% 10%, rgba(0,122,255,.06), transparent 40%),
        radial-gradient(ellipse at 85% 5%, rgba(191,90,242,.05), transparent 35%),
        #f5f5f7;
    color: var(--fc-ink);
    font-family: var(--fc-sans);
}
.flashcard-module * { box-sizing: border-box; }

/* — Session header — */
.flashcard-header {
    width: min(1040px, 100%); margin: 0 auto 16px;
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px;
    border-radius: 16px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.55);
    box-shadow: var(--fc-shadow-xs);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    flex-shrink: 0;
}
.flashcard-header .btn-back {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.60);
    color: var(--fc-primary);
    cursor: pointer;
}

.header-info { flex: 1; }
.flashcard-header .header-title {
    margin: 0;
    font-size: 1.3rem; font-weight: 800;
    color: var(--fc-ink); letter-spacing: -.02em;
}
.header-meta { font-size: .88rem; color: var(--fc-ink-soft); font-weight: 600; }

.header-actions { display: flex; gap: 8px; }
.btn-icon {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--fc-glass-border);
    border-radius: var(--fc-r);
    background: transparent; color: var(--fc-ink-muted);
    cursor: pointer; transition: all var(--fc-dur) var(--fc-ease);
}
.btn-icon:hover { background: var(--fc-glass); color: var(--fc-ink); }
.btn-icon svg { width: 20px; height: 20px; }

/* — Progress — */
.progress-container {
    width: min(1040px, 100%); margin: 0 auto 12px;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 20px;
    border-radius: 14px;
    background: rgba(255,255,255,.55);
    border: 0.5px solid rgba(0,0,0,.06);
    box-shadow: var(--fc-shadow-xs);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    flex-shrink: 0;
}
.progress-bar {
    flex: 1; height: 6px;
    background: rgba(0,0,0,.04);
    border-radius: var(--fc-r-pill);
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fc-primary), var(--fc-purple));
    border-radius: inherit;
    transition: width .5s var(--fc-ease);
}
.progress-text {
    font-size: .85rem; font-weight: 700;
    color: var(--fc-ink-soft); min-width: 52px; text-align: right;
}

/* — Mode Tabs — */
.mode-tabs {
    width: min(1040px, 100%); margin: 0 auto 16px;
    display: flex; gap: 8px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(255,255,255,.55);
    border: 0.5px solid rgba(0,0,0,.06);
    box-shadow: var(--fc-shadow-xs);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    flex-shrink: 0; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.mode-tab {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border: none; border-radius: var(--fc-r-sm);
    background: transparent; color: var(--fc-ink-muted);
    font-size: .85rem; font-weight: 700;
    cursor: pointer; white-space: nowrap;
    transition: all var(--fc-dur) var(--fc-ease);
}
.mode-tab:hover { background: rgba(0,0,0,.03); color: var(--fc-ink); }
.mode-tab.active {
    background: var(--fc-primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,122,255,.22);
}
.tab-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* — Main content — */
.flashcard-content {
    width: min(1040px, 100%); margin: 0 auto;
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    border-radius: 20px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.60);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    box-shadow: var(--fc-shadow-lg);
    overflow: hidden; position: relative;
    min-height: min(60vh, 560px);
}

.state-loading, .state-dealing, .quiz-display,
.result-display, .card-display { width: 100%; }

/* Loading */
.state-loading { flex-direction: column; gap: 16px; }
.loading-spinner {
    width: 48px; height: 48px;
    border: 3px solid rgba(0,0,0,.06);
    border-top-color: var(--fc-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--fc-ink-muted); font-size: .88rem; font-weight: 700; }

/* Dealing */
.state-dealing { flex-direction: column; gap: 24px; }
.dealing-deck { width: 200px; height: 280px; position: relative; }
.dealing-text { font-size: 1rem; font-weight: 700; color: var(--fc-ink-muted); }

.card-stack { position: absolute; width: 220px; height: 320px; perspective: 1200px; }
.stack-card {
    position: absolute; width: 100%; height: 100%;
    background: linear-gradient(145deg, var(--fc-primary), #5856d6);
    border-radius: 20px;
    box-shadow: var(--fc-shadow);
    display: grid; place-items: center;
}
.stack-card-front { color: #fff; text-align: center; }
.stack-card-hanzi { font-family: var(--fc-serif); font-size: 2rem; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   5.  THE FLASHCARD
   ═══════════════════════════════════════════════════════════ */

.card-display {
    max-width: 380px;
    aspect-ratio: 3 / 4;
    max-height: none;
}
.flashcard {
    width: 100%; height: 100%;
    perspective: 1200px;
    cursor: pointer;
    filter: drop-shadow(0 12px 28px rgba(0,0,0,.08));
}
.flashcard-inner {
    position: relative; width: 100%; height: 100%;
    transform-style: preserve-3d;
    transition: transform .65s var(--fc-ease-spring);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--fc-r-xl);
    display: flex; flex-direction: column;
    padding: 24px 18px;
    overflow: hidden;
    border: 1px solid var(--fc-glass-border);
}

/* Liquid shimmer on cards */
.flashcard-front::before, .flashcard-back::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 80% 10%, rgba(0,122,255,.06), transparent 50%),
        linear-gradient(180deg, rgba(255,255,255,.55), transparent 45%);
    pointer-events: none; z-index: 0;
}
.flashcard-front::after {
    content: '';
    position: absolute; inset: -50%;
    background: conic-gradient(from 180deg, transparent, rgba(0,122,255,.03), transparent 60%);
    animation: card-shimmer 8s linear infinite;
    pointer-events: none; z-index: 0;
}
@keyframes card-shimmer { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.flashcard-front {
    background: linear-gradient(160deg, #ffffff, #fbfbfd);
    box-shadow: var(--fc-shadow-card);
    align-items: center; justify-content: center;
}
.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #ffffff, #f5f5f7);
    box-shadow: var(--fc-shadow-card);
    align-items: flex-start; justify-content: flex-start;
    text-align: left;
}

/* Card content */
.card-hanzi {
    position: relative; z-index: 1;
    font-family: var(--fc-serif);
    font-size: clamp(2.8rem, 11vw, 4.5rem);
    font-weight: 700; line-height: 1.15;
    text-align: center;
    color: var(--fc-ink);
    margin-bottom: 8px;
    transition: transform .2s var(--fc-ease-bounce);
}
.flashcard:hover .card-hanzi { transform: scale(1.02); }

.card-pinyin {
    position: relative; z-index: 1;
    padding: 6px 14px;
    border-radius: var(--fc-r-pill);
    background: rgba(0,122,255,.08);
    color: var(--fc-primary);
    font-size: 1.05rem; font-weight: 700;
    margin-bottom: 6px;
    transition: filter .3s, opacity .3s;
}
.card-pinyin[data-reveal="pinyin"]:not([data-revealed="true"]) {
    filter: blur(6px); opacity: .6; cursor: pointer;
}
.card-pinyin[data-revealed="true"] { filter: none; opacity: 1; }

/* Audio button with liquid ripple */
.btn-audio {
    position: absolute; right: 14px; bottom: 14px;
    width: 42px; height: 42px; z-index: 2;
    border: none; border-radius: 50%;
    background: linear-gradient(135deg, var(--fc-primary), #5856d6);
    color: #fff; cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 4px 16px rgba(0,122,255,.22);
    transition: transform .2s var(--fc-ease-bounce),
                box-shadow .2s var(--fc-ease);
    overflow: hidden;
}
.btn-audio:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0,122,255,.28);
}
.btn-audio:active::after {
    content: '';
    position: absolute; inset: 0;
    background: rgba(255,255,255,.3);
    border-radius: 50%;
    animation: ripple-out .5s ease-out forwards;
}
@keyframes ripple-out {
    from { transform: scale(0); opacity: 1; }
    to   { transform: scale(2.5); opacity: 0; }
}
.btn-audio svg { width: 18px; height: 18px; position: relative; z-index: 1; }

/* Back content */
.card-meaning {
    position: relative; z-index: 1;
    width: 100%; margin-bottom: 8px;
    color: var(--fc-ink); text-align: left;
    font-size: 1.1rem; line-height: 1.6;
}
.meaning-main { display: block; font-weight: 600; color: var(--fc-ink); line-height: 1.7; }
.meaning-empty { color: var(--fc-ink-muted); font-style: italic; }
.meaning-item {
    padding: .35rem 0; line-height: 1.6;
    border-bottom: 1px solid rgba(0,0,0,.04);
    color: var(--fc-ink);
}
.meaning-item:last-child { border-bottom: none; }
.meaning-list-inline { display: flex; flex-direction: column; gap: .25rem; margin: .4rem 0; text-align: left; }
.meaning-list { list-style: none; padding: .4rem 0 .4rem 1.2rem; margin: .4rem 0; display: flex; flex-direction: column; gap: .35rem; text-align: left; }
.meaning-list li { position: relative; padding-left: .5rem; font-size: .95rem; color: var(--fc-ink); line-height: 1.55; }
.meaning-list li::before { content: '·'; position: absolute; left: -.8rem; color: var(--fc-primary); font-weight: bold; font-size: 1.2rem; }
.meaning-classifier { display: none; }
.meaning-variant-simple { display: inline-block; color: var(--fc-secondary); font-weight: 600; font-style: italic; }

.card-hanviet, .card-english, .card-example {
    position: relative; z-index: 1;
    width: 100%; padding: 8px 12px;
    border-radius: var(--fc-r-sm);
    margin-bottom: 4px;
    font-size: .92rem;
}
.card-hanviet { background: rgba(0,122,255,.07); color: var(--fc-primary); font-weight: 700; font-style: normal; }
.card-english { background: rgba(255,149,0,.07); color: var(--fc-secondary); }
.card-example { background: rgba(0,0,0,.02); color: var(--fc-ink-soft); font-family: var(--fc-serif); text-align: left; line-height: 1.65; }
.card-hanviet:empty, .card-english:empty, .card-example:empty { display: none; }

/* Reveal hints */
.card-reveal-hints {
    position: absolute; bottom: 16px; left: 16px;
    display: flex; gap: 6px; z-index: 3;
}
.reveal-hint {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: var(--fc-r-pill);
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.65); color: var(--fc-primary);
    font-size: .72rem; font-weight: 700; cursor: pointer;
    transition: all var(--fc-dur) var(--fc-ease);
}
.reveal-hint:hover { background: rgba(255,255,255,.85); }
.reveal-hint.revealed { background: var(--fc-success); color: #fff; border-color: var(--fc-success); }
.hint-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   6.  QUIZ
   ═══════════════════════════════════════════════════════════ */

.quiz-display { flex-direction: column; max-width: 720px; gap: 24px; }

.quiz-question {
    border-radius: var(--fc-r-xl);
    border: 1px solid var(--fc-glass-border);
    background: var(--fc-glass-solid);
    padding: 24px;
    box-shadow: var(--fc-shadow);
}
.question-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; font-size: .85rem; color: var(--fc-ink-muted);
}
.question-number { font-weight: 700; }
.question-type {
    padding: 5px 12px; border-radius: var(--fc-r-pill);
    background: rgba(0,122,255,.08); color: var(--fc-primary);
    font-size: .72rem; font-weight: 800;
}
.question-prompt { text-align: center; margin-bottom: 24px; }
.prompt-text {
    font-family: var(--fc-serif);
    font-size: clamp(2rem, 8vw, 3.2rem);
    font-weight: 700; color: var(--fc-ink);
}
.prompt-pinyin { font-size: 1.15rem; color: var(--fc-ink-soft); margin-top: 8px; }
.question-instruction { text-align: center; color: var(--fc-ink-muted); margin-bottom: 20px; }
.question-prompt .btn-audio { position: static; margin: 16px auto 0; }

.question-options { display: flex; flex-direction: column; gap: 8px; }

.quiz-option {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px;
    border: 2px solid var(--fc-glass-border);
    border-radius: var(--fc-r);
    background: var(--fc-glass);
    text-align: left; cursor: pointer;
    transition: all var(--fc-dur) var(--fc-ease);
}
.quiz-option:hover:not(.answered) {
    border-color: var(--fc-glass-glow);
    background: var(--fc-paper-bright);
    transform: translateX(4px);
    box-shadow: var(--fc-shadow-sm);
}
.option-letter {
    display: grid; place-items: center;
    width: 34px; height: 34px; flex-shrink: 0;
    background: rgba(0,122,255,.08);
    border-radius: 50%;
    font-weight: 700; font-size: .85rem; color: var(--fc-primary);
}
.option-text { flex: 1; font-size: .95rem; color: var(--fc-ink); }

.quiz-option.answered { pointer-events: none; }
.quiz-option.correct {
    border-color: rgba(22,163,74,.24);
    background: rgba(22,163,74,.06);
    animation: correct-pop .45s var(--fc-ease-bounce);
}
.quiz-option.correct .option-letter { background: var(--fc-success); color: #fff; }
.quiz-option.incorrect {
    border-color: rgba(220,38,38,.22);
    background: rgba(220,38,38,.05);
    animation: shake .45s ease-in-out;
}
.quiz-option.incorrect .option-letter { background: var(--fc-danger); color: #fff; }

@keyframes correct-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* ═══════════════════════════════════════════════════════════
   7.  RESULTS
   ═══════════════════════════════════════════════════════════ */

.result-display { flex-direction: column; max-width: 720px; }

.session-result {
    border-radius: var(--fc-r-2xl);
    border: 1px solid var(--fc-glass-border);
    background: var(--fc-glass-solid);
    padding: 32px;
    box-shadow: var(--fc-shadow-lg);
    text-align: center;
}
.result-header { margin-bottom: 24px; }
.result-icon {
    margin-bottom: 12px;
    animation: result-bounce .7s var(--fc-ease-bounce);
    display: flex; justify-content: center;
}
@keyframes result-bounce {
    0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(3deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.result-title { font-size: 1.6rem; font-weight: 800; color: var(--fc-ink); margin: 0; }

.result-stats {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 12px; margin-bottom: 24px;
}
.stat-item {
    padding: 12px;
    border-radius: var(--fc-r);
    background: var(--fc-glass);
    border: 1px solid var(--fc-glass-border);
}
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--fc-primary); }
.stat-item.correct .stat-value { color: var(--fc-success); }
.stat-item.incorrect .stat-value { color: var(--fc-danger); }
.stat-label {
    font-size: .72rem; font-weight: 700; color: var(--fc-ink-muted);
    text-transform: uppercase; letter-spacing: .04em;
}

.result-actions { display: flex; flex-direction: column; gap: 12px; }

/* ═══════════════════════════════════════════════════════════
   8.  NAVIGATION
   ═══════════════════════════════════════════════════════════ */

.card-navigation {
    width: min(1040px, 100%); margin: 16px auto 12px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    border-radius: 16px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: var(--fc-shadow-xs);
    flex-shrink: 0;
}
.nav-btn {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px; padding: 0 16px;
    border: 1px solid var(--fc-glass-border);
    border-radius: var(--fc-r);
    background: var(--fc-glass); color: var(--fc-primary-deep);
    font-size: .85rem; font-weight: 700;
    cursor: pointer; transition: all var(--fc-dur) var(--fc-ease);
}
.nav-btn:hover:not(:disabled) {
    background: var(--fc-paper-bright);
    border-color: var(--fc-glass-glow);
    transform: translateY(-1px);
}
.nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.nav-btn svg { width: 18px; height: 18px; }

.nav-actions { display: flex; gap: 12px; }
.action-btn {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-width: 100px; min-height: 50px;
    padding: 8px 12px;
    border: 1px solid var(--fc-glass-border);
    border-radius: var(--fc-r);
    background: var(--fc-glass); color: var(--fc-ink);
    font-size: .72rem; font-weight: 700;
    cursor: pointer; transition: all var(--fc-dur) var(--fc-ease);
}
.action-btn:hover { background: var(--fc-paper-bright); transform: translateY(-2px); }
.action-btn .btn-icon {
    width: 20px; height: 20px;
    border: none; background: none; color: inherit;
}

.action-unknown:hover { border-color: rgba(220,38,38,.22); background: rgba(220,38,38,.05); color: var(--fc-danger); }
.action-known:hover  { border-color: rgba(22,163,74,.22); background: rgba(22,163,74,.05); color: var(--fc-success); }
.action-flip {
    min-width: 64px;
    background: var(--fc-primary);
    color: #fff; border-color: transparent;
}
.action-flip:hover { box-shadow: 0 6px 20px rgba(0,122,255,.22); }
.action-flip .btn-icon { width: 22px; height: 22px; color: inherit; }

/* ═══════════════════════════════════════════════════════════
   9.  THUMBNAILS
   ═══════════════════════════════════════════════════════════ */

.card-thumbnails {
    width: min(1040px, 100%); margin: 0 auto;
    display: flex; gap: 4px;
    padding: 8px;
    border-radius: 14px;
    border: 0.5px solid rgba(0,0,0,.06);
    background: rgba(255,255,255,.55);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    box-shadow: var(--fc-shadow-xs);
    overflow-x: auto; flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}
.thumbnail {
    flex-shrink: 0;
    width: 48px; height: 48px;
    border: 1px solid var(--fc-glass-border);
    border-radius: var(--fc-r-sm);
    background: var(--fc-glass); color: var(--fc-ink-muted);
    display: grid; place-items: center;
    cursor: pointer;
    transition: all var(--fc-dur) var(--fc-ease);
}
.thumbnail:hover { border-color: var(--fc-glass-glow); background: var(--fc-paper-bright); }
.thumbnail.active {
    background: var(--fc-primary);
    border-color: transparent; color: #fff;
    box-shadow: 0 4px 14px rgba(0,122,255,.22);
}
.thumb-hanzi { font-family: var(--fc-serif); font-size: .82rem; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
  10.  BUTTONS
   ═══════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    min-height: 48px; padding: 0 20px;
    border: none; border-radius: var(--fc-r);
    font-size: .95rem; font-weight: 800;
    cursor: pointer; transition: all var(--fc-dur) var(--fc-ease);
}
.btn svg { width: 18px; height: 18px; }

.btn-primary {
    background: var(--fc-primary);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,122,255,.22);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,122,255,.28);
}
.btn-secondary {
    background: rgba(0,122,255,.07);
    color: var(--fc-primary);
    border: 0.5px solid rgba(0,0,0,.06);
}
.btn-secondary:hover { background: rgba(0,122,255,.12); transform: translateY(-2px); }
.btn-outline {
    background: var(--fc-glass);
    color: var(--fc-ink-soft);
    border: 1px solid var(--fc-glass-border);
}
.btn-outline:hover { border-color: var(--fc-glass-glow); color: var(--fc-primary); }

/* ═══════════════════════════════════════════════════════════
  11.  MODAL
   ═══════════════════════════════════════════════════════════ */

.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.18);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
}
.modal-content {
    position: relative;
    width: min(460px, calc(100% - 24px));
    border-radius: var(--fc-r-xl);
    border: 1px solid var(--fc-glass-border);
    background: var(--fc-paper-bright);
    padding: 24px;
    box-shadow: var(--fc-shadow-xl);
    animation: modal-in .3s var(--fc-ease-bounce);
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(.92) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--fc-glass-border);
}
.modal-header h3 { margin: 0; font-size: 1.15rem; color: var(--fc-ink); }
.btn-close {
    width: 32px; height: 32px;
    border: none; border-radius: var(--fc-r-sm);
    background: rgba(0,0,0,.05);
    color: var(--fc-ink-soft);
    font-size: 1.3rem; line-height: 1;
    cursor: pointer; transition: all var(--fc-dur) var(--fc-ease);
}
.btn-close:hover { background: var(--fc-danger); color: #fff; }
.setting-item { padding: 12px 0; color: var(--fc-ink-soft); }
.setting-item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.setting-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--fc-primary); }

/* ═══════════════════════════════════════════════════════════
  12.  CARD ANIMATIONS (Liquid / Fluid)
   ═══════════════════════════════════════════════════════════ */

/* Dealing — cards drop with liquid bounce */
.stack-card.dealing-in {
    animation: deal-drop .45s var(--fc-ease-spring) forwards;
    animation-delay: var(--deal-delay, 0ms);
    opacity: 0;
}
@keyframes deal-drop {
    0%   { transform: translateY(-120px) rotate(-8deg) scale(.75); opacity: 0; }
    60%  { transform: translateY(6px) rotate(2deg) scale(1.03); opacity: 1; }
    100% { transform: translateY(var(--stack-offset, 0)) rotate(0deg) scale(1); opacity: 1; }
}

/* Card enter */
.card-transitioning .flashcard { opacity: 0; transform: scale(.96); }
.card-enter .flashcard {
    animation: card-slide-in .4s var(--fc-ease-spring) forwards;
}
@keyframes card-slide-in {
    from { opacity: 0; transform: translateX(40px) scale(.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* Reveal */
.reveal-hint.revealed.reveal-animation {
    animation: reveal-glow .5s ease-out;
}
@keyframes reveal-glow {
    0%   { transform: scale(1); box-shadow: 0 0 0 rgba(22,163,74,0); }
    50%  { transform: scale(1.08); box-shadow: 0 0 16px rgba(22,163,74,.25); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(22,163,74,0); }
}

/* Confetti */
.confetti-particle { pointer-events: none; z-index: 9999; }

/* Bounce In for generic use */
.bounce-in { animation: bounceIn .6s var(--fc-ease-bounce); }
@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.fade-scale-in { animation: fadeScaleIn .3s ease-out forwards; }
@keyframes fadeScaleIn {
    from { opacity: 0; transform: scale(.9); }
    to   { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════════════════════
  13.  STATE VISIBILITY
   ═══════════════════════════════════════════════════════════ */

.flashcard-module[data-state="quiz"]     .card-navigation,
.flashcard-module[data-state="quiz"]     .card-thumbnails,
.flashcard-module[data-state="complete"] .card-navigation,
.flashcard-module[data-state="complete"] .card-thumbnails,
.flashcard-module[data-state="result"]   .card-navigation,
.flashcard-module[data-state="result"]   .card-thumbnails { display: none; }

/* ═══════════════════════════════════════════════════════════
  14.  UTILITIES
   ═══════════════════════════════════════════════════════════ */

.hidden { display: none !important; }
.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;
}

/* ═══════════════════════════════════════════════════════════
  15.  RESPONSIVE — Mobile First
   ═══════════════════════════════════════════════════════════ */

/* Base: ≤ 480px (phone) */
@media (max-width: 480px) {
    .fc-shell { width: calc(100% - 16px); padding-top: 16px; }

    .fc-header { grid-template-columns: auto 1fr; gap: 12px; }
    .header-tag { grid-column: 1/-1; justify-self: start; }
    .title-icon { width: 48px; height: 48px; font-size: 1.5rem; border-radius: var(--fc-r); }
    .title-text h1 { font-size: 1.5rem; }

    .fc-hero { grid-template-columns: 1fr; padding: 20px; gap: 16px; }
    .fc-stats { grid-template-columns: 1fr; }
    .fc-stat-card { padding: 12px; }

    .fc-panel { padding: 16px; border-radius: var(--fc-r-lg); }
    .fc-hero { border-radius: var(--fc-r-lg); }

    .level-grid { grid-template-columns: 1fr; }
    .level-card { min-height: 100px; padding: 16px; border-radius: var(--fc-r); }
    .level-num { width: 46px; height: 46px; border-radius: var(--fc-r-sm); font-size: 1.2rem; }

    .fc-option-grid { grid-template-columns: 1fr; }
    .option-group { padding: 12px; }

    .flashcard-module { padding: 12px 8px 20px; }
    .flashcard-header { padding: 12px; border-radius: var(--fc-r); }
    .flashcard-content { padding: 16px; border-radius: var(--fc-r-xl); min-height: 56vh; }

    .card-display { max-width: 100%; aspect-ratio: 3/4; }
    .flashcard-front, .flashcard-back { padding: 16px 14px; border-radius: var(--fc-r-lg); }
    .card-hanzi { font-size: clamp(2.2rem, 14vw, 3.5rem); }
    .card-meaning { font-size: .95rem; }
    .card-pinyin { font-size: .9rem; }

    .btn-audio { width: 36px; height: 36px; right: 10px; bottom: 10px; }
    .card-reveal-hints { left: 12px; bottom: 12px; }
    .reveal-hint { padding: 4px 8px; font-size: .68rem; }

    .card-navigation { padding: 8px 12px; border-radius: var(--fc-r); flex-wrap: wrap; gap: 8px; }
    .nav-btn span { display: none; }
    .nav-actions { flex: 1; justify-content: center; }
    .action-btn { min-width: 0; flex: 1; min-height: 44px; }
    .action-btn .btn-label { display: none; }

    .card-thumbnails { padding: 4px; border-radius: var(--fc-r-sm); }
    .thumbnail { width: 36px; height: 36px; }
    .thumb-hanzi { font-size: .72rem; }

    .prompt-text { font-size: 2rem; }
    .result-stats { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 1.3rem; }
    .result-actions { flex-direction: column; }
    .result-actions .btn { width: 100%; }

    .mode-tabs { border-radius: var(--fc-r-sm); padding: 4px; }
    .mode-tab { padding: 4px 8px; font-size: .78rem; }
    .tab-label { display: none; }

    .section-head { flex-direction: column; align-items: flex-start; }
    .fc-footer { justify-content: flex-start; }
    .footer-dot { display: none; }
}

/* 481–720px (small tablet) */
@media (min-width: 481px) and (max-width: 720px) {
    .fc-shell { width: calc(100% - 24px); }
    .fc-hero { grid-template-columns: 1fr; padding: 24px; }
    .fc-stats { grid-template-columns: repeat(3, 1fr); }
    .level-grid { grid-template-columns: repeat(2, 1fr); }
    .fc-option-grid { grid-template-columns: 1fr; }

    .card-display { max-width: 340px; aspect-ratio: 3/4; }
    .flashcard-content { min-height: 52vh; }

    .card-navigation { flex-wrap: wrap; gap: 8px; }
    .nav-actions { flex: 1; justify-content: center; }
    .action-btn { min-width: 0; flex: 1; }

    .result-stats { grid-template-columns: repeat(3, 1fr); }

    .section-head { flex-direction: column; align-items: flex-start; }
}

/* 721–960px (tablet) */
@media (min-width: 721px) and (max-width: 960px) {
    .fc-hero { grid-template-columns: 1fr; }
    .fc-option-grid { grid-template-columns: repeat(3, 1fr); }
    .level-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ≥961px (desktop) */
@media (min-width: 961px) {
    .fc-hero { grid-template-columns: 1.6fr .9fr; }
    .level-grid { grid-template-columns: repeat(3, 1fr); }
    .fc-option-grid { grid-template-columns: repeat(3, 1fr); }
    .result-stats { grid-template-columns: repeat(5, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
  16.  PRINT
   ═══════════════════════════════════════════════════════════ */

@media print {
    .flashcard-module, .selection-screen { background: #fff !important; }
    .card-navigation, .card-thumbnails, .mode-tabs { display: none; }
}

/* ═══════════════════════════════════════════════════════════
  17.  REDUCED MOTION
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .flashcard-inner { transition-duration: .01ms !important; }
}
