/**
 * SpeakKhmer — Mobile Design System & Style Contract
 * Optimized for Samsung Galaxy S26 Ultra (412x915 CSS viewport, Dynamic AMOLED 2X)
 * Modern One UI / iOS Fluid Style with Glassmorphism & Spring Dynamics
 * Stack: Raw Procedural PHP + Vanilla JS + Mobile PWA
 */

/* ==========================================================================
   1. GOOGLE FONTS IMPORT
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+Khmer:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   2. DESIGN TOKENS (Locked UI Contract)
   ========================================================================== */
:root {
    /* --- Primary Brand Palette (Indigo) --- */
    --color-primary:        #4F46E5;    /* Indigo 600 */
    --color-primary-light:  #818CF8;    /* Indigo 400 */
    --color-primary-dark:   #3730A3;    /* Indigo 800 */
    --color-primary-50:     #EEF2FF;    /* Indigo 50 */
    --color-primary-100:    #E0E7FF;    /* Indigo 100 */

    /* --- Semantic Colors --- */
    --color-success:        #10B981;    /* Emerald 500 */
    --color-success-light:  #ECFDF5;    /* Emerald 50 */
    --color-success-dark:   #065F46;    /* Emerald 800 */
    --color-warning:        #F59E0B;    /* Amber 500 */
    --color-warning-light:  #FFFBEB;    /* Amber 50 */
    --color-error:          #EF4444;    /* Rose/Red 500 */
    --color-error-light:    #FEF2F2;    /* Red 50 */
    --color-error-dark:     #991B1B;    /* Red 800 */

    /* --- Refined Modern Neutrals --- */
    --color-bg:             #F1F5F9;    /* Clean soft slate canvas */
    --color-surface:        #FFFFFF;    /* Pure white elevated surface */
    --color-surface-trans:  rgba(255, 255, 255, 0.85);
    --color-text:           #0F172A;    /* Slate 900 — deep high-contrast text */
    --color-text-secondary: #475569;    /* Slate 600 */
    --color-text-muted:     #94A3B8;    /* Slate 400 */
    --color-border:         #E2E8F0;    /* Slate 200 */
    --color-divider:        #F8FAFC;    /* Slate 50 */
}

/* ==========================================================================
   2.1 AMOLED DARK MODE TOKENS (Instant Theme Engine)
   ========================================================================== */
body.dark-mode {
    --color-bg:             #0F172A;    /* Slate 900 / AMOLED Obsidian */
    --color-surface:        #1E293B;    /* Slate 800 */
    --color-surface-trans:  rgba(30, 41, 59, 0.88);
    --color-text:           #F8FAFC;    /* Slate 50 */
    --color-text-secondary: #94A3B8;    /* Slate 400 */
    --color-text-muted:     #64748B;    /* Slate 500 */
    --color-border:         #334155;    /* Slate 700 */
    --color-divider:        #1E293B;
    --color-primary-50:     rgba(99, 102, 241, 0.15);
    --color-primary-100:    rgba(99, 102, 241, 0.25);
    --shadow-card:          0 10px 25px -5px rgba(0, 0, 0, 0.45);
    --shadow-floating:      0 16px 36px -8px rgba(0, 0, 0, 0.6);
}

:root {

    /* --- Module Accent Gradients --- */
    --grad-module-1:        linear-gradient(135deg, #6366F1 0%, #4338CA 100%); /* Greetings (Indigo) */
    --grad-module-2:        linear-gradient(135deg, #F59E0B 0%, #D97706 100%); /* Tuk-Tuk (Amber) */
    --grad-module-3:        linear-gradient(135deg, #10B981 0%, #059669 100%); /* Market (Emerald) */
    --grad-module-4:        linear-gradient(135deg, #F43F5E 0%, #BE123C 100%); /* Food (Rose) */
    --grad-module-5:        linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%); /* Social (Sky) */

    /* --- Typography Families & Sizes --- */
    --font-latin:           'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
    --font-khmer:           'Noto Sans Khmer', 'Khmer OS', sans-serif;
    
    --font-size-base:       15px;
    --font-size-khmer-xl:   36px;       /* Native Khmer display on Practice Card */
    --font-size-khmer-lg:   24px;       /* Khmer in Module cards */
    --font-size-phonetic:   20px;       /* Phonetic spelling */
    --font-size-guide:      15px;       /* Pronunciation guide */
    --font-size-meaning:    18px;       /* English meaning */
    --font-size-sm:         14px;       /* Labels, captions */
    --font-size-xs:         12px;       /* Badges, meta tags */

    --line-height:          1.55;
    --line-height-khmer:    1.75;       /* Ample line height for Khmer diacritics */

    /* --- Spacing --- */
    --space-2xs: 2px;
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;

    /* --- Mobile Layout & Safe Areas --- */
    --viewport-width:       412px;      /* S26 Ultra CSS viewport width */
    --header-height:        60px;
    --bottom-nav-height:    64px;
    --card-padding:         20px;
    --safe-area-top:        env(safe-area-inset-top, 0px);
    --safe-area-bottom:     env(safe-area-inset-bottom, 0px);

    /* --- Modern Squircles (Border Radius) --- */
    --radius-sm:            10px;
    --radius-md:            14px;
    --radius-lg:            18px;
    --radius-xl:            22px;
    --radius-2xl:           28px;
    --radius-3xl:           32px;
    --radius-full:          9999px;

    /* --- Refined Ambient Shadows (AMOLED Optimized) --- */
    --shadow-sm:            0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card:          0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.02);
    --shadow-card-elevated: 0 14px 34px -10px rgba(79, 70, 229, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    --shadow-card-hover:    0 18px 36px -6px rgba(79, 70, 229, 0.12), 0 8px 16px -4px rgba(0, 0, 0, 0.04);
    --shadow-floating:      0 16px 36px -8px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-modal:         0 25px 50px -12px rgba(15, 23, 42, 0.25);
    --shadow-record-glow:   0 8px 24px -4px rgba(79, 70, 229, 0.4);
    --shadow-recording-glow: 0 0 28px rgba(239, 68, 68, 0.65);

    /* --- Touch Targets --- */
    --touch-min:            48px;       /* Material Design 3 / WCAG AA touch target */
    --record-btn:           64px;       /* Primary bottom CTA button height */

    /* --- Score Thresholds --- */
    --score-pass:           70;         /* >= 70% is OK */
    --score-acceptable:     50;         /* 50-69% is acceptable */

    /* --- Audio Playback Speeds --- */
    --playback-slow:        0.7;
    --playback-normal:      1.0;
}

/* ==========================================================================
   3. BASE RESET & MOBILE DEFAULTS
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

button, a, [role="button"], .touch-target, .module-card, .btn-nav, .category-chip, .puzzle-tile, .pro-stat-pill {
    touch-action: manipulation;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 16px;
    scroll-behavior: smooth;
    background-color: #090D16; /* Deep obsidian frame on desktop screens */
}

body {
    font-family: var(--font-latin);
    font-size: var(--font-size-base);
    line-height: var(--line-height);
    color: var(--color-text);
    background-color: #090D16;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: flex-start;

    /* Mobile UX Rules: prevent accidental pull-to-refresh & text selection */
    overscroll-behavior-y: contain;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Re-enable selection for inputs and text areas */
input, textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* ==========================================================================
   3.1 STAGESHOW TACTILE SPRING COMPRESSION & TOUCH MANIPULATION
   ========================================================================== */
.module-card:active {
    transform: scale(0.98);
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
}

.puzzle-tile:active {
    transform: scale(0.93) translateY(1px);
}

.category-chip:active {
    transform: scale(0.94);
}

.btn-nav:active, .btn-audio:active, .nav-item:active {
    transform: scale(0.95);
}

.puzzle-hero-card:active {
    transform: scale(0.985);
}

/* ==========================================================================
   4. MOBILE CONTAINER (S26 Ultra Viewport Lock 412x915)
   ========================================================================== */
.app-mobile-container {
    width: 100%;
    max-width: 412px; /* Strict S26 Ultra width */
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.45);
    overflow-x: hidden;

    /* Safe Area Insets */
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
}

.app-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Content spacing buffer for floating navigation (Includes safe area inset) */
.with-floating-nav {
    padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   5. GLASSMORPHISM & AMBIENT GLOW UTILITIES
   ========================================================================== */
.glass-bar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.65);
}

.glass-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-card-elevated);
}

