/* Estilos Generales - Redesign v5 */
:root {
    --color-primario: #083285;   /* var(--purple) -> azul rey */
    --color-secundario: #1F2937; /* var(--text-mid) -> neutro oscuro */
    --color-exito: #8C1932;      /* var(--cyan) -> vinotinto */
    --color-peligro: #dc3545;
    --color-fondo: #F5F6F8;      /* var(--bg2) -> fondo app */
    --color-borde: #E2E8F0;      /* var(--border) -> gris suave */
    --color-texto: #0B1120;      /* var(--text) -> texto oscuro */
    --color-casilla: #ffffff;    /* var(--bg) -> blanco */
    --color-casilla-vendida: #EBF1FC; /* var(--purple-pale) -> azul pálido */
    --color-casilla-pagada: #FCEBEE;  /* var(--cyan-pale) -> vinotinto pálido */
    --color-borde-pagado: #8C1932;
    --color-indicador-vacio: #E2E8F0;
    --color-indicador-lleno: #E38F27; /* dorado */
    --color-casi-gana: #FDF5E9;   /* var(--yellow-pale) -> dorado pálido */
    --sombra-caja: 0 4px 24px rgba(8, 50, 133, 0.10);
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
    margin: 0;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.contenedor-principal {
    width: 100%;
    max-width: 900px;
    background: var(--color-fondo);
    padding: 1rem;
}

h1, .subtitulo { text-align: center; }
h1 { font-family: 'Nunito', sans-serif; color: var(--color-primario); margin-bottom: 0.5rem; font-weight: 800; }
.subtitulo { font-family: 'DM Sans', sans-serif; color: var(--color-secundario); margin-top: 0; margin-bottom: 1rem; }

.info-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    background-color: var(--color-casilla);
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--sombra-caja);
    margin-bottom: 2rem;
    gap: 1rem;
    border: 1px solid var(--color-borde);
}
.info-item { text-align: center; }
.info-item h2 { margin: 0 0 0.5rem 0; font-size: 1rem; color: var(--color-secundario); font-family: 'Nunito', sans-serif; font-weight: 700; }
.info-item .valor { font-size: 1.2rem; font-weight: bold; color: var(--color-texto); }
.info-item input {
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-bottom: 2px solid var(--color-borde);
    text-align: center;
    width: 100%;
    max-width: 180px;
    background-color: transparent;
    color: var(--color-texto);
}
.info-item input:focus { outline: none; border-bottom-color: var(--color-primario); }

.configuracion-premios {
    background: var(--color-casilla); padding: 1.5rem; border-radius: 12px;
    box-shadow: var(--sombra-caja); margin-bottom: 2rem;
    border: 1px solid var(--color-borde);
}
.configuracion-premios h2 { text-align: center; color: var(--color-primario); margin-top: 0; margin-bottom: 1.5rem; border-bottom: none; font-family: 'Nunito', sans-serif; }
.form-group-inline { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1.5rem; }
.form-group-inline label { font-weight: bold; color: var(--color-secundario); }
.form-group-inline input { font-size: 1.2rem; font-weight: bold; border: 1px solid var(--color-borde); border-radius: 6px; text-align: center; width: 80px; padding: 5px; color: var(--color-texto); background-color: var(--color-casilla); }
#premios-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.premio-input-group { display: flex; flex-direction: column; text-align: center; }
.premio-input-group label { font-size: 0.9rem; color: var(--color-secundario); margin-bottom: 0.25rem; font-weight: bold; }
.premio-input-group input { font-size: 1.1rem; font-weight: bold; text-align: center; border: 1px solid var(--color-borde); border-radius: 6px; padding: 8px; width: 100%; box-sizing: border-box; color: var(--color-texto); background-color: var(--color-casilla); }

.layout-principal { display: grid; grid-template-columns: 1fr 250px; gap: 2rem; }
#tablero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    align-content: start;
    gap: 10px;
    background-color: var(--color-casilla);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--sombra-caja);
    border: 1px solid var(--color-borde);
}

.numero-casilla {
    background-color: var(--color-casilla); border: 2px solid var(--color-borde);
    border-radius: 8px; aspect-ratio: 1 / 1; display: flex;
    flex-direction: column; justify-content: center; align-items: center;
    transition: all 0.3s ease; position: relative; padding: 5px; cursor: pointer; overflow: hidden;
    color: var(--color-texto);
}
.numero-casilla.vendido { background-color: var(--color-casilla-vendida); }
.numero-casilla.pagado { background-color: var(--color-casilla-pagada); border-color: var(--color-borde-pagado); }
.numero-casilla.juego-activo { cursor: not-allowed; }

