/* Modern Clean Font Stack */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=JetBrains+Mono:wght@400;700&display=swap');

/* Add this at the very top of style.css */
*, *::before, *::after {
    box-sizing: border-box;
}
:root {
    /* Default Light Theme Palette */
    --bg: #ffffff;
    --surface: #f3f4f6;
    --text: #111827;
    --text-sub: #6b7280;
    --hud-bg: rgba(255, 255, 255, 0.85);
    --overlay-bg: rgba(255, 255, 255, 0.96);
    --btn-bg: #ffffff;
    --btn-border: rgba(0,0,0,0.15);
    
    --primary: #2563eb; /* Royal Blue */
    --secondary: #db2777; /* Deep Pink */
    --accent: #d97706; /* Amber */
    
    --glass: rgba(0, 0, 0, 0.04);
    --glass-border: rgba(0, 0, 0, 0.08);
    
    --valid-word: #059669; /* Emerald */
    --danger: #dc2626; /* Red */
    --overdrive: #7c3aed; /* Violet */
    
    --zone-color: #0891b2;
    --glitch-color: #be123c;
    --unstable-color: #f59e0b;
    --bloom-color: #4f46e5;
    --gold: #b45309;
    --stone: #475569; /* Slate 600 */
}

/* DARK THEME OVERRIDES */
[data-theme="dark"] {
    --bg: #111827; /* Gray 900 */
    --surface: #1f2937; /* Gray 800 */
    --text: #f9fafb; /* Gray 50 */
    --text-sub: #9ca3af; /* Gray 400 */
    --hud-bg: rgba(17, 24, 39, 0.85); /* Dark transparent */
    --overlay-bg: rgba(17, 24, 39, 0.96);
    --btn-bg: #1f2937;
    --btn-border: rgba(255,255,255,0.15);
    
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --stone: #334155; /* Slate 700 */
}

/* ========================================
   RETRO VECTOR THEME
   Inspired by Tempest, Battlezone, Asteroids
   ======================================== */
[data-theme="retro"] {
    --bg: #000000;
    --surface: #0a0a0a;
    --text: #00ff41;
    --text-sub: #00aa2a;
    --hud-bg: rgba(0, 0, 0, 0.92);
    --overlay-bg: rgba(0, 0, 0, 0.97);
    --btn-bg: #000000;
    --btn-border: #00ff41;
    
    --primary: #00ffff;
    --secondary: #ff00ff;
    --accent: #ffff00;
    
    --glass: rgba(0, 255, 65, 0.06);
    --glass-border: rgba(0, 255, 65, 0.25);
    
    --valid-word: #00ff41;
    --danger: #ff0040;
    --overdrive: #ff00ff;
    
    --zone-color: #00ffff;
    --glitch-color: #ff0040;
    --unstable-color: #ffff00;
    --bloom-color: #8000ff;
    --gold: #ffff00;
    --stone: #404040;
}

/* RETRO: CRT scanline overlay — REMOVED for cleaner retro look */

/* RETRO: CRT vignette */
[data-theme="retro"] #canvas-container::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    z-index: 10;
}

/* RETRO: Glow on text elements */
[data-theme="retro"] .title-text {
    color: #00ffff !important;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff, 0 0 40px #004444;
    font-family: 'JetBrains Mono', monospace !important;
    letter-spacing: 4px;
}

[data-theme="retro"] .title-sub {
    color: #00ff41 !important;
    text-shadow: 0 0 8px #00ff41;
    font-family: 'JetBrains Mono', monospace !important;
}

/* RETRO: All buttons become wireframe */
[data-theme="retro"] .btn {
    background: transparent !important;
    border: 1px solid #00ff41 !important;
    color: #00ff41 !important;
    font-family: 'JetBrains Mono', monospace !important;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 6px currentColor;
    transition: all 0.15s ease;
    position: relative;
}

[data-theme="retro"] .btn:hover,
[data-theme="retro"] .btn:active {
    background: rgba(0, 255, 65, 0.1) !important;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3), inset 0 0 15px rgba(0, 255, 65, 0.1);
}