.glow-primary {
    box-shadow: var(--shadow-record-glow);
}

.glow-success {
    box-shadow: 0 8px 24px -4px rgba(16, 185, 129, 0.35);
}

.glow-card {
    box-shadow: var(--shadow-card-elevated);
}

/* ==========================================================================
   6. TYPOGRAPHY SCALES & KHMER RENDERING
   ========================================================================== */
.khmer-text {
    font-family: var(--font-khmer);
    line-height: var(--line-height-khmer);
    word-break: break-word;
}

/* Main Khmer Display in Practice Card (36px Bold) */
.text-khmer-xl {
    font-family: var(--font-khmer);
    font-size: var(--font-size-khmer-xl);
    line-height: var(--line-height-khmer);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* Khmer in Module lists / subtitles (24px) */
.text-khmer-lg {
    font-family: var(--font-khmer);
    font-size: var(--font-size-khmer-lg);
    line-height: var(--line-height-khmer);
    font-weight: 600;
}

/* Phonetic Spelling (20px Indigo) */
.text-phonetic {
    font-size: var(--font-size-phonetic);
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.3px;
}

/* Pronunciation Guide (15px Italic Slate) */
.text-guide {
    font-size: var(--font-size-guide);
    color: var(--color-text-secondary);
    font-style: italic;
    font-weight: 500;
}

/* English Meaning (18px Dark) */
.text-meaning {
    font-size: var(--font-size-meaning);
    font-weight: 700;
    color: var(--color-text);
}

/* Utilities */
.text-sm {
    font-size: var(--font-size-sm);
    line-height: 1.45;
}

.text-xs {
    font-size: var(--font-size-xs);
    line-height: 1.35;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-secondary {
    color: var(--color-text-secondary);
}

/* ==========================================================================
   7. SPRING MICRO-INTERACTIONS & TOUCH TARGETS
   ========================================================================== */
.touch-target {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

button, .btn, .touch-target {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.18s ease,
                box-shadow 0.18s ease,
                opacity 0.15s ease;
}

/* Bouncy spring press states */
button:active, .btn:active, .touch-target:active {
    transform: scale(0.96);
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:disabled, .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

/* ==========================================================================
   8. HEADER & FLOATING ISLAND NAVIGATION
   ========================================================================== */
.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.app-header-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.3px;
}

.btn-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.85);
    color: var(--color-text);
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.btn-icon:active {
    background-color: var(--color-divider);
}

/* Sleek Floating Island Bottom Navigation Dock (Apple Dynamic Island / Fluid Spring Style) */
.floating-island-nav {
    position: fixed;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 36px);
    max-width: 396px;
    height: 64px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 20px 45px -12px rgba(15, 23, 42, 0.16), 0 4px 16px -2px rgba(0, 0, 0, 0.05), inset 0 1px 1px rgba(255, 255, 255, 0.9);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 60;
}

.nav-active-pill {
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 6px;
    width: calc((100% - 12px) / 5);
    border-radius: 9999px;
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    box-shadow: 0 6px 18px -2px rgba(79, 70, 229, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.3);
    transition: transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.2s ease;
    z-index: 1;
    pointer-events: none;
    transform: translateX(0);
    will-change: transform;
}

.nav-item {
    position: relative;
    z-index: 2;
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #64748B;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.2px;
    transition: color 0.25s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 9999px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: #FFFFFF;
    font-weight: 700;
}

.nav-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-label {
    display: inline-block;
    line-height: 1.1;
}

.nav-item.active .nav-icon-wrap {
    animation: nav-icon-bounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes nav-icon-bounce {
    0% { transform: scale(0.85); }
    50% { transform: scale(1.22) translateY(-2px); }
    100% { transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .nav-active-pill {
        transition: transform 0.05s ease;
    }
    .nav-item.active .nav-icon-wrap {
        animation: none;
    }
}

/* ==========================================================================
   IN-PAGE MOBILE TAB VIEWS (Samsung Galaxy S26 Ultra Fluid Ergonomics)
   ========================================================================== */
.tab-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.tab-view.hidden {
    display: none !important;
}

.tab-view.active {
    display: flex !important;
    animation: tabViewFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes tabViewFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Legacy fallback bottom nav if needed */
.bottom-nav {
    height: var(--bottom-nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    position: sticky;
    bottom: 0;
    z-index: 40;
    flex-shrink: 0;
}

/* ==========================================================================
   9. HERO WIDGET & STREAK CARD (index.php)
   ========================================================================== */
.hero-streak-card {
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    border-radius: var(--radius-xl);
    padding: 18px 20px;
    color: #FFFFFF;
    margin-bottom: 20px;
    box-shadow: 0 14px 28px -6px rgba(79, 70, 229, 0.35);
    position: relative;
    overflow: hidden;
}

.hero-streak-card::before {
    content: '';
    position: absolute;
    top: -24px;
    right: -24px;
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 9999px;
    pointer-events: none;
}

.streak-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

/* ==========================================================================
   10. MODULE HUB CARDS & MICRO-COMPONENTS (index.php)
   ========================================================================== */
.module-card {
    background-color: var(--color-surface);
    border-radius: 22px; /* Pro modern squircle */
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: var(--shadow-card);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease,
                border-color 0.2s ease;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

@media (hover: hover) and (pointer: fine) {
    .module-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-card-hover);
        border-color: var(--color-primary-light);
    }
}

.module-card:active {
    transform: scale(0.98);
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
    box-shadow: var(--shadow-card-elevated);
}

.module-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.module-card-top-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.module-icon-badge {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #FFFFFF;
    flex-shrink: 0;
    box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.12);
}

.module-card.locked {
    background: #F8FAFC;
    opacity: 0.85;
    border: 1.5px dashed var(--color-border);
    box-shadow: none;
}

.module-card.locked .module-icon-badge {
    filter: grayscale(1);
    opacity: 0.7;
    background: #CBD5E1 !important;
}

/* --- Status Badges (Mastered, In-Progress, New, Locked) --- */
.module-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.module-status-badge.mastered {
    background: #ECFDF5;
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.module-status-badge.in-progress {
    background: #EEF2FF;
    color: #4F46E5;
    border: 1px solid rgba(79, 70, 229, 0.25);
}

.module-status-badge.new {
    background: #F1F5F9;
    color: #64748B;
    border: 1px solid #E2E8F0;
    font-size: 10px;
    text-transform: uppercase;
}

.module-status-badge.locked {
    background: #F1F5F9;
    color: #94A3B8;
    border: 1px solid #E2E8F0;
    padding: 4px;
}

/* --- Module Card Typography & Meta Elements --- */
.module-tag {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-primary);
}

.module-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-text);
    margin: 2px 0 0 0;
    letter-spacing: -0.2px;
}


.module-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-top: 6px;
}

.module-locked-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 9999px;
    background: #F1F5F9;
    font-size: 11px;
    font-weight: 600;
    color: #64748B;
    border: 1px solid #E2E8F0;
    width: fit-content;
}

/* ==========================================================================
   PRO MOBILE STATS ROW & PILLS (Adaptive: List & 2-Col Grid)
   ========================================================================== */
.module-pro-stats-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    width: 100%;
}