.nombre-jugador-casilla {
    font-size: 0.75rem; font-weight: bold; color: var(--color-secundario);
    height: 1.2em; text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; width: 100%; padding: 0 4px;
}
.numero-principal { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: bold; line-height: 1; font-family: 'Nunito', sans-serif; }
.indicadores-conteo { display: flex; gap: 3px; margin-top: 8px; flex-wrap: wrap; justify-content: center; width: 100%; box-sizing: border-box; }
.indicador { width: 8px; height: 8px; background-color: var(--color-indicador-vacio); border-radius: 50%; border: 1px solid var(--color-borde); transition: background-color 0.3s; }
.indicador.lleno { background-color: var(--color-indicador-lleno); border-color: #e0a800; }
.numero-casilla.casi-gana { background-color: var(--color-casi-gana); }
.numero-casilla.ganador-registrado { color: var(--color-texto); transform: scale(1.05); }
.numero-casilla.ganador-registrado .nombre-jugador-casilla { color: var(--color-secundario); }
.premio-ganado-badge {
    position: absolute; top: 4px; right: 4px; color: white;
    font-size: 0.6rem; font-weight: bold; padding: 2px 5px; border-radius: 4px; z-index: 2; display: none; 
}

.panel-lateral { display: flex; flex-direction: column; gap: 1.5rem; }
.caja-info { background: var(--color-casilla); padding: 1rem 1.5rem; border-radius: 12px; box-shadow: var(--sombra-caja); text-align: center; border: 1px solid var(--color-borde); }
.caja-info h2 { font-size: 1.2rem; color: var(--color-primario); margin-top: 0; margin-bottom: 1rem; border-bottom: 2px solid var(--color-borde); padding-bottom: 0.5rem; font-family: 'Nunito', sans-serif; }
.controles button {
    width: 100%; padding: 12px 20px; font-size: 16px; font-weight: bold;
    border: none; border-radius: 8px; cursor: pointer; transition: all 0.3s ease; margin-bottom: 10px;
    font-family: 'DM Sans', sans-serif;
}
#btn-iniciar { background: linear-gradient(135deg, var(--color-primario) 0%, var(--color-secundario) 100%); color: white; }
#btn-iniciar:hover:not(:disabled) { opacity: 0.9; }
#btn-iniciar:disabled { background: var(--color-borde); color: var(--color-secundario); cursor: not-allowed; }
#btn-reiniciar { background-color: var(--color-secundario); color: white; }
#btn-reiniciar:hover { opacity: 0.9; }

.control-group { margin-top: 1rem; text-align: center; }
.control-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; color: var(--color-secundario); font-size: 0.9rem; }
.velocidad-controles { display: flex; justify-content: center; gap: 5px; }
.btn-velocidad {
    flex-grow: 1; padding: 8px 10px; font-size: 14px; border: 1px solid var(--color-borde);
    background-color: var(--color-casilla); color: var(--color-texto); border-radius: 6px; cursor: pointer; transition: all 0.2s ease; margin-bottom: 0;
}
.btn-velocidad:hover:not(:disabled) { background-color: var(--color-fondo); }
.btn-velocidad:disabled { background-color: var(--color-fondo); cursor: not-allowed; opacity: 0.7; }
.btn-velocidad.active { background-color: var(--color-primario); color: white; border-color: var(--color-primario); }

#numero-actual-display { font-size: 4rem; font-weight: bold; color: var(--color-exito); line-height: 1; min-height: 60px; margin-bottom: 0.5rem; font-family: 'Nunito', sans-serif; }

#lista-ganadores { text-align: left; min-height: 40px; max-height: 200px; overflow-y: auto; }
.ganador-item {
    background-color: var(--color-fondo); border-left: 5px solid var(--color-primario); padding: 10px;
    border-radius: 4px; margin-bottom: 8px; font-size: 0.85rem; transition: background-color 0.3s ease;
    color: var(--color-texto);
}
.ganador-item .puesto { font-weight: bold; color: var(--color-texto); display: block; margin-bottom: 4px; }
.ganador-item .premio { font-weight: bold; color: var(--color-exito); }

/* Estados de la casilla durante el juego */
.numero-casilla.casi-gana {
    background-color: var(--color-casi-gana) !important;
    border-color: #ffc107 !important;
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.2) inset !important;
}

.numero-casilla.ganador-destacado {
    background-color: var(--color-casilla-pagada) !important;
    border-color: var(--color-borde-pagado) !important;
    box-shadow: 0 0 15px rgba(0, 191, 165, 0.25) inset !important;
}

