/* GENERAL */
* {
    box-sizing: border-box;
    font-family: "Orbitron", sans-serif;
}

body.phase-game {
    background: url("../img/cp_bg2.jpg") no-repeat center center fixed;
    background-size: cover;
    overflow: hidden;
}

/* CONTENEDOR PRINCIPAL */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* HEADER */
#game-header {
    position: absolute;
    top: 10px;
    width: 100%;
    text-align: center;
    z-index: 10;
}

/* BOTONES IZQUIERDA */
#left-controls {
    position: absolute;
    top: 35%;
    left: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

#left-controls button {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.75);
    color: #00ffe1;
    font-size: 18px;
    cursor: pointer;
    border-radius: 25px;
    border: 2px solid rgba(0, 255, 225, 0.4);
    box-shadow: 0 0 8px rgba(0, 255, 225, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#left-controls button:hover {
    background: rgba(0, 255, 225, 0.2);
    box-shadow: 0 0 12px rgba(0, 255, 225, 0.6);
}

/* Dado visual */
#dice-container {
    display: none; /* oculto en modo normal, activo solo en combate desde overlay */
}
#dice-container img {
    width: 70px;
    height: 70px;
    cursor: pointer;
    transition: transform 0.3s;
}

.dice-stage,
.stage {
    display: flex;
    gap: 50px;
    justify-content: center;
    perspective: 900px;
    perspective-origin: 50% 40%;
}

.dice-stage .die,
.stage .die {
    opacity: 1;
    transition: opacity 0.26s ease;
}

.dice-stage .die.hidden,
.stage .die.hidden {
    opacity: 0;
    pointer-events: none;
}

.die {
    width: 110px;
    height: 110px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-out;
}

.die.rolling {
    animation: dice-roll 0.5s cubic-bezier(.16,.9,.18,1) both;
}

@keyframes dice-roll {
    0% { transform: rotateX(0deg) rotateY(0deg); }
    25% { transform: rotateX(180deg) rotateY(270deg); }
    50% { transform: rotateX(360deg) rotateY(180deg); }
    75% { transform: rotateX(540deg) rotateY(90deg); }
    100% { transform: rotateX(720deg) rotateY(360deg); }
}

.face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.face img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.face.front { transform: translateZ(55px); }
.face.back { transform: rotateY(180deg) translateZ(55px); }
.face.right { transform: rotateY(90deg) translateZ(55px); }
.face.left { transform: rotateY(-90deg) translateZ(55px); }
.face.top { transform: rotateX(90deg) translateZ(55px); }
.face.bottom { transform: rotateX(-90deg) translateZ(55px); }

.dice-stage,
.stage {
    width: min(320px, 100%);
    max-width: 320px;
    margin-inline: auto;
}

.body {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15), 0 1px 6px rgba(0,0,0,0.25);
    background: rgba(0,0,0,0.15);
    pointer-events: none;
}

/* animación simple cuando se lanza el dado (usado por `diceUI.js`) */
.animate {
    animation: dice-spin 0.5s ease-in-out;
}
@keyframes dice-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* OVERLAY UI COMBATE (tipo tests.html) */
body.combat-active #board-wrapper {
    filter: blur(6px);
    transition: filter 0.2s ease;
}

/* Oculta el panel de dados principal mientras está activo el overlay de combate */
body.combat-active #dice-container,
body.pvp-combat-active #dice-container {
    display: none !important;
}

.pvp-combat-modal.combat-modal {
    width: min(960px, 98vw);
}

.pvp-combat-heading {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
    color: #93fbf0;
    text-align: center;
    letter-spacing: 0.04em;
}

.combat-side-caption {
    flex-direction: column;
    gap: 10px;
}

.pvp-player-label {
    font-size: 0.85rem;
    color: #cbd5e1;
    text-align: center;
    max-width: 24vw;
    line-height: 1.2;
}

.combat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    display: none;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.combat-overlay.active {
    display: flex;
}

.combat-modal {
    width: min(920px, 96vw);
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(0, 255, 225, 0.22);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
    padding: 18px 22px;
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    align-items: center;
    gap: 16px;
    color: #e5e7eb;
}