.pro-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* 1. Score Pill (Vibrant Emerald) */
.pro-stat-pill.score-pill {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid rgba(16, 185, 129, 0.35);
}
.pro-stat-pill.score-pill svg {
    color: #059669;
}
.pro-stat-pill .pro-stat-val {
    font-weight: 800;
}
.pro-stat-pill .pro-stat-lbl {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.85;
    text-transform: uppercase;
}
.pro-stat-pill .pro-stat-dot {
    opacity: 0.35;
    margin: 0 1px;
}
.pro-stat-pill .pro-stat-best {
    font-size: 10.5px;
    font-weight: 600;
    opacity: 0.85;
}

/* 2. Trend Pill (Indigo Accent) */
.pro-stat-pill.trend-pill {
    background: #EEF2FF;
    color: #4338CA;
    border: 1px solid rgba(99, 102, 241, 0.35);
}
.pro-stat-pill.trend-pill svg {
    color: #6366F1;
}

/* 3. Attempts Pill (Clean Slate) */
.pro-stat-pill.attempts-pill {
    background: #F1F5F9;
    color: #475569;
    border: 1px solid rgba(148, 163, 184, 0.3);
    margin-left: auto;
}
.pro-stat-pill.attempts-pill svg {
    color: #64748B;
}

/* 4. Neutral Unpracticed Pill */
.pro-stat-pill.neutral-pill {
    background: #F8FAFC;
    color: #64748B;
    border: 1px solid rgba(226, 232, 240, 0.9);
    font-size: 11px;
}
.pro-stat-pill.neutral-pill:last-child {
    margin-left: auto;
}

body.dark-mode .pro-stat-pill.score-pill {
    background: rgba(16, 185, 129, 0.18);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.35);
}
body.dark-mode .pro-stat-pill.trend-pill {
    background: rgba(99, 102, 241, 0.18);
    color: #A5B4FC;
    border-color: rgba(129, 140, 248, 0.35);
}
body.dark-mode .pro-stat-pill.attempts-pill,
body.dark-mode .pro-stat-pill.neutral-pill {
    background: rgba(148, 163, 184, 0.15);
    color: #94A3B8;
    border-color: rgba(148, 163, 184, 0.25);
}

/* ==========================================================================
   10.1 MODULE SEARCH & FAST CATEGORY DISCOVERY
   ========================================================================== */
.module-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    margin-top: 14px;
    margin-bottom: 10px;
}

.module-search-wrap .svg-icon {
    position: absolute;
    left: 14px;
    color: var(--color-text-muted);
    pointer-events: none;
    z-index: 2;
}

.module-search-input {
    width: 100%;
    height: 46px;
    padding: 0 40px 0 40px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--color-text);
    outline: none;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition: all 0.2s ease;
    -webkit-appearance: none;
}

.module-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
    background: #FFFFFF;
}

body.dark-mode .module-search-input {
    background: #1E293B;
    border-color: #334155;
    color: #F8FAFC;
}

body.dark-mode .module-search-input:focus {
    background: #0F172A;
    border-color: #6366F1;
}

.btn-clear-search {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
    .btn-clear-search:hover {
        background: var(--color-text-muted);
        color: #FFFFFF;
    }
}

.btn-clear-search:active {
    background: var(--color-text-muted);
    color: #FFFFFF;
}

.btn-clear-search.hidden {
    display: none !important;
}

/* Horizontal Scrollable Category Filter Carousel */
.module-category-carousel {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px 10px 2px;
    margin: 0 -2px;
}

.module-category-carousel::-webkit-scrollbar {
    display: none;
}

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.category-chip svg {
    color: var(--color-text-muted);
    transition: color 0.2s ease;
}

.category-chip:active {
    transform: scale(0.94);
}

.category-chip.active {
    background: linear-gradient(135deg, #4F46E5 0%, #4338CA 100%);
    border-color: #4338CA;
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.category-chip.active svg {
    color: #FFFFFF;
}

body.dark-mode .category-chip {
    background: #1E293B;
    border-color: #334155;
    color: #94A3B8;
}

body.dark-mode .category-chip.active {
    background: linear-gradient(135deg, #6366F1 0%, #4F46E5 100%);
    border-color: #6366F1;
    color: #FFFFFF;
}

/* Filter Meta & View Switcher Bar */
.module-filter-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 2px;
}

.module-count-text {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.2px;
}

.view-switcher-group {
    display: flex;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 2px;
    gap: 2px;
}

body.dark-mode .view-switcher-group {
    background: #1E293B;
    border-color: #334155;
}

.btn-view-toggle {
    width: 34px;
    height: 32px;
    border-radius: calc(var(--radius-md) - 2px);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.btn-view-toggle.active {
    background: var(--color-primary-50);
    color: var(--color-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

body.dark-mode .btn-view-toggle.active {
    background: #312E81;
    color: #818CF8;
}

/* ==========================================================================
   10.2 GRID VIEW (2-column layout for fast visual exploration)
   ========================================================================== */
.module-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.2s ease;
}

.module-list.view-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    grid-auto-rows: 1fr; /* Equal row heights */
}

.module-list.view-grid .module-card {
    min-height: 205px;
    height: 100%;
    padding: 14px 12px;
    border-radius: 22px; /* Pro modern squircle */
    background: #FFFFFF;
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 18px -4px rgba(15, 23, 42, 0.07), 0 2px 6px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
}

.module-list.view-grid .module-card:active {
    transform: scale(0.98);
}

.module-list.view-grid .module-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
}

.module-list.view-grid .module-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}


.module-list.view-grid .module-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.module-list.view-grid .module-title,
.module-list.view-grid .module-card h2 {
    font-size: 14.5px;
    font-weight: 800;
    line-height: 1.25;
    min-height: 36px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
}

.module-list.view-grid .module-card .khmer-text {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-primary);
    opacity: 0.85;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 2px;
}

.module-list.view-grid .module-desc,
.module-list.view-grid .module-card p.text-xs {
    display: none; /* Hide verbose paragraph in 2-col */
}

.module-list.view-grid .module-card-footer,
.module-list.view-grid .module-card > div:last-child {
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--color-divider);
}

.module-list.view-grid .progress-bar-track {
    height: 4px;
    border-radius: 9999px;
    background: #EEF2FF;
}

/* --------------------------------------------------------------------------
   2-Column Grid Adaptations (.module-list.view-grid)
   -------------------------------------------------------------------------- */
.module-list.view-grid .module-pro-stats-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 4px !important;
    margin-top: 6px !important;
}

.module-list.view-grid .pro-stat-pill {
    padding: 2.5px 6px !important;
    font-size: 10px !important;
    gap: 3px !important;
}

.module-list.view-grid .pro-stat-pill.attempts-pill {
    margin-left: 0 !important;
}

/* In 2-col Grid, hide verbose secondary labels so pills fit on 1 crisp line */
.module-list.view-grid .pro-stat-pill .pro-stat-best,
.module-list.view-grid .pro-stat-pill .pro-stat-dot {
    display: none !important;
}

/* If both Trend and Attempts exist in Grid, prioritize Trend on the right */
.module-list.view-grid .pro-stat-pill.trend-pill + .pro-stat-pill.attempts-pill {
    display: none !important;
}

.module-list.view-grid .module-card.locked {
    background: #F8FAFC;
    border: 1.5px dashed #CBD5E1;
    box-shadow: none;
    opacity: 0.85;
}

.module-list.view-grid .module-card.locked .module-icon-badge {
    background: #E2E8F0 !important;
    color: #94A3B8 !important;
    box-shadow: none;
}

/* Dark mode tokens */
body.dark-mode .module-list.view-grid .module-card,
.dark-mode .module-list.view-grid .module-card {
    background: #1E293B;
    border: 1px solid rgba(51, 65, 85, 0.85);
    box-shadow: 0 4px 18px -4px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
}

