@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700;800&family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=Outfit:wght@700;800&display=swap&subset=vietnamese');

:root {
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
    --glass-blur: blur(16px);
    --surface-raised: #ffffff;
    --surface-muted: #f1f5f9;
    --text-on-accent: #ffffff;
    --control-bg: #ffffff;
    --control-text: #1e293b;
    --control-placeholder: #475569;
    --control-border: #94a3b8;
    --success-bg: #ecfdf5;
    --success-text: #166534;
    --success-border: #22c55e;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #ef4444;
    --warning-bg: #fffbeb;
    --warning-text: #92400e;
    --warning-border: #f59e0b;
    --info-bg: #eff6ff;
    --info-text: #1e40af;
    --info-border: #3b82f6;
}

/* THEME LAB (Dựa trên ảnh tham khảo) */
body.theme-lab {
    --bg-color: #fdf4f4; /* Light pink background */
    --surface: rgba(255, 255, 255, 0.45); /* More transparent for stronger glass effect */
    --text-main: #333333;
    --text-muted: #777777;
    --primary: #b91c1c; /* Dark red */
    --primary-light: #fef2f2;
    --accent: #991b1b;
    --border: #fca5a5; /* Light red border */
    --border-hover: var(--primary);
    --shadow-lg: 0 10px 25px rgba(185, 28, 28, 0.05);
    --card-shadow: 0 2px 10px rgba(0,0,0,0.03);
    --btn-bg: #ffffff;
}

/* Các theme cũ giữ nguyên để dùng chung form làm bài */
body.theme-cyber { --bg-color: #0a0f1c; --surface: rgba(15, 23, 42, 0.6); --text-main: #f8fafc; --text-muted: #94a3b8; --primary: #8b5cf6; --primary-light: rgba(139, 92, 246, 0.15); --border: rgba(255, 255, 255, 0.1); --border-hover: var(--primary); --card-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05); --btn-bg: #1e293b; }
body.theme-neumorphic { --bg-color: #e0e5ec; --surface: #e0e5ec; --text-main: #2d3748; --text-muted: #718096; --primary: #10b981; --primary-light: #d1fae5; --border: rgba(16, 185, 129, 0.35); --border-hover: var(--primary); --card-shadow: 9px 9px 16px rgb(163,177,198,0.6), -9px -9px 16px rgba(255,255,255, 0.5); --btn-bg: #e0e5ec; }
body.theme-mesh { --bg-color: #f3f4f6; --surface: rgba(255, 255, 255, 0.7); --text-main: #111827; --text-muted: #6b7280; --primary: #4f46e5; --primary-light: #e0e7ff; --border: rgba(79, 70, 229, 0.3); --border-hover: var(--primary); --card-shadow: 0 20px 40px -10px rgba(79, 70, 229, 0.15); --btn-bg: white; }
body.theme-crimson { --bg-color: #f8fafc; --surface: rgba(255, 255, 255, 0.85); --text-main: #0f172a; --text-muted: #64748b; --primary: #e11d48; --primary-light: #fff1f2; --accent: #111827; --border: rgba(226, 232, 240, 0.8); --border-hover: var(--primary); --card-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05); --btn-bg: white; }
body.theme-crimson::before { content: ''; position: absolute; top: -10%; left: -10%; width: 50%; height: 50%; background: radial-gradient(circle, rgba(225,29,72,0.06) 0%, transparent 70%); z-index: -1; pointer-events: none; }
body.theme-crimson::after { content: ''; position: absolute; bottom: -20%; right: -10%; width: 60%; height: 60%; background: radial-gradient(circle, rgba(17,24,39,0.05) 0%, transparent 70%); z-index: -1; pointer-events: none; }

/* ── CSS Cascade Layers: base < utilities ──
   Wrap global resets vào @layer base để Tailwind @layer utilities
   có thể override khi cần (vd: px-5, py-2, rounded-full).
   
   Tất cả legacy CSS còn lại (bento-card, btn-primary...) vẫn UNLAYERED
   → vẫn có priority CAO NHẤT, không bị ảnh hưởng.
   
   Xem VTCG_2.0_ARCHITECTURE_RULES.md §4.4 để hiểu chi tiết. */
/* Anti-FOUC: Block ALL transitions during initial page load to prevent dark/light flash */
html.no-transitions,
html.no-transitions *,
html.no-transitions *::before,
html.no-transitions *::after {
    transition: none !important;
}

@layer base {
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { font-family: 'Be Vietnam Pro', sans-serif; background-color: var(--bg-color); color: var(--text-main); min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; overflow-y: auto; position: relative; transition: background-color 0.5s ease; }
    h1, h2, h3, .question-number, .timer, .palette-header { font-family: 'Lexend', sans-serif; }
}

/* ═══ ColorHub — Theme Customization Panel ═══ */
.colorhub-wrap {
    position: fixed; bottom: 2rem; left: 2rem;
    z-index: 1000;
}

/* Trigger Button */
.colorhub-trigger {
    width: 40px; height: 40px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2), inset 0 0 12px rgba(255,255,255,0.15);
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), box-shadow 0.25s;
    outline: none; position: relative;
}
.colorhub-trigger:hover { transform: scale(1.12); box-shadow: 0 6px 25px rgba(0,0,0,0.3), inset 0 0 14px rgba(255,255,255,0.2); }
.colorhub-trigger.open { transform: scale(1.08) rotate(30deg); }

/* Panel */
.colorhub-panel {
    position: absolute; bottom: calc(100% + 12px); left: 0;
    min-width: 280px; max-width: 320px;
    background: var(--surface, rgba(255,255,255,0.45));
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border, rgba(255,255,255,0.2));
    border-radius: 18px;
    padding: 1rem;
    box-shadow: 0 20px 60px -15px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.05);
    animation: colorhub-slide-up 0.3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes colorhub-slide-up {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dark mode panel override */
html.dark-mode .colorhub-panel,
body.dark-mode .colorhub-panel {
    background: rgba(20, 20, 28, 0.88);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 20px 60px -10px rgba(0,0,0,0.6);
}

/* Header */
.colorhub-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.85rem; padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
}
.colorhub-title {
    font-size: 0.82rem; font-weight: 700; color: var(--text-main);
    display: flex; align-items: center; gap: 6px;
    font-family: 'Lexend', sans-serif;
}
.colorhub-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.colorhub-close:hover { background: var(--primary-light, rgba(0,0,0,0.06)); color: var(--text-main); }

/* Section / Label */
.colorhub-section { margin-bottom: 0.75rem; }
.colorhub-label {
    font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    display: flex; align-items: center; gap: 5px;
    margin-bottom: 0.5rem;
}

/* Preset Grid */
.colorhub-presets {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.colorhub-dot {
    width: 32px; height: 32px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35);
    cursor: pointer; position: relative;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.65rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15), inset 0 1px 4px rgba(255,255,255,0.15);
    transition: transform 0.2s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s;
    outline: none;
}
.colorhub-dot:hover { transform: scale(1.15); box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.colorhub-dot.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px var(--primary, #b91c1c), 0 4px 14px rgba(0,0,0,0.25);
    transform: scale(1.08);
}
.colorhub-dot-label {
    position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%);
    font-size: 0.65rem; pointer-events: none; line-height: 1;
    opacity: 0; transition: opacity 0.15s;
}
.colorhub-dot:hover .colorhub-dot-label { opacity: 1; }

/* Custom dot */
.colorhub-dot-custom {
    background: conic-gradient(from 0deg, #f87171, #fbbf24, #34d399, #60a5fa, #a78bfa, #f472b6, #f87171);
    font-size: 0.75rem;
}

/* Color Picker */
.colorhub-picker-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 0.5rem 0; margin-bottom: 0.5rem;
}
.colorhub-picker {
    width: 40px; height: 32px; border: none; padding: 0;
    background: none; cursor: pointer; border-radius: 6px;
}
.colorhub-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.colorhub-picker::-webkit-color-swatch { border-radius: 4px; border: 1px solid rgba(0,0,0,0.15); }
.colorhub-picker-hex {
    font-family: 'Lexend', monospace; font-size: 0.8rem;
    color: var(--text-muted); font-weight: 600;
}

/* Toggle Row */
.colorhub-toggle-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.5rem;
}
.colorhub-toggle-row .colorhub-label { margin-bottom: 0; }