.combat-side {
    display: flex;
    justify-content: center;
    align-items: center;
}

.combat-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.combat-dice-container {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 10px 0;
}

.combat-dice-container img,
.combat-dice-container .dice-stage,
.dice-stage {
    width: 110px;
    height: 110px;
    min-width: 110px;
    min-height: 110px;
}

.die {
    width: 110px !important;
    height: 110px !important;
}

.combat-message {
    color: #e5e7eb;
    text-align: center;
    font-size: 0.95rem;
}

.combat-card-img {
    width: min(220px, 26vw);
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 225, 0.25);
    box-shadow: 0 0 18px rgba(0, 255, 225, 0.12);
    transform: rotate(var(--rot, 0deg));
}


.combat-modifier-badge {
    position: absolute;
    top: -18px;
    left: -18px;

    width: 60px;
    height: 60px;
    border-radius: 50%;

    display: none;
    align-items: center;
    justify-content: center;

    background: #030303;
    border: 5px solid #ff1010;
    color: #ff2525;

    font-size: 1.75rem;
    font-weight: 950;
    line-height: 1;
    letter-spacing: -0.05em;

    z-index: 80;

    box-shadow:
        0 0 0 2px #000,
        0 0 12px rgba(255, 0, 0, 0.8),
        inset 0 0 8px rgba(255, 0, 0, 0.22);

    text-shadow:
        0 0 6px rgba(255, 0, 0, 0.95),
        0 0 12px rgba(255, 0, 0, 0.55);
}

.combat-modifier-badge.active {
    display: flex;
}

.pvp-combat-modifier-badge {
    top: -16px;
    left: -16px;
    z-index: 90;
}

.combat-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.combat-btn {
    background: rgba(0, 255, 225, 0.14);
    border: 1px solid rgba(0, 255, 225, 0.35);
    color: #e5e7eb;
    padding: 10px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.combat-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
/* TABLERO */
#board-wrapper {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 1;

    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

/* El tablero NO se adapta al viewport.
   Su tamaño base siempre es la matriz: 50 * 40 = 2000, 30 * 40 = 1200 */
#board {
    position: absolute;
    left: 0;
    top: 0;

    width: 2000px;
    height: 1200px;
    min-width: 2000px;
    min-height: 1200px;
    max-width: none;
    max-height: none;

    transform-origin: 0 0;
    transition: transform 0.2s ease;
    pointer-events: auto;
    will-change: transform;
}

#board-wrapper.dragging {
    cursor: grabbing;
}

/* Evitar que se seleccione/arrastre la imagen del tablero */
#board img {
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Imagen principal del tablero: tamaño fijo, sin responsive */
#board > img:not(.monster-card) {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: block;

    width: 2000px;
    height: 1200px;
    min-width: 2000px;
    min-height: 1200px;
    max-width: none;
    max-height: none;

    object-fit: fill;
}

#rooms-svg {
    pointer-events: auto;
}

/* PANEL LATERAL DERECHO (ACCORDION) */
#right-panels {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    display: flex;
    z-index: 1000;
}

/* TABS */
#panel-tabs {
    width: 48px;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    border-left: 2px solid #00ffe1;
}

.panel-tab {
    height: 25%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid rgba(0, 255, 225, 0.25);
    font-size: 20px;
    color: #00ffe1;
    transition: all 0.2s ease;
}

.panel-tab i {
    pointer-events: none;
    color: inherit;
}

.panel-tab:hover {
    background: rgba(0, 255, 225, 0.12);
    color: #00ffe1;
}

.panel-tab.active {
    background: rgba(0, 255, 225, 0.2);
    color: #00ffe1;
    box-shadow: inset 0 0 8px rgba(0, 255, 225, 0.3);
}

/* CONTENIDO PANEL */
#panel-content {
    width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(0, 0, 0, 0.9);
    transition: width 0.3s ease;
    border-left: 2px solid #00ffe1;
    color: #e5e7eb;
    max-height: 100vh;
}

#panel-content.open {
    width: 320px;
}