body.dark-mode .module-list.view-grid .module-card.locked,
.dark-mode .module-list.view-grid .module-card.locked {
    background: #0F172A;
    border: 1.5px dashed #334155;
    box-shadow: none;
    opacity: 0.75;
}

body.dark-mode .module-list.view-grid .module-card.locked .module-icon-badge,
.dark-mode .module-list.view-grid .module-card.locked .module-icon-badge {
    background: #1E293B !important;
    color: #64748B !important;
}

body.dark-mode .module-list.view-grid .progress-bar-track,
.dark-mode .module-list.view-grid .progress-bar-track {
    background: rgba(99, 102, 241, 0.18);
}

/* Empty Search State */
.module-empty-state {
    padding: 38px 20px;
    text-align: center;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1.5px dashed var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

.module-empty-state.hidden {
    display: none !important;
}

.module-empty-state h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--color-text);
    margin: 6px 0 0 0;
}

.module-empty-state p {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 0;
}

.btn-reset-search {
    margin-top: 8px;
    padding: 8px 18px;
    background: var(--color-primary-50);
    color: var(--color-primary);
    border: 1px solid var(--color-primary-200);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .btn-reset-search:hover {
        background: var(--color-primary);
        color: #FFFFFF;
    }
}

.btn-reset-search:active {
    background: var(--color-primary);
    color: #FFFFFF;
}

body.dark-mode .btn-reset-search {
    background: #312E81;
    color: #818CF8;
    border-color: #4F46E5;
}

/* ==========================================================================
   11. PRACTICE CARDS & ANIMATIONS (practice.php)
   ========================================================================== */
.practice-card-wrapper {
    position: relative;
    width: 100%;
    perspective: 1000px;
}

.practice-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-2xl); /* 28px squircle */
    border: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: var(--shadow-card-elevated);
    padding: 16px 18px 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    will-change: transform, opacity;
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

.practice-card.card-flipped {
    border-color: rgba(99, 102, 241, 0.5);
    background: linear-gradient(180deg, rgba(238, 242, 255, 0.6) 0%, var(--color-surface) 100%);
    box-shadow: 0 12px 28px -6px rgba(99, 102, 241, 0.18), 0 8px 12px -6px rgba(99, 102, 241, 0.12);
}

/* Subtle ambient decorative gradient background inside card */
.practice-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 90px;
    background: linear-gradient(180deg, rgba(238, 242, 255, 0.6) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* Smooth slide animations between cards */
.practice-card-enter {
    animation: cardSlideInRight 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.practice-card-exit {
    animation: cardSlideOutLeft 0.22s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

.practice-card-enter-left {
    animation: cardSlideInLeft 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.practice-card-exit-right {
    animation: cardSlideOutRight 0.22s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

@keyframes cardSlideInRight {
    from {
        opacity: 0;
        transform: translate3d(40px, 0, 0) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes cardSlideOutLeft {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    to {
        opacity: 0;
        transform: translate3d(-40px, 0, 0) scale(0.97);
    }
}

@keyframes cardSlideInLeft {
    from {
        opacity: 0;
        transform: translate3d(-40px, 0, 0) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes cardSlideOutRight {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
    to {
        opacity: 0;
        transform: translate3d(40px, 0, 0) scale(0.97);
    }
}

/* Phonetic badge */
.phonetic-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    background: var(--color-primary-50);
    border-radius: var(--radius-full);
    border: 1px solid rgba(79, 70, 229, 0.15);
}

/* Pronunciation guide badge */
.guide-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--color-divider);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
}

/* ==========================================================================
   12. THUMB ZONE CONTROLS: AUDIO, RECORD & SCORE DOCK
   ========================================================================== */
.thumb-zone {
    margin-top: auto;
    padding-top: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Audio Controls Row */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.btn-audio {
    min-height: var(--touch-min);
    height: 48px;
    border-radius: var(--radius-lg);
    background-color: var(--color-surface);
    border: 1.5px solid var(--color-border);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 0 var(--space-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-audio:active,
.btn-audio.active {
    background-color: var(--color-primary-50);
    border-color: var(--color-primary);
    color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.voice-toggle-group {
    display: flex;
    background-color: #E2E8F0;
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

.voice-toggle-btn {
    min-height: 38px;
    padding: 0 12px;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.voice-toggle-btn.active {
    background-color: #FFFFFF;
    color: var(--color-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* 64px tall Record Button (Full Width, Primary CTA) */
.btn-record {
    height: var(--record-btn);
    min-height: var(--record-btn);
    width: 100%;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    color: #FFFFFF;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.25), 0 8px 24px -4px rgba(79, 70, 229, 0.45);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease,
                background 0.2s ease,
                border-color 0.2s ease;
}

#record-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-record:active {
    transform: scale(0.97);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* Recording active state: vibrant coral red + pulsating outer glow ring */
.btn-record.recording {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25), 0 8px 25px -4px rgba(239, 68, 68, 0.55);
    border-color: rgba(255, 255, 255, 0.35);
    animation: recordGlowPulse 1.2s infinite ease-in-out;
}

@keyframes recordGlowPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 8px 25px -4px rgba(239, 68, 68, 0.55);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(239, 68, 68, 0), 0 8px 25px -4px rgba(239, 68, 68, 0.55);
        transform: scale(1.012);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 8px 25px -4px rgba(239, 68, 68, 0.55);
        transform: scale(1);
    }
}

/* Audio Waveform Visualizer - Hidden when idle so #record-label stays 100% dead center */
.waveform-container {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3.5px;
    height: 28px;
    width: auto;
    flex-shrink: 0;
    margin-left: 2px;
}

.waveform-container.active,
.btn-record.recording .waveform-container {
    display: inline-flex;
}

.waveform-bar {
    width: 3.5px;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-full);
    transition: height 0.08s ease, background-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.waveform-container.active .waveform-bar,
.btn-record.recording .waveform-bar {
    animation: soundwave 0.75s ease-in-out infinite alternate;
}

.waveform-bar:nth-child(1) { animation-delay: 0.08s; }
.waveform-bar:nth-child(2) { animation-delay: 0.22s; }
.waveform-bar:nth-child(3) { animation-delay: 0.40s; }
.waveform-bar:nth-child(4) { animation-delay: 0.12s; }
.waveform-bar:nth-child(5) { animation-delay: 0.32s; }
.waveform-bar:nth-child(6) { animation-delay: 0.52s; }
.waveform-bar:nth-child(7) { animation-delay: 0.18s; }
.waveform-bar:nth-child(8) { animation-delay: 0.36s; }

@keyframes soundwave {
    0% {
        height: 6px;
    }
    100% {
        height: 28px;
    }
}

/* ==========================================================================
   13. STATUS BADGES & STABLE SCORE EVALUATION DOCK (Zero Layout Shift)
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.35;
}

.badge-ok {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-retry {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-progress {
    background-color: var(--color-primary-50);
    color: var(--color-primary);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

/* Stable Fixed-Height Feedback & Score Slot (Zero Layout Shift) */
.score-box {
    width: 100%;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    border-radius: var(--radius-xl);
    padding: 0 16px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: background-color 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, color 0.22s ease;
}

.score-state-view {
    width: 100%;
    height: 100%;
    align-items: center;
    transition: opacity 0.18s ease;
}

.score-state-view.hidden {
    display: none !important;
}

/* 1. Idle State */
.score-box.idle {
    background: #F8FAFC;
    border-color: rgba(226, 232, 240, 0.95);
    color: var(--color-text-secondary);
}

/* 2. Listening State */
.score-box.listening {
    background: #FEF2F2;
    border-color: #F87171;
    color: #DC2626;
    animation: listeningPulse 1.2s infinite ease-in-out;
}

@keyframes listeningPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.12);
    }
}

/* 3. Evaluating State */
.score-box.evaluating {
    background: #EEF2FF;
    border-color: #818CF8;
    color: #4F46E5;
    animation: evaluatingPulse 1.2s infinite ease-in-out;
}

@keyframes evaluatingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.12);
    }
}

/* 4. Pass State (>=70%) */
.score-box.pass {
    background: #ECFDF5;
    border-color: #10B981;
    color: #065F46;
    box-shadow: 0 6px 18px -4px rgba(16, 185, 129, 0.25);
}

/* 5. Retry State (<70%) */
.score-box.retry {
    background: #FEF2F2;
    border-color: #EF4444;
    color: #991B1B;
    box-shadow: 0 6px 18px -4px rgba(239, 68, 68, 0.2);
}

.score-box.acceptable {
    background: #FFFBEB;
    border-color: #F59E0B;
    color: #92400E;
}

.score-percentage {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
}

/* ==========================================================================
   14. CARD NAVIGATION & AUTO-ADVANCE TOGGLE
   ========================================================================== */
.practice-nav-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.btn-nav {
    flex: 1;
    min-height: 48px;
    border-radius: var(--radius-lg);
    background-color: var(--color-surface);
    border: 1.5px solid var(--color-border);
    color: var(--color-text);
    font-size: var(--font-size-base);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-nav-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border-color: transparent;
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.pulse-green {
    animation: greenPulse 1.5s infinite;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%) !important;
    border-color: transparent !important;
    color: #FFFFFF !important;
}

@keyframes greenPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
        transform: scale(1);
    }
}

/* ==========================================================================
   15. PROGRESS BARS & SEGMENTS
   ========================================================================== */
.progress-bar-track {
    width: 100%;
    height: 8px;
    background-color: #E2E8F0;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4F46E5 0%, #818CF8 100%);
    border-radius: var(--radius-full);
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   16. FORM CONTROLS (Login & Inputs)
   ========================================================================== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-bottom: 16px;
}

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text);
}

.form-input {
    min-height: 52px;
    padding: 0 16px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-family: var(--font-latin);
    background-color: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    outline: none;
}

/* ==========================================================================
   17. MODALS & CELEBRATION DIALOG
   ========================================================================== */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.modal-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-2xl); /* 28px modern dialog */
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    animation: modalPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
}

