:root {
    --bg-army-dark: #2d3319;
    --bg-army-light: #4b5320;
    --army-olive: #556b2f;
    --army-camo: #78866b;
    --army-khaki: #c3b091;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #d1d5db;
    --font-ui: 'Inter', sans-serif;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: var(--font-ui);
    color: var(--text-main);
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
}

#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

/* UI Components should capture pointer events if needed */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at center, rgba(75, 83, 32, 0.8) 0%, rgba(45, 51, 25, 0.95) 100%);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.overlay.hidden {
    display: none !important;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    pointer-events: auto;
}

.text-center { text-align: center; }

h1 {
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 1rem;
    letter-spacing: 4px;
    background: linear-gradient(to bottom, #f8fafc 0%, #c3b091 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

h1.danger {
    background: linear-gradient(to right, #f87171, #ef4444);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: 999px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
    pointer-events: auto;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(59, 130, 246, 0.5);
}

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

/* Secondary button (share, instagram) */
.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 2rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    pointer-events: auto;
    text-decoration: none;
    display: inline-block;
    font-family: var(--font-ui);
}

.secondary-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

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

.instagram-btn {
    background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
    border: none;
    box-shadow: 0 5px 15px rgba(131, 58, 180, 0.4);
}

.instagram-btn:hover {
    box-shadow: 0 10px 25px rgba(131, 58, 180, 0.6);
    background: linear-gradient(135deg, #9b59b6, #ff3333, #ffd700);
}

/* Name input */
.name-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.5rem;
}

.name-input-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

#player-name-input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-main);
    text-align: center;
    letter-spacing: 3px;
    text-transform: uppercase;
    width: 220px;
    outline: none;
    font-family: var(--font-ui);
    transition: border-color 0.2s, box-shadow 0.2s;
    user-select: text;
    -webkit-user-select: text;
    touch-action: auto;
}

#player-name-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

#player-name-input.invalid {
    border-color: var(--accent-red);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    animation: shake 0.3s;
}

.name-error {
    font-size: 0.8rem;
    color: var(--accent-red);
    min-height: 1.2rem;
    margin-top: 0.3rem;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Copyright */
.copyright {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--army-khaki);
    opacity: 0.8;
    letter-spacing: 1px;
}

.version {
    font-size: 0.75rem;
    color: var(--army-khaki);
    opacity: 0.5;
    margin-top: 0.25rem;
    font-weight: 700;
}

/* Game Over */
.game-over-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.player-result {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.final-score-value {
    font-size: 2rem;
}

/* Scoreboard - Premium Aesthetic */
.scoreboard-container {
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.6), rgba(30, 41, 59, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    max-width: 450px;
    width: 100%;
    overflow: visible;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.scoreboard-container h3 {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--army-khaki);
    letter-spacing: 4px;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 2px solid rgba(163, 163, 163, 0.2);
    padding-bottom: 1rem;
    text-shadow: 0 0 15px rgba(163, 163, 163, 0.3);
}

.scoreboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.scoreboard-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.scoreboard-list li:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(5px);
}

.scoreboard-list li.loading {
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
    background: transparent;
}

.scoreboard-list .rank {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text-muted);
    width: 35px;
}

.scoreboard-list .name {
    flex-grow: 1;
    text-align: left;
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.scoreboard-list .score {
    color: var(--accent-blue);
    font-family: monospace;
    font-weight: 900;
    font-size: 1.1rem;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Special styling for top 3 */
.scoreboard-list li:nth-child(1) { border-left-color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.scoreboard-list li:nth-child(2) { border-left-color: #cbd5e1; background: rgba(203, 213, 225, 0.05); }
.scoreboard-list li:nth-child(3) { border-left-color: #d97706; background: rgba(217, 119, 6, 0.05); }

.scoreboard-list li:nth-child(1) .rank { color: #fbbf24; text-shadow: 0 0 8px rgba(251, 191, 36, 0.4); }
.scoreboard-list li:nth-child(1) .name { color: #fbbf24; }

/* HUB (Heads Up Display) */
#hud {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

#hud.hidden {
    display: none;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0));
    gap: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    backdrop-filter: blur(4px);
    min-width: 100px;
}

.stat label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.neon-text {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Points available color animation */
.points-available {
    transition: color 0.5s ease, text-shadow 0.5s ease;
}

.points-available.high {
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

.points-available.medium {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.points-available.low {
    color: #ef4444;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Bars */
.health-bar-bg, .reload-bar-bg {
    width: 100%;
    min-width: 100px;
    height: 12px;
    background: rgba(0,0,0,0.5);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 0.25rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

#health-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
}

#reload-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #eab308, #fde047);
    transition: width 0.1s linear;
}

/* Indicators */
#indicator-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.enemy-indicator {
    position: absolute;
    width: 0; 
    height: 0; 
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 24px solid var(--accent-red);
    transform-origin: center;
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 1));
    transition: opacity 0.2s, transform 0.1s;
    opacity: 0.9;
    z-index: 100;
}

@media (max-width: 768px) {
    #top-bar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        padding: 0.5rem;
        padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
        flex-wrap: wrap;
        justify-content: center;
        background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
        gap: 0.4rem;
        z-index: 100;
    }
    .stat {
        min-width: 30%;
        padding: 0.25rem 0.5rem;
        border-radius: 8px;
        flex: 1 1 auto;
    }
    .stat label {
        font-size: 0.6rem;
        margin-bottom: 0.1rem;
    }
    .neon-text {
        font-size: 0.9rem;
    }
    .health-bar-bg, .reload-bar-bg {
        height: 6px;
        min-width: 60px;
        margin-top: 0.1rem;
    }
    h1 { font-size: 2rem; }
    .glass-panel { padding: 2rem 1.5rem; }
    .game-over-buttons { gap: 0.5rem; }
}
