@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================
   CSS Variables for Easy Theming
   Refined modern palette - soft blue accents
   ============================================ */
:root {
    --color-primary: #64B5F6;
    --color-accent: #42A5F5;
    --color-link: #64B5F6;
    --color-link-hover: #90CAF9;
    --color-bg: #0d1117;
    --color-white: #e6edf3;
    --color-border: #30363d;
    --color-border-hover: #8b949e;
    --color-border-active: #58a6ff;
    --font-main: 'Inter', sans-serif;
    --transition-speed: 0.2s;
    --color-surface: #161b22;
    --color-muted: #8b949e;
}

/* ============================================
   Base Styles (Shared)
   ============================================ */
html {
    height: 100%;
    background-color: var(--color-bg);
}

body {
    margin: 0;
    min-height: 100%;
    background-color: var(--color-bg);
    cursor: pointer !important;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    font-family: var(--font-main);
    font-weight: 400;
}

/* ============================================
   Game Buttons (shared styles)
   ============================================ */
.game-btn {
    width: 200px;
    outline: none;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    margin-left: 2px;

    /* Refined Styling */
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-white);

    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.game-btn:hover {
    background: #21262d;
    border-color: var(--color-border-hover);
    color: var(--color-white);
}

.game-btn:active {
    background: #30363d;
    color: var(--color-muted);
}

/* ============================================
   Links
   ============================================ */
#patr {
    color: var(--color-link);
    text-decoration: none;
    font-size: 15px;
}

#patr:hover,
#patrLink:hover {
    color: var(--color-link-hover);
}

/* ============================================
   Settings License Link
   ============================================ */
.settings-license {
    text-align: center;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-license a {
    color: #666;
    text-decoration: none;
    font-size: 11px;
    font-family: var(--font-main);
    transition: color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-license a:hover {
    color: var(--color-primary);
}

/* ============================================
   Top-Right Control Group Container
   ============================================ */
.top-controls {
    position: fixed;
    top: 10px;
    right: 15px;
    z-index: 100;
    display: flex;
    flex-direction: row-reverse;
    /* Reverse order: icons appear on left, login on right */
    gap: 8px;
    align-items: center;
}

/* Reset positioning for buttons inside container */
.top-controls .game-btn {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
}

/* Icon buttons (Settings, Leaderboard) */
.top-controls .icon-btn {
    min-width: 44px !important;
    width: 44px !important;
    height: 40px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* ============================================
   Top-Left Control Group Container
   ============================================ */
.top-left-controls {
    position: fixed;
    top: 10px;
    left: 15px;
    z-index: 100;
    display: flex;
    align-items: center;
}

/* Auth/Login button */
.auth-btn {
    min-width: 100px;
    height: 40px;
    padding: 0 16px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}


.auth-btn.logged-in {
    border-color: var(--color-primary);
}

.auth-btn .user-icon {
    margin-right: 4px;
}

/* Rank #1 Gold Glow Effect */
.auth-btn.rank-one {
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.3) !important;
}

.auth-btn.rank-one .username-text {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    animation: goldGlow 2s ease-in-out infinite;
}

@keyframes goldGlow {

    0%,
    100% {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    }

    50% {
        text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 30px rgba(255, 215, 0, 0.8), 0 0 40px rgba(255, 200, 0, 0.4);
    }
}

/* ============================================
   Auth Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 30px;
    width: 90%;
    max-width: 360px;
    position: relative;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.modal-close:hover {
    color: var(--color-primary);
}

.modal-content h2 {
    color: var(--color-primary);
    text-align: center;
    margin: 0 0 25px 0;
    font-family: var(--font-main);
    font-size: 24px;
}

/* ============================================
   Auth Form
   ============================================ */
.form-field {
    margin-bottom: 18px;
}

.form-field.hidden {
    display: none;
}

.form-field label {
    display: block;
    color: #aaa;
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-field input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-white);
    font-size: 16px;
    font-family: var(--font-main);
    transition: border-color var(--transition-speed);
    box-sizing: border-box;
}

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

.form-field input::placeholder {
    color: #555;
}

.auth-error {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid #dc3545;
    color: #ff6b7a;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
}

.auth-success {
    background: rgba(40, 167, 69, 0.2);
    border: 1px solid #28a745;
    color: #5dd879;
    padding: 10px 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
}

.hidden {
    display: none !important;
}

.auth-submit {
    width: 100%;
    padding: 14px !important;
    font-size: 16px !important;
    margin-top: 10px;
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: #888;
    font-size: 14px;
}

.switch-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 14px;
    text-decoration: underline;
    padding: 5px;
}

