/* 
 * 2D CYBERPUNK RPG STYLES 
 * Theme: Retro CRT Monitor, Neon, Pixel Art UI
 */

:root {
    --bg-color: #050505;
    --neon-cyan: #00f0ff;
    --neon-purple: #c300ff;
    --neon-green: #00ff9d;
    --neon-red: #ff0055;
    --hud-bg: rgba(0, 20, 40, 0.85);
    --font-pixel: 'Press Start 2P', cursive;
    --font-tech: 'Share Tech Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: var(--font-tech);
    overflow: hidden;
    /* Prevent scrolling, game handles view */
    height: 100vh;
    width: 100vw;
}

/* --- GAME CONTAINER --- */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

canvas {
    display: block;
    image-rendering: pixelated;
    /* Crisp pixels */
}

/* --- CRT EFFECTS --- */
.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.2) 50%,
            rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10;
}

.vignette {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, transparent 50%, rgba(0, 0, 0, 0.9) 100%);
    pointer-events: none;
    z-index: 11;
}

/* --- HUD UI --- */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    /* Let clicks pass through to canvas primarily */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

/* Allow interaction with UI elements */
#ui-layer>* {
    pointer-events: auto;
}

/* Header */
.hud-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.profile-badge {
    display: flex;
    gap: 15px;
    align-items: center;
    background: var(--hud-bg);
    padding: 10px;
    border: 2px solid var(--neon-cyan);
    border-radius: 4px;
    box-shadow: 0 0 10px var(--neon-cyan);
}

.avatar-frame {
    width: 50px;
    height: 50px;
    background: #000;
    /* border removed */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-glitch {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--neon-purple);
    animation: text-flicker 2s infinite;
}

.player-name {
    font-size: 1.2rem;
    color: var(--neon-cyan);
    margin-bottom: 5px;
    text-shadow: 2px 2px 0 #000;
}

.hp-bar-container {
    width: 100px;
    height: 8px;
    background: #333;
    border: 1px solid #555;
}

.hp-bar {
    height: 100%;
    background: var(--neon-green);
    box-shadow: 0 0 5px var(--neon-green);
}

.system-status {
    text-align: right;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--neon-green);
    background: var(--hud-bg);
    padding: 10px;
    border: 1px solid var(--neon-green);
}

.blink-text {
    animation: blink 1s infinite step-end;
}

.crypto-balance {
    display: block;
    margin-top: 8px;
    font-size: 0.9rem;
    color: #ffd700;
}

/* Game Over Modal Overlay */
#game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 0, 0, 0.85);
    /* Reddish tint for danger */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    /* Highest priority */
    pointer-events: auto;
    backdrop-filter: blur(2px);
}

/* Notification / Interaction Terminal */
#notification-area {
    /* Full screen backdrop behavior */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    /* Backdrop dimming */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    /* Ensure high z-index */
    pointer-events: auto;
    /* Catch all clicks */
}

.hidden {
    display: none !important;
}

.terminal-box {
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--neon-cyan);
    padding: 20px;
    box-shadow: 0 0 50px rgba(0, 240, 255, 0.4);
    position: relative;
    max-width: 400px;
    width: 90%;
    z-index: 101;
}

.terminal-box::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid transparent;
    border-top-color: var(--neon-cyan);
    border-bottom-color: var(--neon-cyan);
    animation: border-pulse 2s infinite;
    pointer-events: none;
    /* Fix: Allow clicks to pass through */
}

#notif-title {
    color: var(--neon-cyan);
    font-family: var(--font-pixel);
    font-size: 0.9rem;
    margin-bottom: 15px;
    text-transform: uppercase;
}

#notif-message {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 20px;
    line-height: 1.4;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.hud-btn {
    background: transparent;
    border: 2px solid;
    padding: 10px 20px;
    color: white;
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    cursor: pointer;
    transition: 0.2s;
    min-width: 100px;
    position: relative;
    /* Fix: Elevate above pseudo-element */
    z-index: 2;
}

.hud-btn.neon-green {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

.hud-btn.neon-green:hover {
    background: var(--neon-green);
    color: black;
}

.hud-btn.neon-red {
    border-color: var(--neon-red);
    color: var(--neon-red);
}

.hud-btn.neon-red:hover {
    background: var(--neon-red);
    color: black;
}

/* Footer */
.hud-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.8rem;
    color: #888;
}

.key {
    display: inline-block;
    border: 1px solid #666;
    padding: 2px 5px;
    border-radius: 3px;
    color: white;
    background: #222;
    margin: 0 2px;
    font-family: var(--font-pixel);
    font-size: 0.6rem;
}

.wallet-display {
    background: #111;
    border: 1px solid #333;
    padding: 8px 12px;
    cursor: pointer;
    font-family: var(--font-tech);
}

.wallet-display:hover {
    border-color: var(--neon-green);
    color: var(--neon-green);
}

/* Mobile Controls */
.hidden-desktop {
    display: none;
}

@media (max-width: 768px) {
    .hidden-desktop {
        display: flex;
    }

    .desktop-only {
        display: none;
    }

    #touch-controls {
        position: absolute;
        bottom: 20px;
        left: 20px;
        right: 20px;
        justify-content: space-between;
        align-items: flex-end;
        pointer-events: none;
        /* Let touches pass through containers */
    }

    #touch-controls>* {
        pointer-events: auto;
    }

    .d-pad-area {
        width: 120px;
        height: 120px;
        position: relative;
    }

    .touch-hint {
        position: absolute;
        top: -30px;
        left: 0;
        width: 100%;
        text-align: center;
        font-size: 0.7rem;
        opacity: 0.5;
    }

    .virtual-joystick-base {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.2);
        background: rgba(0, 0, 0, 0.3);
        position: relative;
    }

    .virtual-joystick-stick {
        width: 40px;
        height: 40px;
        background: rgba(0, 240, 255, 0.5);
        border-radius: 50%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        box-shadow: 0 0 10px var(--neon-cyan);
    }

    .action-btn {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        background: rgba(195, 0, 255, 0.3);
        border: 2px solid var(--neon-purple);
        color: white;
        font-family: var(--font-pixel);
        font-size: 1.5rem;
        box-shadow: 0 0 15px var(--neon-purple);
    }

    .action-btn:active {
        background: var(--neon-purple);
    }
}

/* Animations */
@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes text-flicker {
    0% {
        opacity: 1;
    }

    3% {
        opacity: 0.1;
    }

    6% {
        opacity: 1;
    }

    7% {
        opacity: 0.1;
    }

    8% {
        opacity: 1;
    }

    9% {
        opacity: 1;
    }

    100% {
        opacity: 1;
    }
}