/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --pixel-green: #39ff14;
    --pixel-cyan: #00ffff;
    --pixel-magenta: #ff00ff;
    --pixel-yellow: #ffff00;
    --pixel-red: #ff3333;
    --pixel-orange: #ff8800;
    --pixel-blue: #4488ff;
    --bg-dark: #0a0a1a;
    --bg-panel: #111128;
    --border-color: #3a3a5c;
    --text-shadow-glow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 40px currentColor;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Press Start 2P', monospace;
    color: #ffffff;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Crect x='12' y='0' width='8' height='32' fill='%2339ff14'/%3E%3Crect x='0' y='12' width='32' height='8' fill='%2339ff14'/%3E%3C/svg%3E") 16 16, crosshair;
}

/* ========================================
   SCANLINES OVERLAY
   ======================================== */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.15) 2px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    z-index: 1000;
}

/* ========================================
   STARFIELD CANVAS
   ======================================== */
#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
}

/* ========================================
   CRT SCREEN
   ======================================== */
.crt-screen {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: crt-flicker 0.15s infinite alternate;
}

@keyframes crt-flicker {
    0% { opacity: 0.97; }
    100% { opacity: 1; }
}

/* ========================================
   GAME CONTAINER
   ======================================== */
.game-container {
    width: 90%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    position: relative;
}

/* ========================================
   HUD BAR
   ======================================== */
.hud-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    border: 3px solid var(--pixel-cyan);
    background: rgba(0, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2), inset 0 0 15px rgba(0, 255, 255, 0.05);
    image-rendering: pixelated;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    font-size: 8px;
    color: var(--pixel-cyan);
    letter-spacing: 2px;
}

.hud-value {
    font-size: 12px;
    color: var(--pixel-yellow);
    text-shadow: var(--text-shadow-glow);
}