#historial-numeros {
    display: flex; flex-wrap: wrap; gap: 10px; padding: 10px;
    max-height: 60px; overflow-y: auto; border: 1px solid var(--color-borde); border-radius: 8px; align-content: flex-start;
}
.numero-historial {
    background-color: var(--color-casilla); border: 1px solid var(--color-borde); color: var(--color-texto); padding: 5px 10px;
    border-radius: 20px; font-weight: bold; white-space: nowrap; display: flex; align-items: center; gap: 8px;
}
.numero-historial .turno {
    font-weight: normal; font-size: 0.8rem; color: var(--color-primario); background-color: var(--color-casilla-vendida);
    border-radius: 50%; width: 22px; height: 22px; display: inline-flex; justify-content: center; align-items: center;
}
.tabla-jugadores-container { margin-top: 2rem; background-color: var(--color-casilla); padding: 1.5rem; border-radius: 12px; box-shadow: var(--sombra-caja); border: 1px solid var(--color-borde); }
#tabla-jugadores { width: 100%; border-collapse: collapse; }
#tabla-jugadores th, #tabla-jugadores td { padding: 12px; border-bottom: 1px solid var(--color-borde); text-align: left; vertical-align: middle; }
#tabla-jugadores th { background-color: var(--color-fondo); color: var(--color-secundario); font-family: 'Nunito', sans-serif; font-weight: 700; }
#tabla-jugadores tr:last-child td { border-bottom: none; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(26,16,51,0.5);
    display: none; justify-content: center; align-items: center; z-index: 5000;
    backdrop-filter: blur(8px);
}
.modal { background-color: var(--color-casilla); padding: 2rem; border-radius: 12px; width: 90%; max-width: 450px; text-align: center; border: 1px solid var(--color-borde); box-shadow: var(--sombra-caja); color: var(--color-texto); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; text-align: left; }
.modal-header h2 { margin: 0; font-family: 'Nunito', sans-serif; color: var(--color-primario); font-weight: 800; }
.modal-close { font-size: 1.5rem; cursor: pointer; border: none; background: none; color: var(--color-secundario); }
.modal-close:hover { color: var(--color-primario); }
.modal-body .form-group { margin-bottom: 1rem; text-align: left; }
.modal-body label { display: block; margin-bottom: 0.5rem; font-weight: bold; color: var(--color-secundario); }
.modal-body input[type="text"], .modal-body input[type="tel"] { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--color-borde); box-sizing: border-box; background-color: var(--color-fondo); color: var(--color-texto); }
#confirm-modal-body p { font-size: 1.1rem; margin-top: 0; }
.modal-footer { display: flex; justify-content: flex-end; margin-top: 1.5rem; gap: 1rem;}
.modal-footer.center { justify-content: center; }
.modal-footer button { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; font-weight: bold; font-family: 'DM Sans', sans-serif; }
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--color-secundario); }

/* --- ESTILOS MODIFICADOS PARA LA BOLA DE SORTEO --- */
.bola-sorteo-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}
.bola-sorteo-overlay.visible { display: flex; }
.bola-sorteo-overlay.ocultando { animation: fadeOut 0.5s ease-in forwards; }
.bola {
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Usamos la imagen como fondo */
    background-image: url('bola.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    border: none;
    box-shadow: none;
    opacity: 0.95;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.bola #bola-numero {
    color: black;
    font-size: 7rem;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255,255,255,0.8); /* Sombra para mejor legibilidad */
}

#fireworks-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3000; overflow: hidden;
}
.firework {
    position: absolute; width: 4px; height: 4px; background-color: #fff; border-radius: 50%;
    animation: firework-fly 1s cubic-bezier(0.6, 0.04, 0.98, 0.335) forwards;
}
.particle {
    position: absolute; top:0; left: 0; width: 6px; height: 6px; border-radius: 50%; opacity: 0;
    animation: explode 0.8s ease-out forwards;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes zoomIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes firework-fly { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-80vh); opacity: 0.5; } }
@keyframes explode { 0% { transform: scale(0); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes confettiFall { 
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@media (max-width: 900px) {
    .layout-principal { grid-template-columns: 1fr; }
    .panel-lateral { display: grid; grid-template-columns: 1fr 1fr; align-items: flex-start; gap: 1rem; }
}
@media (max-width: 600px) {
    body { padding: 1rem; }
    .panel-lateral { grid-template-columns: 1fr; }
    #tablero { gap: 8px; padding: 1rem; grid-template-columns: repeat(auto-fit, minmax(65px, 1fr)); }
    .indicador { width: 7px; height: 7px; gap: 3px; }
    .nombre-jugador-casilla { font-size: 0.65rem; }
    .numero-principal { font-size: clamp(1.2rem, 4vw, 1.8rem); }
    .bola { width: 220px; height: 220px; }
    .bola #bola-numero { font-size: 7rem; }
}
