/* ==========================================================================
   FINAL WAR: DEATH ZONE
   Authentic Hyper-Casual 3D Crowd Runner & Horde Shooter Stylesheet
   ========================================================================== */

:root {
    --track-blue: #70B8E8;
    --track-surface: #E8F4FC;
    --ui-blue-bg: #1B2B48;
    --ui-card-bg: #243B61;
    --ui-slot-bg: #1A2840;
    --btn-green: #38B000;
    --btn-green-hover: #48CA04;
    --btn-green-shadow: #1E6600;
    --accent-gold: #FFD166;
    --accent-cyan: #00F0FF;
    --accent-red: #FF3366;
    --font-heading: 'Orbitron', 'Fredoka One', sans-serif;
    --font-ui: 'Rajdhani', -apple-system, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #64B5F6;
    font-family: var(--font-ui);
    font-weight: 700;
    color: #FFFFFF;
    touch-action: none;
}

/* 3D WebGL Canvas */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* UI Overlay */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

button, .clickable, .slot-card, .weapon-card, .tree-node, .tab-btn, .big-green-upgrade-btn, .play-prompt-bar {
    pointer-events: auto;
    touch-action: manipulation;
}

/* ==========================================================================
   TOP BAR (Settings, Level Roadmap, Coins)
   ========================================================================== */

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(8px, 2vw, 14px) clamp(10px, 3vw, 20px);
    background: linear-gradient(180deg, rgba(16, 28, 48, 0.85) 0%, rgba(16, 28, 48, 0) 100%);
    pointer-events: auto;
    z-index: 20;
    gap: 8px;
}

.top-round-btn {
    width: clamp(36px, 8vw, 44px);
    height: clamp(36px, 8vw, 44px);
    border-radius: 50%;
    background: #203554;
    border: 2px solid #3A5A8C;
    color: #FFF;
    font-size: clamp(16px, 4vw, 20px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.top-round-btn:hover {
    transform: scale(1.08);
}

/* Level Roadmap Track */
.level-banner {
    flex: 1;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-title-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 3px;
    font-family: var(--font-heading);
    font-size: clamp(11px, 2.5vw, 13px);
}

.level-text {
    color: #FFF;
    letter-spacing: 1px;
}

.dps-pill {
    color: var(--accent-gold);
    background: rgba(0, 0, 0, 0.4);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 11px;
}

.roadmap-track {
    position: relative;
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #3A5A8C;
    border-radius: 8px;
}

.roadmap-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00B4D8, #00F0FF);
    border-radius: 6px;
    transition: width 0.1s linear;
}

.roadmap-node {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    background: #1B2B48;
    border: 2px solid #FFD166;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.roadmap-node.start { left: 0%; }
.roadmap-node.mid:nth-of-type(2) { left: 33%; }
.roadmap-node.mid:nth-of-type(3) { left: 66%; }
.roadmap-node.boss {
    left: 100%;
    border-color: #FF3366;
    background: #400A1A;
    animation: bossPulse 1.2s infinite alternate;
}

@keyframes bossPulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    100% { transform: translate(-50%, -50%) scale(1.25); }
}

.player-marker {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    filter: drop-shadow(0 0 5px #00F0FF);
    transition: left 0.1s linear;
}

/* Coin Badge */
.coin-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: clamp(4px, 1.5vw, 6px) clamp(10px, 2.5vw, 14px);
    background: #203554;
    border: 2px solid #FFD166;
    border-radius: 20px;
    font-family: var(--font-heading);
    font-size: clamp(12px, 2.5vw, 15px);
    color: #FFD166;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Squad Headcount Floating Badge */
.squad-floating-badge {
    position: absolute;
    top: clamp(65px, 12vw, 85px);
    left: 50%;
    transform: translateX(-50%);
    background: #0077B6;
    border: 2px solid #00F0FF;
    border-radius: 16px;
    padding: 3px 12px;
    font-family: var(--font-heading);
    font-size: 14px;
    color: #FFF;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0, 180, 216, 0.5);
    z-index: 15;
}

/* Boss Health HUD */
.boss-hud {
    position: absolute;
    top: clamp(70px, 14vw, 95px);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 480px;
    background: rgba(30, 10, 20, 0.9);
    border: 2px solid #FF3366;
    border-radius: 12px;
    padding: 8px 14px;
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.6);
    display: none;
    z-index: 18;
}

.boss-title-row {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-heading);
    font-size: 11px;
    color: #FFAACC;
    margin-bottom: 5px;
}

.boss-bar-track {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.boss-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #FF7700, #FF0055);
    box-shadow: 0 0 10px #FF3366;
    transition: width 0.15s ease-out;
}

/* Floating Combat Numbers */
#combat-text-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 12;
}