.switch-btn:hover {
    color: var(--color-link-hover);
}

/* ============================================
   User Menu (dropdown)
   ============================================ */
.user-menu {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 0;
    min-width: 180px;
    box-sizing: border-box;
    z-index: 101;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: menuFadeIn 0.15s ease-out;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu-header {
    padding: 10px 15px;
    border-bottom: 1px solid #333;
    margin-bottom: 5px;
}

.user-menu-header .username {
    color: var(--color-primary);
    font-weight: bold;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 10px 15px;
    background: none;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 14px;
    transition: background 0.2s;
}

.user-menu-item:hover {
    background: rgba(244, 96, 255, 0.1);
}

/* ============================================
   Local Records Button
   ============================================ */
.local-records-btn {
    position: fixed;
    top: 100px;
    right: 10px;
    z-index: 100;
    min-width: 100px;
    padding: 8px 16px !important;
}

/* ============================================
   Local Records Panel
   ============================================ */
.local-records-panel {
    position: fixed;
    top: 145px;
    right: 10px;
    width: 220px;
    max-height: 50vh;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    z-index: 98;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: panelSlideIn 0.2s ease-out;
}

/* ============================================
   Game Stats Labels
   ============================================ */
.time-label,
.score-label {
    font-size: 12px;
    letter-spacing: 2px;
    opacity: 0.7;
    text-transform: uppercase;
    font-weight: 600;
}

.lr-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #333;
}

.lr-header h3 {
    margin: 0;
    color: #a0aec0;
    font-size: 14px;
    font-family: var(--font-main);
}

.lr-mode-title {
    text-align: center;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-primary);
    font-size: 12px;
    font-family: var(--font-main);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid #333;
}

.lr-content {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px 0;
}

.lr-empty {
    text-align: center;
    color: #666;
    padding: 20px 15px;
    font-size: 13px;
}

.lr-entry {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    transition: background 0.2s;
}

.lr-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.lr-entry.best {
    background: rgba(244, 96, 255, 0.1);
    border-left: 3px solid var(--color-primary);
}

.lr-rank {
    width: 30px;
    color: #718096;
    font-weight: bold;
    font-size: 12px;
}

.lr-entry.best .lr-rank {
    color: #ffd700;
}

.lr-score {
    flex: 1;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.lr-date {
    color: #666;
    font-size: 11px;
}

/* Leaderboard Button - positioned by .top-controls container */

/* ============================================
   Leaderboard Panel (Right Side)
   ============================================ */
.leaderboard-panel {
    position: fixed;
    top: 60px;
    right: 15px;
    box-sizing: border-box;
    /* Width spans from settings button to login button */
    width: 308px;
    max-height: 50vh;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    z-index: 99;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: panelSlideIn 0.2s ease-out;
}

@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #333;
}

.lb-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 16px;
    font-family: var(--font-main);
}

.lb-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.lb-close:hover {
    color: var(--color-primary);
}

.lb-controls {
    background: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #333;
}

.lb-tabs {
    display: flex;
    border-bottom: 1px solid #333;
}

.lb-tab {
    flex: 1;
    padding: 8px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 13px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.lb-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.lb-tab.active {
    color: var(--color-primary);
    background: rgba(244, 96, 255, 0.1);
    border-bottom: 2px solid var(--color-primary);
}

.lb-source-switch {
    display: flex;
    justify-content: center;
    padding: 5px;
}

.lb-source-btn {
    background: none;
    border: 1px solid #444;
    color: #888;
    padding: 4px 12px;
    font-size: 11px;
    font-family: var(--font-main);
    cursor: pointer;
    margin: 0 2px;
    border-radius: 4px;
    text-transform: uppercase;
}

.lb-source-btn.active {
    background: var(--color-primary);
    color: black;
    border-color: var(--color-primary);
    font-weight: bold;
}

.lb-content {
    max-height: 350px;
    overflow-y: auto;
    padding: 10px 0;
}

.lb-loading,
.lb-message {
    text-align: center;
    color: #888;
    padding: 30px 15px;
    font-size: 14px;
}

.lb-entry {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    transition: background 0.2s;
}

.lb-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.lb-entry.current-user {
    background: rgba(244, 96, 255, 0.15);
    border-left: 3px solid var(--color-primary);
}

.lb-rank {
    width: 35px;
    color: var(--color-accent);
    font-weight: bold;
    font-size: 14px;
}

.lb-entry:nth-child(1) .lb-rank {
    color: #ffd700;
}

.lb-entry:nth-child(2) .lb-rank {
    color: #c0c0c0;
}

.lb-entry:nth-child(3) .lb-rank {
    color: #cd7f32;
}

.lb-name {
    flex: 1;
    color: white;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    color: var(--color-primary);
    font-weight: bold;
    font-size: 14px;
    margin-left: 10px;
}

.lb-user-rank {
    border-top: 1px solid #333;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.2);
}

.lb-user-entry {
    color: #aaa;
    font-size: 13px;
    text-align: center;
}

.lb-user-entry strong {
    color: var(--color-primary);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
.lb-content::-webkit-scrollbar {
    width: 6px;
}

.lb-content::-webkit-scrollbar-track {
    background: transparent;
}

.lb-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.lb-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 600px) {

    .auth-btn,
    .leaderboard-btn {
        font-size: 12px !important;
        padding: 6px 12px !important;
        min-width: 80px;
    }

    .leaderboard-panel {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
    }

    .modal-content {
        padding: 20px;
    }
}

/* ============================================
   Settings Modal (Centered)
   ============================================ */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    /* Highest priority */
    backdrop-filter: blur(5px);
    display: none;
    /* Hidden by default */
}

