/* CloudArena — RPG de batalha por turnos */

.arena-loading {
    text-align: center;
    padding: 4rem 1rem;
    font-size: 1.1rem;
    opacity: 0.8;
}

/* ── Home: seleção de herói + cards das arenas ── */
.arena-hero-select {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.4rem;
    font-size: 0.95rem;
}

.hero-choice {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #cdd3de;
    border-radius: 10px;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hero-choice:hover { border-color: #2dd4bf; }
.hero-choice.active {
    background: rgba(45, 212, 191, 0.15);
    border-color: #2dd4bf;
    color: #2dd4bf;
    font-weight: 700;
}

.arena-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.arena-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--arena-color, #2dd4bf);
    border-radius: 14px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.arena-card-head h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--arena-color, #2dd4bf);
}

.arena-card-head span { font-size: 0.85rem; opacity: 0.7; }

.arena-card-stats {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    opacity: 0.9;
}

.arena-btn {
    background: var(--arena-color, #2dd4bf);
    color: #0f172a;
    border: none;
    border-radius: 10px;
    padding: 0.7rem;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.arena-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }

.arena-link {
    background: none;
    border: none;
    color: #8892a6;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline dotted;
    padding: 0.3rem 0.5rem;
}

.arena-link:hover { color: #2dd4bf; }

/* ── Batalha ── */
.battle-screen { max-width: 860px; margin: 0 auto; }

.battle-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
}

.battle-level { font-weight: 700; color: var(--arena-color, #2dd4bf); }
.battle-dmg { opacity: 0.6; font-variant-numeric: tabular-nums; }

.boss-tag {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff9d9d;
    border-radius: 6px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    margin-left: 0.4rem;
}

.battle-field {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 0.5rem;
    padding: 1rem 0.5rem 1.4rem;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.4), rgba(26, 26, 46, 0.7));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

/* nome do golpe do inimigo (tópico da questão — spec seção 13) */
.attack-callout {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 90%;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 107, 107, 0.16);
    border: 1px solid rgba(255, 107, 107, 0.45);
    color: #ffb3b3;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 5;
}
.attack-callout.show { opacity: 1; }

.fighter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    min-width: 130px;
    transition: transform 0.3s ease;
}

.vs { font-weight: 900; font-size: 1.3rem; opacity: 0.35; align-self: center; }

.sprite {
    width: 110px;
    height: 110px;
    object-fit: contain;
    image-rendering: pixelated;
}

/* o canvas do herói é 180x150 (não quadrado): largura automática preserva a
   proporção intrínseca em qualquer breakpoint, sem distorcer os frames.
   Altura 2x a dos demais sprites — o personagem ocupa só parte do quadro
   (a folga é o espaço do arco da espada), então sem o dobro ele parecia
   pequeno demais em relação ao inimigo. */
canvas.sprite { height: 220px; width: auto; }

/* chefe: personagem com arte própria (spec seção 13) — a escala/aura aqui é
   só o reforço visual sutil opcional (~1.2x) por cima da arte do chefe */
.fighter.is-boss .sprite,
.fighter.is-boss .sprite-fallback { filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.35)); }

.sprite-fallback {
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    user-select: none;
}

.fighter-name { font-size: 0.8rem; font-weight: 700; opacity: 0.85; text-align: center; }

/* HP bars */
.hp-bar { width: 100%; max-width: 160px; }
.hp-label {
    font-size: 0.72rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
    margin-bottom: 2px;
}
.hp-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    overflow: hidden;
}
.hp-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }

/* animações do inimigo geradas em código (sem quadros extras) */
.enemy-hurt .sprite,
.enemy-hurt .sprite-fallback {
    animation: enemyHurtFlash 0.5s ease;
}
@keyframes enemyHurtFlash {
    0%, 100% { filter: none; }
    30% { filter: sepia(1) saturate(6) hue-rotate(-50deg) brightness(1.1); }
}
.fighter.is-boss.enemy-hurt .sprite,
.fighter.is-boss.enemy-hurt .sprite-fallback {
    animation: enemyHurtFlashBoss 0.5s ease;
}
@keyframes enemyHurtFlashBoss {
    0%, 100% { filter: saturate(1.4) drop-shadow(0 0 14px rgba(255, 209, 102, 0.65)); }
    30% { filter: sepia(1) saturate(6) hue-rotate(-50deg) brightness(1.2); }
}

