/* Base Variables for Strong Branding
   - Bold, high contrast but sophisticated colors
   - Dark mode background with striking neon/vibrant accents 
*/
:root {
    --bg-color: #0c0d0c;
    --surface-color: #171917;
    --text-primary: #e2e8f0;
    --text-secondary: #8b949e;
    
    /* Tech Military Palette */
    --accent-color: #88cc00; /* Tactical Green */
    --accent-secondary: #ff4400; /* Warning Orange */
    --action-color: #ffaa00; /* Amber */
    --success-color: #88cc00;
    
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: url('forest_arena.jpg');
    background-size: cover;
    background-position: center;
    color: var(--text-primary);
    overflow: hidden; /* Prevent scrolling, canvas is full screen */
    user-select: none;
}

/* ---------------------------------
   WebGL Canvas
-----------------------------------*/
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1; /* Behind UI */
}

/* ---------------------------------
   UI Overlay
-----------------------------------*/
.ui-layer {
    position: relative;
    z-index: 10;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none; /* Let clicks pass through to canvas by default */
}

/* Re-enable pointer events for interactive UI elements */
.top-bar, .bottom-bar, .message-banner, .btn {
    pointer-events: auto;
}

/* ---------------------------------
   Top Bar
-----------------------------------*/
.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 150px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    z-index: 50;
}

.logo {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    z-index: 100;
    gap: 12px;
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.logo svg {
    filter: drop-shadow(0 0 8px var(--accent-color));
}

.logo h1 {
    font-size: 1.2rem;
    margin: 0;
}

.logo svg {
    filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.5));
}

.logo .accent {
    color: var(--accent-color);
}

.nav-links {
    display: flex;
    gap: 16px;
}

/* ---------------------------------
   Buttons
-----------------------------------*/
.btn {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 24px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.btn-action {
    background: linear-gradient(45deg, var(--action-color), #cc5500);
    color: #000;
    font-size: 1.25rem;
    padding: 16px 40px;
    box-shadow: 0 8px 24px rgba(255, 170, 0, 0.4);
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
    border-radius: 0;
}

.btn-action:hover {
    box-shadow: 0 12px 32px rgba(255, 170, 0, 0.6);
    transform: translateY(-2px);
}

/* ---------------------------------
   Center HUD
-----------------------------------*/
.hud {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 100px;
    z-index: 10;
}

.message-banner {
    text-align: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    padding: 20px 40px;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    border-top: 2px solid var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    transform: translateY(0);
    animation: float 4s ease-in-out infinite;
    pointer-events: auto;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 8%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through empty space */
    transition: opacity 0.3s;
}

.nav-arrow {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    width: 60px;
    height: 100px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.nav-arrow svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.8));
}

.nav-arrow:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

.nav-arrow:active {
    transform: scale(0.9);
}

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

.message-banner h1 {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 3px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.message-banner p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 1px;
}

/* ---------------------------------
   Stats Panel (Slide in from right)
-----------------------------------*/
.stats-panel {
    position: absolute;
    right: -600px; /* Hidden initially */
    top: 50%;
    transform: translateY(-50%);
    width: 450px;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.95), rgba(5, 5, 10, 0.98));
    backdrop-filter: blur(20px);
    border-left: 4px solid var(--accent-color);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 30px 100%, 0 calc(100% - 30px));
    padding: 40px;
    box-shadow: -15px 0 50px rgba(0, 0, 0, 0.8);
    transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 24px;
    pointer-events: auto;
}

.stats-panel.active {
    right: 0;
}

