/* =========================================
   1. CSS VARIABLES (Default Midnight Theme)
   ========================================= */
:root {
    /* Core Layout Colors */
    --bg-color: #0f172a;       
    --bg-gradient-top: #1e293b;
    --panel-color: #1e293b;    
    --panel-dark: #0b1120;       
    --panel-hover: #334155;      
    
    /* Text Colors */
    --text-color: #f8fafc;     
    --text-secondary: #cbd5e1;   
    --text-muted: #94a3b8;
    --text-tertiary: #64748b;    
    --text-dark: #000000;
    --text-light: #ffffff;

    /* Borders, Overlays & Shadows */
    --border-color: #334155;   
    --border-light: rgba(255, 255, 255, 0.05);
    --border-medium: rgba(255, 255, 255, 0.1);
    --overlay-bg: rgba(15, 23, 42, 0.75);
    --overlay-light: rgba(15, 23, 42, 0.4);
    --glass-bg: rgba(30, 41, 59, 0.9);
    --shadow-base: rgba(0, 0, 0, 0.5);
    --shadow-light: rgba(0, 0, 0, 0.3);

    /* Brand Colors */
    --primary-light: #7dd3fc;
    --primary-base: #38bdf8;  
    --primary-dark: #0284c7;
    --gold-light: #fde68a;
    --gold-base: #fbbf24;
    --gold-dark: #b45309;
    --success-light: #ecfdf5;
    --success-base: #2ecc71;
    --success-dark: #047857;
    --danger-light: #fca5a5;
    --danger-base: #ef4444;    
    --danger-dark: #b91c1c;
    --special-light: #d8b4fe;
    --special-base: #a855f7;
    --special-dark: #7e22ce;
    --share-light: #a78bfa;
    --share-base: #8b5cf6;
    --share-dark: #6d28d9;
    --zen-light: #2dd4bf;
    --zen-base: #14b8a6;
    --zen-dark: #0f766e;
}

/* =========================================
   2. GLOBAL RESETS & BASE
   ========================================= */

   * { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; /* Kills the grey/blue flash globally */
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, Verdana, sans-serif;
    background-color: var(--text-dark); 
    color: var(--text-color);
    margin: 0; padding: 0;
    height: 100vh;
    height: 100dvh; 
    overflow: hidden;
    display: flex; justify-content: center;
    overscroll-behavior: none; 
    touch-action: manipulation; /* <-- ADD THIS TO DISABLE DOUBLE-TAP ZOOM */
}

.main-wrapper {
    width: 100%; height: 100%; max-width: 600px;
    position: relative; 
    background-color: var(--bg-color);
    background: radial-gradient(circle at top, var(--bg-gradient-top) 0%, var(--bg-color) 100%);
    box-shadow: 0 0 30px var(--shadow-base); 
    z-index: 1; 
    transition: box-shadow 0.3s ease;
}

.hidden { display: none !important; }
.hidden-logo { display: none !important; }

/* =========================================
   3. ANIMATIONS
   ========================================= */
@keyframes dangerPulse {
    0% { box-shadow: inset 0 2px 5px var(--shadow-base); border-color: var(--border-light); background-color: var(--panel-dark); }
    50% { box-shadow: inset 0 2px 5px var(--shadow-base), 0 0 30px rgba(239, 68, 68, 0.6); border-color: var(--danger-base); background-color: #2a0a10; }
    100% { box-shadow: inset 0 2px 5px var(--shadow-base); border-color: var(--border-light); background-color: var(--panel-dark); }
}
@keyframes heatPulse {
    0% { box-shadow: inset 0 0 20px rgba(255, 69, 0, 0.2); border: 2px solid rgba(255,69,0,0.5); }
    100% { box-shadow: inset 0 0 60px rgba(255, 69, 0, 0.6); border: 2px solid rgba(255,69,0,1); }
}
@keyframes pulse-border {
    0% { border-color: var(--gold-base); box-shadow: 0 0 0 transparent; }
    50% { border-color: var(--text-color); box-shadow: 0 0 10px var(--gold-dark); }
    100% { border-color: var(--gold-base); box-shadow: 0 0 0 transparent; }
}
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    75% { transform: scale(0.95); }
    100% { transform: scale(1); }
}
@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-20px) scale(1.2); opacity: 0; }
}
@keyframes tumble { 
    0% { transform: rotate3d(1, 1, 1, 0deg); } 
    100% { transform: rotate3d(1, 1, 1, 720deg); } 
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Smooth Screen Transitions */
@keyframes screenFadeIn {
    0% { opacity: 0; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}
#intro-screen:not(.hidden), #game-screen:not(.hidden) {
    animation: screenFadeIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards;
}

/* Non-Blocking Success Flash */
@keyframes inputSuccessAnim {
    0% { background-color: var(--success-base); color: white; transform: scale(1.02); }
    100% { background-color: var(--panel-color); color: var(--primary-base); transform: scale(1); }
}
.input-success {
    animation: inputSuccessAnim 0.3s ease-out;
}

.timer-warning { animation: dangerPulse 1s infinite; }
.heat-active .game-container { animation: heatPulse 0.8s infinite alternate; border-radius: 12px; }
.pulse-anim { animation: pulse-border 2s infinite; }
.shake-anim { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both; }

/* The Sequential Letter Hop */
@keyframes letterHop {
    0% { transform: translateY(0); }
    50% { transform: translateY(-15px) scale(1.05); }
    100% { transform: translateY(0); }
}
.die-hop {
    animation: letterHop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* The Arcade Candy Stripe Movement */
@keyframes stripeMove {
    0% { background-position: 0 0; }
    100% { background-position: 30px 0; }
}

/* The Premium Shimmer Sweep */
@keyframes shimmer {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

/* =========================================
   4. BUTTONS & INPUTS (Global)
   ========================================= */

   button { 
    border: none; 
    border-radius: 12px; 
    cursor: pointer; 
    font-weight: 800; 
    transition: transform 0.1s, box-shadow 0.1s; 
    letter-spacing: 0.5px; 
    touch-action: manipulation;
    outline: none; /* <-- ADD THIS: Removes the black focus box */
    -webkit-tap-highlight-color: transparent; /* <-- ADD THIS: Removes mobile tap flashes */
}

/* Add this right below to ensure the focus state is covered */
button:focus {
    outline: none; 
}
button:disabled { filter: grayscale(100%); opacity: 0.6; cursor: not-allowed; transform: none !important; box-shadow: none !important; background: var(--border-color) !important; color: var(--text-muted) !important; border: 1px solid var(--panel-color); }

/* Default Base Gradients */
.primary-btn, .big-submit-btn, .hero-btn { 
    background: linear-gradient(to bottom, var(--primary-light) 0%, var(--primary-base) 100%);
    color: var(--text-dark); padding: 14px; font-size: 1.2rem; width: 100%; 
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 var(--primary-dark), 0 8px 10px var(--shadow-light);
    text-shadow: 0 1px 0 rgba(255,255,255,0.4); border: 1px solid var(--primary-light); text-transform: uppercase;
}
.primary-btn:active, .big-submit-btn:active, .hero-btn:active { 
    transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--primary-dark), 0 2px 2px var(--shadow-light);
}

/* Shimmer Foundation */
.primary-btn, .big-submit-btn, .hero-btn, .golden-die {
    position: relative; 
    overflow: hidden; 
}

/* The Sweeping Light Glare */
.primary-btn::after, .big-submit-btn::after, .hero-btn::after, .golden-die::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg);
    animation: shimmer 4s infinite;
    pointer-events: none;
}

/* Delay the shimmer on the submit button so they don't flash at the exact same time */
.big-submit-btn::after { animation-delay: 2s; }
.daily-btn, .btn-purple {
    background: linear-gradient(to bottom, var(--special-light) 0%, var(--special-base) 100%) !important;
    color: var(--text-light) !important; padding: 14px; font-size: 1.2rem; width: 100%; 
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 var(--special-dark), 0 8px 10px var(--shadow-light) !important;
    text-shadow: 0 1px 0 var(--shadow-light) !important; border: 1px solid var(--special-light) !important; text-transform: uppercase;
}
.daily-btn:active, .btn-purple:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--special-dark), 0 2px 2px var(--shadow-light) !important; }

.danger-btn { 
    background: linear-gradient(to bottom, var(--danger-light) 0%, var(--danger-base) 100%); color: var(--text-light); border: 1px solid var(--danger-light);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 4px 0 var(--danger-dark); 
} 
.danger-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--danger-dark); }

.zen-btn { 
    background: linear-gradient(to bottom, var(--zen-light) 0%, var(--zen-base) 100%); color: var(--text-light); border-radius: 12px;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 var(--zen-dark), 0 8px 10px var(--shadow-light); text-shadow: 0 1px 0 rgba(0,0,0,0.3); border: 1px solid var(--zen-light);
}
.zen-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--zen-dark), 0 2px 2px var(--shadow-light); }

.share-btn { 
    background: linear-gradient(to bottom, var(--share-light) 0%, var(--share-base) 100%); color: var(--text-light); padding: 12px; font-size: 1rem; width: 100%;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 5px 0 var(--share-dark), 0 8px 10px var(--shadow-light); text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}
.share-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--share-dark); }

.secondary-btn { background-color: var(--panel-color); border: 2px solid var(--border-color); color: var(--text-color); padding: 10px; }
.secondary-btn:active { background-color: var(--border-color); transform: translateY(2px); }

.small-btn { font-size: 0.9rem; padding: 8px 12px; width: auto; }
.icon-btn { background: none; font-size: 1.5rem; padding: 5px; color: var(--text-muted); box-shadow: none !important; }
.icon-btn:hover { color: var(--primary-base); transform: scale(1.1); }
.icon-btn:active { transform: scale(0.9); }

/* Inputs */
input[type="text"] {
    width: 100%; height: 40px; padding: 8px; font-size: 1.4rem; border-radius: 8px;
    border: 2px solid var(--border-color); text-align: center; font-weight: 800;
    text-transform: uppercase; background: var(--panel-color); color: var(--primary-base);
    min-width: 0; letter-spacing: 3px; caret-color: transparent; cursor: default;
    user-select: none; -webkit-user-select: none;
}
input:focus { outline: none; border-color: var(--border-color); background-color: var(--panel-color); }
#player-search-input { user-select: text !important; -webkit-user-select: text !important; cursor: text !important; caret-color: var(--text-light) !important; text-align: left !important; text-transform: none !important; letter-spacing: normal !important; }
.input-error { border-color: var(--danger-base) !important; background-color: rgba(239, 68, 68, 0.1) !important; color: var(--danger-base) !important; }

/* --- Special "Success/Shop" Button Style (Flat & Modern) --- */
.success-shop-btn {
    background-color: var(--success-base);
    color: white;
    border: 1px solid var(--success-dark);
    /* Remove the old school box-shadow, keep the playful hover scale from the primary-btn class */
    box-shadow: 0 4px 10px rgba(34, 197, 94, 0.15); 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px; /* Space between icons and text */
    font-weight: 900;
}

/* Hover state is handled by the parent .hover-scale class, but we'll add a color change too */
.success-shop-btn:hover:not(:disabled) {
    background-color: #199e4c; /* Manually chosen darker green for depth */
}

/* Disabled state when they are too poor for pickles */
.success-shop-btn:disabled {
    background-color: var(--panel-color);
    color: var(--text-muted);
    border-color: var(--border-color);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.8;
}

/* =========================================
   5. HEADER & SIDE DRAWER
   ========================================= */
