:root {
    --bg-dark: #0a0a1a;
    --bg-card: rgba(20, 20, 45, 0.85);
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --gold: #fbbf24;
    --danger: #ef4444;
    --success: #22c55e;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --board-light: #d4c4a8;
    --board-dark: #6b5344;
    --board-highlight: rgba(124, 58, 237, 0.5);
    --board-selected: rgba(251, 191, 36, 0.6);
    --board-target: rgba(34, 197, 94, 0.4);
    --board-lava: rgba(239, 68, 68, 0.5);
    --tex-wood-light: url('../textura%20branca%20madeira.png');
    --tex-wood-dark: url('../textura%20preta%20madeira.png');
    --sprite-piece-white: url('../pieces/white.png');
    --sprite-piece-black: url('../pieces/black.png');
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

.stars {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1px 1px at 20% 30%, white, transparent),
        radial-gradient(1px 1px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(1.5px 1.5px at 40% 80%, rgba(167,139,250,0.8), transparent),
        radial-gradient(ellipse at 50% 0%, rgba(124,58,237,0.15), transparent 70%),
        linear-gradient(180deg, #0a0a1a 0%, #1a1033 100%);
    z-index: -1;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(124, 58, 237, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    color: var(--gold);
}

.logo h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--gold), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-tutorial-btn {
    font-size: 0.9rem;
}

.hidden { display: none !important; }

.screen {
    display: none;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.screen.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero p { color: var(--text-muted); font-size: 1.1rem; }

.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.card-highlight {
    border-color: var(--gold);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.1);
}

.card-pvp {
    border-color: var(--accent-light);
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.15);
}

.match-panel { max-width: 440px; margin: 0 auto; }

.match-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-align: center;
}

.match-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.match-mode-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.match-mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.match-tab {
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(124, 58, 237, 0.35);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s;
}

.match-tab.active {
    background: rgba(124, 58, 237, 0.35);
    border-color: var(--accent-light);
    color: var(--text);
}

.match-search-ui {
    text-align: center;
    padding: 1.5rem 0;
}

.match-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 3px solid rgba(124, 58, 237, 0.25);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: matchSpin 0.9s linear infinite;
}

@keyframes matchSpin {
    to { transform: rotate(360deg); }
}

.match-queue-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
}

.btn-lg {
    width: 100%;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-row .btn-primary { flex: 1; min-width: 120px; }

.card-tutorial {
    border-color: rgba(34, 197, 94, 0.4);
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.1);
}

