/* ===== Arcane Bastion — Style System ===== */

:root {
    --bg-dark: #0a0e1a;
    --bg-panel: rgba(15, 20, 40, 0.92);
    --border-glow: rgba(139, 92, 246, 0.3);
    --text-main: #e2e8f0;
    --text-dim: #64748b;
    --accent-purple: #8b5cf6;
    --accent-cyan: #22d3ee;
    --accent-gold: #fbbf24;
    --accent-red: #ef4444;
    --accent-green: #22c55e;
    --fire: #f97316;
    --ice: #38bdf8;
    --lightning: #a78bfa;
    --nature: #4ade80;
    --arcane: #c084fc;
}

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

body {
    background: var(--bg-dark);
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 960px;
    height: 720px;
    background: var(--bg-dark);
    border: 1px solid var(--border-glow);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(139, 92, 246, 0.15);
}

/* ===== HUD ===== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
    backdrop-filter: blur(10px);
}

#hud-left, #hud-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#hud-center {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', monospace;
}

#wave-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#wave-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hud-icon {
    font-size: 1rem;
}

.hud-value {
    font-family: 'Orbitron', monospace;
    font-size: 0.95rem;
    font-weight: 700;
}

#gold-value { color: var(--accent-gold); }
#lives-value { color: var(--accent-red); }
#score-value { color: var(--accent-cyan); }

.hud-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.hud-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-purple);
}

.hud-btn.primary {
    background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
    border-color: var(--accent-purple);
    color: #fff;
}

.hud-btn.primary:hover {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

/* ===== Canvas ===== */
#game-canvas {
    position: absolute;
    top: 48px;
    left: 0;
    width: 960px;
    height: 672px;
    cursor: crosshair;
}

/* ===== Tower Panel ===== */
#tower-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 20px;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.tower-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s;
    user-select: none;
}

.tower-slot:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}

.tower-slot.selected {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.1);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.15);
}

.tower-slot.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.tower-icon {
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.tower-icon.ember { background: rgba(249, 115, 22, 0.15); }
.tower-icon.frost { background: rgba(56, 189, 248, 0.15); }
.tower-icon.storm { background: rgba(167, 139, 250, 0.15); }
.tower-icon.vine { background: rgba(74, 222, 128, 0.15); }
.tower-icon.arcane { background: rgba(192, 132, 252, 0.15); }

.tower-info {
    display: flex;
    flex-direction: column;
}

.tower-name {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tower-cost {
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-family: 'Orbitron', monospace;
}

.tower-cost::before {
    content: '💰 ';
    font-size: 0.6rem;
}

/* ===== Tower Info Popup ===== */
#tower-info-popup {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--accent-purple);
    border-radius: 12px;
    padding: 12px 16px;
    width: 180px;
    z-index: 20;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

#popup-tower-name {
    font-weight: 700;
    font-size: 0.9rem;
}

#popup-tower-level {
    font-size: 0.7rem;
    color: var(--accent-cyan);
    font-family: 'Orbitron', monospace;
}

.popup-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.popup-actions {
    display: flex;
    gap: 6px;
}

.popup-btn {
    flex: 1;
    padding: 5px 8px;
    border: none;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.popup-btn.upgrade {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.popup-btn.sell {
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-gold);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.popup-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* ===== Overlay ===== */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

#overlay-content {
    text-align: center;
    padding: 3rem 4rem;
    background: var(--bg-panel);
    border: 1px solid var(--accent-purple);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(139, 92, 246, 0.2);
}

#overlay-title {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#overlay-message {
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
    #game-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    #game-canvas {
        width: 100%;
        height: calc(100% - 120px);
    }
}

/* ===== Audio Settings Panel ===== */
#audio-settings {
    position: absolute;
    top: 52px;
    right: 12px;
    width: 220px;
    background: rgba(15, 20, 40, 0.95);
    border: 1px solid var(--accent-purple);
    border-radius: 12px;
    padding: 12px 14px;
    z-index: 50;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.1);
    backdrop-filter: blur(12px);
}

.audio-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.audio-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.audio-close:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.audio-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.audio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    min-width: 80px;
}

.audio-toggle {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Orbitron', monospace;
}

.audio-toggle.on {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
    border-color: rgba(34, 197, 94, 0.4);
}

.audio-toggle.off {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.audio-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-purple);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(139, 92, 246, 0.4);
    transition: transform 0.15s;
}

.audio-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.audio-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-purple);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
}

.audio-vol-value {
    font-size: 0.65rem;
    font-family: 'Orbitron', monospace;
    color: var(--text-dim);
    min-width: 28px;
    text-align: right;
}

/* ===== BESTIARY OVERLAY ===== */
#bestiary-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 18, 0.92);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

#bestiary-panel {
    width: 92%;
    height: 88%;
    background: linear-gradient(135deg, rgba(20, 25, 50, 0.95), rgba(15, 18, 35, 0.98));
    border: 1px solid var(--border-glow);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.15), inset 0 0 80px rgba(139, 92, 246, 0.03);
    overflow: hidden;
}

#bestiary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.12), transparent);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

#bestiary-header h2 {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    color: #e2e8f0;
    letter-spacing: 2px;
}

.bestiary-sub {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin-left: 8px;
}

#bestiary-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#bestiary-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    align-content: start;
}

.bestiary-card {
    background: rgba(30, 35, 60, 0.7);
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.bestiary-card:hover {
    border-color: var(--accent-purple);
    background: rgba(40, 45, 80, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.15);
}

.bestiary-card.selected {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.08);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.2);
}

.bestiary-card.undiscovered {
    opacity: 0.35;
    filter: grayscale(1);
}

.bestiary-card img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 6px;
    image-rendering: pixelated;
}

.bestiary-card .card-name {
    font-size: 0.65rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

.bestiary-card .card-type {
    font-size: 0.55rem;
    color: var(--text-dim);
    display: block;
    margin-top: 2px;
}

/* Detail Panel */
#bestiary-detail {
    width: 260px;
    background: rgba(15, 20, 40, 0.95);
    border-left: 1px solid rgba(139, 92, 246, 0.15);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

#detail-portrait {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(30, 35, 60, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(139, 92, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#detail-portrait img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    image-rendering: pixelated;
}

#detail-name {
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    color: var(--accent-cyan);
    text-align: center;
}

#detail-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
}

.stat-label {
    width: 50px;
    color: var(--text-dim);
    font-weight: 600;
}

.stat-bar-bg {
    flex: 1;
    height: 6px;
    background: rgba(100, 116, 139, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.stat-value {
    width: 36px;
    text-align: right;
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    color: var(--text-main);
}

#detail-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.5;
    border-top: 1px solid rgba(100, 116, 139, 0.15);
    padding-top: 10px;
}

.detail-ability {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.65rem;
    color: var(--accent-purple);
}

.detail-ability strong {
    display: block;
    margin-bottom: 3px;
    color: var(--accent-cyan);
    font-size: 0.7rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