#panel-content::-webkit-scrollbar {
    width: 6px;
}

#panel-content::-webkit-scrollbar-track {
    background: rgba(0, 255, 225, 0.05);
}

#panel-content::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 225, 0.3);
    border-radius: 3px;
}

#panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 225, 0.5);
}

.panel-block {
    padding: 16px 14px 12px 14px;
}

.panel-character-img {
    width: 100%;
    max-width: 100px;
    margin: 0 auto 12px;
    display: block;
    border-radius: 10px;
    border: 2px solid rgba(0, 255, 225, 0.4);
    box-shadow: 0 0 12px rgba(0, 255, 225, 0.2);
    aspect-ratio: 2 / 3;
    object-fit: cover;
}

.panel-list {
    margin: 12px 0 0 0;
    padding-left: 20px;
    color: #e5e7eb;
    font-size: 0.9rem;
    list-style: none;
}

.panel-list li {
    margin: 6px 0;
    word-break: break-word;
}

.panel-list li:before {
    content: "▸ ";
    color: #00ffe1;
    margin-right: 6px;
}

.enemy-block {
    border: 1px solid rgba(0, 255, 225, 0.25);
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0 12px 0;
    background: rgba(0, 255, 225, 0.05);
}

.muted {
    color: rgba(229, 231, 235, 0.7);
    font-size: 0.85rem;
    margin: 6px 0;
    line-height: 1.4;
}

#event-log {
    padding: 12px 14px;
    font-size: 0.85rem;
}

#event-log p {
    margin: 6px 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #e5e7eb;
}

.panel-title {
    color: #00ffe1;
    text-align: center;
    margin: 0 0 16px 0;
    padding: 12px 0 8px 0;
    letter-spacing: 2px;
    text-shadow: 0 0 6px #00ffe1;
    border-bottom: 1px solid rgba(0, 255, 225, 0.2);
    font-size: 0.95rem;
}

#panel-content h2 {
    margin: 0;
}

#panel-content p {
    margin: 6px 0;
    line-height: 1.5;
    font-size: 0.9rem;
}

#panel-content strong {
    color: #00ffe1;
}

/* Asegura que el texto del panel no quede oscuro (fondo negro). */
#panel-content h2,
#panel-content p,
#panel-content li,
#panel-content div {
    color: #e5e7eb;
}

/* CARTAS DE MONSTRUOS */
.monster-card {
    position: absolute;
    width: 140px;
    height: auto;
    aspect-ratio: 2 / 3;
    /* rotate se controla desde JS con una variable CSS */
    transform: translate(-50%, -50%) rotate(calc(var(--rot, 0deg) + var(--face-rot, 0deg))) scale(0.5);
    z-index: 6;
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.8));
    /* Mejorar calidad al hacer zoom */
    image-rendering: crisp-edges;
    -ms-interpolation-mode: nearest-neighbor;
    object-fit: cover;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: block;
}

/* COMMON_ROOMS tapadas: imagen cuadrada 210x210 (common.png) */
.monster-card.monster-card-common {
    width: 210px;
    height: 210px;
    aspect-ratio: auto;
    object-fit: cover;
    transform: translate(-50%, -50%) scale(0.5);
}

/* Azul: celdas alcanzables. Debe ir encima del lila, pero debajo de fichas. */
#highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 12;
    pointer-events: none;
}

.highlight-cell {
    background: rgba(0, 255, 225, 0.08);
    border: 1px solid rgba(0, 255, 225, 0.42);
    box-shadow: inset 0 0 5px rgba(0, 255, 225, 0.10);
    pointer-events: none;
}

.highlight-room {
    background: rgba(168, 85, 247, 0.045);
    border: 1px solid rgba(168, 85, 247, 0.32);
    box-shadow: inset 0 0 5px rgba(168, 85, 247, 0.08);
    pointer-events: none;
}

.player-token.active-turn-token {
    z-index: 30;
}

#highlight-layer div {
    transition: background 0.2s;
}

