/* ==================== WORLD SYSTEM STYLES ==================== */

.world-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.world-svg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

body.world-active {
    background: #0f172a !important; /* Dark fallback in case SVG fails */
}

body.world-enchanted-forest {
    background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 40%, #134e4a 100%) !important;
}

/* Fire Dragon animations */
.dragon-circle {
    transform-origin: 0 0;
    animation: dragonCircle 30s linear infinite;
}

@keyframes dragonCircle {
    0% { transform: translate(1270px, 230px) rotate(0deg); }
    25% { transform: translate(1150px, 150px) rotate(0deg); }
    50% { transform: translate(1030px, 230px) rotate(0deg); }
    75% { transform: translate(1150px, 310px) rotate(0deg); }
    100% { transform: translate(1270px, 230px) rotate(0deg); }
}

.dragon-fly {
    animation: dragonBob 1.5s ease-in-out infinite;
}

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

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

.wing-flap {
    transform-origin: -5px 0px;
    animation: wingFlap 0.3s ease-in-out infinite;
}

.wing-flap-delayed {
    transform-origin: -5px 25px;
    animation: wingFlapDown 0.3s ease-in-out infinite;
    animation-delay: 0.15s;
}

@keyframes wingFlap {
    0%, 100% { transform: scaleY(1) rotate(0deg); }
    50% { transform: scaleY(0.7) rotate(-10deg); }
}

@keyframes wingFlapDown {
    0%, 100% { transform: scaleY(1) rotate(0deg); }
    50% { transform: scaleY(0.7) rotate(10deg); }
}

.fire-flicker {
    animation: fireFlicker 0.2s ease-in-out infinite;
}

@keyframes fireFlicker {
    0%, 100% { transform: scaleX(1) translateX(0); opacity: 1; }
    50% { transform: scaleX(1.15) translateX(3px); opacity: 0.9; }
}

.tail-flame {
    animation: tailFlame 0.3s ease-in-out infinite;
}

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

/* Rocky Crags theme */
body.world-rocky-crags {
    background: linear-gradient(180deg, #87CEEB 0%, #b4d7e8 40%, #e8b87d 100%) !important;
}

/* Rocky Crags animations */
.eagle-soar {
    animation: eagleSoar 12s ease-in-out infinite;
}

.eagle-soar-reverse {
    animation: eagleSoarReverse 15s ease-in-out infinite;
}

@keyframes eagleSoar {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -20px) rotate(5deg); }
    50% { transform: translate(60px, 0) rotate(0deg); }
    75% { transform: translate(30px, 20px) rotate(-5deg); }
}

@keyframes eagleSoarReverse {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(-25px, 15px) rotate(-3deg); }
    50% { transform: translate(-50px, 0) rotate(0deg); }
    75% { transform: translate(-25px, -15px) rotate(3deg); }
}

.cloud-drift {
    animation: cloudDrift 30s ease-in-out infinite;
}

.cloud-drift-slow {
    animation: cloudDrift 45s ease-in-out infinite;
}

@keyframes cloudDrift {
    0%, 100% { transform: translateX(0); opacity: 0.5; }
    50% { transform: translateX(50px); opacity: 0.7; }
}

.falling-pebble {
    animation: pebbleFall 6s linear infinite;
}

@keyframes pebbleFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(700px) rotate(360deg); opacity: 0; }
}

.dust-float {
    animation: dustFloat 10s ease-in-out infinite;
}

@keyframes dustFloat {
    0%, 100% { transform: translate(0, 0); opacity: 0.3; }
    25% { transform: translate(10px, -15px); opacity: 0.6; }
    50% { transform: translate(20px, -5px); opacity: 0.4; }
    75% { transform: translate(5px, -20px); opacity: 0.5; }
}

/* Mountain Goat walking up path */
.goat-walk-path {
    animation: goatWalkPath 60s linear infinite;
}

