/* Estilos Generales */
:root {
    --color-primario: #0d6efd;
    --color-secundario: #6c757d;
    --color-exito: #198754;
    --color-peligro: #dc3545;
    --color-fondo: #f0f2f5;
    --color-borde: #dee2e6;
    --color-texto: #212529;
    --color-casilla: #ffffff;
    --color-casilla-vendida: #e9ecef;
    --color-casilla-pagada: #e9f7ef;
    --color-borde-pagado: #198754;
    --color-indicador-vacio: #e9ecef;
    --color-indicador-lleno: #ffc107;
    --color-casi-gana: #fffa6d;
    --sombra-caja: 0 6px 12px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, 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 { color: var(--color-primario); margin-bottom: 0.5rem; }
.subtitulo { 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: #fff;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: var(--sombra-caja);
    margin-bottom: 2rem;
    gap: 1rem;
}
.info-item { text-align: center; }
.info-item h2 { margin: 0 0 0.5rem 0; font-size: 1rem; color: var(--color-secundario); }
.info-item .valor { font-size: 1.2rem; font-weight: bold; }
.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;
}
.info-item input:focus { outline: none; border-bottom-color: var(--color-primario); }

.configuracion-premios {
    background: white; padding: 1.5rem; border-radius: 12px;
    box-shadow: var(--sombra-caja); margin-bottom: 2rem;
}
.configuracion-premios h2 { text-align: center; color: var(--color-primario); margin-top: 0; margin-bottom: 1.5rem; border-bottom: none; }
.form-group-inline { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1.5rem; }
.form-group-inline label { font-weight: bold; }
.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; }
#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; }

.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: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--sombra-caja);
}

.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;
}
.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; }
.indicadores-conteo { display: flex; gap: 4px; margin-top: 8px; }
.indicador { width: 10px; height: 10px; background-color: var(--color-indicador-vacio); border-radius: 50%; border: 1px solid #ccc; 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: white; padding: 1rem 1.5rem; border-radius: 12px; box-shadow: var(--sombra-caja); text-align: center; }
.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; }
.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;
}
#btn-iniciar { background-color: var(--color-primario); color: white; }
#btn-iniciar:hover:not(:disabled) { background-color: #0b5ed7; }
#btn-iniciar:disabled { background-color: #a0c7ff; cursor: not-allowed; }
#btn-reiniciar { background-color: var(--color-secundario); color: white; }
#btn-reiniciar:hover { background-color: #5a6268; }

.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: #fff; color: var(--color-texto); border-radius: 6px; cursor: pointer; transition: all 0.2s ease; margin-bottom: 0;
}
.btn-velocidad:hover:not(:disabled) { background-color: #f0f2f5; }
.btn-velocidad:disabled { background-color: #e9ecef; 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; }

#lista-ganadores { text-align: left; min-height: 40px; max-height: 200px; overflow-y: auto; }
.ganador-item {
    background-color: #f8f9fa; border-left: 5px solid #6c757d; padding: 10px;
    border-radius: 4px; margin-bottom: 8px; font-size: 0.85rem; transition: background-color 0.3s ease;
}
.ganador-item .puesto { font-weight: bold; color: #212529; display: block; margin-bottom: 4px; }
.ganador-item .premio { font-weight: bold; color: var(--color-exito); }

#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: #ffffff; 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: #e7f1ff;
    border-radius: 50%; width: 22px; height: 22px; display: inline-flex; justify-content: center; align-items: center;
}
.tabla-jugadores-container { margin-top: 2rem; background-color: #fff; padding: 1.5rem; border-radius: 12px; box-shadow: var(--sombra-caja); }
#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: #f8f9fa; color: var(--color-secundario); }
#tabla-jugadores tr:last-child td { border-bottom: none; }

.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6);
    display: none; justify-content: center; align-items: center; z-index: 1000;
}
.modal { background-color: #fff; padding: 2rem; border-radius: 12px; width: 90%; max-width: 450px; text-align: center; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; text-align: left; }
.modal-header h2 { margin: 0; }
.modal-close { font-size: 1.5rem; cursor: pointer; border: none; background: none; }
.modal-body .form-group { margin-bottom: 1rem; text-align: left; }
.modal-body label { display: block; margin-bottom: 0.5rem; }
.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; }
#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; }
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; }

/* --- ESTILOS MODIFICADOS PARA LA BOLA DE SORTEO --- */
.bola-sorteo-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); display: none; justify-content: center;
    align-items: center; z-index: 2000; 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;
    /* Quitamos los estilos que creaban el círculo anterior */
    background-color: transparent;
    border: none;
    box-shadow: none;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.bola #bola-numero {
    color: black;
    font-size: 7rem;
    font-weight: bold;
    text-shadow: 0 0 13px rgba(0,0,0,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; } }

@media (max-width: 900px) {
    .layout-principal { grid-template-columns: 1fr; }
    .panel-lateral { order: -1; display: grid; grid-template-columns: 1fr 1fr; align-items: flex-start; }
}
@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; }
}