.home-navbar { position: absolute; top: 0; left: 0; width: 100%; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; z-index: 200; }
.nav-icon-btn { background: none; color: var(--text-muted); font-size: 1.8rem; padding: 0; border: none; cursor: pointer; box-shadow: none !important; }
.profile-section { display: flex; align-items: center; gap: 10px; }
.hover-scale { transition: transform 0.1s; cursor: pointer; }
.hover-scale:active { transform: scale(0.95); }

.xp-pill { background: var(--panel-color); padding: 5px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; color: var(--gold-base); border: 1px solid var(--border-color); }
.streak-pill { background: var(--panel-color); padding: 5px 12px; border-radius: 20px; font-size: 0.9rem; font-weight: bold; color: var(--gold-base); border: 1px solid var(--gold-base); display: flex; align-items: center; gap: 5px; }

.header-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-base); display: block; }
.header-avatar-placeholder { width: 36px; height: 36px; border-radius: 50%; background: var(--panel-color); border: 2px solid var(--border-color); display: flex; justify-content: center; align-items: center; color: var(--text-muted); font-size: 1.2rem; }

.side-drawer { position: fixed; top: 0; left: 0; width: 280px; height: 100%; background: var(--bg-color); z-index: 5000; box-shadow: 2px 0 15px var(--shadow-base); border-right: 1px solid var(--border-color); transform: translateX(-105%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; }
.side-drawer.open { transform: translateX(0); }
.drawer-header { padding: 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.close-drawer-x { font-size: 1.4rem; color: var(--text-muted); background: none; border: none; }
.drawer-nav { padding: 20px; flex: 1; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; padding-bottom: 40px; }
.drawer-item { background: var(--panel-color); color: var(--text-color); text-align: left; padding: 15px; font-size: 1rem; display: flex; align-items: center; gap: 15px; border: 1px solid var(--border-color); box-shadow: none; font-weight: normal; }
.d-icon { font-size: 1.2rem; }
.drawer-section-title {
    font-size: 0.75rem; font-weight: 900; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 1px; 
    padding: 10px 15px 5px 15px; margin-top: 5px;
}
.drawer-divider {
    height: 1px; width: 100%; background: var(--border-color);
    margin: 10px 0;
}
.drawer-item { 
    /* Overriding the old boxy borders for a cleaner flush look */
    border: none !important; border-radius: 8px; margin-bottom: 2px;
}

.drawer-item:active { background: var(--panel-hover); transform: scale(0.98); }
.drawer-footer { padding: 15px; text-align: center; color: var(--text-tertiary); font-size: 0.8rem; border-top: 1px solid var(--border-color); }
.menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--shadow-base); z-index: 4900; backdrop-filter: blur(2px); }

/* Level Progress */
.level-container { padding: 15px 20px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border-color); }
.level-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.level-badge { font-weight: 900; font-size: 1.1rem; letter-spacing: 1px; }
.xp-text { font-size: 0.8rem; color: var(--text-muted); font-weight: bold; }
.level-bar-bg { width: 100%; height: 8px; background: var(--panel-dark); border-radius: 4px; overflow: hidden; border: 1px solid var(--border-color); }
.level-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease-out, background 0.3s; }

/* =========================================
   6. INTRO / HOME SCREEN
   ========================================= */
#intro-screen { 
    height: 100%; 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    justify-content: flex-start; /* Forces content to start below header instead of pushing up */
    align-items: center; 
    padding: 85px 2rem 2rem 2rem; /* Adds top padding to perfectly clear the header */
    text-align: center; 
    overflow-y: auto; /* Enables scrolling on small devices! */
}

.logo-wrapper { margin: 20px 0; display: flex; flex-direction: column; align-items: center; }
.racer-logo { text-align: center; transform: skew(-5deg); }
.flag-icon { font-size: 60px; margin-bottom: 5px; animation: wave 1s infinite alternate; }
.game-title { font-size: 3.5rem; line-height: 0.9; color: var(--text-color); margin: 0; letter-spacing: 2px; font-style: italic; text-shadow: 4px 4px 0 var(--primary-base); }
.teaser-text { color: var(--text-muted); margin-bottom: 2rem; font-style: italic; letter-spacing: 1px; }
.spacer { flex: 1; }
#intro-loading-msg { margin-bottom: 15px; font-weight: bold; font-size: 0.9rem; color: var(--primary-base); height: 20px; }
.offline-banner { background-color: var(--gold-base); color: var(--bg-color); text-align: center; padding: 8px; font-weight: bold; font-size: 0.9rem; width: 100%; z-index: 100; box-shadow: 0 2px 10px var(--shadow-light); animation: slideDown 0.3s ease-out forwards; }

/* Unified Home Menu Cards */
.intro-actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.home-menu-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100%;
    padding: 16px 20px !important;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
    text-align: left;
    border: none;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}
.home-menu-card:active { transform: scale(0.96); }
.hmc-icon { font-size: 2rem; margin-right: 15px; line-height: 1; display: flex; align-items: center; justify-content: center; width: 40px; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.hmc-text { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start !important; min-width: 0; }
.hmc-title { font-size: 1.15rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; color: #fff; margin-bottom: 4px; text-shadow: 0 1px 2px rgba(0,0,0,0.4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: left; }
.hmc-subtitle { font-size: 0.8rem; color: rgba(255, 255, 255, 0.85); line-height: 1.2; text-align: left; font-weight: normal !important; }
.hmc-action { display: flex; align-items: center; justify-content: center; padding-left: 10px; font-size: 1.2rem; color: rgba(255, 255, 255, 0.5); flex-shrink: 0; }

/* Menu Card Legacy Gradients (Overrides in Quickle Themes) */
.daily-card { background: linear-gradient(135deg, var(--special-light) 0%, var(--special-dark) 100%); border: 2px solid var(--special-light); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 8px 15px rgba(126, 34, 206, 0.3); }
.daily-card.locked { background: var(--panel-color); border: 2px solid var(--border-color); box-shadow: none; opacity: 0.6; cursor: pointer; }
.daily-card.locked:active { transform: scale(0.96); }
.daily-card.locked .hmc-title { color: var(--text-color); text-shadow: none; }
.daily-card.locked .hmc-subtitle { color: var(--text-muted); }
.solo-card { background: linear-gradient(135deg, var(--primary-base) 0%, var(--primary-dark) 100%); border: 2px solid var(--primary-light); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 8px 15px rgba(2, 132, 199, 0.3); }
.social-card { background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--border-color); box-shadow: none; }
.social-card.active-turn { background: linear-gradient(135deg, var(--danger-base) 0%, var(--danger-dark) 100%); border: 2px solid #fca5a5; box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 8px 15px rgba(239, 68, 68, 0.4); }

.hub-notification-badge { position: absolute; top: 12px; right: 12px; background: #ff4757; color: white; font-size: 0.7rem; font-weight: 900; padding: 2px 8px; border-radius: 10px; box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3); }

/* =========================================
   7. AUTH & LOGIN
   ========================================= */
#auth-container { margin-bottom: 25px; margin-top: 40px; width: 100%; display: flex; flex-direction: column; align-items: center; min-height: 50px; }
#login-buttons-group { display: flex; flex-direction: row; gap: 12px; margin-bottom: 5px; width: 100%; max-width: 320px; justify-content: center; }
.google-btn, .facebook-btn { flex: 1; font-family: 'Nunito', sans-serif; font-weight: bold; padding: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.95rem; border-radius: 12px; transition: transform 0.1s; white-space: nowrap; }

.google-btn { background-color: var(--text-light); color: var(--panel-color); box-shadow: 0 4px 0 var(--text-secondary); border: 1px solid var(--text-secondary); }
.google-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--text-secondary); }
.google-btn:hover { background-color: var(--text-color); }
.g-icon { font-weight: 900; font-family: 'Georgia', serif; color: #4285F4; font-size: 1.1rem; }

.facebook-btn { background-color: #1877F2; color: var(--text-light); box-shadow: 0 4px 0 #165dbb; border: 1px solid #1877F2; }
.facebook-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #165dbb; }
.facebook-btn:hover { background-color: #166fe5; }

/* =========================================
   8. GAME SCREEN & BOARD
   ========================================= */
#game-screen { height: 100%; width: 100%; position: relative; z-index: 5; }
.game-container { height: 100%; display: flex; flex-direction: column; }
.game-header { padding: 15px 15px 5px 15px; flex-shrink: 0; background: var(--bg-color); border-bottom: 1px solid var(--border-color); }
.header-top-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.logo-small { font-weight: bold; color: var(--text-tertiary); letter-spacing: 1px; font-style: italic; }
.close-icon { color: var(--danger-base); font-weight: bold; }

.header-stats { display: flex; justify-content: space-around; font-size: 1.2rem; font-weight: bold; margin-bottom: 8px; }
.stat-group { text-align: center; position: relative; }
.stat-label { font-size: 0.7rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 1px; }

#progress-container { 
    width: 100%; 
    height: 12px; /* <-- Doubled height so the stripes are highly visible! */
    background: var(--panel-color); 
    border-radius: 6px; 
    overflow: hidden; 
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#progress-bar { 
    height: 100%; width: 100%; 
    background-color: var(--primary-base); 
    /* The Candy Stripe Overlay */
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 30px 30px;
    animation: stripeMove 1s linear infinite;
    transition: width 1s linear, background-color 0.5s; 
}
.progress-critical { background-color: var(--danger-base) !important; box-shadow: 0 0 10px var(--danger-base); }

.game-body { flex: 1; display: flex; flex-direction: column; padding: 0 15px; overflow: hidden; gap: 10px; }
#word-count-status { font-size: 0.9rem; color: var(--text-muted); text-align: center; display: flex; justify-content: center; gap: 8px; align-items: center; margin-top: 8px; flex-shrink: 0; }
.status-divider { color: var(--border-color); font-size: 1.1rem; }

.start-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; display: flex; justify-content: center; align-items: center; background: var(--overlay-light); }
.start-card { background: var(--glass-bg); backdrop-filter: blur(8px); border: 1px solid var(--primary-base); padding: 30px; border-radius: 20px; text-align: center; box-shadow: 0 10px 30px var(--shadow-base); width: 90%; max-width: 500px; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; }
.start-title { font-size: 2.5rem; color: var(--text-light); margin: 0 0 15px 0; text-transform: uppercase; font-style: italic; text-shadow: 3px 3px 0 var(--primary-base); }
.quick-tips { list-style: disc; padding-left: 20px; margin: 0 0 25px 0; text-align: left; }
.quick-tips li { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 8px; padding-left: 5px; }

.back-link { margin-top: 20px; display: inline-block; font-size: 0.95rem; color: var(--text-muted); text-decoration: underline; cursor: pointer; transition: color 0.2s; }
.back-link:hover { color: var(--primary-base); }

.dice-wrapper { display: flex; flex-direction: column; align-items: center; margin-bottom: 8px; width: 100%; position: relative; flex-shrink: 0; padding-top: 0; }
.dice-container { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 500px; margin: 0 auto; perspective: 1000px; background-color: var(--panel-dark); padding: 12px; border-radius: 16px; box-shadow: inset 0 2px 5px var(--shadow-base); border: 1px solid var(--border-light); }

.die { 
    width: 100%; aspect-ratio: 1 / 1; 
    background-color: var(--text-color); color: var(--bg-color); 
    font-size: clamp(2rem, 8vw, 3rem); font-weight: 800; 
    border-radius: 12px; display: flex; justify-content: center; align-items: center; 
    box-shadow: 0 4px 0 var(--text-secondary); text-transform: uppercase; 
    
    /* --- NEW: iOS WebKit Overrides --- */
    user-select: none; 
    -webkit-user-select: none; 
    -webkit-touch-callout: none; 
    /* --------------------------------- */
    
    cursor: pointer; transition: transform 0.1s, background-color 0.1s; 
    touch-action: manipulation; 
}
.die-placeholder { width: 100%; aspect-ratio: 1/1; background: var(--border-light); border-radius: 12px; border: 2px dashed var(--border-color); }
.die:active { transform: scale(0.95) translateY(4px); box-shadow: none; background-color: var(--text-secondary); }
.die.used { background-color: var(--panel-color); color: var(--text-tertiary); transform: scale(0.96); box-shadow: none; border: 2px solid var(--border-color); }
.die.rolling { animation: tumble 0.6s ease-out; color: transparent; text-shadow: none; }
.die[data-value="QU"] { font-size: clamp(1.5rem, 6vw, 2.2rem); }

.golden-die { background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-base) 100%); color: var(--bg-color); border: 2px solid var(--gold-base); box-shadow: 0 4px 0 var(--gold-dark); text-shadow: 0 1px 0 rgba(255,255,255,0.4); }
.golden-die:active { background: var(--gold-light); }
.golden-die.used { background: var(--gold-dark); color: var(--gold-light); border-color: var(--gold-dark); }

