/* ========================================
   VocabMaster - CSS Design System
   ======================================== */

/* CSS Variables */
:root {
    /* Light Theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-card: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
    
    /* Spacing */
    --sidebar-width: 280px;
    --header-height: 64px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Theme Colors - Emerald */
[data-color="emerald"] {
    --accent-primary: #10b981;
    --accent-primary-hover: #059669;
    --accent-secondary: #34d399;
    --gradient-primary: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

/* Theme Colors - Rose */
[data-color="rose"] {
    --accent-primary: #f43f5e;
    --accent-primary-hover: #e11d48;
    --accent-secondary: #fb7185;
    --gradient-primary: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
}

/* Theme Colors - Amber */
[data-color="amber"] {
    --accent-primary: #f59e0b;
    --accent-primary-hover: #d97706;
    --accent-secondary: #fbbf24;
    --gradient-primary: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

/* Theme Colors - Cyan */
[data-color="cyan"] {
    --accent-primary: #06b6d4;
    --accent-primary-hover: #0891b2;
    --accent-secondary: #22d3ee;
    --gradient-primary: linear-gradient(135deg, #06b6d4 0%, #22d3ee 100%);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --gradient-card: linear-gradient(135deg, rgba(30,41,59,0.9) 0%, rgba(30,41,59,0.7) 100%);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

/* ======================================== 
   Loading Overlay 
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 1rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ======================================== 
   Header 
   ======================================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--gradient-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-fast);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    position: relative;
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-normal);
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.theme-icon-dark,
.theme-icon-light {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    transition: var(--transition-normal);
}

[data-theme="dark"] .theme-icon-dark {
    opacity: 1;
}

[data-theme="dark"] .theme-icon-light {
    opacity: 0;
}

[data-theme="light"] .theme-icon-dark {
    opacity: 0;
}

[data-theme="light"] .theme-icon-light {
    opacity: 1;
}

/* ======================================== 
   Sidebar 
   ======================================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    transition: var(--transition-normal);
    z-index: 900;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.sidebar-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    background: var(--accent-danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

.topics-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.topic-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: left;
    width: 100%;
    position: relative;
}

.topic-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topic-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 3px solid var(--accent-primary);
}

.topic-item .topic-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.topic-item .topic-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-item .topic-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.topic-item .topic-actions {
    display: none;
    gap: 0.25rem;
}

.topic-item:hover .topic-actions {
    display: flex;
}

.topic-item:hover .topic-count {
    display: none;
}

/* ======================================== 
   Main Content 
   ======================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.view-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-title .topic-icon {
    font-size: 2rem;
}

.view-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ======================================== 
   Stats Grid 
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px var(--shadow-color);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ======================================== 
   Dashboard Sections 
   ======================================== */
.dashboard-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.due-words-preview {
    max-height: 300px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Weekly Chart */
.weekly-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 150px;
    gap: 0.5rem;
    padding: 1rem 0;
}

.chart-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.chart-bar-fill {
    width: 100%;
    max-width: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition-normal);
    min-height: 4px;
}

.chart-bar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ======================================== 
   Words List 
   ======================================== */
.words-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.word-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.word-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 20px var(--shadow-color);
}

.word-speak {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.word-speak:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
}

.word-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.word-english {
    font-size: 1.125rem;
    font-weight: 600;
}

.word-vietnamese {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.word-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.word-status-badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
}

.word-status-badge.new {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.word-status-badge.learning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-warning);
}

.word-status-badge.mastered {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
}

.word-status-badge.due {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

.word-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: var(--transition-fast);
}

.word-card:hover .word-actions {
    opacity: 1;
}

/* Search Bar */
.search-bar {
    margin-bottom: 1.5rem;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition-fast);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ======================================== 
   Flashcard (Review Mode) 
   ======================================== */
.review-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 2rem;
}

.review-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin-bottom: 2rem;
    font-size: 1.125rem;
    font-weight: 500;
}

.flashcard {
    width: 100%;
    max-width: 500px;
    height: 300px;
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 1rem;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--gradient-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    backface-visibility: hidden;
    box-shadow: 0 20px 60px var(--shadow-color);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--gradient-primary);
}

.flashcard-word {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
}

.flashcard-meaning {
    font-size: 2rem;
    font-weight: 600;
    color: white;
    text-align: center;
}

.speak-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.speak-btn:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
}

.flashcard-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.review-actions {
    display: flex;
    gap: 1rem;
}

/* ======================================== 
   Test Mode 
   ======================================== */
.test-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 2rem;
}

.test-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin-bottom: 2rem;
    font-size: 1.125rem;
    font-weight: 500;
    gap: 1rem;
}

.test-card {
    width: 100%;
    max-width: 500px;
    padding: 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px var(--shadow-color);
    text-align: center;
}

.test-meaning {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.test-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.25rem;
    text-align: center;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition-fast);
}

.test-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.test-input.correct {
    border-color: var(--accent-success);
    background: rgba(16, 185, 129, 0.1);
}

.test-input.wrong {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.test-feedback {
    margin-top: 1rem;
    font-size: 1rem;
    min-height: 1.5rem;
}

.test-feedback.correct {
    color: var(--accent-success);
}

.test-feedback.wrong {
    color: var(--accent-danger);
}

.test-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Test Result */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    padding: 2rem;
    text-align: center;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
}

