:root {
    --ted-red: #eb0028;
    --ted-red-hover: #c00020;
    --color-black: #0a0e17; /* Dark blue/black */
    --color-white: #ffffff;
    --glass-bg: rgba(10, 14, 23, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Inter', sans-serif;
    --accent-gold: #ffde00;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-black);
    font-family: var(--font-main);
    color: var(--color-white);
    touch-action: none; /* Prevent scroll on mobile */
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Background Layers */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background-size: 50% 100%;
    background-repeat: repeat-x;
    z-index: 1;
}

.bg-sky {
    background: linear-gradient(to bottom, #1a0b12 0%, var(--color-black) 100%);
    z-index: 0;
}

.bg-buildings {
    background-image: url('assets/bg.png');
    background-size: 100% 100%;
    background-position: center bottom;
    background-repeat: no-repeat;
    opacity: 1;
    z-index: 1;
}

.bg-trees {
    /* Ground separator removed as image has a ground, just leave a small overlay */
    position: absolute;
    bottom: 0;
    height: 15%;
    width: 100%;
    z-index: 2;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    display: block;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to canvas when playing */
    display: flex;
    flex-direction: column;
}

#top-bar {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
}

.score-container {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.6);
}

#score {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1;
    display: block;
    margin-top: 5px;
}

/* Progress Bar */
.progress-container {
    flex: 1;
    max-width: 600px;
    margin: 0 2rem;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    position: relative;
    margin-top: 1.5rem;
    display: none;
}

@media (min-width: 768px) {
    .progress-container { display: block; }
}

#progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--ted-red);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s linear;
    box-shadow: 0 0 10px var(--ted-red);
}

.milestones {
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.3);
}

.controls {
    display: flex;
    gap: 1rem;
}

.controls button, .btn-control {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}

.controls button:hover, .btn-control:hover {
    background: var(--ted-red);
}

/* Menus */
.menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 3rem;
    border-radius: 16px;
    pointer-events: auto;
    transition: opacity 0.3s, transform 0.3s;
    min-width: 300px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -45%);
}

.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}

h1 {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 1rem;
    letter-spacing: -1px;
}

h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

p {
    color: #bbb;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.text-ted-red {
    color: var(--ted-red);
}

.final-score-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 30px;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    width: 100%;
}

.btn-primary {
    background: var(--ted-red);
    color: white;
    box-shadow: 0 5px 15px rgba(235, 0, 40, 0.4);
}

.btn-primary:hover {
    background: var(--ted-red-hover);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: white;
    border: 1px solid var(--ted-red);
}

.btn-outline:hover {
    background: var(--ted-red);
}

/* (Removed old btn-close-game absolute styles) */

.instructions {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #888;
    display: flex;
    justify-content: center;
}

.desktop-only { display: block; }
.mobile-only { display: none; }

/* Start Menu Layout */
.start-menu {
    max-width: 900px;
    width: 90%;
    padding: 2.5rem;
}

.start-menu-layout {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.start-menu-left {
    flex: 1;
}

.start-menu-right {
    flex: 1.5;
    display: flex;
    gap: 1.5rem;
    border-left: 1px solid rgba(255,255,255,0.1);
    padding-left: 2rem;
    text-align: left;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: block; }
    h1 { font-size: 2.5rem; }
    
    .menu { padding: 1.5rem; width: 95%; max-height: 95vh; overflow-y: auto; }
    
    /* Stack layout on mobile */
    .start-menu-layout {
        flex-direction: column;
        gap: 1.5rem;
    }
    .start-menu-right {
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-left: 0;
        padding-top: 1.5rem;
        width: 100%;
        justify-content: center;
        gap: 2rem;
    }

    .game-leaderboard {
        max-height: 120px;
    }
}

/* Game Over Form Styles */
.game-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 24px;
    border-radius: 30px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.game-input:focus {
    outline: none;
    border-color: var(--ted-red);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), 0 0 12px rgba(235, 0, 40, 0.4);
}

.game-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.95rem;
}

/* Fix annoying browser autofill background changing to white */
.game-input:-webkit-autofill,
.game-input:-webkit-autofill:hover, 
.game-input:-webkit-autofill:focus, 
.game-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #1a1a1a inset !important;
    -webkit-text-fill-color: white !important;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Game Leaderboard */
.game-leaderboard {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin: 15px 0;
    padding: 10px;
    max-height: 180px;
    overflow-y: auto;
}

.leaderboard-title {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-align: center;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    width: 20px;
    font-weight: 700;
    color: #888;
}

.leaderboard-item.top-3 .leaderboard-rank {
    color: var(--accent-gold);
}

.leaderboard-name {
    flex-grow: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

.leaderboard-score {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: var(--ted-red);
}

/* Custom Scrollbar for Leaderboard */
.game-leaderboard::-webkit-scrollbar {
    width: 4px;
}
.game-leaderboard::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
.game-leaderboard::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}