#input-area { width: 100%; max-width: 450px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; position: relative; padding-top: 5px; flex-shrink: 0; margin-top: 15px; margin-bottom: 0px; }
.message { height: 20px; font-size: 0.9rem; color: var(--danger-base); font-weight: bold; text-align: center; margin-top: 2px; }

.submit-wrapper { flex-shrink: 0; width: 100%; max-width: 450px; margin: 0 auto; display: flex; gap: 8px; }
#shuffle-btn, #backspace-btn { width: 50px; height: 50px; flex-shrink: 0; display: flex; justify-content: center; align-items: center; background: var(--panel-color); color: var(--text-light); border-radius: 8px; font-size: 1.2rem; border: 1px solid var(--border-color); padding: 0; }
.shuffle-style { background-color: var(--panel-color); }
.backspace-style { background-color: var(--danger-base); border-color: var(--danger-base); color: var(--bg-color); }

.words-found-container { flex: 1; min-height: 0; background: var(--panel-color); border-radius: 12px; padding: 10px; overflow-y: auto; border: 1px solid var(--border-color); position: relative; margin-bottom: 10px; }
#word-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; justify-content: center; }
#word-list li { background: var(--bg-color); color: var(--primary-base); padding: 6px 12px; border-radius: 20px; font-size: 0.9rem; white-space: nowrap; font-weight: bold; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

.game-footer { padding: 15px; background: var(--bg-color); border-top: 1px solid var(--border-color); flex-shrink: 0;}
.footer-buttons { display: flex; gap: 10px; }
#start-round-btn { flex: 2; }

/* =========================================
   9. MODALS (Global Modals, Overlays)
   ========================================= */

   .modal { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: var(--overlay-bg); 
    
    /* --- NEW: iOS Glassmorphism --- */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* ------------------------------ */
    
    z-index: 4000; 
    display: flex; justify-content: center; align-items: center; 
    padding: 20px;
}
/* Modal Hierarchy Z-Indexes */
#leaderboard-modal { z-index: 4100 !important; }
#stats-modal { z-index: 4500 !important; }
#home-stats-modal { z-index: 4600 !important; } 
#full-history-modal { z-index: 4700 !important; }
#settings-modal { z-index: 4800 !important; }
#challenge-login-modal { z-index: 4900 !important; }
#definition-modal { z-index: 5000 !important; }
#badge-detail-overlay { z-index: 9000 !important; }

#pause-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--overlay-bg); backdrop-filter: blur(8px); z-index: 3000; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
#pause-overlay h2 { margin-bottom: 10px; color: var(--primary-base); font-size: 2.5rem; }
#pause-overlay p { margin-bottom: 30px; color: var(--text-muted); }

.modal-content { 
    background: var(--bg-color); border: 1px solid var(--border-color); 
    padding: 25px; border-radius: 16px; 
    width: 100%; max-width: 500px; max-height: 85vh; 
    overflow-y: auto; text-align: center; 
    display: flex; flex-direction: column; gap: 15px; 
    box-shadow: 0 10px 25px var(--shadow-base); 
    position: relative; 
}
.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.modal-close-x {
    position: absolute; top: 10px; right: 15px;
    background: none; border: none;
    color: var(--text-muted); font-size: 1.5rem;
    cursor: pointer; padding: 5px; z-index: 20;
    line-height: 1; box-shadow: none !important;
}
.modal-close-x:hover { color: var(--danger-base); transform: scale(1.1); }

/* =========================================
   10. RESULTS & STATS SCREEN
   ========================================= */
#modal-title { margin: 0; line-height: 1; font-size: 1.8rem; }
.results-header-row { margin-bottom: 25px !important; margin-top: -10px; }
.score-pop { position: absolute; top: 5px; right: -30px; color: var(--gold-base); font-size: 1.1rem; font-weight: 800; pointer-events: none; animation: floatUp 0.8s ease-out forwards; text-shadow: 1px 1px 0 var(--shadow-base); z-index: 10; }
.golden-pop { color: var(--gold-base) !important; text-shadow: 0 0 5px rgba(245, 158, 11, 0.8); font-size: 1.4rem !important; }

.score-split-layout { display: flex; align-items: center; justify-content: center; gap: 25px; background: var(--panel-color); padding: 20px 15px; border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 20px !important; box-shadow: inset 0 0 20px var(--shadow-light); }
.score-left-col { text-align: center; padding-right: 20px; border-right: 1px solid var(--border-medium); min-width: 120px; }
.score-right-col { text-align: left; display: flex; flex-direction: column; justify-content: center; gap: 12px; }

.score-label { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 5px; text-transform: uppercase; }
.final-score-compact { font-size: 3.5rem; font-weight: 900; color: var(--primary-base); line-height: 1; letter-spacing: -1px; }

.breakdown-row-compact { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; /* Ensures icons and text stay perfectly level */
    font-size: 0.9rem; 
    color: var(--text-secondary); 
    gap: 15px; 
}
.b-val-compact { font-weight: bold; color: var(--text-light); }
.b-val-compact.bonus { color: var(--gold-base); }

.results-summary-card { display: flex; flex-direction: column; padding: 0 !important; gap: 0; margin-bottom: 25px !important; overflow: hidden; background: linear-gradient(135deg, var(--panel-color) 0%, var(--bg-color) 100%); border: 2px solid var(--border-color); border-radius: 12px; box-shadow: inset 0 0 20px var(--shadow-light); }
.summary-stats-content { display: flex; justify-content: space-between; align-items: center; padding: 20px 15px; width: 100%; }
.summary-col { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.summary-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: bold; margin-bottom: 8px; }
.summary-word { font-size: 1.3rem; font-weight: 900; color: var(--text-light); margin-bottom: 4px; word-break: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; text-shadow: 0 2px 4px var(--shadow-base); max-width: 100%; }
.summary-pts { font-size: 1rem; font-weight: bold; padding: 4px 10px; border-radius: 6px; background: var(--border-medium); color: var(--text-secondary); display: inline-block; }
.summary-divider { width: 1px; height: 60px; background: var(--border-color); margin: 0 15px; }

.col-found .summary-word { color: var(--primary-base) !important; }
.col-found .summary-pts { color: var(--primary-light) !important; background: rgba(56, 189, 248, 0.15) !important; }
.col-missed .summary-word { color: var(--gold-base) !important; }
.col-missed .summary-pts { color: var(--gold-light) !important; background: rgba(251, 191, 36, 0.15) !important; }

.summary-card-footer { width: 100%; padding: 14px; background: var(--shadow-light); border-top: 1px solid var(--border-medium); text-align: center; color: var(--text-muted); font-weight: 800; font-size: 0.9rem; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px; transition: background 0.2s, color 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.summary-card-footer:hover { background: rgba(56, 189, 248, 0.1); color: var(--text-light); }
.summary-card-footer:active { background: rgba(56, 189, 248, 0.2); }
.results-actions { display: flex; flex-direction: column; gap: 15px !important; margin-top: 0 !important; padding-bottom: 30px; }

#stats-dashboard { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-card { background: var(--panel-dark); padding: 12px; border-radius: 12px; text-align: center; border: 1px solid var(--border-color); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.stat-icon { font-size: 1.2rem; margin-bottom: 4px; }
.stat-val { font-size: 1.2rem; font-weight: 800; color: var(--text-light); word-break: break-all; }
.stat-lbl { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

/* Word Recap Stats */
#word-recap-modal .word-list-box { height: auto !important; max-height: none !important; overflow: visible !important; flex-shrink: 0 !important; min-height: 200px; margin-bottom: 20px; }
.recap-stats-container { background: var(--panel-dark); border-radius: 8px; padding: 12px; margin-bottom: 15px; border: 1px solid var(--border-color); }
.recap-metrics-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-medium); }
.recap-metric { flex: 1; text-align: center; background: rgba(255,255,255,0.03); border-radius: 6px; padding: 6px 4px; }
.recap-metric-val { font-weight: 800; color: var(--text-light); font-size: 1.1rem; line-height: 1; }
.recap-metric-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }
.dist-row { display: flex; align-items: center; margin-bottom: 4px; font-size: 0.8rem; }
.dist-label { width: 30px; color: var(--text-muted); font-weight: bold; }
.dist-bar-container { flex: 1; height: 16px; background: var(--border-light); border-radius: 4px; overflow: hidden; display: flex; align-items: center; }
.dist-bar { height: 100%; background: var(--primary-base); border-radius: 4px; min-width: 4px; transition: width 0.5s ease; }
.dist-count { margin-left: 8px; font-weight: bold; color: var(--text-light); width: 20px; text-align: right; }

/* =========================================
   11. LEADERBOARDS & CHALLENGES DASHBOARD
   ========================================= */
.lb-menu-grid { display: flex; flex-direction: column; gap: 12px; }
.lb-menu-card { background: var(--panel-color); border: 2px solid var(--border-color); padding: 20px 15px; border-radius: 16px; display: flex; align-items: center; gap: 15px; width: 100%; color: var(--text-light); box-shadow: 0 4px 10px var(--shadow-light); transition: transform 0.1s, border-color 0.2s; }
.lb-menu-card:active { transform: scale(0.97); border-color: var(--primary-base); }
.lb-menu-icon { font-size: 2rem; line-height: 1; }
.lb-menu-text { font-size: 1.2rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }

.lb-row { display: flex; align-items: center; justify-content: space-between; background: var(--panel-color); padding: 10px 15px; border-radius: 20px; margin-bottom: 8px; border: 1px solid var(--border-light); }
.lb-row.is-me { background: rgba(56, 189, 248, 0.15); border: 1px solid var(--primary-base); }
.lb-row-rank { width: 35px; font-weight: 900; color: var(--text-muted); font-size: 1rem; }
.lb-row-player { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.lb-row-name { font-weight: bold; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row-score { font-weight: 900; color: var(--text-light); font-size: 1.1rem; text-align: right; }
.lb-row-score.vocab { color: var(--primary-base); }
.lb-row-score.xp, .lb-row-score.high { color: var(--gold-base); }
.lb-row[data-rank="1"] .lb-row-rank { color: var(--gold-base); font-size: 1.2rem; }
.lb-row[data-rank="2"] .lb-row-rank { color: var(--text-secondary); font-size: 1.1rem; }
.lb-row[data-rank="3"] .lb-row-rank { color: #fb923c; font-size: 1.1rem; }

/* Challenges Dashboard */
.challenge-header-container { padding: 25px 25px 10px 25px; background: var(--bg-color); border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.dashboard-status-msg { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 5px; min-height: 1.2rem; }
.challenge-dashboard-content { padding: 0 !important; position: relative; overflow: hidden; display: flex; flex-direction: column; height: 80vh; }
.challenge-feed { flex: 1; overflow-y: auto; padding: 15px 15px 80px 15px; width: 100%; }
.feed-section { margin-bottom: 25px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1px solid var(--border-color); cursor: pointer; user-select: none; }
.section-title { font-size: 0.9rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; }
.section-badge { background: var(--panel-color); border: 1px solid var(--border-color); color: var(--text-secondary); font-size: 0.75rem; font-weight: bold; padding: 2px 8px; border-radius: 10px; margin-left: 10px; }


#inbox-count { background: var(--danger-base); color: var(--text-light); border: none; }
#active-count { background: rgba(56, 189, 248, 0.2); color: var(--primary-base); border: 1px solid var(--primary-base); }
#completed-count { background: rgba(46, 204, 113, 0.2); color: var(--success-base); border: 1px solid var(--success-base); }
#c-section-completed:not(.hidden) {
    display: block !important;
}

.arrow-icon { color: var(--text-tertiary); font-size: 0.8rem; transition: transform 0.3s ease; }
.feed-list { transition: max-height 0.3s ease-out; overflow: hidden; }
.feed-list.collapsed { display: none; }
.section-header.expanded .arrow-icon { transform: rotate(180deg); }
.dashboard-footer { padding: 15px; background: var(--bg-color); border-top: 1px solid var(--border-color); flex-shrink: 0; z-index: 10; }

.challenge-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; background: var(--panel-color); border-bottom: 1px solid var(--border-color); cursor: pointer; transition: background-color 0.1s; border-radius: 8px; margin-bottom: 8px; }
.challenge-row:active { background: var(--panel-hover); }
.c-row-actions { display: flex; align-items: center; gap: 12px; }
.action-circle-btn { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; transition: transform 0.1s; cursor: pointer; box-shadow: none !important; padding: 0; }
.action-circle-btn:active { transform: scale(0.9); }
.btn-nudge { background: rgba(56, 189, 248, 0.1); border: 1px solid var(--primary-base); color: var(--primary-base); }
.btn-share { background: rgba(251, 191, 36, 0.1); border: 1px solid var(--gold-base); color: var(--gold-base); }
.btn-cancel { background: transparent; border: 1px solid var(--danger-base); color: var(--danger-base); }

/* =========================================
   12. VERSUS & RIVALRY MODALS
   ========================================= */
.vs-content { background: linear-gradient(135deg, var(--bg-color) 0%, var(--panel-color) 100%); border: 2px solid var(--primary-base); box-shadow: 0 0 40px rgba(56, 189, 248, 0.2); overflow: visible; }
.vs-header { font-size: 2.5rem; font-weight: 900; text-transform: uppercase; text-align: center; margin-bottom: 25px; text-shadow: 0 2px 10px var(--shadow-base); letter-spacing: 2px; }
.vs-header.victory { color: var(--success-base); text-shadow: 0 0 15px rgba(46, 204, 113, 0.4); }
.vs-header.defeat { color: var(--danger-base); text-shadow: 0 0 15px rgba(239, 68, 68, 0.4); }

.vs-container { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; position: relative; padding: 0 10px; }
.vs-player-card { display: flex; flex-direction: column; align-items: center; width: 42%; position: relative; }
.vs-avatar-large { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 4px solid var(--border-color); background: var(--text-dark); box-shadow: 0 4px 15px var(--shadow-base); margin-bottom: 10px; }
.vs-player-card.winner .vs-avatar-large { border-color: var(--gold-base); box-shadow: 0 0 20px rgba(251, 191, 36, 0.4); }
.vs-name { font-size: 0.9rem; color: var(--text-secondary); font-weight: bold; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.vs-score-large { font-size: 2.2rem; font-weight: 800; color: var(--text-light); line-height: 1; }

.vs-center-badge { position: absolute; left: 50%; top: 35px; transform: translateX(-50%); width: 40px; height: 40px; background: var(--primary-dark); color: var(--text-light); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: 900; font-size: 1rem; border: 3px solid var(--bg-color); z-index: 10; box-shadow: 0 4px 10px var(--shadow-base); }
.vs-winner-tag { position: absolute; top: -12px; background: var(--danger-base); color: var(--text-light); font-size: 0.7rem; font-weight: bold; padding: 4px 10px; border-radius: 4px; text-transform: uppercase; box-shadow: 0 2px 5px var(--shadow-light); z-index: 20; animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

.vs-comparison-box { background: var(--overlay-light); border: 1px solid var(--border-color); border-radius: 12px; padding: 15px; margin-bottom: 15px; text-align: center; }
.vs-comp-header { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; letter-spacing: 1px; font-weight: bold; }
.vs-comp-grid { display: flex; align-items: center; }
.vs-comp-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vs-comp-label { font-size: 0.7rem; color: var(--text-tertiary); font-weight: bold; text-transform: uppercase; }
.vs-word-text { font-size: 1.2rem; font-weight: 800; letter-spacing: 1px; }
.vs-comp-col.left .vs-word-text { color: var(--primary-base); }
.vs-comp-col.right .vs-word-text { color: var(--gold-base); }
.vs-pts-pill { background: var(--panel-hover); padding: 2px 8px; border-radius: 6px; font-size: 0.8rem; font-weight: bold; color: var(--text-secondary); }
.vs-comp-divider { width: 1px; height: 40px; background: var(--border-medium); margin: 0 10px; }

/* =========================================
   13. BADGES, WORD BANK & HISTORY
   ========================================= */
#badge-gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding-bottom: 20px; }
.badge-item { transition: transform 0.2s, border-color 0.2s; background: var(--panel-dark); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.badge-item:active { transform: scale(0.95); }
@media (hover: hover) { .badge-item:hover { transform: translateY(-2px); border-color: var(--primary-base) !important; } }
#badge-toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 6000; pointer-events: none; width: 90%; max-width: 350px; }

.word-list-box { height: 150px; overflow-y: scroll; background: var(--bg-color); padding: 10px; text-align: left; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; font-size: 0.9rem; border: 1px solid var(--border-color); }
.word-list-box div { color: var(--text-color); background: var(--panel-color); padding: 4px 8px; border-radius: 6px; } 
.clickable-word { text-decoration: underline dotted; cursor: pointer; }
.clickable-word:hover { color: var(--primary-base); }
.list-tabs { display: flex; gap: 5px; margin-top: 10px; }
.tab-btn { background: var(--panel-color); border-radius: 8px 8px 0 0; padding: 10px; flex: 1; font-size: 0.9rem; color: var(--text-muted); border: 1px solid var(--border-color); border-bottom: none; }
.tab-btn.active { background: var(--bg-color); color: var(--primary-base); border-top: 2px solid var(--primary-base); font-weight: bold; }

.history-scroll-area { max-height: 50vh; overflow-y: auto; width: 100%; margin-bottom: 15px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-color); }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
.history-table th { background: var(--panel-color); color: var(--text-muted); padding: 12px 8px; text-align: center; font-size: 0.75rem; text-transform: uppercase; position: sticky; top: 0; z-index: 10; border-bottom: 2px solid var(--border-color); box-shadow: 0 2px 5px var(--shadow-light); }
.history-table td { border-bottom: 1px solid var(--border-light); padding: 12px 8px; color: var(--text-secondary); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.95rem; }
/* (Deleted the old nth-child overrides so JavaScript can control the colors!) */
.history-table td:nth-child(2) { color: var(--gold-base); font-weight: bold; }
.history-table td:nth-child(5), .history-table th:nth-child(5) { text-align: right; padding-right: 15px; }

/* Picklepedia Fact Cards */
.pickle-fact-card {
    background: var(--panel-color);
    border: 2px solid var(--success-base);
    border-radius: 12px;
    padding: 15px;
    text-align: left;
    position: relative;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.1);
    animation: popIn 0.3s ease-out;
}
.pickle-fact-card.locked {
    background: var(--panel-dark);
    border: 2px dashed var(--border-color);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    animation: none;
}
.pickle-fact-number {
    font-size: 0.75rem;
    color: var(--success-base);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}
.pickle-fact-text {
    font-size: 0.95rem;
    color: var(--text-color);
    line-height: 1.4;
    font-weight: bold;
}

/* =========================================
   14. SETTINGS, CALENDAR & ANNOUNCEMENTS
   ========================================= */
.settings-profile-section { text-align: center; margin-bottom: 15px; display: flex; flex-direction: column; align-items: center; }
.settings-avatar-placeholder { width: 60px; height: 60px; border-radius: 50%; background: var(--panel-color); border: 2px solid var(--border-color); display: flex; justify-content: center; align-items: center; color: var(--text-muted); font-size: 2rem; margin: 0 auto 10px auto; }
.settings-avatar-large { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-base); margin-bottom: 5px; }
.settings-username { font-size: 1.2rem; font-weight: bold; color: var(--text-light); margin-bottom: 5px; }
.settings-hint { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 10px; }
.settings-auth-buttons { display: flex; flex-direction: row; gap: 10px; width: 100%; justify-content: center; }

.toggle-group { text-align: left; margin-top: 10px; border-top: 1px solid var(--border-color); padding-top: 10px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.toggle-row label { font-size: 1rem; color: var(--text-light); }
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary-base); cursor: pointer; }

.calendar-grid-header div { font-weight: bold; padding-bottom: 5px; border-bottom: 1px solid var(--border-color); margin-bottom: 5px; }
#calendar-modal .modal-content { max-width: 400px; }

.announcements-container { text-align: left; max-height: 60vh; overflow-y: auto; padding-right: 5px; }
.release-card { background: var(--panel-color); border: 1px solid var(--border-color); border-radius: 12px; padding: 15px; margin-bottom: 15px; }
.release-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; border-bottom: 1px solid var(--border-medium); padding-bottom: 8px; }
.release-version { font-size: 1.1rem; font-weight: 800; color: var(--primary-base); }
.release-date { font-size: 0.8rem; color: var(--text-muted); }
.release-title { font-size: 0.95rem; font-weight: bold; color: var(--gold-base); margin-bottom: 8px; }
.release-changes { padding-left: 20px; margin: 0; list-style-type: disc; }
.release-changes li { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 6px; line-height: 1.4; }
.release-changes li strong { color: var(--text-light); }

/* =========================================
   15. RESPONSIVE LAYOUTS
   ========================================= */
@media (min-width: 600px) {
    .screen { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color); }
    .dice-grid { gap: 15px; }
}

@media (max-width: 600px) {
    .modal { padding: 0 !important; }
    .modal-content {
        max-width: 100% !important; height: 100% !important; max-height: 100% !important;
        border-radius: 0 !important; border: none !important;
        justify-content: flex-start !important; 
        padding-top: 50px !important; padding-bottom: 50px !important;
        padding-left: 20px !important; padding-right: 20px !important;
    }
    #game-over-modal .modal-content {
        background: radial-gradient(circle at top, var(--panel-color) 0%, var(--bg-color) 100%); 
        padding-top: 40px !important; 
    }
    .modal-close-x {
        top: 15px; right: 15px; background: var(--overlay-light); 
        border-radius: 50%; width: 40px; height: 40px;
        display: flex; justify-content: center; align-items: center; z-index: 5000;
    }
}

@media (max-width: 360px) {
    .stat-val { font-size: 0.9rem; } 
    .vs-avatar-large { width: 60px; height: 60px; }
    .vs-header { font-size: 2rem; }
}