.result-container h1 {
    margin-bottom: 2rem;
}

.result-stats {
    display: flex;
    gap: 3rem;
    margin-bottom: 2rem;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-value {
    font-size: 3rem;
    font-weight: 700;
}

.result-label {
    font-size: 1rem;
    color: var(--text-secondary);
}

.wrong-words {
    width: 100%;
    max-width: 500px;
    margin-bottom: 2rem;
    text-align: left;
}

.wrong-words h3 {
    margin-bottom: 1rem;
    color: var(--accent-danger);
}

.wrong-word-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

/* ======================================== 
   Buttons 
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ======================================== 
   Modals 
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 80px var(--shadow-color);
    animation: modalSlide 0.3s ease;
}

.modal-small {
    max-width: 360px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-content > p {
    padding: 1.5rem;
    color: var(--text-secondary);
}

/* Forms */
.form-group {
    padding: 0 1.5rem;
    margin-bottom: 1.25rem;
}

.form-group:first-of-type {
    margin-top: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.inline-input {
    width: 80px !important;
    padding: 0.5rem !important;
    margin: 0 0.5rem;
}

.icon-picker,
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.icon-picker {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.icon-option,
.color-option {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.icon-option:hover,
.color-option:hover {
    border-color: var(--border-color);
}

.icon-option.selected,
.color-option.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Mobile responsive icon picker */
@media (max-width: 600px) {
    .icon-picker {
        max-height: 150px;
        gap: 0.35rem;
        padding: 0.35rem;
    }
    
    .icon-option {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    #topicModal .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ======================================== 
   Toast Notifications 
   ======================================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 3000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px var(--shadow-color);
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-message {
    font-size: 0.9375rem;
}

.toast.success {
    border-left: 4px solid var(--accent-success);
}

.toast.error {
    border-left: 4px solid var(--accent-danger);
}

.toast.warning {
    border-left: 4px solid var(--accent-warning);
}

/* ======================================== 
   Study List (Review Phase 1)
   ======================================== */
.study-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin-bottom: 1rem;
}

.study-header h2 {
    font-size: 1.5rem;
}

.study-list {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.study-word-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.study-word-row:hover {
    background: var(--border-color);
}

.study-word-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

.study-word-speak {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.study-word-speak:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.study-word-english {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 120px;
    flex-shrink: 0;
    margin-right: 1rem;
}

.study-word-vietnamese {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: right;
}

.study-actions {
    width: 100%;
    max-width: 600px;
    text-align: center;
    padding: 1rem 0;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* Mobile: optimize study list for small screens */
@media (max-width: 600px) {
    .review-container {
        padding: 1rem 0;
        min-height: auto;
        align-items: stretch;
    }
    
    .study-header {
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .study-header h2 {
        font-size: 1.25rem;
    }
    
    .study-list {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .study-word-row {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        flex-wrap: nowrap;
    }
    
    .study-word-number {
        width: 22px;
        height: 22px;
        font-size: 0.65rem;
        flex-shrink: 0;
    }
    
    .study-word-speak {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    
    .study-word-english {
        min-width: 80px;
        flex-shrink: 0;
        font-size: 0.875rem;
    }
    
    .study-word-vietnamese {
        flex: 1;
        font-size: 0.8125rem;
        color: var(--text-muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .study-actions {
        max-width: 100%;
        padding: 1rem;
    }
    
    .btn-large {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* ======================================== 
   Responsive 
   ======================================== */
@media (max-width: 1024px) {
    .dashboard-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 0.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .view-header:not(#chatView .view-header) {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .flashcard {
        height: 250px;
    }
    
    .flashcard-word {
        font-size: 2rem;
    }
    
    .flashcard-meaning {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .result-stats {
        gap: 1.5rem;
    }
    
    .result-value {
        font-size: 2rem;
    }
}

/* ======================================== 
   Confetti Animation 
   ======================================== */
@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    pointer-events: none;
}

/* Install Button */
#installBtn {
    display: none;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8125rem;
}

/* Profile Modal */
.profile-content {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.profile-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--accent-primary);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.profile-avatar-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.avatar-edit-btn {
    background: var(--accent-primary);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.avatar-edit-btn:hover {
    background: var(--accent-secondary);
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edit-name-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.6;
    transition: var(--transition-fast);
}

.edit-name-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.profile-details h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.profile-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.profile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem;
}

.profile-stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.profile-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
}

.profile-level {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.level-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.level-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.level-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.profile-section {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.profile-section h4 {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.profile-history {
    list-style: none;
    padding: 0;
    margin: 0;
}

.profile-history li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.profile-history li:last-child {
    border-bottom: none;
}

/* Badges */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.badge-item.earned {
    background: var(--gradient-primary);
    color: white;
}

.badge-item.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge-icon {
    font-size: 1.5rem;
}

.badge-name {
    font-size: 0.625rem;
    text-align: center;
    font-weight: 500;
}

.badge-mini {
    font-size: 1.25rem;
    cursor: pointer;
}

/* Theme Color Selector */
.theme-colors {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid transparent;
    padding: 4px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-primary);
}

.color-option span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ======================================== 
   Micro-Animations 
   ======================================== */

/* Card hover lift effect */
.stat-card,
.word-card,
.topic-item,
.mission-card,
.feature-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover,
.word-card:hover,
.topic-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-color);
}

/* Button press effect */
.btn {
    transition: all 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

/* Modal appear animation */
.modal.active .modal-content {
    animation: modalAppear 0.25s ease forwards;
}

@keyframes modalAppear {
    from { 
        opacity: 0; 
        transform: scale(0.9) translateY(-20px); 
    }
    to { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
}

/* Toast slide in */
.toast {
    animation: toastSlideIn 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { 
        transform: translateX(100%);
        opacity: 0;
    }
    to { 
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading pulse for stats */
.stat-value {
    transition: transform 0.2s ease;
}

/* Nav item hover */
.nav-item {
    transition: all 0.2s ease;
}

.nav-item:hover {
    transform: translateX(4px);
}

/* Mobile Responsive - Hide logo text */
@media (max-width: 600px) {
    .logo-text {
        display: none;
    }
    
    .user-name {
        display: none;
    }
    
    .header-right {
        gap: 0.25rem;
    }
    
    #loginBtn {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.75rem;
    }
    
    #loginBtn::before {
        content: "🔵";
    }
    
    /* Profile Modal - Fullscreen on mobile */
    #profileModal {
        padding: 0;
    }
    
    #profileModal .modal-content {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    #profileModal .modal-header {
        flex-shrink: 0;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid var(--border-color);
    }
    
    #profileModal .profile-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 1.25rem;
        padding-bottom: 2rem;
    }
    
    /* Better spacing between sections */
    .profile-user {
        margin-bottom: 1.5rem;
    }
    
    .profile-stats {
        margin-bottom: 1.5rem;
        padding: 1rem;
    }
    
    .profile-stat {
        padding: 0.5rem 0;
    }
    
    .profile-level {
        margin-bottom: 1.5rem;
        padding: 1rem;
    }
    
    .profile-section {
        margin-bottom: 1.5rem;
        padding: 1rem;
        background: var(--bg-tertiary);
        border-radius: var(--radius-md);
    }
    
    .profile-section h4 {
        margin-bottom: 1rem;
    }
    
    .badges-grid {
        gap: 0.5rem;
    }
    
    .badge-item {
        padding: 0.5rem 0.25rem;
    }
    
    .badge-icon {
        font-size: 1.25rem;
    }
    
    .badge-name {
        font-size: 0.5rem;
    }
    
    /* Form actions fixed at bottom */
    #profileModal .form-actions {
        flex-shrink: 0;
        padding: 1rem 1.25rem;
        border-top: 1px solid var(--border-color);
        background: var(--bg-secondary);
    }
    
    /* Hide login text on very small screens */
    @media (max-width: 400px) {
        #loginBtn span,
        #loginBtn {
            font-size: 0;
        }
        #loginBtn::after {
            content: "🔵";
            font-size: 1.25rem;
        }
    }
}

/* ======================================== 
   Landing Page 
   ======================================== */
.landing-page {
    min-height: 100vh;
    padding-top: 70px;
    background: var(--bg-primary);
}

.landing-hero {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--gradient-primary);
    color: white;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-hero {
    background: white;
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.btn-hero:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.landing-section {
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 2rem;
}

/* Mission Cards */
.mission-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.mission-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: var(--transition-normal);
}

.mission-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px var(--shadow-color);
}

.mission-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.mission-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--accent-primary);
}

.mission-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
}

.feature-item:hover {
    border-color: var(--accent-primary);
}

.feature-icon {
    font-size: 1.5rem;
}

/* Global Stats */
.global-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.global-stat {
    text-align: center;
}

.global-stat-value {
    display: block;
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.global-stat-label {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Install Section */
.install-section {
    text-align: center;
}

.install-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.install-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    max-width: 700px;
    margin: 0 auto 1.5rem;
}

.install-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: left;
    transition: var(--transition-normal);
}

.install-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.install-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.install-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.install-steps {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.install-steps li {
    margin-bottom: 0.5rem;
}

.install-steps strong {
    color: var(--accent-primary);
}

.share-icon {
    display: inline-block;
    background: var(--accent-primary);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.btn-install {
    background: var(--gradient-success);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    animation: pulse 2s infinite;
}

.btn-install:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
}

/* Leaderboard */
.leaderboard {
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.lea.dashboard-section:last-child {
    margin-bottom: 0;
}

/* Dashboard Row - Side by Side Sections */
.dashboard-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.dashboard-section-half {
    margin-bottom: 0;
}

/* Online count badge */
.online-count {
    background: var(--accent-success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Online users preview */
.online-users-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.online-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.online-user img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.online-user .online-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-success);
    border-radius: 50%;
}

/* Leaderboard preview compact */
.leaderboard-preview .leaderboard-item {
    padding: 0.75rem 1rem;
}

.leaderboard-preview .leaderboard-avatar {
    width: 32px;
    height: 32px;
}

.leaderboard-preview .leaderboard-rank {
    font-size: 1.125rem;
    width: 28px;
}

/* Mobile: Stack sections */
@media (max-width: 768px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    
    .dashboard-section-half {
        margin-bottom: 1.5rem;
    }
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: 700;
    width: 40px;
    text-align: center;
}

.leaderboard-rank.gold { color: #fbbf24; }
.leaderboard-rank.silver { color: #9ca3af; }
.leaderboard-rank.bronze { color: #d97706; }

.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: 600;
}

.leaderboard-xp {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.leaderboard-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Landing CTA */
.landing-cta {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
}

.landing-cta h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
}

/* App Container */
.app-container {
    display: flex;
    width: 100%;
    min-height: calc(100vh - 70px);
    margin-top: 70px;
}

/* Mobile Landing */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .global-stats {
        gap: 1.5rem;
    }
    
    .global-stat-value {
        font-size: 2rem;
    }
    
    .global-stat-label {
        font-size: 0.75rem;
    }
    
    /* Leaderboard mobile */
    .leaderboard-item {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .leaderboard-rank {
        font-size: 1.25rem;
        width: 30px;
    }
    
    .leaderboard-avatar {
        width: 32px;
        height: 32px;
    }
    
    .leaderboard-name {
        font-size: 0.875rem;
    }
    
    .leaderboard-xp {
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* ======================================== 
   Chat 
   ======================================== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    max-height: 600px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    max-width: 80%;
}

.chat-message.own {
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-bubble {
    background: var(--bg-tertiary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border-top-left-radius: 4px;
}

.chat-message.own .chat-bubble {
    background: var(--accent-primary);
    color: white;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: 4px;
}

.chat-sender {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.chat-message.own .chat-sender {
    display: none;
}

.chat-text {
    font-size: 0.9375rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-time {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.chat-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.chat-message.own .chat-time {
    color: rgba(255,255,255,0.7);
}

.chat-actions {
    display: none;
    gap: 0.25rem;
}

.chat-message:hover .chat-actions {
    display: flex;
}

.chat-action-btn {
    background: none;
    border: none;
    padding: 0.125rem;
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: var(--transition-fast);
}

.chat-action-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.chat-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Clickable chat elements */
.clickable-avatar {
    cursor: pointer;
    transition: var(--transition-fast);
}

.clickable-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.clickable-name {
    cursor: pointer;
    transition: var(--transition-fast);
}

.clickable-name:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 0.5rem 1rem;
    border-radius: 999px;
}

.online-badge .online-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   Import Modal
   ======================================== */
.modal-large {
    max-width: 600px;
}

.file-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.file-input:hover {
    border-color: var(--accent-primary);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.import-preview-container {
    margin: 1rem 1.5rem;
}

.import-preview-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.import-preview {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    padding: 0.75rem;
}

.import-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.import-table th,
.import-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.import-table th {
    font-weight: 600;
    color: var(--text-muted);
}

.import-errors {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-danger);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.import-errors ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.import-errors li {
    color: var(--accent-danger);
}

/* ========================================
   Admin Panel
   ======================================== */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.admin-tab {
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9375rem;
    transition: var(--transition-fast);
}

.admin-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.admin-tab.active {
    background: var(--accent-primary);
    color: white;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-secondary);
}

.admin-table tr:hover {
    background: var(--bg-tertiary);
}

.admin-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.admin-actions {
    display: flex;
    gap: 0.25rem;
}

.admin-message {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-message:hover {
    background: var(--bg-tertiary);
}

.admin-message-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 120px;
}

.admin-message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-message-text {
    flex: 1;
    color: var(--text-secondary);
}

.admin-message-delete {
    flex-shrink: 0;
}

.user-data-container {
    padding: 1rem 1.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.user-data-container h4 {
    margin: 1rem 0 0.5rem;
    color: var(--text-primary);
}

.user-data-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-data-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* Admin badges and status */
.banned-user {
    opacity: 0.6;
    background: rgba(239, 68, 68, 0.05);
}

.admin-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-size: 0.675rem;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    margin-left: 0.5rem;
}

.banned-badge {
    color: var(--accent-danger);
    font-weight: 500;
}

.active-badge {
    color: var(--accent-success);
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

/* ========================================
   Private Chat / Inbox
   ======================================== */
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    color: var(--text-primary);
}

.conversation-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Private Chat View */
.private-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.private-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.private-chat-name {
    font-weight: 600;
    color: var(--text-primary);
}

.private-chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 150px);
}

.private-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.private-message {
    display: flex;
    justify-content: flex-start;
}

.private-message.own {
    justify-content: flex-end;
}

.private-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.private-message.own .private-bubble {
    background: var(--accent-primary);
    color: white;
}

.private-text {
    word-wrap: break-word;
}

.private-time {
    font-size: 0.7rem;
    opacity: 0.7;
    text-align: right;
    margin-top: 0.25rem;
}

.private-form {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.private-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

/* Chat button in user card */
.chat-user-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.chat-user-btn:hover {
    opacity: 0.9;
}

/* ========================================
   Challenges
   ======================================== */
.challenges-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.challenges-list h3 {
    margin: 1rem 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.challenge-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--border-color);
}

.challenge-card.pending {
    border-left-color: var(--accent-warning);
}

.challenge-card.active {
    border-left-color: var(--accent-primary);
}

.challenge-card.completed.won {
    border-left-color: var(--accent-success);
}

.challenge-card.completed.lost {
    border-left-color: var(--accent-danger);
}

.challenge-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.challenge-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.challenge-name {
    font-weight: 600;
    color: var(--text-primary);
}

.challenge-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.challenge-actions {
    display: flex;
    gap: 0.5rem;
}

.challenge-score {
    font-weight: 600;
    color: var(--accent-primary);
}

.challenge-result {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.challenge-result .score {
    font-size: 1.25rem;
    font-weight: 700;
}

.result-badge {
    font-size: 0.8rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* Opponent List in Challenge Modal */
.opponent-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
}

.opponent-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.opponent-item:last-child {
    border-bottom: none;
}

.opponent-item:hover {
    background: var(--bg-secondary);
}

.opponent-item.selected {
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid var(--accent-primary);
}

.opponent-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.opponent-info {
    flex: 1;
    min-width: 0;
}

.opponent-name {
    font-weight: 600;
    color: var(--text-primary);
}

.opponent-xp {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
}

/* ========================================
   Online Users Grid & User Cards
   ======================================== */
.online-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
}

.user-card:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
}

.user-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-success);
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-xp {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* View User Profile Modal */
.modal-small {
    max-width: 400px;
}

.view-user-content {
    padding: 1.5rem;
    text-align: center;
}

.view-user-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.view-user-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-primary);
}

.view-user-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.view-user-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.view-user-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.view-user-stat .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.view-user-stat .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.view-user-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* Chat Mobile */
@media (max-width: 768px) {
    #chatView {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        padding: 0;
        margin: 0;
        background: var(--bg-primary);
        z-index: 100;
        overflow: hidden;
    }
    
    #chatView.active {
        display: flex;
    }
    
    #chatView .view-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-shrink: 0;
        margin: 0;
        padding: 0.75rem 1rem;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        flex-wrap: nowrap !important;
        gap: 0.75rem;
    }
    
    #chatView .view-header h1 {
        font-size: 1rem;
        margin: 0;
        white-space: nowrap;
    }
    
    #chatView .online-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        white-space: nowrap;
    }
    
    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: auto;
        max-height: none;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .chat-messages {
        flex: 1;
        min-height: 0;
        padding: 0.75rem;
    }
    
    .chat-form {
        flex-shrink: 0;
        padding: 0.5rem;
        border-top: 1px solid var(--border-color);
    }
    
    .chat-form input {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .chat-form button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .chat-message {
        max-width: 85%;
    }
    
    .chat-bubble {
        padding: 0.5rem 0.75rem;
    }
    
    /* Mobile: Show actions on tap */
    .chat-actions {
        display: flex;
        opacity: 0.7;
    }
    
    /* Private Chat Mobile Fullscreen */
    #privateChatView {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        padding: 0;
        margin: 0;
        background: var(--bg-primary);
        z-index: 100;
        overflow: hidden;
    }
    
    #privateChatView.active {
        display: flex;
    }
    
    .private-chat-header {
        flex-shrink: 0;
        margin: 0;
        padding: 0.75rem 1rem;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
    }
    
    .private-chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: auto;
        max-height: none;
    }
    
    .private-messages {
        flex: 1;
        overflow-y: auto;
        padding: 0.75rem;
    }
    
    .private-form {
        flex-shrink: 0;
        padding: 0.75rem;
        background: var(--bg-secondary);
    }
    
    /* Inbox Mobile Fullscreen */
    #inboxView {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        padding: 0;
        margin: 0;
        background: var(--bg-primary);
        z-index: 100;
        overflow-y: auto;
    }
    
    #inboxView.active {
        display: flex;
    }
}