.tutorial-panel {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

.tutorial-panel > h2 {
    font-family: 'Cinzel', serif;
    text-align: center;
    margin-bottom: 0.5rem;
}

.tutorial-intro {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.tutorial-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tutorial-tab {
    padding: 0.65rem 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(124, 58, 237, 0.35);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tutorial-tab.active {
    background: rgba(124, 58, 237, 0.35);
    border-color: var(--accent-light);
    color: var(--text);
}

.tutorial-content {
    display: none;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tutorial-content.active {
    display: flex;
}

.tutorial-section,
.tutorial-mode-card,
.tutorial-ability-card {
    background: var(--bg-card);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
}

.tutorial-section h3,
.tutorial-mode-card h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
    color: var(--accent-light);
}

.tutorial-section p,
.tutorial-mode-card p {
    color: var(--text-muted);
    line-height: 1.6;
}

.tutorial-steps {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
    color: var(--text-muted);
    line-height: 1.8;
}

.tutorial-steps li {
    margin-bottom: 0.35rem;
}

.tutorial-tip {
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.75rem;
}

.tutorial-note {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 0.25rem;
}

.points-table {
    list-style: none;
    margin-top: 0.75rem;
}

.points-table li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(124, 58, 237, 0.15);
    color: var(--text-muted);
}

.points-table li:last-child {
    border-bottom: none;
}

.points-table strong {
    color: var(--gold);
}

.tutorial-ability-card ul,
.tutorial-strategy ul {
    list-style: none;
    padding: 0;
}

.tutorial-ability-card li,
.tutorial-strategy li {
    position: relative;
    padding-left: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.tutorial-ability-card li::before,
.tutorial-strategy li::before {
    content: '◆';
    position: absolute;
    left: 0;
    color: var(--accent-light);
    font-size: 0.55rem;
    top: 0.35rem;
}

.tutorial-ability-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.dot-demo {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin: 0 2px;
}

.valid-move-demo {
    background: rgba(34, 197, 94, 0.7);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.valid-capture-demo {
    background: rgba(239, 68, 68, 0.7);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.tutorial-strategy {
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .tutorial-tabs {
        grid-template-columns: 1fr;
    }
}

.card h3 {
    font-family: 'Cinzel', serif;
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.btn {
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5b21b6);
    color: white;
}

.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
    background: rgba(124, 58, 237, 0.3);
    color: var(--accent-light);
    border: 1px solid var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.3); }

.btn-ability {
    width: 100%;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid var(--danger);
    margin-top: 0.5rem;
}

.btn-ability:not(:disabled):hover {
    background: rgba(239, 68, 68, 0.4);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.auth-panel, .lobby-panel {
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form input, .lobby-panel input, .join-row input {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}

.auth-form input:focus, .lobby-panel input:focus {
    outline: none;
    border-color: var(--accent);
}

.back-btn { margin-top: 1.5rem; width: 100%; }

.lobby-actions { margin-bottom: 1.5rem; }

.form-group { margin-bottom: 0.75rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    cursor: pointer;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
}

.btn-row .btn { flex: 1; }

.join-section {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.join-section h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.join-row {
    display: flex;
    gap: 0.5rem;
}

.join-row input { flex: 1; }

.waiting-list {
    margin-bottom: 1rem;
}

.wait-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.wait-item small { color: var(--text-muted); }

.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    align-items: start;
}

.sidebar {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.game-info p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin: 1rem 0;
}

.score-box {
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.white-score { background: rgba(255,255,255,0.1); }
.black-score { background: rgba(0,0,0,0.4); }

.score-box strong {
    display: block;
    font-size: 1.5rem;
    margin-top: 0.25rem;
    color: var(--gold);
}

.abilities-panel h3 {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: var(--accent-light);
}

.ability-card {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.ability-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.85rem;
}

.ability-cost {
    color: var(--gold);
    font-size: 0.8rem;
}

.ability-card p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.4rem 0;
    line-height: 1.4;
}

.ability-card.unlocked {
    border-color: rgba(124, 58, 237, 0.4);
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding-bottom: 4.5rem;
    overflow: visible;
}

.board-wrapper {
    position: relative;
    width: min(580px, 92vw);
}

.board-wrapper:not(.campaign-arena) {
    aspect-ratio: 1;
}

.arena-frame {
    position: relative;
    width: 100%;
    line-height: 0;
}

.board-wrapper.campaign-arena {
    width: 100%;
    max-width: min(1402px, 96vw);
    overflow: visible;
}

.board-wrapper.campaign-arena .arena-frame {
    perspective: none;
    overflow: visible;
    width: 100%;
    isolation: isolate;
}

.board-wrapper.campaign-arena .board-playfield {
    position: absolute;
    inset: auto;
    left: 23.82%;
    top: 29.14%;
    width: 52.14%;
    height: 40.91%;
    aspect-ratio: unset;
    overflow: visible;
    box-sizing: border-box;
    z-index: 10;
    pointer-events: auto;
}

.board-wrapper.campaign-arena .chess-board {
    place-items: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.board-wrapper.campaign-arena .chess-board,
.board-wrapper.campaign-arena .fx-layer {
    overflow: visible;
    pointer-events: auto;
}

/* Peças centralizadas nos quadrados da arena */
.board-wrapper.campaign-arena .square {
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.board-wrapper.campaign-arena .chess-piece {
    width: 88%;
    height: 88%;
    max-width: none;
    max-height: none;
    margin: 0;
    position: relative;
    z-index: 10;
    visibility: visible;
    opacity: 1;
    transform: scale(var(--piece-scale, 1));
    transform-origin: center bottom;
}

.board-wrapper.campaign-arena .square[data-row="0"] { --piece-scale: 0.90; }
.board-wrapper.campaign-arena .square[data-row="1"] { --piece-scale: 0.93; }
.board-wrapper.campaign-arena .square[data-row="2"] { --piece-scale: 0.96; }
.board-wrapper.campaign-arena .square[data-row="3"] { --piece-scale: 0.98; }
.board-wrapper.campaign-arena .square[data-row="4"] { --piece-scale: 1.00; }
.board-wrapper.campaign-arena .square[data-row="5"] { --piece-scale: 1.02; }
.board-wrapper.campaign-arena .square[data-row="6"] { --piece-scale: 1.05; }
.board-wrapper.campaign-arena .square[data-row="7"] { --piece-scale: 1.08; }

.board-wrapper.campaign-arena .square:hover:not(.square-lava):not(.selected) .chess-piece {
    transform: scale(calc(var(--piece-scale, 1) * 1.06));
}

.board-wrapper.campaign-arena .square.selected .chess-piece {
    transform: scale(calc(var(--piece-scale, 1) * 1.1));
}

/* Campanha com arena — peças PNG individuais (white-peao.png, black-peao.png, etc.) */
.board-wrapper.campaign-arena .chess-piece.piece-individual {
    width: 100%;
    height: 100%;
    background: none !important;
    transform-origin: center bottom;
    filter:
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5))
        drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
}

.board-wrapper.campaign-arena .chess-piece.piece-individual .piece-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center bottom;
    pointer-events: none;
    user-select: none;
}

.arena-scene {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
    user-select: none;
    border-radius: 6px;
    position: relative;
    z-index: 1;
}

.board-playfield {
    position: absolute;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Arena medieval — Piso 1 (posição via JS a partir da imagem 1402×1122) */

.board-wrapper.campaign-arena .chess-board {
    position: absolute;
    inset: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
}

.board-wrapper.campaign-arena .fx-layer {
    position: absolute;
    inset: 0;
    border-radius: 0;
    overflow: visible;
}

.board-wrapper.campaign-arena .chess-piece {
    z-index: 3;
}

.board-wrapper.campaign-arena .square.light,
.board-wrapper.campaign-arena .square.dark {
    background: transparent !important;
    box-shadow: none;
}

.board-wrapper.campaign-arena .square.valid-move::after,
.board-wrapper.campaign-arena .square.valid-capture::after {
    z-index: 5;
}

.board-wrapper:not(.campaign-arena) .arena-frame {
    position: absolute;
    inset: 0;
    height: 100%;
}

.board-wrapper:not(.campaign-arena) .arena-scene {
    display: none !important;
}

.chess-board {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 3px solid rgba(124, 58, 237, 0.55);
    border-radius: 6px;
    box-shadow:
        0 0 40px rgba(124, 58, 237, 0.25),
        inset 0 0 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background: #4a3d32;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.15s, box-shadow 0.15s;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.square.light {
    background-color: #d4c4a8;
    background-image: var(--tex-wood-light);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.square.dark {
    background-color: #5c4638;
    background-image: var(--tex-wood-dark);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.28);
}

.chess-piece {
    width: 82%;
    height: 82%;
    max-width: 100%;
    max-height: 100%;
    background-size: 300% 200%;
    background-repeat: no-repeat;
    display: block;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1), filter 0.2s ease;
    transform-origin: center center;
    position: relative;
    z-index: 2;
    margin: auto;
}

.piece-white {
    background-image: var(--sprite-piece-white);
    filter:
        drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55))
        drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.piece-black {
    background-image: var(--sprite-piece-black);
    filter:
        drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7))
        drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.piece-type-P { background-position: 0% 0%; }
.piece-type-R { background-position: 50% 0%; }
.piece-type-Q { background-position: 100% 0%; }
.piece-type-N { background-position: 0% 100%; }
.piece-type-B { background-position: 50% 100%; }
.piece-type-K { background-position: 100% 100%; }

/* Peças PNG individuais (white-peao.png, black-peao.png, etc.) */
.chess-piece.piece-individual {
    width: 95%;
    height: 95%;
    background: none !important;
    filter:
        drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55))
        drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.chess-piece.piece-individual .piece-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center center;
    pointer-events: none;
    user-select: none;
}

