/* ============================================
   Fortress Stand - Styles
   Fantasy defense game UI
   ============================================ */

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

body {
    background: #1a1a2e;
    color: #e0d8c8;
    font-family: 'Segoe UI', 'Trebuchet MS', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- HUD Bar ---- */
#hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: linear-gradient(180deg, #2a2a4a 0%, #1e1e38 100%);
    border-bottom: 2px solid #3a3a5c;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 10;
    min-height: 52px;
}

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

.hud-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8888aa;
    font-weight: 600;
}

.hud-value {
    font-size: 22px;
    font-weight: 700;
    color: #e0d8c8;
    text-shadow: 0 0 6px rgba(224, 216, 200, 0.3);
}

.gold-text {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.hud-status {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 12px;
    border-radius: 4px;
    background: rgba(100, 200, 100, 0.15);
    color: #88cc88;
    border: 1px solid rgba(100, 200, 100, 0.3);
}

.hud-status.active {
    background: rgba(255, 100, 80, 0.15);
    color: #ff8866;
    border-color: rgba(255, 100, 80, 0.3);
}

/* HP Bar in HUD */
#hud-hp-bar {
    position: relative;
    width: 200px;
    height: 22px;
    background: #1a1a2e;
    border-radius: 4px;
    border: 1px solid #3a3a5c;
    overflow: hidden;
}

#hud-hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(180deg, #55cc55 0%, #339933 100%);
    border-radius: 3px;
    transition: width 0.2s ease;
}

#hud-hp-fill.warning {
    background: linear-gradient(180deg, #ddaa33 0%, #bb8822 100%);
}

#hud-hp-fill.critical {
    background: linear-gradient(180deg, #dd4444 0%, #aa2222 100%);
}

#hud-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    white-space: nowrap;
}

/* ---- Main Game Area ---- */
#game-area {
    flex: 1;
    display: flex;
    min-height: 0;
    position: relative;
}

#game-canvas {
    flex: 1;
    display: block;
    background: #16213e;
}

/* ---- Panel Toggle Button ---- */
#panel-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    background: linear-gradient(180deg, #2e2e52 0%, #252545 100%);
    border: 2px solid #3a3a5c;
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: #aaaacc;
    font-size: 18px;
    padding: 12px 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

#panel-toggle:hover {
    background: linear-gradient(180deg, #383868 0%, #2e2e52 100%);
    color: #e0d8c8;
}

#panel-toggle.panel-open {
    right: 230px;
}

/* ---- Upgrade Panel ---- */
#upgrade-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 230px;
    background: linear-gradient(180deg, #252545 0%, #1e1e38 100%);
    border-left: 2px solid #3a3a5c;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3a3a5c transparent;
    z-index: 15;
    transform: translateX(0);
    transition: transform 0.2s ease;
}

#upgrade-panel.panel-hidden {
    transform: translateX(100%);
}

.panel-title {
    text-align: center;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #aaaacc;
    padding-bottom: 5px;
    border-bottom: 1px solid #3a3a5c;
    margin-bottom: 2px;
}