/* =========================================
   16. LEGACY THEMES (Pickle, Grey, Evergreen, Matcha)
   ========================================= */
/* Pickle Green */
body.theme-pickle { --bg-color: #0b1a10; --panel-color: #14301d; --panel-dark: #07120a; --primary-base: #a3e635; --primary-hover: #84cc16; --border-color: #275735; --special-light: #864c09; --special-base: #6e350c; --special-dark: #442804; --share-light: #fcd34d; --share-base: #f59e0b; --share-dark: #b45309; --zen-light: #34d399; --zen-base: #10b981; --zen-dark: #047857; }
body.theme-pickle .main-wrapper, body.theme-pickle #game-over-modal .modal-content, body.theme-pickle .results-summary-card, body.theme-pickle .challenge-card-modal { background: radial-gradient(circle at top, var(--panel-color) 0%, var(--bg-color) 100%) !important; }
body.theme-pickle .primary-btn, body.theme-pickle .big-submit-btn, body.theme-pickle .hero-btn { background: linear-gradient(to bottom, #bef264 0%, var(--primary-base) 100%); color: #1a2e05; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 #65a30d, 0 8px 10px var(--shadow-light); border: 1px solid #d9f99d; }
body.theme-pickle .primary-btn:active, body.theme-pickle .big-submit-btn:active, body.theme-pickle .hero-btn:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 #65a30d, 0 2px 2px var(--shadow-light); }
body.theme-pickle .vs-content { background: linear-gradient(135deg, var(--bg-color) 0%, var(--panel-color) 100%); box-shadow: 0 0 40px rgba(163, 230, 53, 0.2); }

/* Charcoal & Dill */
body.theme-grey { --bg-color: #040605; --bg-gradient-top: #043c2c; --panel-color: #2d2d2d; --panel-dark: #111111; --panel-hover: #404040; --text-color: #cee2d2; --text-secondary: #74ad8a; --text-muted: #616967; --text-tertiary: #56886e; --text-dark: #000000; --text-light: #ffffff; --border-color: #404040; --border-light: rgba(255, 255, 255, 0.05); --border-medium: rgba(255, 255, 255, 0.1); --overlay-bg: rgba(26, 26, 26, 0.95); --overlay-light: rgba(26, 26, 26, 0.6); --glass-bg: rgba(45, 45, 45, 0.9); --shadow-base: rgba(0, 0, 0, 0.7); --shadow-light: rgba(0, 0, 0, 0.4); --primary-light: #8fbc8f; --primary-base: #3f5710; --primary-dark: #2a3b0a; --gold-light: #bef264; --gold-base: #9acd32; --gold-dark: #4d7c0f; --success-light: #dcfce7; --success-base: #22c55e; --success-dark: #14532d; --danger-light: #fca5a5; --danger-base: #dc2626; --danger-dark: #7f1d1d; --special-light: #65a30d; --special-base: #4d7c0f; --special-dark: #3f6212; --share-light: #fde047; --share-base: #eab308; --share-dark: #a16207; --zen-light: #5eead4; --zen-base: #14b8a6; --zen-dark: #0f766e; }

/* Evergreen */
body.theme-evergreen { --bg-color: #040605; --bg-gradient-top: #043c2c; --panel-color: #043c2c; --panel-dark: #040605; --panel-hover: #50524e; --text-color: #cee2d2; --text-secondary: #7c9c94; --text-muted: #616967; --text-tertiary: #50524e; --text-dark: #040605; --text-light: #ffffff; --border-color: #568a6e; --border-light: rgba(206, 226, 210, 0.1); --border-medium: rgba(206, 226, 210, 0.2); --overlay-bg: rgba(4, 6, 5, 0.95); --overlay-light: rgba(4, 60, 44, 0.6); --glass-bg: rgba(4, 60, 44, 0.9); --shadow-base: rgba(0, 0, 0, 0.6); --shadow-light: rgba(0, 0, 0, 0.3); --primary-light: #cee2d2; --primary-base: #74ad8a; --primary-dark: #568a6e; --gold-light: #a37a6e; --gold-base: #8d6256; --gold-dark: #63433a; --success-light: #cee2d2; --success-base: #74ad8a; --success-dark: #043c2c; --danger-light: #fca5a5; --danger-base: #dc2626; --danger-dark: #7f1d1d; --special-light: #7c9c94; --special-base: #568a6e; --special-dark: #043c2c; --share-light: #7c9c94; --share-base: #616967; --share-dark: #50524e; --zen-light: #cee2d2; --zen-base: #7c9c94; --zen-dark: #568a6e; }
body.theme-evergreen .main-wrapper, body.theme-evergreen #game-over-modal .modal-content, body.theme-evergreen .results-summary-card, body.theme-evergreen .challenge-card-modal { background: radial-gradient(circle at top, var(--bg-gradient-top) 0%, var(--bg-color) 100%) !important; }
body.theme-evergreen .primary-btn, body.theme-evergreen .big-submit-btn, body.theme-evergreen .hero-btn { background: linear-gradient(to bottom, var(--primary-light) 0%, var(--primary-base) 100%); color: var(--bg-color); box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 var(--primary-dark), 0 8px 10px rgba(0,0,0,0.3); border: 1px solid var(--primary-light); }
body.theme-evergreen .primary-btn:active, body.theme-evergreen .big-submit-btn:active, body.theme-evergreen .hero-btn:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--primary-dark), 0 2px 2px rgba(0,0,0,0.3); }
body.theme-evergreen .vs-content { background: linear-gradient(135deg, var(--bg-color) 0%, var(--panel-color) 100%); box-shadow: 0 0 40px rgba(116, 173, 138, 0.2); }

/* Matcha Cream */
body.theme-matcha-cream { --bg-color: #f3efe8; --bg-gradient-top: #ffffff; --panel-color: #ffffff; --panel-dark: #e8e4dc; --panel-hover: #f3efe8; --text-color: #1f493d; --text-secondary: #3d3d3d; --text-muted: #829c94; --text-tertiary: #a0b0ab; --text-dark: #000000; --text-light: #ffffff; --border-color: #d1d6d3; --border-light: rgba(31, 73, 61, 0.1); --border-medium: rgba(31, 73, 61, 0.2); --overlay-bg: rgba(243, 239, 232, 0.95); --overlay-light: rgba(243, 239, 232, 0.6); --shadow-base: rgba(31, 73, 61, 0.15); --shadow-light: rgba(31, 73, 61, 0.05); --primary-light: #4d8f7e; --primary-base: #336659; --primary-dark: #1f493d; --gold-light: #fde047; --gold-base: #d97706; --gold-dark: #92400e; --success-base: #336659; --danger-base: #dc2626; --special-light: #94b8b0; --special-base: #5a8a7e; --special-dark: #336659; --zen-light: #a3b8b3; --zen-base: #739c92; --zen-dark: #3d3d3d; }
body.theme-matcha-cream .main-wrapper, body.theme-matcha-cream #game-over-modal .modal-content, body.theme-matcha-cream .results-summary-card, body.theme-matcha-cream .challenge-card-modal { background: radial-gradient(circle at top, var(--bg-gradient-top) 0%, var(--bg-color) 100%) !important; }
body.theme-matcha-cream .die { background-color: var(--panel-color); color: var(--primary-dark); border: 1px solid var(--border-color); box-shadow: 0 4px 0 var(--panel-dark); }
body.theme-matcha-cream .game-title { text-shadow: 3px 3px 0 var(--primary-light); }
body.theme-matcha-cream .primary-btn, body.theme-matcha-cream .big-submit-btn, body.theme-matcha-cream .hero-btn { background: linear-gradient(to bottom, var(--primary-light) 0%, var(--primary-base) 100%); color: var(--text-light); box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), 0 6px 0 var(--primary-dark), 0 8px 10px var(--shadow-base); border: 1px solid var(--primary-light); }
body.theme-matcha-cream .primary-btn:active, body.theme-matcha-cream .big-submit-btn:active, body.theme-matcha-cream .hero-btn:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--primary-dark), 0 2px 2px var(--shadow-base); }

/* Matcha Dark */
body.theme-matcha-dark { --bg-color: #000000; --bg-gradient-top: #1f493d; --panel-color: #1f493d; --panel-dark: #0d211b; --panel-hover: #336659; --text-color: #f3efe8; --text-secondary: #c2cfcb; --text-muted: #829c94; --text-tertiary: #3d3d3d; --text-light: #ffffff; --border-color: #336659; --overlay-bg: rgba(0, 0, 0, 0.95); --shadow-base: rgba(0, 0, 0, 0.8); --primary-light: #4d8f7e; --primary-base: #336659; --primary-dark: #1f493d; --special-light: #7c9c94; --special-base: #3d3d3d; --special-dark: #1a1a1a; --zen-light: #829c94; --zen-base: #336659; --zen-dark: #1f493d; }
body.theme-matcha-dark .main-wrapper, body.theme-matcha-dark #game-over-modal .modal-content, body.theme-matcha-dark .results-summary-card, body.theme-matcha-dark .challenge-card-modal { background: radial-gradient(circle at top, var(--bg-gradient-top) 0%, var(--bg-color) 100%) !important; }
body.theme-matcha-dark .primary-btn, body.theme-matcha-dark .big-submit-btn, body.theme-matcha-dark .hero-btn { background: linear-gradient(to bottom, var(--primary-light) 0%, var(--primary-base) 100%); color: var(--text-light); box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 6px 0 var(--primary-dark), 0 8px 10px rgba(0,0,0,0.6); border: 1px solid var(--primary-light); }
body.theme-matcha-dark .primary-btn:active, body.theme-matcha-dark .big-submit-btn:active, body.theme-matcha-dark .hero-btn:active { box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), 0 2px 0 var(--primary-dark), 0 2px 2px rgba(0,0,0,0.6); }

/* Dynamic Logos */
body.theme-quickle-light .default-splash-logo, body.theme-quickle-dark .default-splash-logo, body.theme-quickle-light .default-logo, body.theme-quickle-dark .default-logo, body.theme-quickle-light .default-title, body.theme-quickle-dark .default-title { display: none !important; }
body.theme-quickle-light .quickle-logo-light { display: block !important; }
body.theme-quickle-light .logo-small .quickle-title { display: inline !important; }
body.theme-quickle-dark .quickle-logo-dark { display: block !important; }
body.theme-quickle-dark .logo-small .quickle-title { display: inline !important; }


/* =========================================
   17. NEW QUICKLE THEMES (Light & Dark)
   ========================================= */
/* Quickle Light */
body.theme-quickle-light {
    --bg-color: #F8F8F4;       
    --bg-gradient-top: #FFFFFF; 
    --panel-color: #FFFFFF;    
    --panel-dark: #F0F0EA;       
    --text-color: #1e293b;     
    --text-secondary: #475569;   
    --text-muted: #64748b; 
    --text-dark: #0f172a;
    --text-light: #FFFFFF;
    --border-color: #CBD5E1;   
    --overlay-bg: rgba(248, 248, 244, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.95); 
    --primary-base: #22C55E;  
    --primary-dark: #16A34A;  
    --gold-base: #F97316; 
    --gold-dark: #C2410C;
    --share-base: #F97316;
    --share-dark: #C2410C;
    --zen-base: #3B82F6;
    --zen-dark: #2563EB;
    
    /* Dill Pickle Golden Die Colors */
    --dill-light: #4D7C0F; 
    --dill-base: #365314;  
    --dill-text: #ECFCCB;  
}

/* Quickle Dark */
body.theme-quickle-dark {
    --bg-color: #1A1F23;       
    --bg-gradient-top: #252A2E; 
    --panel-color: #252A2E;    
    --panel-dark: #111417;       
    --text-color: #F8F8F4;     
    --text-secondary: #AAB0B7;   
    --text-muted: #6E757C;
    --text-light: #FFFFFF;
    --border-color: #4A4F55;   
    --overlay-bg: rgba(26, 31, 35, 0.95);
    --glass-bg: rgba(37, 42, 46, 0.95);
    --primary-base: #6DA34D;  
    --primary-dark: #4F7A38;  
    --gold-base: #F2994A;
    --gold-dark: #C2762E;
    --share-base: #F2994A;
    --share-dark: #C2762E;
    --zen-base: #6DA34D;
    --zen-dark: #4F7A38;
}

/* Base Overrides for Quickle Themes */
body.theme-quickle-light .main-wrapper, body.theme-quickle-dark .main-wrapper,
body.theme-quickle-light #game-over-modal .modal-content, body.theme-quickle-dark #game-over-modal .modal-content,
body.theme-quickle-light .results-summary-card, body.theme-quickle-dark .results-summary-card,
body.theme-quickle-light .challenge-card-modal, body.theme-quickle-dark .challenge-card-modal { 
    background: var(--bg-color) !important; 
}
body.theme-quickle-light .die, body.theme-quickle-dark .die { 
    background-color: var(--panel-color); 
    color: var(--text-color); 
    border: 2px solid var(--border-color); 
    box-shadow: 0 4px 0 var(--border-color); 
}

/* Flat Chunky Buttons (Applied to Both Quickles) */
body.theme-quickle-light .primary-btn, body.theme-quickle-dark .primary-btn,
body.theme-quickle-light .big-submit-btn, body.theme-quickle-dark .big-submit-btn,
body.theme-quickle-light .hero-btn, body.theme-quickle-dark .hero-btn,
body.theme-quickle-light .daily-btn, body.theme-quickle-dark .daily-btn,
body.theme-quickle-light .zen-btn, body.theme-quickle-dark .zen-btn,
body.theme-quickle-light .share-btn, body.theme-quickle-dark .share-btn,
body.theme-quickle-light .btn-purple, body.theme-quickle-dark .btn-purple {
    background: var(--primary-base) !important;
    color: #FFFFFF !important; 
    text-shadow: none !important;
    font-weight: 900;
    border: 2px solid var(--primary-dark) !important;
    box-shadow: 0 5px 0 var(--primary-dark) !important;
    border-radius: 12px;
}
body.theme-quickle-light .primary-btn:active, body.theme-quickle-dark .primary-btn:active,
body.theme-quickle-light .big-submit-btn:active, body.theme-quickle-dark .big-submit-btn:active,
body.theme-quickle-light .hero-btn:active, body.theme-quickle-dark .hero-btn:active,
body.theme-quickle-light .daily-btn:active, body.theme-quickle-dark .daily-btn:active,
body.theme-quickle-light .zen-btn:active, body.theme-quickle-dark .zen-btn:active,
body.theme-quickle-light .share-btn:active, body.theme-quickle-dark .share-btn:active,
body.theme-quickle-light .btn-purple:active, body.theme-quickle-dark .btn-purple:active {
    transform: translateY(5px) !important;
    box-shadow: 0 0 0 transparent !important;
}

/* Override Specific Button Colors */
body.theme-quickle-light .share-btn, body.theme-quickle-dark .share-btn,
body.theme-quickle-light .btn-purple, body.theme-quickle-dark .btn-purple,
body.theme-quickle-light .daily-btn, body.theme-quickle-dark .daily-btn {
    background: var(--share-base) !important;
    border-color: var(--share-dark) !important;
    box-shadow: 0 5px 0 var(--share-dark) !important;
}
body.theme-quickle-light .zen-btn, body.theme-quickle-dark .zen-btn {
    background: var(--zen-base) !important;
    border-color: var(--zen-dark) !important;
    box-shadow: 0 5px 0 var(--zen-dark) !important;
}

/* Home Menu Cards Overrides (Quickle Light & Dark) */
body.theme-quickle-light .home-menu-card, body.theme-quickle-dark .home-menu-card,
body.theme-quickle-light .hmc-title, body.theme-quickle-dark .hmc-title { text-shadow: none !important; }
body.theme-quickle-light .home-menu-card:active, body.theme-quickle-dark .home-menu-card:active { transform: translateY(5px) !important; box-shadow: 0 0 0 transparent !important; }

/* Solo Card (Now Orange) */
body.theme-quickle-light .solo-card, body.theme-quickle-dark .solo-card { background: var(--gold-base) !important; border: 2px solid var(--gold-dark) !important; box-shadow: 0 5px 0 var(--gold-dark) !important; }
body.theme-quickle-light .solo-card .hmc-title, body.theme-quickle-dark .solo-card .hmc-title, body.theme-quickle-light .solo-card .hmc-subtitle, body.theme-quickle-dark .solo-card .hmc-subtitle, body.theme-quickle-light .solo-card .hmc-icon, body.theme-quickle-dark .solo-card .hmc-icon, body.theme-quickle-light .solo-card .hmc-action, body.theme-quickle-dark .solo-card .hmc-action { color: #FFFFFF !important; }

/* Global Active Daily Card (Now Green) */
body.theme-quickle-light .daily-card:not(.locked), body.theme-quickle-dark .daily-card:not(.locked) { background: var(--primary-base) !important; border: 2px solid var(--primary-dark) !important; box-shadow: 0 5px 0 var(--primary-dark) !important; }
body.theme-quickle-light .daily-card:not(.locked) .hmc-title, body.theme-quickle-dark .daily-card:not(.locked) .hmc-title, body.theme-quickle-light .daily-card:not(.locked) .hmc-subtitle, body.theme-quickle-dark .daily-card:not(.locked) .hmc-subtitle, body.theme-quickle-light .daily-card:not(.locked) .hmc-icon, body.theme-quickle-dark .daily-card:not(.locked) .hmc-icon, body.theme-quickle-light .daily-card:not(.locked) .hmc-action, body.theme-quickle-dark .daily-card:not(.locked) .hmc-action { color: #FFFFFF !important; }


/* Versus Card */
body.theme-quickle-light .social-card, body.theme-quickle-dark .social-card { background: var(--share-base) !important; border: 2px solid var(--share-dark) !important; box-shadow: 0 5px 0 var(--share-dark) !important; }
body.theme-quickle-light .social-card .hmc-title, body.theme-quickle-dark .social-card .hmc-title, body.theme-quickle-light .social-card .hmc-subtitle, body.theme-quickle-dark .social-card .hmc-subtitle, body.theme-quickle-light .social-card .hmc-icon, body.theme-quickle-dark .social-card .hmc-icon, body.theme-quickle-light .social-card .hmc-action, body.theme-quickle-dark .social-card .hmc-action { color: #FFFFFF !important; }

/* Global Locked */
body.theme-quickle-light .daily-card.locked { background: #F1F5F9 !important; border: 2px solid #CBD5E1 !important; box-shadow: 0 5px 0 #CBD5E1 !important; opacity: 1 !important; }
body.theme-quickle-light .daily-card.locked .hmc-title { color: #334155 !important; }
body.theme-quickle-light .daily-card.locked .hmc-subtitle, body.theme-quickle-light .daily-card.locked .hmc-icon, body.theme-quickle-light .daily-card.locked .hmc-action { color: #64748B !important; }

body.theme-quickle-dark .daily-card.locked { background: var(--panel-color) !important; border: 2px solid var(--border-color) !important; box-shadow: 0 5px 0 var(--border-color) !important; opacity: 1 !important; }
body.theme-quickle-dark .daily-card.locked .hmc-title { color: var(--text-color) !important; }
body.theme-quickle-dark .daily-card.locked .hmc-subtitle, body.theme-quickle-dark .daily-card.locked .hmc-icon, body.theme-quickle-dark .daily-card.locked .hmc-action { color: var(--text-muted) !important; }

/* Profile Pillo Overrides */
body.theme-quickle-light #header-streak-container { color: var(--gold-dark) !important; border-color: var(--gold-dark) !important; }
body.theme-quickle-light #header-xp-trigger, body.theme-quickle-dark #header-xp-trigger { color: var(--text-color) !important; border-color: var(--border-color) !important; }


/* =========================================
   18. QUICKLE TEXT ACCESSIBILITY FIXES
   ========================================= */
body.theme-quickle-light .start-title, body.theme-quickle-dark .start-title { color: var(--primary-dark) !important; text-shadow: none !important; }

/* Stats, Results, Settings & Recap Text Fixes */
body.theme-quickle-light .b-val-compact, body.theme-quickle-light .recap-metric-val, body.theme-quickle-light .dist-count, body.theme-quickle-light .stat-val, body.theme-quickle-light .lt-value, body.theme-quickle-light .lt-word, body.theme-quickle-light .settings-username, body.theme-quickle-light .toggle-row label { color: var(--text-color) !important; }

/* Colored Metrics */
body.theme-quickle-light .b-val-compact.bonus { color: var(--gold-dark) !important; }
body.theme-quickle-light .recap-metric-val[style*="color:var(--gold-base)"] { color: var(--gold-dark) !important; }
body.theme-quickle-light .recap-metric-val[style*="color:var(--gold-light)"] { color: var(--gold-dark) !important; }
body.theme-quickle-light .recap-metric-val[style*="color:var(--danger-base)"] { color: var(--danger-dark) !important; }

/* Versus & Rivalry Screens */
body.theme-quickle-light .vs-score-large { color: var(--text-color) !important; }
body.theme-quickle-light .vs-header.victory { color: var(--success-dark) !important; text-shadow: none !important; }
body.theme-quickle-light .vs-header.defeat { color: var(--danger-dark) !important; text-shadow: none !important; }
body.theme-quickle-light .vs-center-badge, body.theme-quickle-dark .vs-center-badge { color: #FFFFFF !important; }

/* In-App Injected Styles (Inbox, Dict, Search) */
body.theme-quickle-light .challenge-row div[style*="color:#fff"], body.theme-quickle-light .challenge-row strong[style*="color:#fff"] { color: var(--text-color) !important; }
body.theme-quickle-light .challenge-row .play-challenge-btn { color: #FFFFFF !important; }
body.theme-quickle-light #def-meanings span[style*="color:#cbd5e1"] { color: var(--text-secondary) !important; }
body.theme-quickle-light #def-meanings span[style*="color:#facc15"] { color: var(--gold-dark) !important; }
body.theme-quickle-light #zen-hint-skeletons span { color: var(--text-color) !important; background: var(--panel-dark) !important; border-color: var(--border-color) !important; }
body.theme-quickle-light #game-target-score { color: var(--gold-dark) !important; }
body.theme-quickle-light .offline-banner { color: #FFFFFF !important; }
body.theme-quickle-light .score-pop { color: var(--gold-dark) !important; text-shadow: none !important; font-weight: 900 !important; }
body.theme-quickle-light .level-container { background: var(--panel-dark) !important; }
body.theme-quickle-light .level-badge { color: var(--text-color) !important; }
body.theme-quickle-light .google-btn { background-color: #FFFFFF !important; color: var(--text-color) !important; border-color: var(--border-color) !important; box-shadow: 0 4px 0 var(--border-color) !important; }
body.theme-quickle-light #player-search-input { caret-color: var(--text-color) !important; background-color: var(--panel-dark) !important; color: var(--text-color) !important; }
body.theme-quickle-light .history-table td:nth-child(2) { color: var(--gold-dark) !important; }
body.theme-quickle-light .word-list-box div { color: var(--text-color) !important; background: var(--panel-dark) !important; border: 1px solid var(--border-color) !important; }
body.theme-quickle-light #accept-c-name { color: var(--text-color) !important; }

/* =========================================
   19. QUICKLE ICON & LEADERBOARD VISIBILITY
   ========================================= */

/* Icons Inherit properly */
body.theme-quickle-light i, body.theme-quickle-dark i { color: inherit; }

/* Force icons on colored action buttons to be White */
body.theme-quickle-light .home-menu-card .hmc-icon i, body.theme-quickle-dark .home-menu-card .hmc-icon i,
body.theme-quickle-light .home-menu-card .hmc-action i, body.theme-quickle-dark .home-menu-card .hmc-action i,
body.theme-quickle-light .primary-btn i, body.theme-quickle-dark .primary-btn i,
body.theme-quickle-light .big-submit-btn i, body.theme-quickle-dark .big-submit-btn i,
body.theme-quickle-light .zen-btn i, body.theme-quickle-dark .zen-btn i,
body.theme-quickle-light .share-btn i, body.theme-quickle-dark .share-btn i,
body.theme-quickle-light .btn-purple i, body.theme-quickle-dark .btn-purple i {
    color: #FFFFFF !important;
}

/* Force icons on light backgrounds to be Dark */
body.theme-quickle-light .header-top-row i,
body.theme-quickle-light .nav-icon-btn,
body.theme-quickle-light .icon-btn i,
body.theme-quickle-light .drawer-item i,
body.theme-quickle-light .lb-menu-icon i {
    color: var(--text-color) !important;
}

/* Special Case: Checkmark on Completed Global Mode card */
body.theme-quickle-light .daily-card.locked .hmc-icon i { color: var(--text-muted) !important; }
body.theme-quickle-dark .daily-card.locked .hmc-icon i { color: var(--text-muted) !important; }

/* Leaderboard Overrides */
body.theme-quickle-light .lb-menu-card { color: var(--text-color) !important; }
body.theme-quickle-light .lb-menu-card.daily-btn, body.theme-quickle-light .lb-menu-card.zen-btn { color: #FFFFFF !important; }
body.theme-quickle-light .lb-menu-card.daily-btn i, body.theme-quickle-light .lb-menu-card.zen-btn i { color: #FFFFFF !important; }

body.theme-quickle-light .lb-row-name { color: var(--text-color) !important; }
body.theme-quickle-light .lb-row-score { color: var(--text-color); }
body.theme-quickle-light .lb-row-score.vocab { color: var(--primary-dark) !important; }
body.theme-quickle-light .lb-row-score.xp, body.theme-quickle-light .lb-row-score.high { color: var(--gold-dark) !important; }

body.theme-quickle-light .back-link { color: var(--text-secondary) !important; }
body.theme-quickle-light .back-link:hover { color: var(--primary-dark) !important; }

/* =========================================
   QUICKLE LIGHT: GAME OVER SCREEN FIXES
   ========================================= */

/* 1. Fix the invisible "Exited" / "Time's Up" modal titles (overrides the JS 'white' style) */
body.theme-quickle-light #modal-title[style*="white"] {
    color: var(--text-color) !important;
}

/* 2. Remove muddy shadows from the Results Cards */
body.theme-quickle-light .results-summary-card,
body.theme-quickle-light .score-split-layout {
    box-shadow: none !important;
}

/* 3. Remove blurry text shadows from the "Best/Missed" words */
body.theme-quickle-light .summary-word {
    text-shadow: none !important;
}

/* 4. Fix the unreadable points pills (e.g., 30 pts, 80 pts) */
body.theme-quickle-light .col-found .summary-pts {
    color: var(--primary-dark) !important;
    background: var(--panel-dark) !important;
}
body.theme-quickle-light .col-missed .summary-pts {
    color: var(--gold-dark) !important;
    background: var(--panel-dark) !important;
}

/* 5. Clean up the "View Full Word Recap" button so it's flat and readable */
body.theme-quickle-light .summary-card-footer {
    background: var(--panel-dark) !important;
    color: var(--text-color) !important;
    border-top: 2px solid var(--border-color) !important;
}
body.theme-quickle-light .summary-card-footer:hover {
    background: var(--border-color) !important;
}

/* 6. Fix the muddy close 'X' button on mobile */
body.theme-quickle-light .modal-close-x {
    background: var(--panel-dark) !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
}
body.theme-quickle-light .modal-close-x:active {
    background: var(--border-color) !important;
    color: var(--danger-base) !important;
}

/* =========================================
   20. QUICKLE SHUFFLE & BACKSPACE FIX
   ========================================= */

/* 1. Make the Shuffle button a chunky flat button with a dark icon */
body.theme-quickle-light #shuffle-btn, 
body.theme-quickle-dark #shuffle-btn {
    background-color: var(--panel-color) !important;
    color: var(--text-color) !important;
    border: 2px solid var(--border-color) !important;
    box-shadow: 0 4px 0 var(--border-color) !important;
    transition: transform 0.1s, box-shadow 0.1s;
}

/* Ensure the SVG graphic matches the text color perfectly */
body.theme-quickle-light #shuffle-btn svg, 
body.theme-quickle-dark #shuffle-btn svg {
    stroke: var(--text-color) !important;
}

body.theme-quickle-light #shuffle-btn:active, 
body.theme-quickle-dark #shuffle-btn:active {
    transform: translateY(4px) !important;
    box-shadow: 0 0 0 transparent !important;
}

/* 2. Make the Backspace button a chunky flat red button */
body.theme-quickle-light #backspace-btn, 
body.theme-quickle-dark #backspace-btn {
    background-color: var(--danger-base) !important;
    color: #FFFFFF !important;
    border: 2px solid var(--danger-dark) !important;
    box-shadow: 0 4px 0 var(--danger-dark) !important;
    transition: transform 0.1s, box-shadow 0.1s;
}

body.theme-quickle-light #backspace-btn:active, 
body.theme-quickle-dark #backspace-btn:active {
    transform: translateY(4px) !important;
    box-shadow: 0 0 0 transparent !important;
}

/* 3. Ensure header text buttons (like the X close button) adapt properly */
body.theme-quickle-light .icon-btn, 
body.theme-quickle-dark .icon-btn {
    color: var(--text-muted) !important;
}
body.theme-quickle-light .icon-btn:hover, 
body.theme-quickle-dark .icon-btn:hover {
    color: var(--primary-base) !important;
}

/* =========================================
   21. HOME SCREEN HEIGHT & SPACING FIXES (Adaptive)
   ========================================= */

/* 1. Base container padding */
#intro-screen {
    padding: 85px 1.5rem 1rem 1.5rem !important; 
    justify-content: flex-start !important;
}

/* 2. FLEX MAGIC: Auto margins push the content into the vertical center 
      ONLY if there is extra space on tall phones. */
.logo-wrapper {
    margin-top: auto !important; /* Pushes down from the top header */
    margin-bottom: clamp(15px, 4vh, 40px) !important; /* Dynamic gap below logo */
}
.intro-actions {
    margin-bottom: auto !important; /* Pushes up from the bottom of the screen */
    gap: 8px !important;
}

/* 3. CLAMP MAGIC: Logo grows on tall screens, stops at 320px. Shrinks on short screens, stops at 180px. */
.logo-wrapper {
    margin-top: auto !important; /* Pushes down from the top header */
    margin-bottom: 5px !important; /* TIGHTENED: Pulls the tagline right up to the image */
}

/* 4. Adaptive gap under the tagline */
.teaser-text {
    font-weight: 900 !important;
    font-style: italic !important;
    font-size: 1.05rem !important;
    color: var(--text-secondary) !important;
    margin-top: 0 !important;
    margin-bottom: clamp(20px, 4vh, 40px) !important; /* Acts as the spring pushing the buttons down */
}

/* =========================================
   22. PAUSE SCREEN SPACING FIX
   ========================================= */
#pause-overlay {
    padding: 0 2rem !important; /* Adds breathing room on the left and right */
}

#pause-overlay #resume-btn {
    width: 100% !important;
    max-width: 340px !important; /* Keeps the button size consistent with the Home screen */
}

/* =========================================
   23. GAME OVER MODAL OVERLAP FIX
   ========================================= */

/* 1. Ensure the modal gives enough room to clear the mobile 'X' button */
@media (max-width: 600px) {
    #game-over-modal .modal-content {
        padding-top: 60px !important; 
    }
}

/* 2. Stop the title row from pulling itself upwards */
.results-header-row {
    margin-top: 0 !important;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 3. Make the title text responsive so it fits perfectly on narrow screens */
#modal-title {
    font-size: clamp(1.4rem, 6.5vw, 1.8rem) !important;
    line-height: 1.1 !important;
    margin: 0 10px !important;
    text-align: center;
}

/* =========================================
   24. BONUS WORD STYLING (Pleasant Gold)
   ========================================= */
.bonus-word-item {
    background: #FEF3C7 !important; /* Soft, sunny yellow background */
    color: #A16207 !important;      /* Deep golden/brown text for contrast */
    border: 2px solid #EAB308 !important; /* Bright gold border */
    font-weight: 800 !important;
}

/* Ensure it glows nicely on dark backgrounds */
body.theme-quickle-dark .bonus-word-item,
body.theme-default .bonus-word-item,
body.theme-matcha-dark .bonus-word-item {
    background: rgba(234, 179, 8, 0.15) !important;
    color: #FDE047 !important; 
    border: 2px solid #EAB308 !important;
}

/* =========================================
   25. ZEN PROGRESS BUTTON AFFORDANCE
   ========================================= */

/* Make the letter cards look like chunky, clickable buttons */
.zen-letter-card {
    border-radius: 12px !important;
    border: 2px solid var(--border-color) !important;
    box-shadow: 0 4px 0 var(--border-color) !important;
    transition: transform 0.1s, box-shadow 0.1s;
}

/* Add the satisfying "press" animation when clicked */
.zen-letter-card:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 transparent !important;
}

/* Disable the animation if they are out of hints */
.zen-letter-card.no-hints:active {
    transform: none;
    box-shadow: 0 4px 0 var(--border-color) !important;
}

/* If a letter is completely finished, make it look "pressed down" and flat */
.zen-letter-card.finished {
    border: 2px solid var(--success-base) !important;
    box-shadow: none !important;
    transform: translateY(4px);
}

/* =========================================
   26. LIGHT MODE TIMER PULSE
   ========================================= */
@keyframes dangerPulseLight {
    0% { background-color: var(--panel-dark); border-color: var(--border-color); }
    50% { background-color: rgba(239, 68, 68, 0.15); border-color: var(--danger-base); box-shadow: inset 0 2px 5px rgba(0,0,0,0.05), 0 0 20px rgba(239, 68, 68, 0.3); }
    100% { background-color: var(--panel-dark); border-color: var(--border-color); }
}

body.theme-quickle-light .timer-warning {
    animation: dangerPulseLight 1s infinite !important;
}


/* =========================================
   27. QUICKLE: GOLDEN DIE & PRESSED STATES
   ========================================= */

/* 1. Revert to the clean, dark dill Golden Die */
body.theme-quickle-light .golden-die,
body.theme-quickle-dark .golden-die {
    background-color: var(--dill-light, #4D7C0F) !important;
    background-image: none !important; /* Removes the texture */
    color: var(--dill-text, #ECFCCB) !important;
    border: 2px solid var(--dill-base, #365314) !important;
    box-shadow: 0 4px 0 var(--dill-base, #365314) !important;
    text-shadow: none !important;
}

/* 2. Standard Die - PRESSED / USED State */
body.theme-quickle-light .die.used, 
body.theme-quickle-light .die:active {
    background-color: #E2E8F0 !important; /* Distinct grey so it looks pressed */
    color: var(--text-muted) !important;
    box-shadow: 0 0 0 transparent !important;
    transform: translateY(4px) !important;
}

body.theme-quickle-dark .die.used, 
body.theme-quickle-dark .die:active {
    background-color: var(--panel-dark) !important; 
    color: var(--text-muted) !important;
    box-shadow: 0 0 0 transparent !important;
    transform: translateY(4px) !important;
}

/* 3. Golden Die - PRESSED / USED State */
body.theme-quickle-light .golden-die.used,
body.theme-quickle-light .golden-die:active,
body.theme-quickle-dark .golden-die.used,
body.theme-quickle-dark .golden-die:active {
    background-color: var(--dill-base, #365314) !important; /* Darkens the green */
    color: rgba(255, 255, 255, 0.6) !important;
    box-shadow: 0 0 0 transparent !important;
    transform: translateY(4px) !important;
}


/* =========================================
   28. FOUND WORDS READABILITY FIX (Light Mode)
   ========================================= */
body.theme-quickle-light #word-list li {
    color: var(--primary-dark) !important; /* Uses the darker, legible green */
    background: var(--panel-dark) !important; /* Slightly deeper grey for the pill */
    border: 1px solid var(--border-color) !important; /* Adds a crisp edge */
}

/* =========================================
   29. MODERN SETTINGS UI
   ========================================= */

/* Card Containers */
.settings-card {
    background: var(--panel-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: left;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.settings-card-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 1px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-medium);
}
.settings-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Modern iOS-Style Toggles */
.modern-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}
.modern-toggle input {
    opacity: 0; width: 0; height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--panel-dark);
    border: 2px solid var(--border-color);
    transition: .3s;
    border-radius: 34px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 50%;
}
.modern-toggle input:checked + .toggle-slider {
    background-color: var(--primary-base);
    border-color: var(--primary-dark);
}
.modern-toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: #ffffff;
}

/* Modern Mobile Select Dropdowns */
select.modern-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: var(--panel-dark) url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23888888%22%20stroke-width%3D%223%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E") no-repeat right 12px center;
    background-size: 16px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-color);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    outline: none;
    cursor: pointer;
}
select.modern-select:focus {
    border-color: var(--primary-base);
}

/* Segmented Control (Pill Tabs) */
.segmented-control {
    display: flex;
    background: var(--panel-dark);
    border-radius: 12px;
    padding: 4px;
    border: 2px solid var(--border-color);
    width: 100%;
}
.segmented-control label {
    flex: 1;
    text-align: center;
    cursor: pointer;
}
.segmented-control input { display: none; }
.segmented-btn {
    display: block;
    padding: 10px;
    border-radius: 8px;
    font-weight: 800;
    color: var(--text-muted);
    transition: all 0.2s;
}
.segmented-control input:checked + .segmented-btn {
    background: var(--panel-color);
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
}


/* =========================================
   30. QUICKLE: VERSUS COMPARISON FIX
   ========================================= */
body.theme-quickle-light .vs-comparison-box {
    background: var(--panel-dark) !important;
    border: 1px solid var(--border-color) !important;
}
body.theme-quickle-light .vs-comp-label,
body.theme-quickle-dark .vs-comp-label {
    color: var(--text-muted) !important;
}
body.theme-quickle-light .vs-pts-pill,
body.theme-quickle-dark .vs-pts-pill {
    color: var(--text-color) !important;
    background: var(--bg-color) !important;
    border: 1px solid var(--border-color) !important;
}

/* =========================================
   31. ADAPTIVE BONUS TEXT
   ========================================= */
.bonus-die-text {
    color: var(--gold-base);
    font-weight: bold;
}

body.theme-quickle-light .bonus-die-text,
body.theme-quickle-dark .bonus-die-text {
    color: var(--dill-light, #4D7C0F) !important;
}

/* =========================================
   REUSABLE SUCCESS BANNER CARD
   ========================================= */
.success-banner-card {
    background: rgba(46, 204, 113, 0.15);
    border: 2px solid var(--success-base);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-bottom: 15px;
}
.sbc-title {
    font-size: 1.3rem;
    color: var(--success-base);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sbc-desc {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-top: 5px;
}

/* PWA Install Toast Animation (Bulletproof Bottom Slide) */
@keyframes toastSlideUp {
    0% { opacity: 0; bottom: -100px; }
    100% { opacity: 1; bottom: 20px; }
}

/* =========================================
   BOTTOM SHEETS (Native UI)
   ========================================= */
.bottom-sheet-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6); z-index: 5500;
    opacity: 0; transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}
.bottom-sheet-overlay.visible { opacity: 1; }

.bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto;
    width: 100%; max-width: 600px;
    background: var(--panel-color); border-top: 1px solid var(--border-color);
    border-radius: 24px 24px 0 0; padding: 20px 25px 35px 25px;
    z-index: 5600; 
    transform: translateY(calc(100% + 60px)); /* <-- THIS IS THE FIX */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1); /* Slight bounce */
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
    width: 40px; height: 5px; background: var(--border-color);
    border-radius: 3px; margin: 0 auto 15px auto;
}
.sheet-close-x {
    position: absolute; top: 15px; right: 15px;
    background: var(--panel-dark); color: var(--text-muted);
    border: none; border-radius: 50%; width: 32px; height: 32px;
    font-size: 1.2rem; display: flex; justify-content: center; align-items: center;
    cursor: pointer;
}
.sheet-close-x:active { background: var(--border-color); color: var(--text-color); }