.settings-panel {
    position: relative;
    /* Relative to overlay */
    top: auto;
    right: auto;
    left: auto;
    width: 300px;
    /* Slightly wider */
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out;
    display: block;
    /* Always block inside the flex overlay */
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid #333;
}

.settings-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 16px;
    font-family: var(--font-main);
}

.settings-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.settings-close:hover {
    color: var(--color-primary);
}

.settings-content {
    padding: 15px;
}

.settings-row {
    margin-bottom: 20px;
}

.settings-row:last-child {
    margin-bottom: 5px;
}

.settings-label {
    display: block;
    color: #aaa;
    font-size: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Settings row with toggle switch - inline layout */
.settings-row:has(.toggle-switch) {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-row:has(.toggle-switch) .settings-label {
    margin-bottom: 0;
}

/* Custom Range Input for Volume and Zoom */
.volume-slider,
.zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #333;
    outline: none;
    opacity: 0.9;
    transition: opacity .2s;
}

.volume-slider:hover,
.zoom-slider:hover {
    opacity: 1;
}

.volume-slider::-webkit-slider-thumb,
.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb,
.zoom-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: none;
}

/* Custom Select for Sound */
.sound-select {
    width: 100%;
    padding: 8px;
    background: #0d0d1a;
    border: 1px solid #444;
    border-radius: 4px;
    color: white;
    font-family: var(--font-main);
    font-size: 14px;
    outline: none;
}

.sound-select:focus {
    border-color: var(--color-primary);
}

@media (max-width: 600px) {
    .settings-panel {
        width: 90%;
    }

}

/* ============================================
   Stats Panel - Premium Spacious Design
   ============================================ */
.stats-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
}