/* RETRO: Keep small/sub text readable on hover */
[data-theme="retro"] .btn small {
    color: inherit !important;
    opacity: 0.7 !important;
}

[data-theme="retro"] .btn .high-score-display {
    color: #ffff00 !important;
    text-shadow: 0 0 4px #ffff00;
    opacity: 1 !important;
}

/* RETRO: Override the default hover rule that sets text to --bg (black) */
[data-theme="retro"] .btn:hover .high-score-display {
    color: #ffff00 !important;
    border-color: rgba(255, 255, 0, 0.3) !important;
    opacity: 1 !important;
}

/* RETRO: Fix coffee button text on hover — inline white gets overridden */
[data-theme="retro"] .btn:hover small,
[data-theme="retro"] .btn:active small {
    color: inherit !important;
}

/* RETRO: Fix inline-styled span/small inside buttons (e.g. Coffee button) */
[data-theme="retro"] .btn span,
[data-theme="retro"] .btn:hover span {
    color: inherit !important;
}

/* RETRO: Fix Coffee button (a.btn) — inline color fights with hover */
[data-theme="retro"] a.btn,
[data-theme="retro"] a.btn:hover,
[data-theme="retro"] a.btn:active,
[data-theme="retro"] a.btn:visited {
    color: #ff5e5b !important;
    border-color: #ff5e5b !important;
    text-shadow: 0 0 6px #ff5e5b;
}

[data-theme="retro"] a.btn:hover small,
[data-theme="retro"] a.btn small {
    color: #ff5e5b !important;
    opacity: 0.8 !important;
}

/* RETRO: Mode buttons with specific colors */
[data-theme="retro"] .btn-overdrive {
    border-color: #ff00ff !important;
    color: #ff00ff !important;
}
[data-theme="retro"] .btn-timed {
    border-color: #00ffff !important;
    color: #00ffff !important;
}
[data-theme="retro"] .btn-blitz {
    border-color: #ffff00 !important;
    color: #ffff00 !important;
}
[data-theme="retro"] .btn-surge {
    border-color: #ff6600 !important;
    color: #ff6600 !important;
}
[data-theme="retro"] .btn-chain {
    border-color: #ff0040 !important;
    color: #ff0040 !important;
}
[data-theme="retro"] .btn-blackout {
    border-color: #cc66ff !important;
    color: #cc66ff !important;
}
[data-theme="retro"] .btn-puzzle {
    border-color: #00ff88 !important;
    color: #00ff88 !important;
}

/* RETRO: High score display */
[data-theme="retro"] .high-score-display {
    color: #ffff00 !important;
    text-shadow: 0 0 4px #ffff00;
}

/* RETRO: HUD Panel */
[data-theme="retro"] .side-hud {
    background: rgba(0, 0, 0, 0.9) !important;
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.1);
}

[data-theme="retro"] .stat-label {
    color: #00ffff !important;
    text-shadow: 0 0 4px #00ffff;
}

[data-theme="retro"] .stat-val {
    color: #00ff41 !important;
    text-shadow: 0 0 4px #00ff41;
}

/* RETRO: System alert box */
[data-theme="retro"] #sys-alert-box {
    background: rgba(0, 0, 0, 0.9) !important;
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
}

[data-theme="retro"] #sys-status-header {
    color: #00ffff !important;
    text-shadow: 0 0 6px #00ffff;
}

/* RETRO: Overdrive meter */
[data-theme="retro"] #overdrive-container {
    border: 1px solid #ff00ff !important;
    background: rgba(0, 0, 0, 0.8) !important;
}

[data-theme="retro"] #overdrive-fill {
    background: #ff00ff !important;
    box-shadow: 0 0 10px #ff00ff;
}

[data-theme="retro"] #overdrive-label {
    color: #ff00ff !important;
    text-shadow: 0 0 6px #ff00ff;
}

/* RETRO: Controls hint */
[data-theme="retro"] #controls-hint {
    color: #00aa2a !important;
    text-shadow: 0 0 3px #00aa2a;
}

