/* ==========================================================================
   GLOBAL.CSS - KARLOS TCG
   Contiene TODO el motor visual del juego, animaciones y UI.
   ========================================================================== */

:root {
    --p1-color: #3b82f6;
    --p2-color: #ef4444;
    --bg-color: #1e293b;
    --card-width: 90px;
    --card-height: 126px;
    --card-scale-hover: 1.2;
    --stack-offset: 120px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: white;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* --- LAYOUT --- */
#game-board {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: filter 0.3s;
}

#game-board.waiting-interaction .card:not(.interactive) {
    filter: grayscale(1) brightness(0.5);
    pointer-events: none;
}

.player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    position: relative;
    min-height: 0;
}

#p2-area {
    border-bottom: 2px solid #475569;
    background: rgba(239, 68, 68, 0.05);
    justify-content: flex-start;
}

#p1-area {
    border-top: 2px solid #475569;
    background: rgba(59, 130, 246, 0.05);
    justify-content: flex-end;
}

/* --- ZONES --- */
.rows-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
    width: 100%;
    position: relative;
    padding-left: var(--stack-offset);
    box-sizing: border-box;
}

.zone-row {
    display: flex;
    gap: 8px;
    min-height: var(--card-height);
    padding: 5px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    justify-content: center;
    align-items: center;
    position: relative;
}

.zone-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.05);
    pointer-events: none;
    text-transform: uppercase;
    z-index: 0;
}

.hand-zone {
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0; 
    z-index: 10;
    margin: 5px 0;
    width: 100%;
    position: relative;
    padding-left: var(--stack-offset);
    box-sizing: border-box;
    overflow: visible; 
}

#p1-hand {
    align-items: flex-end;
    padding-bottom: 10px;
}

#p2-hand {
    align-items: flex-start;
    padding-top: 10px;
}

.hand-zone:hover .card {
    margin-right: 5px;
}

/* --- CARDS --- */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: 6px;
    background: #cbd5e1;
    color: #0f172a;
    font-size: 0.6rem;
    display: flex;
    flex-direction: column;
    padding: 3px;
    box-sizing: border-box;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, margin 0.2s;
    border: 2px solid #000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 1;
    background-color: white;
    flex-shrink: 0;
}

.card:hover {
    transform: scale(var(--card-scale-hover));
    z-index: 100;
}

.card.selected {
    border: 3px solid yellow !important;
    box-shadow: 0 0 20px yellow !important;
    z-index: 50;
    transform: scale(var(--card-scale-hover));
}

.card.targetable {
    border: 3px solid red !important;
    box-shadow: 0 0 15px red !important;
    cursor: crosshair;
}

.card.valid-target {
    border: 3px solid #4ade80 !important;
    box-shadow: 0 0 15px #4ade80 !important;
    cursor: pointer;
}

.card.exhausted {
    filter: grayscale(0.8) brightness(0.7);
}

.card.interactive {
    border: 3px solid #f97316 !important;
    box-shadow: 0 0 20px #f97316 !important;
    z-index: 2000 !important;
    cursor: pointer !important;
    transform: scale(1.1);
    animation: pulseInteractive 1s infinite;
}

