/* Reversi-specific page, lobby, board and overlays. */
#screen-reversi-game, #screen-reversi-game * { box-sizing: border-box; margin: 0; padding: 0; }

#screen-reversi-game {
    background: #1a0e06;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-family: Arial, sans-serif;
    color: #e8d8b8;
    overflow: hidden;
}

#screen-reversi-game.screen:not(.active) {
    display: none;
}

/* ── Lobby ────────────────────────────────────────── */
#screen-reversi-game #lobby-section {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
#screen-reversi-game .lobby-box {
    background: linear-gradient(135deg, #2a1608, #150a04);
    border: 2px solid #6a3a10;
    border-radius: 16px;
    padding: 36px 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-width: 300px;
}
#screen-reversi-game .lobby-title {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 5px;
    color: #e8d0a0;
}
#screen-reversi-game .lobby-code {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 10px;
    color: #f0c040;
    border: 2px solid rgba(240,192,64,0.3);
    padding: 8px 20px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}
#screen-reversi-game .lobby-hint { font-size: 0.72rem; color: #8a6030; letter-spacing: 2px; }
#screen-reversi-game .lobby-status { font-size: 0.85rem; color: #b08040; }
#screen-reversi-game .btn-lobby {
    padding: 10px 24px;
    background: linear-gradient(135deg, #8a5a20, #5a3a10);
    border: none; border-radius: 8px;
    color: #f0d898; font-size: 0.9rem; font-weight: bold;
    cursor: pointer; transition: filter 0.15s;
}
#screen-reversi-game .btn-lobby:hover { filter: brightness(1.2); }

/* ── Juego ────────────────────────────────────────── */
#screen-reversi-game #game-section {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Marcador — placa de madera oscura con oro antiguo */
#screen-reversi-game #score-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 80vmin;
    padding: 12px 24px;
    background: linear-gradient(to bottom, #3a2318, #1a0f0a);
    border: 2px solid #a67c00;
    border-radius: 8px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.6), inset 0 0 15px rgba(0,0,0,0.8);
    color: #e8c361;
    font-family: 'Georgia', serif;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
}
/* Huecos tallados para los contadores */
#screen-reversi-game .score-item {
    background: rgba(0,0,0,0.4);
    padding: 5px 15px;
    border-radius: 5px;
    border-top:    1px solid rgba(0,0,0,0.8);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    gap: 10px;
}
#screen-reversi-game .score-disc {
    width: 22px; height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
}
#screen-reversi-game .score-disc.black {
    background: #1c1c1c;
    border: 1px solid #444;
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}
#screen-reversi-game .score-disc.white {
    background: #f0eeea;
    border: 1px solid #bbb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
#screen-reversi-game .score-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: #e8c361;
    min-width: 1.5ch;
    text-align: center;
}
#screen-reversi-game #reversi-status {
    font-size: 0.82rem;
    color: #c8a040;
    letter-spacing: 1px;
    text-align: center;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

/* Tablero — madera de caoba barnizada */
#screen-reversi-game #reversi-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 80vmin;
    height: 80vmin;
    background-color: #8b5a2b;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.15) 0%, rgba(0,0,0,0.5) 100%),
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,0.04) 10px, rgba(0,0,0,0.04) 20px);
    border: 15px solid #4a2f1d;
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 20px 40px rgba(0,0,0,0.6);
    gap: 0;
}

/* Surcos tallados en la madera */
#screen-reversi-game .cell {
    border-top:    1px solid rgba(0,0,0,0.6);
    border-left:   1px solid rgba(0,0,0,0.6);
    border-bottom: 1px solid rgba(255,255,255,0.15);
    border-right:  1px solid rgba(255,255,255,0.15);
    background: transparent;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}
#screen-reversi-game .cell:hover { background: rgba(255,255,255,0.06); }
#screen-reversi-game .cell.valid-move::after {
    content: '';
    width: 22%;
    height: 22%;
    border-radius: 50%;
    background: rgba(0,0,0,0.3);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

/* Fichas — planas */
#screen-reversi-game .piece-container {
    width: 82%;
    height: 82%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#screen-reversi-game .piece-container.pop {
    animation: reversi-pop 0.22s ease-out;
}
#screen-reversi-game .piece-container.pop .piece {
    transition: none;
}
#screen-reversi-game .piece {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform-origin: 50% 50%;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.55);
    will-change: transform;
}
#screen-reversi-game .face {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 50%;
}
#screen-reversi-game .face-black {
    background: #1c1c1c;
    border: 1.5px solid #3a3a3a;
}
#screen-reversi-game .face-white {
    background: #f0eeea;
    border: 1.5px solid #cccccc;
    transform: rotateY(180deg);
}
#screen-reversi-game .piece.is-black { transform: rotateY(0deg); }
#screen-reversi-game .piece.is-white { transform: rotateY(180deg); }
@keyframes reversi-pop {
    0% { transform: scale(0.35); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Panel de jugadores (fijo derecha) ─────────────── */
#screen-reversi-game #reversi-player-panel {
    position: fixed;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

@media (max-width: 600px) {
    #screen-reversi-game { padding-bottom: 62px; }

    #screen-reversi-game #reversi-player-panel {
        top: auto;
        right: 0; left: 0; bottom: 0;
        transform: none;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        padding: 8px 12px;
        background: rgba(40,20,5,0.85);
        backdrop-filter: blur(4px);
        border-top: 1px solid rgba(166,124,0,0.3);
    }

    #screen-reversi-game .ps-slot {
        min-width: 0;
        flex: 1;
        max-width: 180px;
        justify-content: center;
    }
}
#screen-reversi-game .ps-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(40, 20, 5, 0.6);
    border-radius: 8px;
    padding: 8px 12px;
    min-width: 130px;
    border: 1px solid transparent;
    transition: background 0.25s, border-color 0.25s;
}
#screen-reversi-game .ps-slot.turno-activo {
    background: rgba(180, 120, 40, 0.25);
    border-color: rgba(200, 150, 60, 0.5);
}
#screen-reversi-game .ps-color { font-size: 1.2rem; line-height: 1; }
#screen-reversi-game .ps-name  { font-size: 0.82rem; color: #c8a870; white-space: nowrap; }
#screen-reversi-game .turno-activo .ps-name { color: #f0d898; font-weight: 700; }