.enemy-attacking { transform: translateX(-46px); }

/* animações do herói */
.hero-attack { animation: heroLunge 0.5s ease; }
@keyframes heroLunge {
    0%, 100% { transform: translateX(0); }
    35% { transform: translateX(40px); }
}
.hero-hurt { animation: heroShake 0.5s ease; }
@keyframes heroShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(4px); }
}

/* ── Pergunta e golpes ── */
.battle-question {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 1.1rem;
}

.question-text { font-size: 1rem; line-height: 1.5; margin: 0 0 0.9rem; }

.phase-title {
    font-weight: 800;
    color: var(--arena-color, #2dd4bf);
    font-size: 0.95rem;
    margin: 0.6rem 0;
}

.option-list { display: flex; flex-direction: column; gap: 0.55rem; }

.option-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    font-size: 0.92rem;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.option-check:hover { border-color: rgba(255, 209, 102, 0.5); }
.option-check.selected {
    border-color: #ffd166;
    background: rgba(255, 209, 102, 0.09);
}
.option-check input { margin-top: 0.2rem; accent-color: #ffd166; }

.option-btn {
    text-align: left;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    color: inherit;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.option-btn:hover:not(.disabled) { border-color: #2dd4bf; background: rgba(45, 212, 191, 0.07); }
.option-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    text-decoration: line-through;
}

.elim-feedback {
    font-size: 0.84rem;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.45rem;
    line-height: 1.4;
}
.elim-feedback.good { background: rgba(45, 212, 191, 0.08); border: 1px solid rgba(45, 212, 191, 0.3); }
.elim-feedback.bad { background: rgba(255, 107, 107, 0.08); border: 1px solid rgba(255, 107, 107, 0.35); }

.arena-action {
    display: inline-block;
    background: var(--arena-color, #2dd4bf);
    color: #0f172a;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1.4rem;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 0.9rem;
    text-decoration: none;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.arena-action:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.arena-action:disabled { opacity: 0.4; cursor: not-allowed; }
.arena-action.ghost {
    background: transparent;
    color: var(--arena-color, #2dd4bf);
    border: 1.5px solid var(--arena-color, #2dd4bf);
}

/* ── Telas de fim ── */
.arena-end {
    max-width: 560px;
    margin: 2rem auto;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem 1.4rem;
}

.arena-end h2 { font-size: 1.8rem; margin: 0 0 0.8rem; }
.arena-end.victory { border-color: rgba(45, 212, 191, 0.4); }
.arena-end.gameover { border-color: rgba(255, 107, 107, 0.4); }
.end-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.share-box {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

/* ── Conquistas ── */
.arena-achievements { max-width: 860px; margin: 0 auto; }

.ach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.7rem;
}

.ach-section { margin: 1.4rem 0 0.7rem; }

.ach-item {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem;
}

.ach-item.unlocked { border-color: rgba(255, 209, 102, 0.45); background: rgba(255, 209, 102, 0.06); }
.ach-item.locked { opacity: 0.45; filter: grayscale(0.9); }
.ach-icon { font-size: 1.6rem; }
.ach-item strong { display: block; font-size: 0.9rem; }
.ach-item small { font-size: 0.76rem; opacity: 0.75; line-height: 1.35; display: block; margin-top: 0.15rem; }

/* ── Toast de conquista ── */
.arena-toast {
    position: fixed;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a2e;
    border: 1.5px solid #ffd166;
    color: #ffd166;
    border-radius: 12px;
    padding: 0.7rem 1.2rem;
    font-weight: 700;
    font-size: 0.9rem;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.arena-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Mobile ── */
@media (max-width: 600px) {
    .battle-field { padding: 0.7rem 0.25rem 1rem; }
    .sprite, .sprite-fallback { width: 84px; height: 84px; font-size: 3rem; }
    canvas.sprite { height: 168px; width: auto; } /* herói 2x também no mobile */
    .fighter { min-width: 100px; }
    .hp-bar { max-width: 120px; }
    .enemy-attacking { transform: translateX(-30px); }
    .battle-question { padding: 0.9rem 0.75rem; }
    .question-text { font-size: 0.92rem; }
    .option-check, .option-btn { font-size: 0.86rem; padding: 0.65rem 0.7rem; }
    .arena-end { margin: 1rem auto; padding: 1.4rem 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Etapa 3 — layout da batalha
   ═══════════════════════════════════════════════════════════════════════ */

/* HP bar agora fica ABAIXO do nome (convenção de RPG). Só um respiro. */
.fighter .hp-bar { margin-top: 0.35rem; }

/* Cabeçalho da pergunta: texto + toggle de layout lado a lado */
.q-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.q-head .question-text { margin: 0; flex: 1 1 auto; }

.opt-layout-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    overflow: hidden;
}
.olt-btn {
    background: transparent;
    color: rgba(234, 241, 255, 0.55);
    border: none;
    padding: 0.32rem 0.6rem;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.olt-btn + .olt-btn { border-left: 1px solid rgba(255, 255, 255, 0.14); }
.olt-btn:hover { color: var(--arena-color, #2dd4bf); }
.olt-btn.active { background: var(--arena-color, #2dd4bf); color: #0f172a; }

/* Alternativas em blocos: 2 por linha (A B / C D). Vale para os três golpes,
   porque todos usam .option-list. */
.battle-question.opt-grid .option-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    align-items: stretch;
}
.battle-question.opt-grid .option-btn,
.battle-question.opt-grid .option-check { height: 100%; }

/* ── Split screen no desktop: [ batalha | pergunta ] ─────────────────── */
@media (min-width: 900px) {
    .battle-screen {
        max-width: 1080px;
        display: grid;
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
        grid-template-areas:
            "top   top"
            "field question";
        column-gap: 1.5rem;
        row-gap: 1rem;
        align-items: start;
    }
    .battle-top { grid-area: top; margin-bottom: 0; }
    /* a batalha fica fixa enquanto a pergunta (mais alta) rola: a luta nunca
       some de vista, que era o problema do layout empilhado */
    .battle-field {
        grid-area: field;
        margin-bottom: 0;
        position: sticky;
        top: 5rem;
    }
    .battle-question { grid-area: question; }
}

/* Spritesheets 4×4: canvas quadrado e encaixe estável em desktop/mobile.
   Não aplicar image-rendering:pixelated aos sprites ilustrados. */
canvas.sprite.sprite-sheet {
    width: 175px;
    height: 175px;
    max-width: 100%;
    object-fit: contain;
    image-rendering: auto;
    flex-shrink: 0;
}

/* The enemy has one visual surface. No legacy img/emoji can race the canvas.
   Padding is inside the packed atlas; never enlarge with a CSS transform. */
.enemy-visual { position: relative; width: min(190px, 100%); aspect-ratio: 1; height: auto; flex: 0 0 auto; }
.enemy-visual canvas.sprite.sprite-sheet { display: block; width: 100%; height: 100%; }
.is-boss .enemy-visual { width: min(210px, 100%); }
.sprite-status { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 0.7rem; color: #9caec4; }
.sprite-status[hidden] { display: none; }
.battle-question.is-animating { cursor: wait; }
.battle-question.is-animating .option-list, .battle-question.is-animating .arena-action { pointer-events: none; }
#enemyWrap { min-width: 0; flex: 1 1 0; }
#heroWrap { min-width: 0; flex: 1 1 0; }
.fighter-name { overflow-wrap: anywhere; max-width: 210px; }
@media (max-width: 600px) {
    .enemy-visual { width: min(38vw, 152px, 100%); }
    .is-boss .enemy-visual { width: min(40vw, 160px, 100%); }
    .battle-field { gap: 0.15rem; }
    .vs { font-size: 0.9rem; }
    .enemy-attacking { transform: translateX(-14px); }
}
@media (max-width: 600px) {
    canvas.sprite.sprite-sheet {
        width: 132px;
        height: 132px;
    }
}