@keyframes modalPopIn {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==========================================================================
   18. SCROLLBAR & ACCESSIBILITY
   ========================================================================== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: var(--radius-full);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .btn-record.recording {
        animation: none;
        box-shadow: 0 0 0 4px #DC2626;
    }

    .waveform-container.active .waveform-bar,
    .btn-record.recording .waveform-bar {
        animation: none;
        height: 16px;
    }
}


/* ==========================================================================
   SVG ICON UTILITIES (Lucide Style Sizing & Alignment)
   ========================================================================== */
.svg-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}
.w-3 { width: 12px; }
.h-3 { height: 12px; }
.w-3\.5 { width: 14px; }
.h-3\.5 { height: 14px; }
.w-4 { width: 16px; }
.h-4 { height: 16px; }
.w-5 { width: 20px; }
.h-5 { height: 20px; }
.w-6 { width: 24px; }
.h-6 { height: 24px; }
.w-7 { width: 28px; }
.h-7 { height: 28px; }
.w-8 { width: 32px; }
.h-8 { height: 32px; }
.w-10 { width: 40px; }
.h-10 { height: 40px; }
.text-amber-500 { color: #F59E0B; }

/* ==========================================================================
   19. SPEAKKHMER V2 UI REVAMP (TRAVGO INSPIRATION)
   ========================================================================== */

/* --- 19.1 Header & User Identity --- */
.app-header.glass-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    height: 64px;
    background: var(--color-surface-trans);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

@media (hover: hover) and (pointer: fine) {
    .menu-btn:hover {
        background: var(--color-surface);
        border-color: var(--color-primary);
    }
}

.menu-btn-bar {
    width: 18px;
    height: 2px;
    background-color: var(--color-text);
    border-radius: 9999px;
    transition: all 0.25s ease;
}

.country-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    overflow: hidden;
    padding: 0 4px;
}

.greeting-text {
    font-size: 14px;
    font-weight: 800;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.level-subtext {
    font-size: 10px;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: visible;
    flex-shrink: 0;
    cursor: pointer;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: block;
    background: #FEF9C3; /* Travgo Soft Yellow */
}

body.dark-mode .avatar-img {
    border-color: #334155;
    background: #422006;
}

.avatar-status-dot {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #FFFFFF;
    z-index: 2;
}

body.dark-mode .avatar-status-dot {
    border-color: #1E293B;
}

.avatar-status-dot.online {
    background-color: #00C566; /* Travgo Emerald Green */
}

/* --- 19.2 Slide-Out Navigation Drawer --- */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: max(0px, calc(50% - 206px));
    width: min(100vw, 412px);
    height: 100vh;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.app-drawer {
    position: fixed;
    top: 0;
    left: max(0px, calc(50% - 206px));
    width: min(320px, calc(412px * 0.82));
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: var(--color-surface);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.34s cubic-bezier(0.32, 1, 0.23, 1), visibility 0.34s;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
}

.app-drawer.active {
    transform: translateX(0);
    visibility: visible;
}

.drawer-header {
    padding: 24px 20px 20px 20px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.drawer-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.drawer-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #FFFFFF;
    background: #FEF9C3; /* Travgo Soft Yellow */
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

body.dark-mode .drawer-avatar {
    border-color: #334155;
    background: #422006;
}

.drawer-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.3px;
}

.drawer-location {
    font-size: 12px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    font-weight: 500;
}

.btn-edit-profile {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .btn-edit-profile:hover {
        border-color: var(--color-primary);
        color: var(--color-primary);
        background: var(--color-primary-50);
    }
}

.drawer-email {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 2px;
}

.drawer-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--color-primary-50);
    color: var(--color-primary);
    margin-top: 4px;
}

.drawer-menu {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.drawer-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--color-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
}

.drawer-menu-item.active {
    background: var(--color-bg);
    color: var(--color-primary);
}

@media (hover: hover) and (pointer: fine) {
    .drawer-menu-item:hover {
        background: var(--color-bg);
        color: var(--color-primary);
    }
}

.drawer-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--color-bg);
}

/* iOS / Travgo Style Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    display: inline-block;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #CBD5E1;
    border-radius: 9999px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* --- 19.3 Floating Dynamic Island Dock (4 Tabs) --- */
.floating-island-nav {
    position: fixed;
    bottom: calc(14px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 400px;
    height: 64px;
    background: var(--color-surface-trans);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 32px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-floating);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px;
    z-index: 900;
}

.floating-island-nav .nav-item {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--color-text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: color 0.25s ease;
}

.floating-island-nav .nav-item.active {
    color: var(--color-primary);
}

.floating-island-nav .nav-label {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.nav-active-pill {
    position: absolute;
    top: 6px;
    left: 6px;
    height: 52px;
    width: calc((100% - 12px) / 5);
    background: var(--color-primary-50);
    border-radius: 26px;
    z-index: 1;
    pointer-events: none;
    transition: transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- 19.4 Squircle Module Cards with Thumbnail Slot --- */
.module-card {
    border-radius: 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    padding: 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .module-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-card-hover);
        border-color: var(--color-primary-light);
    }
}

.module-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}



/* --- 19.5 Practice Card Conversation Sheet --- */
.btn-conversation-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

@media (hover: hover) and (pointer: fine) {
    .btn-conversation-toggle:hover {
        background: var(--color-primary-50);
    }
}

.conversation-box {
    margin-top: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    text-align: left;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.25s ease;
}

.conv-khmer {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}

.conv-phonetic {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary);
}

.conv-en {
    font-size: 12px;
    color: var(--color-text-secondary);
}

