/* Global Overrides if needed */
body {
    margin: 0;
    overflow: hidden;
    background: #000;
    color: white;
    font-family: 'Fredoka', sans-serif;
}

#game-wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* HUD */
#hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.5);
    z-index: 10;
    pointer-events: auto;
    flex-wrap: wrap;
}

#stats-display {
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 1.1rem;
    font-weight: bold;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Bars */
#hp-bar-container, #xp-bar-container {
    position: absolute;
    left: 20px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #333;
    border-radius: 10px;
    overflow: hidden;
}

#hp-bar-container {
    bottom: 20px;
    width: 300px;
}

#hp-bar {
    height: 100%;
    background: #ef4444;
    width: 100%;
    transition: width 0.2s;
}

#hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
}

#xp-bar-container {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    border: none;
    border-radius: 0;
}

#xp-bar {
    height: 100%;
    background: #3b82f6;
    width: 0%;
    transition: width 0.2s;
}

/* Active Item */
#active-item-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #fbbf24;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

#active-item-icon {
    font-size: 24px;
}

#active-item-key {
    font-size: 10px;
    color: #fbbf24;
    margin-top: 2px;
}

#active-item-cooldown {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.3);
    height: 0%;
    transition: height 0.1s linear;
}

/* Modals */
.modal, .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

.modal-content {
    background: #1e293b;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #475569;
    text-align: center;
    color: white;
    max-width: 500px;
    width: 90%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #94a3b8;
}

.modal-close:hover {
    color: white;
}

/* Upgrade Cards */
#upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.upgrade-card {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    text-align: left;
    pointer-events: auto;
}

.upgrade-card:hover, .upgrade-card.selected {
    border-color: #3b82f6;
    background: #1e293b;
    transform: scale(1.02);
}

.upgrade-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: #fbbf24;
    margin-bottom: 5px;
}

.upgrade-desc {
    font-size: 0.9rem;
    color: #cbd5e1;
}

/* Inventory Styles */
.inventory-section {
    margin-bottom: 25px;
    text-align: left;
}

.inventory-section h3 {
    border-bottom: 1px solid #334155;
    padding-bottom: 8px;
    margin-bottom: 15px;
    color: #e2e8f0;
}

.slot-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f172a;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #334155;
}

.slot-arrow {
    background: #334155;
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    pointer-events: auto;
}

.slot-arrow:hover {
    background: #475569;
}

.slot-info {
    flex-grow: 1;
    text-align: center;
    padding: 0 10px;
}

.slot-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 2px;
}

.slot-name {
    font-weight: bold;
    color: #fbbf24;
    font-size: 1.1rem;
}

.slot-level {
    font-size: 0.85rem;
    color: #94a3b8;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    background: #0f172a;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #cbd5e1;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.primary-btn {
    background: #3b82f6;
    color: white;
}

.secondary-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.small-btn {
    padding: 5px 10px;
    font-size: 0.9rem;
    width: auto;
}

.header-btn {
    padding: 5px 10px;
    margin-right: 5px;
    font-size: 1.2rem;
    line-height: 1;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    width: auto;
}

.btn:hover {
    opacity: 0.9;
}

#inventory-btn {
    background: #8b5cf6;
    border-color: #7c3aed;
    position: absolute;
    bottom: 20px;
    right: 90px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    pointer-events: auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 20;
}

@media (max-width: 600px) {
    header {
        padding: 2px 5px;
    }
    header h1 {
        font-size: 1rem;
    }
    #stats-display {
        gap: 5px;
        font-size: 0.75rem;
    }
    .small-btn {
        padding: 3px 6px;
        font-size: 0.8rem;
    }
    .header-btn {
        padding: 2px 5px;
        font-size: 0.9rem;
        min-width: 24px;
        margin-right: 2px;
    }
    #active-item-container {
        width: 50px;
        height: 50px;
        right: 10px;
        bottom: 10px;
    }
    #inventory-btn {
        width: 50px;
        height: 50px;
        right: 70px;
        bottom: 10px;
        font-size: 20px;
    }
    #hp-bar-container {
        width: 200px;
        left: 10px;
        bottom: 10px;
    }
}

.end-inventory {
    margin-top: 20px;
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
}

.end-inventory li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
