* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #0f172a;
    color: #f8fafc;
    min-height: 100dvh;
    padding: 52px 16px 16px;
    position: relative;
}

/* =========================================================
   1. FONDOS AUTOMÁTICOS POR TEMPORADA / BARAJA
   ========================================================= */
body.tema-extendida {
    background: #0f172a url('../../img/fondo_kermes.jpg') center / cover fixed no-repeat;
}
body.tema-navidad {
    background: #0f172a url('../../img/fondo_navidad.jpg') center / cover fixed no-repeat;
}
body.tema-semana_santa {
    background: #0f172a url('../../img/fondo_semana_santa.jpg') center / cover fixed no-repeat;
}
body.tema-verano {
    background: #0f172a url('../../img/fondo_verano.jpg') center / cover fixed no-repeat;
}
body.tema-halloween {
    background: #0f172a url('../../img/fondo_halloween.jpg') center / cover fixed no-repeat;
}

#escenario-ocasion {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.35) 0%, rgba(15, 23, 42, 0.82) 100%);
}

#canvas-confeti-global {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 90;
}

/* =========================================================
   2. PAPEL PICADO COLGANTE ONDEANTE POR TEMPORADA
   ========================================================= */
.banderines-ocasion {
    position: fixed;
    top: 0;
    left: -4%;
    width: 108%;
    height: 38px;
    z-index: 60;
    pointer-events: none;
    opacity: 0.96;
    border-top: 3px solid rgba(15, 23, 42, 0.85);
    filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.65));
    transform-origin: top center;
    animation: ondearBanderines 3.4s ease-in-out infinite alternate;

    -webkit-mask-image:
        linear-gradient(to bottom, #000 0, #000 30px, transparent 30px),
        conic-gradient(from 290deg at 50% 100%, #000 140deg, transparent 0);
    -webkit-mask-size: 42px 38px, 42px 38px;
    -webkit-mask-position: 0 0, 0 0;
    -webkit-mask-repeat: repeat-x;

    mask-image:
        linear-gradient(to bottom, #000 0, #000 30px, transparent 30px),
        conic-gradient(from 290deg at 50% 100%, #000 140deg, transparent 0);
    mask-size: 42px 38px, 42px 38px;
    mask-position: 0 0, 0 0;
    mask-repeat: repeat-x;

    background:
        radial-gradient(circle 3.5px at 21px 16px, rgba(15, 23, 42, 0.85) 95%, transparent 100%) 0 0 / 42px 38px repeat-x,
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.6) 0 1.5px, transparent 1.5px 42px),
        repeating-linear-gradient(
            90deg,
            #10b981 0 42px,
            #3b82f6 42px 84px,
            #ec4899 84px 126px,
            #f59e0b 126px 168px
        );
}

body.tema-navidad .banderines-ocasion {
    background:
        radial-gradient(circle 3.5px at 21px 16px, rgba(15, 23, 42, 0.85) 95%, transparent 100%) 0 0 / 42px 38px repeat-x,
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.6) 0 1.5px, transparent 1.5px 42px),
        repeating-linear-gradient(
            90deg,
            #dc2626 0 42px,
            #16a34a 42px 84px,
            #fbbf24 84px 126px,
            #f8fafc 126px 168px
        );
}

body.tema-semana_santa .banderines-ocasion {
    background:
        radial-gradient(circle 3.5px at 21px 16px, rgba(15, 23, 42, 0.85) 95%, transparent 100%) 0 0 / 42px 38px repeat-x,
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.6) 0 1.5px, transparent 1.5px 42px),
        repeating-linear-gradient(
            90deg,
            #7e22ce 0 42px,
            #fbbf24 42px 84px,
            #f8fafc 84px 126px,
            #a855f7 126px 168px
        );
}

body.tema-verano .banderines-ocasion {
    background:
        radial-gradient(circle 3.5px at 21px 16px, rgba(15, 23, 42, 0.85) 95%, transparent 100%) 0 0 / 42px 38px repeat-x,
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.6) 0 1.5px, transparent 1.5px 42px),
        repeating-linear-gradient(
            90deg,
            #06b6d4 0 42px,
            #facc15 42px 84px,
            #fb7185 84px 126px,
            #10b981 126px 168px
        );
}