/* --- 19.6 Circular SVG Score Ring --- */
.score-dial-wrap {
    position: relative;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.score-dial-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-dial-bg {
    fill: none;
    stroke: var(--color-border);
    stroke-width: 4;
}

.score-dial-fill {
    fill: none;
    stroke: #00C566;
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.score-dial-text {
    position: absolute;
    font-size: 13px;
    font-weight: 800;
    color: var(--color-text);
}

/* --- 19.6 Word Attempt History & Improvement Progression Strip --- */
.word-history-strip {
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-sizing: border-box;
}

.word-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-size: 11px;
    font-weight: 700;
}

.history-label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-secondary);
}

.history-attempts-pill {
    background: rgba(99, 102, 241, 0.1);
    color: var(--color-primary);
    padding: 1px 7px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 800;
}

.history-improvement-tag {
    background: #ECFDF5;
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    animation: pulseBadge 1.5s infinite;
}

@keyframes pulseBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.history-pills-row {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.history-pills-row::-webkit-scrollbar {
    display: none;
}

.history-pill {
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
    transition: transform 0.2s ease;
}

.history-pill.pass {
    background: #ECFDF5;
    color: #059669;
    border-color: #A7F3D0;
}

.history-pill.retry {
    background: #FEF2F2;
    color: #DC2626;
    border-color: #FECACA;
}

.history-pill.best {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    color: #4F46E5;
    border-color: #C7D2FE;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15);
}

.history-arrow {
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 700;
}

.history-empty-text {
    font-size: 11px;
    color: var(--color-text-muted);
    font-style: italic;
    font-weight: 500;
}

/* Module Card Score Badge */
.module-score-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 800;
}

body.dark-mode .module-score-pill {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
    border-color: rgba(52, 211, 153, 0.4);
}

.attempt-history-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .attempt-history-card:hover {
        border-color: var(--color-primary);
    }
}



/* ==========================================================================
   TRAVGO-INSPIRED SETTINGS & 3D AVATAR SELECTION SYSTEM
   ========================================================================== */
.settings-group-header {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-muted);
    margin: 16px 0 8px 4px;
}

body.dark-mode .settings-group-header {
    color: #94A3B8;
}

.avatar-selection-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 2px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.avatar-selection-grid::-webkit-scrollbar {
    display: none;
}

.avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 4px;
    border-radius: var(--radius-lg);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
}

.avatar-option:active {
    transform: scale(0.92);
}

.avatar-option-img-wrap {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    padding: 2px;
    border: 2px solid transparent;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-option-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
    object-fit: cover;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.avatar-option.selected .avatar-option-img-wrap {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25), 0 4px 12px rgba(79, 70, 229, 0.3);
    transform: scale(1.06);
}

.avatar-check-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4F46E5;
    border: 2px solid #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.avatar-option.selected .avatar-check-badge {
    transform: scale(1);
}

.avatar-option-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
}

.avatar-option.selected .avatar-option-label {
    color: var(--color-primary);
    font-weight: 800;
}

body.dark-mode .avatar-option.selected .avatar-option-img-wrap {
    border-color: #818CF8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.35), 0 4px 12px rgba(99, 102, 241, 0.4);
}

body.dark-mode .avatar-check-badge {
    background: #818CF8;
    border-color: #1E293B;
}

body.dark-mode .avatar-option.selected .avatar-option-label {
    color: #818CF8;
}

#card-avatar-picker {
    transition: all 0.3s ease;
}

#card-avatar-picker.collapsed {
    display: none;
}

/* ==========================================================================
   20. WORD PUZZLE GAME & HERO BANNER (Samsung Galaxy S26 Ultra Optimized)
   ========================================================================== */

/* --- 20.1 Hub Word Puzzle Challenge Hero Banner --- */
.puzzle-banner-card {
    position: relative;
    overflow: hidden;
    margin: 14px 0 20px 0;
    border-radius: 24px;
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 45%, #4F46E5 100%);
    color: #FFFFFF;
    padding: 20px;
    box-shadow: 0 14px 34px -8px rgba(49, 46, 129, 0.45);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.puzzle-banner-card:active {
    transform: scale(0.99);
}

.puzzle-banner-glow {
    position: absolute;
    top: -40px;
    right: -40px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.35) 0%, rgba(99, 102, 241, 0) 70%);
    pointer-events: none;
}

.puzzle-banner-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.puzzle-banner-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(8px);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #FCD34D;
    border: 1px solid rgba(252, 211, 77, 0.3);
}

.puzzle-banner-tiles-preview {
    display: inline-flex;
    gap: 4px;
}

.puzzle-banner-tile-chip {
    padding: 2px 7px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    font-family: var(--font-khmer);
    font-size: 13px;
    font-weight: 700;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.puzzle-banner-title {
    font-size: 18.5px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.3px;
    margin: 0;
}

.puzzle-banner-subtitle {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.85);
    margin: 4px 0 0 0;
    line-height: 1.4;
}

.puzzle-banner-features {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.8);
}

.puzzle-banner-feature-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.puzzle-banner-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    border-radius: 14px;
    background: #F59E0B;
    color: #0F172A;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-banner-cta:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
        color: #0F172A;
    }
}

.puzzle-banner-cta:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
    color: #0F172A;
}

/* --- 20.2 Word Puzzle Screen Container & Navigation Header --- */
.puzzle-screen-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

.puzzle-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--color-surface-trans);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--color-border);
}

.puzzle-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.puzzle-btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.2s;
}

.puzzle-btn-back:active {
    background: var(--color-border);
}

.puzzle-header-title-wrap {
    text-align: center;
    flex: 1;
    padding: 0 8px;
}

.puzzle-header-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text);
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.puzzle-header-subtitle {
    font-family: var(--font-khmer);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 1px;
}

.puzzle-header-stats {
    display: flex;
    align-items: center;
    gap: 6px;
}

.puzzle-streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 9px;
    border-radius: 9999px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #D97706;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.puzzle-streak-badge.pulse {
    transform: scale(1.15);
    background: rgba(245, 158, 11, 0.25);
}

.puzzle-xp-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 9px;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

/* --- 20.3 Category Filter Bar (Horizontal Smooth Carousel) --- */
.puzzle-category-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.puzzle-category-bar::-webkit-scrollbar {
    display: none;
}

.puzzle-category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-category-chip:hover {
        border-color: var(--color-primary-light);
        color: var(--color-primary);
    }
}

.puzzle-category-chip.active {
    background: var(--color-primary);
    color: #FFFFFF;
    border-color: var(--color-primary);
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.35);
}

/* --- 20.4 Large Realistic Hero Picture Card --- */
.puzzle-hero-card {
    position: relative;
    width: calc(100% - 32px);
    max-width: 340px;
    height: 180px;
    margin: 12px auto 8px auto;
    border-radius: 22px;
    background: #FFFFFF;
    border: 1.5px solid var(--color-border);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.puzzle-hero-card:active {
    transform: scale(0.985);
}

body.dark-mode .puzzle-hero-card {
    background: #1E293B;
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.45);
}

.puzzle-hero-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 14px;
    display: block;
    transition: transform 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-hero-card:hover .puzzle-hero-img {
        transform: scale(1.03);
    }
}

.puzzle-zoom-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: background 0.2s;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-zoom-badge:hover {
        background: rgba(15, 23, 42, 0.85);
    }
}

.puzzle-cat-indicator-wrap {
    position: absolute;
    bottom: 10px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
}

/* --- 20.5 English Meaning & Phonetic Hints --- */
.puzzle-meta-wrap {
    text-align: center;
    margin: 4px 16px 6px 16px;
}

.puzzle-meaning-text {
    font-size: 19px;
    font-weight: 800;
    color: var(--color-text);
    margin: 0;
    letter-spacing: -0.3px;
}

.puzzle-phonetic-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
}

