/* ============================================================================
   N.A.Y. EVO - SPEEDRUN EDITION - STYLESHEET
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
    --p-color: #00ff41;
    --bg-color: #050505;
}

body {
    background-color: var(--bg-color);
    color: var(--p-color);
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

/* ============================================================================
   VIEWPORT & CARTES
   ============================================================================ */

#viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: #000;
    cursor: grab;
    z-index: 0;
}

#viewport:active {
    cursor: grabbing;
}

#world-container {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
    display: block;
    width: 100%;
    height: 100%;
}

#map-canvas {
    z-index: 0;
}

#fx-canvas {
    z-index: 20;
    pointer-events: none;
}

#world-entities {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* ============================================================================
   ENTITÉS
   ============================================================================ */

.entity {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    will-change: left, top;
    transition: transform 0.1s;
}

.entity.grabbed {
    z-index: 100 !important;
    transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
    opacity: 0.9;
    pointer-events: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.entity img {
    border-radius: 50%;
    box-shadow: 0 0 5px currentColor;
    border: 2px solid currentColor;
    object-fit: cover;
    width: 100%;
    height: 100%;
    background: #111;
}

/* Couleurs des unités */
.unit-worker img {
    border-color: #00ffff;
    box-shadow: 0 0 5px #00ffff;
}

.unit-soldier img {
    border-color: #3b82f6;
    box-shadow: 0 0 10px #3b82f6;
}

.unit-researcher img {
    border-color: #ffffff;
    box-shadow: 0 0 8px #ffffff;
}

.unit-zombie img {
    border-color: #ff0040;
    filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(5);
    box-shadow: 0 0 12px #ff0040;
}

/* ============================================================================
   BÂTIMENTS
   ============================================================================ */

.building-base {
    width: 44px;
    height: 44px;
    border: 2px solid #222;
    background: rgba(10, 15, 10, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    z-index: 5;
    transition: transform 0.2s;
}

.building-base:hover {
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 50;
    border-color: var(--p-color);
    box-shadow: 0 0 15px var(--p-color);
}

.building-info {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    color: white;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

.building-base:hover .building-info {
    opacity: 1;
}

.bldg-hp {
    position: absolute;
    bottom: -8px;
    width: 30px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    display: none;
    border: 1px solid #111;
}

.bldg-hp-fill {
    height: 100%;
    background: #00ff41;
    width: 100%;
    transition: width 0.2s;
}

/* ============================================================================
   RESSOURCES
   ============================================================================ */

.resource-node {
    position: absolute;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    animation: bounce 3s infinite ease-in-out;
    pointer-events: auto;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

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

/* ============================================================================
   BARRES DE STATS
   ============================================================================ */

.bars-container {
    width: 28px;
    height: 4px;
    background: #222;
    margin-top: 3px;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid #111;
}

.hp-fill {
    height: 100%;
    background: #00ff41;
    width: 100%;
    transition: width 0.2s;
    position: absolute;
    left: 0;
}

.inf-fill {
    height: 100%;
    background: #ff0040;
    width: 0%;
    transition: width 0.2s;
    position: absolute;
    right: 0;
    mix-blend-mode: lighten;
}

/* ============================================================================
   BLUEPRINT & CURSEUR
   ============================================================================ */

.blueprint {
    position: absolute;
    pointer-events: none;
    z-index: 99;
    opacity: 0.7;
    display: none;
    transform: translate(-50%, -50%);
    border: 2px dashed;
    border-radius: 10px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: left 0.05s, top 0.05s;
}

.blueprint.valid {
    background: rgba(0, 255, 65, 0.3);
    border-color: #00ff41;
    box-shadow: 0 0 15px #00ff41;
}

.blueprint.invalid {
    background: rgba(255, 0, 0, 0.3);
    border-color: #ff0000;
    box-shadow: 0 0 15px #ff0000;
}

.blueprint.destroy {
    background: rgba(255, 100, 0, 0.3);
    border-color: #ff8800;
    border-style: solid;
    box-shadow: 0 0 20px #ff8800;
    border-radius: 50%;
    width: 60px;
    height: 60px;
}

.blueprint.interact {
    background: rgba(0, 255, 255, 0.2);
    border-color: #0ff;
    border-style: dotted;
    border-radius: 50%;
    width: 80px;
    height: 80px;
}

/* ============================================================================
   UI - STYLE GLASS
   ============================================================================ */

.glass-ui {
    background: rgba(10, 15, 10, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 255, 65, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

/* ============================================================================
   TOP BAR
   ============================================================================ */

#top-bar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 98%;
    max-width: 1000px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    z-index: 100;
}

.res-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
    justify-content: center;
}

.res-pill {
    display: flex;
    align-items: center;
    font-size: 11px;
    padding: 4px 8px;
    background: rgba(5, 10, 5, 0.9);
    border: 1px solid rgba(0, 255, 65, 0.3);
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}

.res-val {
    margin-left: 5px;
    font-weight: bold;
    color: white;
}

.res-capped {
    color: #ffeb3b !important;
    text-shadow: 0 0 5px #ffeb3b;
}

/* ============================================================================
   TIME CONTROLS
   ============================================================================ */

.time-controls {
    display: flex;
    align-items: center;
    background: rgba(20, 0, 0, 0.8);
    border: 1px solid #ff0040;
    border-radius: 8px;
    padding: 2px 6px;
    gap: 5px;
}

.speed-btn {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
}

.speed-btn.active {
    color: #00ff41;
    text-shadow: 0 0 8px #00ff41;
}

.speed-btn.paused {
    color: #facc15;
    text-shadow: 0 0 8px #facc15;
}

/* ============================================================================
   DOCK
   ============================================================================ */

#dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 400px;
    height: 65px;
    border-radius: 35px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.dock-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a1a1a;
    color: #888;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dock-btn:hover {
    transform: scale(1.1);
    color: white;
    border-color: white;
}

.dock-btn.active {
    border-color: var(--p-color);
    color: var(--p-color);
    background: rgba(0, 40, 10, 0.9);
    box-shadow: 0 0 15px var(--p-color);
    transform: translateY(-5px);
}

/* ============================================================================
   BUILD DRAWER
   ============================================================================ */

#build-drawer {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: rgba(5, 5, 5, 0.98);
    border-top: 2px solid var(--p-color);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    z-index: 90;
    transition: bottom 0.3s ease-out;
    max-height: 50vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#build-drawer.open {
    bottom: 0;
}

.build-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 800px;
}

.build-card {
    border: 1px solid #333;
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    font-size: 9px;
    color: #ccc;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.1s;
}

.build-card.affordable {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.15);
    box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.1);
}

