* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme Variables */
:root {
    /* Default Theme - Modern Purple/Blue */
    --bg-primary: #4e54c8;
    --bg-secondary: #8f94fb;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --accent-primary: #ff0080;
    --accent-secondary: #00ffcc;
    --button-bg: rgba(255, 255, 255, 0.15);
    --button-hover: rgba(255, 255, 255, 0.25);
    --card-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.2);
}

/* Dark Theme - True Dark */
body.theme-dark {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --accent-primary: #ff3333;
    --accent-secondary: #3333ff;
    --button-bg: rgba(255, 255, 255, 0.1);
    --button-hover: rgba(255, 255, 255, 0.2);
    --card-bg: rgba(20, 20, 20, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.8);
}

/* Neon Theme - Cyberpunk */
body.theme-neon {
    --bg-primary: #050505;
    --bg-secondary: #1a0b2e;
    --text-primary: #0ff;
    --text-secondary: rgba(0, 255, 255, 0.7);
    --accent-primary: #f0f;
    --accent-secondary: #0f0;
    --button-bg: rgba(0, 255, 255, 0.1);
    --button-hover: rgba(255, 0, 255, 0.2);
    --card-bg: rgba(10, 10, 30, 0.8);
    --glass-border: #0ff;
    --shadow-color: #f0f;
}

/* Sleek Theme - Minimalist Blue */
body.theme-sleek {
    --bg-primary: #2980b9;
    --bg-secondary: #2c3e50;
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --accent-primary: #e74c3c;
    --accent-secondary: #3498db;
    --button-bg: rgba(236, 240, 241, 0.1);
    --button-hover: rgba(236, 240, 241, 0.2);
    --card-bg: rgba(44, 62, 80, 0.8);
    --glass-border: rgba(236, 240, 241, 0.3);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Retro Theme - 8-Bit Nostalgia */
body.theme-retro {
    --bg-primary: #3e2723;
    --bg-secondary: #5d4037;
    --text-primary: #33ff00;
    --text-secondary: #ccffcc;
    --accent-primary: #ffcc00;
    --accent-secondary: #33ff00;
    --button-bg: rgba(62, 39, 35, 0.6);
    --button-hover: rgba(93, 64, 55, 0.8);
    --card-bg: rgba(62, 39, 35, 0.8);
    --glass-border: #33ff00;
    --shadow-color: #000000;
}

body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    transition: all 0.5s ease;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    z-index: 10;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--shadow-color);
    border-radius: 20px;
}

/* Menu Screen */
.menu-container {
    text-align: center;
    z-index: 2;
}

.game-logo {
    margin: 0 auto 2rem;
    animation: float 6s ease-in-out infinite, pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(102, 126, 234, 0.4));
}

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

.game-title {
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--text-primary), var(--accent-primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    letter-spacing: -2px;
}

.game-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    font-weight: 300;
    letter-spacing: 1px;
    opacity: 0.9;
}

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

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 300px;
    margin: 0 auto;
}

.menu-btn {
    padding: 1.2rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--button-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(4px);
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:hover {
    background: var(--button-hover);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px var(--shadow-color);
    border-color: var(--accent-primary);
}

.menu-btn:active {
    transform: translateY(1px);
}

/* Admin & Song Select Containers */
.admin-container,
.song-select-container,
.settings-container,
.scoreboard-container {
    padding: 2.5rem;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.5s ease-out;
}

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

.admin-container h2,
.song-select-container h2,
.settings-container h2,
.scoreboard-container h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 1rem;
    display: inline-block;
    width: 100%;
}

/* Info Box */
.info-box {
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--accent-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.info-box h4 {
    color: var(--accent-secondary);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

/* Forms & Inputs */
.upload-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 1.5rem;
}

#music-upload {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--text-secondary);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s;
}

#music-upload:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-primary);
}

#music-upload::file-selector-button {
    padding: 0.5rem 1.5rem;
    background: var(--accent-primary);
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    margin-right: 1rem;
    font-weight: bold;
    transition: transform 0.2s;
}

#music-upload::file-selector-button:hover {
    transform: scale(1.05);
}

.btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--accent-primary);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover:not(:disabled) {
    background: var(--accent-primary);
    filter: brightness(1.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.btn:disabled {
    background: gray;
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Song List */
.song-item {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.song-item .song-details {
    flex: 1;
    cursor: pointer;
}

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

.song-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-secondary);
}

.preview-btn, .play-btn {
    background: var(--button-bg);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px var(--shadow-color);
    min-width: 100px;
}

.play-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: var(--accent-primary);
    font-weight: 700;
}

.preview-btn:hover, .play-btn:hover {
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.play-btn:hover {
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 4px 15px var(--accent-primary);
}

.preview-btn:active, .play-btn:active {
    transform: translateY(0);
}

.song-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.song-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Admin Song List */
.admin-song-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin-bottom: 0.8rem;
    border-left: 3px solid var(--accent-primary);
}

.delete-song-btn {
    background: #ff4757;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.delete-song-btn:hover {
    background: #ff6b81;
    transform: scale(1.1);
}

/* Game Screen */
#game-screen {
    background: #000;
}

#game-ui {
    position: absolute;
    top: 30px;
    left: 30px;
    right: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
    font-family: 'Courier New', monospace;
    pointer-events: none; /* Let clicks pass through to canvas */
}

.ui-panel {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    text-align: center;
}

.ui-label {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.ui-value {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

#multiplier-display .ui-value {
    color: #ffd700;
    text-shadow: 0 0 15px #ffd700;
}

.fullscreen-btn {
    pointer-events: auto;
    position: absolute;
    top: 30px;
    right: 30px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 101;
    backdrop-filter: blur(5px);
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

#back-to-songs-btn {
    pointer-events: auto;
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 100;
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    color: white;
    font-weight: bold;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
}

#back-to-songs-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    padding-right: 2rem;
}

/* Progress Bar */
#progress-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 99;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 0 10px var(--accent-primary);
    transition: width 0.1s linear;
}

/* Settings */
.settings-section {
    margin-bottom: 2.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 15px;
}

.settings-section h3 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-mode-buttons, .theme-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.mode-btn {
    padding: 1rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(var(--accent-primary), 0.3);
}

/* Scoreboard */
.scoreboard-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.scoreboard-filter span {
    font-weight: 600;
    color: var(--text-primary);
}

.scoreboard-filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.scoreboard-filter .difficulty-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.scoreboard-filter .difficulty-toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scoreboard-filter .difficulty-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}

.scoreboard-song {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

.song-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.song-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.song-scores {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.score-entry {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.2rem;
    border-radius: 12px;
    border-left: 5px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: transform 0.2s;
}

.score-entry:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.1);
}

.score-entry.rank-1 { border-left-color: #FFD700; background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent); }
.score-entry.rank-2 { border-left-color: #C0C0C0; background: linear-gradient(90deg, rgba(192, 192, 192, 0.1), transparent); }
.score-entry.rank-3 { border-left-color: #CD7F32; background: linear-gradient(90deg, rgba(205, 127, 50, 0.1), transparent); }

.score-song-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.score-details {
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.score-entry.empty {
    justify-content: center;
    border-left-color: rgba(255, 255, 255, 0.2);
    font-style: italic;
}

.score-rank {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 2.5rem;
    text-align: center;
}

.score-body {
    flex: 1;
}

.score-player {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.score-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.scoreboard-error {
    background: rgba(255, 99, 71, 0.15);
    border: 1px solid rgba(255, 99, 71, 0.5);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.scoreboard-error-details {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin: 0.5rem 0 1rem 0;
}

.network-notice {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.9rem 1.4rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
    z-index: 9999;
    font-size: 0.95rem;
    opacity: 0;
    pointer-events: none;
}

.network-notice.info { background: rgba(59, 130, 246, 0.9); }
.network-notice.warning { background: rgba(245, 158, 11, 0.95); }
.network-notice.success { background: rgba(16, 185, 129, 0.95); }
.network-notice.error { background: rgba(239, 68, 68, 0.95); }

/* Game Results Modal */
.results-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.results-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.results-card {
    background: rgba(15, 15, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem;
    width: min(90%, 520px);
    color: var(--text-primary);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
}

.results-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.results-card h3 {
    text-align: center;
    margin-bottom: 1rem;
}

.results-grade {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 1rem auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.results-song {
    text-align: center;
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.results-grid span,
.results-breakdown span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.results-grid strong,
.results-breakdown strong {
    font-size: 1.1rem;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .game-title {
        font-size: 3rem;
    }
    
    .menu-btn {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
    }
    
    .admin-container,
    .song-select-container,
    .settings-container,
    .scoreboard-container {
        padding: 1.5rem;
        width: 95%;
    }
    
    #game-ui {
        top: 15px;
        left: 15px;
        right: 15px;
    }
    
    .ui-panel {
        padding: 5px 10px;
    }
    
    .ui-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 926px) and (orientation: landscape) {
    .game-title {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }
    
    .menu-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }
    
    .menu-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
}