.stats-header {
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.header-main {
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.title-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-header h2 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
    transition: all 0.3s ease;
}

.tags {
    display: flex;
    gap: 8px;
    transition: all 0.3s ease;
    flex-wrap: wrap;
}

/* Condensing Scroll States */
.stats-panel.scrolled .stats-header {
    margin-bottom: 12px;
}
.stats-panel.scrolled .header-main {
    margin-bottom: 8px;
}
.stats-panel.scrolled .title-group {
    flex-direction: row;
    align-items: center;
    gap: 16px;
}
.stats-panel.scrolled h2 {
    font-size: 1.5rem;
}
.stats-panel.scrolled .tags {
    transform: scale(0.85);
    transform-origin: left center;
}
.stats-panel.scrolled .segmented-bar {
    display: none;
}
.stats-panel.scrolled .hp-text-condensed {
    display: block !important;
}

.threat-level, .class-tag {
    font-family: var(--font-main);
    font-weight: 900;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 10px;
    transform: skewX(-15deg);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    display: inline-block;
}

.threat-level {
    background: linear-gradient(90deg, #aa2200, var(--accent-secondary));
}

.class-tag {
    background: linear-gradient(90deg, #334411, var(--accent-color));
}

.stats-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.hp-container {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.hp-text-condensed {
    display: none;
    font-weight: 900;
    color: var(--accent-secondary);
    font-size: 1.2rem;
    margin-left: auto;
}

.segmented-bar {
    display: flex;
    gap: 4px;
    height: 20px;
    flex-grow: 1;
    transform: skewX(-20deg);
}

.segment {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.3s ease;
}

.segment.active {
    background: var(--accent-secondary);
    box-shadow: 0 0 10px var(--accent-secondary);
    border-color: transparent;
}

.lore-box {
    margin-top: 16px;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
    border-left: 4px solid var(--action-color);
}

.lore-box h3 {
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lore-scroll {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 12px;
}

/* Custom scrollbar for webkit */
.lore-scroll::-webkit-scrollbar {
    width: 4px;
}
.lore-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.lore-scroll::-webkit-scrollbar-thumb {
    background: var(--accent-color);
}

.lore-box p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.list-title {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.item-card {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid var(--accent-color);
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.item-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.item-card.negative {
    border-bottom-color: var(--accent-secondary);
}
.item-card.negative:hover {
    border-color: var(--accent-secondary);
}

.item-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
}

/* ---------------------------------
   Item Modal
-----------------------------------*/
.item-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 60px;
}

.item-modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    padding: 40px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    border-top: 4px solid var(--action-color);
    box-shadow: 0 20px 50px rgba(0,0,0,0.9);
}

.modal-content h3 {
    color: var(--text-primary);
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 32px;
}

/* ---------------------------------
   Bottom Bar
-----------------------------------*/
.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 40px;
    background: linear-gradient(to top, rgba(15, 17, 26, 0.95), transparent);
}

.status-panel {
    display: flex;
    gap: 32px;
    background: rgba(0, 0, 0, 0.8);
    padding: 16px 24px;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
    border-left: 4px solid var(--accent-color);
}

/* ---------------------------------
   Mobile Responsiveness
-----------------------------------*/
@media (max-width: 768px) {
    .top-bar {
        padding: 16px 20px;
        flex-direction: column;
        gap: 16px;
    }

    .bottom-bar {
        padding: 20px;
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }

    .status-panel {
        gap: 16px;
        width: 100%;
        justify-content: center;
    }

    .message-banner {
        padding: 12px 24px;
        width: 90%;
    }

    .message-banner h1 {
        font-size: 1.2rem;
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .stats-panel {
        /* Convert to bottom sheet */
        width: 100%;
        height: 80vh;
        top: auto;
        bottom: -100%;
        right: auto !important;
        left: 0;
        transform: none;
        clip-path: polygon(0 20px, 20px 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
        border-left: none;
        border-top: 4px solid var(--accent-color);
        padding: 24px;
        transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 100;
    }

    .stats-panel.active {
        bottom: 0;
    }

    .stats-header h2 {
        font-size: 1.8rem;
    }
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.status-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 1px;
}

.status-item .value {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 1px;
}

.value.success {
    color: var(--success-color);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

/* Inventory Overlay */
.overlay-panel {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 12, 18, 0.95);
    z-index: 200;
    display: none;
    flex-direction: column;
    padding: 60px;
    color: #fff;
    backdrop-filter: blur(10px);
    pointer-events: auto;
}
.overlay-panel.active {
    display: flex;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
    padding-bottom: 20px;
    margin-bottom: 30px;
}
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    overflow-y: auto;
    padding-bottom: 60px;
}
.inv-card {
    background: #1a1d24;
    border: 2px solid #333;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.inv-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.icon-btn {
    background: rgba(20, 24, 34, 0.8);
    border: 2px solid #333;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.8rem;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
.icon-btn:hover {
    border-color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.loadout-slot { flex: 1; min-width: 80px; border: 2px dashed rgba(255,255,255,0.2); padding: 10px; height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); border-radius: 8px; text-align: center; transition: all 0.3s; }
.loadout-slot:hover { border-color: var(--accent-color); background: rgba(255,170,0,0.1); }
.slot-label { font-size: 0.7rem; color: var(--accent-color); font-weight: bold; margin-bottom: auto; letter-spacing: 1px; }
.slot-content { font-size: 0.9rem; font-weight: bold; color: #fff; margin-top: auto; margin-bottom: auto; word-break: break-word; }

.loadout-slot { cursor: pointer; }
@media (max-width: 768px) { 
    .loadout-slot { min-width: 45%; height: 80px; } 
    .odds-container { padding: 10px; margin-bottom: 10px !important; } 
    #oddsText { font-size: 2.5rem !important; } 
}

/* Redesigned Premium Battle HUD Elements */
.battle-hud-player-hp {
    width: 300px;
    pointer-events: auto;
}

.battle-hud-boss-hp {
    width: 350px;
    pointer-events: auto;
}

.battle-attack-btn {
    background: linear-gradient(135deg, rgba(150, 20, 20, 0.85), rgba(80, 10, 10, 0.95));
    border: 1px solid rgba(255, 100, 100, 0.2);
    color: #ffeded;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 12px 30px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.battle-attack-btn:hover {
    background: linear-gradient(135deg, rgba(180, 25, 25, 0.9), rgba(100, 15, 15, 1));
    border-color: rgba(255, 100, 100, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(150, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 0 8px rgba(255,100,100,0.5);
}

.battle-attack-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.battle-defend-btn {
    background: linear-gradient(135deg, rgba(20, 60, 120, 0.85), rgba(10, 30, 60, 0.95));
    border: 1px solid rgba(100, 150, 255, 0.2);
    color: #edf5ff;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 12px 25px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.battle-defend-btn:hover {
    background: linear-gradient(135deg, rgba(30, 80, 150, 0.9), rgba(15, 40, 80, 1));
    border-color: rgba(100, 150, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 50, 150, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 0 8px rgba(100,150,255,0.5);
}

.battle-defend-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.battle-item-btn {
    background: linear-gradient(135deg, rgba(120, 80, 20, 0.85), rgba(60, 40, 10, 0.95));
    border: 1px solid rgba(255, 180, 80, 0.2);
    color: #fff5ed;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 10px 18px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.battle-item-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(150, 100, 25, 0.9), rgba(80, 50, 15, 1));
    border-color: rgba(255, 180, 80, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(150, 100, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 0 8px rgba(255,180,80,0.5);
}

.battle-item-btn:disabled {
    filter: grayscale(1) opacity(0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 768px) {
    .battle-hud-player-hp, .battle-hud-boss-hp {
        width: 48%;
    }
    
    .battle-hud-boss-hp h3 {
        font-size: 1.2rem !important;
    }
    
    .battle-hud-player-hp h3 {
        font-size: 1rem !important;
    }
    
    .battle-top-bar {
        padding: 10px !important;
        height: auto !important;
    }
    
    .battle-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px !important;
    }
    
    .battle-separator {
        display: none;
    }
    
    .battle-actions-row {
        width: 100%;
        justify-content: space-between !important;
        gap: 10px;
    }
    
    .battle-attack-btn, .battle-defend-btn {
        flex: 1;
        width: auto !important;
        padding: 15px 10px;
        font-size: 1.2rem;
    }
    
    .battle-attack-btn {
        font-size: 1.4rem;
    }
    
    .battle-item-btn {
        font-size: 0.9rem;
        padding: 10px 15px;
        white-space: nowrap;
    }
    
    #battleItemsContainer {
        justify-content: flex-start !important;
        overflow-x: auto;
        padding-bottom: 5px;
        width: 100%;
    }
    
    #battleLog {
        height: 60px !important;
        font-size: 0.8rem !important;
        margin-bottom: 10px !important;
    }
    
    .battle-bottom-bar {
        padding: 20px 10px 10px 10px !important;
    }
}

.inv-card-container {
    position: relative;
    width: 100%;
}

.card-badge-quantity {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #ff3333, #aa0000);
    color: white;
    font-size: 1.1rem;
    font-weight: 900;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 17px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8);
    border: 2px solid #fff;
    z-index: 10;
    pointer-events: none;
}
