/* Letter Bloom - Base Styles and Layout with Zone Backgrounds */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: background-image 1.5s ease-in-out;
}

/* Dynamic Background Container */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    transition: opacity 1.5s ease-in-out;
}

.background-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(3px);
    transform: scale(1.1); /* Slightly scale to hide blur edges */
    transition: opacity 1.5s ease-in-out;
}

/* Zone-specific backgrounds */
.zone-1 { background-image: url('Backgrounds/Beach.png'); }
.zone-2 { background-image: url('Backgrounds/CherryTreeGarden.png'); }
.zone-3 { background-image: url('Backgrounds/CosyCabin.png'); }
.zone-4 { background-image: url('Backgrounds/DesertOasis.png'); }
.zone-5 { background-image: url('Backgrounds/Forest.png'); }
.zone-6 { background-image: url('Backgrounds/Meadow.png'); }
.zone-7 { background-image: url('Backgrounds/MountainLake.png'); }
.zone-8 { background-image: url('Backgrounds/RollingHills.png'); }
.zone-9 { background-image: url('Backgrounds/Ruins.png'); }
.zone-10 { background-image: url('Backgrounds/SnowyVillage.png'); }

/* Fallback gradient if images don't load */
.background-fallback {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        #667eea 0%, 
        #764ba2 25%, 
        #f093fb 50%, 
        #f5576c 75%, 
        #4facfe 100%);
    z-index: -2;
}

/* Enhanced overlay for better text readability */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.15) 0%, 
        rgba(118, 75, 162, 0.15) 50%, 
        rgba(240, 147, 251, 0.15) 100%);
    pointer-events: none;
    z-index: 0;
}

/* Additional overlay for depth */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.2) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    z-index: 0;
}

/* Animated Background Orbs */
.background-animation {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
}

.background-animation::before,
.background-animation::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    animation: float 20s infinite ease-in-out;
}

.background-animation::before {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(240, 147, 251, 0.2) 0%, transparent 70%);
    top: -200px;
    left: -200px;
}

.background-animation::after {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.2) 0%, transparent 70%);
    bottom: -300px;
    right: -300px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(100px, -100px) scale(1.1); }
    50% { transform: translate(-100px, 100px) scale(0.9); }
    75% { transform: translate(50px, 50px) scale(1.05); }
}

/* Zone Transition Effect */
@keyframes zoneTransition {
    0% { opacity: 0; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1.1); }
}

.zone-changing .background-image {
    animation: zoneTransition 1.5s ease-in-out;
}

/* Zone Name Display */
.zone-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    font-weight: 800;
    color: white;
    text-shadow: 
        0 0 40px rgba(0, 0, 0, 0.5),
        0 0 80px rgba(102, 126, 234, 0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    animation: zoneNameReveal 3s ease-in-out;
}

@keyframes zoneNameReveal {
    0% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.5);
        letter-spacing: 20px;
    }
    20% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1.1);
        letter-spacing: 10px;
    }
    40% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        letter-spacing: 5px;
    }
    80% { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1);
        letter-spacing: 5px;
    }
    100% { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.9);
        letter-spacing: 2px;
    }
}

/* Premium Glass Game Wrapper */
.game-wrapper {
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 800px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    padding: 25px;
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Elegant Game Header with Zone Display */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 15px;
}

.game-header h1 {
    font-size: 2.8em;
    font-weight: 800;
    letter-spacing: 3px;
    position: relative;
    display: inline-block;
    color: white;
    text-shadow: 
        0 2px 10px rgba(255, 255, 255, 0.5),
        0 4px 20px rgba(102, 126, 234, 0.6),
        0 6px 40px rgba(240, 147, 251, 0.4);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

/* Individual letter animation */
.game-header h1 span {
    display: inline-block;
    animation: letterFloat 3s ease-in-out infinite;
    position: relative;
}

/* Stagger the animation for each letter */
.game-header h1 span:nth-child(1) { animation-delay: 0s; }
.game-header h1 span:nth-child(2) { animation-delay: 0.1s; }
.game-header h1 span:nth-child(3) { animation-delay: 0.2s; }
.game-header h1 span:nth-child(4) { animation-delay: 0.3s; }
.game-header h1 span:nth-child(5) { animation-delay: 0.4s; }
.game-header h1 span:nth-child(6) { animation-delay: 0.5s; }
.game-header h1 span:nth-child(7) { animation-delay: 0.6s; }
.game-header h1 span:nth-child(8) { animation-delay: 0.7s; }
.game-header h1 span:nth-child(9) { animation-delay: 0.8s; }
.game-header h1 span:nth-child(10) { animation-delay: 0.9s; }
.game-header h1 span:nth-child(11) { animation-delay: 1.0s; }
.game-header h1 span:nth-child(12) { animation-delay: 1.1s; }

/* Particle effect for each letter - with staggered timing */
.game-header h1 span::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, transparent 70%);
    border-radius: 50%;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    animation: particleRise 4s ease-in-out infinite;
    opacity: 0;
}

/* Stagger particle animations differently from letter float */
.game-header h1 span:nth-child(1)::after { animation-delay: 0.2s; }
.game-header h1 span:nth-child(2)::after { animation-delay: 0.5s; }
.game-header h1 span:nth-child(3)::after { animation-delay: 0.8s; }
.game-header h1 span:nth-child(4)::after { animation-delay: 1.1s; }
.game-header h1 span:nth-child(5)::after { animation-delay: 1.4s; }
.game-header h1 span:nth-child(6)::after { animation-delay: 1.7s; }
.game-header h1 span:nth-child(7)::after { animation-delay: 2.0s; }
.game-header h1 span:nth-child(8)::after { animation-delay: 2.3s; }
.game-header h1 span:nth-child(9)::after { animation-delay: 2.6s; }
.game-header h1 span:nth-child(10)::after { animation-delay: 2.9s; }
.game-header h1 span:nth-child(11)::after { animation-delay: 3.2s; }
.game-header h1 span:nth-child(12)::after { animation-delay: 3.5s; }

@keyframes letterFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-3px) rotate(-1deg);
    }
    75% {
        transform: translateY(2px) rotate(1deg);
    }
}

@keyframes titleGlow {
    0% {
        filter: brightness(1);
    }
    100% {
        filter: brightness(1.1);
    }
}

@keyframes particleRise {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(0);
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px);
    }
}

/* Enhanced Level Info with Zone Display */
.level-info {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 12px 25px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.level-text, .score-text, .zone-text {
    font-size: 1em;
    color: #fff;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.level-text span, .score-text span, .zone-text span {
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.zone-text {
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 20px;
}

/* 3 Column Layout with Glass Effects */
.game-area {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 25px;
    min-height: 0;
}

/* Left Panel - Premium Crossword */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

/* Center Panel - Elegant Interactive Area */
.center-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    min-width: 220px;
}

/* Right Panel - Elegant Word Lists */
.right-panel {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    overflow-y: auto;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Enhanced Loading Screen */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    font-size: 1.3em;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.loading::after {
    content: '';
    display: block;
    width: 50px;
    height: 50px;
    margin: 20px auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Premium Music Toggle (Hidden when media player is active) */
.music-toggle {
    display: none; /* Hidden since we have media player */
}

/* FIXED: Message Popup at Top */
.message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #764ba2;
    padding: 15px 35px;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 600;
    z-index: 1000;
    animation: messageSlideDown 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.2),
        0 0 60px rgba(102, 126, 234, 0.3);
    text-align: center;
    min-width: 200px;
}

@keyframes messageSlideDown {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px) scale(0.9);
    }
    50% {
        transform: translateX(-50%) translateY(5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}