/* =========================================
   32. SAFE AREA INSETS (Notch & Home Bar)
   ========================================= */

/* Top Notch Padding (Headers) */
.home-navbar { padding-top: calc(15px + env(safe-area-inset-top)); }
.game-header { padding-top: calc(15px + env(safe-area-inset-top)); }
.drawer-header { padding-top: calc(20px + env(safe-area-inset-top)); }
.challenge-header-container { padding-top: calc(25px + env(safe-area-inset-top)); }
.lb-detail-header { padding-top: calc(15px + env(safe-area-inset-top)); }

/* Bottom Swipe Bar Padding (Footers) */
#intro-screen { padding-bottom: calc(2rem + env(safe-area-inset-bottom)) !important; }
.game-footer { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
.dashboard-footer { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
.drawer-footer { padding-bottom: calc(15px + env(safe-area-inset-bottom)); }
.bottom-sheet { padding-bottom: calc(35px + env(safe-area-inset-bottom)); }
#pwa-install-toast { bottom: calc(20px + env(safe-area-inset-bottom)) !important; }

/* Mobile Full-Screen Modals */
@media (max-width: 600px) {
    .modal-content {
        padding-top: calc(50px + env(safe-area-inset-top)) !important;
        padding-bottom: calc(50px + env(safe-area-inset-bottom)) !important;
    }
    .modal-close-x {
        top: calc(15px + env(safe-area-inset-top)) !important;
    }
    #game-over-modal .modal-content {
        padding-top: calc(60px + env(safe-area-inset-top)) !important;
    }
}

/* =========================================
   33. TABULAR NUMERALS (Anti-Jitter)
   ========================================= */
#timer, #score, #game-target-score, .stat-val, 
.vs-score-large, .final-score-compact, .lb-row-score,
.b-val-compact, .recap-metric-val, .summary-pts, 
#zv-time, .hub-notification-badge, .section-badge {
    font-variant-numeric: tabular-nums;
}