[data-theme="retro"] .key-bind {
    border-color: #00ff41 !important;
    color: #00ff41 !important;
}

/* RETRO: Mobile buttons */
[data-theme="retro"] .mobile-control-btn {
    background: rgba(0, 0, 0, 0.85) !important;
    border: 1px solid #00ff41 !important;
    color: #00ff41 !important;
    text-shadow: 0 0 6px #00ff41;
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}

/* RETRO: Canvas container */
[data-theme="retro"] #canvas-container {
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.5);
    background: #000000 !important;
}

/* RETRO: Overlay screens */
[data-theme="retro"] .overlay {
    background: rgba(0, 0, 0, 0.97) !important;
}

/* RETRO: Profile/Leaderboard modals */
[data-theme="retro"] .p-stat-box {
    background: transparent !important;
    border: 1px solid rgba(0, 255, 65, 0.3) !important;
}

[data-theme="retro"] .p-label {
    color: #00ffff !important;
    text-shadow: 0 0 3px #00ffff;
}

[data-theme="retro"] .p-val {
    color: #00ff41 !important;
    text-shadow: 0 0 6px #00ff41;
}

/* RETRO: Cookie consent */
[data-theme="retro"] #cookie-consent-banner {
    border-color: #00ff41 !important;
}

/* RETRO: Auth modal */
[data-theme="retro"] #auth-modal input {
    background: #000000 !important;
    border-color: #00ff41 !important;
    color: #00ff41 !important;
    font-family: 'JetBrains Mono', monospace !important;
}

/* RETRO: Settings grid */
[data-theme="retro"] .settings-grid {
    border-color: rgba(0, 255, 65, 0.2) !important;
}

[data-theme="retro"] .setting-label {
    color: #00ffff !important;
}

/* RETRO: Flicker animation for title */
[data-theme="retro"] .title-text {
    animation: retro-flicker 4s infinite;
}

@keyframes retro-flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.8; }
    94% { opacity: 1; }
    96% { opacity: 0.9; }
    97% { opacity: 1; }
}

/* RETRO: Enemy HP bar */
[data-theme="retro"] #enemy-hp-container {
    border-color: #ff0040 !important;
}

[data-theme="retro"] .enemy-hp-bar-bg {
    background: #1a0000 !important;
    border: 1px solid #ff0040 !important;
}

[data-theme="retro"] #enemy-hp-fill {
    background: #ff0040 !important;
    box-shadow: 0 0 8px #ff0040;
}

/* RETRO: Game over screen */
[data-theme="retro"] #final-score-val {
    color: #00ffff !important;
    text-shadow: 0 0 15px #00ffff, 0 0 30px #004444;
    font-family: 'JetBrains Mono', monospace !important;
}

/* RETRO: Loading screen */
[data-theme="retro"] .loader {
    border-color: #001a00 !important;
    border-top-color: #00ff41 !important;
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

/* RETRO: Zen keyboard */
[data-theme="retro"] #zen-keyboard button {
    background: transparent !important;
    border: 1px solid #00ff41 !important;
    color: #00ff41 !important;
}

/* RETRO: Small text glow */
[data-theme="retro"] small {
    text-shadow: 0 0 3px currentColor;
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    width: 100%;
    position: fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
    
    /* Safe area handling */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
    
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#canvas-container {
    position: relative;
    /* FIX: Reserved space (120px) so the bottom bars don't overlap the game grid */
    height: calc(100dvh - 120px);
    width: auto;
    max-width: 100%;
    aspect-ratio: 440 / 620;
    
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    cursor: none;
    z-index: 5;
    background: var(--bg);
    transition: background-color 0.3s ease;
}

/* Fullscreen Helper Class */
body.is-fullscreen #canvas-container {
    border-radius: 0;
    border: none;
    /* Maintain the reserved space even in fullscreen */
    max-height: calc(100dvh - 120px);
    max-width: 100vw;
    box-shadow: none;
}

canvas { 
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none; 
}