.hud-hearts {
    font-size: 14px;
    color: var(--pixel-red);
    text-shadow: 0 0 10px var(--pixel-red), 0 0 20px var(--pixel-red);
    animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ========================================
   PIXEL CHARACTER
   ======================================== */
.pixel-character {
    position: absolute;
    top: 60px;
    right: -50px;
    width: 48px;
    height: 48px;
    animation: character-float 3s ease-in-out infinite;
}

.character-sprite {
    width: 100%;
    height: 100%;
    background: 
        /* Hat */
        linear-gradient(to right, transparent 8px, var(--pixel-red) 8px, var(--pixel-red) 40px, transparent 40px) no-repeat 0 0 / 48px 8px,
        linear-gradient(to right, transparent 4px, var(--pixel-red) 4px, var(--pixel-red) 44px, transparent 44px) no-repeat 0 8px / 48px 4px,
        /* Face */
        linear-gradient(to right, transparent 8px, var(--pixel-yellow) 8px, var(--pixel-yellow) 40px, transparent 40px) no-repeat 0 12px / 48px 12px,
        /* Eyes */
        linear-gradient(to right, transparent 14px, #000 14px, #000 18px, transparent 18px, transparent 30px, #000 30px, #000 34px, transparent 34px) no-repeat 0 16px / 48px 4px,
        /* Body */
        linear-gradient(to right, transparent 8px, var(--pixel-blue) 8px, var(--pixel-blue) 40px, transparent 40px) no-repeat 0 24px / 48px 16px,
        /* Belt */
        linear-gradient(to right, transparent 12px, var(--pixel-yellow) 12px, var(--pixel-yellow) 36px, transparent 36px) no-repeat 0 32px / 48px 4px,
        /* Legs */
        linear-gradient(to right, transparent 12px, var(--pixel-blue) 12px, var(--pixel-blue) 20px, transparent 20px, transparent 28px, var(--pixel-blue) 28px, var(--pixel-blue) 36px, transparent 36px) no-repeat 0 40px / 48px 8px;
    image-rendering: pixelated;
}

@keyframes character-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* ========================================
   TITLE
   ======================================== */
.title-block {
    text-align: center;
    margin: 10px 0;
}

.glitch-wrapper {
    position: relative;
}

.main-title {
    font-size: clamp(18px, 5vw, 36px);
    color: #ffffff;
    text-shadow:
        0 0 4px var(--pixel-green),
        0 0 12px rgba(57, 255, 20, 0.5),
        0 0 24px rgba(57, 255, 20, 0.2);
    letter-spacing: 4px;
    line-height: 1.6;
    -webkit-text-stroke: 1px var(--pixel-green);
    animation: title-pulse 2s ease-in-out infinite;
    position: relative;
}

/* Glitch effect layers */
.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: var(--pixel-cyan);
    z-index: -1;
    animation: glitch-1 3s infinite linear alternate-reverse;
}

.glitch::after {
    color: var(--pixel-magenta);
    z-index: -2;
    animation: glitch-2 2s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0%, 93% { clip-path: inset(0 0 0 0); transform: translate(0); }
    94% { clip-path: inset(20% 0 40% 0); transform: translate(-4px, 2px); }
    95% { clip-path: inset(60% 0 10% 0); transform: translate(4px, -2px); }
    96% { clip-path: inset(30% 0 30% 0); transform: translate(-2px, 1px); }
    97% { clip-path: inset(0 0 70% 0); transform: translate(3px, -1px); }
    98% { clip-path: inset(50% 0 20% 0); transform: translate(-3px, 2px); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

@keyframes glitch-2 {
    0%, 90% { clip-path: inset(0 0 0 0); transform: translate(0); }
    91% { clip-path: inset(40% 0 20% 0); transform: translate(3px, -2px); }
    93% { clip-path: inset(10% 0 50% 0); transform: translate(-3px, 1px); }
    95% { clip-path: inset(70% 0 5% 0); transform: translate(2px, -1px); }
    97% { clip-path: inset(25% 0 45% 0); transform: translate(-4px, 2px); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

@keyframes title-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.subtitle-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

.pixel-diamond {
    color: var(--pixel-yellow);
    font-size: 10px;
    animation: diamond-spin 2s linear infinite;
}

.subtitle {
    font-size: clamp(6px, 2vw, 10px);
    color: var(--pixel-cyan);
    letter-spacing: 3px;
    animation: blink-text 1.2s step-end infinite;
}

@keyframes diamond-spin {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(90deg); }
    50% { transform: rotate(180deg); }
    75% { transform: rotate(270deg); }
    100% { transform: rotate(360deg); }
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========================================
   PIXEL DIVIDER
   ======================================== */
.pixel-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 4px 0;
}

.pixel-divider span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--pixel-magenta);
    animation: divider-pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px var(--pixel-magenta);
}

.pixel-divider span.big {
    width: 12px;
    height: 12px;
    background: var(--pixel-yellow);
    box-shadow: 0 0 10px var(--pixel-yellow);
}

.pixel-divider span:nth-child(1) { animation-delay: 0s; }
.pixel-divider span:nth-child(2) { animation-delay: 0.1s; }
.pixel-divider span:nth-child(3) { animation-delay: 0.2s; }
.pixel-divider span:nth-child(4) { animation-delay: 0.3s; }
.pixel-divider span:nth-child(5) { animation-delay: 0.4s; }
.pixel-divider span:nth-child(6) { animation-delay: 0.5s; }
.pixel-divider span:nth-child(7) { animation-delay: 0.4s; }
.pixel-divider span:nth-child(8) { animation-delay: 0.3s; }
.pixel-divider span:nth-child(9) { animation-delay: 0.2s; }
.pixel-divider span:nth-child(10) { animation-delay: 0.1s; }
.pixel-divider span:nth-child(11) { animation-delay: 0s; }

@keyframes divider-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

/* ========================================
   DIALOG BOX (RPG Style)
   ======================================== */
.dialog-box {
    width: 100%;
}

.dialog-border {
    border: 4px solid #ffffff;
    border-radius: 4px;
    padding: 4px;
    background: var(--bg-panel);
    box-shadow:
        0 0 0 2px var(--bg-dark),
        0 0 20px rgba(255, 255, 255, 0.1),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.dialog-inner {
    border: 2px solid var(--border-color);
    padding: 16px 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    position: relative;
}

.dialog-text {
    font-size: clamp(7px, 1.8vw, 10px);
    line-height: 2.2;
    color: #e0e0e0;
    letter-spacing: 1px;
}

.dialog-arrow {
    position: absolute;
    bottom: 8px;
    right: 12px;
    color: var(--pixel-cyan);
    font-size: 10px;
    animation: arrow-bounce 0.8s ease-in-out infinite;
}

@keyframes arrow-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* ========================================
   MENU (Game Menu Style)
   ======================================== */
.menu-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    text-decoration: none;
    color: #ffffff;
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(7px, 1.8vw, 10px);
    transition: all 0.1s step-end;
    position: relative;
    cursor: pointer;
}

.menu-item:not(.menu-item-disabled):hover {
    border-color: var(--pixel-green);
    background: rgba(57, 255, 20, 0.08);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.15), inset 0 0 15px rgba(57, 255, 20, 0.05);
}

.menu-item:not(.menu-item-disabled):hover .menu-arrow {
    color: var(--pixel-green);
    animation: arrow-right-bounce 0.5s step-end infinite;
}

.menu-item:not(.menu-item-disabled):hover .menu-text {
    color: var(--pixel-green);
    text-shadow: 0 0 10px var(--pixel-green);
}

.menu-arrow {
    color: var(--pixel-yellow);
    font-size: 12px;
    flex-shrink: 0;
}

.menu-text {
    flex: 1;
    letter-spacing: 2px;
}

.menu-badge {
    font-size: 6px;
    padding: 4px 8px;
    background: var(--pixel-magenta);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    letter-spacing: 1px;
    box-shadow: 0 0 8px rgba(255, 0, 255, 0.4);
}

.menu-item-disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.dim {
    opacity: 0.5;
}

@keyframes arrow-right-bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* Main CTA link - big and impossible to miss */
.menu-item-main {
    padding: 16px 20px;
    border: 3px solid var(--pixel-green) !important;
    background: rgba(57, 255, 20, 0.06) !important;
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.2), inset 0 0 20px rgba(57, 255, 20, 0.05);
    font-size: clamp(9px, 2.2vw, 13px) !important;
    animation: cta-pulse 2s ease-in-out infinite;
    position: relative;
}