/* Switch */
.colorhub-switch {
    width: 38px; height: 22px; border-radius: 50px;
    background: rgba(120,120,130,0.25); border: none;
    cursor: pointer; position: relative; padding: 0;
    transition: background 0.25s;
}
.colorhub-switch.on { background: var(--primary, #b91c1c); }
.colorhub-switch-thumb {
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; display: flex; align-items: center; justify-content: center;
    color: #333; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
}
.colorhub-switch.on .colorhub-switch-thumb { transform: translateX(16px); }

/* Reset Button */
.colorhub-reset {
    width: 100%; padding: 0.45rem;
    background: none; border: 1px solid var(--border, rgba(0,0,0,0.1));
    border-radius: 10px; color: var(--text-muted);
    font-size: 0.75rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
}
.colorhub-reset:hover {
    background: var(--primary-light, rgba(0,0,0,0.04));
    color: var(--primary, #b91c1c);
    border-color: var(--primary, #b91c1c);
}

/* Hide bg-animated */
.bg-animated.bg-hidden { display: none !important; }

/* ═══ Legacy Theme Switcher (keep for backward compat) ═══ */
.theme-switcher { position: fixed; bottom: 2rem; left: 2rem; background: var(--surface); backdrop-filter: var(--glass-blur); padding: 0.75rem; border-radius: 50px; display: flex; gap: 0.75rem; box-shadow: var(--card-shadow); border: 1px solid var(--border); z-index: 1000; transition: opacity 0.3s ease, visibility 0.3s ease; }
body.hide-switcher .theme-switcher { opacity: 0; visibility: hidden; pointer-events: none; }


/* Dark Mode Theme Overrides - Standard High-Quality Charcoal/Dark Grey (Cốc Cốc style) */
html.dark-mode body,
body.dark-mode {
    --bg-color: #121214;
    --surface: rgba(30, 30, 35, 0.92);
    --surface-raised: #25252b;
    --surface-muted: #1a1a1f;
    --text-main: #f3f4f6;
    --text-muted: #b6bbc5;
    --text-on-accent: #ffffff;
    --border: rgba(255, 255, 255, 0.14);
    --btn-bg: #1e1e24;
    --control-bg: #22232a;
    --control-text: #f8fafc;
    --control-placeholder: #c3c8d1;
    --control-border: #5f6673;
    --success-bg: #102b20;
    --success-text: #86efac;
    --success-border: #4ade80;
    --error-bg: #351719;
    --error-text: #fca5a5;
    --error-border: #f87171;
    --warning-bg: #33250c;
    --warning-text: #fde68a;
    --warning-border: #fbbf24;
    --info-bg: #15243d;
    --info-text: #bfdbfe;
    --info-border: #60a5fa;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
/* Propagate dark-mode class from html to body for legacy selectors */
html.dark-mode body { background-color: var(--bg-color); color: var(--text-main); }

html.dark-mode body.theme-lab,
body.dark-mode.theme-lab {
    --bg-color: #320808;
    --surface: rgba(20, 20, 25, 0.75);
    --text-main: #f3f4f6;
    --text-muted: #fca5a5;
    --border: rgba(239, 68, 68, 0.25);
    --btn-bg: #4c1111;
    --primary: #ff4d4d;
    --primary-light: rgba(255, 77, 77, 0.15);
    --accent: #f87171;
}

html.dark-mode body.theme-mesh,
body.dark-mode.theme-mesh {
    --primary: #4f46e5;
    --primary-light: rgba(79, 70, 229, 0.15);
    --accent: #818cf8;
}

html.dark-mode body.theme-neumorphic,
body.dark-mode.theme-neumorphic {
    --bg-color: #18191c;
    --surface: #1e2024;
    --primary: #10b981;
    --primary-light: rgba(16, 185, 129, 0.15);
    --accent: #34d399;
    --border: rgba(16, 185, 129, 0.25);
    --card-shadow: 6px 6px 12px rgba(0, 0, 0, 0.6), -6px -6px 12px rgba(255, 255, 255, 0.02);
    --btn-bg: #1e2024;
}

html.dark-mode body.theme-cyber,
body.dark-mode.theme-cyber {
    --bg-color: #0c0d12;
    --surface: rgba(20, 21, 30, 0.8);
    --primary: #8b5cf6;
    --primary-light: rgba(139, 92, 246, 0.15);
    --accent: #a78bfa;
}

/* High specificity overrides to bypass page-level !important rules */
html.dark-mode body.theme-lab,
html.dark-mode body.theme-mesh,
html.dark-mode body.theme-neumorphic,
html.dark-mode body.theme-cyber,
html.dark-mode body.theme-crimson,
body.dark-mode.theme-lab,
body.dark-mode.theme-mesh,
body.dark-mode.theme-neumorphic,
body.dark-mode.theme-cyber,
body.dark-mode.theme-crimson {
    background-color: var(--bg-color) !important;
}

html.dark-mode body.theme-lab #loading-screen,
html.dark-mode body.theme-mesh #loading-screen,
html.dark-mode body.theme-neumorphic #loading-screen,
html.dark-mode body.theme-cyber #loading-screen,
html.dark-mode body.theme-crimson #loading-screen,
body.dark-mode.theme-lab #loading-screen,
body.dark-mode.theme-mesh #loading-screen,
body.dark-mode.theme-neumorphic #loading-screen,
body.dark-mode.theme-cyber #loading-screen,
body.dark-mode.theme-crimson #loading-screen {
    background-color: var(--bg-color) !important;
}

/* Views */
.view { display: none; flex: 1; height: 100%; width: 100%; flex-direction: column; }
.view.active { display: flex; }

/* Override for #study-view to allow full height expansion */
#study-view.view { height: auto; min-height: 100vh; }

/* ================== BENTO DASHBOARD VIEW ================== */
.bento-layout { background: transparent; color: var(--text-main); transition: background-color 0.5s ease; overflow-y: auto; position: relative; z-index: 10; display: flex; flex-direction: column; }

/* Override for #study-view bento-layout to prevent overflow scroll */
#study-view.bento-layout { overflow-y: visible; }

/* Top Nav */
.bento-nav { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 3rem; background: var(--surface); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--border); transition: background-color 0.5s ease; position: sticky; top: 0; z-index: 50; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 2.5rem; }
.bento-logo { font-size: 1.75rem; font-weight: 800; color: var(--primary); font-family: 'Be Vietnam Pro', sans-serif; letter-spacing: -0.5px; display: flex; align-items: center; }
.bento-logo .logo-image-desktop { display: none; height: 38px; width: auto; object-fit: contain; }
.bento-logo .logo-image-desktop-wrapper { display: none; align-items: center; gap: 0.75rem; }
.bento-logo .logo-text-mobile { display: inline; }
.bento-logo .logo-admin-badge { background: var(--primary); color: #ffffff; font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.5px; margin-left: 0.5rem; }

@media (min-width: 768px) {
    .bento-logo .logo-image-desktop { display: block; }
    .bento-logo .logo-image-desktop-wrapper { display: flex; }
    .bento-logo .logo-text-mobile { display: none; }
}
.nav-links { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; position: relative; }
.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    padding: 0.25rem 0;
    white-space: nowrap;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0); transform-origin: left; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}
.nav-links a:hover {
    color: var(--text-main);
}
.nav-links a:hover::after {
    transform: scaleX(1);
}
.nav-links a.active {
    color: var(--primary);
    font-weight: 700;
}
.nav-links a.active::after {
    transform: scaleX(1);
}
.nav-links a svg.nav-icon {
    stroke: var(--text-muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.3s ease;
}
.nav-links a:hover svg.nav-icon {
    stroke: var(--text-main);
    transform: scale(1.2) rotate(4deg);
}
.nav-links a.active svg.nav-icon {
    stroke: var(--primary);
    transform: scale(1.2);
}

.streak-badge { background: rgba(245, 158, 11, 0.1); color: #d97706; padding: 0.4rem 0.8rem; border-radius: 50px; font-weight: 700; font-size: 0.9rem; border: 1px solid rgba(245, 158, 11, 0.2); }
.bento-user { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; font-weight: 600; font-size: 0.95rem; color: var(--text-main); }
.bento-user .avatar { width: 36px; height: 36px; background: var(--primary-light); border: 1px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; }

/* Subheader */
.bento-subheader { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 0 0 0; max-width: 1280px; margin: 0 auto; width: 100%; }
.breadcrumb { font-size: 0.95rem; color: var(--text-muted); font-weight: 500; }
.breadcrumb span.active { color: var(--text-main); font-weight: 700; }
.btn-sm { padding: 0.6rem 1.5rem; font-size: 0.9rem; border-radius: 50px; }

/* Bento Content */
.bento-content { padding: 1rem 0; max-width: 1280px; margin: 0 auto; width: 100%; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bento-grid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: minmax(0, 26fr) minmax(0, 21fr) minmax(0, 22fr); gap: 1rem; min-height: 0; padding-bottom: 1rem; }

/* Bento Cards */
@keyframes bento-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.bento-card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 20px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s ease;
    border: 1px solid var(--border);
    overflow-y: auto;
    animation: bento-fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.bento-card:hover {
    transform: translateY(-5px) scale(1.01);
    border-color: var(--border-hover, var(--border));
    box-shadow: 0 15px 35px var(--primary-light), 0 0 0 1px var(--primary-light);
}
body.dark-mode .bento-card:hover {
    border-color: var(--border-hover, var(--border));
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-hover, var(--border));
}
.bento-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin-bottom: 1rem; }

/* Stagger card entry animation delays */
.bento-grid > :nth-child(1) { animation-delay: 0.05s; }
.bento-grid > :nth-child(2) { animation-delay: 0.1s; }
.bento-grid > :nth-child(3) { animation-delay: 0.15s; }
.bento-grid > :nth-child(4) { animation-delay: 0.2s; }
.bento-grid > :nth-child(5) { animation-delay: 0.25s; }
.bento-grid > :nth-child(6) { animation-delay: 0.3s; }
.bento-grid > :nth-child(7) { animation-delay: 0.35s; }
.bento-grid > :nth-child(8) { animation-delay: 0.4s; }

/* Specific Cards */
.bento-hero { grid-column: span 2; background: linear-gradient(135deg, var(--surface) 0%, var(--primary-light) 100%); justify-content: space-between; position: relative; overflow: hidden; }
.bento-hero::after { content: ''; position: absolute; right: -10%; top: -10%; width: 200px; height: 200px; background: radial-gradient(circle, var(--primary) 0%, transparent 70%); opacity: 0.1; border-radius: 50%; pointer-events: none; }
.hero-text h1 { font-size: 1.5rem; font-weight: 800; color: var(--text-main); margin-top: 0; margin-bottom: 0.25rem; line-height: 1.2; }
.hero-text p { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.35; max-width: 100%; }
.hero-stats { display: flex; gap: 1.5rem; margin-top: auto; padding-top: 0; flex-shrink: 0; }
.bento-countdown .text-lg { font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.25rem; }
.bento-countdown .text-sm { font-size: 0.85rem; color: var(--text-muted); }

.exp-container { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; margin-bottom: 0.5rem; flex: 0 1 auto !important; }
.stat-box { display: flex; flex-direction: column; gap: 0.2rem; }
.stat-num { font-size: 2rem; font-weight: 800; color: var(--primary); font-family: 'Lexend'; line-height: 1; }
.stat-lbl { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.bento-action { grid-column: span 1; background: var(--primary); color: white; cursor: default; justify-content: flex-start; align-items: flex-start; position: relative; overflow: hidden; }
.pulse-bg::before { content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent); transform: skewX(-20deg); animation: shine 3s infinite; pointer-events: none; }
@keyframes shine { 0% { left: -100%; } 20% { left: 200%; } 100% { left: 200%; } }

/* Schedule Card */
.schedule-card { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; position: relative; z-index: 1; }
.schedule-header { display: flex; align-items: center; gap: 0.4rem; font-weight: 800; font-size: 1rem; color: white; }
.schedule-days { display: flex; gap: 2px; }
.schedule-day-btn { flex: 1; padding: 0.25rem 0; border-radius: 6px; border: none; background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7); font-size: 0.65rem; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.schedule-day-btn:hover { background: rgba(255,255,255,0.25); }
.schedule-day-btn.active { background: white; color: var(--primary); }
.schedule-day-btn.today:not(.active) { border: 1.5px solid rgba(255,255,255,0.5); }
.schedule-events { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; min-height: 0; overflow-y: auto; max-height: 120px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent; }
.schedule-event { display: flex; align-items: flex-start; gap: 0.5rem; background: rgba(255,255,255,0.12); border-radius: 8px; padding: 0.4rem 0.5rem; }
.schedule-event-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 0.35rem; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
.schedule-event-info { flex: 1; min-width: 0; }
.schedule-event-time { font-size: 0.6rem; color: rgba(255,255,255,0.65); display: flex; align-items: center; gap: 3px; }
.schedule-event-title { font-size: 0.78rem; font-weight: 700; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-event-sub { font-size: 0.6rem; color: rgba(255,255,255,0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-live-badge { display: inline-flex; align-items: center; gap: 2px; background: #22c55e; color: white; font-size: 0.55rem; font-weight: 800; padding: 1px 5px; border-radius: 4px; white-space: nowrap; animation: livePulse 1.5s infinite; flex-shrink: 0; margin-top: 0.2rem; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.schedule-empty { text-align: center; color: rgba(255,255,255,0.5); font-size: 0.78rem; padding: 0.75rem 0; font-style: italic; }
.schedule-more { text-align: center; font-size: 0.65rem; color: rgba(255,255,255,0.6); }
.schedule-footer { font-size: 0.6rem; color: rgba(255,255,255,0.45); text-align: center; margin-top: auto; }

.leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.leaderboard-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; background: color-mix(in srgb, var(--bg-color), black 5%); border-radius: 10px; font-weight: 600; }
.rank { width: 20px; height: 20px; background: #fbbf24; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; }
.leaderboard-list li:nth-child(2) .rank { background: #94a3b8; }
.leaderboard-list li:nth-child(3) .rank { background: #b45309; }
.leaderboard-list .name { flex: 1; color: var(--text-main); font-size: 0.85rem; }
.leaderboard-list .score { color: var(--primary); font-family: 'Lexend'; font-size: 0.95rem; }

/* Heatmap Styles */
.bento-heatmap { grid-column: span 3; }
.heatmap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.heatmap-header h3 { margin-bottom: 0; }
.heatmap-total { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.heatmap-body { display: flex; flex-direction: column; gap: 0.5rem; }
.heatmap-months { display: flex; justify-content: space-between; padding-left: 1.5rem; font-size: 0.75rem; color: var(--text-muted); }
.heatmap-grid-container { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; overflow: hidden; padding-bottom: 0; }
.heatmap-cell { aspect-ratio: 1; width: 100%; border-radius: 2px; }
.level-0 { background: var(--text-muted); opacity: 0.1; }
.level-1 { background: var(--primary); opacity: 0.25; }
.level-2 { background: var(--primary); opacity: 0.5; }
.level-3 { background: var(--primary); opacity: 0.75; }
.level-4 { background: var(--primary); opacity: 1; }
.heatmap-footer { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.legend-squares { display: flex; gap: 3px; }

/* Daily Quests */
.bento-quests { grid-column: span 1; }

/* Skill Gap Analysis */
.bento-skills { grid-column: span 2; }


/* ================== EXAM VIEW SHARED (Keep identical logic) ================== */
.btn-primary { background: var(--primary); color: white; padding: 1rem 2.5rem; border-radius: 12px; font-weight: 700; font-size: 1.3rem; text-transform: uppercase; letter-spacing: 0.5px; border: none; cursor: pointer; transition: all 0.3s; font-family: 'Lexend'; box-shadow: 0 4px 15px var(--primary-light); }
.btn-primary:hover { transform: translateY(-2px); filter: brightness(1.1); box-shadow: 0 8px 20px var(--primary-light); }
.btn-outline { background: var(--btn-bg); border: 2px solid var(--border); color: var(--text-main); padding: 1rem 2rem; border-radius: 12px; font-weight: 600; font-size: 1.3rem; cursor: pointer; transition: all 0.3s ease; font-family: 'Lexend'; box-shadow: var(--card-shadow); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
#exam-view header { background: var(--surface); backdrop-filter: var(--glass-blur); border-bottom: 1px solid var(--border); padding: 0.75rem 2rem; display: flex; justify-content: space-between; align-items: center; z-index: 10; }
.section-info { text-align: center; background: var(--btn-bg); padding: 0.5rem 2rem; border-radius: 100px; box-shadow: var(--card-shadow); border: 1px solid var(--border); }
.section-title { font-weight: 700; font-size: 1.3rem; color: var(--primary); text-transform: uppercase; }
.timer { display: flex; align-items: center; gap: 0.75rem; background: rgba(220, 38, 38, 0.08); color: var(--primary); padding: 0.6rem 1.2rem; border-radius: 50px; font-weight: 700; font-size: 1.4rem; border: 1px solid rgba(220, 38, 38, 0.15); position: relative; }
.main-container { display: flex; flex: 1; padding: 1.5rem 2rem; gap: 2rem; max-width: 1800px; margin: 0 auto; width: 100%; height: calc(100vh - 70px); }
.panel { background: var(--surface); backdrop-filter: var(--glass-blur); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; }
.question-panel { flex: 1; min-width: 0; padding: 2rem; position: relative; overflow-y: auto; display: flex; flex-direction: column; }
.question-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.question-number { font-size: 3rem; font-weight: 800; color: var(--text-main); }
.question-content { font-size: 1.3rem; line-height: 1.6; margin-bottom: 1.5rem; color: var(--text-main); }
.options-list { display: flex; flex-direction: column; gap: 1rem; }
.option { display: flex; align-items: center; padding: 1.15rem 1.75rem; background: var(--surface); border: 2px solid var(--border); border-radius: 16px; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
.option:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 15px rgba(0,0,0,0.05); }
.option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--text-main); }
.option-text { font-size: 1.3rem; font-weight: 500; color: var(--text-main); }
.radio-custom { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-muted); margin-right: 1.5rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.option:hover .radio-custom { border-color: var(--primary); }
.option.selected .radio-custom { border-color: var(--primary); background: var(--primary); }
.option.selected .radio-custom::after { content: ''; width: 8px; height: 8px; background: white; border-radius: 50%; }
.action-buttons { margin-top: auto; padding-top: 2rem; display: flex; justify-content: space-between; }
.palette-panel { width: 350px; flex-shrink: 0; padding: 1.5rem; display: flex; flex-direction: column; }
.palette-header { font-weight: 700; font-size: 1.4rem; margin-bottom: 1.5rem; color: var(--text-main); }
.status-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 2rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.legend-item { display: flex; align-items: center; gap: 0.5rem; }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; }
.dot-answered { background: var(--primary); }
.dot-unanswered { background: var(--btn-bg); border: 2px solid var(--border); }
.dot-current { background: var(--btn-bg); border: 2px solid var(--primary); }
.question-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.85rem; overflow-y: auto; padding-right: 10px; height: calc(100% - 130px); flex: 1; align-content: start; }
.q-box { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-family: 'Lexend', sans-serif; font-weight: 700; font-size: 1.1rem; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); color: var(--text-muted); box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.q-box:hover { border-color: var(--primary); color: var(--primary); transform: scale(1.15); box-shadow: 0 5px 15px rgba(220, 38, 38, 0.2); }
.q-box.answered { background: var(--primary); color: white; border-color: transparent; }
.q-box.current { border: 2px solid var(--primary); color: var(--primary); }
.q-box.correct { background: #10b981; color: white; border-color: transparent; }
.q-box.incorrect { background: #ef4444; color: white; border-color: transparent; }
.q-box.skipped { background: var(--btn-bg); color: var(--text-muted); border-color: var(--border); }
.option.correct { border-color: #10b981; background: rgba(16, 185, 129, 0.1); }
.option.incorrect { border-color: #ef4444; background: rgba(239, 68, 68, 0.1); }
.dot-correct { background: #10b981; }
.dot-incorrect { background: #ef4444; }
.dot-skipped { background: var(--btn-bg); border: 2px solid var(--border); }
.submit-area { margin-top: auto; padding-top: 1.5rem; }
.btn-submit { width: 100%; background: var(--primary); color: white; padding: 1.25rem; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; border-radius: 14px; border: none; cursor: pointer; font-family: 'Lexend'; font-weight: 700; transition: all 0.3s; box-shadow: 0 8px 20px var(--primary-light); }
.btn-submit:hover { transform: translateY(-2px); filter: brightness(1.1); }

/* KaTeX Math Scaling */
.question-content .katex, .option-text .katex { font-size: 1.3em !important; }
.katex .scriptstyle { font-size: 0.9em !important; } /* Make exponents bigger */
.katex .scriptscriptstyle { font-size: 0.8em !important; } /* Make nested exponents bigger */

/* Result */
.center-view { align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.score-circle { width: 220px; height: 220px; border-radius: 50%; background: var(--primary); color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 8px solid var(--btn-bg); box-shadow: var(--card-shadow); margin-bottom: 2rem; }
.score-number { font-size: 5rem; font-weight: 800; font-family: 'Lexend'; }
.score-label { font-size: 1.2rem; font-weight: 600; text-transform: uppercase; opacity: 0.9; }
.result-details { display: flex; gap: 2rem; margin-bottom: 3rem; }
.detail-box { background: var(--surface); backdrop-filter: var(--glass-blur); padding: 1.5rem; border-radius: 16px; border: 1px solid var(--border); min-width: 160px; box-shadow: var(--card-shadow); }
.detail-value { font-size: 2.5rem; font-weight: 800; color: var(--primary); font-family: 'Lexend'; }

.review-panel { border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 1.5rem; }
.review-panel p { margin-bottom: 0.5rem; color: var(--text-main); font-weight: 500; }
.explanation-box { background: var(--surface); border: 1px solid var(--border); padding: 1rem; border-radius: 8px; font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; white-space: pre-wrap; }

/* Tu Tien Magic Formation Background */
/*
 * QUY TẮC ĐẶT TÊN: các class trang trí ở đây PHẢI mang tiền tố `tran-phap-`.
 * File này load SAU Tailwind (xem <link> trong app/layout.tsx), nên bất kỳ tên
 * class trùng với utility của Tailwind đều khiến legacy thắng và phá vỡ component
 * mới. Tên cũ `.ring`, `.ring-1..4` từng đè lên utility `ring-*` của Tailwind.
 */
.bg-animated { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; overflow: hidden; pointer-events: none; background: transparent; }
.tran-phap { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.22; width: 100%; height: 100%; transition: opacity 0.5s ease; pointer-events: none; }
html.dark-mode .tran-phap { opacity: 0.35; }
.tran-phap-ring { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 50%; box-sizing: border-box; }

/* Vòng hào quang ngoài cùng */
.tran-phap-ring-outer-glow {
  width: 1700px;
  height: 1700px;
  border: 1px solid var(--primary);
  box-shadow: 0 0 40px var(--primary-light), inset 0 0 40px var(--primary-light);
  opacity: 0.3;
  animation: spin-center 300s linear infinite;
}

.tran-phap-ring-1 { width: 1540px; height: 1540px; border: 2px solid var(--primary); animation: spin-center 180s linear infinite; }
.tran-phap-ring-2 { width: 1440px; height: 1440px; border: 8px dashed var(--primary); animation: spin-center-reverse 120s linear infinite; opacity: 0.6; }

/* Vòng Thiên Cơ / Kim Đồng Hồ Thiên Văn xoay giật nấc 60 bước */
.tran-phap-ring-astro-stepped {
  width: 1380px;
  height: 1380px;
  border: 2px solid transparent;
  border-top: 6px solid var(--primary);
  border-bottom: 6px solid var(--primary);
  border-left: 1px solid var(--primary);
  border-right: 1px solid var(--primary);
  box-shadow: 0 0 20px var(--primary-light);
  animation: spin-center-stepped 60s steps(60) infinite;
  opacity: 0.75;
}

/* Vạch chia la bàn tinh xảo */
.tran-phap-ring-ticks {
  width: 1320px;
  height: 1320px;
  border: 3px dotted var(--primary);
  opacity: 0.7;
  animation: spin-center 140s linear infinite;
}

/* 8 Cổ tự Bát Quái khắc nổi (Càn, Khảm, Cấn, Chấn, Tốn, Ly, Khôn, Đoài) */
.tran-phap-ring-runes {
  width: 1200px;
  height: 1200px;
  animation: spin-center 90s linear infinite;
}
.tran-phap-ring-runes span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  font-family: 'Cinzel', 'Lexend', serif;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 16px var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tran-phap-ring-runes span:nth-child(1) { transform: rotate(0deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(2) { transform: rotate(45deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(3) { transform: rotate(90deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(4) { transform: rotate(135deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(5) { transform: rotate(180deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(6) { transform: rotate(225deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(7) { transform: rotate(270deg) translateY(-560px); }
.tran-phap-ring-runes span:nth-child(8) { transform: rotate(315deg) translateY(-560px); }

.tran-phap-ring-3 { width: 1000px; height: 1000px; border: 4px double var(--primary); animation: spin-center 200s linear infinite; }

/* 8 ấn ký quẻ Bát Quái đối xứng */
.tran-phap-ring-sigils { width: 1000px; height: 1000px; animation: spin-center-reverse 90s linear infinite; }
.tran-phap-ring-sigils span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 16px;
  margin: -8px 0 0 -26px;
  border-top: 5px solid var(--primary);
  border-bottom: 5px solid var(--primary);
  transform-origin: 26px 8px;
  opacity: .95;
}
.tran-phap-ring-sigils span::after {
  content: '';
  position: absolute;
  left: 19px;
  top: -5px;
  width: 14px;
  height: 16px;
  background: var(--bg-color);
}
.tran-phap-ring-sigils span:nth-child(1) { transform: rotate(0deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(2) { transform: rotate(45deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(3) { transform: rotate(90deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(4) { transform: rotate(135deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(5) { transform: rotate(180deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(6) { transform: rotate(225deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(7) { transform: rotate(270deg) translateY(-460px); }
.tran-phap-ring-sigils span:nth-child(8) { transform: rotate(315deg) translateY(-460px); }

/* Vòng bát giác / ngôi sao đối xứng ở tâm */
.tran-phap-ring-inner-star {
  width: 640px;
  height: 640px;
  border: 2px solid var(--primary);
  border-style: dotted;
  animation: spin-center-reverse 75s linear infinite;
  opacity: 0.7;
}

.tran-phap-ring-4 {
  width: 380px;
  height: 380px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spin-center 60s linear infinite;
  filter: drop-shadow(0 0 35px var(--primary-light));
  opacity: 0.85;
}

@keyframes spin-center { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes spin-center-reverse { 0% { transform: translate(-50%, -50%) rotate(360deg); } 100% { transform: translate(-50%, -50%) rotate(0deg); } }
@keyframes spin-center-stepped { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* V2 PREMIUM CRIMSON SPECIFIC ANIMATIONS & STYLES */
body.theme-crimson .logo .icon-box { background: linear-gradient(135deg, var(--primary) 0%, #991b1b 100%); box-shadow: 0 0 20px rgba(220, 38, 38, 0.15); }
body.theme-crimson .timer { overflow: hidden; box-shadow: 0 0 15px rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.2); }
body.theme-crimson .timer::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 50px; border: 2px solid var(--primary); opacity: 0; animation: pulse-border 2s infinite cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes pulse-border { 0% { transform: scale(0.95); opacity: 0.5; } 100% { transform: scale(1.1); opacity: 0; } }

body.theme-crimson .option { overflow: hidden; }
body.theme-crimson .option.selected .radio-custom::after { animation: popIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }

body.theme-crimson .q-box:hover { transform: scale(1.1) rotate(2deg); z-index: 2; border-color: var(--primary); color: var(--primary); }
body.theme-crimson .q-box.answered { background: linear-gradient(135deg, var(--primary) 0%, #be123c 100%); box-shadow: 0 4px 10px rgba(225, 29, 72, 0.2); color: white; border-color: transparent;}
body.theme-crimson .q-box.current { box-shadow: 0 0 0 4px var(--primary-light); transform: scale(1.05); }

/* Premium SaaS Buttons */
body.theme-crimson .btn-outline { background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); color: #334155; border: 1px solid #cbd5e1; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
body.theme-crimson .btn-outline:hover { background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); border-color: #94a3b8; color: #0f172a; transform: translateY(-1px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
body.theme-crimson .btn-outline:active { transform: scale(0.98); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }

body.theme-crimson .btn-submit { background: linear-gradient(180deg, #f43f5e 0%, #e11d48 100%); color: #ffffff; border: 1px solid #be123c; box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 4px 12px rgba(225, 29, 72, 0.3); text-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
body.theme-crimson .btn-submit:hover { background: linear-gradient(180deg, #fb7185 0%, #f43f5e 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 6px 16px rgba(225, 29, 72, 0.4); transform: translateY(-1px); }
body.theme-crimson .btn-submit:active { transform: scale(0.98); box-shadow: inset 0 2px 6px rgba(159, 18, 57, 0.4); }

body.theme-crimson .btn-primary { background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); color: #ffffff; border: 1px solid #000000; box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 4px rgba(0,0,0,0.2); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
body.theme-crimson .btn-primary:hover { background: linear-gradient(180deg, #334155 0%, #1e293b 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 4px 8px rgba(0,0,0,0.3); transform: translateY(-1px); }
body.theme-crimson .btn-primary:active { transform: scale(0.98); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }

/* ================== LEADERBOARD TABS ================== */
.leaderboard-tabs button {
    background: none; border: none; cursor: pointer; font-family: inherit;
    font-size: 0.75rem; font-weight: 600; color: var(--text-muted);
    padding: 0.25rem 0.6rem; border-radius: 6px;
    transition: all 0.2s; white-space: nowrap;
}
.leaderboard-tabs button:hover { color: var(--text-main); background: rgba(0,0,0,0.05); }
.leaderboard-tabs button.active-tab { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* Clickable nav user */
.bento-user { cursor: pointer; }
.bento-user:hover #nav-username { color: var(--primary); }

/* Skill progress bars */
/* skill progress bars deleted (now using tailwind) */

/* ================== HAMBURGER BUTTON (Desktop: ẩn) ================== */
.hamburger-btn {
    display: none; /* Ẩn trên desktop */
}

/* ================== MOBILE NAV DRAWER ================== */
/* Mobile-only: chỉ áp dụng khi JS inject class mobile-nav-drawer */
.mobile-nav-drawer {
    /* Desktop: không thay đổi gì */
}


/* Mobile Responsiveness */
@media (max-width: 768px) {
    /* Reset zoom and unlock scroll on mobile */
    html { overflow-x: hidden !important; }
    body { zoom: 1 !important; width: 100% !important; height: auto !important; min-height: 100vh !important; overflow: auto !important; overflow-x: hidden !important; -webkit-text-size-adjust: 100%; }
    * { -webkit-tap-highlight-color: transparent; }
    .view { height: auto !important; overflow: visible !important; max-width: 100vw !important; }
    .bento-layout { overflow: visible !important; max-width: 100vw !important; }

    /* KaTeX Math Responsive Display on Mobile */
    .katex-display {
        max-width: 100% !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0.25rem 0 !important;
        margin: 0.5rem 0 !important;
    }
    .katex {
        max-width: 100% !important;
    }
    .question-content .katex, .option-text .katex {
        font-size: 1.15em !important;
    }

    /* Hide animated background on mobile - causes visual chaos and performance issues */
    .bg-animated { display: none !important; }
    .tran-phap { display: none !important; }

    /* ===== HAMBURGER BUTTON ===== */
    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 38px;
        height: 38px;
        padding: 0;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        cursor: pointer;
        transition: background 0.2s, border-color 0.2s;
        flex-shrink: 0;
        order: 99; /* Luôn ở cuối nav-right */
    }
    .hamburger-btn:hover {
        background: var(--primary-light);
        border-color: var(--primary);
    }
    .ham-line {
        display: block;
        width: 18px;
        height: 2px;
        background: var(--text-main);
        border-radius: 2px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
        transform-origin: center;
    }
    /* Hiệu ứng X khi mở */
    .hamburger-btn.is-open .ham-line:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .hamburger-btn.is-open .ham-line:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }
    .hamburger-btn.is-open .ham-line:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* ===== NAVBAR — single row: logo trái, user+hamburger phải ===== */
    .bento-nav {
        padding: 0.5rem 1rem;
        flex-wrap: nowrap; /* Chỉ 1 hàng */
        gap: 0;
        align-items: center;
        justify-content: space-between;
    }
    .nav-left {
        gap: 0.5rem;
        width: auto;
        flex: 1;
        justify-content: flex-start;
    }
    .nav-right {
        gap: 0.6rem;
        width: auto;
        flex-shrink: 0;
        align-items: center;
    }

    /* ===== MOBILE DRAWER — slide in từ trái ===== */
    .mobile-nav-overlay {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 90;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .mobile-nav-drawer {
        position: fixed !important;
        top: 0;
        left: 0;
        width: min(280px, 80vw);
        height: 100dvh;
        background: var(--bg-color) !important;
        border-right: 1px solid var(--border);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
        z-index: 100;
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        padding: 5rem 0 1.5rem 0;
        overflow-y: auto;
        transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex-wrap: nowrap !important;
        overflow-x: hidden;
    }
    .mobile-nav-drawer.drawer-open {
        transform: translateX(0);
    }
    .mobile-nav-drawer a {
        font-size: 1rem !important;
        font-weight: 600 !important;
        white-space: nowrap;
        padding: 0.85rem 1.5rem !important;
        border-bottom: 1px solid var(--border);
        display: flex !important;
        align-items: center;
        gap: 0.75rem !important;
        color: var(--text-muted);
        transition: background 0.15s, color 0.15s;
        border-radius: 0 !important;
    }
    .mobile-nav-drawer a:hover,
    .mobile-nav-drawer a:active {
        background: var(--primary-light);
        color: var(--primary);
    }
    .mobile-nav-drawer a.active {
        color: var(--primary);
        font-weight: 700 !important;
        background: var(--primary-light);
    }
    .mobile-nav-drawer a i {
        width: 20px;
        text-align: center;
        font-size: 1rem;
    }
    /* Ẩn underline animation trong drawer */
    .mobile-nav-drawer a::after { display: none !important; }

    /* ===== ẨN các element không cần trong mobile navbar ===== */
    .streak-badge { display: none !important; } /* Ẩn streak — quá chật */

    .bento-logo { font-size: 1.25rem; }
    .bento-logo .main-logo-img { height: 40px !important; }
    .bento-user { font-size: 0.85rem; gap: 0.4rem; max-width: 140px; }
    .bento-user .avatar { width: 30px; height: 30px; font-size: 0.85rem; }
    #nav-username { max-width: 80px !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; display: inline-block !important; }
    #btn-logout { font-size: 0.75rem !important; padding: 0.35rem 0.55rem !important; margin-left: 0.25rem !important; }

    /* Subheader */
    .bento-subheader {
        padding: 0.75rem 1rem 0 1rem;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    .breadcrumb { font-size: 0.85rem; }
    .btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; width: 100%; text-align: center; }

    /* Content area */
    .bento-content {
        padding: 0.5rem 0.75rem;
        flex: none;
        display: block;
    }

    /* Grid - single column stack */
    .bento-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 0.75rem;
    }
    .bento-hero, .bento-action, .bento-countdown, .bento-league, 
    .bento-heatmap, .bento-recent, .bento-quests, .bento-skills {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: auto !important;
    }

    /* Cards — disable float/hover animations on mobile */
    .bento-card {
        padding: 1rem !important;
        border-radius: 12px !important;
        animation: none !important;
        transition: none !important;
    }
    .bento-card:hover {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.02) !important;
    }
    body.dark-mode .bento-card:hover {
        transform: none !important;
        box-shadow: none !important;
    }
    .bento-card h3 { font-size: 1rem !important; }

    /* Nav — firm sticky, no backdrop jitter */
    .bento-nav {
        position: sticky;
        top: 0;
        z-index: 50;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }
    /* Disable hover underline animation on nav links for touch */
    .nav-links a::after {
        display: none !important;
    }
    .nav-links a:hover svg.nav-icon {
        transform: none !important;
    }
    .nav-links a.active svg.nav-icon {
        transform: none !important;
    }

    /* Hero card */
    .bento-hero { min-height: 180px !important; }
    .bento-hero h2 { font-size: 1.1rem !important; }
    .bento-hero p { font-size: 0.85rem !important; }

    /* Action card (VÀO THI NHANH) */
    .bento-action { min-height: 80px !important; }
    .bento-action h2 { font-size: 1.2rem !important; }

    /* Heatmap - scroll horizontally */
    .bento-heatmap { overflow-x: auto; }
    .bento-heatmap svg { min-width: 600px; }
    .heatmap-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .heatmap-chart-area { min-width: 580px; }

    /* League/Leaderboard */
    .bento-league { max-height: 350px; overflow-y: auto; }
    .league-day-selector { flex-wrap: wrap; gap: 0.25rem; }
    .league-day-selector .btn-day { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

    /* Stats row */
    .stats-row, .stat-row, .bento-stats-row {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    .stat-item, .bento-stat-item {
        flex: 1 1 45% !important;
        min-width: 0 !important;
    }

    /* Recent exams */
    .bento-recent { max-height: 300px; overflow-y: auto; }

    /* Quests */
    .bento-quests { max-height: 300px; overflow-y: auto; }

    /* Skills chart */
    .bento-skills { max-height: 300px; overflow-y: auto; }

    /* Theme switcher */
    .theme-switcher {
        bottom: 0.75rem;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.4rem;
        gap: 0.3rem;
        z-index: 100;
    }
    .theme-switcher .theme-dot { width: 16px !important; height: 16px !important; }
    .theme-switcher .dark-mode-btn { width: 16px !important; height: 16px !important; font-size: 0.55rem !important; }

    /* Countdown card */
    .bento-countdown { min-height: 160px !important; }
    .countdown-timer { font-size: 1.2rem !important; }

    /* Floating elements */
    .chat-float-btn { bottom: 3.5rem !important; right: 0.75rem !important; width: 44px !important; height: 44px !important; }

    /* Mobile KaTeX formulas scroll */
    .katex-display {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        max-width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Prevent global horizontal spill on small screens */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .bento-layout {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Touch target comfort */
    button, a, input, select {
        touch-action: manipulation;
    }
}

/* Compact layout for smaller height screens (e.g. 1080p at 125% scale) */
@media (max-height: 900px) and (min-width: 769px) {
    body { zoom: 0.8; width: 125vw; min-height: 125vh; }
    .bg-animated { width: 125vw !important; min-height: 125vh !important; }
}

@media (min-width: 1600px), (max-height: 900px) and (min-width: 769px) {
    .bento-content { max-width: 1600px !important; }
    .bento-subheader { max-width: 1600px !important; padding-left: 0 !important; }
    .bento-grid { grid-template-columns: repeat(12, 1fr) !important; grid-template-rows: none !important; grid-auto-rows: auto !important; gap: 1rem; }
    
    .bento-league { grid-column: 1 / span 3 !important; grid-row: 1 / span 3 !important; }
    .bento-hero { grid-column: 4 / span 4 !important; grid-row: 1 !important; }
    .bento-countdown { grid-column: 8 / span 2 !important; grid-row: 1 !important; }
    .bento-action { grid-column: 10 / span 3 !important; grid-row: 1 !important; }
    
    .bento-heatmap { grid-column: 4 / span 9 !important; grid-row: 2 !important; }
    
    .bento-quests { grid-column: 4 / span 3 !important; grid-row: 3 !important; }
    .bento-recent { grid-column: 7 / span 3 !important; grid-row: 3 !important; }
    .bento-skills { grid-column: 10 / span 3 !important; grid-row: 3 !important; }



    .theme-switcher { left: 1rem !important; right: auto !important; padding: 0.5rem !important; gap: 0.5rem !important; }
    .theme-switcher .theme-dot { width: 18px !important; height: 18px !important; }
    .theme-switcher .dark-mode-btn { width: 18px !important; height: 18px !important; font-size: 0.6rem !important; }
}
@media (max-width: 768px) {
    .bento-grid { grid-template-rows: auto; }
    .bento-content { flex: none; display: block; }
}

/* ======================== SKELETON LOADING ======================== */
@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg,
        var(--border, rgba(0,0,0,0.06)) 25%,
        rgba(255,255,255,0.15) 37%,
        var(--border, rgba(0,0,0,0.06)) 63%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-card {
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border, rgba(0,0,0,0.06));
    background: var(--surface, rgba(255,255,255,0.6));
    backdrop-filter: blur(12px);
}

.skeleton-line {
    height: 14px;
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-full { width: 100%; }
.skeleton-line.h-lg { height: 20px; }
.skeleton-line.h-btn { height: 38px; border-radius: 10px; margin-top: 1rem; }

.skeleton-row {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.04));
}
.skeleton-row .skeleton-cell {
    height: 16px;
    border-radius: 4px;
    flex: 1;
}
.skeleton-row .skeleton-cell:first-child { flex: 0.3; }
.skeleton-row .skeleton-cell:last-child { flex: 0.5; }

/* Admin search + pagination bar */
.admin-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.admin-search-input {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border, rgba(0,0,0,0.12));
    border-radius: 8px;
    background: var(--surface, #fff);
    color: var(--text-main, #1e293b);
    font-size: 0.85rem;
    outline: none;
    min-width: 220px;
    transition: border-color 0.2s;
}
.admin-search-input:focus {
    border-color: var(--primary, #ef4444);
}
.users-pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

/* --- Page Loading Screen --- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}
.loader-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 400px;
    width: 90%;
    z-index: 2;
}
.loader-portal {
    position: relative;
    width: 140px;
    height: 140px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.portal-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
}
.portal-ring.ring-outer {
    width: 140px;
    height: 140px;
    border-top-color: var(--primary);
    border-bottom-color: var(--primary);
    animation: portal-spin-clockwise 3s linear infinite;
    box-shadow: 0 0 15px var(--primary-light), inset 0 0 15px var(--primary-light);
}
.portal-ring.ring-middle {
    width: 110px;
    height: 110px;
    border-left-color: var(--primary);
    border-right-color: var(--primary);
    border-style: dashed;
    animation: portal-spin-counter 2s linear infinite;
}
.portal-ring.ring-inner {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-light);
    animation: portal-pulse 1.5s ease-in-out infinite;
}
.loader-title {
    font-family: 'Lexend', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    animation: text-pulse 2s infinite;
}
.loader-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 500;
}
.loader-progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}
body.theme-cyber .loader-progress-bar {
    background: rgba(255, 255, 255, 0.05);
}
.loader-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--border));
    border-radius: 10px;
    animation: progress-fill-anim 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes portal-spin-clockwise {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes portal-spin-counter {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}
@keyframes portal-pulse {
    0%, 100% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}
@keyframes text-pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}
@keyframes progress-fill-anim {
    0% { width: 0%; }
    30% { width: 40%; }
    60% { width: 75%; }
    100% { width: 100%; }
}

/* ================= LEVEL UP THIÊN KIẾP ANIMATION ================= */
#level-up-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, rgba(153, 27, 27, 0.3) 0%, rgba(5, 5, 5, 0.98) 75%);
    backdrop-filter: blur(15px); z-index: 999999;
    display: none; align-items: center; justify-content: center; flex-direction: column;
    opacity: 0; transition: opacity 0.5s ease-out;
}
#level-up-modal.active { display: flex; opacity: 1; }

#level-up-modal.active .shake-container {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column;
    animation: cameraShake 0.7s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes cameraShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate3d(-15px, 15px, 0); }
    20%, 40%, 60%, 80% { transform: translate3d(15px, -15px, 0); }
}

/* 1. Lôi Kiếp Huyết Sắc */
.lightning-bolt {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 350px; height: 100%; z-index: 20; pointer-events: none; opacity: 0;
    filter: brightness(1.5);
}
#level-up-modal.active .lightning-bolt { animation: strikeLightning 0.6s ease-out forwards; }
@keyframes strikeLightning {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0); }
    5% { opacity: 1; transform: translateX(-50%) scaleY(1); filter: brightness(3); }
    10% { opacity: 0; }
    15% { opacity: 1; filter: brightness(4); }
    20% { opacity: 0; }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1.1); filter: brightness(1.5); }
}

.flash-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff; z-index: 15; pointer-events: none; opacity: 0;
    mix-blend-mode: overlay;
}
#level-up-modal.active .flash-overlay { animation: flashScreen 0.8s ease-out forwards; }
@keyframes flashScreen { 0% { opacity: 0.9; } 20% { opacity: 0.2; } 30% { opacity: 0.8; } 100% { opacity: 0; } }

/* Vùng bọc huy hiệu - Tâm điểm */
.badge-wrapper {
    position: relative; display: flex; align-items: center; justify-content: center;
    margin: 40px 0; z-index: 1; pointer-events: none;
}

/* 2. God Rays (Tia sáng chiếu rọi) */
.god-rays {
    position: absolute; top: 50%; left: 50%; width: 1200px; height: 1200px;
    transform: translate(-50%, -50%);
    background: repeating-conic-gradient(from 0deg, rgba(251, 191, 36, 0.15) 0deg 3deg, transparent 3deg 12deg);
    -webkit-mask-image: radial-gradient(circle, black 10%, transparent 60%);
    z-index: -2; opacity: 0; pointer-events: none;
}
#level-up-modal.active .god-rays {
    animation: rotateRays 40s linear infinite;
    transition: opacity 2s ease-in 1s; opacity: 1;
}
@keyframes rotateRays { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }

/* 3. Aura Thái Cực & Trận Pháp */
.aura-bg {
    position: absolute; top: 50%; left: 50%; width: 550px; height: 550px;
    transform: translate(-50%, -50%); z-index: -1; opacity: 0; pointer-events: none;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 1s ease-in 0.8s;
}
#level-up-modal.active .aura-bg { opacity: 1; }

.magic-circle {
    position: absolute; width: 100%; height: 100%; border: 2px solid rgba(251, 191, 36, 0.3); border-radius: 50%;
    box-shadow: 0 0 60px rgba(220, 38, 38, 0.5), inset 0 0 60px rgba(220, 38, 38, 0.5);
    animation: rotateMagicCircle 20s linear infinite;
    background: repeating-radial-gradient(circle, transparent 0, transparent 40px, rgba(220, 38, 38, 0.05) 40px, rgba(220, 38, 38, 0.05) 41px);
}
.magic-circle::before {
    content: ''; position: absolute; top: -30px; left: -30px; right: -30px; bottom: -30px;
    border: 4px dashed rgba(220, 38, 38, 0.4); border-radius: 50%;
    animation: rotateMagicCircle 15s linear infinite reverse;
}
.taiji {
    font-size: 350px; color: rgba(251, 191, 36, 0.1); animation: rotateTaiji 30s linear infinite reverse;
    text-shadow: 0 0 80px rgba(220, 38, 38, 0.6); line-height: 1;
}
@keyframes rotateMagicCircle { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes rotateTaiji { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* 4. Shockwave (Sóng âm bùng nổ) */
.shockwave {
    position: absolute; top: 50%; left: 50%; width: 200px; height: 200px;
    transform: translate(-50%, -50%) scale(0);
    border: 10px solid rgba(251, 191, 36, 0.8); border-radius: 50%;
    box-shadow: 0 0 50px rgba(220, 38, 38, 1), inset 0 0 50px rgba(220, 38, 38, 1);
    pointer-events: none; z-index: 6; opacity: 0;
}
#level-up-modal.active .shockwave { animation: fireShockwave 0.8s cubic-bezier(0.1, 0.8, 0.2, 1) 1.5s forwards; }
@keyframes fireShockwave {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; border-width: 30px; }
    100% { transform: translate(-50%, -50%) scale(6); opacity: 0; border-width: 1px; }
}

/* 5. Lens Flare (Tia sáng vắt ngang) */
.lens-flare {
    position: absolute; top: 50%; left: 50%; width: 800px; height: 4px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,1), transparent);
    transform: translate(-50%, -50%) scaleX(0);
    box-shadow: 0 0 30px rgba(255, 255, 255, 1), 0 0 60px #ef4444;
    z-index: 10; opacity: 0; pointer-events: none;
}
#level-up-modal.active .lens-flare { animation: flareFlash 0.6s cubic-bezier(0.1, 0.8, 0.2, 1) 1.5s forwards; }
@keyframes flareFlash {
    0% { transform: translate(-50%, -50%) scaleX(0); opacity: 1; height: 1px; }
    50% { transform: translate(-50%, -50%) scaleX(1); opacity: 1; height: 12px; }
    100% { transform: translate(-50%, -50%) scaleX(0); opacity: 0; height: 1px; }
}

/* Badge Image */
.level-up-badge {
    width: 250px; height: 250px; object-fit: contain; position: relative; z-index: 5;
    transform: scale(4) translateY(-150px); opacity: 0;
    filter: drop-shadow(0 0 50px rgba(220, 38, 38, 1));
    transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.8s; /* Rơi xuống */
}
#level-up-modal.active .level-up-badge {
    transform: scale(1) translateY(0); opacity: 1;
    animation: floatBadge 4s ease-in-out infinite 1.6s, pulseGlow 2s infinite 1.6s;
}
@keyframes floatBadge {
    0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 40px rgba(251, 191, 36, 0.8)); }
    50% { transform: translateY(-20px); filter: drop-shadow(0 0 80px rgba(220, 38, 38, 1)); }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); border-radius: 50%; }
    50% { box-shadow: 0 0 0 70px rgba(220, 38, 38, 0); border-radius: 50%; }
}

/* TEXTS */
.level-up-content { position: relative; z-index: 25; text-align: center; display: flex; flex-direction: column; align-items: center; }

.level-up-title {
    font-family: 'Lexend', sans-serif; font-size: 3rem; font-weight: 900; text-transform: uppercase;
    letter-spacing: 12px; margin: 0;
    background: linear-gradient(180deg, #ffffff 0%, #fcd34d 50%, #dc2626 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 25px rgba(220, 38, 38, 0.9));
    transform: scale(0.8) translateY(-30px); opacity: 0;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s;
}
@media (min-width: 768px) { .level-up-title { font-size: 5.5rem; letter-spacing: 15px; } }
#level-up-modal.active .level-up-title { transform: scale(1) translateY(0); opacity: 1; }

.level-up-rank {
    font-family: 'Lexend', sans-serif; font-size: 2.2rem; color: #fef3c7; font-weight: 800;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.8), 0 0 40px rgba(220, 38, 38, 0.8);
    margin: 0 0 15px 0; transform: translateY(40px); opacity: 0;
    transition: all 0.6s ease-out 1.2s;
}
#level-up-modal.active .level-up-rank { transform: translateY(0); opacity: 1; }

.level-up-desc {
    font-family: 'Be Vietnam Pro', sans-serif; color: #e2e8f0; font-size: 1.15rem; max-width: 500px;
    line-height: 1.6; margin-bottom: 45px; transform: translateY(30px); opacity: 0;
    transition: all 0.6s ease-out 1.4s; text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}
#level-up-modal.active .level-up-desc { transform: translateY(0); opacity: 1; }

.continue-btn {
    font-family: 'Lexend', sans-serif; padding: 14px 45px; font-size: 1.2rem; font-weight: bold; text-transform: uppercase;
    background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(153, 27, 27, 0.4));
    color: #fbbf24; border: 2px solid #fbbf24; border-radius: 50px; cursor: pointer;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3), inset 0 0 10px rgba(245, 158, 11, 0.2);
    opacity: 0; transform: translateY(20px);
    transition: all 0.6s ease-out 1.8s, background 0.3s, color 0.3s, transform 0.3s, box-shadow 0.3s;
    position: relative; overflow: hidden; pointer-events: auto; z-index: 50;
}
#level-up-modal.active .continue-btn { opacity: 1; transform: translateY(0); }
.continue-btn:hover {
    background: #fbbf24; color: #000; box-shadow: 0 0 40px rgba(245, 158, 11, 0.8); transform: scale(1.05);
}
.continue-btn::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(45deg) translateX(-100%); transition: transform 0.6s;
}
.continue-btn:hover::after { transform: rotate(45deg) translateX(100%); }

/* Cải tiến Particles (Hạt linh khí) */
.level-up-particle {
    position: absolute; bottom: -50px;
    border-radius: 50%; pointer-events: none; opacity: 0; z-index: 5;
    filter: blur(1px);
}
@keyframes sparkUpAdvanced {
    0% { transform: translateY(0) scale(1) translateX(0); opacity: 0; }
    10% { opacity: 1; }
    50% { opacity: 1; transform: translateY(-50vh) scale(1.5) translateX(20px); filter: blur(0px); }
    100% { transform: translateY(-110vh) scale(0.2) translateX(-20px); opacity: 0; filter: blur(2px); }
}

/* ======================== ADMIN TABLES ======================== */
.admin-table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}
.admin-table th {
    background: rgba(0,0,0,0.03);
    padding: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
body.dark-mode .admin-table th {
    background: rgba(255,255,255,0.03);
}
.admin-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}
.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table tbody tr {
    transition: background-color 0.2s;
}
.admin-table tbody tr:hover {
    background: rgba(0,0,0,0.015);
}
body.dark-mode .admin-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}
/* Admin table specific utilities */
.admin-table td .status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}
.admin-table td .status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.admin-table td .status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Custom Dropdown Overrides for Tailwind CDN */
.group:hover .group-hover\:opacity-100 { opacity: 1 !important; }
.group:hover .group-hover\:visible { visibility: visible !important; }
.group:hover .group-hover\:scale-100 { transform: scale(1) !important; }

/* Admin Sidebar Accordion Dropdown -> Converted to Absolute Float Dropdown */
.admin-sidebar-group { position: relative; cursor: pointer; display: flex; align-items: center; }
.admin-sidebar-group > a { display: flex !important; align-items: center; }
.admin-sidebar-menu {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%) scale(0.95);
    width: max-content; min-width: 200px; background: var(--btn-bg); border: 1px solid var(--border);
    border-radius: 0.75rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    opacity: 0; visibility: hidden; transition: all 0.2s ease;
    display: flex; flex-direction: column; z-index: 9999; padding: 0.5rem 0; margin-top: 0.5rem;
}
.admin-sidebar-group:hover .admin-sidebar-menu {
    opacity: 1; visibility: visible; transform: translateX(-50%) scale(1);
}
.admin-sidebar-menu a {
    padding: 0.75rem 1.25rem !important; font-size: 0.875rem !important; gap: 0.75rem !important;
    color: var(--text-main) !important; justify-content: flex-start !important;
    background: transparent !important;
}
.admin-sidebar-menu a:hover {
    background: var(--primary, #3b82f6) !important; color: #fff !important;
}

/* Top Nav Admin Dropdown */
.nav-dropdown-container {
    position: relative;
    z-index: 9999;
}
.nav-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding-right: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
    font-weight: bold;
}
.nav-dropdown-trigger:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    width: 15rem;
    background: var(--btn-bg);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transform-origin: top left;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.nav-dropdown-container:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}
.nav-dropdown-menu a {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: background-color 0.2s;
}
.nav-dropdown-menu a:hover {
    background-color: var(--primary, #3b82f6);
    color: #ffffff;
}
.nav-dropdown-menu a i {
    width: 1.25rem;
    text-align: center;
}

/* ============================================================
   MOBILE RESPONSIVE — Admin & Shared Components
   All rules are scoped to max-width: 768px.
   Desktop layout is NOT affected.
   ============================================================ */
@media (max-width: 768px) {

    /* --- ADMIN TABLES: horizontal scroll wrapper --- */
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
    }
    .admin-table {
        min-width: 600px;
        font-size: 0.82rem;
    }
    .admin-table th,
    .admin-table td {
        padding: 0.65rem 0.75rem;
        white-space: nowrap;
    }

    /* --- ADMIN TOOLBAR --- */
    .admin-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .admin-search-input {
        min-width: 0;
        width: 100%;
    }
    .users-pagination {
        margin-left: 0;
        justify-content: center;
    }

    /* --- NAV DROPDOWNS: touch friendly --- */
    .nav-dropdown-menu {
        width: 12rem;
    }
    .nav-dropdown-menu a {
        padding: 0.85rem 1rem;
        font-size: 0.82rem;
    }
    .admin-sidebar-menu {
        min-width: 160px;
    }
    .admin-sidebar-menu a {
        padding: 0.65rem 1rem !important;
        font-size: 0.82rem !important;
    }

    /* --- LEVEL UP MODAL: scale down on mobile --- */
    .level-up-badge {
        width: 180px !important;
        height: 180px !important;
    }
    .level-up-title {
        font-size: 2.2rem !important;
        letter-spacing: 6px !important;
    }
    .level-up-rank {
        font-size: 1.6rem !important;
    }
    .level-up-desc {
        font-size: 0.95rem !important;
        max-width: 300px !important;
        margin-bottom: 30px !important;
    }
    .continue-btn {
        padding: 10px 30px !important;
        font-size: 1rem !important;
    }
    .aura-bg {
        width: 350px !important;
        height: 350px !important;
    }
    .god-rays {
        width: 600px !important;
        height: 600px !important;
    }
}

/* ================== MOBILE NOTICE BANNER ================== */
#mobile-notice {
    position: fixed;
    bottom: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 420px;
    background: var(--surface, rgba(255,255,255,0.97));
    border: 1px solid var(--border, rgba(185,28,28,0.2));
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1rem 1rem 1.1rem;
    z-index: 99999;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
#mobile-notice.mn-show {
    bottom: 1rem;
}
.mn-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.mn-body {
    flex: 1;
    min-width: 0;
}
.mn-title {
    font-family: 'Lexend', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main, #333);
    margin-bottom: 0.25rem;
}
.mn-desc {
    font-size: 0.78rem;
    color: var(--text-muted, #777);
    line-height: 1.45;
}
.mn-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #999);
    font-size: 1rem;
    padding: 0.1rem 0.25rem;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.2s;
}
.mn-close:hover {
    color: var(--primary, #b91c1c);
}

/* ─── NAME FRAMES (BẾ QUAN THẦN THỤ) ─── */
/* ══════════════════════════════════════════════════════════════════════════
   PREMIUM CYBER & MYTHIC DISPLAY NAME STYLES (Đẳng cấp Thần Thoại & Tiên Hiệp)
   - Dòng chảy ánh sáng liên tục (Seamless Directional Gradient Flow)
   - Vệt sáng ánh kim phản chiếu (Specular Sheen Sweep)
   - Hào quang linh khí hít thở 2 lớp (Breathing Dual-Layer Ambient Aura)
   ══════════════════════════════════════════════════════════════════════════ */
.name-frame-base {
    display: inline-flex;
    align-items: center;
    position: relative;
    font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 800;
    font-size: 1.08em;
    line-height: 1.25;
    letter-spacing: 0.035em;
    white-space: nowrap;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: background-position, transform;
}

.name-frame-base:hover {
    transform: translateY(-1px) scale(1.02);
}

/* 1. Hỏa Phượng (Inferno Phoenix Flare) - Dela Gothic One (Ultra Heavy Impact) */
.name-frame-hoa_phuong {
    font-family: 'Dela Gothic One', 'Alfa Slab One', sans-serif !important;
    letter-spacing: 0.04em;
    background-image: linear-gradient(
        115deg,
        #e11d48 0%,
        #f43f5e 18%,
        #fb923c 35%,
        #ffffff 50%,
        #f59e0b 65%,
        #ea580c 82%,
        #e11d48 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 3.2s linear infinite, fireAura 2.6s ease-in-out infinite;
}

/* 2. Ngọc Quang (Cyber Jade / Thanh Đế Bích Ngọc) - MuseoModerno (Modern Ring) */
.name-frame-jade {
    font-family: 'MuseoModerno', sans-serif !important;
    font-weight: 800;
    letter-spacing: 0.03em;
    background-image: linear-gradient(
        115deg,
        #059669 0%,
        #10b981 18%,
        #34d399 35%,
        #ffffff 50%,
        #6ee7b7 65%,
        #047857 82%,
        #059669 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 3.6s linear infinite, jadeAura 2.8s ease-in-out infinite;
}

/* 3. Hư Không (Void Mystic / Tử Tiêu Ma Tôn) - Playfair Display (Dramatic Luxury Serif) */
.name-frame-void {
    font-family: 'Playfair Display', serif !important;
    font-weight: 900;
    font-style: italic;
    letter-spacing: 0.03em;
    background-image: linear-gradient(
        115deg,
        #7c3aed 0%,
        #9333ea 18%,
        #ec4899 35%,
        #ffffff 50%,
        #a855f7 65%,
        #4f46e5 82%,
        #7c3aed 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 3.4s linear infinite, voidAura 2.5s ease-in-out infinite;
}

/* 4. Lôi Kiếp (Thunder Tribulation / Cửu Thiên Huyền Lôi) - Alfa Slab One (Heavy Sledgehammer) */
.name-frame-loi_kiep {
    font-family: 'Alfa Slab One', cursive, sans-serif !important;
    letter-spacing: 0.04em;
    background-image: linear-gradient(
        115deg,
        #0891b2 0%,
        #0284c7 18%,
        #38bdf8 35%,
        #ffffff 50%,
        #7dd3fc 65%,
        #0369a1 82%,
        #0891b2 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 2.4s linear infinite, thunderSurge 2s ease-in-out infinite;
}

/* 5. Tinh Không (Cosmic Nebula / Thái Cổ Tinh Thần) - Goldman (Sci-Fi Cyberpunk) */
.name-frame-tinh_khong {
    font-family: 'Goldman', 'Be Vietnam Pro', sans-serif !important;
    font-weight: 700;
    letter-spacing: 0.06em;
    background-image: linear-gradient(
        115deg,
        #6366f1 0%,
        #8b5cf6 20%,
        #ec4899 40%,
        #ffffff 52%,
        #06b6d4 70%,
        #4338ca 85%,
        #6366f1 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 4s linear infinite, nebulaAura 3s ease-in-out infinite;
}

/* 6. Hoàng Kim Long (Imperial Sovereign Gold / Chí Tôn Hoàng Đế) - Playball (Imperial Cursive Script) */
.name-frame-hoang_kim {
    font-family: 'Playball', 'Playfair Display', cursive, serif !important;
    font-size: 1.15em;
    letter-spacing: 0.03em;
    background-image: linear-gradient(
        115deg,
        #b45309 0%,
        #d97706 18%,
        #f59e0b 35%,
        #ffffff 50%,
        #fef08a 65%,
        #b45309 82%,
        #b45309 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 3s linear infinite, goldAura 2.4s ease-in-out infinite;
}

/* 7. Băng Tôn (Glacial Frost / Hàn Băng Tuyệt Cảnh) - Grenze Gotisch (Gothic Ice Crystal) */
.name-frame-bang_ton {
    font-family: 'Grenze Gotisch', serif !important;
    font-weight: 800;
    letter-spacing: 0.04em;
    background-image: linear-gradient(
        115deg,
        #0284c7 0%,
        #38bdf8 20%,
        #7dd3fc 38%,
        #ffffff 50%,
        #bae6fd 68%,
        #0369a1 85%,
        #0284c7 100%
    );
    background-size: 200% auto;
    animation: textFlowAnim 3.4s linear infinite, frostAura 2.8s ease-in-out infinite;
}

/* 8. Neon Cyber (Neon Tube Glow) - MuseoModerno (Modern Neon) */
.name-frame-neon {
    font-family: 'MuseoModerno', sans-serif !important;
    font-weight: 900;
    letter-spacing: 0.05em;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    text-shadow:
        0 0 4px #ffffff,
        0 0 10px #c084fc,
        0 0 20px #a855f7,
        0 0 38px #7c3aed,
        0 0 60px #4f46e5;
    animation: neonElectricAnim 3s ease-in-out infinite;
}

/* 9. Hoạt Họa Anime (Toon Pop Outline) - Bangers (Comic Pop) */
.name-frame-toon {
    font-family: 'Bangers', cursive, sans-serif !important;
    font-size: 1.18em;
    letter-spacing: 0.12em;
    word-spacing: 0.25em;
    color: #fde047 !important;
    -webkit-text-fill-color: #fde047 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    paint-order: stroke fill;
    -webkit-text-stroke: 1px #0f172a;
    text-shadow:
        1.5px 1.5px 0px #0f172a,
        3px 3px 0px #ef4444;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
    animation: toonBounceAnim 1.8s cubic-bezier(0.28, 0.84, 0.42, 1) infinite, toonShadowAnim 1.8s ease-in-out infinite;
    transform-origin: center bottom;
    display: inline-block;
    white-space: nowrap;
}
.name-frame-toon:hover {
    animation-duration: 0.9s;
}

/* 10. Pop 3D Retro (Retro Pop Art 3D) - Alfa Slab One (Heavy Arcade Pop) */
.name-frame-pop {
    font-family: 'Alfa Slab One', 'Dela Gothic One', sans-serif !important;
    font-size: 1.05em;
    letter-spacing: 0.08em;
    word-spacing: 0.2em;
    color: #6ee7b7 !important;
    -webkit-text-fill-color: #6ee7b7 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    text-shadow:
        1px 1px 0px #065f46,
        2px 2px 0px #064e3b,
        3px 3px 0px #022c22,
        4px 4px 6px rgba(0, 0, 0, 0.6);
    animation: pop3DPulseAnim 1.8s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
    transform-origin: center center;
    display: inline-block;
    white-space: nowrap;
}
.name-frame-pop:hover {
    animation-duration: 0.9s;
}

/* 11. Kẹo Dẻo Gummy (Sweet Gummy Jelly Gloss) - Cherry Bomb One (Bubble Pastel) */
.name-frame-gummy {
    font-family: 'Cherry Bomb One', 'Comfortaa', cursive, sans-serif !important;
    font-size: 1.12em;
    letter-spacing: 0.06em;
    word-spacing: 0.15em;
    background-image: linear-gradient(180deg, #ffffff 0%, #f472b6 36%, #ec4899 70%, #9333ea 100%);
    background-size: 100% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 0px rgba(168, 85, 247, 0.5)) drop-shadow(0 4px 10px rgba(244, 114, 182, 0.5));
    animation: gummyWobbleAnim 2.2s ease-in-out infinite, gummyShineAnim 2.2s ease-in-out infinite;
    transform-origin: center center;
    display: inline-block;
    white-space: nowrap;
}
.name-frame-gummy:hover {
    animation-duration: 1.1s;
}

/* 12. Lăng Kính Prism (Holo Prism Hologram) - Dela Gothic One (Ultra-Wide Spectral Flow) */
.name-frame-prism {
    font-family: 'Dela Gothic One', 'MuseoModerno', sans-serif !important;
    letter-spacing: 0.06em;
    word-spacing: 0.15em;
    background-image: linear-gradient(
        115deg,
        #ff007a 0%,
        #ff8c00 18%,
        #ffe600 36%,
        #00f0ff 54%,
        #7000ff 72%,
        #ec4899 90%,
        #ff007a 100%
    );
    background-size: 250% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textFlowAnim 4s linear infinite, prismWaveAnim 3s ease-in-out infinite, prismAura 3s ease-in-out infinite;
    transform-origin: center center;
    display: inline-block;
    white-space: nowrap;
}

/* 13. Pixel 8-Bit (Arcade 8-Bit Scanline) - Pixelify Sans (Retro Arcade 8-Bit) */
.name-frame-pixel {
    font-family: 'Pixelify Sans', monospace !important;
    font-weight: 700;
    letter-spacing: 0.1em;
    word-spacing: 0.2em;
    color: #4ade80 !important;
    -webkit-text-fill-color: #4ade80 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    text-shadow:
        0 0 2px #ffffff,
        0 0 6px #22c55e,
        0 0 14px #16a34a,
        0 0 26px rgba(34, 197, 94, 0.45);
    animation: pixelStepAnim 1.4s steps(1) infinite, pixelGlowAnim 1.4s steps(2) infinite;
    display: inline-block;
    white-space: nowrap;
}

/* ── Smooth High-End Keyframes ────────────────────────────────────────── */
@keyframes textFlowAnim {
    0% {
        background-position: 0% center;
    }
    100% {
        background-position: 200% center;
    }
}

/* ── Cartoon Squash & Stretch Bouncing ──────────────────────── */
@keyframes toonBounceAnim {
    0%, 100% {
        transform: translateY(0) scale(1, 1);
        animation-timing-function: cubic-bezier(0.28, 0.84, 0.42, 1);
    }
    18% {
        transform: translateY(2px) scale(1.08, 0.9);
        animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28);
    }
    38% {
        transform: translateY(-9px) scale(0.92, 1.12);
        animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
    }
    54% {
        transform: translateY(1.5px) scale(1.06, 0.94);
        animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    68% {
        transform: translateY(-3px) scale(0.98, 1.02);
        animation-timing-function: ease-in-out;
    }
    82% {
        transform: translateY(0) scale(1.01, 0.99);
    }
}

@keyframes toonShadowAnim {
    0%, 100% {
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    }
    38% {
        filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.25)) drop-shadow(0 0 10px rgba(239, 68, 68, 0.3));
    }
    54% {
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    }
}

/* ── Gummy Jelly Wobble ───────────────────────────────────────── */
@keyframes gummyWobbleAnim {
    0%, 100% {
        transform: scale(1, 1) rotate(0deg);
    }
    16% {
        transform: scale(1.07, 0.93) rotate(-1.8deg);
    }
    33% {
        transform: scale(0.94, 1.06) rotate(1.8deg) translateY(-4px);
    }
    50% {
        transform: scale(1.05, 0.95) rotate(-1.2deg) translateY(0px);
    }
    66% {
        transform: scale(0.97, 1.03) rotate(0.8deg);
    }
    83% {
        transform: scale(1.02, 0.98) rotate(-0.4deg);
    }
}

@keyframes gummyShineAnim {
    0%, 100% {
        filter: drop-shadow(0 2px 0px rgba(168, 85, 247, 0.7)) drop-shadow(0 4px 12px rgba(244, 114, 182, 0.6));
    }
    50% {
        filter: drop-shadow(0 3px 0px rgba(236, 72, 153, 0.85)) drop-shadow(0 6px 22px rgba(244, 114, 182, 0.85));
    }
}

/* ── Pop 3D Extrusion Punch ───────────────────────────────────── */
@keyframes pop3DPulseAnim {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        text-shadow:
            1px 1px 0px #065f46,
            2px 2px 0px #064e3b,
            3px 3px 0px #022c22,
            4px 4px 6px rgba(0, 0, 0, 0.6);
    }
    50% {
        transform: translate(-2px, -2px) scale(1.04);
        text-shadow:
            1px 1px 0px #065f46,
            2px 2px 0px #065f46,
            3px 3px 0px #064e3b,
            4px 4px 0px #022c22,
            5px 5px 0px #022c22,
            6px 6px 10px rgba(0, 0, 0, 0.75);
    }
}

/* ── Neon Tube Electric Hum & Flicker ─────────────────────────── */
@keyframes neonElectricAnim {
    0%, 100% {
        text-shadow:
            0 0 4px #ffffff,
            0 0 10px #c084fc,
            0 0 22px #a855f7,
            0 0 40px #7c3aed,
            0 0 65px #4f46e5;
        opacity: 1;
    }
    45% {
        text-shadow:
            0 0 6px #ffffff,
            0 0 14px #e879f9,
            0 0 28px #c026d3,
            0 0 50px #9333ea,
            0 0 80px #a855f7;
        opacity: 1;
    }
    68% {
        text-shadow:
            0 0 2px #ffffff,
            0 0 6px #c084fc,
            0 0 12px #a855f7;
        opacity: 0.88;
    }
    70% {
        text-shadow: 0 0 1px #ffffff;
        opacity: 0.65;
    }
    72% {
        text-shadow:
            0 0 7px #ffffff,
            0 0 18px #e879f9,
            0 0 32px #c026d3,
            0 0 60px #9333ea;
        opacity: 1;
    }
}

/* ── Prism Spectral Wave ──────────────────────────────────────── */
@keyframes prismWaveAnim {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-2px) rotate(-0.5deg);
    }
    50% {
        transform: translateY(-4px) rotate(0deg);
    }
    75% {
        transform: translateY(-2px) rotate(0.5deg);
    }
}

/* ── 8-Bit Step Hop & Phosphor CRT Glow ───────────────────────── */
@keyframes pixelStepAnim {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-4px);
    }
    50% {
        transform: translateY(-4px);
    }
    75% {
        transform: translateY(0);
    }
}

@keyframes pixelGlowAnim {
    0%, 100% {
        text-shadow:
            0 0 2px #ffffff,
            0 0 6px #22c55e,
            0 0 14px #16a34a,
            0 0 26px rgba(34, 197, 94, 0.45);
    }
    50% {
        text-shadow:
            0 0 4px #ffffff,
            0 0 10px #4ade80,
            0 0 22px #22c55e,
            0 0 35px rgba(34, 197, 94, 0.7);
    }
}

/* Breathing Ethereal Auras */
@keyframes fireAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(244, 63, 94, 0.8)) drop-shadow(0 0 6px rgba(249, 115, 22, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(244, 63, 94, 0.85));
    }
}

@keyframes jadeAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(16, 185, 129, 0.8)) drop-shadow(0 0 6px rgba(52, 211, 153, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(16, 185, 129, 0.85));
    }
}

@keyframes voidAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(168, 85, 247, 0.8)) drop-shadow(0 0 6px rgba(236, 72, 153, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(168, 85, 247, 0.85));
    }
}

@keyframes thunderSurge {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.8)) drop-shadow(0 0 6px rgba(6, 182, 212, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.95)) drop-shadow(0 0 8px rgba(56, 189, 248, 0.85));
    }
}

@keyframes nebulaAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(99, 102, 241, 0.8)) drop-shadow(0 0 6px rgba(236, 72, 153, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(139, 92, 246, 0.85));
    }
}

@keyframes goldAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.8)) drop-shadow(0 0 6px rgba(217, 119, 6, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(245, 158, 11, 0.85));
    }
}

@keyframes frostAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.8)) drop-shadow(0 0 6px rgba(125, 211, 252, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 8px rgba(56, 189, 248, 0.85));
    }
}

@keyframes prismAura {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 0, 122, 0.7)) drop-shadow(0 0 6px rgba(0, 240, 255, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 4px rgba(255, 230, 0, 0.85)) drop-shadow(0 0 8px rgba(112, 0, 255, 0.65));
    }
}

/* ── Exam mode selection ───────────────────────────────────────────── */
.exam-mode-backdrop{position:fixed;inset:0;z-index:10050;display:grid;place-items:center;padding:24px;background:rgba(3,7,18,.78);backdrop-filter:blur(14px)}
.exam-mode-dialog{position:relative;width:min(720px,100%);max-height:94vh;overflow:auto;padding:32px;border:1px solid rgba(255,255,255,.13);border-radius:24px;background:radial-gradient(circle at 10% 0%,rgba(16,185,129,.16),transparent 38%),radial-gradient(circle at 90% 0%,rgba(245,158,11,.15),transparent 38%),linear-gradient(145deg,#111827,#070b14);box-shadow:0 36px 100px rgba(0,0,0,.6);color:#f8fafc;outline:none}
.exam-mode-close{position:absolute;right:20px;top:16px;width:40px;height:40px;border:1px solid rgba(255,255,255,.12);border-radius:50%;background:rgba(255,255,255,.06);color:#cbd5e1;font-size:26px;cursor:pointer;transition:.2s}.exam-mode-close:hover{background:rgba(255,255,255,.13);transform:rotate(8deg)}
.exam-mode-heading{text-align:center;margin-bottom:24px}.exam-mode-heading h2{margin:0 0 8px;font:800 clamp(22px,3vw,32px)/1.15 Lexend,sans-serif}.exam-mode-heading p{color:#94a3b8;font-weight:600;font-size:14px}
.exam-mode-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.exam-mode-card{position:relative;display:flex;flex-direction:column;align-items:flex-start;min-height:200px;padding:24px;border:1px solid rgba(255,255,255,.12);border-radius:18px;color:#fff;text-align:left;cursor:pointer;overflow:hidden;transition:transform .28s,border-color .28s,box-shadow .28s}.exam-mode-card:before{content:"";position:absolute;inset:0;opacity:.75;pointer-events:none}.exam-mode-card>*{position:relative;z-index:1}.exam-mode-card.is-free{background:linear-gradient(150deg,rgba(6,78,59,.72),rgba(6,24,34,.9))}.exam-mode-card.is-free:before{background:radial-gradient(circle at 100% 0%,rgba(52,211,153,.25),transparent 48%)}.exam-mode-card.is-strict{background:linear-gradient(150deg,rgba(92,40,5,.72),rgba(32,14,10,.94))}.exam-mode-card.is-strict:before{background:radial-gradient(circle at 100% 0%,rgba(251,146,60,.28),transparent 48%)}.exam-mode-card:hover:not(:disabled){transform:translateY(-5px);border-color:rgba(255,255,255,.34);box-shadow:0 24px 50px rgba(0,0,0,.35)}.exam-mode-card:disabled{opacity:.45;cursor:not-allowed;filter:grayscale(.65)}
.exam-mode-card>strong{margin:0 0 14px;font:800 20px Lexend,sans-serif}.exam-mode-points{list-style:none;padding:0;margin:0 0 auto;display:flex;flex-direction:column;gap:10px;color:#e2e8f0;font-size:13px;font-weight:600}.exam-mode-points li{display:flex;align-items:flex-start;gap:10px}.exam-mode-points i{width:16px;margin-top:2px;flex-shrink:0;text-align:center}.is-free .exam-mode-points i{color:#6ee7b7}.is-strict .exam-mode-points i{color:#fdba74}.exam-mode-cta{display:flex;justify-content:center;align-items:center;gap:8px;width:100%;padding:12px;margin-top:16px;border-radius:12px;background:rgba(255,255,255,.1);font-weight:800;font-size:14px}.exam-mode-note{text-align:center;margin:18px 0 0;color:#94a3b8;font-size:12px}
@media(max-width:720px){.exam-mode-backdrop{padding:10px}.exam-mode-dialog{padding:24px 16px 20px;border-radius:20px}.exam-mode-grid{grid-template-columns:1fr}.exam-mode-card{min-height:0;padding:20px}.exam-mode-heading{padding:0 20px}}

/* ── Custom Theme-Synchronized Scrollbar ── */
html, body, * {
    scrollbar-width: thin;
    scrollbar-color: var(--border, rgba(148, 163, 184, 0.45)) transparent;
}
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border, rgba(148, 163, 184, 0.4));
    border-radius: 9999px;
    border: 1px solid transparent;
    background-clip: padding-box;
    transition: background-color 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #b91c1c);
}
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--border, rgba(148, 163, 184, 0.4));
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #b91c1c);
}

/* ── Mobile Viewport & Responsiveness Overhaul (Scoped max-width: 768px) ── */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
    
    .bento-layout {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .bento-content {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* KaTeX Mathematical Formulas horizontal touch scroll */
    .katex-display {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        max-width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 0.35rem 0 !important;
    }

    .katex {
        max-width: 100% !important;
    }

    /* Navbar mobile optimization */
    .bento-nav {
        padding: 0.5rem 0.75rem !important;
    }

    #nav-username {
        max-width: 85px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        display: inline-block !important;
        font-size: 0.8rem !important;
    }

    #btn-logout {
        padding: 0.35rem 0.55rem !important;
        font-size: 0.8rem !important;
        margin-left: 0.35rem !important;
    }

    /* Subheader & breadcrumbs */
    .bento-subheader {
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
        padding: 0.6rem 0.75rem !important;
    }

    .bento-subheader .breadcrumb {
        font-size: 0.78rem !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        max-width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Touch enhancement */
    button, a, input, select, textarea {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Modals & Dialogs full width safeguard */
    .modal-dialog, .bento-dialog {
        max-width: calc(100vw - 24px) !important;
        margin: 12px auto !important;
    }

    /* Media & pre/code containment */
    img, video, iframe {
        max-width: 100%;
    }
    pre, code {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Contain per-row layout/style and isolate chat scroll compositor */
.chat-msg-row {
    contain: layout style;
}

.chat-feed-scroll {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

@keyframes chatMsgPulse {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary, #b91c1c) 55%, transparent);
    }
    55% {
        box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary, #b91c1c) 0%, transparent);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.chat-msg-highlight {
    animation: chatMsgPulse 1.1s ease-out 2;
}

