/* Global styles and reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Main container - adapts to iframe or standalone */
#app-container {
    width: 100%;
    height: 450px; /* Default for iframe */
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

/* Standalone mode detection - uses 90vh */
@media (min-height: 600px) {
    body:not(.iframe-mode) #app-container {
        height: 90vh;
    }
}

/* Tooltip styling - appears at center for better visibility in iframe */
.tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    max-width: 80%;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

.tooltip.show {
    opacity: 1;
}

/* Screen management - only one screen visible at a time */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* Intro screen styling */
.intro-content {
    text-align: center;
    padding: 20px;
    max-width: 500px;
}

.fire-icon {
    font-size: 80px;
    animation: flicker 2s infinite;
    margin-bottom: 10px;
}

@keyframes flicker {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.intro-content h1 {
    font-size: 36px;
    color: #ff6b6b;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.intro-content p {
    font-size: 16px;
    color: #555;
    margin-bottom: 20px;
}

.info-icon {
    display: inline-block;
    font-size: 24px;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.3s ease;
}

.info-icon:hover {
    transform: scale(1.2);
}

/* Button styling - optimized for touch and mouse */
.main-button {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    min-height: 48px; /* Touch-friendly size */
    white-space: nowrap;
}

.main-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.main-button:active {
    transform: translateY(0);
}

.main-button.secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Location selection screen */
.location-content {
    text-align: center;
    padding: 20px;
    width: 100%;
}

.location-content h2 {
    font-size: 28px;
    color: #ff6b6b;
    margin-bottom: 20px;
}

.location-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.location-card {
    background: white;
    border: 3px solid #ff6b6b;
    border-radius: 20px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.location-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);
    border-color: #ff8e53;
}

.location-icon {
    font-size: 60px;
    margin-bottom: 10px;
}

.location-name {
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

/* Game screen layout */
#game-screen {
    flex-direction: column;
    padding: 0;
    align-items: stretch;
}

.game-header {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.3s ease;
}

.stat-item:hover {
    background: rgba(255, 107, 107, 0.1);
}

.stat-icon {
    font-size: 20px;
}

/* Scene container - where hazards are displayed */
.scene-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scene-title {
    text-align: center;
    padding: 8px;
    font-size: 18px;
    font-weight: bold;
    color: #ff6b6b;
    background: rgba(255, 255, 255, 0.8);
}

.scene-area {
    flex: 1;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Hazard hotspots - clickable areas in the scene */
.hazard-hotspot {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 107, 107, 0.7);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    transition: all 0.3s ease;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.5);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.hazard-hotspot:hover {
    transform: scale(1.2);
    background: rgba(255, 107, 107, 0.9);
}

.hazard-hotspot.found {
    background: rgba(76, 217, 100, 0.7);
    border-color: #4cd964;
    animation: none;
    pointer-events: none;
}

.hazard-hotspot.found::after {
    content: '✓';
    position: absolute;
    font-size: 40px;
    color: white;
}

/* Matching panel - slides up from bottom */
.matching-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    max-height: 70%;
    overflow-y: auto;
    transition: transform 0.4s ease;
    transform: translateY(100%);
    z-index: 100;
}

.matching-panel:not(.hidden) {
    transform: translateY(0);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.panel-header h3 {
    font-size: 18px;
    margin: 0;
}

.close-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

.hazard-description {
    padding: 15px 20px;
    font-size: 14px;
    color: #555;
    background: #fff9e6;
    border-left: 4px solid #ffd700;
    margin: 10px 20px;
    border-radius: 8px;
}

.solutions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    padding: 15px 20px 20px;
}

/* Solution cards for matching */
.solution-card {
    background: white;
    border: 3px solid #ddd;
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.solution-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border-color: #ff6b6b;
}

.solution-card.correct {
    background: linear-gradient(135deg, #4cd964 0%, #5de26e 100%);
    color: white;
    border-color: #4cd964;
    animation: correctAnswer 0.6s ease;
}

.solution-card.incorrect {
    background: #ffebee;
    border-color: #f44336;
    animation: shake 0.5s ease;
}

@keyframes correctAnswer {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.solution-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.solution-text {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}

/* Results screen */
.results-content {
    text-align: center;
    padding: 20px;
    max-width: 500px;
}

.results-icon {
    font-size: 80px;
    margin-bottom: 10px;
    animation: bounce 1s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.results-content h2 {
    font-size: 32px;
    color: #ff6b6b;
    margin-bottom: 20px;
}

.results-stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    gap: 15px;
}

.result-stat {
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex: 1;
}

.result-label {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.result-value {
    font-size: 24px;
    font-weight: bold;
    color: #ff6b6b;
}

.feedback-message {
    background: #fff9e6;
    padding: 15px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

.results-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Audio control button */
.audio-control {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
}

.audio-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #ff6b6b;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.audio-btn:hover {
    transform: scale(1.1);
    background: white;
}

.audio-btn.muted::after {
    content: '🔇';
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    .intro-content h1 {
        font-size: 28px;
    }
    
    .fire-icon {
        font-size: 60px;
    }
    
    .location-card {
        min-width: 120px;
        min-height: 120px;
        padding: 20px;
    }
    
    .location-icon {
        font-size: 48px;
    }
    
    .solutions-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

/* Hidden utility class */
.hidden {
    display: none !important;
}