/* --- UI LAYER --- */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    padding: 0;
    box-sizing: border-box;
}

.side-hud {
    position: absolute;
    /* FIXED: Positioned safely at the bottom, above the controls */
    top: auto; 
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    max-width: 95%; 
    display: none;
    flex-direction: row; 
    align-items: center;
    justify-content: center;
    gap: 15px;
    
    background: var(--hud-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 6px 15px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    pointer-events: none;
    transition: opacity 0.4s ease, background-color 0.3s ease;
    white-space: nowrap;
    z-index: 16;
}

.stat-row {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 5px;
}

.stat-label { font-weight: 700; color: var(--primary); }
.stat-val { color: var(--text); font-weight: 600; }
.hud-divider { width: 1px; height: 15px; background: var(--text-sub); opacity: 0.3; }

.extra-stat {
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 5px;
}
.extra-stat label { font-size: 0.65rem; color: var(--text-sub); letter-spacing: 0; }
.extra-stat span { font-size: 0.75rem; color: var(--text); font-weight: 700; }

#sys-alert-box {
    position: absolute;
    top: 75px; 
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 200px;
    text-align: center;
    border: none;
    border-bottom: 2px solid var(--danger);
    padding-bottom: 5px;
    background: transparent;
    display: none; 
}

#sys-status-header {
    font-family: 'JetBrains Mono'; font-size: 0.7rem; color: var(--text-sub);
    border: none; margin-bottom: 2px; display: flex; justify-content: center; gap: 10px;
}

#sys-timer { color: var(--text); font-weight: 700; }
.sys-row { font-size: 0.85rem; font-family: 'JetBrains Mono'; letter-spacing: -0.5px; margin-bottom: 2px; font-weight: 600; }
.status-normal { color: var(--valid-word); }
.status-blocked { color: var(--danger); animation: pulse-warning 1.5s infinite; } 
.status-danger { color: var(--danger); animation: flash 0.7s infinite; }
.lift-req { color: var(--accent); font-size: 0.7rem; }

.status-wotd { color: var(--gold); border-bottom-color: var(--gold) !important; }

#overdrive-container {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
    width: 300px; height: 6px; background: rgba(0,0,0,0.05);
    display: none; border-radius: 3px; overflow: hidden;
}
#overdrive-fill {
    width: 0%; height: 100%; background: var(--overdrive);
    transition: width 0.1s linear;
}
#overdrive-label {
    position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
    font-family: 'Inter'; font-weight: 800; font-size: 0.8rem; color: var(--overdrive);
    display: none; letter-spacing: 1px;
}

/* Enemy HP Bar for Spellbound Mode */
#enemy-hp-container {
    display: none; position: absolute; top: 70px; left: 50%; transform: translateX(-50%); 
    width: 300px; text-align: center;
}
.enemy-hp-title {
    font-family: 'JetBrains Mono'; font-size: 0.8rem; color: var(--danger); margin-bottom: 4px; font-weight: 700;
}
.enemy-hp-bar-bg {
    width: 100%; height: 10px; background: rgba(0,0,0,0.1); border-radius: 5px; 
    overflow: hidden; border: 1px solid var(--danger);
}
#enemy-hp-fill {
    width: 100%; height: 100%; background: var(--danger); transition: width 0.3s ease;
}
#enemy-stats {
    font-family: 'JetBrains Mono'; font-size: 0.7rem; color: var(--text-sub); margin-top: 2px;
}
#enemy-status-msg {
    color: var(--accent); font-weight: 700; font-size: 0.8rem; height: 1rem; margin-top: 2px;
}

