@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);
}

/* 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 */
    --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); --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: transparent; --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(255, 255, 255, 0.8); --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); --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; }

* { 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); height: 100vh; display: flex; flex-direction: column; overflow: hidden; position: relative; transition: background-color 0.5s ease; }
h1, h2, h3, .question-number, .timer, .palette-header { font-family: 'Lexend', sans-serif; }

/* Switcher */
.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; }
.theme-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.2s; }
.theme-dot:hover { transform: scale(1.2); }
.dot-cyber { background: linear-gradient(135deg, #0f172a, #8b5cf6); }
.dot-neumorphic { background: #e0e5ec; border: 2px solid #cbd5e1; }
.dot-mesh { background: linear-gradient(135deg, #e0c3fc, #8ec5fc); }

/* Views */
.view { display: none; flex: 1; height: 100%; width: 100%; flex-direction: column; }
.view.active { display: flex; }

/* ================== 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; }

/* 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: 2rem; }
.nav-links a { text-decoration: none; color: var(--text-muted); font-weight: 500; font-size: 0.95rem; transition: color 0.2s; display: flex; align-items: center; gap: 0.4rem; }
.nav-links a:hover { color: var(--text-main); }
.nav-links a.active { color: var(--text-main); font-weight: 700; }
.nav-links a i { font-size: 0.95rem; transition: transform 0.2s ease; }
.nav-links a:hover i { transform: scale(1.15); }

.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 */
.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.3s ease, box-shadow 0.3s ease; border: 1px solid var(--border); overflow-y: auto; }
.bento-card:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.05); }
.bento-card h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin-bottom: 1rem; }

/* 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: pointer; justify-content: center; 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%; } }
.action-content h3 { color: white; margin-bottom: 0.25rem; font-size: 1.25rem; }
.action-content p { color: rgba(255,255,255,0.8); font-size: 0.85rem; margin-bottom: 1rem; }
.btn-start-now { background: white; color: var(--primary); padding: 0.5rem 1rem; border-radius: 50px; font-weight: 700; font-size: 0.85rem; display: inline-block; }

.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: var(--bg-color); 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, 10px); grid-auto-flow: column; grid-auto-columns: 10px; gap: 3px; overflow-x: auto; padding-bottom: 0; }
.heatmap-cell { width: 10px; height: 10px; 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; }

.recent-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.recent-list li { display: flex; justify-content: space-between; align-items: center; color: var(--text-main); font-weight: 500; font-size: 0.85rem; position: relative; padding-left: 1.25rem; }
.recent-list li::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; }
.recent-list li:first-child::before { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.recent-list .date { color: var(--text-muted); font-size: 0.8rem; }

/* Daily Quests */
.bento-quests { grid-column: span 1; }
.quest-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.quest-list li { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; font-weight: 500; color: var(--text-main); }
.quest-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.quest-list input[type="checkbox"]:checked + label { text-decoration: line-through; color: var(--text-muted); }

/* 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.05rem; 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.05rem; 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.05rem; 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: 2rem; font-weight: 800; color: var(--text-main); }
.question-content { font-size: 1.15rem; 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: 1rem 1.5rem; 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.15rem; 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); }

/* 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 */
.bg-animated { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 0; overflow: hidden; pointer-events: none; background: transparent; }
.tran-phap { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0.12; width: 100vw; height: 100vh; }
.ring { position: absolute; top: 50%; left: 50%; border-radius: 50%; }

.ring-1 { width: 1500px; height: 1500px; border: 2px solid var(--primary); animation: spin-center 180s linear infinite; box-shadow: inset 0 0 50px var(--primary-light), 0 0 50px var(--primary-light); }
.ring-2 { width: 1440px; height: 1440px; border: 12px dashed var(--primary); animation: spin-center-reverse 120s linear infinite; }
.ring-3 { width: 1000px; height: 1000px; border: 4px solid var(--primary); animation: spin-center 200s linear infinite; }

.ring-bagua { width: 1000px; height: 1000px; animation: spin-center-reverse 90s linear infinite; }
.bagua { position: absolute; top: 50%; left: 50%; font-size: 6rem; color: var(--primary); margin-top: -3rem; margin-left: -3rem; font-weight: bold; }
.bagua:nth-child(1) { transform: rotate(0deg) translateY(-460px); }
.bagua:nth-child(2) { transform: rotate(45deg) translateY(-460px); }
.bagua:nth-child(3) { transform: rotate(90deg) translateY(-460px); }
.bagua:nth-child(4) { transform: rotate(135deg) translateY(-460px); }
.bagua:nth-child(5) { transform: rotate(180deg) translateY(-460px); }
.bagua:nth-child(6) { transform: rotate(225deg) translateY(-460px); }
.bagua:nth-child(7) { transform: rotate(270deg) translateY(-460px); }
.bagua:nth-child(8) { transform: rotate(315deg) translateY(-460px); }

.ring-4 { font-size: 25rem; color: var(--primary); line-height: 1; display: flex; align-items: center; justify-content: center; animation: spin-center 60s linear infinite; text-shadow: 0 0 30px var(--primary-light); }

@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); } }