/* asegurarse de que las imágenes de pasillo queden debajo */
#board > img:not(.monster-card) {
    /* imagen principal del tablero */
    z-index: 5;
    display: block;
    width: 100%;
    height: 100%;
}
/* ficha de jugador en el tablero */
.player-token {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #00ffe1;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    z-index: 15;

    transition:
        left 0.3s ease,
        top 0.3s ease,
        width 0.25s ease,
        height 0.25s ease,
        filter 0.25s ease,
        box-shadow 0.25s ease;

    box-shadow: 0 0 8px rgba(0, 255, 225, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: #000;
    left: 0;
    top: 0;
    overflow: visible;
}

/* ===== BADGE RESULTADO PvE ===== */

#combat-dice-message.combat-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* mismo ancho que el bloque de los 2 botones */
    width: min(340px, 92%);
    min-height: 42px;
    padding: 7px 22px;
    margin: 4px auto 6px;

    border-radius: 999px;
    border: 2px solid rgba(210, 235, 255, 0.55);

    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1;

    position: relative;
    overflow: hidden;

    background:
        linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%),
        linear-gradient(180deg, rgba(19, 28, 42, 0.98), rgba(4, 8, 16, 0.98));

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.16),
        inset 0 -7px 14px rgba(0,0,0,0.42),
        0 0 14px rgba(0,0,0,0.45);

    text-shadow:
        0 0 7px currentColor,
        0 0 16px currentColor;
}

/* Brillo superior */
#combat-dice-message.combat-result-badge::before {
    content: "";
    position: absolute;
    inset: 2px 18px auto 18px;
    height: 38%;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(255,255,255,0.16),
        rgba(255,255,255,0.03),
        transparent
    );
    pointer-events: none;
}

/* Línea inferior sutil */
#combat-dice-message.combat-result-badge::after {
    content: "";
    position: absolute;
    left: 34px;
    right: 34px;
    bottom: 5px;
    height: 1px;
    background: currentColor;
    opacity: 0.42;
    box-shadow: 0 0 10px currentColor;
    pointer-events: none;
}

/* Victoria azul */
#combat-dice-message.combat-result-badge.victory {
    color: #8ee8ff;
    border-color: rgba(106, 210, 255, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(82, 210, 255, 0.26), transparent 58%),
        linear-gradient(90deg, rgba(4, 14, 30, 0.96), rgba(12, 73, 120, 0.96), rgba(4, 14, 30, 0.96)),
        linear-gradient(180deg, rgba(20, 64, 110, 0.98), rgba(3, 14, 32, 0.98));
    box-shadow:
        inset 0 1px 0 rgba(210, 250, 255, 0.22),
        inset 0 -7px 16px rgba(0,0,0,0.5),
        0 0 10px rgba(68, 200, 255, 0.65),
        0 0 22px rgba(26, 134, 255, 0.38),
        0 0 38px rgba(0, 80, 255, 0.18);
}

/* Derrota roja */
#combat-dice-message.combat-result-badge.defeat {
    color: #ff7373;
    border-color: rgba(255, 93, 93, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 75, 75, 0.25), transparent 58%),
        linear-gradient(90deg, rgba(30, 4, 8, 0.96), rgba(124, 18, 22, 0.96), rgba(30, 4, 8, 0.96)),
        linear-gradient(180deg, rgba(112, 20, 24, 0.98), rgba(32, 3, 7, 0.98));
    box-shadow:
        inset 0 1px 0 rgba(255, 215, 215, 0.16),
        inset 0 -7px 16px rgba(0,0,0,0.5),
        0 0 10px rgba(255, 76, 76, 0.65),
        0 0 22px rgba(255, 32, 45, 0.36),
        0 0 38px rgba(160, 0, 0, 0.18);
}

/* Penalización: cilindro amarillo */
#combat-dice-message.combat-result-badge.penalty {
    color: #fff8d8;
    border-color: rgba(255, 210, 74, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 211, 77, 0.26), transparent 58%),
        linear-gradient(90deg, rgba(42, 26, 3, 0.98), rgba(145, 101, 18, 0.98), rgba(42, 26, 3, 0.98)),
        linear-gradient(180deg, rgba(118, 78, 12, 0.98), rgba(35, 20, 3, 0.98));
    box-shadow:
        inset 0 1px 0 rgba(255, 245, 190, 0.22),
        inset 0 -8px 16px rgba(0, 0, 0, 0.50),
        0 0 10px rgba(255, 210, 74, 0.62),
        0 0 22px rgba(255, 170, 30, 0.34),
        0 0 36px rgba(180, 115, 0, 0.16);
}