@keyframes flash { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
@keyframes pulse-warning { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

#controls-hint {
    position: absolute; 
    bottom: 10px; /* Slight bump up */
    left: 50%; transform: translateX(-50%);
    width: 100%; text-align: center;
    font-size: 0.6rem;
    color: var(--text-sub);
    background: transparent; 
    padding: 0; border: none;
    font-family: 'JetBrains Mono'; 
    display: flex; justify-content: center; gap: 15px;
    opacity: 0.7;
    pointer-events: none;
    z-index: 15;
}

.key-bind {
    color: var(--text); font-weight: 600; border: 1px solid var(--glass-border);
    background: var(--surface);
    padding: 1px 5px; border-radius: 4px; margin-left: 4px; 
    font-size: 0.55rem; display: inline-block;
}

.overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    background: var(--overlay-bg);
    display: flex; flex-direction: column; 
    z-index: 20; pointer-events: auto; backdrop-filter: blur(10px); cursor: default; 
    transition: background-color 0.3s ease;
}

#start-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.title-text {
    font-family: 'Inter', sans-serif; font-size: 3rem; font-weight: 900;
    color: var(--text);
    letter-spacing: -2px;
    margin-bottom: 20px;
    text-align: center;
    flex-shrink: 0;
    line-height: 0.9;
}

.title-sub {
    font-size: 1rem; margin-top: 5px; color: var(--text-sub); font-weight: 400; letter-spacing: 0; font-family: 'JetBrains Mono';
}

.mode-container { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    width: 95%; 
    max-width: 500px;
    overflow-y: auto;
    overflow-x: hidden; 
    max-height: 100%; 
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--text-sub) transparent;
}

.btn {
    background: var(--btn-bg); 
    border: 1px solid var(--btn-border); 
    color: var(--text);
    padding: 12px 5px; 
    font-family: 'Inter', sans-serif; 
    font-weight: 700;
    font-size: 0.9rem; 
    cursor: pointer; 
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; 
    text-transform: uppercase; 
    border-radius: 8px;
    width: 100%; text-align: center; position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    min-height: 70px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.btn:hover, .btn:focus, .btn.gamepad-selected { 
    background: var(--text); 
    color: var(--bg); 
    border-color: var(--text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); 
    transform: translateY(-2px); 
    outline: none; 
}

.btn small { 
    display: block; font-size: 0.65em; font-family: 'JetBrains Mono'; 
    opacity: 0.6; margin-top: 4px; text-transform: none; line-height: 1.1; font-weight: 400;
}

.btn:hover small, .btn:focus small, .btn.gamepad-selected small { opacity: 0.9; }

/* Mode Specific Borders/Colors */
#btn-daily-seed { border: 2px solid #f59e0b; border-bottom: 3px solid #f59e0b; }
#btn-daily-seed small { opacity: 0.85; color: #f59e0b; font-weight: 600; }
.btn-overdrive { border-bottom: 3px solid var(--overdrive); }
.btn-timed { border-bottom: 3px solid var(--primary); }
.btn-blitz { border-bottom: 3px solid var(--secondary); }
.btn-surge { border-bottom: 3px solid var(--danger); }
.btn-chain { border-bottom: 3px solid var(--unstable-color); }
.btn-blackout { border-bottom: 3px solid var(--text); }
.btn-puzzle { border-bottom: 3px solid var(--bloom-color); }

.high-score-display {
    font-family: 'JetBrains Mono'; font-size: 0.7rem; color: var(--text-sub);
    margin-top: 6px;
    border-top: 1px solid rgba(0,0,0,0.05); width: 60%;
    padding-top: 4px; font-weight: 600;
}

.btn:hover .high-score-display { 
    color: var(--bg) !important;
    opacity: 0.7; 
    border-color: var(--bg);
}

.loader {
    width: 40px; height: 40px; border: 4px solid var(--glass-border); border-top: 4px solid var(--text);
    border-radius: 50%; margin-bottom: 20px; animation: spin 1s linear infinite;
}

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

/* GAME OVER SCREEN FIXES */
#game-over { 
    background: rgba(0,0,0,0); 
    transition: background 2s ease; 
    justify-content: center;
    align-items: center;
    z-index: 1000 !important;
}
#game-over.visible { background: var(--overlay-bg); }

#game-over-content { 
    opacity: 0; 
    transform: translateY(20px); 
    transition: opacity 2s ease, transform 2s ease;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    text-align: center; /* [FIX] Ensures all child text is centered, not just flex-aligned */
}
#game-over-content.visible { opacity: 1; transform: translateY(0); }