.square.selected .chess-piece {
    transform: scale(1.12);
    z-index: 5;
}

.square:hover:not(.square-lava):not(.selected) .chess-piece {
    transform: scale(1.06);
}

.square.selected {
    box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.75);
    background: var(--board-selected) !important;
}
.square.valid-move::after,
.square.valid-capture::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 3;
}

.square.valid-move::after {
    width: 28%;
    height: 28%;
    background: rgba(34, 197, 94, 0.85);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.square.valid-capture::after {
    width: 78%;
    height: 78%;
    border: 3px solid rgba(239, 68, 68, 0.85);
    background: rgba(239, 68, 68, 0.15);
    box-shadow: inset 0 0 8px rgba(239, 68, 68, 0.35);
}

.square.row-highlight,
.square.col-highlight {
    outline: 2px dashed var(--danger);
    outline-offset: -2px;
    background: rgba(239, 68, 68, 0.15) !important;
}

.square.square-lava {
    background: #1a0800 !important;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 16px rgba(255, 80, 0, 0.45);
}

.square.square-lava::before,
.square.square-lava::after {
    display: none;
}

.lava-video,
.fx-lava-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 1;
}

.fx-lava-video {
    z-index: 3;
    animation: lavaVideoReveal 1.1s ease-out forwards;
}

