/* --- CSS VARIABLES (iOS DARK THEME) --- */
:root {
    /* Backgrounds */
    --bg-dark: #000000;
    --bg-gradient-start: #000000;
    --bg-gradient-end: #1c1c1e;
    
    /* iOS Glassmorphism - Enhanced */
    --glass-surface: rgba(255, 255, 255, 0.08); /* Much lighter, relying on blur */
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-highlight: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    /* iOS System Colors */
    --primary: #0A84FF; /* iOS System Blue Dark Mode */
    --primary-glow: rgba(10, 132, 255, 0.4);
    --secondary: #FF375F; /* iOS System Pink Dark Mode */
    --accent: #30D158; /* iOS System Green Dark Mode */
    --warning: #FF9F0A; /* iOS System Orange Dark Mode */
    --danger: #FF453A; /* iOS System Red Dark Mode */
    --purple: #BF5AF2; /* iOS System Purple Dark Mode */
    
    /* Text Colors */
    --text-main: #FFFFFF;
    --text-muted: #EBEBF5; /* Lighter gray for better contrast on glass */
    --text-dim: #8E8E93;
    
    /* Neon Aliases (mapped to iOS colors) */
    --neon-blue: var(--primary);
    --neon-purple: var(--purple);
    --neon-green: var(--accent);
    --neon-orange: var(--warning);
    --neon-red: var(--danger);
    --neon-yellow: #FFD60A;
    
    /* Spacing & Radius */
    --radius-xl: 28px; /* iOS large radius */
    --radius-lg: 20px; /* iOS medium radius */
    --radius-md: 14px;
    --radius-sm: 8px;

    /* Card Variables - Glassy */
    --card-bg-front: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.03) 100%);
    --card-bg-back: linear-gradient(135deg, #5e5ce6 0%, #4744ca 100%);
}

/* --- RESET & BASE --- */
* {box-sizing: border-box;-webkit-tap-highlight-color: transparent; user-select: none; -webkit-font-smoothing: antialiased;}

html { visibility: visible; opacity: 1; height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0; padding: 0;
    height: 100dvh;
    overflow: hidden;
    display: flex; flex-direction: column;
    position: relative;
    background: #000;
}

/* --- BACKGROUND ANIMATION --- */
.aurora-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; overflow: hidden;
    pointer-events: none;
    background: radial-gradient(circle at 50% 0%, #2c2c2e 0%, #000 100%);
}
.orb {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4;
    animation: float 20s infinite ease-in-out;
}
.orb-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; left: -50px; animation-delay: 0s; }
.orb-2 { width: 350px; height: 350px; background: var(--purple); bottom: 10%; right: -100px; animation-delay: -8s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(20px, 40px) scale(1.1); }
}