.menu-item-main .menu-text {
    color: var(--pixel-green);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
}

.menu-item-main .menu-arrow {
    color: var(--pixel-green);
    font-size: 16px;
}

@keyframes cta-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(57, 255, 20, 0.15), inset 0 0 15px rgba(57, 255, 20, 0.03); }
    50% { box-shadow: 0 0 30px rgba(57, 255, 20, 0.35), inset 0 0 25px rgba(57, 255, 20, 0.08); }
}

/* Click here label */
.click-here {
    font-size: clamp(7px, 1.5vw, 9px);
    color: var(--pixel-yellow);
    text-shadow: 0 0 8px var(--pixel-yellow);
    animation: click-bounce 1s ease-in-out infinite;
    white-space: nowrap;
    margin-left: 8px;
}

@keyframes click-bounce {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(-6px); opacity: 0.6; }
}

/* ========================================
   ENEMIES
   ======================================== */
.enemies-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.enemy {
    position: absolute;
    font-size: 20px;
    image-rendering: pixelated;
    animation: enemy-float 4s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(255, 0, 0, 0.5));
    pointer-events: auto;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Crect x='12' y='0' width='8' height='32' fill='%23ff3333'/%3E%3Crect x='0' y='12' width='32' height='8' fill='%23ff3333'/%3E%3C/svg%3E") 16 16, crosshair;
    transition: transform 0.1s;
}

.enemy:hover {
    transform: scale(1.3);
}

.enemy.destroyed {
    animation: enemy-explode 0.5s forwards;
}

@keyframes enemy-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(5deg); }
    75% { transform: translateY(10px) rotate(-5deg); }
}

@keyframes enemy-explode {
    0% { transform: scale(1); opacity: 1; filter: brightness(1); }
    30% { transform: scale(1.5); opacity: 1; filter: brightness(3) hue-rotate(90deg); }
    100% { transform: scale(0); opacity: 0; filter: brightness(5); }
}

/* ========================================
   BOTTOM BAR
   ======================================== */
.bottom-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.blink {
    font-size: clamp(6px, 1.5vw, 9px);
    color: var(--pixel-yellow);
    animation: blink-text 1s step-end infinite;
    letter-spacing: 3px;
    text-shadow: 0 0 10px var(--pixel-yellow);
}

.copyright {
    font-size: 6px;
    color: var(--border-color);
    letter-spacing: 1px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 500px) {
    .game-container {
        width: 95%;
        gap: 14px;
        padding: 12px;
    }

    .hud-bar {
        padding: 6px 8px;
    }

    .hud-label {
        font-size: 6px;
    }

    .hud-value {
        font-size: 9px;
    }

    .pixel-character {
        display: none;
    }

    .dialog-inner {
        padding: 12px;
    }

    .menu-item {
        padding: 10px 12px;
    }

    .menu-badge {
        font-size: 5px;
        padding: 3px 5px;
    }
}

/* Power on animation */
@keyframes power-on {
    0% {
        filter: brightness(30) saturate(0);
        transform: scale(1, 0.01);
    }
    20% {
        filter: brightness(10) saturate(0);
        transform: scale(1, 0.01);
    }
    40% {
        filter: brightness(3) saturate(0.5);
        transform: scale(1.1, 0.8);
    }
    60% {
        filter: brightness(1.5) saturate(0.8);
        transform: scale(0.98, 1.02);
    }
    80% {
        filter: brightness(1.1) saturate(1);
        transform: scale(1.01, 0.99);
    }
    100% {
        filter: brightness(1) saturate(1);
        transform: scale(1);
    }
}

.crt-screen {
    animation: power-on 1.2s ease-out forwards, crt-flicker 0.15s 1.2s infinite alternate;
}