@keyframes goatWalkPath {
    0% { transform: translate(100px, 780px); }
    10% { transform: translate(200px, 720px); }
    20% { transform: translate(350px, 680px); }
    30% { transform: translate(500px, 600px); }
    40% { transform: translate(650px, 540px); }
    50% { transform: translate(800px, 460px); }
    60% { transform: translate(950px, 400px); }
    70% { transform: translate(1100px, 340px); }
    80% { transform: translate(1250px, 300px); }
    90% { transform: translate(1380px, 260px); }
    100% { transform: translate(100px, 780px); }
}

.goat-head {
    animation: goatHeadBob 2s ease-in-out infinite;
}

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

.goat-tail {
    animation: goatTailWag 0.8s ease-in-out infinite;
}

@keyframes goatTailWag {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(8deg); }
}

/* Dragon eye pulse */
.dragon-eye-pulse {
    animation: dragonEyePulse 2s ease-in-out infinite;
}

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

/* Pebble elements added via JS */
.pebble {
    position: absolute;
    top: -10px;
    border-radius: 50%;
    animation: pebbleFall 6s linear infinite;
}

/* Dust elements added via JS */
.dust {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(212, 165, 116, 0.5);
    animation: dustFloat 10s ease-in-out infinite;
}

body.world-active .waves {
    display: none !important;
}

/* Stars */
.star-twinkle {
    animation: starTwinkle 3s ease-in-out infinite;
}
@keyframes starTwinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Trees */
.tree-sway {
    animation: treeSway 6s ease-in-out infinite;
    transform-origin: bottom center;
}
.tree-sway-delayed {
    animation: treeSway 7s ease-in-out infinite;
    animation-delay: 1s;
    transform-origin: bottom center;
}
.tree-sway-slow {
    animation: treeSwaySubtle 8s ease-in-out infinite;
    transform-origin: bottom center;
}
.tree-sway-slow-delayed {
    animation: treeSwaySubtle 9s ease-in-out infinite;
    animation-delay: 2s;
    transform-origin: bottom center;
}
@keyframes treeSway {
    0%, 100% { transform: rotate(-0.5deg); }
    50% { transform: rotate(0.5deg); }
}
@keyframes treeSwaySubtle {
    0%, 100% { transform: rotate(-0.3deg) translateX(-1px); }
    50% { transform: rotate(0.3deg) translateX(1px); }
}

/* Mushrooms */
.mushroom-glow {
    animation: mushroomPulse 3s ease-in-out infinite;
}
.mushroom-glow-delayed {
    animation: mushroomPulse 3.5s ease-in-out infinite;
    animation-delay: 1s;
}
@keyframes mushroomPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

/* Diamond mushroom special sparkle for Island 5 */
.world-milestone[data-island-id="5"] .mushroom-cap-outer {
    animation: diamondSparkle 2s ease-in-out infinite;
}
@keyframes diamondSparkle {
    0%, 100% { 
        filter: brightness(1) drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
    }
    25% { 
        filter: brightness(1.4) drop-shadow(0 0 15px rgba(180, 240, 255, 1));
    }
    50% { 
        filter: brightness(1.2) drop-shadow(0 0 12px rgba(200, 180, 255, 0.9));
    }
    75% { 
        filter: brightness(1.5) drop-shadow(0 0 18px rgba(255, 255, 255, 1));
    }
}