/* Resultado final de penalización */
/* Herida leve: naranja/ámbar */
#combat-dice-message.combat-result-badge.wound.leve {
    border-color: rgba(255, 165, 58, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 170, 60, 0.24), transparent 58%),
        linear-gradient(90deg, rgba(42, 18, 3, 0.98), rgba(142, 72, 14, 0.98), rgba(42, 18, 3, 0.98)),
        linear-gradient(180deg, rgba(118, 58, 10, 0.98), rgba(30, 12, 3, 0.98));
    box-shadow:
        inset 0 1px 0 rgba(255, 225, 170, 0.18),
        inset 0 -8px 16px rgba(0, 0, 0, 0.50),
        0 0 10px rgba(255, 160, 54, 0.62),
        0 0 22px rgba(255, 115, 24, 0.32),
        0 0 36px rgba(180, 72, 0, 0.16);
}

/* Opcional: grave algo más rojo */
#combat-dice-message.combat-result-badge.wound.grave {
    border-color: rgba(255, 96, 96, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 70, 70, 0.25), transparent 58%),
        linear-gradient(90deg, rgba(35, 4, 8, 0.98), rgba(125, 22, 28, 0.98), rgba(35, 4, 8, 0.98)),
        linear-gradient(180deg, rgba(112, 20, 26, 0.98), rgba(34, 3, 8, 0.98));
}

/* Opcional: aturdido algo morado */
#combat-dice-message.combat-result-badge.wound.aturdido {
    border-color: rgba(190, 115, 255, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(180, 85, 255, 0.25), transparent 58%),
        linear-gradient(90deg, rgba(22, 4, 35, 0.98), rgba(82, 28, 120, 0.98), rgba(22, 4, 35, 0.98)),
        linear-gradient(180deg, rgba(80, 26, 115, 0.98), rgba(18, 3, 30, 0.98));
}

/* Opcional: sin herida en azul */
#combat-dice-message.combat-result-badge.wound.ninguno {
    border-color: rgba(106, 210, 255, 0.95);
    background:
        radial-gradient(circle at 50% 50%, rgba(82, 210, 255, 0.24), transparent 58%),
        linear-gradient(90deg, rgba(4, 14, 30, 0.96), rgba(12, 73, 120, 0.96), rgba(4, 14, 30, 0.96)),
        linear-gradient(180deg, rgba(20, 64, 110, 0.98), rgba(3, 14, 32, 0.98));
}

/* ===== FICHA ACTIVA: AURA DE TURNO ===== */

.player-token i {
    position: relative;
    z-index: 2;
}

.player-token.active-turn-token {
    width: 36px;
    height: 36px;
    z-index: 30;
    filter: brightness(1.18);
    box-shadow:
        0 0 8px var(--token-color),
        0 0 16px var(--token-color),
        0 0 26px rgba(255, 255, 255, 0.18);
}

.player-token.active-turn-token::before {
    content: "";
    position: absolute;
    inset: -9px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        color-mix(in srgb, var(--token-color) 42%, transparent) 0%,
        color-mix(in srgb, var(--token-color) 24%, transparent) 42%,
        transparent 72%
    );
    box-shadow:
        0 0 10px var(--token-color),
        0 0 22px var(--token-color),
        0 0 36px color-mix(in srgb, var(--token-color) 45%, transparent);
    opacity: 0.75;
    z-index: -1;
    pointer-events: none;
    animation: activeTokenBreath 1.8s ease-in-out infinite;
}

.player-token.active-turn-token::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--token-color);
    opacity: 0.85;
    box-shadow:
        0 0 8px var(--token-color),
        inset 0 0 8px var(--token-color);
    pointer-events: none;
    animation: activeTokenRingBreath 1.8s ease-in-out infinite;
}