.build-card.unaffordable {
    opacity: 0.5;
    filter: grayscale(0.8);
    background: #111;
}

.build-card.locked {
    opacity: 0.3;
    filter: grayscale(1);
    pointer-events: none;
    background: #000;
}

.build-emoji {
    font-size: 22px;
    margin-bottom: 2px;
}

/* ============================================================================
   ROTATION BUTTON
   ============================================================================ */

#rotate-btn {
    display: none;
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    z-index: 150;
    border: 1px solid #00ff41;
    background: rgba(5, 10, 5, 0.95);
    backdrop-filter: blur(5px);
}

/* ============================================================================
   MENUS & ÉCRANS
   ============================================================================ */

#main-menu, #game-over, #victory {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(5, 5, 5, 0.95);
    backdrop-filter: blur(10px);
}

#game-over, #victory {
    display: none;
    z-index: 1500;
}

.title-glow {
    text-shadow: 0 0 20px currentColor;
}

.main-btn {
    padding: 15px 40px;
    font-size: 1.5rem;
    border: 2px solid var(--p-color);
    background: #111;
    color: var(--p-color);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    border-radius: 8px;
}

.main-btn:hover {
    background: var(--p-color);
    color: #000;
    box-shadow: 0 0 20px var(--p-color);
}

/* ============================================================================
   MENU DIFFICULTÉS
   ============================================================================ */

.diff-btn {
    padding: 10px 20px;
    border: 2px solid #444;
    background: #111;
    color: #888;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
    font-size: 14px;
}

.diff-btn:hover {
    background: #222;
}

.diff-btn.active.peaceful {
    border-color: #00ff41;
    color: #00ff41;
    box-shadow: 0 0 15px #00ff41;
}

.diff-btn.active.default {
    border-color: #3b82f6;
    color: #3b82f6;
    box-shadow: 0 0 15px #3b82f6;
}

.diff-btn.active.hardcore {
    border-color: #ff0040;
    color: #ff0040;
    box-shadow: 0 0 15px #ff0040;
}

/* ============================================================================
   ALERTE DE VAGUE
   ============================================================================ */

#wave-alert {
    display: none;
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 0, 64, 0.9);
    border: 2px solid #ff0040;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 14px;
    color: white;
    font-weight: bold;
    text-shadow: 0 0 5px black;
    z-index: 150;
    animation: alertPulse 1s infinite alternate;
    white-space: nowrap;
    box-shadow: 0 0 20px #ff0040;
}

@keyframes alertPulse {
    from {
        box-shadow: 0 0 10px #ff0040;
        transform: translateX(-50%) scale(1);
    }
    to {
        box-shadow: 0 0 30px #ff0040;
        transform: translateX(-50%) scale(1.05);
    }
}

/* ============================================================================
   EFFETS
   ============================================================================ */

.floater {
    position: absolute;
    font-weight: bold;
    font-size: 13px;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 200;
    text-shadow: 0 0 3px black;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-40px) scale(1.2);
        opacity: 0;
    }
}

.shake {
    animation: shake 0.4s both;
}

@keyframes shake {
    10%, 90% {
        transform: translate3d(-1px, 0, 0);
    }
    20%, 80% {
        transform: translate3d(2px, 0, 0);
    }
}

.toast {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
}
