/* ==================== REALM MAP SCREEN ==================== */
#map-screen {
    background: linear-gradient(180deg, #0d0d1a 0%, #1a0a2e 50%, #0d1a1a 100%);
    background-size: cover;
    background-position: center;
    padding: 20px;
    justify-content: flex-start;
}

.map-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.player-stats {
    display: flex;
    gap: 15px;
}

.realms-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    position: relative;
    padding: 10px 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.realm-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s;
    position: relative;
}

.realm-node:active { transform: scale(0.95); }
.realm-node.locked { opacity: 0.5; pointer-events: none; }
.realm-node.locked .lock-overlay {
    position: absolute;
    font-size: 30px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.realm-node img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(139, 92, 246, 0.4));
    animation: realmFloat 3s ease-in-out infinite;
}

.realm-node:nth-child(2) img { animation-delay: 0.5s; }
.realm-node:nth-child(3) img { animation-delay: 1s; }
.realm-node:nth-child(4) img { animation-delay: 1.5s; }

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

.realm-name {
    color: #e9d5ff;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5), 0 0 10px rgba(139, 92, 246, 0.3);
    margin-top: 8px;
}

.realm-stars {
    display: flex;
    gap: 3px;
    margin-top: 5px;
}

.realm-stars img {
    width: 20px;
    height: 20px;
    animation: none;
}

.realm-stars img.empty { filter: grayscale(1) opacity(0.3); }

/* ==================== REALM INTRO SCREEN ==================== */
#realm-intro-screen {
    background-size: cover;
    background-position: center;
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: rgba(0,0,0,0.7);
    padding: 40px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(139, 92, 246, 0.3);
}

.intro-content h2 {
    color: #e9d5ff;
    font-size: 36px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5), 0 0 20px rgba(139, 92, 246, 0.4);
}

.intro-content img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    animation: bossIntro 1s ease-out;
}

@keyframes bossIntro {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.intro-content p {
    color: #c4b5fd;
    font-size: 18px;
    text-align: center;
}

/* ==================== BOSS FIGHT SCREEN ==================== */
#boss-screen {
    background-size: cover;
    background-position: center;
    padding: 10px;
    justify-content: space-between;
    overflow: visible;
}

.boss-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 15px;
    margin-bottom: 10px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.hearts-display {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    max-width: 60%;
}

.heart {
    width: 14px;
    height: 14px;
    transition: all 0.3s;
}

.heart.lost {
    filter: grayscale(1);
    opacity: 0.3;
    transform: scale(0.8);
}

.heart.damage {
    animation: heartDamage 0.5s ease;
}

@keyframes heartDamage {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.3); filter: brightness(2); }
    50% { transform: scale(0.8); }
}

.boss-health-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    margin-left: 15px;
}

.boss-health-bar {
    flex: 1;
    height: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(239, 68, 68, 0.4);
}

.boss-health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ef4444, #dc2626);
    border-radius: 8px;
    transition: width 0.5s ease;
}

#boss-health-text {
    color: #fff;
    font-weight: bold;
    min-width: 45px;
}

/* Boss Arena */
.boss-arena {
    width: 100%;
    height: 25vh;
    min-height: 120px;
    max-height: 180px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    position: relative;
    flex-shrink: 0;
}

.boss-sprite {
    width: min(150px, 20vh);
    height: min(150px, 20vh);
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
    transition: all 0.3s;
}

.boss-sprite.idle { animation: bossIdle 2s ease-in-out infinite; }
.boss-sprite.hit { animation: bossHit 0.5s ease; }
.boss-sprite.attack { animation: bossAttack 0.8s ease; }
.boss-sprite.defeated { animation: bossDefeated 1s ease forwards; }

@keyframes bossIdle {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.02); }
}

@keyframes bossHit {
    0% { transform: translateX(0); filter: brightness(2); }
    25% { transform: translateX(-20px); }
    50% { transform: translateX(20px); }
    75% { transform: translateX(-10px); }
    100% { transform: translateX(0); filter: brightness(1); }
}

@keyframes bossAttack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(50px) scale(1.2); }
    100% { transform: translateX(0) scale(1); }
}

@keyframes bossDefeated {
    0% { transform: rotate(0) scale(1); }
    50% { transform: rotate(10deg) scale(0.9); }
    100% { transform: rotate(-5deg) scale(0.8) translateY(30px); opacity: 0.7; }
}

.player-sprite {
    width: min(120px, 16vh);
    height: min(120px, 16vh);
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(139, 92, 246, 0.4));
}

.player-sprite.attack { animation: playerAttack 0.5s ease; }
.player-sprite.damage { animation: playerDamage 0.5s ease; }

@keyframes playerAttack {
    0% { transform: translateX(0); }
    50% { transform: translateX(-40px) scale(1.1); }
    100% { transform: translateX(0); }
}

@keyframes playerDamage {
    0%, 100% { transform: translateX(0); filter: brightness(1); }
    25% { transform: translateX(15px); filter: brightness(2) sepia(1); }
    75% { transform: translateX(-15px); }
}

/* Boss Question */
.boss-question-container {
    background: rgba(0,0,0,0.7);
    border-radius: 20px;
    padding: 10px 25px;
    margin: 5px 0;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 2px solid rgba(139, 92, 246, 0.3);
    flex-shrink: 0;
}

.boss-timer {
    width: 100%;
    margin: 10px 0;
}