/* ANIMACIONES BÁSICAS Y COMBATE */
@keyframes pulseInteractive {
    0% { box-shadow: 0 0 10px #f97316; }
    50% { box-shadow: 0 0 25px #f97316, 0 0 10px #fbbf24; transform: scale(1.15); }
    100% { box-shadow: 0 0 10px #f97316; }
}

@keyframes enterBoard {
    0% { transform: scale(0.5) translateY(50px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.card.entering, .stack-card.entering {
    animation: enterBoard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card.drawing {
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 1000;
}

@keyframes hardShake {
    0% { transform: translate(0, 0) rotate(0); }
    10% { transform: translate(-8px, -8px) rotate(-10deg); }
    30% { transform: translate(8px, 6px) rotate(8deg); }
    50% { transform: translate(-6px, 4px) rotate(-5deg); }
    70% { transform: translate(4px, -4px) rotate(4deg); }
    90% { transform: translate(-2px, 2px) rotate(-2deg); }
    100% { transform: translate(0, 0) rotate(0); }
}

.card.shaking {
    animation: hardShake 0.3s ease-out;
    border-color: red;
    box-shadow: 0 0 20px red inset;
}

.shake-ui {
    animation: hardShake 0.3s ease-out;
}

@keyframes dieEffect {
    0% { transform: scale(1); filter: grayscale(0); }
    30% { transform: scale(1.1) rotate(5deg); background-color: #ef4444; }
    100% { transform: scale(0) rotate(45deg); opacity: 0; filter: grayscale(1); clip-path: polygon(0 0, 45% 0, 30% 100%, 0 100%); }
}

.card.dying {
    animation: dieEffect 0.8s ease-in-out forwards;
    pointer-events: none;
    z-index: 200;
}

@keyframes dodgeRight {
    0% { transform: translateX(0); }
    20% { transform: translateX(40px) skewX(-10deg); }
    50% { transform: translateX(40px) skewX(-10deg); }
    100% { transform: translateX(0); }
}

.card.dodging {
    animation: dodgeRight 0.4s ease-out;
}

@keyframes splitTop {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(-20px) translateX(-10px) rotate(-15deg); opacity: 0; }
}

@keyframes splitBottom {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(20px) translateX(10px) rotate(15deg); opacity: 0; }
}

/* Floating Text */
.floating-text {
    position: fixed;
    font-size: 1.5rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 2000;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    animation: floatUp 1.5s ease-out forwards;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

@keyframes floatUp {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    15% { transform: translate(-50%, -150%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -250%) scale(1); opacity: 0; }
}

.ft-red { color: #ef4444; font-size: 2.5rem; }
.ft-red-stat { color: #ef4444; }
.ft-green { color: #4ade80; }
.ft-yellow { color: #facc15; }
.ft-blue { color: #60a5fa; font-size: 1.2rem; }
.ft-purple { color: #d946ef; font-size: 1.5rem; text-shadow: 0 0 5px #a21caf, 1px 1px 0 #000; }
.ft-gray { color: #9ca3af; font-size: 1.5rem; text-shadow: 0 0 5px #4b5563, 1px 1px 0 #000; }
.ft-ability { color: #22d3ee; font-size: 1.2rem; text-shadow: 0 0 10px #0891b2, 1px 1px 0 #000; letter-spacing: 1px; }

/* Phase Banner */
#phase-banner {
    position: fixed;
    top: 45%;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(0, 0, 0, 0.9);
    color: #fbbf24;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    z-index: 9000;
    transform: translateX(100%);
    border-top: 2px solid #fbbf24;
    border-bottom: 2px solid #fbbf24;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    display: none;
    mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}

@keyframes phaseSwipe {
    0% { transform: translateX(100%); opacity: 0; }
    10% { transform: translateX(0%); opacity: 1; }
    90% { transform: translateX(0%); opacity: 1; }
    100% { transform: translateX(-100%); opacity: 0; }
}

.anim-phase {
    display: flex !important;
    animation: phaseSwipe 1.8s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* ACTION BANNER */
#action-banner {
    position: fixed;
    top: 20%;
    width: 100%;
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    color: #f97316;
    text-shadow: 0 0 10px black;
    z-index: 4000;
    display: none;
    pointer-events: none;
}

/* COIN FLIP SYSTEM */
#coin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 6000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

#coin {
    width: 150px;
    height: 150px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 3s ease-out;
    cursor: pointer;
}

.coin-side {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 2rem;
    border: 5px solid #f59e0b;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.side-heads { background: #fcd34d; color: #78350f; }
.side-tails { background: #cbd5e1; color: #0f172a; transform: rotateY(180deg); }
.flipping { animation: spinCoin 0.5s infinite linear; }
@keyframes spinCoin { 0% { transform: rotateY(0); } 100% { transform: rotateY(360deg); } }

/* TYPE SELECTION & MODALS */
#type-select-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 6500;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.type-btn-container { display: flex; gap: 10px; margin-top: 20px; }

.type-btn {
    padding: 15px 25px; font-size: 1rem; font-weight: bold;
    background: #334155; border: 2px solid #94a3b8; color: white;
    cursor: pointer; border-radius: 8px; transition: transform 0.2s;
}
.type-btn:hover { background: #475569; transform: scale(1.1); border-color: #fbbf24; }

#confirm-ability-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); z-index: 8000; display: none;
    flex-direction: column; align-items: center; justify-content: center;
}

.confirm-box {
    background: #1e293b; padding: 20px 30px; border-radius: 10px;
    border: 2px solid #fbbf24; text-align: center;
}
.confirm-btns { display: flex; gap: 20px; margin-top: 20px; justify-content: center; }

/* Card Types Colors */
.type-Personaje { background: linear-gradient(135deg, #fcd34d, #b45309); border-color: #78350f; color: black; }
.type-Esbirro { background: linear-gradient(135deg, #94a3b8, #475569); border-color: #1e293b; color: black; }
.type-Evento { background: linear-gradient(135deg, #c084fc, #7e22ce); border-color: #581c87; color: white; }
.type-Ayuda { background: linear-gradient(135deg, #f9a8d4, #be185d); border-color: #831843; color: white; }

.card-back {
    background: #334155 !important;
    background-image: repeating-linear-gradient(45deg, #1e293b 0, #1e293b 10px, #334155 10px, #334155 20px) !important;
    border-color: #94a3b8; cursor: default;
}
.card-back:hover { transform: none; }
.card-back * { display: none; }

/* Card Content internals */
.card-header {
    display: flex; justify-content: center; align-items: center;
    font-weight: bold; border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    height: 18px; overflow: visible; text-align: center; padding: 0 2px;
}
.card-header span { white-space: nowrap; display: inline-block; line-height: 1; transition: none; transform-origin: center; }
.card-image { flex: 1; background: rgba(255, 255, 255, 0.3); margin: 2px 0; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.card-body { font-size: 0.5rem; overflow: hidden; height: 32px; line-height: 1; margin-bottom: 2px; }
.stats-row { display: flex; justify-content: space-between; background: rgba(0, 0, 0, 0.6); color: white; border-radius: 4px; padding: 2px; margin-top: auto; }
.stat-box { text-align: center; flex: 1; display: flex; flex-direction: column; white-space: nowrap; }
.stat-label { font-size: 0.4rem; opacity: 0.8; }
.stat-val { font-weight: bold; font-size: 0.65rem; height: 1rem; display: flex; align-items: center; justify-content: center; }

/* Badges y Contadores */
.furor-container { position: absolute; top: -6px; right: -12px; background: #ef4444; color: white; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-weight: bold; border: 2px solid white; font-size: 0.8rem; z-index: 5; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.status-dot { position: absolute; top: -6px; left: -18px; width: 22px; height: 22px; background: #f97316; color: white; border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: bold; z-index: 6; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }
.counter-badge { position: absolute; bottom: -6px; right: -28px; min-width: 22px; height: 22px; padding: 0 4px; background: #0f766e; border: 2px solid #5eead4; border-radius: 11px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 4px rgba(0,0,0,0.5); z-index: 5; }
.counter-badge span { font-size: 0.8rem; color: white; font-weight: bold; line-height: 1; }
.stealth-badge { position: absolute; bottom: -6px; left: -16px; width: 22px; height: 22px; background: #1e1b4b; color: #a5b4fc; border-radius: 50%; border: 2px solid #6366f1; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; z-index: 6; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); }

/* ANIMACIÓN DE EVOLUCIÓN */
@keyframes evolve-anim {
    0% { transform: scale(1) rotateY(0deg); filter: brightness(1) drop-shadow(0 0 0px #a855f7); }
    40% { transform: scale(1.3) rotateY(90deg); filter: brightness(2) drop-shadow(0 0 30px #a855f7); }
    60% { transform: scale(1.3) rotateY(270deg); filter: brightness(2) drop-shadow(0 0 30px #a855f7); }
    100% { transform: scale(1) rotateY(360deg); filter: brightness(1) drop-shadow(0 0 0px #a855f7); }
}
.evolving { animation: evolve-anim 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards; z-index: 1000 !important; }

/* CONTENEDOR PARA APILAR BOTONES AUTOMÁTICAMENTE */
.action-btn-container {
    position: absolute; 
    bottom: 28px; 
    left: 50%; 
    transform: translateX(-50%);
    display: flex; 
    flex-direction: column-reverse; 
    gap: 4px; 
    
    /* TRUCO: Contenedor súper ancho invisible para que Flexbox lo expanda siempre desde el centro */
    width: 300%; 
    align-items: center;
    z-index: 20;
    pointer-events: none; 
}

.action-btn-card {
    pointer-events: auto; 
    background: #2563eb; color: white; border: 1px solid white; border-radius: 10px;
    padding: 4px 8px; font-size: 0.6rem; font-weight: bold; cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); 
    text-align: center; box-sizing: border-box;
    
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    
    width: max-content; 
    max-width: 82px; /* Límite en reposo */
    margin: 0 auto;  /* Centrado seguro */
    
    /* ANIMACIÓN AL QUITAR EL RATÓN (Encoger) */
    /* Si quieres revertir a como estaba, cambia '0.4s' por '0.2s' */
    transition: max-width 0.4s ease-in-out, transform 0.1s, filter 0.1s;
    position: relative;
}

.action-btn-card:hover { 
    max-width: 180px; /* Límite ajustado para que la animación no se sienta falsa */
    transform: scale(1.05); 
    z-index: 1000;
    filter: brightness(0.85); 
    
    /* ANIMACIÓN AL PONER EL RATÓN (Expandir suavemente) */
    /* Si no te gusta este efecto y quieres que sea de golpe, cambia '0.8s' por '0.2s' */
    transition: max-width 0.8s cubic-bezier(0, 0.5, 0.5, 1), transform 0.1s, filter 0.1s;
}

/* Controls UI */
#debug-btn-main { position: absolute; top: 10px; left: 10px; background: #7c3aed; font-size: 0.7rem; padding: 5px; z-index: 7000; }
#rules-btn-main { position: absolute; top: 10px; left: 70px; font-size: 0.7rem; padding: 5px; z-index: 7000; }
#volume-control { position: absolute; top: 10px; right: 10px; z-index: 7000; display: flex; align-items: center; gap: 5px; background: rgba(0, 0, 0, 0.5); padding: 5px 10px; border-radius: 20px; }
#volume-slider { width: 100px; cursor: pointer; }
#volume-icon { font-size: 1.2rem; cursor: pointer; user-select: none; }

#ui-layer {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 8px; z-index: 200;
}

button.game-btn {
    padding: 8px 15px; background: #22c55e; color: white; border: none; border-radius: 5px;
    font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); font-size: 0.9rem;
}
button.game-btn:hover { background: #16a34a; }
button.game-btn:disabled { background: #64748b; cursor: not-allowed; opacity: 0.7; }

#btn-direct-attack { background: #dc2626; animation: pulse-btn 1s infinite; display: block; }
@keyframes pulse-btn { 0% { transform: scale(1); box-shadow: 0 0 0 rgba(220, 38, 38, 0.7); } 50% { transform: scale(1.05); box-shadow: 0 0 10px rgba(220, 38, 38, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 rgba(220, 38, 38, 0.7); } }
.btn-confirm-ability { background: #10b981 !important; animation: pulse-btn 1s infinite; }

/* --- PILAS LATERALES --- */
.stacks-container { position: absolute; left: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.stack-row { display: flex; gap: 10px; align-items: center; }
.stack-card {
    width: var(--card-width); height: var(--card-height); box-sizing: border-box; border-radius: 6px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-weight: bold; font-size: 0.7rem; text-align: center; color: white; position: relative;
    text-shadow: 0px 0px 4px black, 0px 0px 4px black, 0px 0px 2px black;
}
.count-badge { position: absolute; bottom: 5px; right: 5px; background: rgba(0, 0, 0, 0.7); border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; border: 1px solid white; }

.retribution-stack { background: #b91c1c; border: 3px solid white; box-shadow: 4px 4px 0px #7f1d1d; }
.deck-stack { background: #0f172a; background-image: repeating-linear-gradient(135deg, #1e293b 0, #1e293b 10px, #0f172a 10px, #0f172a 20px); border: 2px solid #475569; box-shadow: 4px 4px 0px #020617; }
.empty-slot { border: 2px dashed rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.1); cursor: default; }
.discard-stack { cursor: pointer; transition: border-color 0.2s; }
.discard-stack:hover { border-color: #fbbf24; }
.discard-stack.filled { border: 2px solid #000; background: #cbd5e1; }
.discard-stack .card-preview-mini { width: 100%; height: 100%; position: absolute; top: 0; left: 0; border-radius: 4px; background: #cbd5e1; color: transparent; display: flex; align-items: center; justify-content: center; z-index: -1; background-size: cover; }

#p2-area .stacks-container { top: auto; bottom: 10px; flex-direction: column-reverse; }
#p1-area .stacks-container { top: 10px; bottom: auto; flex-direction: column; }

/* DISCARD/HAND VIEWER OVERLAY */
#discard-viewer { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.85); z-index: 4000; display: none; flex-direction: column; align-items: center; justify-content: center; }
#discard-content { display: flex; flex-wrap: wrap; gap: 10px; max-width: 80%; justify-content: center; overflow-y: auto; padding: 20px; max-height: 70vh; }
#discard-title { font-size: 1.5rem; color: white; margin-bottom: 20px; text-transform: uppercase; font-weight: bold; }
.close-discard { position: absolute; top: 20px; right: 30px; font-size: 2rem; color: white; cursor: pointer; }

/* DEBUG MODAL */
#debug-modal { display: none; position: fixed; top: 50px; left: 20px; width: auto; height: auto; background: transparent; z-index: 7000; }
.debug-panel { 
    background: rgba(30, 41, 59, 0.95); 
    border: 2px solid #7c3aed; 
    padding: 15px; 
    border-radius: 10px; 
    min-width: 280px;        /* Mantiene el tamaño original si el texto es corto */
    width: max-content;      /* Se estira automáticamente para que quepa el texto largo */
    max-width: 90vw;         /* Tope de seguridad para que no se salga de la pantalla en móviles */
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8); 
}
.debug-row { display: flex; gap: 5px; align-items: center; flex-wrap: nowrap; }
.debug-row select { flex: 1; padding: 5px; background: #334155; color: white; border: 1px solid #7c3aed; border-radius: 4px; }
.debug-row input { width: 45px; padding: 5px; background: #334155; color: white; border: 1px solid #7c3aed; border-radius: 4px; flex: none; }
.debug-mode-active { border: 4px solid #7c3aed !important; box-shadow: 0 0 15px #7c3aed !important; }
.debug-radio-group { display: flex; gap: 10px; font-size: 0.7rem; color: #94a3b8; }
.debug-radio-group label { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.btn-destroy { background: #dc2626 !important; border: 1px solid #ef4444 !important; }

/* LOG CONTAINER */
#log-container { position: absolute; bottom: 10px; left: 10px; width: 280px; height: 180px; z-index: 9100; display: flex; flex-direction: column; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); border-radius: 4px; overflow: hidden; }
#log-header { background: #475569; color: white; font-size: 0.7rem; padding: 4px 8px; cursor: grab; display: flex; justify-content: space-between; align-items: center; user-select: none; }
#log-header:active { cursor: grabbing; }
#log-content { flex: 1; background: rgba(0, 0, 0, 0.9); font-family: monospace; font-size: 0.75rem; padding: 8px; overflow-y: auto; pointer-events: auto; border: 1px solid #4ade80; border-top: none; }
.log-entry { margin-bottom: 2px; }
.log-p1 { color: #60a5fa; }
.log-p2 { color: #f87171; }
.log-combat { color: #fb923c; }
.log-ability { color: #22d3ee; }
.log-phase { color: #facc15; font-weight: bold; border-top: 1px solid #444; margin-top: 5px; padding-top: 5px; }
.log-system { color: #94a3b8; font-style: italic; }
.log-neutral { color: #4ade80; }
.btn-reset-log { background: #64748b; border: none; color: white; font-size: 0.6rem; padding: 2px 5px; border-radius: 3px; cursor: pointer; }

/* PREVIEW SIDEBAR */
#card-preview { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 260px; min-height: 100px; height: auto; background: rgba(15, 23, 42, 0.95); border: 2px solid #94a3b8; border-left: none; border-radius: 0 10px 10px 0; z-index: 5000; display: none; flex-direction: column; padding: 15px; box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.5); pointer-events: none; }
.preview-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; border-bottom: 1px solid #475569; }
.preview-title { font-size: 1.2rem; font-weight: bold; color: #fbbf24; }
.preview-id { font-size: 0.8rem; color: #64748b; }
.preview-type { font-size: 0.8rem; color: #94a3b8; margin-bottom: 6px; font-style: italic; }
.preview-effects { font-size: 0.75rem; color: #22d3ee; margin-bottom: 12px; padding: 5px; border-top: 1px dashed #475569; border-bottom: 1px dashed #475569; background: rgba(0, 0, 0, 0.3); border-radius: 4px; }
.preview-text { font-size: 0.8rem; line-height: 1.3; color: white; flex: 1; margin-bottom: 10px; }

/* CAJAS DE HABILIDADES EN LA PREVIEW */
.ability-box { margin-bottom: 6px; padding: 6px 8px; border-radius: 0 4px 4px 0; font-size: 0.75rem; line-height: 1.3; background: rgba(255, 255, 255, 0.05); }
.passive-box { background: rgba(59, 130, 246, 0.15); border-left: 3px solid #3b82f6; }
.active-box { background: rgba(239, 68, 68, 0.15); border-left: 3px solid #ef4444; }
.ability-box strong { color: #fbbf24; display: inline-block; margin-bottom: 2px; }

.preview-stats { display: flex; justify-content: space-around; background: rgba(0, 0, 0, 0.5); border: 1px solid #475569; padding: 8px 5px; border-radius: 6px; margin-top: auto; }
.stat-buff { color: #4ade80; font-weight: 900; text-shadow: 0 0 3px black; }
.stat-nerf { color: #facc15; font-weight: 900; text-shadow: 0 0 3px black; }
.hp-low { color: #ef4444; font-weight: 900; text-shadow: 0 0 3px white; font-size: 0.9rem; }

/* OVERLAYS GLOBALES */
#turn-overlay { display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.95); z-index: 9200; align-items: center; justify-content: center; flex-direction: column; transition: opacity 0.3s; }
.hidden-overlay { opacity: 0; pointer-events: none; }
.turn-title { font-size: 3rem; font-weight: bold; color: #fbbf24; margin-bottom: 20px; text-transform: uppercase; text-shadow: 0 0 20px orange; }
.turn-subtitle { color: white; font-size: 1.2rem; margin-bottom: 40px; }

#modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.85); z-index: 9500; align-items: center; justify-content: center; }
.modal { background: white; color: black; padding: 30px; border-radius: 10px; text-align: center; max-width: 300px; }

#confirmation-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.85); z-index: 8000; flex-direction: column; align-items: center; justify-content: center; }

/* BLOQUEO DURANTE BANNERS */
#phase-banner.anim-phase ~ #game-board #ui-layer button { pointer-events: none; opacity: 0.8; }
#debug-btn-main, #volume-control { pointer-events: auto !important; }

/* ANIMACIÓN DE BARAJAR MAZO */
@keyframes deckShuffle {
    0% { transform: translate(0, 0) rotate(0); }
    25% { transform: translate(-3px, 0) rotate(-2deg); }
    50% { transform: translate(3px, 0) rotate(2deg); }
    75% { transform: translate(-3px, 0) rotate(-2deg); }
    100% { transform: translate(0, 0) rotate(0); }
}
.stack-card.shuffling { animation: deckShuffle 0.15s infinite; border-color: #fbbf24; box-shadow: 0 0 15px #fbbf24; }

/* EFECTO HOLOGRÁFICO RAREZA S (BASE DORADA PARA PERSONAJES) */
.card.rarity-S { border: 2px solid #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.8); }
.card.rarity-S.targetable { border: 3px solid red !important; box-shadow: 0 0 15px red !important; }
.card.rarity-S.selected { border: 3px solid yellow !important; box-shadow: 0 0 20px yellow !important; }
.card.rarity-S.valid-target { border: 3px solid #4ade80 !important; box-shadow: 0 0 15px #4ade80 !important; }

.card.rarity-S::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 4px;
    background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.6) 25%, rgba(255,255,255,0.8) 30%, transparent 35%);
    background-size: 300% 100%; background-position: 100% 0; animation: shine-s-rank 3s infinite; pointer-events: none; z-index: 10;
}
@keyframes shine-s-rank { 0% { background-position: 150% 0; } 20% { background-position: -50% 0; } 100% { background-position: -50% 0; } }

/* EFECTO HOLOGRÁFICO RAREZA S PARA ESBIRROS (Plateado brillante) */
.card.type-Esbirro.rarity-S { 
    border: 2px solid #e2e8f0; 
    box-shadow: 0 0 12px rgba(226, 232, 240, 0.8); 
}
.card.type-Esbirro.rarity-S::after {
    background-image: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.7) 25%, rgba(255,255,255,0.9) 30%, transparent 35%);
}

/* EFECTO HOLOGRÁFICO RAREZA S PARA AYUDAS (Rosa chillón / Magenta neón) */
.card.type-Ayuda.rarity-S { 
    border: 2px solid #ff1493; 
    box-shadow: 0 0 12px rgba(255, 20, 147, 0.8); 
}
.card.type-Ayuda.rarity-S::after {
    background-image: linear-gradient(105deg, transparent 20%, rgba(255,105,180,0.6) 25%, rgba(255,105,180,0.8) 30%, transparent 35%);
}
/* Las pseudo-clases .targetable, .selected y .valid-target de .card.rarity-S ya se aplican solas por herencia general */

/* EFECTO MITAD Y MITAD PARA CARTAS DUALES (ARTHAS) */
.card.dual-type {
    border-color: #78350f !important; 
    color: black !important;
    /* Para hacerlo más estrecho, acerca los porcentajes. Ejemplo: 45%, 48%, 52%, 55% */
    background: linear-gradient(135deg, 
        #fcd34d 0%,    /* Empieza dorado */
        #b45309 45%,   /* Dorado oscuro hasta casi la mitad */
        #be185d 55%,   /* Pasa a rosa oscuro justo pasada la mitad */
        #f9a8d4 100%   /* Termina en rosa claro */
    ) !important;
}
.card.dual-type .card-header {
    background: rgba(255, 255, 255, 0.3) !important;
    color: black !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3) !important;
}

/* ANIMACIÓN DESINTEGRACIÓN EVENTO */
.card.event-expire, .stack-card.event-expire { pointer-events: none; z-index: 1000 !important; animation: disintegrationEffect 1.3s ease-out forwards; }
@keyframes disintegrationEffect {
    0% { opacity: 1; transform: scale(1) rotate(0deg) translateY(0); filter: blur(0px) brightness(1); }
    30% { filter: blur(2px) brightness(3); transform: scale(1.02) translateY(-5px); }
    100% { opacity: 0; transform: scale(1.1) rotate(2deg) translateY(-30px); filter: blur(10px) brightness(5); }
}

/* ENVOLTURAS DE CARTAS EQUIPADAS */
.card-wrapper { position: relative; display: inline-block; margin: 0 4px; }
.equipped-card-visual { 
    position: absolute; top: -15px; left: 15px; z-index: 0; 
    filter: brightness(0.6) sepia(0.3); pointer-events: none; transform: rotate(5deg);
}

/* ==========================================================================
   ESTILOS EXCLUSIVOS DEL MANUAL DE REGLAS (MODAL GLOBAL)
   ========================================================================== */
#rules-body h2, #rules-body h3 { color: #fbbf24; margin-top: 1.5rem; margin-bottom: 0.5rem; }
#rules-body h3 { font-size: 1.2rem; border-bottom: 1px solid #475569; padding-bottom: 5px; }
#rules-body p { margin-bottom: 1rem; }
#rules-body ul { margin-bottom: 1rem; padding-left: 20px; }
#rules-body li { margin-bottom: 5px; }
#rules-body strong { color: #f8fafc; }
#rules-body::-webkit-scrollbar { width: 8px; }
#rules-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); border-radius: 4px; }
#rules-body::-webkit-scrollbar-thumb { background: #38bdf8; border-radius: 4px; }
#rules-body::-webkit-scrollbar-thumb:hover { background: #0284c7; }