@keyframes lavaVideoReveal {
    0%   { opacity: 0; transform: scale(1.15); }
    25%  { opacity: 1; transform: scale(1); }
    100% { opacity: 1; transform: scale(1); }
}

.square.row-target {
    outline: 2px dashed var(--danger);
    outline-offset: -2px;
}

.square .coord {
    position: absolute;
    font-size: 0.55rem;
    color: rgba(0,0,0,0.4);
    bottom: 2px;
    right: 3px;
    font-family: monospace;
}

.ability-hint {
    margin-top: 1rem;
    padding: 0.75rem 1.25rem;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 8px;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.toast.error { border-color: var(--danger); color: #fca5a5; }

@keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.card-story {
    border-color: rgba(251, 191, 36, 0.5);
    background: linear-gradient(135deg, rgba(20,20,45,0.9), rgba(40,30,10,0.4));
}

.card-story h3 { color: var(--gold); }

/* ── Campanha / Torre ── */
.story-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1rem;
}

.season-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(251, 191, 36, 0.2);
    border: 1px solid var(--gold);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.story-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.75rem;
}

.achievement-badge {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(251,191,36,0.2), rgba(124,58,237,0.2));
    border: 1px solid var(--gold);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--gold);
    white-space: nowrap;
}

.campaign-map {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 1rem 0 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.map-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: -1rem 0 1.5rem;
}

.map-climb {
    display: flex;
    justify-content: center;
    padding: 0.25rem 0;
    color: var(--accent-light);
    opacity: 0.6;
}

.map-climb-arrow {
    font-size: 1.25rem;
    animation: mapClimbPulse 1.5s ease-in-out infinite;
}

@keyframes mapClimbPulse {
    0%, 100% { opacity: 0.4; transform: translateY(2px); }
    50% { opacity: 1; transform: translateY(-4px); }
}

.map-floor {
    width: 100%;
    max-width: 720px;
    background: var(--bg-card);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 16px;
    padding: 1rem 1.25rem 1.25rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.map-floor.current {
    border-color: var(--gold);
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.15);
}

.map-floor.completed {
    border-color: rgba(34, 197, 94, 0.35);
    opacity: 0.85;
}

.map-floor.locked {
    opacity: 0.45;
    filter: grayscale(0.4);
}

.map-floor-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.map-floor-num {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--accent-light);
    font-size: 0.95rem;
}

