/* ======== ESTILO GENERAL ======== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(180deg, rgba(10,10,20,0.9), rgba(10,10,30,0.9)),
                url("../img/rompecabeza.jpg") center/cover no-repeat;
    color: #fff;
    text-align: center;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(5px);
}

h1 {
    font-size: 2.3rem;
    font-weight: 600;
    color: #FFD700;
    text-shadow: 0 0 15px #FFD700, 0 0 30px #FFAE00;
    margin-bottom: 20px;
    animation: fadeInDown 1s ease;
}

/* ======== CONTROLES ======== */
#controls {
    background: rgba(255,255,255,0.07);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(255,255,255,0.1);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

label {
    font-size: 1rem;
}

select, button {
    padding: 10px 15px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

select {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

select:focus {
    border-color: #FFD700;
}

button {
    background: linear-gradient(90deg, #FFD700, #FFAE00);
    color: #000;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255,215,0,0.4);
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255,215,0,0.7);
}

/* ======== INFO PANEL ======== */
#info-panel {
    display: flex;
    justify-content: center;
    gap: 30px;
    background: rgba(255,255,255,0.05);
    padding: 12px 25px;
    border-radius: 12px;
    font-size: 1.1rem;
    margin-bottom: 20px;
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

#info-panel strong {
    color: #FFD700;
}

/* ======== CONTENEDOR FLEX PARA TABLERO + RÉCORDS ======== */
#game-records-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
    margin: auto;
    flex-wrap: wrap;
    align-items: flex-start; /* asegura que todo se alinee arriba */
}

/* ======== ÁREA DEL JUEGO ======== */
#game-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
}

/* ======== PALETA DE PIEZAS ======== */
#palette-container {
    position: relative;
    background: rgba(20,20,30,0.7);
    padding: 20px;
    border-radius: 15px;
    width: 480px;
    box-shadow: 0 0 25px rgba(255,215,0,0.1);
    transition: all 0.3s ease;
    text-align: center;
    overflow: hidden;
    backdrop-filter: blur(6px);
}

#palette-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("../img/rompe.jpg") center/cover no-repeat;
    opacity: 0.25;
    z-index: 0;
    border-radius: 15px;
}

#palette-container h2 {
    position: relative;
    z-index: 1;
    font-size: 1.2rem;
    color: #FFD700;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #FFD700;
}

#palette {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    align-items: center;
    gap: 10px;
    padding: 10px;
    max-height: 360px;
    overflow-y: auto;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #FFD700 rgba(255, 255, 255, 0); /* Firefox */
}

/* Chrome / Edge / Safari */
#palette::-webkit-scrollbar {
    width: 6px;
}
#palette::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0);
    border-radius: 23px;
}
#palette::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #FFD700, #FFAE00);
    border-radius: 23px;
}
#palette::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #FFEA70, #FFCC00);
}

/* PIEZAS DE ROMPECABEZAS */
.piece {
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    cursor: grab;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border 0.25s ease;
    border: 2px solid rgba(255, 215, 0, 0.25);
    position: relative;
}

.piece:hover {
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(255,215,0,0.8);
    border-color: rgba(255,215,0,0.8);
}

.piece.dragging {
    opacity: 0.7;
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(255,215,0,0.6);
}

/* Piezas correctamente colocadas */
.piece.correct {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.9);
    border-color: #FFD700;
    animation: pulseGold 0.5s ease;
}

.piece.wrong {
    animation: shake 0.3s ease;
    border-color: #ff5555;
}

/* ======== TABLERO DE ROMPECABEZAS ======== */
#puzzle-container {
    display: grid;
    gap: 3px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 15px rgba(255,255,255,0.05);
    position: relative;
}

/* ======== TABLA DE RÉCORDS ======== */
#records {
    flex-shrink: 1;
    background: rgba(255, 255, 255, 0.07);
    padding: 20px 25px;
    border-radius: 20px;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.1);
    width: 370px;
    backdrop-filter: blur(6px);
    animation: fadeIn 1s ease;
    margin-top: 0; /* elimina espacio extra */
}

#records h2 {
    color: #FFD700;
    font-size: 1.4rem;
    text-shadow: 0 0 10px #FFD700;
    margin-bottom: 15px;
}

#records table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(255,255,255,0.05);
}

#records th, #records td {
    padding: 12px 15px;
    text-align: center;
    font-size: 1rem;
}

#records thead {
    background: linear-gradient(90deg, #FFD700, #FFAE00);
    color: #000;
    font-weight: 700;
}

#records tbody tr {
    transition: background 0.3s ease, transform 0.2s ease;
}

#records tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.05);
}

#records tbody tr:hover {
    background: rgba(255,215,0,0.1);
    transform: scale(1.02);
}

#records td {
    color: #fff;
}

/* ======== EFECTOS DE COLOCACIÓN ======== */
.sparkle {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: radial-gradient(circle, rgba(255,215,0,0.5) 0%, transparent 70%);
    animation: sparkleFade 0.6s ease forwards;
    pointer-events: none;
}

/* Animaciones */
@keyframes pulseGold {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes sparkleFade {
    0% { opacity: 1; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.5); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ======== RESPONSIVO ======== */
@media (max-width: 1024px) {
    #game-records-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    #records {
        width: 90%;
    }
}
#celebration-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

@media (max-width: 768px) {
    #game-area {
        flex-direction: column;
        align-items: center;
    }
    #palette-container, #puzzle-container {
        width: 90%;
        max-width: 400px;
    }
    #palette {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    }
    #info-panel {
        flex-direction: column;
        gap: 10px;
    }
}

/* Scrollbar completo */
::-webkit-scrollbar {
    width: 8px;           /* ancho de la barra vertical */
    height: 8px;          /* alto de la barra horizontal */
}

/* Parte de fondo de la barra */
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0);
    border-radius: 8px;
}

/* Parte que se mueve */
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #FFD700, #FFAE00);
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(255,215,0,0.5);
}

/* Hover sobre el thumb */
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #FFEA70, #FFCC00);
}