/* ========================================
   Animated Badges System
   ======================================== */

/* Badge container */
.animated-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    vertical-align: middle;
}

/* Badge sizes */
.badge-sm, .badge-small {
    width: 18px;
    height: 18px;
    font-size: 12px;
}

.badge-md, .badge-medium {
    width: 24px;
    height: 24px;
    font-size: 16px;
}

.badge-lg, .badge-large {
    width: 36px;
    height: 36px;
    font-size: 24px;
}

.badge-icon {
    display: inline-block;
    animation: badgePulse 2s ease-in-out infinite;
}

/* Base animations */
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes badgeSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes badgeShine {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5) drop-shadow(0 0 4px currentColor); }
}

@keyframes badgeBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes badgeWiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

@keyframes badgeGlow {
    0%, 100% { filter: drop-shadow(0 0 2px currentColor); }
    50% { filter: drop-shadow(0 0 8px currentColor) brightness(1.2); }
}

@keyframes badgeRainbow {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes badgeFlame {
    0%, 100% { transform: scaleY(1) scaleX(1); }
    25% { transform: scaleY(1.1) scaleX(0.95); }
    50% { transform: scaleY(0.95) scaleX(1.05); }
    75% { transform: scaleY(1.05) scaleX(0.98); }
}

/* Premium Badge Styles - SVG */
.badge-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.badge-verified .badge-svg {
    animation: badgePulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(24, 119, 242, 0.5));
}

