/* ======= Estilo general ======= */
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #e8f0ff, #f4f4f9);
    margin: 0;
    padding: 10px; /* Padding general para evitar que el contenido toque los bordes */
    min-height: 100vh;
    box-sizing: border-box; /* Asegura que padding y borde no afecten el ancho total */
    overflow-x: hidden; /* Evita el scroll horizontal no deseado */
}

h1 {
    color: #004085;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    margin-top: 20px;
}

main {
    width: 100%;
    max-width: 800px; /* Limitar el ancho del contenido principal en pantallas grandes */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ======= Controles ======= */
.controles {
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap; /* Permite que los elementos pasen a la siguiente línea */
    gap: 15px;
    align-items: center;
    justify-content: space-around; /* Distribución flexible del espacio */
    width: 100%; /* Ocupa el ancho completo de 'main' */
    max-width: 550px;
    background-color: #ffffffcc;
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    box-sizing: border-box; 
}

.controles label {
    font-weight: bold;
    color: #333;
}

.controles select, 
.controles button,
#donar-btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 1; /* Permite que crezcan para ocupar el espacio */
    min-width: 120px; /* Mínimo para que el texto sea legible */
    text-align: center;
    text-decoration: none; /* Asegura que el enlace de donación no tenga subrayado */
}

/* ======= Botón Reiniciar ======= */
#reiniciar {
    background-color: #28a745;
    color: white;
    border: none;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}

#reiniciar:hover {
    background-color: #1e7e34;
    transform: scale(1.05);
}

/* --- ESTILOS PARA EL BOTÓN DE DONACIONES --- */
#donar-btn {
    display: inline-block;
    background-color: #e54d60; /* Color llamativo (rojo/rosa) */
    color: white !important;
    border: none;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}

#donar-btn:hover {
    background-color: #c72c41; /* Color más oscuro al pasar el ratón */
    transform: scale(1.05);
}

/* ======= Tablero ======= */
#juego-tablero {
    display: grid;
    grid-template-columns: repeat(7, 70px);
    grid-template-rows: repeat(6, 70px);
    background-color: #007bff;
    border: 8px solid #0056b3;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    padding: 10px;
    margin-top: 15px;
}

/* ======= Celdas ======= */
.celda {
    width: 70px;
    height: 70px;
    background-color: #ffffff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.celda:hover {
    transform: translateY(-3px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

/* ======= Fichas ======= */
.ficha {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.2);
    animation: drop 0.35s ease-out forwards;
}

.jugador-1 {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c70000);
}

.jugador-2 {
    background: radial-gradient(circle at 30% 30%, #ffe066, #e0a800);
}

/* ======= Mensaje de estado ======= */
#mensaje {
    margin-top: 25px;
    font-size: 1.4em;
    font-weight: bold;
    color: #333;
    background-color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

/* ======= Animaciones ======= */
@keyframes drop {
    0% {
        transform: translateY(-400%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ======= Adaptación a pantallas pequeñas (Mobile Responsiveness) ======= */
@media (max-width: 600px) {
    /* Encabezado */
    h1 {
        font-size: 1.4em;
        text-align: center;
    }
    
    /* Controles */
    .controles {
        padding: 10px; 
        gap: 10px; /* Reducir el espacio entre elementos */
        max-width: 100%;
    }

    /* Tablero */
    #juego-tablero {
        /* Reducir el tamaño para que las 7 columnas quepan en un móvil */
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(6, 45px);
        padding: 6px;
        border: 4px solid #0056b3; 
        /* Aseguramos que el tablero no desborde si el dispositivo es estrecho */
        margin-left: auto;
        margin-right: auto;
    }

    .celda {
        width: 45px;
        height: 45px;
    }

    .ficha {
        width: 38px;
        height: 38px;
    }

    #mensaje {
        font-size: 1.1em;
    }
}