/* SHARE BUTTONS SPECIFIC FIXES */
#game-over .btn {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    min-height: 50px;
    margin: 3px;
}

/* Share button row container */
#game-over > #game-over-content > div[style*="display: flex"] {
    display: flex !important;
    flex-direction: row;
    gap: 8px !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    width: 100% !important;
    max-width: 300px !important;
    justify-content: center;
    align-items: center;
}

/* Individual share buttons */
#game-over .btn[style*="flex: 1"] {
    flex: 1 !important;
    min-width: 70px !important;
    height: 55px !important;
    min-height: 55px !important;
    margin: 0 !important;
    padding: 5px 4px !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-over .btn[style*="flex: 1"] span {
    font-size: 1.1rem !important;
}

#game-over .btn[style*="flex: 1"] small {
    font-size: 0.55rem !important;
    margin-top: 1px !important;
}

/* Specific share button IDs */
#btn-share-native,
#btn-copy-score {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    z-index: 1001 !important;
}

/* Ensure all buttons in game-over are visible */
#game-over button {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

.settings-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
    width: 90%; max-width: 400px; margin-bottom: 10px;
}
.setting-label { font-family: 'JetBrains Mono'; text-align: left; align-self: center; color: var(--text-sub); font-size: 0.8rem; }

.btn.setting-btn { 
    font-size: 0.75rem !important; 
    padding: 4px 8px !important; 
    min-height: 32px !important; 
    height: auto;
    border-color: var(--glass-border);
}

.rebind-active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* --- MOBILE CONTROLS (Updated for Layout) --- */
.mobile-control-btn {
    position: absolute; 
    width: 65px; 
    height: 65px; 
    border-radius: 50%;
    background: var(--surface); 
    border: 1px solid var(--glass-border);
    color: var(--text); 
    font-family: 'Inter'; 
    font-weight: 800; 
    font-size: 1.5rem;
    display: none; 
    justify-content: center; 
    align-items: center;
    z-index: 100; 
    backdrop-filter: blur(4px); 
    pointer-events: auto;
    user-select: none; 
    touch-action: manipulation;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.mobile-control-btn:active { background: var(--text); color: var(--bg); transform: scale(0.95); }

/* Drop Button: Bottom Right, above HUD/Controls */
#mobile-drop-btn { 
    top: auto; 
    bottom: 130px; 
    right: 20px; 
}

/* Pause Button: Bottom Left, above HUD/Controls (Symmetrical) */
#mobile-pause-btn { 
    top: auto;
    bottom: 130px;
    left: 20px; 
    color: var(--text-sub); 
    width: 50px; /* Slightly smaller pause button */
    height: 50px;
    font-size: 1rem;
}

#zen-keyboard { display: none; }

/* Add to style.css */
input::placeholder {
    color: var(--text-sub);
    opacity: 0.7;
}

input:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

/* Add to style.css */

a.btn {
    text-decoration: none; /* Removes the link underline */
    display: flex;         /* Ensures flexbox alignment works like buttons */
}

a.btn:hover {
    color: var(--bg) !important; /* Ensures text turns white/dark on hover */
    background: #FF5E5B;         /* Ko-fi Red background on hover */
    border-color: #FF5E5B;
}

a.btn:hover small {
    color: var(--bg) !important; /* Ensures sub-text is readable on hover */
}

/* New About Menu Styling */
.about-text-container {
    width: 90%;
    max-width: 500px;
    text-align: left;
    font-family: 'JetBrains Mono';
    font-size: 0.8rem;
    color: var(--text-sub);
    line-height: 1.5;
    background: var(--surface);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    margin-bottom: 20px;
}
.about-text-container p { margin-bottom: 15px; }
.about-text-container a { color: var(--primary); text-decoration: none; border-bottom: 1px solid var(--primary); }

/* Leaderboard Navigation Arrows */
.lb-nav-arrow {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    font-family: Arial, sans-serif;
}