.badge-diamond .badge-svg {
    animation: badgeSpin 4s linear infinite, badgeShine 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(0, 212, 255, 0.5));
}

.badge-flame .badge-svg {
    animation: badgeFlame 0.5s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(255, 107, 53, 0.5));
}

.badge-rainbow .badge-svg {
    animation: badgeRainbow 3s linear infinite, badgePulse 2s ease-in-out infinite;
}

.badge-unique .badge-svg {
    animation: badgeWiggle 1s ease-in-out infinite, badgeShine 2s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(180, 74, 192, 0.5));
}

/* Level badges animations - SVG */
.animated-badge[data-badge-id="level_1"] .badge-svg { 
    animation: badgePulse 2s ease-in-out infinite; 
}
.animated-badge[data-badge-id="level_2"] .badge-svg { 
    animation: badgeBounce 1.5s ease-in-out infinite; 
}
.animated-badge[data-badge-id="level_3"] .badge-svg { 
    animation: badgeSpin 8s linear infinite; 
}
.animated-badge[data-badge-id="level_4"] .badge-svg { 
    animation: badgeShine 1.5s ease-in-out infinite; 
}
.animated-badge[data-badge-id="level_5"] .badge-svg { 
    animation: badgeGlow 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.5));
}
.animated-badge[data-badge-id="level_6"] .badge-svg { 
    animation: badgeShine 0.8s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(236, 72, 153, 0.5));
}
.animated-badge[data-badge-id="level_7"] .badge-svg { 
    animation: badgeGlow 1.5s ease-in-out infinite, badgeWiggle 2s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.6));
}

