:root {
    --azul-bg: #2646a0;
    --azul-claro: #4976f2;
    --azul-panel: #f9fbff;
    --azul-btn: #37dac7;
    --azul-btn2: #3772ff;
    --gris-txt: #444b58;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background: url('fondo.jpg') bottom center / cover no-repeat fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.layout-main {
    display: flex;
    gap: 36px;
    background: #f4f7fe;
    border-radius: 20px;
    padding: 42px 38px 32px 38px;
    box-shadow: 0 12px 44px #16235524;
    align-items: flex-start;
}

.main-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 310px;
    width: 100%;
}

.game-title {
    font-size: 2.4rem;
    font-weight: 900;
    color: #284497;
    letter-spacing: .5px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-title img {
    width: 38px; height: 38px;
}

.game-subtitle {
    color: #3d577e;
    font-size: 1.1rem;
    margin-bottom: 23px;
}

.puzzle-container {
    border-radius: 16px;
    background: #fff;
    padding: 14px;
    box-shadow: 0 4px 18px #1b254014;
    margin-top: 3px;
    width: 100%;
}

.puzzle-grid {
    width: 100vw;
    max-width: 480px;
    aspect-ratio: 1 / 1;
    height: auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    border-radius: 10px;
    margin: 0 auto;
}

.puzzle-piece {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    cursor: pointer;
    border-radius: 8px;
    border: 2.5px solid transparent;
    position: relative;
    overflow: hidden;
    background-color: #e3e8f5;
    transition: box-shadow .15s;
    box-shadow: 0 1.5px 7px #20263d0b;
    font-family: inherit;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.puzzle-piece:hover:not(.empty) {
    border-color: var(--azul-btn);
    box-shadow: 0 3px 12px #4976f218;
}

.puzzle-piece.empty {
    background: #c3d2ef;
    opacity: 0.16;
    pointer-events: none;
}

.piece-number {
    margin: 8px;
    background: rgba(34,46,88,0.83);
    color: #fff; width: 26px; height: 26px;
    border-radius: 50%;
    font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px #2a3e7035;
}

.puzzle-piece.correct {
    border-color: #37dac7;
}

/* Panel lateral */
.side-panel {
    background: #fff;
    border-radius: 17px;
    padding: 34px 32px;
    min-width: 220px;
    box-shadow: 0 3px 24px #1b254012;
    display: flex;
    flex-direction: column;
    gap: 22px;
    align-items: left;
    justify-content: flex-start;
}

.info-item {
    margin-bottom: 14px;
}

.info-label {
    font-size: 1rem;
    color: #5771a2;
    font-weight: 500;
    margin-bottom: 2px;
    letter-spacing: .2px;
}

.info-value {
    font-size: 2.1rem;
    font-weight: 900;
    color: #2340af;
    margin-bottom: 2px;
    letter-spacing: .5px;
}

.info-estado {
    font-size: 1.13rem;
    color: #34b59b;
    font-weight: 700;
    margin-top: 9px;
    margin-bottom: 2px;
    text-align: left;
    min-height: 25px;
}

.btn-cambiar-imagen {
    background: linear-gradient(135deg, #37dac7 0%, #3772ff 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 22px;
    cursor: pointer;
    font-size: 1.09rem;
    font-weight: 700;
    box-shadow: 0 2px 10px #1b40ff15;
    letter-spacing: .5px;
    margin-top: 10px;
    transition: all 0.22s;
}
.btn-cambiar-imagen:hover {
    background: linear-gradient(135deg, #3772ff 0%, #37dac7 100%);
    transform: scale(1.05);
}

/* Modal popup */
.modal-bg {
    position: fixed;
    left: 0; top: 0;
    width: 100vw; height: 100vh;
    background: rgba(36, 45, 105, 0.60);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity .4s;
}
.modal-bg.visible { display: flex; opacity: 1; }
.modal-popup {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 14px 90px 20px rgba(55,114,255,0.22),0 0px 18px #2439ad42;
    padding: 30px 28px 22px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: modalIn .7s cubic-bezier(.23,1.35,.33,1) both;
}
@keyframes modalIn {
    0% { transform: translateY(60px) scale(.8); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-popup img {
    width: 320px; height: 320px; border-radius: 12px;
    box-shadow: 0 3px 14px #1930a622;
    margin-bottom: 18px;
    object-fit: cover;
    background: #dbefff;
}
.modal-title {
    font-size: 1.4rem; font-weight: bold; color: #2746af;
    margin-bottom: 11px; letter-spacing: 1px;
    text-align: center;
}
.btn-play-again {
    background: linear-gradient(135deg, #3772ff 40%, #27e7a9 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 1.03rem;
    font-weight: 700;
    transition: all 0.23s;
    margin-top: 6px;
    box-shadow: 0 2px 9px #1b40ff24;
    letter-spacing: .5px;
}
.btn-play-again:hover {
    background: linear-gradient(135deg, #27e7a9 0%, #3772ff 100%);
    transform: scale(1.05);
}

@media (max-width: 900px) {
    .layout-main { flex-direction: column; gap: 18px; padding: 8px; }
    .side-panel { min-width: 0; width: 98%; padding: 22px 8px;}
    .main-panel { min-width: 0;}
    .puzzle-container { padding: 4px;}
    .puzzle-grid { max-width: 98vw; }
}

@media (max-width: 500px) {
    .modal-popup img { width: 90vw; max-width: 320px; height: auto; max-height: 320px;}
}