.boss-timer-bar {
    width: 100%;
    height: 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 5px;
    overflow: hidden;
}

.boss-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #8b5cf6, #a855f7);
    border-radius: 5px;
    transition: width 0.1s linear;
}

.boss-timer-fill.warning {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.boss-timer-fill.critical {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    animation: timerPulse 0.3s ease-in-out infinite;
}

/* ==================== VICTORY SCREEN ==================== */
#victory-screen {
    background: linear-gradient(135deg, #1a0a2e 0%, #0d1a0d 100%);
}

.victory-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    animation: victoryPopIn 0.5s ease-out;
}

.victory-content h2 {
    font-size: 48px;
    color: #fbbf24;
    text-shadow: 3px 3px 0 #78350f, 0 0 30px rgba(251, 191, 36, 0.5);
    animation: victoryTitle 1s ease-in-out infinite;
}

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

@keyframes victoryPopIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.defeated-boss {
    width: 150px;
    height: 150px;
    object-fit: contain;
    animation: defeatedBounce 1s ease-in-out infinite;
}

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

.victory-stars {
    display: flex;
    gap: 15px;
}

.victory-stars img {
    width: 60px;
    height: 60px;
}

.victory-stars img.earned {
    animation: starEarned 0.5s ease-out backwards;
}

.victory-stars img:not(.earned) {
    filter: grayscale(1) opacity(0.3);
}

.victory-content p {
    color: #c4b5fd;
    font-size: 20px;
}

/* ==================== GAME OVER SCREEN ==================== */
#gameover-screen {
    background: linear-gradient(135deg, #2d0a0a 0%, #1a0a2e 100%);
}

.gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.gameover-content h2 {
    font-size: 42px;
    color: #ef4444;
    text-shadow: 2px 2px 0 #450a0a, 0 0 20px rgba(239, 68, 68, 0.4);
}

.sad-mascot {
    width: 150px;
    height: 150px;
    object-fit: contain;
    animation: sadBounce 2s ease-in-out infinite;
}

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

.gameover-content p {
    color: #fca5a5;
    font-size: 18px;
}

.gameover-content .btn-secondary {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
}

/* Attack Effects */
.attack-effect {
    position: absolute;
    pointer-events: none;
    z-index: 100;
}

.energy-beam {
    width: 200px;
    height: 30px;
    background: linear-gradient(90deg, #8b5cf6, #a855f7, #8b5cf6);
    border-radius: 15px;
    box-shadow: 0 0 20px #8b5cf6, 0 0 40px #8b5cf6;
    animation: beamShoot 0.4s ease-out forwards;
}

@keyframes beamShoot {
    0% { transform: scaleX(0); opacity: 1; }
    100% { transform: scaleX(2) translateX(-50px); opacity: 0; }
}

.boss-attack-effect {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, #ef4444, transparent);
    box-shadow: 0 0 30px #ef4444;
    animation: bossAttackEffect 0.5s ease-out forwards;
}

@keyframes bossAttackEffect {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}

.damage-number {
    position: absolute;
    font-size: 32px;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 2px 2px 0 #78350f;
    pointer-events: none;
    animation: damageFloat 1s ease-out forwards;
}

@keyframes damageFloat {
    0% { transform: translateY(0) scale(0.5); opacity: 1; }
    100% { transform: translateY(-80px) scale(1.2); opacity: 0; }
}

/* ==================== RESPONSIVE - 16:9 and wider screens ==================== */
@media (max-aspect-ratio: 3/4) {
    /* Portrait mode - default styling works fine */
}

@media (min-aspect-ratio: 4/3) {
    .boss-header {
        padding: 5px 10px;
        margin-bottom: 5px;
    }

    .boss-arena {
        height: 22vh;
        min-height: 100px;
        max-height: 150px;
        padding: 0 10px;
    }

    .boss-sprite {
        width: min(120px, 18vh);
        height: min(120px, 18vh);
    }

    .player-sprite {
        width: min(100px, 14vh);
        height: min(100px, 14vh);
    }

    .boss-question-container {
        padding: 8px 20px;
        margin: 3px 0;
    }

    .boss-question-container .question-text {
        font-size: 16px;
    }

    .boss-timer {
        margin: 5px 0;
    }

    .heart {
        width: 25px;
        height: 25px;
    }

    #boss-screen .answers-grid {
        gap: 8px;
        max-width: 300px;
        margin: 8px auto;
    }

    #boss-screen .answer-btn.monster-option .monster-name {
        font-size: 10px;
    }
}

/* ==================== VICTORY SCORE ==================== */
.victory-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin: 10px 0;
}
.victory-score .score-label {
    font-size: 16px;
    color: #c4b5fd;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.victory-score .score-value {
    font-size: 42px;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 2px 2px 0 #78350f, 0 0 20px rgba(251, 191, 36, 0.4);
    animation: scoreCountUp 1s ease-out;
}
.victory-score .best-score-line {
    font-size: 14px;
    color: #a78bfa;
}
.new-best-badge {
    font-size: 18px;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    animation: newBestPulse 1s ease-in-out infinite;
}
@keyframes scoreCountUp {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes newBestPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ==================== MAP BEST SCORE ==================== */
.realm-best-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 3px;
    font-size: 13px;
    color: #fbbf24;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}
.realm-best-score:empty,
.realm-score-value:empty { display: none; }
