:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #1a1a1a;
    --accent-red: #D2001F;
    /* Approximated from typical manufacturing red or Altimo bright red */
    --accent-glow: #ff4d4d;
    --text-main: #ffffff;
    --text-muted: #888888;
    --glass-bg: rgba(20, 20, 20, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --christmas-gold: #FFD700;
    --christmas-green: #00873E;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: radial-gradient(circle at top right, #1a0505, var(--bg-dark));
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.game-header {
    position: absolute;
    top: 20px;
    left: 40px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 20px;
    pointer-events: none;
    /* Let clicks pass through */
}

.logo {
    height: 40px;
    object-fit: contain;
}

h1 {
    font-size: 1.5rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #111;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
}

canvas {
    background-color: #2a2a2a;
    /* Raw metal sheet look handled in JS, this is fallback */
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    cursor: none;
    /* Prevent scrolling on touch */
    touch-action: none;
}

/* Overlays with Glassmorphism */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.menu-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.btn-primary {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    box-shadow: 0 0 20px rgba(210, 0, 31, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(210, 0, 31, 0.6);
    background: #ff1a3c;
}

/* HUD */
.hud {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    background: var(--glass-bg);
    padding: 15px 40px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    pointer-events: none;
    z-index: 50;
}

.hud * {
    pointer-events: auto;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.bar-container {
    width: 150px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--christmas-green), var(--christmas-gold));
    transition: width 0.1s linear;
}

#time-display {
    font-family: monospace;
    font-size: 1.25rem;
    color: var(--christmas-gold);
}

/* New Styles for Leaderboard */
.input-field {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 1rem;
    width: 100%;
    margin-bottom: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.input-field:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-red);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    text-transform: uppercase;
    transition: all 0.3s;
}

.btn-secondary:hover {
    border-color: white;
    color: white;
}

.btn-icon {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s;
    pointer-events: auto;
}

.btn-icon:hover {
    background: var(--accent-red);
}

.wide {
    max-width: 800px;
}

.leaderboard-list {
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
    margin-top: 1rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.rank {
    font-weight: bold;
    color: var(--christmas-gold);
    width: 30px;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: bold;
    display: block;
}

.player-company {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.score-val {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--accent-glow);
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-main);
}

/* Side Panel */
.side-panel {
    position: absolute;
    right: 20px;
    top: 80px;
    bottom: 120px;
    width: 250px;
    background: rgba(20, 20, 20, 0.7);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    z-index: 15;
    pointer-events: none;
}

.side-panel h3 {
    font-size: 1.2rem;
    color: var(--christmas-gold);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

#side-leaderboard-list {
    flex: 1;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.side-item {
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ccc;
}

.side-item .p-right {
    text-align: right;
}

.side-item .p-name {
    font-weight: bold;
    color: white;
    display: block;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-item .p-company {
    font-size: 0.7rem;
    color: #888;
    display: block;
}

.side-item .p-score {
    color: var(--accent-glow);
    font-family: monospace;
    display: block;
}

.side-item .p-time {
    font-size: 0.7rem;
    color: #888;
}

/* Leaderboard Tabs */
.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #aaa;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.tab-btn.active {
    background: var(--christmas-gold);
    color: #1a1a1a;
    border-color: var(--christmas-gold);
    font-weight: bold;
}

#leaderboard-content {
    max-height: 300px;
    overflow-y: auto;
}

/* Mobile: Hide side panel */
@media (max-width: 900px) {
    .side-panel {
        display: none;
    }

    .game-header {
        left: 10px;
        top: 10px;
        gap: 10px;
    }

    .game-header h1 {
        font-size: 0.8rem;
    }

    .logo {
        height: 25px;
    }

    /* Make HUD more compact but visible */
    .hud {
        bottom: 60px;
        gap: 10px;
        padding: 8px 15px;
        border-radius: 30px;
    }

    .hud-item {
        gap: 2px;
    }

    .label {
        font-size: 0.6rem;
    }

    .bar-container {
        width: 60px;
    }

    #time-display {
        font-size: 1rem;
    }

    #finish-btn {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.7rem !important;
    }

    /* Footer stays visible but rotated on left side */
    footer {
        font-size: 0.5rem !important;
        bottom: auto !important;
        right: auto !important;
        left: 5px !important;
        top: 50% !important;
        transform: rotate(-90deg) translateX(-50%);
        transform-origin: left center;
        white-space: nowrap;
    }
}