/* 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;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Main game container with responsive height */
#gameContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #F4E4BC 0%, #DEB887 100%);
    position: relative;
    border: 2px solid #8B4513;
    box-shadow: inset 0 0 20px rgba(139, 69, 19, 0.3);
}

/* Responsive height for standalone browser */
@media (min-height: 500px) {
    body:not(.iframe) #gameContainer {
        height: 90vh;
    }
}

/* Progress bar styling */
#progressBar {
    height: 30px;
    background: rgba(139, 69, 19, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: white;
    font-weight: bold;
    font-size: 12px;
}

#progressFill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    width: 0%;
    transition: width 0.5s ease;
}

#progressText {
    position: relative;
    z-index: 2;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

/* Main game area */
#gameArea {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Scene container */
#sceneContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 400"><defs><linearGradient id="sky" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" style="stop-color:%23FFE4B5"/><stop offset="100%" style="stop-color:%23DEB887"/></linearGradient></defs><rect width="800" height="400" fill="url(%23sky)"/><rect x="0" y="300" width="800" height="100" fill="%23228B22"/><rect x="300" y="150" width="200" height="150" fill="%238B4513" rx="10"/><polygon points="300,150 400,100 500,150" fill="%23654321"/><rect x="380" y="200" width="40" height="100" fill="%234B0000"/><circle cx="150" cy="80" r="40" fill="%23FFD700" opacity="0.8"/></svg>') center/cover;
    position: relative;
}

#sceneImage {
    flex: 1;
    background-size: cover;
    background-position: center;
    position: relative;
    cursor: pointer;
    transition: filter 0.3s ease;
}

#sceneImage:hover {
    filter: brightness(1.1);
}

#sceneDescription {
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 10px;
    min-height: 60px;
    display: flex;
    align-items: center;
}

#sceneText {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
}

/* Interactive elements overlay */
#interactiveElements {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px; /* Account for scene description */
    pointer-events: none;
}

.hotspot {
    position: absolute;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.8) 0%, rgba(255, 165, 0, 0.6) 100%);
    border: 3px solid #FFD700;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    animation: pulse 2s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #8B4513;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
}

.hotspot:hover {
    transform: scale(1.2);
    animation-play-state: paused;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

/* Bottom interface panel */
#interfacePanel {
    height: 120px;
    background: rgba(139, 69, 19, 0.95);
    display: flex;
    border-top: 2px solid #8B4513;
}

/* Inventory section */
#inventory {
    width: 25%;
    padding: 8px;
    border-right: 1px solid #654321;
}

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

#inventoryItems {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    height: 80px;
    overflow-y: auto;
}

.inventory-item {
    width: 35px;
    height: 35px;
    background: #DEB887;
    border: 2px solid #8B4513;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.inventory-item:hover {
    transform: scale(1.1);
    border-color: #FFD700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.5);
}

/* Dialogue area */
#dialogueArea {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

#dialogueBox {
    flex: 1;
    background: rgba(244, 228, 188, 0.9);
    border: 2px solid #8B4513;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    overflow-y: auto;
}

#dialogueText {
    font-size: 13px;
    line-height: 1.4;
    color: #4B0000;
}

#decisionButtons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.decision-btn {
    flex: 1;
    min-width: 120px;
    height: 32px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 2px solid #8B4513;
    border-radius: 6px;
    color: #4B0000;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.decision-btn:hover {
    background: linear-gradient(135deg, #FFA500, #FF8C00);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.decision-btn:active {
    transform: translateY(0);
}

/* Navigation controls */
#navigationControls {
    width: 25%;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-left: 1px solid #654321;
}

.nav-btn {
    height: 32px;
    background: linear-gradient(135deg, #DEB887, #D2691E);
    border: 2px solid #8B4513;
    border-radius: 6px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #D2691E, #CD853F);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 250px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tooltip.show {
    opacity: 1;
}

/* Achievement notification */
.achievement-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #FFD700, #FFA500);
    border: 3px solid #8B4513;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    z-index: 1001;
    transition: transform 0.3s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.achievement-popup.show {
    transform: translate(-50%, -50%) scale(1);
}

.achievement-title {
    font-size: 16px;
    font-weight: bold;
    color: #4B0000;
    margin-bottom: 8px;
}

.achievement-text {
    font-size: 14px;
    color: #8B4513;
    line-height: 1.4;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #interfacePanel {
        height: 140px;
    }
    
    #inventory {
        width: 20%;
    }
    
    #navigationControls {
        width: 20%;
    }
    
    .decision-btn {
        min-width: 100px;
        font-size: 11px;
    }
    
    .nav-btn {
        font-size: 11px;
        height: 28px;
    }
    
    .hotspot {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .hotspot {
        width: 44px;
        height: 44px;
    }
    
    .decision-btn {
        height: 36px;
        min-height: 44px;
    }
    
    .nav-btn {
        height: 36px;
        min-height: 44px;
    }
    
    .inventory-item {
        width: 40px;
        height: 40px;
    }
}