/* --- UTILITIES --- */
.hidden { display: none !important; }
.w-full { width: 100%; }
.fade-in { animation: fadeIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.btn {
    border: none; cursor: pointer; font-family: inherit; font-weight: 600;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
    border-radius: var(--radius-md);
    color: white;
}
.btn:active { transform: scale(0.95); opacity: 0.8; }

/* --- HEADER --- */
header {
    padding: 16px 20px; z-index: 10; flex-shrink: 0;
    display: flex; flex-direction: column; gap: 12px;
    background: transparent;
}
.hud-top { display: flex; justify-content: space-between; align-items: center; }
.hud-group { display: flex; gap: 10px; align-items: center; }

.hud-badge {
    background: rgba(255, 255, 255, 0.1);
    border: 0.5px solid rgba(255, 255, 255, 0.2);
    padding: 0 12px;
    border-radius: 100px;
    font-size: 0.9rem; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    height: 38px;
    color: var(--text-main);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.streak-badge svg { color: var(--warning); }
.currency-badge svg { color: var(--accent); }
.level-badge svg { color: var(--primary); }

.sync-status {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.1); border: 0.5px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted); transition: all 0.3s;
    cursor: pointer;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.sync-active { color: var(--primary); animation: pulseSync 2s infinite; }
.sync-done { color: var(--accent); }
.sync-error { color: var(--danger); border-color: var(--danger); }
@keyframes pulseSync { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

.xp-track {
    width: 100%; height: 6px; background: rgba(255,255,255,0.15);
    border-radius: 100px; overflow: hidden; position: relative;
}
.xp-fill {
    height: 100%; background: var(--primary);
    width: 0%; transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-radius: 100px;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* --- MAIN CONTENT --- */
main {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 10px 20px 120px 20px;
    scrollbar-width: none;
}
main::-webkit-scrollbar { display: none; }

.glass-panel {
    background: var(--glass-surface);
    backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255, 255, 255, 0.25); /* Highlight top edge */
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    color: var(--text-main);
    position: relative;
    overflow: hidden;
}
/* Subtle sheen effect */
.glass-panel::before {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(120deg, rgba(255,255,255,0.05) 0%, transparent 40%);
    pointer-events: none;
}

/* --- LEARN TAB --- */
.page-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 2px; font-weight: 600; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.page-header h1 { margin: 0; font-size: 2.1rem; font-weight: 700; letter-spacing: 0.3px; color: white; }
.progress-text { font-family: -apple-system, monospace; color: var(--primary); font-weight: 600; font-size: 0.95rem; background: rgba(10, 132, 255, 0.15); padding: 6px 12px; border-radius: 100px; }

.flashcard-container { perspective: 1500px; height: 370px; width: 100%; cursor: pointer; margin-bottom: 24px; }
.flashcard {
    position: relative; width: 100%; height: 100%;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}
.flashcard.flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute; width: 100%; height: 100%; 
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: var(--radius-xl);
    background: var(--card-bg-front);
    border: 0.5px solid var(--glass-border);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 32px; text-align: center;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.6);
}
.card-back { 
    transform: rotateY(180deg); 
    background: var(--card-bg-back); 
    border-color: rgba(255,255,255,0.1);
}

.word-lg { font-size: 3rem; font-weight: 700; margin-bottom: 12px; color: white; letter-spacing: -0.5px; }
.word-context { font-size: 1.1rem; color: var(--text-muted); font-style: italic; margin-bottom: 32px; line-height: 1.5; }
.word-meaning { font-size: 2.2rem; font-weight: 700; color: white; }

.card-actions { display: flex; gap: 20px; z-index: 5; margin-top: 24px; }
.action-btn {
    width: 50px; height: 50px; border-radius: 50%;
    background: rgba(255,255,255,0.1); color: white;
    border: none;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}
.action-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.mic-active { background: var(--danger) !important; animation: pulse 1.5s infinite; }

.vote-container { display: flex; gap: 16px; margin-top: 20px; }
.vote-btn {
    flex: 1; padding: 18px; border-radius: var(--radius-lg); font-size: 1rem;
    color: white; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: none;
}
.vote-fail { background: rgba(255, 69, 58, 0.15); color: var(--danger); }
.vote-fail:active { background: rgba(255, 69, 58, 0.25); }
.vote-success { background: rgba(48, 209, 88, 0.15); color: var(--accent); }
.vote-success:active { background: rgba(48, 209, 88, 0.25); }

/* --- QUESTS & LISTS --- */
.quest-card { 
    display: flex; flex-direction: column; gap: 10px; padding: 16px; margin-bottom: 12px; 
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    transition: transform 0.2s;
    backdrop-filter: blur(10px);
}
.quest-card:active { transform: scale(0.98); background: rgba(255, 255, 255, 0.1); }
.quest-card.completed { background: rgba(48, 209, 88, 0.1); border-color: rgba(48, 209, 88, 0.3); }
.quest-row { display: flex; justify-content: space-between; align-items: center; }
.quest-title { font-weight: 600; font-size: 1rem; color: var(--text-main); }
.quest-reward { 
    background: rgba(255, 159, 10, 0.2); color: var(--warning); 
    padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; 
}

/* --- QUIZ & GAMES --- */
.quiz-opt {
    width: 100%; padding: 18px; margin-top: 10px;
    background: rgba(255, 255, 255, 0.08); border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); color: var(--text-main); text-align: left; 
    transition: all 0.2s; font-weight: 500; font-size: 1rem;
    backdrop-filter: blur(10px);
}
.quiz-opt:active { background: rgba(255, 255, 255, 0.15); transform: scale(0.99); }