@keyframes activeTokenBreath {
    0%, 100% {
        transform: scale(0.92);
        opacity: 0.45;
    }

    50% {
        transform: scale(1.18);
        opacity: 0.9;
    }
}

@keyframes activeTokenRingBreath {
    0%, 100% {
        transform: scale(0.96);
        opacity: 0.55;
    }

    50% {
        transform: scale(1.12);
        opacity: 1;
    }
}

/* ===== MENSAJES PvP ===== */

#pvp-dice-message.pvp-message-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    /* misma medida visual que los otros cilindros */
    width: min(340px, 92%);
    min-height: 42px;
    max-height: 42px;
    padding: 7px 22px;
    margin: 4px auto 6px;

    border-radius: 999px;
    border: 2px solid var(--pvp-accent, #00ffe1);

    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1;

    color: #f4fbff;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    position: relative;

    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.95),
        0 0 8px rgba(255, 255, 255, 0.18);

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        inset 0 -8px 16px rgba(0, 0, 0, 0.48),
        0 0 10px color-mix(in srgb, var(--pvp-accent) 52%, transparent),
        0 0 22px color-mix(in srgb, var(--pvp-accent) 22%, transparent);
}

/* Brillo superior fino */
#pvp-dice-message.pvp-message-badge::before {
    content: "";
    position: absolute;
    inset: 2px 18px auto 18px;
    height: 38%;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.18),
        rgba(255, 255, 255, 0.04),
        transparent
    );
    pointer-events: none;
}

/* Línea inferior estilo HUD */
#pvp-dice-message.pvp-message-badge::after {
    content: "";
    position: absolute;
    left: 34px;
    right: 34px;
    bottom: 5px;
    height: 1px;
    background: currentColor;
    opacity: 0.32;
    box-shadow: 0 0 10px currentColor;
    pointer-events: none;
}

/* TURNO: color del personaje, más elegante y tech */
#pvp-dice-message.pvp-message-badge.turn {
    color: #ffffff;
    border-color: color-mix(in srgb, var(--pvp-accent) 78%, white 22%);
    background:
        radial-gradient(
            circle at 50% 45%,
            color-mix(in srgb, var(--pvp-accent) 28%, transparent) 0%,
            transparent 58%
        ),
        linear-gradient(
            90deg,
            color-mix(in srgb, var(--pvp-accent) 18%, black 82%) 0%,
            color-mix(in srgb, var(--pvp-accent) 46%, black 54%) 50%,
            color-mix(in srgb, var(--pvp-accent) 18%, black 82%) 100%
        ),
        linear-gradient(
            180deg,
            rgba(28, 36, 52, 0.98),
            rgba(4, 8, 16, 0.98)
        );

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.16),
        inset 0 -8px 16px rgba(0, 0, 0, 0.52),
        0 0 10px color-mix(in srgb, var(--pvp-accent) 62%, transparent),
        0 0 24px color-mix(in srgb, var(--pvp-accent) 28%, transparent);
}

/* ESPERA: mismo cilindro, algo más sobrio */
#pvp-dice-message.pvp-message-badge.waiting {
    color: #ffffff;
    border-color: color-mix(in srgb, var(--pvp-accent) 68%, white 16%);
    background:
        radial-gradient(
            circle at 50% 45%,
            color-mix(in srgb, var(--pvp-accent) 20%, transparent) 0%,
            transparent 62%
        ),
        linear-gradient(
            90deg,
            color-mix(in srgb, var(--pvp-accent) 12%, black 88%) 0%,
            color-mix(in srgb, var(--pvp-accent) 32%, black 68%) 50%,
            color-mix(in srgb, var(--pvp-accent) 12%, black 88%) 100%
        ),
        linear-gradient(
            180deg,
            rgba(22, 28, 40, 0.98),
            rgba(3, 7, 14, 0.98)
        );

    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.13),
        inset 0 -8px 16px rgba(0, 0, 0, 0.50),
        0 0 8px color-mix(in srgb, var(--pvp-accent) 48%, transparent),
        0 0 18px color-mix(in srgb, var(--pvp-accent) 20%, transparent);
}

