/* game.css */
#game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    touch-action: none; /* Prevent scrolling during scrub */
}

#game-overlay.active {
    display: flex;
}

#three-canvas-container {
    flex: 1;
    width: 100%;
    position: relative;
    background: radial-gradient(circle at center, #333 0%, #000 100%);
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.5s ease;
}

#loading-text {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #D4AF37;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    border-top-color: #D4AF37;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* UI Overlay */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    box-sizing: border-box;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
}

.stats {
    background: rgba(0,0,0,0.7);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(212, 175, 55, 0.5);
    margin-bottom: 10px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.health-bar-container {
    width: 100px;
    height: 10px;
    background: #333;
    border-radius: 5px;
    overflow: hidden;
}

#health-bar {
    width: 100%;
    height: 100%;
    background: #4caf50;
    transition: width 0.3s, background 0.3s;
}

.close-btn {
    background: rgba(255,0,0,0.7);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

.bottom-panel {
    pointer-events: none;
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.instruction-panel {
    background: rgba(0,0,0,0.8);
    padding: 15px 30px;
    border-radius: 12px;
    border: 1px solid #D4AF37;
    text-align: center;
    pointer-events: auto;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.step-title {
    color: #D4AF37;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.controls-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 250px;
    background: rgba(10,10,10,0.9);
    border: 1px solid #D4AF37;
    border-radius: 12px;
    padding: 15px;
    pointer-events: auto;
    z-index: 100;
}

.selection-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 150px;
    overflow-y: auto;
    padding-bottom: 5px;
}

.item-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    flex-grow: 1;
}

.item-card.selected {
    background: rgba(212, 175, 55, 0.3);
    border-color: #D4AF37;
}

.action-btn {
    background: linear-gradient(135deg, #D4AF37, #B08D22);
    color: #000;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    text-transform: uppercase;
}

.progress-container {
    width: 100%;
    margin-top: 10px;
}

.progress-text {
    font-size: 0.8rem;
    text-align: left;
    margin-bottom: 4px;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
}

#progress-bar-fill {
    width: 0%;
    height: 100%;
    background: #4caf50;
    transition: width 0.2s ease;
}

#feedback-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    border: 2px solid #D4AF37;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    width: 80%;
    max-width: 400px;
    display: none;
    pointer-events: auto;
    z-index: 20;
}

#feedback-modal h3 {
    margin-bottom: 10px;
}

#feedback-btn {
    background: #D4AF37;
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
}

@media (max-width: 768px) {
    .controls-panel {
        top: 75px;
        right: 10px;
        width: 170px;
        padding: 10px;
    }
    .selection-row {
        flex-wrap: wrap; /* Let items wrap instead of overflowing */
        max-height: none;
    }
    .item-card {
        padding: 8px 4px;
        font-size: 0.75rem;
        min-width: 65px;
    }
}