.puzzle-phonetic-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13.5px;
    font-family: monospace;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-50);
    padding: 2px 10px;
    border-radius: 8px;
    border: 1px solid var(--color-primary-100);
}

.puzzle-phonetic-badge.blurred {
    filter: blur(4px);
    user-select: none;
    cursor: pointer;
    transition: filter 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-phonetic-badge.blurred:hover {
        filter: blur(2px);
    }
}

.puzzle-btn-phonetic-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-secondary);
    cursor: pointer;
}

/* --- 20.6 Native Khmer Audio Pronunciation Bar --- */
.puzzle-audio-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 6px 16px 10px 16px;
}

.puzzle-audio-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 16px;
    border-radius: 9999px;
    background: var(--color-primary);
    color: #FFFFFF;
    font-size: 13.5px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-audio-btn:hover {
        background: var(--color-primary-dark);
    }
}

.puzzle-audio-btn:active {
    transform: scale(0.97);
}

.puzzle-audio-btn.playing {
    background: #4338CA;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.35);
    animation: puzzle-audio-pulse 1.4s infinite;
}

.puzzle-voice-btn,
.puzzle-speed-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 38px;
    padding: 0 12px;
    border-radius: 9999px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.puzzle-voice-btn:active,
.puzzle-speed-btn:active {
    background: var(--color-bg);
    transform: scale(0.96);
}

/* --- 20.7 Target Word Puzzle Slot Area --- */
.puzzle-slots-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 16px 14px 16px;
    min-height: 60px;
}

.puzzle-slot {
    min-width: 52px;
    height: 56px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-khmer);
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0 8px;
}

.puzzle-slot.empty {
    border: 2px dashed #94A3B8;
    background: rgba(241, 245, 249, 0.6);
    color: #94A3B8;
}

body.dark-mode .puzzle-slot.empty {
    border-color: #475569;
    background: rgba(30, 41, 59, 0.6);
    color: #64748B;
}

.puzzle-slot.empty::before {
    content: "•";
    font-size: 18px;
    opacity: 0.5;
}

.puzzle-slot.filled {
    border: 2.5px solid #10B981;
    background: #ECFDF5;
    color: #065F46;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.18);
    transform: translateY(-2px);
}

body.dark-mode .puzzle-slot.filled {
    border-color: #10B981;
    background: rgba(16, 185, 129, 0.2);
    color: #A7F3D0;
}