.pop-text {
    position: absolute;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: clamp(14px, 3vw, 20px);
    transform: translate(-50%, -50%);
    animation: popUp 0.75s ease-out forwards;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

.pop-text.dmg { color: #FFF; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9); }
.pop-text.crit { color: #FF3366; font-size: clamp(18px, 4vw, 26px); text-shadow: 0 0 12px #FF0055, 0 0 24px #FF3366; }
.pop-text.fire { color: #FFAA00; font-size: clamp(18px, 4.2vw, 28px); text-shadow: 0 0 12px #FF5500, 0 0 24px #FF2200; font-style: italic; }
.pop-text.gate { color: #00F0FF; font-size: clamp(18px, 4vw, 24px); text-shadow: 0 0 12px #00F0FF, 0 0 24px #0077B6; }

.pop-text.hidden, .hidden {
    display: none !important;
}

@keyframes popUp {
    0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
    30% { transform: translate(-50%, -30px) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(0.9); }
}

/* ==========================================================================
   MAIN MENU: GEARING SCREEN & INVENTORY (EXACT INFOGRAPHIC RECREATION)
   ========================================================================== */

.menu-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 30%, rgba(20, 38, 64, 0.75) 0%, rgba(10, 20, 36, 0.92) 100%);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(8px, 1.8vh, 16px);
    padding: clamp(50px, 8vh, 65px) clamp(10px, 3vw, 20px) clamp(16px, 3vh, 28px);
    z-index: 30;
    pointer-events: auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-backdrop.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.game-brand-title {
    font-family: var(--font-heading);
    font-size: clamp(18px, 4.5vw, 30px);
    font-weight: 900;
    color: #FFF;
    text-shadow: 0 0 15px rgba(0, 180, 216, 0.5);
    letter-spacing: 2px;
    text-align: center;
    flex-shrink: 0;
}

.game-brand-title .highlight {
    color: #FF3366;
    text-shadow: 0 0 15px rgba(255, 51, 102, 0.6);
}

/* Gearing Main Card - Fully Responsive Mobile & Desktop */
.gearing-main-card {
    width: 100%;
    max-width: 580px;
    background: var(--ui-card-bg);
    border: 2px solid #3A5A8C;
    border-radius: 18px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

@media (min-width: 560px) {
    .gearing-main-card {
        flex-direction: row;
        max-height: 480px;
    }
}

/* Left Column: Character Preview & Equipment Slots */
.character-preview-col {
    background: #1E3150;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 2px solid #3A5A8C;
}

@media (min-width: 560px) {
    .character-preview-col {
        border-bottom: none;
        border-right: 2px solid #3A5A8C;
        width: 210px;
        flex-shrink: 0;
    }
}

.char-viewport {
    height: 75px;
    background: radial-gradient(circle, #2A4874 0%, #15243C 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #3A5A8C;
    position: relative;
}

.char-avatar-render {
    font-size: 32px;
    filter: drop-shadow(0 0 8px #00F0FF);
}

.hero-name-tag {
    font-family: var(--font-heading);
    font-size: 10px;
    color: var(--accent-cyan);
    letter-spacing: 1px;
}

/* Equipment Slots (Rifle, Armor, Special) */
.equip-slots-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

@media (min-width: 560px) {
    .equip-slots-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
}

.slot-card {
    background: var(--ui-slot-bg);
    border: 1.5px solid #3A5A8C;
    border-radius: 10px;
    padding: 8px 6px;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

@media (min-width: 560px) {
    .slot-card {
        padding: 6px 10px;
        align-items: flex-start;
        text-align: left;
    }
}

.slot-card:active {
    transform: scale(0.97);
    border-color: #00F0FF;
}

.slot-card.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.slot-badge {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    background: #0077B6;
    color: #FFF;
    font-size: 8px;
    font-family: var(--font-heading);
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
}

@media (min-width: 560px) {
    .slot-badge {
        left: 8px;
        transform: none;
    }
}
    border-radius: 4px;
}

.slot-icon-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.slot-emoji {
    font-size: 20px;
}

.slot-title {
    font-family: var(--font-heading);
    font-size: 12px;
    color: #FFF;
}

.slot-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

/* Right Column: Inventory & Skill Tree */
.inventory-col {
    flex: 1.3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
}

.inv-title {
    font-family: var(--font-heading);
    font-size: 13px;
    letter-spacing: 1px;
    color: #FFF;
}

.tab-switcher {
    display: flex;
    gap: 4px;
}

.tab-btn {
    background: #1A2840;
    border: 1px solid #3A5A8C;
    color: rgba(255, 255, 255, 0.7);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 10px;
    cursor: pointer;
}

.tab-btn.active {
    background: #0077B6;
    border-color: #00F0FF;
    color: #FFF;
}

.tab-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.tab-panel.active {
    display: block;
}

/* Weapons Grid */
.weapons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.weapon-card {
    background: #1A2840;
    border: 2px solid #3A5A8C;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.weapon-card:hover {
    border-color: #00F0FF;
}

.weapon-card.selected {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.15);
}

.weapon-card.locked {
    opacity: 0.5;
    filter: grayscale(0.8);
}

.w-icon {
    font-size: 26px;
}

.w-name {
    font-family: var(--font-heading);
    font-size: 10px;
    margin-top: 3px;
    text-align: center;
}

.w-cost {
    font-size: 9px;
    color: var(--accent-gold);
    margin-top: 2px;
}

/* Skill Tree Layout (Matches Infographic Gearing Screen) */
.skill-tree-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.tree-row {
    display: flex;
    gap: 12px;
}

.tree-node {
    background: #1A2840;
    border: 2px solid #3A5A8C;
    border-radius: 10px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 65px;
    transition: all 0.15s ease;
}

.tree-node:hover {
    border-color: var(--accent-gold);
    transform: scale(1.05);
}

.tree-node.pulse-highlight {
    border-color: #00F0FF;
    background: rgba(0, 240, 255, 0.25);
    box-shadow: 0 0 15px #00F0FF;
    transform: scale(1.12);
}

.node-icon { font-size: 20px; }
.node-label { font-size: 9px; color: rgba(255, 255, 255, 0.7); }
.node-lvl { font-family: var(--font-heading); font-size: 10px; color: var(--accent-gold); }

/* Big Green Upgrade Action Bar */
.upgrade-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.unit-stat-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 9px;
    color: var(--accent-cyan);
}

.side-icon { font-size: 16px; }

.big-green-upgrade-btn {
    flex: 1;
    background: linear-gradient(180deg, var(--btn-green-hover) 0%, var(--btn-green) 100%);
    border: 2px solid #6BE82A;
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--btn-green-shadow), 0 8px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-green-upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 var(--btn-green-shadow), 0 12px 20px rgba(0, 0, 0, 0.5);
}

.big-green-upgrade-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 var(--btn-green-shadow);
}

.big-green-upgrade-btn.disabled {
    opacity: 0.5;
    filter: grayscale(0.8);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 0 #333;
}

.big-green-upgrade-btn.full-width {
    width: 100%;
}

.big-green-upgrade-btn.red-btn {
    background: linear-gradient(180deg, #FF3366 0%, #CC0033 100%);
    border-color: #FFAACC;
    box-shadow: 0 6px 0 #880022;
}

.upg-txt {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 900;
    color: #FFF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

.upg-cost {
    font-family: var(--font-heading);
    font-size: 12px;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 3px;
}

.play-prompt-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    margin-top: 6px;
    margin-bottom: 12px;
    pointer-events: auto;
    touch-action: manipulation;
    width: 100%;
    max-width: 440px;
    flex-shrink: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.battle-start-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(180deg, #48CA04 0%, #2B8A00 100%);
    border: 2.5px solid #70E000;
    box-shadow: 0 6px 0 #185200, 0 10px 24px rgba(72, 202, 4, 0.45);
    border-radius: 30px;
    padding: 14px 28px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    animation: pulseStart 2.2s infinite ease-in-out;
}

@keyframes pulseStart {
    0%, 100% { box-shadow: 0 6px 0 #185200, 0 8px 20px rgba(72, 202, 4, 0.4); }
    50% { box-shadow: 0 6px 0 #185200, 0 12px 30px rgba(72, 202, 4, 0.75); }
}

.battle-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #185200, 0 12px 28px rgba(72, 202, 4, 0.55);
}

.battle-start-btn:active, .play-prompt-bar:active .battle-start-btn {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #185200;
}

.battle-start-icon {
    font-size: 16px;
    color: #FFF;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.battle-start-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #FFFFFF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.prompt-msg {
    font-family: var(--font-heading);
    font-size: 11px;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 6px;
    text-shadow: 0 0 8px #00F0FF;
}

/* Modals */
.modal-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 12, 24, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 50;
    pointer-events: auto;
}

.modal-box.hidden {
    display: none;
}

.modal-content {
    background: #1B2B48;
    border: 2px solid #3A5A8C;
    border-radius: 18px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-heading {
    font-family: var(--font-heading);
    font-size: 22px;
    margin-bottom: 14px;
    color: #FFF;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.toggle-btn {
    background: #0077B6;
    border: 1px solid #00F0FF;
    color: #FFF;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-heading);
}

.modal-close-btn {
    width: 100%;
    padding: 10px;
    background: #3A5A8C;
    border: none;
    border-radius: 10px;
    color: #FFF;
    font-family: var(--font-heading);
    font-size: 13px;
    cursor: pointer;
    margin-top: 10px;
}

/* Victory / Defeat Cards */
.victory-heading { color: var(--accent-gold); }
.stars-row { font-size: 26px; margin-bottom: 12px; }
.stats-summary-card {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}
.summary-line { display: flex; justify-content: space-between; }
.summary-line.total { border-top: 1px solid rgba(255,255,255,0.15); padding-top: 6px; font-weight: 900; }
.total-val { color: var(--accent-gold); font-size: 16px; }

.defeat-heading { color: #FF3366; }
.defeat-sub { font-size: 12px; color: rgba(255,255,255,0.7); margin-bottom: 16px; }
.flat-text-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-family: var(--font-heading);
    font-size: 12px;
    cursor: pointer;
    margin-top: 10px;
}
