/* ============================================
   TYPING OF THE DEAD — Global Styles
   Keyboard-Only Zombie Typing Game
   ============================================ */

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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Share Tech Mono', monospace;
    color: #e0e0e0;
    cursor: default;
    user-select: none;
}

/* ---- Canvas ---- */
#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

/* ---- UI Root ---- */
#ui-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

#ui-root>* {
    pointer-events: auto;
}

/* ---- Main Menu ---- */
.menu-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(10, 25, 10, 0.92) 0%, rgba(0, 0, 0, 0.97) 80%);
    backdrop-filter: blur(6px);
    animation: fadeIn 0.6s ease-out;
}

.menu-screen h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 6px;
    color: #00ff66;
    text-shadow:
        0 0 10px #00ff66,
        0 0 30px #00cc44,
        0 0 60px #009933;
    margin-bottom: 0.3rem;
    animation: glitch 3s infinite;
}

.menu-screen .subtitle {
    font-size: 1rem;
    color: #77aa77;
    letter-spacing: 4px;
    margin-bottom: 3rem;
    text-transform: uppercase;
}

.menu-screen .difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 340px;
}

.menu-screen .difficulty-btn {
    padding: 16px 32px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    border: 2px solid;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.difficulty-btn .btn-desc {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 1px;
    opacity: 0.6;
    text-transform: none;
}

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

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

.difficulty-btn.normal {
    color: #00ff66;
    border-color: #00ff6644;
}

.difficulty-btn.normal:hover {
    background: rgba(0, 255, 102, 0.1);
    border-color: #00ff66;
    box-shadow: 0 0 20px rgba(0, 255, 102, 0.3);
}

.difficulty-btn.medium {
    color: #ffaa00;
    border-color: #ffaa0044;
}

.difficulty-btn.medium:hover {
    background: rgba(255, 170, 0, 0.1);
    border-color: #ffaa00;
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.3);
}

.difficulty-btn.hard {
    color: #ff3344;
    border-color: #ff334444;
}

.difficulty-btn.hard:hover {
    background: rgba(255, 51, 68, 0.1);
    border-color: #ff3344;
    box-shadow: 0 0 20px rgba(255, 51, 68, 0.3);
}

.menu-screen .instructions {
    margin-top: 2.5rem;
    text-align: center;
    color: #557755;
    font-size: 0.85rem;
    line-height: 2;
    letter-spacing: 1px;
}

.menu-screen .keyboard-only {
    display: inline-block;
    margin-top: 0.5rem;
    color: #00ff66;
    font-weight: bold;
    letter-spacing: 2px;
}

/* ---- HUD ---- */
.hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    padding: 24px;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #00ff66;
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.5);
}

.hud-wave {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    color: #88bbaa;
    text-shadow: 0 0 6px rgba(136, 187, 170, 0.4);
}

.hud-health-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-health-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: #cc4444;
    letter-spacing: 2px;
}

.hud-health-bar {
    width: 220px;
    height: 14px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 50, 50, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.hud-health-fill {
    height: 100%;
    background: linear-gradient(90deg, #22cc44, #44ff66);
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(34, 204, 68, 0.6);
}

.hud-bottom {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.hud-typed-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.2rem;
    color: #00ff66;
    text-shadow: 0 0 12px rgba(0, 255, 102, 0.7);
    letter-spacing: 6px;
    min-height: 3rem;
    min-width: 200px;
    text-align: center;
    padding: 10px 32px;
    border: 2px solid rgba(0, 255, 102, 0.2);
    border-radius: 6px;
    background: rgba(0, 20, 0, 0.6);
    backdrop-filter: blur(4px);
    transition: all 0.15s ease;
}

.hud-typed-text.active {
    border-color: rgba(0, 255, 102, 0.5);
    background: rgba(0, 30, 0, 0.7);
    box-shadow: 0 0 20px rgba(0, 255, 102, 0.15);
}

.hud-typed-text.miss {
    color: #ff4444 !important;
    border-color: #ff4444 !important;
    text-shadow: 0 0 12px rgba(255, 68, 68, 0.7) !important;
    animation: shake 0.25s ease;
}

.hud-target-word {
    font-size: 0.9rem;
    color: #557755;
    letter-spacing: 3px;
}

.hud-hint {
    font-size: 0.8rem;
    color: #446644;
    letter-spacing: 1px;
    animation: pulse 2s ease-in-out infinite;
}

/* ---- Damage Overlay ---- */
.damage-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.damage-overlay.flash {
    opacity: 1;
    background: radial-gradient(ellipse at center,
            transparent 40%,
            rgba(255, 0, 0, 0.4) 100%);
    animation: damageFlash 0.3s ease-out forwards;
}

/* ---- Game Over ---- */
.gameover-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(40, 5, 5, 0.94) 0%, rgba(0, 0, 0, 0.98) 80%);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.8s ease-out;
}

.gameover-screen h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: #ff3344;
    text-shadow:
        0 0 10px #ff3344,
        0 0 40px #cc0022;
    letter-spacing: 6px;
    margin-bottom: 1.5rem;
}

.gameover-screen .final-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.8rem;
    color: #ffaa00;
    text-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
    margin-bottom: 0.5rem;
}

.gameover-screen .stats {
    font-size: 1rem;
    color: #888;
    margin-bottom: 2.5rem;
    text-align: center;
    line-height: 1.8;
}

.gameover-screen .restart-btn {
    padding: 14px 48px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #00ff66;
    background: transparent;
    border: 2px solid #00ff6644;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.gameover-screen .restart-btn:hover {
    background: rgba(0, 255, 102, 0.1);
    border-color: #00ff66;
    box-shadow: 0 0 25px rgba(0, 255, 102, 0.3);
}

/* ---- Wave Announcement ---- */
.wave-announce {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: #00ff66;
    text-shadow: 0 0 20px rgba(0, 255, 102, 0.6);
    letter-spacing: 6px;
    animation: waveAnnounce 2s ease-out forwards;
    pointer-events: none;
}

/* ---- Muzzle Flash ---- */
.muzzle-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, rgba(68, 255, 136, 0.1) 0%, transparent 50%);
    pointer-events: none;
    animation: flashOut 0.12s ease-out forwards;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes waveAnnounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

@keyframes flashOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes glitch {

    0%,
    93%,
    100% {
        opacity: 1;
        transform: translate(0);
    }

    94% {
        opacity: 0.8;
        transform: translate(-2px, 1px);
    }

    95% {
        opacity: 1;
        transform: translate(1px, -1px);
    }

    96% {
        opacity: 0.9;
        transform: translate(-1px, 0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(-50%);
    }

    25% {
        transform: translateX(calc(-50% - 6px));
    }

    50% {
        transform: translateX(calc(-50% + 6px));
    }

    75% {
        transform: translateX(calc(-50% - 4px));
    }
}

@keyframes damageFlash {
    0% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}