.puzzle-slot.correct {
    border-color: #059669;
    background: #D1FAE5;
    box-shadow: 0 0 22px rgba(16, 185, 129, 0.6);
    animation: puzzle-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .puzzle-slot.correct {
    background: rgba(16, 185, 129, 0.35);
    border-color: #34D399;
    color: #FFFFFF;
}

.puzzle-slot.shake {
    animation: puzzle-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    border-color: #EF4444;
    background: #FEF2F2;
    color: #991B1B;
}

body.dark-mode .puzzle-slot.shake {
    background: rgba(239, 68, 68, 0.2);
    color: #FCA5A5;
}

/* --- 20.8 Scrambled Syllable Tile Tray --- */
.puzzle-tray-card {
    margin: 0 16px 12px 16px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: 20px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.puzzle-tray-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-align: center;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.puzzle-tiles-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    min-height: 54px;
}

.puzzle-tile {
    min-width: 50px;
    min-height: 50px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1.5px solid #CBD5E1;
    border-bottom: 3.5px solid #94A3B8;
    color: #0F172A;
    font-family: var(--font-khmer);
    font-size: 23px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body.dark-mode .puzzle-tile {
    background: #334155;
    border-color: #475569;
    border-bottom-color: #1E293B;
    color: #F8FAFC;
}

@media (hover: hover) and (pointer: fine) {
    .puzzle-tile:hover {
        border-color: var(--color-primary-light);
        color: var(--color-primary);
    }
}

.puzzle-tile:active {
    transform: scale(0.93) translateY(1px);
    border-bottom-width: 1.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.puzzle-tile.placed {
    opacity: 0.28;
    pointer-events: none;
    transform: scale(0.92);
    border-bottom-width: 1.5px;
    border-color: #E2E8F0;
    background: #F1F5F9;
    color: #94A3B8;
    box-shadow: none;
}

body.dark-mode .puzzle-tile.placed {
    background: #1E293B;
    border-color: #334155;
    color: #64748B;
}

/* --- 20.9 Action Controls Bar --- */
.puzzle-controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 16px 16px 16px;
}

.btn-puzzle-control {
    flex: 1;
    height: 44px;
    border-radius: 14px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--color-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-tap-highlight-color: transparent;
}

.btn-puzzle-control:active {
    transform: scale(0.97);
    background: var(--color-bg);
}

.btn-puzzle-hint {
    color: #D97706;
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.btn-puzzle-reset {
    color: #64748B;
}

.btn-puzzle-skip {
    color: var(--color-primary);
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
}

/* --- 20.10 Celebration & Toast Feedback --- */
.puzzle-floating-xp {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    font-weight: 900;
    color: #10B981;
    pointer-events: none;
    animation: puzzle-float-xp 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    text-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    z-index: 100;
}

.puzzle-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    color: #FFFFFF;
    padding: 10px 18px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 999;
    white-space: nowrap;
}

.puzzle-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- 20.11 Modals (Celebration & Image Zoom) --- */
.puzzle-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.puzzle-modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.puzzle-modal-card {
    width: 100%;
    max-width: 360px;
    background: var(--color-surface);
    border-radius: 28px;
    border: 1.5px solid var(--color-border);
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.puzzle-modal-backdrop.active .puzzle-modal-card {
    transform: scale(1);
}

.puzzle-modal-trophy {
    width: 72px;
    height: 72px;
    margin: 0 auto 12px auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #FDE68A 0%, #F59E0B 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 10px 20px rgba(245, 158, 11, 0.35);
}

.puzzle-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.puzzle-stat-box {
    padding: 10px;
    border-radius: 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
}

.puzzle-stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
}

.puzzle-stat-label {
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-top: 2px;
}

/* Image Zoom Full Screen Modal */
.puzzle-zoom-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.puzzle-zoom-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.puzzle-zoom-card {
    width: 100%;
    max-width: 340px;
    background: #FFFFFF;
    border-radius: 24px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

body.dark-mode .puzzle-zoom-card {
    background: #1E293B;
}

.puzzle-zoom-img {
    width: 100%;
    height: 240px;
    object-fit: contain;
}

.puzzle-zoom-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    border: none;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --- 20.12 Keyframe Animations --- */
@keyframes puzzle-shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
    40%, 60% { transform: translate3d(5px, 0, 0); }
}

@keyframes puzzle-pop {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes puzzle-float-xp {
    0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
    30% { opacity: 1; transform: translate(-50%, -20px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

@keyframes puzzle-audio-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}


/* ==========================================================================
   21. Offline Audio Pack & APK Pre-Cache Styles
   ========================================================================== */
.btn-precache-audio {
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--color-primary, #4F46E5) 0%, #4338CA 100%);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md, 12px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .btn-precache-audio:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
    }
}

.btn-precache-audio:active {
    transform: translateY(0);
}

.btn-precache-audio:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.audio-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.audio-progress-wrap.hidden {
    display: none !important;
}

.audio-progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #E2E8F0;
    border-radius: 999px;
    overflow: hidden;
}

.dark .audio-progress-bar-bg {
    background: #334155;
}

.audio-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary, #4F46E5) 0%, #10B981 100%);
    border-radius: 999px;
    transition: width 0.15s ease-out;
}

.audio-progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary, #64748B);
    text-align: center;
}


/* ==========================================================================
   GAMES HUB TAB & QUICK-PLAY LAUNCHERS (Samsung Galaxy S26 Ultra 412x915)
   ========================================================================== */

.games-hero-card {
    position: relative;
    border-radius: var(--radius-2xl, 24px);
    background: linear-gradient(145deg, #FFFFFF 0%, #F8FAFC 100%);
    border: 1.5px solid rgba(99, 102, 241, 0.25);
    box-shadow: 0 12px 32px -8px rgba(79, 70, 229, 0.16), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode .games-hero-card {
    background: linear-gradient(145deg, #1E293B 0%, #0F172A 100%);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.45);
}

.games-hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
    pointer-events: none;
    border-radius: 50%;
}

.games-hero-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.games-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 9999px;
    line-height: 1;
}

.games-badge.challenge-badge {
    background: #EEF2FF;
    color: var(--color-primary, #4F46E5);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.games-badge.streak-badge {
    background: #FFFBEB;
    color: #B45309;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.games-badge.xp-badge {
    background: #F5F3FF;
    color: #6D28D9;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

body.dark-mode .games-badge.challenge-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #A5B4FC;
}

body.dark-mode .games-badge.streak-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #FCD34D;
}

body.dark-mode .games-badge.xp-badge {
    background: rgba(139, 92, 246, 0.2);
    color: #DDD6FE;
}

.games-hero-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--color-text, #0F172A);
    margin: 0;
    letter-spacing: -0.3px;
    line-height: 1.25;
}

.games-hero-desc {
    font-size: 13px;
    color: var(--color-text-secondary, #64748B);
    line-height: 1.45;
    margin: 4px 0 0 0;
}

.games-hero-btn {
    width: 100%;
    min-height: 48px;
    border-radius: var(--radius-xl, 16px);
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 6px 20px -2px rgba(79, 70, 229, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.games-hero-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px -2px rgba(79, 70, 229, 0.3);
}

/* Quick-Play Category Launchers Grid */
.quick-play-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

.quick-play-card {
    min-height: 76px;
    border-radius: var(--radius-2xl, 20px);
    background: var(--color-surface, #FFFFFF);
    border: 1px solid var(--color-border, #E2E8F0);
    box-shadow: 0 2px 8px -1px rgba(15, 23, 42, 0.05);
    padding: 12px 14px;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease, border-color 0.18s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body.dark-mode .quick-play-card {
    background: #1E293B;
    border-color: #334155;
    box-shadow: 0 2px 8px -1px rgba(0, 0, 0, 0.25);
}

.quick-play-card:active {
    transform: scale(0.97);
    border-color: var(--color-primary, #4F46E5);
}

.quick-play-card-full {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06) 0%, rgba(139, 92, 246, 0.06) 100%);
    border-color: rgba(99, 102, 241, 0.22);
}

body.dark-mode .quick-play-card-full {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, rgba(139, 92, 246, 0.15) 100%);
    border-color: rgba(99, 102, 241, 0.35);
}

.quick-play-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.quick-play-icon-badge {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.quick-play-card:active .quick-play-icon-badge {
    transform: scale(1.1);
}

.quick-play-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.quick-play-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--color-text, #0F172A);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.quick-play-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary, #64748B);
    margin-top: 1px;
}

.quick-play-arrow {
    color: var(--color-text-muted, #94A3B8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
}

.quick-play-card:active .quick-play-arrow {
    transform: translateX(2px);
    color: var(--color-primary, #4F46E5);
}

/* Games Achievement Stats Grid */
.games-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.game-stat-item {
    background: #F8FAFC;
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-lg, 16px);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark-mode .game-stat-item {
    background: #0F172A;
    border-color: #334155;
}

.game-stat-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.game-stat-data {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.game-stat-val {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-text, #0F172A);
    line-height: 1.2;
}

.game-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary, #64748B);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   26. MOBILE AUTHENTICATION & LOGIN/REGISTER (Samsung Galaxy S26 Ultra)
   ========================================================================== */
.auth-page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 18px 40px 18px;
    max-width: 412px;
    margin: 0 auto;
}

.auth-hero-wrap {
    text-align: center;
    margin-bottom: 22px;
}

.auth-logo-badge {
    width: 76px;
    height: 76px;
    margin: 0 auto 14px auto;
    border-radius: var(--radius-2xl, 22px);
    background: linear-gradient(135deg, #4F46E5 0%, #3730A3 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 32px -8px rgba(79, 70, 229, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.auth-logo-badge img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.auth-brand-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--color-text, #0F172A);
    margin: 0 0 2px 0;
    letter-spacing: -0.6px;
}

.auth-brand-khmer {
    font-family: var(--font-khmer);
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary, #4F46E5);
    margin: 0 0 4px 0;
}

.auth-brand-desc {
    font-size: 13px;
    color: var(--color-text-secondary, #64748B);
    max-width: 290px;
    margin: 0 auto;
    line-height: 1.4;
}

.auth-card {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-2xl, 22px);
    padding: 22px 18px;
    box-shadow: 0 16px 40px -12px rgba(15, 23, 42, 0.12);
}

.auth-tabs {
    display: flex;
    background: #F1F5F9;
    border-radius: var(--radius-xl, 16px);
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
}

.auth-tab-btn {
    flex: 1;
    height: 42px;
    border-radius: var(--radius-lg, 12px);
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-secondary, #64748B);
    border: none;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auth-tab-btn.active {
    background: #FFFFFF;
    color: var(--color-primary, #4F46E5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.auth-tab-btn:active {
    transform: scale(0.96);
}

.auth-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
    width: 100%;
}

.auth-input-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text, #0F172A);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auth-input-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: #94A3B8;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-input-field {
    width: 100%;
    min-height: 50px;
    padding: 0 44px 0 44px;
    border: 1.5px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-lg, 12px);
    font-size: 15px;
    font-family: var(--font-latin);
    background-color: #F8FAFC;
    color: var(--color-text, #0F172A);
    outline: none;
    touch-action: manipulation;
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-input-field:focus {
    background-color: #FFFFFF;
    border-color: var(--color-primary, #4F46E5);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.auth-toggle-btn {
    position: absolute;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
}

.auth-toggle-btn:active {
    transform: scale(0.92);
    color: var(--color-primary, #4F46E5);
}

/* Demo Role Pills */
.demo-accounts-bar {
    background: #F8FAFC;
    border: 1px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-lg, 12px);
    padding: 10px 12px;
    margin-bottom: 18px;
}

.demo-bar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary, #64748B);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.demo-chips-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.demo-role-btn {
    min-height: 44px;
    background: #FFFFFF;
    border: 1.5px solid var(--color-border, #E2E8F0);
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.demo-role-btn:active {
    transform: scale(0.96);
    border-color: var(--color-primary, #4F46E5);
    background: #EEF2FF;
}

.demo-role-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.demo-role-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.demo-role-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text, #0F172A);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.demo-role-cred {
    font-size: 10px;
    color: var(--color-text-muted, #94A3B8);
}

/* Voice Picker */
.voice-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.voice-option-tile {
    border: 1.5px solid var(--color-border, #E2E8F0);
    border-radius: var(--radius-md, 10px);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: #F8FAFC;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.voice-option-tile:active {
    transform: scale(0.97);
}

.voice-option-tile.selected {
    border-color: var(--color-primary, #4F46E5);
    background: #EEF2FF;
}

.voice-tile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.voice-tile-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text, #0F172A);
}

.voice-tile-desc {
    font-size: 11px;
    color: var(--color-text-secondary, #64748B);
}

/* Avatar Character Picker */
.avatar-picker-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 2px;
}

.avatar-option-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    padding: 2px;
    background: #F1F5F9;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-option-btn:active {
    transform: scale(0.92);
}

.avatar-option-btn.selected {
    border-color: var(--color-primary, #4F46E5);
    background: #EEF2FF;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.avatar-option-btn img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

/* Active User Session Notice */
.auth-active-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #EEF2FF;
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: var(--radius-lg, 12px);
    margin-bottom: 18px;
}