#games-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
#games-menu .btn {
    flex-direction: column; gap: 12px; padding: 20px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
}
#games-menu .btn:active { background: rgba(255, 255, 255, 0.1); }

/* --- SHOP --- */
.shop-item { 
    display: flex; justify-content: space-between; align-items: center; padding: 16px; margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.05); border-radius: var(--radius-lg); border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}
.item-icon { 
    width: 48px; height: 48px; background: rgba(255,255,255,0.1); border-radius: 12px; 
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem; 
}
.price-btn { 
    background: rgba(255,255,255,0.15); color: var(--text-main); padding: 8px 16px; 
    border-radius: 100px; font-weight: 600; font-size: 0.9rem;
}

/* --- NAVIGATION DOCK (iOS Style) --- */
.nav-dock-container { 
    position: fixed; bottom: 30px; left: 0; width: 100%; 
    display: flex; justify-content: center; pointer-events: none; z-index: 50; 
}
.nav-dock {
    pointer-events: auto; background: rgba(30, 30, 30, 0.7);
    backdrop-filter: blur(40px) saturate(180%); -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid rgba(255,255,255,0.15); padding: 0 24px; height: 68px;
    border-radius: 34px; display: flex; gap: 28px; align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.nav-item { 
    background: none; border: none; padding: 0; cursor: pointer; 
    color: var(--text-muted); position: relative; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    transition: all 0.3s; gap: 0;
}
.nav-item svg { width: 24px; height: 24px; stroke-width: 2.2; transition: all 0.3s; }
.nav-label { 
    font-size: 0; opacity: 0; font-weight: 600; letter-spacing: 0.3px; 
    transition: all 0.3s; height: 0; overflow: hidden;
}
.nav-item.active { color: var(--primary); gap: 4px; }
.nav-item.active svg { fill: rgba(10, 132, 255, 0.15); transform: translateY(-2px); }
.nav-item.active .nav-label { font-size: 0.7rem; opacity: 1; height: auto; }

/* --- TOAST --- */
#toast {
    position: fixed; top: 100px; left: 50%; transform: translateX(-50%) translateY(-20px) scale(0.9);
    background: rgba(28, 28, 30, 0.9); color: white; padding: 14px 24px;
    border-radius: 100px; z-index: 200; font-weight: 600; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); border: 0.5px solid var(--glass-border);
    opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex; align-items: center; gap: 10px; font-size: 0.9rem;
    backdrop-filter: blur(20px);
    width: max-content;
    max-width: 90%;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

#confetti-canvas {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 150;
}

/* --- MODAL (iOS Sheet Style) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent; backdrop-filter: blur(5px);
    z-index: 300; display: flex; align-items: flex-end; justify-content: center;
    padding: 0; opacity: 1; transition: opacity 0.3s;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.modal-content {
    width: 100%; max-width: 600px;
    transform: translateY(0); transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    background: rgba(30, 30, 30, 0.6); /* More transparent for glass effect */
    backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-top-left-radius: 24px; border-top-right-radius: 24px; overflow: hidden;
    padding-bottom: 40px; /* Safe area */
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}
.modal-overlay.hidden .modal-content { transform: translateY(100%); }

/* --- PROFILE & CHARTS --- */
.progress-ring-container { position: relative; width: 140px; height: 140px; margin: 0 auto 24px; }
.progress-ring-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.progress-ring-circle-bg { fill: transparent; stroke: rgba(255,255,255,0.08); stroke-width: 10; }
.progress-ring-circle {
    fill: transparent; stroke: var(--accent); stroke-width: 10;
    stroke-dasharray: 339.292; stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.2, 0.8, 0.2, 1); stroke-linecap: round;
}
.progress-ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }

.chart-container {
    display: flex; align-items: stretch; justify-content: space-between;
    height: 180px; margin-top: 24px; padding-bottom: 12px;
    border-bottom: 0.5px solid var(--glass-border);
}
.chart-bar-wrapper { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; flex: 1; height: 100%; }
.chart-bar {
    width: 8px; background: var(--primary); border-radius: 100px;
    transition: height 1s cubic-bezier(0.2, 0.8, 0.2, 1); min-height: 6px;
    opacity: 0.8;
}
.chart-bar:hover { opacity: 1; transform: scaleX(1.5); }