/* Badge Selector Styles */
.badge-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.badge-selector h4 {
    margin: 12px 0 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.badge-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.badge-option:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.badge-option.selected {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.badge-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.badge-option.locked:hover {
    transform: none;
}

.badge-option .badge-name {
    font-weight: 500;
    flex: 1;
}

.badge-option .badge-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge-option .badge-desc {
    font-size: 0.8rem;
    color: var(--accent-primary);
}

.badge-option .badge-locked {
    font-size: 0.75rem;
    color: var(--accent-warning);
    margin-left: auto;
}

/* Chat badge display */
.chat-sender .animated-badge,
.chat-name .animated-badge {
    margin-left: 4px;
}

/* Leaderboard badge display */
.leaderboard-name .animated-badge {
    margin-left: 4px;
}

/* Animated Badge Section in Profile */
.animated-badge-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    gap: 12px;
}

.current-badge-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-badge-display .badge-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* Admin Label in Chat */
.admin-label {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #DC2626, #991B1B);
    color: #FFD700;
    border-radius: 4px;
    vertical-align: middle;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    animation: adminGlow 2s ease-in-out infinite;
}

@keyframes adminGlow {
    0%, 100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 1px 8px rgba(220, 38, 38, 0.5), 0 0 12px rgba(255, 215, 0, 0.3); }
}