/* =========================================
   34. PLAYFUL UX (Juice)
   ========================================= */

   /* The Arcade "Time's Up" Flash */
@keyframes timeFlashAnim {
    0% { background-color: rgba(255,255,255,1); }
    30% { background-color: rgba(255,255,255,1); } /* Hold solid white for 300ms */
    100% { background-color: rgba(255,255,255,0); } /* Smoothly fade out */
}
.time-up-flash::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999; /* This sits above EVERYTHING, allowing the modal to render invisibly underneath */
    pointer-events: none;
    animation: timeFlashAnim 1s ease-out forwards;
}


/* Physics: Pop up big, then fly towards the score bank and shrink */
@keyframes flyToScore {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, calc(-50% - 40px)) scale(1.2); opacity: 1; }
    80% { transform: translate(calc(-50% + var(--end-x)), calc(-50% + var(--end-y))) scale(0.8); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--end-x)), calc(-50% + var(--end-y))) scale(0.5); opacity: 0; }
}

/* Floating Point Trails (Cleaned for JS Physics) */
/* Floating Point Trails (Cleaned for JS Physics) */
.floating-score-pop {
    position: fixed;
    top: 0; left: 0; /* <-- CRITICAL: Start at window 0,0 so JS coordinates work */
    z-index: 9999;
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-base);
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
    pointer-events: none;
    user-select: none;
    will-change: transform, opacity;
}