.map-floor-here {
    font-size: 0.75rem;
    color: var(--gold);
    background: rgba(251, 191, 36, 0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.map-path {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}

.map-path-line {
    align-self: center;
    width: 24px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0.5;
    flex-shrink: 0;
}

.map-path-line-boss {
    width: 32px;
    background: linear-gradient(90deg, var(--accent-light), var(--gold));
    opacity: 0.7;
}

.map-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 88px;
    max-width: 120px;
    padding: 0.65rem 0.5rem;
    border-radius: 12px;
    border: 2px solid rgba(124, 58, 237, 0.35);
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

.map-node.lackey.available:hover,
.map-node.boss.available:hover {
    transform: translateY(-3px);
    border-color: var(--accent-light);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.map-node.boss.available {
    border-color: rgba(251, 191, 36, 0.5);
    min-width: 110px;
}

.map-node.boss.available:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.25);
}

.map-node.defeated {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.08);
    cursor: default;
}

.map-node.locked,
.map-node:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.map-node-icon {
    font-size: 1.75rem;
    line-height: 1;
}

.map-node-portrait {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(251, 191, 36, 0.5);
}

.map-node-name {
    font-size: 0.7rem;
    text-align: center;
    line-height: 1.2;
    color: var(--text-muted);
}

.map-node-rank {
    font-size: 0.65rem;
    color: var(--gold);
}

.map-node-done {
    position: absolute;
    top: 4px;
    right: 6px;
    color: var(--success);
    font-size: 0.85rem;
}

.map-node-crown {
    font-size: 0.9rem;
}

.campaign-tower {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 700px;
    margin: 0 auto 2rem;
}

.tower-node {
    position: relative;
    display: flex;
    justify-content: center;
}

.tower-connector {
    position: absolute;
    top: -20px;
    width: 3px;
    height: 20px;
    background: linear-gradient(180deg, rgba(124,58,237,0.6), rgba(251,191,36,0.4));
}

.tower-node:first-child .tower-connector { display: none; }

.tower-card {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 12px;
    transition: all 0.2s;
}

.tower-node.unlocked .tower-card {
    border-color: rgba(124, 58, 237, 0.5);
    cursor: pointer;
}

.tower-node.unlocked .tower-card:hover {
    border-color: var(--accent-light);
    transform: translateX(4px);
}

.tower-node.completed .tower-card {
    border-color: rgba(34, 197, 94, 0.4);
    opacity: 0.85;
}

.tower-node.locked .tower-card {
    opacity: 0.45;
    filter: grayscale(0.6);
}

.tower-node.boss .tower-card {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.15);
}

.tower-level {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-light);
    min-width: 2rem;
    text-align: center;
}

.tower-icon { font-size: 2rem; }

.leader-portrait {
    object-fit: cover;
    object-position: center top;
    border-radius: 10px;
    border: 2px solid rgba(124, 58, 237, 0.35);
    background: rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.tower-portrait {
    width: 72px;
    height: 72px;
}

.tower-node.boss .tower-portrait {
    border-color: rgba(251, 191, 36, 0.55);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.25);
}

.narrative-portrait {
    width: 100%;
    max-height: 220px;
    aspect-ratio: 16 / 10;
    margin-bottom: 1rem;
    transition: opacity 0.25s ease, filter 0.25s ease;
}

.narrative-portrait.dimmed {
    opacity: 0.55;
    filter: grayscale(0.35);
}

.story-dialogue-portrait {
    width: 56px;
    height: 56px;
    border-radius: 8px;
}

.story-battle-portrait {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    vertical-align: middle;
    margin-right: 0.35rem;
}

.story-opponent {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.result-leader-portrait {
    width: 96px;
    height: 96px;
    border-radius: 12px;
    margin: 0 auto 0.5rem;
    display: block;
    border-color: rgba(251, 191, 36, 0.45);
}

.tower-info strong { display: block; font-size: 0.95rem; }
.tower-info small { color: var(--text-muted); font-size: 0.75rem; }
.tower-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.tower-preview {
    font-style: italic;
    color: var(--accent-light) !important;
    opacity: 0.9;
}

.tower-done { color: var(--success); font-size: 0.85rem; }
.tower-lock { font-size: 1.25rem; }

.diff-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.4rem;
    background: rgba(239,68,68,0.2);
    border-radius: 4px;
    font-size: 0.7rem;
    color: #fca5a5;
}

