/* Global Styles - Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* NEW: Background Images Container - Creates vibrant Singapore-themed background */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* NEW: Individual background images with CSS-generated Singapore landmarks */
.bg-image {
    position: absolute;
    opacity: 0.15;
    animation: float 20s ease-in-out infinite;
    filter: blur(1px);
}

/* NEW: Merlion representation using CSS */
.bg-merlion {
    width: 150px;
    height: 150px;
    top: 10%;
    left: 5%;
    background: radial-gradient(circle, #ff6b6b 0%, #ee5a6f 50%, #c44569 100%);
    clip-path: polygon(50% 0%, 80% 30%, 100% 30%, 70% 50%, 85% 80%, 50% 65%, 15% 80%, 30% 50%, 0% 30%, 20% 30%);
    animation: float 15s ease-in-out infinite;
}

/* NEW: Marina Bay Sands representation */
.bg-marina {
    width: 200px;
    height: 120px;
    top: 60%;
    right: 8%;
    background: linear-gradient(to top, #4facfe 0%, #00f2fe 100%);
    clip-path: polygon(10% 100%, 10% 30%, 20% 30%, 20% 100%, 40% 100%, 40% 30%, 50% 30%, 50% 100%, 70% 100%, 70% 30%, 80% 30%, 80% 100%, 90% 100%, 90% 20%, 5% 20%, 5% 100%);
    animation: float 18s ease-in-out infinite reverse;
}

/* NEW: Gardens by the Bay Supertrees representation */
.bg-gardens {
    width: 180px;
    height: 180px;
    bottom: 15%;
    left: 15%;
    background: radial-gradient(circle, #56ab2f 0%, #a8e063 100%);
    clip-path: polygon(50% 0%, 55% 20%, 70% 25%, 60% 40%, 75% 50%, 55% 60%, 65% 80%, 50% 70%, 35% 80%, 45% 60%, 25% 50%, 40% 40%, 30% 25%, 45% 20%);
    animation: float 22s ease-in-out infinite;
}

/* NEW: Singapore Flag representation */
.bg-flag {
    width: 160px;
    height: 100px;
    top: 35%;
    right: 20%;
    background: linear-gradient(to bottom, #ff0000 0%, #ff0000 50%, #ffffff 50%, #ffffff 100%);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
    animation: float 16s ease-in-out infinite;
}

/* NEW: Fireworks representation */
.bg-fireworks {
    width: 140px;
    height: 140px;
    top: 20%;
    right: 35%;
    background: radial-gradient(circle, #ffd700 0%, #ff6b6b 30%, #4facfe 60%, transparent 70%);
    animation: float 12s ease-in-out infinite, pulse 3s ease-in-out infinite;
}

/* NEW: Floating animation for background elements */
@keyframes float {
    0%, 100% {
        transform: translateY(0) translateX(0) rotate(0deg);
    }
    25% {
        transform: translateY(-20px) translateX(10px) rotate(5deg);
    }
    50% {
        transform: translateY(-10px) translateX(-10px) rotate(-5deg);
    }
    75% {
        transform: translateY(-30px) translateX(5px) rotate(3deg);
    }
}

/* NEW: Pulse animation for fireworks */
@keyframes pulse {
    0%, 100% {
        opacity: 0.15;
        transform: scale(1);
    }
    50% {
        opacity: 0.25;
        transform: scale(1.1);
    }
}

/* Main App Container - Responsive height based on environment */
/* MODIFIED: Added z-index to ensure content appears above background */
#app {
    width: 100%;
    height: 450px; /* Default for iframe */
    position: relative;
    overflow: hidden;
    z-index: 1;
}

/* If opened in new tab, use 90vh */
html:not([data-iframe]) #app {
    height: 90vh;
}

/* Tooltip for header information */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
    max-width: 300px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Progress Container - Compact design */
.progress-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 15px;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    transition: width 0.5s ease;
    border-radius: 10px;
}

.stats {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Game Area */
.game-area {
    height: calc(100% - 50px);
    position: relative;
    padding: 15px;
    overflow-y: auto;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Character Avatar */
.character-avatar {
    font-size: 60px;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

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

/* Story Text */
/* MODIFIED: Increased background opacity for better readability with background images */
.story-text {
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    border-radius: 15px;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.story-text h2 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 22px;
}

.story-text p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
    font-size: 15px;
}

.highlight {
    background: linear-gradient(120deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-block;
    margin-top: 8px;
}

/* Buttons - Optimized for text fitting */
.game-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    white-space: nowrap;
    min-width: fit-content;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.game-btn.secondary {
    background: linear-gradient(135deg, #a29bfe 0%, #6c5ce7 100%);
}

.game-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Chapter Info */
/* MODIFIED: Increased background opacity for better readability */
.chapter-info {
    text-align: center;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.98);
    padding: 12px;
    border-radius: 12px;
}

.chapter-info h3 {
    color: #667eea;
    font-size: 18px;
    margin-bottom: 5px;
}

.chapter-desc {
    color: #666;
    font-size: 13px;
}

/* Matching Container */
.matching-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    max-width: 800px;
    width: 100%;
}

.match-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Match Cards */
/* MODIFIED: Increased background opacity for better readability */
.match-card {
    background: rgba(255, 255, 255, 0.98);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 3px solid transparent;
    text-align: center;
    font-size: 14px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.match-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.match-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    transform: scale(1.05);
}

.match-card.matched {
    border-color: #00d2d3;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    pointer-events: none;
    animation: matchSuccess 0.5s ease;
}

.match-card.wrong {
    border-color: #ff6b6b;
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    animation: shake 0.5s ease;
}

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

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

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Choice Buttons */
.choices {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 500px;
}

/* MODIFIED: Increased background opacity for better readability */
.choice-btn {
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    border: 3px solid #667eea;
    padding: 15px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    white-space: normal;
    line-height: 1.4;
}

.choice-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateX(5px);
}

/* Results Screen */
/* MODIFIED: Increased background opacity for better readability */
.final-score {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    margin: 15px 0;
}

.score-item {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 18px;
}

.score-label {
    font-weight: 600;
    color: #666;
}

.score-value {
    font-weight: 700;
    color: #667eea;
    font-size: 22px;
}

/* Audio Controls */
.audio-controls {
    position: fixed;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.audio-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.audio-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.audio-btn.muted {
    opacity: 0.5;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    .matching-container {
        grid-template-columns: 1fr;
    }
    
    .match-card {
        font-size: 13px;
        padding: 12px;
    }
    
    .story-text h2 {
        font-size: 20px;
    }
    
    .story-text p {
        font-size: 14px;
    }
    
    /* NEW: Adjust background images for mobile */
    .bg-image {
        opacity: 0.1;
    }
}

/* Scrollbar styling */
.game-area::-webkit-scrollbar {
    width: 8px;
}

.game-area::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.game-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}

.game-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}