.google-btn {
    width: 100%; padding: 16px; 
    background: white; color: #000; 
    border-radius: var(--radius-lg); font-weight: 600; 
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-bottom: 20px; cursor: pointer; border: none;
    transition: transform 0.2s;
    font-size: 1rem;
}
.google-btn:active { transform: scale(0.98); }
/* --- DUEL & CHALLENGE UI --- */
#duel-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10;
    display: flex; flex-direction: column;
}

.duel-header {
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 30px; padding: 20px; 
    background: rgba(255, 255, 255, 0.05); 
    border-radius: var(--radius-lg); 
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
}

.duel-player-info {
    text-align: center; width: 40%;
}

.duel-vs-badge {
    font-weight: 900; color: var(--text-muted); font-size: 1.2rem; opacity: 0.5;
    font-style: italic;
}

.duel-name {
    font-size: 0.9rem; font-weight: 700; margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.duel-bar-track {
    height: 8px; background: rgba(255,255,255,0.1);
    border-radius: 100px; overflow: hidden;
}

.duel-bar-fill {
    height: 100%; border-radius: 100px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Result Screen Enhancements (Mobile Optimized) */
.result-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: transparent; /* Removed overlay */
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    opacity: 1; transition: opacity 0.3s;
}
.result-screen.hidden { opacity: 0; pointer-events: none; }

.result-content {
    width: 100%; max-width: 400px;
    display: flex; flex-direction: column; gap: 24px;
    animation: slideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.result-header { text-align: center; }
.result-header h2 { font-size: 2rem; margin: 0; background: linear-gradient(to right, #fff, #c4b5fd); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.result-icon-container {
    position: relative; width: 100px; height: 100px; margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center;
}
.result-icon { font-size: 4rem; z-index: 2; position: relative; animation: bounce 2s infinite; }
.result-glow {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 120px; height: 120px; background: radial-gradient(circle, rgba(139,92,246,0.4) 0%, transparent 70%);
    filter: blur(20px); animation: pulse 3s infinite;
}

.result-score-card {
    padding: 30px; text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
}
.score-label { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 2px; font-weight: 600; margin-bottom: 8px; }
.score-value { 
    font-size: 4.5rem; font-weight: 800; line-height: 1;
    background: linear-gradient(180deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.result-rewards { display: flex; flex-direction: column; gap: 10px; }
.reward-item {
    display: flex; align-items: center; gap: 16px; padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}
.reward-icon { 
    width: 44px; height: 44px; border-radius: 12px; 
    background: rgba(255, 255, 255, 0.05); display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.reward-info { display: flex; flex-direction: column; flex: 1; }
.reward-label { font-size: 0.85rem; color: var(--text-muted); }
.reward-amount { font-size: 1.2rem; font-weight: 700; color: white; }

.result-actions .btn-primary {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white; padding: 18px;
    font-size: 1.1rem; border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    gap: 10px; width: 100%;
    transition: all 0.3s ease;
    margin-top: 20px;
}
.result-actions .btn-primary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.3);
}
.result-actions .btn-primary:active { transform: scale(0.98); }

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.result-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px; margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

.result-row.winner {
    background: rgba(48, 209, 88, 0.15);
    border-color: rgba(48, 209, 88, 0.3);
}

.result-row.loser {
    background: rgba(255, 69, 58, 0.15);
    border-color: rgba(255, 69, 58, 0.3);
}

/* --- CENTERED MODAL (Challenge) --- */
.center-modal {
    align-items: center !important;
    padding: 20px;
}

.center-modal .modal-content {
    border-radius: var(--radius-xl) !important;
    padding: 30px !important;
    max-width: 340px;
    background: rgba(25, 25, 25, 0.65) !important;
    backdrop-filter: blur(50px) saturate(180%);
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden.center-modal .modal-content {
    transform: scale(0.9);
    opacity: 0;
}

/* --- REFACTORED STYLES --- */

/* Level Up Modal */
/* Level Up Modal */
.level-up-content { 
    text-align: center; padding: 40px; 
    width: 90%; max-width: 400px;
    background: rgba(30, 30, 30, 0.8);
    backdrop-filter: blur(30px);
    border-radius: 30px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    /* Ensure it's not stuck at bottom if parent is flex */
    margin: auto; 
}
.level-up-emoji { font-size: 4rem; margin-bottom: 10px; }
.level-up-title { font-size: 2.5rem; margin: 0; color: var(--neon-purple); text-shadow: 0 0 20px rgba(139,92,246,0.5); }
.level-up-subtitle { font-size: 1.2rem; margin: 20px 0; color: var(--text-muted); }
.new-level-display { 
    font-size: 5rem; font-weight: 800; line-height: 1; margin-bottom: 30px; 
    background: linear-gradient(to bottom, #fff, #a78bfa); 
    -webkit-background-clip: text; background-clip: text; 
    -webkit-text-fill-color: transparent; 
}
.level-up-btn { padding: 15px; background: var(--neon-purple); color: white; border-radius: var(--radius-lg); font-size: 1.1rem; }

/* Modals (Favs, Dict) */
.modal-content-full { height: 80vh; display: flex; flex-direction: column; padding: 0; }
.modal-header { padding: 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; }
.modal-title-text { margin: 0; font-size: 1.5rem; }
.modal-close-btn { background: transparent; font-size: 1.5rem; }
.modal-body-scroll { flex: 1; overflow-y: auto; padding: 20px; }

/* Dictionary Specific */
.dict-header { padding: 20px; border-bottom: 1px solid var(--glass-border); }
.dict-header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.dict-search-input { 
    width: 100%; padding: 12px; border-radius: 12px; 
    background: rgba(255,255,255,0.1); border: 1px solid var(--glass-border); 
    color: white; outline: none; 
}

/* Header & HUD */
.hud-badge-level { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; border: 1px solid rgba(139, 92, 246, 0.3); }
.header-right { display: flex; gap: 10px; align-items: center; }
.page-header-title { margin: 0; font-size: 1.8rem; font-weight: 300; }

/* Flashcard */
.flashcard-reveal-text { margin-top: auto; font-size: 0.75rem; letter-spacing: 2px; font-weight: 600; text-transform: uppercase; opacity: 0.6; }

/* Duel */
.duel-question-area { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.duel-name-user { color: var(--neon-blue); }
.duel-name-opponent { color: var(--neon-red); }
.duel-bar-user { width: 0%; background: var(--neon-blue); box-shadow: 0 0 10px var(--neon-blue); }
.duel-bar-opponent { width: 0%; background: var(--neon-red); box-shadow: 0 0 10px var(--neon-red); }

/* Games Menu */
.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.game-btn-content { padding: 20px; text-align: center; }
.game-btn-icon { font-size: 2rem; }
.game-btn-title { font-weight: 700; }
.game-btn-sub { font-size: 0.8rem; color: var(--text-muted); }
.btn-challenge { 
    border: 1px solid rgba(255, 255, 255, 0.15); 
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    display: flex; align-items: center; justify-content: center;
    aspect-ratio: 1;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}
.btn-challenge::after {
    content: '';
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.4) 0%, transparent 70%);
    opacity: 0; transition: opacity 0.4s;
    z-index: -1;
}
.btn-challenge:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 20px 50px rgba(139, 92, 246, 0.3);
}
.btn-challenge:hover::after { opacity: 1; }

.btn-challenge .game-btn-icon { 
    color: white; 
    font-size: 3.5rem; 
    filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.6));
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-challenge:hover .game-btn-icon {
    transform: scale(1.15) rotate(10deg);
    color: #fff;
    filter: drop-shadow(0 0 30px rgba(139, 92, 246, 1));
}
.btn-span-2 { grid-column: span 2; }

/* Quiz Play Area */
.quiz-play-area { padding: 20px; text-align: center; }
.quiz-header-info { display: flex; justify-content: space-between; margin-bottom: 20px; color: var(--text-muted); font-size: 0.9rem; }
.quiz-timer-text { color: var(--neon-red); font-weight: bold; }
.quiz-word { font-size: 2.5rem; font-weight: 800; margin-bottom: 30px; }
.quiz-options-grid { display: grid; gap: 10px; }
.quiz-options-grid > button { text-align: center; }
/* Match & Hangman Games */
.match-header { display: flex; justify-content: space-between; margin-bottom: 15px; }
.btn-back { background: rgba(255,255,255,0.1); padding: 5px 15px; border-radius: 10px; }
.match-score-text { font-weight: 800; color: var(--neon-yellow); }
.match-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hangman-area { padding: 20px; text-align: center; }
.hangman-lives-text { color: var(--neon-red); }
.hangman-word-display { font-size: 2rem; letter-spacing: 5px; margin: 30px 0; font-family: monospace; font-weight: 700; }
.hangman-hint { color: var(--text-muted); margin-bottom: 30px; font-style: italic; }
.hangman-keyboard { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }

/* Shop */
.shop-section-header { color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; margin-bottom: 10px; }
.shop-section-header-margin { margin: 30px 0 10px 0; }
.active-buffs-area { margin-bottom: 20px; }
.shop-item-content { display: flex; gap: 15px; align-items: center; }
.shop-icon-blue { color: var(--neon-blue); }
.shop-icon-purple { color: var(--neon-purple); }
.shop-item-title { font-weight: 700; font-size: 1.1rem; }
.shop-item-desc { font-size: 0.9rem; color: var(--text-muted); }

/* Profile */
.profile-header-center { text-align: center; margin-bottom: 30px; margin-top: 20px; }
.mastery-pct-text { font-size: 1.5rem; font-weight: 800; color: var(--neon-green); }
.mastery-label { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 1px; }
.profile-title { margin: 0; font-size: 1.5rem; }
.career-badge {
    color: var(--neon-blue);
    font-family: -apple-system, monospace;
    margin-top: 12px;
    font-size: 0.9rem;
    background: rgba(10, 132, 255, 0.15);
    border: 1px solid rgba(10, 132, 255, 0.3);
    padding: 8px 16px;
    border-radius: 100px;
    display: inline-block;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(10, 132, 255, 0.1);
}
.user-email-text { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; opacity: 0; }
.profile-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px; }
.stat-panel { padding: 20px; text-align: center; }
.stat-value-blue { font-size: 1.8rem; font-weight: 800; color: var(--neon-blue); }
.stat-value-green { font-size: 1.8rem; font-weight: 800; color: var(--neon-green); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.chart-header { font-weight: 300; margin-bottom: 15px; }
.chart-panel { padding: 15px; margin-bottom: 30px; }
.profile-action-btn { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.achievements-header { font-weight: 300; border-bottom: 1px solid var(--glass-border); padding-bottom: 10px; margin-bottom: 15px; }
.achievements-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 30px; }
.btn-reset-data { 
    padding: 15px; background: rgba(255, 69, 58, 0.15); color: var(--danger); 
    border: 1px solid rgba(255, 69, 58, 0.3); border-radius: 16px; margin-top: 20px; 
}

/* Leaderboard */
.leaderboard-loading { padding: 20px; text-align: center; color: var(--text-muted); }
.leaderboard-footer { margin-top: 20px; text-align: center; font-size: 0.8rem; color: var(--text-muted); }

.leaderboard-row {
    display: flex; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s;
}
.leaderboard-row.me { background: rgba(139, 92, 246, 0.1); }

.leaderboard-rank {
    font-weight: 700; width: 24px; text-align: center;
    color: var(--text-muted); font-size: 1rem;
    margin-right: 12px;
}
.leaderboard-rank.rank-1 { color: #FFD700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); font-size: 1.2rem; }
.leaderboard-rank.rank-2 { color: #C0C0C0; text-shadow: 0 0 10px rgba(192, 192, 192, 0.5); font-size: 1.1rem; }
.leaderboard-rank.rank-3 { color: #CD7F32; text-shadow: 0 0 10px rgba(205, 127, 50, 0.5); font-size: 1.1rem; }

.leaderboard-user-info { flex: 1; overflow: hidden; }
.leaderboard-name {
    font-weight: 600; color: white;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 0.95rem;
}
.leaderboard-name.me-text { color: var(--neon-blue); }
.leaderboard-lvl { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.leaderboard-row-right { display: flex; align-items: center; gap: 8px; }
.leaderboard-xp { font-weight: 800; color: var(--neon-green); font-size: 0.9rem; white-space: nowrap; }

.btn-mini-challenge {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: white;
    font-size: 1rem; /* Emoji size */
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.btn-mini-challenge:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.2);
}

.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.online {
    background: var(--neon-green);
    box-shadow: 0 0 6px var(--neon-green);
    animation: pulseDot 2s infinite;
}
.status-dot.offline {
    background: var(--neon-red);
    box-shadow: 0 0 4px var(--neon-red);
    opacity: 0.5;
}
@keyframes pulseDot {
    0% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.6; transform: scale(0.9); }
}

/* --- JS DYNAMIC ELEMENTS --- */

/* Match Game */
.match-card-btn {
    padding: 20px 10px; font-size: 0.9rem; font-weight: 700;
    min-height: 80px; display: flex; align-items: center; justify-content: center;
}
.match-card-selected {
    background: rgba(255,255,255,0.2) !important;
    border: 1px solid var(--neon-blue) !important;
}
.match-card-matched {
    background: rgba(34, 197, 94, 0.2) !important;
    border: 1px solid var(--neon-green) !important;
    opacity: 0.5;
}

/* Hangman Game */
.hangman-key-btn {
    width: 36px; height: 40px; margin: 2px;
    background: rgba(255,255,255,0.1); border-radius: 8px;
}
.hangman-key-disabled { opacity: 0.3; }
.hangman-key-correct { background: var(--neon-green) !important; color: black !important; }
.hangman-key-wrong { background: var(--neon-red) !important; }

/* Listening Game */
.listening-btn {
    background: var(--neon-blue); width: 80px; height: 80px; 
    border-radius: 50%; font-size: 2rem;
}

/* Quiz Options */
.quiz-opt-correct {
    background: rgba(16, 185, 129, 0.4) !important;
    border-color: var(--neon-green) !important;
}
.quiz-opt-wrong {
    background: rgba(239, 68, 68, 0.4) !important;
    border-color: var(--neon-red) !important;
}

/* Duel Result */
.duel-result-table { 
padding: 15px;
margin-bottom: 0;
margin-top: 100px; }
.duel-result-header { color: var(--text-muted); margin-bottom: 15px; font-weight: 600; font-size: 0.9rem; letter-spacing: 1px; }
.font-bold { font-weight: 700; }
.btn-rematch {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid var(--neon-purple);
    color: var(--neon-purple);
    margin-top: 10px; padding: 15px;
    border-radius: var(--radius-lg);
    font-weight: 700;
}

/* Multiplayer Challenge Modal */
.challenge-modal-content { text-align: center; border: 1px solid rgba(139, 92, 246, 0.3); }
.challenge-icon-container {
    width: 80px; height: 80px; background: rgba(139, 92, 246, 0.2);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px auto; box-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}
.challenge-icon { font-size: 3rem; }
.challenge-title { color: white; font-size: 1.6rem; margin: 0 0 10px 0; font-weight: 700; }
.challenge-msg { margin: 10px 0 25px 0; font-size: 1.1rem; line-height: 1.5; color: var(--text-muted); }
.challenge-bet-badge {
    background: rgba(255, 214, 10, 0.1); border: 1px solid rgba(255, 214, 10, 0.3);
    padding: 12px 20px; border-radius: 100px; display: inline-flex; align-items: center;
    gap: 8px; margin-bottom: 30px;
}
.bet-icon { font-size: 1.2rem; }
.bet-text { font-size: 1rem; color: var(--neon-yellow); font-weight: 700; }
.challenge-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.btn-reject {
    background: rgba(255, 69, 58, 0.15); color: var(--danger);
    padding: 16px; border: 1px solid rgba(255, 69, 58, 0.3);
    border-radius: var(--radius-lg); font-weight: 700;
}
.btn-accept {
    background: var(--neon-green); color: black; font-weight: bold;
    padding: 16px; box-shadow: 0 0 20px rgba(48, 209, 88, 0.4);
    border-radius: var(--radius-lg);
}
.sender-name-bold { color: white; font-weight: bold; }

/* --- SWITCH TOGGLE --- */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Range Slider */
input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  margin-top: -8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

input[type=range]:focus {
  outline: none;
}