body.tema-halloween .banderines-ocasion {
    background:
        radial-gradient(circle 3.5px at 21px 16px, rgba(15, 23, 42, 0.85) 95%, transparent 100%) 0 0 / 42px 38px repeat-x,
        repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.6) 0 1.5px, transparent 1.5px 42px),
        repeating-linear-gradient(
            90deg,
            #f97316 0 42px,
            #7e22ce 42px 84px,
            #ec4899 84px 126px,
            #fbbf24 126px 168px
        );
}

@keyframes ondearBanderines {
    0% {
        transform: translateX(-6px) skewX(-2.5deg) scaleY(0.96);
    }
    50% {
        transform: translateX(0px) skewX(0deg) scaleY(1.04);
    }
    100% {
        transform: translateX(6px) skewX(2.5deg) scaleY(0.96);
    }
}

/* =========================================================
   3. CONTENEDORES Y COMPONENTES GENERALES
   ========================================================= */
.contenedor-rifa,
.contenedor-jugador {
    position: relative;
    z-index: 10;
    max-width: 1360px;
    margin: 0 auto;
}

.oculto {
    display: none !important;
}

.header-taquilla {
    background: rgba(30, 41, 59, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.header-taquilla h1 {
    font-size: clamp(18px, 2.4vw, 24px);
    color: #fbbf24;
}

.subtitulo {
    font-size: 13px;
    color: #cbd5e1;
}

.acciones-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.panel,
.tarjeta-panel {
    background: rgba(30, 41, 59, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
}

.panel h2,
.tarjeta-panel h2 {
    font-size: 18px;
    color: #fbbf24;
    margin-bottom: 12px;
}

.barra-evento {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.campo-inline,
.selector-evento {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
}

.campo-inline select,
.selector-evento select {
    flex: 1;
    min-width: 220px;
}

/* Formularios y botones */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.grid-form-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.campo {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.campo label {
    font-size: 13px;
    color: #cbd5e1;
    font-weight: 600;
}

.campo-check {
    justify-content: center;
}

.campo-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
select {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 9px 11px;
    font-size: 14px;
    width: 100%;
}

button,
.btn-link {
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.1s ease, filter 0.15s ease;
}

button:hover,
.btn-link:hover {
    filter: brightness(1.1);
}

button:active {
    transform: scale(0.98);
}

.btn-verde { background: #16a34a; color: #fff; }
.btn-dorado { background: #fbbf24; color: #0f172a; }
.btn-gris { background: #334155; color: #f8fafc; border: 1px solid #475569; }
.btn-link { background: #1e293b; color: #38bdf8; border: 1px solid #38bdf8; }
.btn-grande { width: 100%; padding: 12px; font-size: 15px; }

.acciones-form,
.fila-botones {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Métricas Taquilla */
.grid-metricas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.metrica-card,
.tarjeta-metrica {
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.metrica-card span,
.tarjeta-metrica span {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.metrica-card strong,
.tarjeta-metrica strong {
    font-size: 20px;
}

.metrica-verde strong,
.texto-verde { color: #4ade80; }
.metrica-ambar strong,
.texto-naranja { color: #fb923c; }
.texto-dorado { color: #fbbf24; }

/* Layout Taquilla */
.layout-taquilla {
    display: grid;
    grid-template-columns: 390px 1fr;
    gap: 14px;
    align-items: start;
}

.mensaje-estado,
.mensaje-feedback {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #4ade80;
}

.divisor,
.separador {
    border: 0;
    border-top: 1px solid #334155;
    margin: 14px 0;
}

.ayuda-texto {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.lista-wa {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.item-wa {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.btn-wa {
    background: #22c55e;
    color: #052e16;
    font-weight: 800;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.cabecera-tabla {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.filtros-tabla,
.filtros-pago {
    display: flex;
    gap: 6px;
}

.btn-filtro {
    background: #0f172a;
    color: #cbd5e1;
    border: 1px solid #475569;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-filtro.activo {
    background: #fbbf24;
    color: #0f172a;
    border-color: #fbbf24;
}

.tabla-scroll,
.contenedor-tabla-scroll {
    overflow-x: auto;
    max-height: 520px;
}

.tabla-datos {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabla-datos th,
.tabla-datos td {
    padding: 9px 10px;
    border-bottom: 1px solid #334155;
    text-align: left;
}

.tabla-datos th {
    background: #0f172a;
    color: #fbbf24;
    position: sticky;
    top: 0;
}

.badge-codigo {
    background: #0f172a;
    color: #38bdf8;
    border: 1px solid #38bdf8;
    padding: 2px 7px;
    border-radius: 6px;
    font-family: monospace;
    font-weight: 700;
}

.badge-activa { color: #4ade80; font-weight: 700; }
.badge-ganadora { color: #fbbf24; font-weight: 700; }

/* =========================================================
   4. CHAT EN VIVO (ALTURA FIJA Y SCROLL INTERNO)
   ========================================================= */
.caja-chat-vivo {
    margin-top: 6px;
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 7px 9px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

.lista-mensajes-chat {
    height: 82px;
    max-height: 82px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.msg-chat-item {
    background: rgba(30, 41, 59, 0.92);
    border-left: 3px solid #38bdf8;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.25;
    word-break: break-word;
    flex-shrink: 0;
}

.msg-chat-item.es-admin {
    background: rgba(251, 191, 36, 0.14);
    border-left-color: #fbbf24;
}

.form-chat-vivo {
    display: flex;
    gap: 6px;
}

.form-chat-vivo input {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
}

/* =========================================================
   5. ADAPTABILIDAD RESPONSIVA GLOBAL
   ========================================================= */
@media (max-width: 960px) {
    body {
        padding: 48px 10px 10px;
    }
    .layout-taquilla {
        grid-template-columns: 1fr;
    }
    .grid-form-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .header-taquilla {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .acciones-header {
        justify-content: center;
    }
}

/* =========================================================
   6. EMOJIS GRANDES EN CARTAS TEMÁTICAS (SIN IMAGEN)
   ========================================================= */
#sorteo-carta-activa #sorteo-emoji {
    font-size: 135px !important;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.28));
    margin: 10px 0;
}

.celda-j .emoji-celda-j,
.celda-tabla .emoji-carta,
.celda-jugador .emoji-carta,
.celda-show .emoji-carta-grande {
    font-size: clamp(20px, 3.8dvh, 34px) !important;
    line-height: 1.05;
    display: block;
    margin: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
}

.celda-j .nombre-celda-j,
.celda-tabla .nombre-carta-celda,
.celda-jugador .nombre-carta-celda,
.celda-show .nombre-carta-celda {
    font-size: 9px !important;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.05;
    text-align: center;
    padding: 0 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-audit .emoji-audit {
    font-size: 46px !important;
    line-height: 1.1;
    margin: 6px 0;
}

/* =========================================================
   MAZO BOCA ABAJO CON EL REVERSO CUADRICULADO (back.jpg)
   ========================================================= */
.carta-reverso {
    background: #1e3a8a url('../../img/extendida_108/back.jpg') center / cover no-repeat !important;
    border: 2.5px solid #fbbf24;
    border-radius: 12px;
    box-shadow:
        3px 3px 0 #cbd5e1,
        6px 6px 0 #94a3b8,
        0 8px 18px rgba(0, 0, 0, 0.55);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.carta-reverso #sorteo-restantes {
    background: rgba(15, 23, 42, 0.86);
    color: #fbbf24;
    border: 1.5px solid #fbbf24;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 18px;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    z-index: 2;
}

/* =========================================================
   7. PANTALLA DE BIENVENIDA CON VIDEO Y FONDO EN LOOP
   ========================================================= */
#canvas-confeti-global {
    z-index: 215 !important;
}

#contenedor-video-fondo {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

#video-fondo-loop {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.42;
}

.velo-video-fondo {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.48) 0%, rgba(15, 23, 42, 0.86) 100%);
}

#intro-video-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #090d16;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.65s ease;
}

#intro-video-overlay.intro-desvanecer {
    opacity: 0;
    pointer-events: none;
}

#intro-video-player {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.intro-video-capa-ui {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 36px 20px 34px;
    background: linear-gradient(
        to bottom,
        rgba(9, 13, 22, 0.62) 0%,
        rgba(9, 13, 22, 0.12) 45%,
        rgba(9, 13, 22, 0.78) 100%
    );
    text-align: center;
}

.intro-video-textos h2 {
    font-size: clamp(22px, 4vw, 38px);
    color: #fbbf24;
    text-shadow: 0 3px 14px rgba(0, 0, 0, 0.85);
    margin-bottom: 6px;
}

.intro-video-textos p {
    font-size: clamp(13px, 2vw, 17px);
    color: #f8fafc;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
}

.intro-btn-saltar {
    padding: 12px 24px;
    font-size: 15px;
    border-radius: 999px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.65);
}