/* New Premium Badge Styles */
.badge-vip .badge-svg {
    animation: badgeShine 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.5));
}

.badge-creator .badge-svg {
    animation: badgePulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.5));
}

.badge-developer .badge-svg {
    animation: badgeBounce 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(16, 185, 129, 0.5));
}

.badge-supporter .badge-svg {
    animation: badgePulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 3px rgba(236, 72, 153, 0.5));
}

.badge-champion .badge-svg {
    animation: badgeGlow 1.5s ease-in-out infinite, badgeWiggle 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(220, 38, 38, 0.5));
}

/* ========================================
   Admin Edit User Modal Fixes
   ======================================== */

/* Make edit user form scrollable */
#editUserModal .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#editUserModal form {
    overflow-y: auto;
    max-height: calc(90vh - 70px);
    flex: 1;
}

#editUserModal .form-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    margin: 0;
    z-index: 10;
}

/* Premium badges grid - 2 columns */
.premium-badges-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1rem;
}

.premium-badges-checkboxes .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.premium-badges-checkboxes .checkbox-label span {
    white-space: nowrap;
}

/* ========================================
   Mobile Responsive Optimizations
   ======================================== */

/* Landing Page Mobile */
@media (max-width: 600px) {
    .landing-page {
        padding-top: 64px;
    }
    
    .landing-hero {
        padding: 2.5rem 1rem;
    }
    
    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
        margin-bottom: 1.5rem;
        padding: 0 0.5rem;
    }
    
    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        max-width: 280px;
    }
    
    .landing-section {
        padding: 2rem 1rem;
    }
    
    .section-title {
        font-size: 1.375rem;
        margin-bottom: 1.5rem;
    }
    
    /* Mission cards - stack on mobile */
    .mission-cards {
        gap: 1rem;
    }
    
    .mission-card {
        padding: 1.25rem;
    }
    
    .mission-icon {
        font-size: 2.5rem;
    }
    
    .mission-card h3 {
        font-size: 1.125rem;
    }
    
    .mission-card p {
        font-size: 0.9375rem;
    }
    
    /* Features grid - 2 columns on mobile */
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .feature-item {
        padding: 0.75rem;
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .feature-icon {
        font-size: 1.25rem;
    }
    
    .feature-item span:last-child {
        font-size: 0.8125rem;
    }
    
    /* Global stats */
    .global-stats {
        gap: 1.5rem;
    }
    
    .global-stat-value {
        font-size: 2rem;
    }
    
    .global-stat-label {
        font-size: 0.875rem;
    }
    
    /* Install section */
    .install-cards {
        gap: 1rem;
    }
    
    .install-card {
        padding: 1.25rem;
    }
    
    .install-icon {
        font-size: 2rem;
    }
    
    .install-card h3 {
        font-size: 1.125rem;
        margin-bottom: 0.75rem;
    }
    
    .install-steps {
        font-size: 0.9375rem;
        line-height: 1.6;
    }
    
    .btn-install {
        width: 100%;
        max-width: 280px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    /* CTA section */
    .landing-cta {
        padding: 2rem 1rem;
    }
    
    .landing-cta h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .hero-title {
        font-size: 1.75rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .feature-item {
        flex-direction: row;
        text-align: left;
    }
    
    .global-stats {
        flex-direction: column;
        gap: 1rem;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn, button {
        min-height: 44px;
    }
    
    .nav-item {
        min-height: 48px;
    }
    
    /* Disable hover effects on touch */
    .mission-card:hover,
    .install-card:hover,
    .feature-item:hover {
        transform: none;
    }
    
    /* Active states for touch feedback */
    .mission-card:active,
    .install-card:active {
        transform: scale(0.98);
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}

/* Safe area support for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .landing-page {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .chat-form {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
    
    .header {
        padding-left: calc(1.5rem + env(safe-area-inset-left));
        padding-right: calc(1.5rem + env(safe-area-inset-right));
    }
}

/* PWA standalone mode adjustments */
@media (display-mode: standalone) {
    .header {
        padding-top: env(safe-area-inset-top, 0);
    }
    
    .landing-page {
        padding-top: calc(64px + env(safe-area-inset-top, 0));
    }
}

/* Hero and CTA Button Layouts */
.hero-buttons,
.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.hero-buttons .btn,
.cta-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
}

@media (max-width: 600px) {
    .hero-buttons,
    .cta-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .hero-buttons .btn,
    .cta-buttons .btn {
        width: 100%;
        min-width: unset;
    }
}

/* Challenge Preview Modal */
.challenge-preview-modal {
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.challenge-preview-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.challenge-word-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.challenge-word-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.challenge-word-number {
    min-width: 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.challenge-word-speak {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

.challenge-word-text {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.challenge-word-vn {
    text-align: right;
}

.challenge-preview-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.challenge-preview-actions .btn:first-child {
    flex: 1;
}

.challenge-preview-actions .btn:last-child {
    flex: 2;
}

/* Mobile fullscreen challenge preview */
@media (max-width: 600px) {
    .challenge-preview-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        transform: none !important;
    }
    
    .challenge-preview-body {
        padding: 1rem;
    }
    
    .challenge-word-row {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .challenge-word-text {
        font-size: 0.9rem;
    }
    
    .challenge-word-vn {
        max-width: 45%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .challenge-preview-actions {
        flex-direction: column;
    }
    
    .challenge-preview-actions .btn:first-child,
    .challenge-preview-actions .btn:last-child {
        flex: 1;
        width: 100%;
    }
}

/* ========================================
   NATIVE-LIKE MOBILE EXPERIENCE
   ======================================== */

/* Disable text selection on interactive elements for app-like feel */
@media (max-width: 768px) {
    .btn, .nav-item, .topic-item, .word-item, .tab-btn, 
    .icon-option, .color-option, .message-item, .challenge-card {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Touch feedback - Active state animation */
    .btn:active, .nav-item:active, .topic-item:active, 
    .word-item:active, .tab-btn:active, .message-item:active,
    .challenge-card:active, .card:active {
        transform: scale(0.97);
        opacity: 0.8;
    }
    
    /* Smooth momentum scrolling */
    .main-content, .sidebar, .modal-content, .chat-messages,
    .private-chat-messages, .word-list, .topics-list, .challenges-list {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
    }
    
    /* Prevent pull-to-refresh on PWA */
    body {
        overscroll-behavior-y: contain;
    }
    
    /* Minimum tap target size (44x44 as per Apple guidelines) */
    .btn, .nav-item, .btn-icon, .icon-option, .color-option,
    .tab-btn, .topic-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Smaller btn-icon (theme toggle, etc.) */
    .btn-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }
    
    /* Larger touch targets for form elements */
    input, select, textarea {
        min-height: 48px;
        font-size: 16px !important; /* Prevent iOS zoom on focus */
    }
    
    /* Header improvements */
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(var(--bg-secondary-rgb, 30, 41, 59), 0.9);
    }
    
    /* Card press effect */
    .stat-card, .challenge-card, .word-item {
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    
    .stat-card:active, .challenge-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Smoother modal animations */
    .modal {
        transition: opacity 0.25s ease;
    }
    
    .modal-content {
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
        transform: translateY(20px);
    }
    
    .modal.active .modal-content {
        transform: translateY(0);
    }
    
    /* Fixed bottom action buttons in modals */
    .modal .form-actions {
        position: sticky;
        bottom: 0;
        background: var(--bg-secondary);
        padding: 1rem;
        margin: 0 -1.5rem -1.5rem;
        border-top: 1px solid var(--border-color);
    }
    
    
    /* Swipe hint animation */
    @keyframes swipeHint {
        0%, 100% { transform: translateX(0); }
        50% { transform: translateX(-10px); }
    }
    
    /* Loading skeleton animation */
    @keyframes shimmer {
        0% { background-position: -200% 0; }
        100% { background-position: 200% 0; }
    }
    
    .skeleton {
        background: linear-gradient(90deg, 
            var(--bg-tertiary) 25%, 
            var(--bg-secondary) 50%, 
            var(--bg-tertiary) 75%);
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    .sidebar {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .header {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    .modal .form-actions {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .main-content {
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
    }
}

/* Haptic-like visual feedback for important actions */
@keyframes successPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.success-pulse {
    animation: successPulse 0.5s ease;
}

.error-shake {
    animation: errorShake 0.5s ease;
}

/* Improved toast notifications for mobile */
@media (max-width: 768px) {
    .toast-container {
        bottom: 100px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 90vw;
    }
    
    .toast {
        border-radius: var(--radius-lg);
        box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile fixes for private chat and profile modal */
@media (max-width: 768px) {
    /* Private chat - ensure input is visible at bottom */
    #inboxChatView {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    #inboxChatView .chat-messages,
    .private-chat-messages {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }
    
    #inboxChatView .chat-input-container,
    .private-chat-form,
    #privateForm {
        position: sticky;
        bottom: 0;
        background: var(--bg-secondary);
        padding: 0.75rem;
        border-top: 1px solid var(--border-color);
        z-index: 10;
        flex-shrink: 0;
    }
    
    #privateForm input[type="text"] {
        min-height: 40px;
    }
    
    /* Profile modal - fix button layout */
    #profileModal .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }
    
    #profileModal .profile-content {
        padding-bottom: 80px;
    }
    
    #profileModal .form-actions,
    #profileModal .profile-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        padding: 1rem;
        display: flex;
        gap: 0.75rem;
        border-top: 1px solid var(--border-color);
        z-index: 10;
        margin: 0;
    }
    
    #profileModal .btn {
        flex: 1;
        min-height: 44px;
        height: auto;
        padding: 0.75rem 1rem;
    }
    
    /* Reset btn-icon min-height inside profile modal */
    #profileModal .btn-icon {
        min-height: unset;
        height: 36px;
    }
    
    /* Fix sticky form-actions not to affect profile modal */
    #profileModal .modal .form-actions {
        position: fixed;
        margin: 0;
    }
    
    /* Smaller theme toggle button */
    .theme-toggle {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        padding: 0.25rem !important;
        font-size: 1rem !important;
    }
    
    .theme-toggle .theme-icon-dark,
    .theme-toggle .theme-icon-light {
        font-size: 1rem;
    }
    
    /* Disable hover effects on mobile to prevent double-tap */
    .word-item:hover,
    .topic-item:hover,
    .word-card:hover,
    .vocab-item:hover {
        transform: none !important;
        box-shadow: inherit !important;
        border-color: inherit !important;
        background: inherit !important;
    }
    
    /* Only apply active state (actual touch) */
    .word-item:active,
    .topic-item:active,
    .word-card:active,
    .vocab-item:active {
        transform: scale(0.98) !important;
        opacity: 0.9;
    }
    
    /* Dashboard user panel - vertical box layout on mobile */
    .dashboard-user,
    .current-user-panel,
    .user-rank-panel,
    .my-rank {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .dashboard-user .user-avatar,
    .current-user-panel .user-avatar,
    .my-rank .user-avatar {
        width: 64px !important;
        height: 64px !important;
        margin: 0 auto 0.5rem !important;
    }
    
    .dashboard-user .user-info,
    .current-user-panel .user-info,
    .my-rank .user-info {
        text-align: center;
        width: 100%;
    }
    
    .dashboard-user .user-stats,
    .current-user-panel .user-stats,
    .my-rank .user-stats {
        justify-content: center;
        flex-wrap: wrap;
        gap: 1rem;
        width: 100%;
    }
}

/* Touch device specific - disable hover completely */
@media (hover: none) and (pointer: coarse) {
    .word-item:hover,
    .topic-item:hover,
    .nav-item:hover,
    .btn:hover,
    .card:hover {
        transform: none !important;
        box-shadow: inherit !important;
        border-color: inherit !important;
    }
}

/* Mobile leaderboard/user panel - box layout */
@media (max-width: 768px) {
    /* Leaderboard items - vertical layout */
    .leaderboard-item,
    .online-user {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center;
        padding: 1rem !important;
        gap: 0.5rem !important;
    }
    
    .leaderboard-item .leaderboard-avatar,
    .online-user img {
        width: 48px !important;
        height: 48px !important;
        margin: 0 auto !important;
    }
    
    .leaderboard-item .leaderboard-info,
    .leaderboard-item .leaderboard-name {
        text-align: center;
        width: 100%;
    }
    
    .leaderboard-item .leaderboard-rank {
        margin-bottom: 0.25rem;
    }
    
    /* Current user highlight */
    .leaderboard-item.current-user,
    .online-user.current-user {
        background: var(--gradient-primary) !important;
        border-radius: var(--radius-md);
    }
    
    /* Admin table - card layout on mobile */
    .admin-table {
        display: block;
    }
    
    .admin-table thead {
        display: none; /* Hide header row */
    }
    
    .admin-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .admin-table tr {
        display: flex;
        flex-direction: column;
        align-items: center;
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        padding: 1rem;
        gap: 0.5rem;
        text-align: center;
        border: 1px solid var(--border-color);
    }
    
    .admin-table td {
        display: block;
        width: 100%;
        padding: 0.25rem 0;
        border: none !important;
    }
    
    .admin-table td:before {
        display: none; /* No labels needed, content is self-explanatory */
    }
    
    .admin-table .admin-avatar {
        width: 64px !important;
        height: 64px !important;
        margin: 0 auto;
        border-radius: 50%;
    }
    
    .admin-table .admin-actions {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
    }
}
