@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;500;700;900&display=swap');

:root {
    --bg-dark: #0a0e17;
    --acc-gold: #fbbf24;
    --acc-gold-glow: rgba(251, 191, 36, 0.5);
    --card-bg: rgba(255, 255, 255, 0.05);
    --border-light: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body.dark-mode {
    background: radial-gradient(circle at center, #1a2336 0%, var(--bg-dark) 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* No scroll en broadcast */
    display: flex;
    flex-direction: column;
}

.broadcast-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* HEADER */
.broadcast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    border-bottom: 1px solid var(--border-light);
}

.logo-zone {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-zone i {
    font-size: 2.5rem;
    color: var(--acc-gold);
}

.glow-text {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    text-transform: none;
    letter-spacing: -0.5px;
    color: #fff;
    text-shadow: 0 0 15px var(--acc-gold-glow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.live-badge {
    background: #ef4444;
    color: white;
    font-size: 0.9rem;
    padding: 4px 10px;
    border-radius: 4px;
    animation: blink-pulse 2s infinite;
}

.sorteo-info {
    text-align: right;
}

.sorteo-info h2 {
    font-size: 1.8rem;
    color: var(--acc-gold);
    text-shadow: 0 0 10px var(--acc-gold-glow);
}

.sorteo-info p {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* MAIN STAGE */
.main-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 1200px; /* Habilitar 3D */
}

.status-message {
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-muted);
}

.blink {
    animation: blink-slow 2s infinite;
}

/* SPOTLIGHT */
.spotlight {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Quitamos el scale/opacity previo para manejarlo en la tarjeta */
}

.extraction-number {
    font-size: 1.8rem;
    font-weight: 900;
    color: #22c55e; /* Verde Lotto7 */
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

/* --- ESTRUCTURA TARJETA 3D --- */
.card-3d {
    width: 380px;
    height: 520px;
    perspective: 1000px;
    transform-style: preserve-3d;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 1s cubic-bezier(0.23, 1, 0.32, 1);
    transform-style: preserve-3d;
    transform: rotateY(90deg) scale(0.5); /* Inicialmente oculta de lado */
    opacity: 0;
}

.card-inner.reveal {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
}

.spotlight-animal {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid var(--acc-gold);
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 0 50px var(--acc-gold-glow), inset 0 0 30px rgba(251, 191, 36, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    backdrop-filter: blur(15px);
}

.spotlight-img-wrapper {
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.spotlight-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
}

.emoji-large {
    font-size: 8rem;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
}

.spotlight-details {
    text-align: center;
}

.s-numero {
    font-size: 5rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
    margin-bottom: 5px;
}

.s-nombre {
    font-size: 2.5rem;
    font-weight: 500;
    color: var(--acc-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.layout-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden; /* No scroll en el broadcast */
}

/* SIDEBAR IZQUIERDA (Grilla de Resultados) */
.results-sidebar {
    width: 520px;
    background: rgba(0,0,0,0.6);
    border-right: 1px solid var(--border-light);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.grid-header {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.extracted-grid {
    display: grid;
    /* Caben 7 bolitas por fila (7x5=35) */
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    padding-right: 5px; /* espacio para scrollbar */
}

.grid-item {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: scale(0.5);
    animation: pop-in-small 0.4s forwards;
    position: relative;
    overflow: hidden;
}

.grid-item::before {
    content: attr(data-pos);
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.7rem;
    color: var(--acc-gold);
    font-weight: bold;
    opacity: 0.8;
}

.grid-item img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.grid-emoji {
    font-size: 2rem;
}

.g-num {
    font-size: 1.2rem;
    font-weight: 900;
    color: #fff;
}

/* Scrollbar para la grid */
.extracted-grid::-webkit-scrollbar {
    width: 8px;
}
.extracted-grid::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.extracted-grid::-webkit-scrollbar-thumb {
    background: var(--acc-gold);
    border-radius: 4px;
}

/* ANIMATIONS */
@keyframes blink-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px #ef4444; }
    50% { opacity: 0.5; box-shadow: 0 0 0px #ef4444; }
}

@keyframes blink-slow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pop-in {
    0% { transform: scale(0.5) translateY(50px); opacity: 0; }
    70% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pop-in-small {
    0% { transform: scale(0) translateY(20px); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* FULLSCREEN GRID MODE (Repeticiones automáticas) */
.broadcast-container.fullscreen .results-sidebar {
    width: 100% !important;
    border-right: none;
    align-items: center; 
    padding: 15px 20px;
    background: transparent;
}
.broadcast-container.fullscreen .grid-header {
    font-size: 2.2rem;
    color: var(--acc-gold);
    text-shadow: 0 0 15px var(--acc-gold-glow);
    margin-bottom: 20px;
}
.broadcast-container.fullscreen .main-stage {
    display: none !important;
}
.broadcast-container.fullscreen .extracted-grid {
    /* minmax(0, 1fr) fuerza a que nunca desborde el ancho disponible */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    width: 100%;
    height: 100%;
    gap: 10px;
    padding: 0;
    overflow: visible; 
}
.broadcast-container.fullscreen .grid-item {
    flex-direction: row; 
    padding: 5px 10px;
    border-width: 2px;
    border-radius: 12px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 5px 10px rgba(0,0,0,0.5);
    overflow: hidden; 
}
.broadcast-container.fullscreen .grid-item img {
    width: auto;
    height: 55px; 
    margin-bottom: 0;
    max-height: 100%;
    object-fit: contain;
}
.broadcast-container.fullscreen .g-num {
    font-size: 2.8rem;
    line-height: 1;
    text-shadow: 0 3px 8px rgba(0,0,0,0.7);
    margin: 0;
}
.broadcast-container.fullscreen .grid-item::before {
    font-size: 0.9rem;
    left: 8px;
    top: 3px;
}
.broadcast-container.fullscreen .grid-emoji {
    font-size: 4rem;
}