.stats-panel {
    position: relative;
    width: 500px;
    max-height: 90vh;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(100, 181, 246, 0.1);
    animation: modalSlideIn 0.25s ease-out;
    overflow: hidden;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-header h3 {
    margin: 0;
    color: var(--color-primary);
    font-size: 18px;
    font-family: var(--font-main);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stats-close {
    background: none;
    border: none;
    color: #666;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}

.stats-close:hover {
    color: var(--color-primary);
    transform: scale(1.1);
}

.stats-content {
    padding: 28px;
    overflow-y: auto;
    max-height: calc(90vh - 70px);
}

.stats-loading,
.stats-empty {
    text-align: center;
    color: #888;
    padding: 60px 20px;
    font-size: 15px;
}

/* Account Section */
.stats-account {
    text-align: center;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stats-username {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stats-joined {
    font-size: 13px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Chart Section */
.stats-chart-section {
    margin-bottom: 28px;
}

.stats-section-title {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
    font-weight: 600;
}

.stats-chart-container {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.2) 100%);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

#stats-chart {
    display: block;
    width: 100%;
    height: auto;
}

/* Stats Grid - 2 Column Premium Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stats-card {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.15) 100%);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.stats-card:hover {
    border-color: rgba(100, 181, 246, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stats-card:hover::before {
    opacity: 1;
}

.stats-card-icon {
    margin-bottom: 12px;
    color: var(--color-muted);
    display: flex;
    justify-content: center;
    align-items: center;
}

.stats-card-icon svg {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.stats-card:hover .stats-card-icon svg {
    opacity: 1;
}

.stats-card-value {
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

/* Special card value colors */
.stats-card.rank .stats-card-value {
    color: #ffd700;
}

.stats-card.rank .stats-card-icon svg {
    stroke: #ffd700;
    opacity: 0.85;
}

.stats-card.best .stats-card-value {
    color: var(--color-primary);
}

.stats-card.best .stats-card-icon svg {
    stroke: var(--color-primary);
    opacity: 0.85;
}

.stats-card-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Login Prompt */
.stats-login-prompt {
    text-align: center;
    padding: 50px 30px;
}

.stats-login-icon {
    margin-bottom: 20px;
    color: #555;
}

.stats-login-icon svg {
    opacity: 0.5;
}

.stats-login-prompt p {
    color: #888;
    margin-bottom: 24px;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.stats-login-btn {
    padding: 12px 32px !important;
    font-size: 14px !important;
}

/* Stats Button in top controls */
.stats-btn {
    font-size: 16px !important;
}

/* Scrollbar Styling */
.stats-content::-webkit-scrollbar {
    width: 6px;
}

.stats-content::-webkit-scrollbar-track {
    background: transparent;
}

.stats-content::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.stats-content::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Responsive */
@media (max-width: 600px) {
    .stats-panel {
        width: 95%;
        max-height: 90vh;
        border-radius: 12px;
    }

    .stats-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stats-card {
        padding: 16px 12px;
    }

    .stats-card-value {
        font-size: 22px;
    }

    .stats-username {
        font-size: 22px;
    }
}

/* ============================================
   Stats Panel - Extended Tabbed Layout
   ============================================ */

/* Update stats panel to be wider like game version */
.stats-panel {
    width: 900px;
    max-width: 95vw;
}

/* Main Layout - Two Column */
.stats-layout {
    display: flex;
    gap: 24px;
}

.stats-left {
    flex: 0 0 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Account Section - Horizontal */
.stats-account {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
}

/* Tabs */
.stats-tabs {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.stats-tab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.stats-tab:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.stats-tab.active {
    background: var(--color-primary);
    color: #0d1117;
}

/* Top 5 Scores */
.stats-top5 {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.15) 100%);
    border-radius: 6px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-top5-row {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.stats-top5-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.stats-top5-row.best {
    background: rgba(100, 181, 246, 0.1);
}

.stats-top5-rank {
    width: 30px;
    font-size: 13px;
    font-weight: 700;
    color: var(--color-primary);
}

.stats-top5-row.best .stats-top5-rank {
    color: #ffd700;
}

.stats-top5-value {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.stats-top5-date {
    font-size: 11px;
    color: #888;
}

.stats-top5-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

/* History Button */
.stats-history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: #888;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.stats-history-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--color-border-hover);
    color: #fff;
}

.stats-history-btn svg {
    opacity: 0.7;
}

/* Stats Group */
.stats-group {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.1) 100%);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-group-title {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Update stats grid for 3 column */
.stats-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* Charts Row - Bottom Section */
.stats-charts-row {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    align-items: stretch;
}

.stats-chart-left {
    flex: 1;
    max-width: 340px;
    display: flex;
    flex-direction: column;
}

.stats-chart-left .stats-chart-container {
    flex: 1;
    min-height: 140px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.stats-chart-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.stats-chart-right .stats-chart-container {
    flex: 1;
    min-height: 140px;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Chart canvases fill container */
#stats-chart,
#stats-bar-chart {
    flex: 1;
    width: 100% !important;
}

/* Chart Header */
.stats-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    min-height: 26px;
}

.stats-chart-header .stats-section-title {
    margin-bottom: 0;
}

/* Range Toggle */
.stats-range-toggle {
    display: flex;
    gap: 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.stats-range-btn {
    padding: 4px 10px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.stats-range-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.stats-range-btn.active {
    background: #FFB74D;
    color: #0d1117;
}

/* Chart Tooltip */
.stats-chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    border: 1px solid rgba(255, 183, 77, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.stats-chart-tooltip.visible {
    opacity: 1;
}

.stats-chart-tooltip-date {
    font-weight: 600;
    color: #FFB74D;
    margin-bottom: 2px;
}

.stats-chart-tooltip-value {
    color: #fff;
}

.stats-chart-tooltip-rank {
    color: #888;
    font-size: 11px;
    margin-top: 2px;
}

/* Score chart tooltip uses blue accent */
#stats-score-tooltip .stats-chart-tooltip-date {
    color: #64B5F6;
}

#stats-score-tooltip {
    border-color: rgba(100, 181, 246, 0.3);
}

/* Responsive adjustments for new layout */
@media (max-width: 900px) {
    .stats-panel {
        width: 95%;
    }

    .stats-layout {
        flex-direction: column;
    }

    .stats-left {
        flex: none;
    }

    .stats-charts-row {
        flex-direction: column;
    }

    .stats-chart-left {
        max-width: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Toggle Switch Component
   ============================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}