/* Flowers */
.flower-glow {
    animation: flowerPulse 2s ease-in-out infinite;
}
.flower-glow-delayed {
    animation: flowerPulse 2.5s ease-in-out infinite;
    animation-delay: 0.5s;
}
@keyframes flowerPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Cottage */
.window-glow {
    animation: windowFlicker 4s ease-in-out infinite;
}
@keyframes windowFlicker {
    0%, 100% { fill: #fef3c7; }
    50% { fill: #fde68a; }
    75% { fill: #fcd34d; }
}

.smoke-rise {
    animation: smokeRise 4s ease-out infinite;
}
.smoke-rise-delayed {
    animation: smokeRise 4s ease-out infinite;
    animation-delay: 1.5s;
}
@keyframes smokeRise {
    0% { transform: translateY(0) scale(1); opacity: 0.3; }
    100% { transform: translateY(-25px) translateX(8px) scale(1.8); opacity: 0; }
}

.lantern-glow {
    animation: lanternFlicker 2s ease-in-out infinite;
}
@keyframes lanternFlicker {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; filter: brightness(1.3); }
}

/* Cauldron */
.potion-color {
    animation: potionShift 6s ease-in-out infinite;
}
@keyframes potionShift {
    0%, 100% { fill: #f472b6; }
    25% { fill: #38bdf8; }
    50% { fill: #fb923c; }
    75% { fill: #facc15; }
}

.bubble {
    animation: bubbleShift 6s ease-in-out infinite;
}
.bubble-1 { animation: bubblePop 1.5s ease-in-out infinite, bubbleShift 6s ease-in-out infinite; }
.bubble-2 { animation: bubblePop 1.8s ease-in-out infinite, bubbleShift 6s ease-in-out infinite; animation-delay: 0.2s; }
.bubble-3 { animation: bubblePop 1.3s ease-in-out infinite, bubbleShift 6s ease-in-out infinite; animation-delay: 0.5s; }
.bubble-4 { animation: bubblePop 2s ease-in-out infinite, bubbleShift 6s ease-in-out infinite; animation-delay: 0.8s; }

@keyframes bubbleShift {
    0%, 100% { fill: #f9a8d4; }
    25% { fill: #7dd3fc; }
    50% { fill: #fdba74; }
    75% { fill: #fde047; }
}
@keyframes bubblePop {
    0% { transform: translateY(0) scale(0.5); }
    50% { transform: translateY(-10px) scale(1); }
    100% { transform: translateY(-20px) scale(0.3); opacity: 0; }
}

.sparkle {
    animation: sparkleShift 6s ease-in-out infinite;
}
.sparkle-1 { animation: sparkleFloat 2s ease-in-out infinite, sparkleShift 6s ease-in-out infinite; }
.sparkle-2 { animation: sparkleFloat 2.5s ease-in-out infinite, sparkleShift 6s ease-in-out infinite; animation-delay: 0.5s; }
.sparkle-3 { animation: sparkleFloat 2.2s ease-in-out infinite, sparkleShift 6s ease-in-out infinite; animation-delay: 1s; }

@keyframes sparkleShift {
    0%, 100% { fill: #fce7f3; }
    25% { fill: #e0f2fe; }
    50% { fill: #ffedd5; }
    75% { fill: #fef9c3; }
}
@keyframes sparkleFloat {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.9; }
    50% { transform: translateY(-10px) scale(1.3); opacity: 0.5; }
}

/* Animals */
.owl-blink {
    animation: owlBlink 4s ease-in-out infinite;
}
@keyframes owlBlink {
    0%, 45%, 50%, 100% { transform: scaleY(1); }
    47% { transform: scaleY(0.1); }
}

.owl-eye-glow {
    animation: owlEyeGlow 3s ease-in-out infinite;
}
@keyframes owlEyeGlow {
    0%, 100% { fill: #fbbf24; filter: drop-shadow(0 0 3px #fbbf24); }
    50% { fill: #fcd34d; filter: drop-shadow(0 0 6px #fbbf24); }
}

.frog-throat {
    animation: frogThroat 3s ease-in-out infinite;
}
@keyframes frogThroat {
    0%, 70%, 100% { transform: scale(1); }
    75%, 85% { transform: scale(1.8, 2); }
}

.snail-crawl {
    animation: snailCrawl 60s linear infinite;
}
@keyframes snailCrawl {
    0% { transform: translateX(200px); }
    100% { transform: translateX(1100px); }
}

.snail-shell {
    animation: shellGlow 3s ease-in-out infinite;
}
@keyframes shellGlow {
    0%, 100% { fill: #fcd34d; filter: drop-shadow(0 0 8px #fbbf24); }
    33% { fill: #f0abfc; filter: drop-shadow(0 0 12px #e879f9); }
    66% { fill: #67e8f9; filter: drop-shadow(0 0 10px #22d3ee); }
}

/* Pawprints */
.pawprint {
    fill: #3d2817;
    opacity: 0.3;
}
.pawprint-pink { animation: pawGlowPink 32s ease-in-out infinite; }
.pawprint-gold { animation: pawGlowGold 32s ease-in-out infinite; }
.pawprint-cyan { animation: pawGlowCyan 32s ease-in-out infinite; }
.pawprint-purple { animation: pawGlowPurple 32s ease-in-out infinite; }

@keyframes pawGlowPink {
    0%, 4%, 100% { fill: #3d2817; opacity: 0.3; filter: none; }
    2% { fill: #f472b6; opacity: 1; filter: drop-shadow(0 0 12px #f472b6); }
}
@keyframes pawGlowGold {
    0%, 4%, 100% { fill: #3d2817; opacity: 0.3; filter: none; }
    2% { fill: #fbbf24; opacity: 1; filter: drop-shadow(0 0 12px #fbbf24); }
}
@keyframes pawGlowCyan {
    0%, 4%, 100% { fill: #3d2817; opacity: 0.3; filter: none; }
    2% { fill: #22d3ee; opacity: 1; filter: drop-shadow(0 0 12px #22d3ee); }
}
@keyframes pawGlowPurple {
    0%, 4%, 100% { fill: #3d2817; opacity: 0.3; filter: none; }
    2% { fill: #a78bfa; opacity: 1; filter: drop-shadow(0 0 12px #a78bfa); }
}

/* Fireflies */
.fireflies {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.firefly {
    position: absolute;
    border-radius: 50%;
    background: #fde047;
    box-shadow: 0 0 10px 4px rgba(253, 224, 71, 0.6);
    animation: fireflyFloat 6s ease-in-out infinite;
}
@keyframes fireflyFloat {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.8; }
    25% { transform: translate(20px, -30px) scale(1.2); opacity: 1; }
    50% { transform: translate(-10px, -50px) scale(0.8); opacity: 0.5; }
    75% { transform: translate(30px, -20px) scale(1.1); opacity: 0.9; }
}

/* Particles */
.particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.pollen {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #a7f3d0;
    opacity: 0.4;
    animation: pollenFloat 12s linear infinite;
}
@keyframes pollenFloat {
    0% { transform: translateY(100vh) translateX(0); opacity: 0; }
    10% { opacity: 0.4; }
    90% { opacity: 0.4; }
    100% { transform: translateY(-20px) translateX(50px); opacity: 0; }
}

/* ==================== MILESTONE MARKERS ==================== */

.world-milestones {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

.world-milestone {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.3s ease, filter 0.3s ease;
    text-align: center;
}

.world-milestone:hover {
    transform: translate(-50%, -50%) scale(1.1) translateY(-5px);
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
}

.world-milestone.locked {
    opacity: 0.85;
}
.world-milestone.locked:hover {
    transform: translate(-50%, -50%) scale(1.05) translateY(-3px);
    cursor: pointer;
    filter: drop-shadow(0 6px 15px rgba(0, 0, 0, 0.3));
}

.milestone-marker {
    width: 70px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
    transition: filter 0.3s ease, transform 0.3s ease;
}

.milestone-marker:hover {
    transform: scale(1.1);
}

/* Mushroom outer cap glow pulse animation */
.world-milestone.unlocked .mushroom-cap-outer {
    animation: capPulse 2s ease-in-out infinite;
}

@keyframes capPulse {
    0%, 100% { 
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
        opacity: 1;
    }
    50% { 
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
        opacity: 0.95;
    }
}

/* Locked practice button */
body.world-active .btn-locked,
.btn-locked {
    background: linear-gradient(135deg, #78716c, #57534e) !important;
    cursor: not-allowed;
    opacity: 0.8;
}

.btn-locked:hover {
    transform: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

/* Locked island header banner */
.island-locked-banner {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #78350f;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(251, 191, 36, 0.3);
}

.island-locked-banner .lock-icon {
    font-size: 1.3rem;
}

.milestone-svg {
    width: 100%;
    height: 100%;
}

.milestone-name {
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Quicksand', sans-serif;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.world-milestone.unlocked .milestone-name {
    background: rgba(255, 255, 255, 0.95);
    color: #3f3f46;
}

.world-milestone.locked .milestone-name {
    background: rgba(168, 162, 158, 0.9);
    color: #57534e;
}

/* Next World Indicator */
.next-world-indicator {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    z-index: 25;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
}

.next-world-indicator:hover {
    color: white;
    transform: translateY(-50%) scale(1.05);
}

.next-world-indicator.locked {
    opacity: 0.7;
    cursor: pointer;
}
.next-world-indicator.locked:hover {
    transform: translateY(-50%) scale(1.05);
}

/* Previous world indicator (left side) */
.prev-world-indicator {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    z-index: 25;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 15px;
}

.prev-world-indicator:hover {
    color: white;
    transform: translateY(-50%) scale(1.05);
}

.prev-world-icon {
    font-size: 2.8rem;
    margin-bottom: 8px;
}

.prev-world-text {
    font-size: 0.8rem;
    max-width: 90px;
    line-height: 1.3;
    font-family: 'Quicksand', sans-serif;
    margin: 0 auto;
}

.prev-world-arrow {
    width: 24px;
    height: 24px;
    margin: 10px auto 0;
    animation: bounceLeft 1.5s ease-in-out infinite;
}

@keyframes bounceLeft {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-6px); }
}

.next-world-icon {
    font-size: 2.8rem;
    margin-bottom: 8px;
}

.next-world-text {
    font-size: 0.8rem;
    max-width: 90px;
    line-height: 1.3;
    font-family: 'Quicksand', sans-serif;
    margin: 0 auto;
}

.next-world-arrow {
    width: 24px;
    height: 24px;
    margin: 10px auto 0;
    animation: bounceRight 1.5s ease-in-out infinite;
}
@keyframes bounceRight {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* ==================== HEADER ADJUSTMENTS ==================== */

body.world-active .user-bar {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

body.world-active .user-info {
    background: linear-gradient(135deg, #ddd6fe, #a5f3fc);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 25px;
    padding: 6px 12px;
    box-shadow: 0 2px 15px rgba(167, 139, 250, 0.4);
}

body.world-active .user-info #displayUsername {
    color: #4c1d95;
}

body.world-active .logout-btn {
    background: rgba(239, 68, 68, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Title in header bar */
.header-title {
    font-size: 3rem;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

body.world-active .header-title span {
    text-shadow: 
        2px 2px 0 rgba(0, 0, 0, 0.4),
        -1px -1px 0 rgba(0, 0, 0, 0.2),
        0 0 30px rgba(255, 255, 255, 0.4);
}

/* Hide old title location */
body.world-active header .rainbow-title:not(.header-title) {
    display: none;
}

body.world-active .streak-display {
    background: linear-gradient(135deg, #fb923c, #ea580c) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

body.world-active .header-leaderboard-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Streak bar on world - float nicely */
body.world-active .streak-leaderboard-bar {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 30px;
    padding: 5px;
}

/* Adjust header area when in world mode */
body.world-active header {
    padding-top: 10px;
}

body.world-active .header-controls {
    display: flex;
    justify-content: center;
}

/* ==================== ISLAND VIEW ON FOREST ==================== */

body.world-active .island-view {
    position: relative;
    z-index: 25;
}

body.world-active .island-header {
    background: linear-gradient(135deg, rgba(8, 131, 149, 0.95), rgba(10, 77, 104, 0.95));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: visible !important;
}

/* Ensure quote guide stays visible */
body.world-active .island-guide {
    z-index: 50;
    position: absolute;
    animation: none !important;
}

body.world-active .island-guide[style*="display: flex"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

body.world-active .guide-speech-bubble {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    animation: none !important;
}

body.world-active .guide-character {
    animation: none !important;
}

body.world-active .legend {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 15px 20px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

body.world-active .word-grid {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

body.world-active .action-buttons .btn {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .world-milestone {
        transform: translate(-50%, -50%) scale(0.75);
    }
    .world-milestone:hover {
        transform: translate(-50%, -50%) scale(0.82) translateY(-4px);
    }
    .milestone-name {
        font-size: 0.7rem;
        padding: 4px 10px;
    }
    .next-world-indicator {
        right: 10px;
        padding: 10px;
    }
    .next-world-icon {
        font-size: 2rem;
    }
    .next-world-text {
        font-size: 0.7rem;
        max-width: 70px;
    }
    .prev-world-indicator {
        left: 10px;
        padding: 10px;
    }
    .prev-world-icon {
        font-size: 2rem;
    }
    .prev-world-text {
        font-size: 0.7rem;
        max-width: 70px;
    }
    
    .header-title {
        font-size: 2.2rem;
    }
}

@media (max-width: 480px) {
    .milestone-marker {
        width: 55px;
        height: 66px;
    }
    .milestone-name {
        display: none;
    }
    .prev-world-text,
    .next-world-text {
        display: none;
    }
    
    .header-title {
        font-size: 1.6rem;
    }
}

/* ==================== GREETING SPEECH BUBBLE ==================== */

.greeting-speech-bubble {
    position: fixed;
    top: 70px;
    left: 20px;
    z-index: 9999;
    max-width: 320px;
    animation: bubblePopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), 
               bubbleFadeOut 2s ease-out 8s forwards;
    cursor: pointer;
}

.greeting-bubble-content {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #d946ef 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 20px 20px 20px 4px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5),
                0 4px 15px rgba(0, 0, 0, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.greeting-bubble-content #greetingIcon {
    font-size: 1.4rem;
    animation: iconWiggle 0.6s ease-in-out 0.3s;
}

.greeting-bubble-subtext {
    background: linear-gradient(135deg, #f0abfc 0%, #e879f9 100%);
    color: #701a75;
    padding: 10px 16px;
    border-radius: 4px 16px 16px 16px;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 6px;
    margin-left: 20px;
    box-shadow: 0 4px 15px rgba(232, 121, 249, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* Bubble pointer/tail */
.greeting-bubble-content::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 15px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid #a855f7;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15));
}

@keyframes bubblePopIn {
    0% { 
        transform: scale(0) translateY(20px); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.1) translateY(-5px); 
    }
    100% { 
        transform: scale(1) translateY(0); 
        opacity: 1; 
    }
}

@keyframes bubbleFadeOut {
    0% { 
        opacity: 1; 
        transform: scale(1) translateY(0); 
    }
    100% { 
        opacity: 0; 
        transform: scale(0.95) translateY(-10px); 
    }
}

@keyframes iconWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Sparkle effect on bubble */
.greeting-bubble-content::after {
    content: '✨';
    position: absolute;
    top: -8px;
    right: -5px;
    font-size: 1.2rem;
    animation: sparkleFloat 2s ease-in-out infinite;
}

@keyframes sparkleFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 1; }
    50% { transform: translateY(-5px) rotate(15deg); opacity: 0.7; }
}

@media (max-width: 480px) {
    .greeting-speech-bubble {
        left: 10px;
        max-width: 280px;
        top: 65px;
    }
    
    .greeting-bubble-content {
        padding: 12px 16px;
        font-size: 1rem;
    }
    
    .greeting-bubble-subtext {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* First Name Prompt specific styles */
.first-name-prompt {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 50%, #14b8a6 100%);
    border: 2px solid rgba(94, 234, 212, 0.4);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 
                0 0 40px rgba(94, 234, 212, 0.3);
}

.first-name-prompt input {
    width: 100%;
    padding: 14px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-family: 'Quicksand', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #0f766e;
    text-align: center;
    box-sizing: border-box;
}

.first-name-prompt input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.first-name-prompt input::placeholder {
    color: #5eead4;
}

@media (max-width: 480px) {
    .greeting-content {
        padding: 30px 25px;
    }
    
    .greeting-icon {
        font-size: 3rem;
    }
    
    .greeting-content h2 {
        font-size: 1.4rem;
    }
    
    .greeting-content p {
        font-size: 1rem;
    }
    
    .greeting-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}
