@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800;900&family=Press+Start+2P&display=swap');

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0b0f19;
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    display: block;
}

/* UI Overlay Containers */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.wave-badge {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

#wave-title-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fbbf24;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

#wave-timer-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}

/* Red Flash Overlay */
#red-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(225, 29, 72, 0.35);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    z-index: 5;
}

/* Crosshair & Hitmarker */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10;
}

#hitmarker {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 0;
    pointer-events: none;
    z-index: 11;
    transition: opacity 0.08s ease;
}

#hitmarker::before, #hitmarker::after {
    content: '';
    position: absolute;
    background-color: #ef4444;
}

#hitmarker::before {
    top: 0;
    left: 11px;
    width: 2px;
    height: 24px;
}

#hitmarker::after {
    top: 11px;
    left: 0;
    width: 24px;
    height: 2px;
}

#hitmarker.active {
    opacity: 1;
}

/* Wave Notification Banner */
#wave-banner {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    font-family: 'Press Start 2P', monospace;
    font-size: 1.6rem;
    color: #f59e0b;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.8), 0 4px 0 #78350f;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 12;
    white-space: nowrap;
}

#wave-banner.show {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* HUD Overlay */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Health & Stamina Bars */
.stat-bar-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
}

.bar-wrapper {
    width: 180px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.15s ease;
}

#health-fill {
    background: linear-gradient(90deg, #ef4444, #f43f5e);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

#stamina-fill {
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

/* Mute Audio Button — Always Interactive with z-index: 999 */
.mute-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 46px;
    height: 46px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    color: #ffffff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
    pointer-events: auto !important;
    z-index: 999 !important;
}

.mute-btn:hover {
    background: rgba(30, 41, 59, 0.98);
    transform: scale(1.08);
    border-color: #38bdf8;
}

.mute-btn.muted {
    background: rgba(225, 29, 72, 0.3);
    border-color: #ef4444;
}

/* Score & Kills Badge */
.score-badge {
    position: absolute;
    top: 20px;
    right: 80px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 20px;
    border-radius: 12px;
    text-align: right;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.score-num {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.2rem;
    color: #fbbf24;
}

.kills-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-top: 2px;
}

/* Bottom Weapon Bar */
#weapon-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.weapon-slot {
    position: relative;
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.weapon-slot span {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
}

.weapon-slot img {
    max-width: 38px;
    max-height: 38px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.block-slot-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #b45309, #78350f);
    border: 2px solid #fde68a;
    border-radius: 6px;
    color: #ffffff;
    font-weight: 900;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(180, 83, 9, 0.6);
}

.weapon-slot.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    transform: translateY(-4px);
}

.weapon-slot.active span {
    color: #3b82f6;
}

/* Ammo Box */
#ammo-box {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 14px;
    display: flex;
    align-items: baseline;
    gap: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.ammo-clip {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.5rem;
    color: #ffffff;
}

.ammo-reserve {
    font-size: 0.9rem;
    font-weight: 600;
    color: #94a3b8;
}

/* Controls Guide Overlay — Positioned Safely Below Health Bar */
.controls-guide {
    position: absolute;
    top: 135px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

.controls-guide span {
    font-weight: 800;
    color: #38bdf8;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Modal Overlay Screens (Start Menu / Game Over) */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 100;
}

.modal-card {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 2.5rem;
    width: 480px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.game-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 2.2rem;
    color: #4ef037;
    text-shadow: 0 0 20px rgba(78, 240, 55, 0.6), 0 4px 0 #1b6811;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
}

.game-title.danger {
    color: #f43f5e;
    text-shadow: 0 0 20px rgba(244, 63, 94, 0.6), 0 4px 0 #881337;
}

.game-subtitle {
    font-size: 1rem;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.credits-text {
    font-size: 0.9rem;
    color: #38bdf8;
    font-weight: 700;
    margin-top: -0.75rem;
    margin-bottom: 1.5rem;
}

.modal-body p {
    font-size: 0.95rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.btn-primary {
    width: 100%;
    padding: 14px 28px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffffff;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6);
}

.leaderboard-card {
    margin-top: 1.8rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-card h3 {
    font-size: 0.85rem;
    font-weight: 800;
    color: #fbbf24;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

#highscore-list, #highscore-list-end {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

#highscore-list li, #highscore-list-end li {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    color: #cbd5e1;
}

.name-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 1.5rem;
    text-align: left;
}

.name-input-group label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #94a3b8;
}

#player-name-input {
    width: 100%;
    padding: 12px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    outline: none;
}
