/* Reset and base styles for cross-browser compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 100%);
    overflow: hidden;
    user-select: none;
}

/* Main game container - responsive height for iframe vs full screen */
#gameContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #F4E4BC 0%, #DEB887 100%);
    border: 2px solid #8B4513;
    position: relative;
}

/* Full screen mode detection */
@media (min-height: 500px) {
    #gameContainer {
        height: 90vh;
    }
}

/* Progress bar styling with visual feedback */
#progressBar {
    height: 30px;
    background: rgba(139, 69, 19, 0.3);
    border-bottom: 2px solid #8B4513;
    display: flex;
    align-items: center;
    padding: 0 10px;
    position: relative;
}

#progressFill {
    height: 20px;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#progressText {
    position: absolute;
    right: 10px;
    font-size: 12px;
    font-weight: bold;
    color: #8B4513;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

/* Main game area layout */
#gameArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
}

/* Scene container with illustration */
#sceneContainer {
    flex: 1;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    border: 2px solid #8B4513;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.2);
}

#sceneImage {
    width: 100%;
    height: 80%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease;
}

#sceneTitle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(139, 69, 19, 0.9);
    color: #FFD700;
    text-align: center;
    padding: 8px;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Dialogue box with cognitive load considerations */
#dialogueBox {
    min-height: 80px;
    max-height: 120px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #8B4513;
    border-radius: 8px;
    padding: 12px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#dialogueText {
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    text-align: justify;
}

/* Bottom panel layout */
#bottomPanel {
    height: 120px;
    display: flex;
    gap: 10px;
    padding: 0 10px 10px 10px;
}

/* Inventory panel styling */
#inventoryPanel {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #8B4513;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.panel-title {
    font-size: 12px;
    font-weight: bold;
    color: #8B4513;
    margin-bottom: 5px;
    text-align: center;
}

#inventoryGrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    height: calc(100% - 25px);
}

.inventory-item {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 1px solid #8B4513;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.inventory-item:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

/* Action panel with navigation and decision buttons */
#actionPanel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#navigationButtons {
    display: flex;
    gap: 5px;
    flex: 1;
}

.nav-btn {
    flex: 1;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    padding: 8px 4px;
    text-align: center;
    line-height: 1.2;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #5CBF60, #4CAF50);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Decision buttons styling */
#decisionButtons {
    display: flex;
    gap: 5px;
    flex: 1;
}

.decision-btn {
    flex: 1;
    background: linear-gradient(135deg, #FF6B6B, #FF5252);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    padding: 8px 4px;
    text-align: center;
    line-height: 1.2;
}

.decision-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #FF7B7B, #FF6B6B);
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Tooltip styling for additional information */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

/* Mobile-first responsive design */
@media (max-width: 480px) {
    #bottomPanel {
        flex-direction: column;
        height: 160px;
    }
    
    #inventoryPanel {
        height: 60px;
    }
    
    .nav-btn, .decision-btn {
        font-size: 10px;
        padding: 6px 2px;
    }
    
    #dialogueText {
        font-size: 13px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .nav-btn, .decision-btn, .inventory-item {
        min-height: 44px; /* iOS recommended touch target size */
    }
    
    .nav-btn:active, .decision-btn:active {
        background: rgba(255,255,255,0.3);
    }
}