/* Tiny Burst Particles */
.score-particle {
    position: fixed;
    top: 0; left: 0; /* <-- CRITICAL: Start at window 0,0 */
    z-index: 9998;
    font-size: 1.2rem;
    pointer-events: none;
    will-change: transform, opacity;
}
.floating-score-pop.golden-pop {
    color: var(--gold-base);
    text-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
    font-size: 2.5rem;
}


/* The "Receipt" that stays by the score bank */
.score-receipt {
    position: absolute;
    right: -40px; top: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold-base);
    animation: fadeOutUp 1s ease-out forwards;
    pointer-events: none;
}

@keyframes fadeOutUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* =========================================
   35. PICKLE RANK AVATAR FRAMES
   ========================================= */
/* Rank 0: Novice Cucumber (Simple Light Green) */
.avatar-rank-0 { 
    border: 3px solid var(--success-light) !important; 
} 
/* Rank 1: Crispy Cornichon (Dashed Green) */
.avatar-rank-1 { 
    border: 3px dashed var(--success-base) !important; 
} 
/* Rank 2: Dill Enthusiast (Solid Dark Green + Soft Glow) */
.avatar-rank-2 { 
    border: 4px solid var(--success-dark) !important; 
    box-shadow: 0 0 10px var(--success-base) !important; 
} 
/* Rank 3: Brine Master (Blue/Green Brine + Deep Glow) */
.avatar-rank-3 { 
    border: 4px solid var(--primary-base) !important; 
    box-shadow: inset 0 0 5px var(--primary-dark), 0 0 15px var(--primary-dark) !important; 
} 
/* Rank 4: Grand Gherkin (Pulsing Gold) */
.avatar-rank-4 { 
    border: 4px solid var(--gold-base) !important; 
    box-shadow: 0 0 20px var(--gold-base) !important; 
    animation: pulse-border 2s infinite !important; 
}

/* =========================================
   36. AVATAR SHOP
   ========================================= */
.avatar-shop-wrapper {
    position: relative;
    width: 50px; height: 50px;
    cursor: pointer;
    transition: transform 0.1s;
}
.avatar-shop-wrapper:active { transform: scale(0.9); }

.avatar-shop-wrapper.locked .gallery-avatar {
    filter: grayscale(100%) brightness(0.5);
    opacity: 0.6;
    border-color: var(--border-color) !important;
}

.avatar-shop-wrapper .avatar-cost-badge { display: none; }

.avatar-shop-wrapper.locked .avatar-cost-badge {
    display: flex; position: absolute;
    bottom: -8px; left: 50%; transform: translateX(-50%);
    background: var(--panel-dark);
    border: 1px solid var(--success-base);
    color: var(--success-base);
    font-size: 0.65rem; font-weight: 900;
    padding: 2px 6px; border-radius: 10px;
    white-space: nowrap; z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.avatar-shop-wrapper.locked::after {
    content: '🔒';
    position: absolute;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem; z-index: 2;
}