/* Resultado victoria: azul tipo dado / tech */
#pvp-dice-message.pvp-message-badge.result.victory {
    --pvp-accent: #42cfff;
    color: #ffffff;
    border-color: rgba(116, 225, 255, 0.95);

    background:
        radial-gradient(circle at 50% 50%, rgba(72, 210, 255, 0.26), transparent 58%),
        linear-gradient(90deg, rgba(3, 14, 30, 0.98), rgba(10, 84, 140, 0.98), rgba(3, 14, 30, 0.98)),
        linear-gradient(180deg, rgba(18, 72, 122, 0.98), rgba(3, 14, 32, 0.98));

    box-shadow:
        inset 0 1px 0 rgba(210, 250, 255, 0.22),
        inset 0 -8px 16px rgba(0, 0, 0, 0.50),
        0 0 10px rgba(68, 200, 255, 0.65),
        0 0 22px rgba(26, 134, 255, 0.36),
        0 0 36px rgba(0, 80, 255, 0.16);
}

/* Resultado derrota: rojo tech */
#pvp-dice-message.pvp-message-badge.result.defeat {
    --pvp-accent: #ff5656;
    color: #ffffff;
    border-color: rgba(255, 104, 104, 0.95);

    background:
        radial-gradient(circle at 50% 50%, rgba(255, 70, 70, 0.24), transparent 58%),
        linear-gradient(90deg, rgba(30, 3, 8, 0.98), rgba(125, 18, 24, 0.98), rgba(30, 3, 8, 0.98)),
        linear-gradient(180deg, rgba(120, 22, 30, 0.98), rgba(34, 3, 8, 0.98));

    box-shadow:
        inset 0 1px 0 rgba(255, 215, 215, 0.16),
        inset 0 -8px 16px rgba(0, 0, 0, 0.50),
        0 0 10px rgba(255, 76, 76, 0.64),
        0 0 22px rgba(255, 32, 45, 0.34),
        0 0 36px rgba(160, 0, 0, 0.16);
}

/* ===== MODAL CONFIRMACIÓN PvP ===== */

.pvp-confirm-modal {
    width: min(420px, 92vw);
    padding: 24px 26px;
    border-radius: 18px;

    background:
        radial-gradient(circle at 50% 0%, rgba(0, 255, 225, 0.16), transparent 55%),
        linear-gradient(180deg, rgba(10, 18, 32, 0.96), rgba(2, 6, 14, 0.98));

    border: 1px solid rgba(0, 255, 225, 0.38);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.08),
        0 0 20px rgba(0, 255, 225, 0.18),
        0 18px 50px rgba(0, 0, 0, 0.75);

    color: #e5e7eb;
    text-align: center;
}

.pvp-confirm-modal h2 {
    margin: 0 0 12px;
    color: #ffffff;
    font-size: 1.25rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-shadow:
        0 0 8px rgba(0, 255, 225, 0.55),
        0 1px 2px rgba(0,0,0,0.9);
}

.pvp-confirm-modal p {
    margin: 0 auto 20px;
    max-width: 320px;
    color: #cbd5e1;
    font-size: 0.95rem;
    line-height: 1.45;
}

.pvp-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.pvp-confirm-actions .combat-btn {
    min-width: 130px;
}

.log-player-name {
    font-weight: 900;
    text-shadow: 0 0 6px currentColor;
}

.win-goal-highlight {
    z-index: 35;
    border-radius: 8px;
    border: 2px solid rgba(255, 230, 70, 0.65);
    background: rgba(255, 221, 0, 0.13);
    box-shadow:
        0 0 6px rgba(255, 221, 0, 0.45),
        0 0 12px rgba(255, 190, 0, 0.28),
        inset 0 0 5px rgba(255, 255, 160, 0.22);
    animation: win-goal-pulse 1.15s ease-in-out infinite alternate;
}

@keyframes win-goal-pulse {
    from { transform: scale(0.92); opacity: 0.72; }
    to { transform: scale(1.08); opacity: 1; }
}