.lb-nav-arrow:hover {
    background: var(--primary);
    color: var(--bg);
    border-color: var(--primary);
}

.lb-nav-arrow:active {
    transform: scale(0.95);
}

.lb-nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- DESKTOP COMPACT LAYOUT --- */
@media (min-width: 601px) {
    .title-text {
        font-size: 2.4rem;
        margin-bottom: 12px;
    }
    .title-sub {
        font-size: 0.85rem;
        margin-top: 3px;
    }
    .mode-container {
        gap: 8px;
        padding: 6px;
        max-width: 460px;
    }
    .btn {
        min-height: 52px;
        padding: 8px 5px;
        font-size: 0.82rem;
    }
    .btn small {
        font-size: 0.6em;
        margin-top: 2px;
    }
    .high-score-display {
        font-size: 0.62rem;
        margin-top: 4px;
        padding-top: 3px;
    }
    #start-screen {
        padding: 12px;
    }

    /* Pause menu compact */
    #pause-menu h1.title-text {
        font-size: 1.8rem;
        margin-bottom: 4px;
    }
    #pause-menu p {
        margin-bottom: 10px !important;
        font-size: 0.75rem !important;
    }
    #pause-menu .btn {
        min-height: 34px;
        margin-bottom: 4px !important;
        width: 180px !important;
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    /* Settings menu compact */
    #settings-menu h2.title-text {
        font-size: 1.6rem;
        margin-bottom: 6px;
    }
    #settings-menu .btn:last-child {
        margin-top: 10px;
    }
    .settings-grid .btn.setting-btn {
        min-height: 30px !important;
        padding: 3px 8px !important;
        font-size: 0.72rem !important;
    }
    .settings-grid {
        gap: 5px;
    }
    .setting-label {
        font-size: 0.75rem;
    }

    /* Game over compact on desktop */
    #game-over-content {
        padding: 15px;
        overflow-y: auto;
        max-height: 100vh;
    }
    #game-over .btn {
        min-height: 44px;
    }
}

/* --- MOBILE RESPONSIVE TWEAKS --- */
@media (max-width: 600px) {
    .title-text { 
        font-size: 2.8rem; 
        margin-bottom: 10px; 
        margin-top: 5px; 
    }
    .title-sub {
        font-size: 0.85rem;
    }
    .mode-container { 
        grid-template-columns: 1fr; 
        width: 100%; 
        gap: 8px;
        padding: 5px 10px;
        padding-bottom: 40px; 
    }
    /* Force all buttons to single column on mobile */
    .mode-container .btn {
        grid-column: span 1 !important;
        min-height: 60px; 
        font-size: 1rem;
    }
    .high-score-display {
        font-size: 0.7rem !important;
        margin-top: 5px !important;
        padding-top: 4px !important;
        width: 80% !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    .btn-full, .btn-overdrive, .btn-chain, .btn-sec, .btn-accent, .btn-danger, .btn-glitch { 
        grid-column: span 1; 
    }
    #start-screen { 
        padding-top: 0; 
    }
    .side-hud { 
        gap: 8px; 
        padding: 5px 10px; 
        bottom: 30px; 
    }
    .stat-row { font-size: 0.65rem; }
    .stat-label { font-size: 0.7rem; }
    
    /* Mobile adjustments for game over screen to prevent obscuring */
    #game-over-content {
        padding: 10px;
        justify-content: flex-start; /* Align top so scrollable if needed */
        padding-top: 20px;
        overflow-y: auto;
        max-height: 100vh;
    }

    #game-over-content .title-text {
        font-size: 2.2rem; /* Shrink title */
        margin-bottom: 5px;
        margin-top: 5px;
    }

    #final-score-val {
        font-size: 2.8rem !important; /* Shrink score */
        margin: 3px 0;
    }

    /* Shrink the space between elements */
    #game-over > #game-over-content > div[style*="display: flex"] {
        flex-direction: row; /* Keep buttons side-by-side if possible, or wrap */
        margin-top: 8px !important;
        margin-bottom: 8px !important;
        max-width: 100% !important;
    }
    
    #game-over .btn[style*="flex: 1"] {
        height: 48px !important; /* Shorter share buttons */
        min-height: 48px !important;
        min-width: 55px !important;
        padding: 4px !important;
    }
    
    #game-over .btn {
        min-height: 42px !important;
    }

    /* Main Menu Button Visibility */
    #game-over .btn[onclick*="returnToMenu"] {
        margin-top: 4px !important;
        min-height: 40px !important;
        width: 90% !important;
    }
    
    /* Pause menu adjustments */
    #pause-menu {
        overflow-y: auto; /* Ensure scrollable on small screens */
    }
    #pause-menu h1.title-text {
        font-size: 1.6rem;
        margin-bottom: 2px;
    }
    #pause-menu p {
        margin-bottom: 8px !important;
        font-size: 0.7rem !important;
    }
    #pause-menu .btn {
        min-height: 32px;
        margin-bottom: 4px !important;
        width: 170px !important;
        font-size: 0.72rem;
        padding: 4px 8px;
    }
    
    /* Settings menu compact on mobile */
    .settings-grid {
        gap: 4px;
        margin-bottom: 6px;
    }
    .setting-label {
        font-size: 0.7rem;
    }
    .settings-grid .btn.setting-btn {
        font-size: 0.68rem !important;
        min-height: 26px !important;
        padding: 3px 6px !important;
    }
    #settings-menu h2.title-text {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }
}