/* ── Botón volver ───────────────────────────────────── */
#screen-reversi-game .btn-volver {
    position: fixed;
    top: 12px; left: 12px;
    padding: 6px 14px;
    background: rgba(74, 47, 29, 0.7);
    border: 1px solid rgba(166, 124, 0, 0.4);
    color: #c8a050; border-radius: 7px;
    cursor: pointer; font-size: 13px;
    transition: background 0.15s;
}
#screen-reversi-game .btn-volver:hover { background: rgba(74, 47, 29, 1); color: #e8c361; }

#screen-reversi-game #result-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 5, 2, 0.72);
    z-index: 20000;
}
#screen-reversi-game #result-overlay.visible { display: flex; }
#screen-reversi-game .result-panel {
    width: min(420px, calc(100vw - 32px));
    padding: 28px;
    background:
        linear-gradient(145deg, rgba(70,42,22,0.98), rgba(24,13,7,0.98));
    border: 2px solid #a67c00;
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.68), inset 0 0 18px rgba(0,0,0,0.55);
    text-align: center;
    font-family: Georgia, serif;
}
#screen-reversi-game .result-title {
    margin-bottom: 8px;
    color: #f0d898;
    font-size: 2rem;
    font-weight: 900;
}
#screen-reversi-game .result-subtitle {
    margin-bottom: 20px;
    color: #c8a040;
    font-size: 0.95rem;
}
#screen-reversi-game .result-score-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    padding: 14px;
    background: rgba(0,0,0,0.28);
    border-radius: 8px;
    box-shadow: inset 0 3px 8px rgba(0,0,0,0.38);
}
#screen-reversi-game .result-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #e8d8b8;
    font-size: 0.82rem;
}
#screen-reversi-game .result-disc {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}
#screen-reversi-game .result-disc.black { background: #1c1c1c; border: 1px solid #444; }
#screen-reversi-game .result-disc.white { background: #f0eeea; border: 1px solid #bbb; }
#screen-reversi-game .result-score {
    color: #f0d898;
    font-size: 2rem;
    font-weight: 900;
}
#screen-reversi-game .result-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}
#screen-reversi-game .result-btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(240,216,152,0.22);
    cursor: pointer;
    font-weight: 800;
}
#screen-reversi-game .result-btn.primary {
    background: linear-gradient(135deg, #b8892a, #7a4f16);
    color: #160b04;
}
#screen-reversi-game .result-btn.secondary {
    background: rgba(0,0,0,0.24);
    color: #f0d898;
}
#screen-reversi-game .confirm-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 5, 2, 0.72);
    z-index: 21000;
}
#screen-reversi-game .confirm-overlay.visible { display: flex; }
#screen-reversi-game .confirm-panel {
    width: min(360px, calc(100vw - 32px));
    padding: 24px;
    background: linear-gradient(145deg, rgba(70,42,22,0.98), rgba(24,13,7,0.98));
    border: 2px solid #a67c00;
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.68), inset 0 0 18px rgba(0,0,0,0.55);
    text-align: center;
}
#screen-reversi-game .confirm-title {
    color: #f0d898;
    font-size: 1.4rem;
    font-weight: 900;
    margin-bottom: 8px;
}
#screen-reversi-game .confirm-text {
    color: #c8a040;
    font-size: 0.92rem;
    margin-bottom: 18px;
}
#screen-reversi-game .confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}
#screen-reversi-game .rules-list {
    margin: 14px 0 18px;
    padding-left: 20px;
    color: #d8c098;
    text-align: left;
    line-height: 1.55;
    font-size: 0.9rem;
}
#screen-reversi-game .rules-list li + li { margin-top: 7px; }

/* ── Botón menú in-game (sistema SPA) ── */
#screen-reversi-game .btn-back {
    padding: 10px 22px;
    font-size: 0.9rem;
    color: #c8a050;
    border-color: rgba(166, 124, 0, 0.4);
    background: rgba(74, 47, 29, 0.7);
}
#screen-reversi-game .btn-back:hover {
    background: rgba(74, 47, 29, 1);
    color: #e8c361;
}
#screen-reversi-game .game-menu-dropdown {
    min-width: 180px;
    padding: 10px;
    background: rgba(30, 15, 5, 0.97);
    border-color: rgba(166, 124, 0, 0.35);
}
#screen-reversi-game .game-menu-dropdown button {
    padding: 12px 16px;
    font-size: 0.9rem;
    color: #c8a870;
}