.loot-ready-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(5px);
}

.loot-ready-card {
    width: min(520px, 92vw);
    border-radius: 18px;
    border: 1px solid rgba(255, 230, 80, 0.7);
    background:
        radial-gradient(circle at top, rgba(255, 221, 0, 0.18), transparent 48%),
        rgba(5, 8, 14, 0.95);
    box-shadow:
        0 0 22px rgba(255, 221, 0, 0.25),
        0 18px 50px rgba(0, 0, 0, 0.75);
    color: #e5e7eb;
    text-align: center;
    padding: 28px 26px;
}

.loot-ready-card h2 {
    margin: 0 0 14px;
    color: #ffe75a;
    letter-spacing: 0.12em;
    text-shadow: 0 0 12px rgba(255, 221, 0, 0.75);
}

.loot-ready-card p {
    line-height: 1.5;
    margin: 10px 0;
}

.game-end-screen {
    position: fixed;
    inset: 0;
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 26px;
    background:
        radial-gradient(circle at 50% 20%, rgba(0, 255, 225, 0.12), transparent 42%),
        rgba(0, 0, 0, 0.92);
    color: #e5e7eb;
}

.game-end-screen.defeat {
    background:
        radial-gradient(circle at 50% 20%, rgba(255, 45, 45, 0.14), transparent 42%),
        rgba(0, 0, 0, 0.94);
}

.game-end-card {
    width: min(860px, 95vw);
    max-height: 92vh;
    overflow: auto;
    border-radius: 22px;
    border: 1px solid rgba(0, 255, 225, 0.35);
    background: rgba(4, 8, 15, 0.96);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.75);
    padding: 34px;
    text-align: center;
}

.game-end-screen.victory .game-end-card {
    border-color: rgba(100, 220, 255, 0.85);
    box-shadow:
        0 0 24px rgba(80, 200, 255, 0.35),
        0 24px 70px rgba(0, 0, 0, 0.75);
}

.game-end-screen.defeat .game-end-card {
    border-color: rgba(255, 80, 80, 0.78);
    box-shadow:
        0 0 24px rgba(255, 70, 70, 0.28),
        0 24px 70px rgba(0, 0, 0, 0.75);
}

.game-end-card h1 {
    margin: 0 0 12px;
    font-size: clamp(2.5rem, 8vw, 5.5rem);
    letter-spacing: 0.14em;
    text-shadow: 0 0 18px currentColor;
}

.game-end-screen.victory h1 { color: #8ee8ff; }
.game-end-screen.defeat h1 { color: #ff6b6b; }

.game-end-subtitle {
    font-size: 1.05rem;
    margin: 0 0 22px;
    color: #cbd5e1;
}

.game-end-info {
    margin: 22px auto;
    text-align: left;
    border: 1px solid rgba(0, 255, 225, 0.22);
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(0, 255, 225, 0.04);
}

.game-end-info summary {
    cursor: pointer;
    color: #00ffe1;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-align: center;
}

.final-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.final-player-stats {
    border: 1px solid rgba(0, 255, 225, 0.18);
    border-radius: 14px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.32);
}

.final-player-stats h3 {
    margin: 0 0 10px;
    color: #e5e7eb;
    font-size: 0.95rem;
}

.final-player-stats p {
    margin: 6px 0;
    font-size: 0.86rem;
    color: #cbd5e1;
}

.final-stats-list {
    margin: 10px 0 0;
    padding-left: 18px;
    font-size: 0.82rem;
    color: #cbd5e1;
}

.game-end-btn {
    margin-top: 8px;
    border: 1px solid rgba(0, 255, 225, 0.55);
    border-radius: 14px;
    padding: 12px 20px;
    background: rgba(0, 255, 225, 0.14);
    color: #e5e7eb;
    font-weight: 900;
    letter-spacing: 0.08em;
    cursor: pointer;
    box-shadow: 0 0 14px rgba(0, 255, 225, 0.18);
}

.game-end-btn:hover {
    background: rgba(0, 255, 225, 0.24);
}