/* --- COOKIE CONSENT BANNER --- */
#cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    pointer-events: auto;
    background: var(--surface);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    padding: 0;
    animation: slideUp 0.4s ease-out;
}

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

.consent-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 18px 20px;
    text-align: center;
}

.consent-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-sub);
    line-height: 1.5;
    margin-bottom: 12px;
}

.consent-links {
    margin-bottom: 12px;
}

.consent-links a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.consent-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.consent-btn {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 10px 24px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 42px;
}

.consent-accept {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.consent-accept:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.consent-essential {
    background: var(--btn-bg);
    color: var(--text);
    border-color: var(--btn-border);
}

.consent-essential:hover {
    background: var(--surface);
    transform: scale(1.02);
}
@keyframes pulse-gold {
    0% { transform: scale(1); opacity: 1; text-shadow: 0 0 10px rgba(217, 119, 6, 0.2); }
    50% { transform: scale(1.05); opacity: 0.8; text-shadow: 0 0 20px rgba(217, 119, 6, 0.5); }
    100% { transform: scale(1); opacity: 1; text-shadow: 0 0 10px rgba(217, 119, 6, 0.2); }
}
/* Leaderboard Styles */
.lb-rank-1 { color: #fbbf24; font-weight: 900; } /* Gold */
.lb-rank-2 { color: #9ca3af; font-weight: 800; } /* Silver */
.lb-rank-3 { color: #b45309; font-weight: 800; } /* Bronze */

#lb-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-family: 'JetBrains Mono';
    font-size: 0.9rem;
}

#lb-mode-selector button {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-sub);
    padding: 8px 16px;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
}

#lb-mode-selector button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
/* Profile / Career Modal Styles */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.p-stat-box {
    background: var(--bg);
    border: 1px solid var(--glass-border);
    padding: 15px 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.full-width {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--bg) 0%, var(--surface) 100%);
    border-color: var(--primary);
}

.p-label {
    font-family: 'JetBrains Mono';
    font-size: 0.65rem;
    color: var(--text-sub);
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.p-val {
    font-family: 'Inter';
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--text);
}
/* Overdrive Active State */
@keyframes overdrive-pulse {
    0% { box-shadow: inset 0 0 30px rgba(124, 58, 237, 0.3); }
    50% { box-shadow: inset 0 0 60px rgba(124, 58, 237, 0.6); }
    100% { box-shadow: inset 0 0 30px rgba(124, 58, 237, 0.3); }
}

canvas.overdrive-active {
    animation: overdrive-pulse 0.7s ease-in-out infinite;
}