/* 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.175, 0.885, 0.32, 1.275); }
@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-item { display: flex; flex-direction: column; gap: 0.4rem; }
.skill-info { display: flex; justify-content: space-between; font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.progress-bg { height: 8px; background: rgba(0,0,0,0.07); border-radius: 50px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 50px; transition: width 0.5s ease; }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .bento-nav {
        padding: 0.75rem 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    .nav-left, .nav-right {
        gap: 1rem;
        justify-content: space-between;
        width: 100%;
    }
    .nav-links {
        gap: 1rem;
        overflow-x: auto;
        padding-bottom: 4px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    .nav-links a {
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .bento-subheader {
        padding: 1rem 1.25rem 0 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    .bento-content {
        padding: 0.5rem 1.25rem;
    }
    .bento-grid {
        grid-template-columns: 1fr;
    }
    .bento-hero, .bento-action, .bento-countdown, .bento-league, .bento-heatmap, .bento-recent, .bento-quests, .bento-skills {
        grid-column: span 1 !important;
    }
    .bento-logo {
        font-size: 1.5rem;
    }
    .theme-switcher {
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.5rem;
    }
}

/* Compact layout for smaller height screens (e.g. 1080p at 125% scale) */
@media (max-height: 900px) {
    body { zoom: 0.8; width: 125vw; height: 125vh; }
    .bg-animated { width: 125vw !important; height: 125vh !important; }
}

/* Wide layout for large screens or zoomed-out views (Sidebar Leaderboard) */
@media (min-width: 1600px), (max-height: 900px) {
    .bento-content { max-width: 1600px !important; }
    .bento-subheader { max-width: 1600px !important; padding-left: 0 !important; }
    .bento-grid { grid-template-columns: 320px repeat(4, 1fr) !important; }
    .bento-hero { grid-column: 2 / span 2 !important; }
    .bento-countdown { grid-column: 4 / span 1 !important; }
    .bento-action { grid-column: 5 / span 1 !important; }
    .bento-league { grid-column: 1 / span 1 !important; grid-row: 1 / span 3 !important; }
    .bento-heatmap { grid-column: 2 / span 4 !important; }
    .bento-recent { grid-column: 2 / span 1 !important; }
    .bento-quests { grid-column: 3 / span 1 !important; }
    .bento-skills { grid-column: 4 / span 2 !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; }
}

@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: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    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.6s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes cameraShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate3d(-10px, 10px, 0); }
    20%, 40%, 60%, 80% { transform: translate3d(10px, -10px, 0); }
}
.lightning-bolt {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
}
#level-up-modal.active .lightning-bolt {
    animation: strikeLightning 0.5s ease-out forwards;
}
@keyframes strikeLightning {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0); }
    5% { opacity: 1; transform: translateX(-50%) scaleY(1); filter: brightness(2); }
    10% { opacity: 0; }
    15% { opacity: 1; filter: brightness(3); }
    20% { opacity: 0; }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1.1); filter: brightness(1); }
}
.flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
}
#level-up-modal.active .flash-overlay {
    animation: flashScreen 0.8s ease-out forwards;
}
@keyframes flashScreen {
    0% { opacity: 0.8; }
    20% { opacity: 0.2; }
    30% { opacity: 0.9; }
    100% { opacity: 0; }
}
.sunburst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200vw;
    height: 200vw;
    margin-top: -100vw;
    margin-left: -100vw;
    background: repeating-conic-gradient(
        from 0deg,
        rgba(251, 191, 36, 0.2) 0deg 10deg,
        transparent 10deg 20deg
    );
    animation: rotateSunburst 30s linear infinite;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1s ease-in 0.6s;
}
#level-up-modal.active .sunburst { opacity: 1; }
@keyframes rotateSunburst {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.level-up-content {
    position: relative;
    z-index: 25;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.level-up-title {
    font-size: 3rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
    background: linear-gradient(to bottom, #ffffff, #fbbf24, #d97706);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    filter: drop-shadow(0 0 15px rgba(245, 158, 11, 0.5));
    transform: scale(0.5) translateY(-50px);
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.5s;
}
@media (min-width: 768px) {
    .level-up-title { font-size: 4rem; letter-spacing: 6px; }
}
#level-up-modal.active .level-up-title {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.level-up-badge {
    width: 200px;
    height: 200px;
    margin: 30px 0;
    transform: scale(0.1) rotate(-180deg);
    opacity: 0;
    filter: drop-shadow(0 0 40px rgba(245, 158, 11, 0.8));
    transition: all 1s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s;
}
#level-up-modal.active .level-up-badge {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    animation: floatBadge 3s ease-in-out infinite 1.6s;
}
@keyframes floatBadge {
    0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 40px rgba(245, 158, 11, 0.8)); }
    50% { transform: translateY(-20px) scale(1.05); filter: drop-shadow(0 0 60px rgba(245, 158, 11, 1)); }
}
.level-up-rank {
    font-size: 2rem;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    margin: 0 0 10px 0;
    transform: translateY(30px);
    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 {
    color: #cbd5e1;
    font-size: 1.1rem;
    max-width: 450px;
    line-height: 1.6;
    margin-bottom: 40px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.6s ease-out 1.4s;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    padding: 0 1rem;
}
#level-up-modal.active .level-up-desc {
    transform: translateY(0);
    opacity: 1;
}
.continue-btn {
    padding: 12px 40px;
    font-size: 1.1rem;
    font-weight: bold;
    text-transform: uppercase;
    background: rgba(0,0,0,0.5);
    color: #fbbf24;
    border: 2px solid #fbbf24;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease-out 1.6s, background 0.3s, color 0.3s, transform 0.3s;
}
#level-up-modal.active .continue-btn {
    opacity: 1;
    transform: translateY(0);
}
.continue-btn:hover {
    background: #fbbf24;
    color: #000;
    box-shadow: 0 0 35px rgba(245, 158, 11, 0.8);
    transform: scale(1.05);
}
.level-up-particle {
    position: absolute;
    bottom: -20px;
    width: 6px;
    height: 15px;
    background: #60a5fa;
    border-radius: 10px;
    box-shadow: 0 0 10px #3b82f6, 0 0 20px #60a5fa;
    pointer-events: none;
    opacity: 0;
    z-index: 5;
}
@keyframes sparkUp {
    0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    100% { transform: translateY(-100vh) scale(0.5) rotate(45deg); opacity: 0; }
}
