/* --- Battle Scene Layout (Preserved) --- */
.battle-scene {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    /* Stretch to ensure equal height */
    gap: 20px;
    position: relative;
    /* Context for timer */
}

/* ... (previous styles) ... */

/* --- Battle Timer (Time Attack Mode) --- */
.battle-timer {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    /* Floating Medallion Style */
    background: radial-gradient(circle at 30% 30%, #475569, #0f172a);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #ffd700;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.5);

    /* Centering Overlay */
    position: absolute;
    top: 50px;
    /* Align with avatars roughly */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.battle-timer.danger {
    color: #ffcccc;
    border-color: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
    animation: pulse 0.8s infinite alternate;
}

/* --- Visual Enhancements --- */
.combatant {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px;
    /* Glassmorphism */
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 215, 0, 0.15);
    /* Subtle gold border */
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: #e2e8f0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.combatant:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.3);
}

.combatant-name {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #ffd700;
    /* Gold text */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 0.5px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.combatant-avatar {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    /* Soft square looks more RPG-card like */
    margin-bottom: 20px;
    object-fit: contain;
    border: 3px solid #334155;
    background-color: rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.combatant-avatar:hover {
    transform: scale(1.02);
}

/* --- Health Bars --- */
.health-bar {
    width: 100%;
    height: 20px;
    background-color: #0f172a;
    border: 2px solid #334155;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.health-bar-inner {
    height: 100%;
    width: 100%;
    /* Rich green gradient */
    background: linear-gradient(90deg, #15803d, #22c55e);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

.health-bar-inner.low {
    /* Critical red gradient */
    background: linear-gradient(90deg, #991b1b, #ef4444);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.health-value {
    margin-top: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: #94a3b8;
}

/* --- Minigame Area --- */
.minigame-area {
    width: 100%;
    margin-top: 30px;
    padding: 30px;
    /* Glassmorphism darker */
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Decorative corner accents for minigame area (CSS only) */
.minigame-area::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 20px;
    height: 20px;
    border-top: 2px solid #ffd700;
    border-left: 2px solid #ffd700;
    border-radius: 14px 0 0 0;
}

.minigame-area::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-bottom: 2px solid #ffd700;
    border-right: 2px solid #ffd700;
    border-radius: 0 0 14px 0;
}

.problem {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    color: #f1f5f9;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.9);
    line-height: 1.4;
}

#answer-form {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
}

#answer-input {
    flex-grow: 1;
    max-width: 300px;
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #ffd700;
    background: rgba(255, 255, 255, 0.05);
    /* Very subtle fill */
    border: none;
    border-bottom: 3px solid #475569;
    padding: 10px;
    transition: all 0.3s;
}

#answer-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffd700;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* --- Epic Attack Button --- */
.btn-attack-epic {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 35px;
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
    letter-spacing: 2px;

    /* Fire/Battle Gradient */
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 50%, #7f1d1d 100%);
    border: 2px solid #ef4444;
    box-shadow:
        0 4px 15px rgba(185, 28, 28, 0.4),
        inset 0 0 10px rgba(0, 0, 0, 0.3);

    /* Text Shadow for clarity */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.btn-attack-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    transition: transform 0.4s ease;
}

.btn-attack-icon-container svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
}

.btn-attack-epic::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 100%;
    height: 200%;
    background: linear-gradient(to right,
            transparent,
            rgba(255, 255, 255, 0.2),
            transparent);
    transform: rotate(25deg);
    transition: left 0.6s ease;
}

/* Hover Effects */
.btn-attack-epic:hover:not(:disabled) {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 50%, #b91c1c 100%);
    border-color: #f87171;
    transform: translateY(-3px) scale(1.05);
    box-shadow:
        0 8px 25px rgba(220, 38, 38, 0.6),
        0 0 15px rgba(255, 215, 0, 0.2);
}

.btn-attack-epic:hover .btn-attack-icon-container {
    transform: rotate(15deg) scale(1.2);
}

.btn-attack-epic:hover::before {
    left: 200%;
}

/* Active / Click Effect */
.btn-attack-epic:active:not(:disabled) {
    transform: translateY(2px) scale(0.95);
    box-shadow: 0 2px 10px rgba(185, 28, 28, 0.4);
    filter: brightness(0.9);
}

.btn-attack-epic:disabled {
    background: #334155;
    border-color: #1e293b;
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

@keyframes attack-button-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.btn-attack-epic:not(:disabled) {
    animation: attack-button-pulse 2s infinite;
}

/* --- Animations --- */
.damage-animation {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.attack-animation {
    animation: attack 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes attack {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* --- Battle Navbar Styling --- */
.battle-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid #334155;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.button-exit {
    background: transparent;
    border: 1px solid #475569;
    color: #cbd5e1;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.button-exit:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ffd700;
    color: #ffd700;
}

/* Battle Exit Minimal - Default hidden, shown in mobile */
.button-exit-minimal {
    display: none;
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid #ef4444;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    text-transform: uppercase;
    font-weight: 700;
    transition: all 0.2s;
}

.button-exit-minimal:hover {
    background: #ef4444;
    transform: scale(1.05);
}

.nav-player-stats {
    display: flex;
    align-items: center;
    gap: 20px;
    font-family: 'Cinzel', serif;
    color: #e2e8f0;
}

.nav-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* --- Battle Timer (Time Attack Mode) --- */
/* --- Battle Timer (Time Attack Mode) --- */
.battle-timer {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    /* Floating Medallion Style */
    background: radial-gradient(circle at 30% 30%, #475569, #0f172a);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid #ffd700;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.5);

    /* Centering Overlay */
    position: absolute;
    top: 50px;
    /* Align with avatars roughly */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.battle-timer.danger {
    color: #ffcccc;
    border-color: #ef4444;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
    animation: pulse 0.8s infinite alternate;
}

@media (max-width: 768px) {
    .battle-scene {
        flex-direction: column;
        align-items: stretch;
    }

    .combatant {
        margin-bottom: 10px;
    }

    .battle-navbar {
        display: none !important;
        /* Hide redundant bar in mobile */
    }

    .button-exit-minimal {
        display: none !important;
        /* Hide minimal exit button, now in global menu */
    }

    .battle-scene {
        margin-top: 20px;
        /* Reduced margin since button is gone */
    }

    .battle-timer {
        top: 60px;
        font-size: 2rem;
    }
}