#upgrade-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* Upgrade button cards */
.upgrade-btn {
    background: linear-gradient(180deg, #2e2e52 0%, #252545 100%);
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    padding: 7px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    color: #e0d8c8;
    font-family: inherit;
}

.upgrade-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #383868 0%, #2e2e52 100%);
    border-color: #5a5a8c;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.upgrade-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.upgrade-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.upgrade-btn .upgrade-name {
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrade-btn .upgrade-cost {
    color: #ffd700;
    font-size: 12px;
    font-weight: 700;
}

.upgrade-btn .upgrade-desc {
    font-size: 11px;
    color: #8888aa;
    line-height: 1.3;
}

.upgrade-btn .upgrade-level {
    font-size: 10px;
    color: #6666aa;
    margin-top: 2px;
}

/* ---- Wave Button ---- */
.wave-btn {
    background: linear-gradient(180deg, #44aa55 0%, #338844 100%);
    border: 2px solid #55cc66;
    border-radius: 6px;
    padding: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    margin-top: auto;
}

.wave-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #55bb66 0%, #44aa55 100%);
    box-shadow: 0 0 12px rgba(85, 204, 102, 0.3);
    transform: translateY(-1px);
}

.wave-btn:active:not(:disabled) {
    transform: translateY(0);
}

.wave-btn:disabled {
    background: linear-gradient(180deg, #3a3a5c 0%, #2a2a4a 100%);
    border-color: #4a4a6c;
    color: #6666aa;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---- Speed Button ---- */
/* ---- Panel Section Headers ---- */
.panel-section-header {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #6666aa;
    padding: 5px 0 2px 0;
    border-top: 1px solid #3a3a5c;
    margin-top: 2px;
    text-align: center;
}

/* ---- Speed Button ---- */
.speed-btn {
    background: linear-gradient(180deg, #2e2e52 0%, #252545 100%);
    border: 2px solid #5a5a8c;
    border-radius: 6px;
    padding: 8px;
    color: #aaaacc;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    margin-top: 6px;
}

.speed-btn:hover {
    background: linear-gradient(180deg, #383868 0%, #2e2e52 100%);
    border-color: #7a7aac;
    color: #e0d8c8;
}

.speed-btn.fast {
    color: #ffaa33;
    border-color: #cc8822;
    text-shadow: 0 0 6px rgba(255, 170, 50, 0.3);
}

.speed-btn.fastest {
    color: #ff6644;
    border-color: #cc4422;
    text-shadow: 0 0 6px rgba(255, 102, 68, 0.3);
}

/* ---- Ability Buttons ---- */
.ability-btn.ability-selected {
    background: linear-gradient(180deg, #3a3870 0%, #2e2e60 100%);
    border-color: #7a7acc;
    box-shadow: 0 0 8px rgba(120, 120, 200, 0.3);
}

.ability-btn:disabled .ability-cd {
    color: #ff6666;
}

/* ============================================
   Mobile Responsive
   ============================================ */

/* Tablet and small screens */
@media (max-width: 768px) {
    body {
        overflow: hidden;
        height: 100dvh; /* dynamic viewport height for mobile browsers */
    }

    /* Compact HUD */
    #hud {
        padding: 4px 10px;
        min-height: 40px;
        gap: 6px;
    }
    .hud-label { display: none; }
    .hud-value { font-size: 16px; }
    .hud-status { font-size: 10px; padding: 3px 8px; }
    #hud-hp-bar { width: 120px; height: 18px; }
    #hud-hp-text { font-size: 9px; }

    /* Panel slides up from bottom on mobile */
    #upgrade-panel {
        position: absolute;
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-height: 55vh;
        border-left: none;
        border-top: 2px solid #3a3a5c;
        border-radius: 12px 12px 0 0;
        transform: translateY(0);
        padding: 8px 12px;
    }
    #upgrade-panel.panel-hidden {
        transform: translateY(100%);
    }

    /* Panel toggle at bottom-right */
    #panel-toggle {
        right: 10px;
        top: auto;
        bottom: 10px;
        transform: none;
        border: 2px solid #3a3a5c;
        border-radius: 8px;
        padding: 10px 14px;
        font-size: 20px;
        min-width: 44px;
        min-height: 44px;
    }
    #panel-toggle.panel-open {
        right: 10px;
        bottom: 56vh;
    }

    /* Upgrade buttons list scrolls horizontally for upgrades */
    #upgrade-buttons {
        gap: 5px;
    }

    /* Larger tap targets */
    .upgrade-btn {
        min-height: 40px;
        padding: 8px 10px;
    }
    .wave-btn {
        padding: 10px;
        font-size: 13px;
        min-height: 44px;
    }
    .speed-btn {
        padding: 6px 8px;
        font-size: 11px;
        min-height: 36px;
        margin-top: 4px;
    }

    /* Game over - smaller */
    #game-over-box {
        padding: 24px 20px;
        margin: 10px;
    }
    #game-over-box h1 { font-size: 22px; }
    #game-over-box p { font-size: 13px; }
    #restart-btn { padding: 12px 30px; font-size: 15px; }

    /* Canvas touch */
    #game-canvas {
        touch-action: manipulation;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    .hud-value { font-size: 14px; }
    #hud-hp-bar { width: 90px; height: 16px; }
    #hud-hp-text { font-size: 8px; }
    .hud-status { font-size: 9px; padding: 2px 6px; }

    #upgrade-panel {
        max-height: 60vh;
    }

    .upgrade-btn .upgrade-name { font-size: 11px; }
    .upgrade-btn .upgrade-desc { font-size: 10px; }
    .upgrade-btn .upgrade-level { font-size: 9px; }

    .panel-title { font-size: 11px; }
    .panel-section-header { font-size: 9px; }
}

/* ---- Game Over Overlay ---- */
#game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.5s ease;
}

#game-over-overlay.hidden {
    display: none;
}

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

#game-over-box {
    background: linear-gradient(180deg, #2e2e52 0%, #1e1e38 100%);
    border: 2px solid #5a5a8c;
    border-radius: 12px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.6), 0 0 80px rgba(90, 90, 140, 0.15);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#game-over-box h1 {
    font-size: 32px;
    color: #ff6644;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 16px;
    text-shadow: 0 0 10px rgba(255, 102, 68, 0.3);
}

#game-over-box p {
    font-size: 16px;
    color: #aaaacc;
    margin-bottom: 8px;
}

#game-over-box p span {
    color: #e0d8c8;
    font-weight: 700;
}

#restart-btn {
    margin-top: 24px;
    padding: 14px 40px;
    font-size: 18px;
}