/* ── Modais ── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 16px;
    padding: 2rem;
    max-width: 480px;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.modal-narrative { text-align: center; max-width: 520px; }

.modal-arena-intro-wrap {
    padding: 0;
}

.modal-arena-intro {
    position: relative;
    padding: 0;
    max-width: min(1024px, 96vw);
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.arena-intro-video {
    width: 100%;
    display: block;
    vertical-align: top;
}

.btn-skip-intro {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    z-index: 2;
}

.modal-promotion {
    text-align: center;
    max-width: 360px;
}

.modal-promotion h3 {
    font-family: 'Cinzel', serif;
    margin-bottom: 0.5rem;
}

.modal-promotion p {
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.promotion-choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.promotion-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    min-height: 88px;
    border-radius: 12px;
    border: 2px solid rgba(124, 58, 237, 0.4);
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.promotion-piece {
    width: 52px;
    height: 52px;
    margin: 0 auto;
}

.fx-piece-ghost .chess-piece {
    width: 100%;
    height: 100%;
}

.promotion-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.promotion-choice:hover {
    transform: scale(1.05);
    border-color: var(--accent-light);
    background: rgba(124, 58, 237, 0.25);
}

.promotion-choice:hover .promotion-label {
    color: var(--text);
}

.modal-narrative h3 {
    font-family: 'Cinzel', serif;
    margin-bottom: 1rem;
}

.narrative-dialogue {
    text-align: left;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 12px;
    padding: 1.25rem;
    min-height: 120px;
    margin-bottom: 0.75rem;
}

.narrative-speaker {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.narrative-speaker.is-narrator { color: var(--gold); }
.narrative-speaker.is-leader { color: var(--accent-light); }

.narrative-text {
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text);
}

.narrative-text.is-narrator {
    font-style: italic;
    color: var(--text-muted);
}

.narrative-text.is-leader {
    font-style: italic;
    color: var(--accent-light);
}

.narrative-progress {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

blockquote {
    font-style: italic;
    color: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    text-align: left;
}

/* Falas durante a batalha */
.story-dialogue {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: min(540px, 96%);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: rgba(10, 10, 26, 0.92);
    border: 1px solid rgba(124, 58, 237, 0.45);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    z-index: 50;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.story-dialogue.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.story-dialogue-icon {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
}

.story-dialogue-body {
    flex: 1;
    min-width: 0;
}

.story-dialogue-body strong {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--accent-light);
    margin-bottom: 0.25rem;
}

.story-dialogue-body p {
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--text);
    font-style: italic;
}

.result-speaker {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    color: var(--accent-light);
    margin-bottom: 0.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.modal-actions .btn { flex: 1; }

.modal-result { text-align: center; }
.result-icon { font-size: 3rem; margin-bottom: 0.5rem; }

.modal-achievement {
    text-align: center;
    position: relative;
    overflow: hidden;
    border-color: var(--gold);
    box-shadow: 0 0 40px rgba(251, 191, 36, 0.3);
}

.achievement-glow {
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle, rgba(251,191,36,0.15) 0%, transparent 60%);
    animation: achievementPulse 2s ease-in-out infinite;
}

@keyframes achievementPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50%      { transform: scale(1.1); opacity: 1; }
}

.achievement-crown { font-size: 4rem; display: block; margin-bottom: 0.5rem; position: relative; }

.achievement-label {
    font-size: 0.8rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
}

.modal-achievement h2 {
    font-family: 'Cinzel', serif;
    font-size: 1.75rem;
    color: var(--gold);
    margin: 0.5rem 0;
    position: relative;
}

#achievement-season {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    position: relative;
}

@media (max-width: 768px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
    .sidebar { order: 2; }
    .tower-card {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }
    .tower-portrait {
        width: 56px;
        height: 56px;
    }
    .tower-action { grid-column: 1 / -1; text-align: right; }
    .map-path {
        flex-direction: column;
        align-items: stretch;
    }
    .map-path-line {
        width: 2px;
        height: 18px;
        margin: 0 auto;
        background: linear-gradient(180deg, var(--accent), var(--accent-light));
    }
    .map-path-line-boss {
        height: 24px;
        background: linear-gradient(180deg, var(--accent-light), var(--gold));
    }
    .map-node { max-width: none; width: 100%; }
}

