* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: flex-start;

    padding: 20px 0;

    font-family: Arial, sans-serif;
    background: #111827;
    color: white;
}

.game-container {
    position: relative;
    width: 90%;
    max-width: 420px;

    text-align: center;

    background: #1f2937;

    padding: 30px;

    border-radius: 20px;
}

.sound-control {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.sound-button {
    min-height: 44px;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid #4b5563;
    border-radius: 10px;
    background: #1f2937;
    color: #d1d5db;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.sound-button:hover {
    background: #374151;
}

.sound-button:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

h1 {
    margin: 0;

    font-size: 42px;
    letter-spacing: 4px;
}

.subtitle {
    color: #9ca3af;
    margin-bottom: 30px;
}

.game-info {
    display: flex;
    justify-content: space-between;

    margin-bottom: 15px;

    font-size: 16px;
}

.board {
    display: grid;

    grid-template-columns: repeat(3, 1fr);

    gap: 10px;
}

.cell {
    aspect-ratio: 1;

    border: none;
    border-radius: 12px;

    background: #374151;
    color: white;

    font-size: 28px;
    font-weight: bold;

    cursor: pointer;
}

.cell:hover {
    background: #4b5563;
}

/* Tableros 4x4: casillas cuadradas también en pantallas estrechas. */
.board-large {
    gap: 8px;
    min-width: 0;
}

.board-large .cell {
    min-width: 0;
    min-height: 0;
    width: 100%;
    padding: 0;
    font-size: clamp(20px, 5vw, 28px);
}

.cell.blocked,
.cell.blocked:hover {
    background: repeating-linear-gradient(135deg, #182130, #182130 7px, #253244 7px, #253244 9px);
    border: 2px solid #475569;
    color: #94a3b8;
    cursor: default;
    opacity: 1;
}


.game-actions,
.stage-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.game-actions button,
.stage-actions button {
    flex: 1;
}

.levels-game-button {
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: #4b5563;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.levels-game-button:hover {
    background: #6b7280;
}

.restart-button {
    width: 100%;
    margin-top: 0;
    padding: 12px;

    border: none;
    border-radius: 10px;

    background: #2563eb;
    color: white;

    font-size: 16px;
    font-weight: bold;

    cursor: pointer;
}

.restart-button:hover {
    background: #1d4ed8;
}
.cell.correcta {
    background: #16a34a;
    transform: scale(0.95);
}
.cell.incorrecta {
    background: #dc2626;
    animation: error 0.25s;
}

@keyframes error {

    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }

}
.cell.actual {
    outline: 3px solid #facc15;
    outline-offset: -3px;
}
.game-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.stat {
    flex: 1;

    display: flex;
    flex-direction: column;

    padding: 10px;

    background: #111827;
    border-radius: 10px;
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
}

.stat-label {
    margin-top: 3px;

    color: #9ca3af;
    font-size: 12px;
}

.stars {
    margin-bottom: 15px;
    font-size: 30px;
    letter-spacing: 5px;
    color: #facc15;
}

.result-screen {
    display: none;
    margin-top: 20px;
    padding: 20px;
    background: #111827;
    border-radius: 15px;
}

.result-screen h2 {
    margin-top: 0;
    margin-bottom: 10px;
}

.result-stars {
    margin-bottom: 20px;
    color: #facc15;
    font-size: 36px;
    letter-spacing: 5px;
}

.result-data {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.result-data div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    background: #1f2937;
    border-radius: 10px;
}

.result-data span {
    color: #9ca3af;
    font-size: 12px;
}

.result-data strong {
    font-size: 20px;
}

.result-buttons {
    display: flex;
    gap: 10px;
}

.result-buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

#retry-button {
    background: #4b5563;
}

#next-button {
    background: #2563eb;
}

#levels-button {
    background: #1f2937;
    color: white;
}

#levels-button:hover {
    background: #374151;
}

.level-select {
    display: none;
}

.game-screen {
    display: none;
    position: relative;
}

.celebration {
    position: absolute;
    inset: 0;
    z-index: 5;
    overflow: hidden;
    border-radius: 15px;
    pointer-events: none;
}

.celebration-message {
    position: absolute;
    top: var(--message-top);
    left: 0;
    right: 0;
    z-index: 1;
    width: max-content;
    max-width: calc(100% - 16px);
    margin: 0 auto;
    color: #fde68a;
    text-shadow: 0 0 14px #facc1566, 0 2px 4px #111827;
    font-size: clamp(26px, 7vw, 36px);
    font-weight: bold;
    animation: celebration-message 1.7s ease both;
}

.party-popper {
    position: absolute;
    top: var(--popper-top);
    width: 40px;
    height: 40px;
}

.party-popper-left { left: 8px; }
.party-popper-right { right: 8px; transform: scaleX(-1); }

.party-popper-cone {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, #c084fc 0 8px, #facc15 8px 16px, #60a5fa 16px 24px);
    clip-path: polygon(0 100%, 55% 0, 100% 45%);
    transform-origin: bottom left;
    animation: popper-burst 1.8s ease-out both;
}

.confetti-particle {
    position: absolute;
    left: 75%;
    bottom: 70%;
    width: 4px;
    height: 7px;
    border-radius: 2px;
    background: var(--confetti-color);
    animation: confetti-burst 1.65s linear both;
}

.confetti-streamer {
    width: 9px;
    height: 28px;
    background: transparent;
    border-left: 3px solid var(--confetti-color);
    border-right: 2px solid var(--confetti-color);
    border-radius: 60% 30% 60% 30%;
}

.confetti-large { width: 7px; height: 10px; }

@keyframes confetti-burst {
    0% { transform: translate3d(0, 0, 0) rotate(-35deg) scale(0.5); opacity: 0.85; animation-timing-function: ease-out; }
    40% { transform: translate3d(calc(var(--travel-x) * 0.65), var(--peak-y), 0) rotate(calc(var(--spin) * 0.4)) scale(1); opacity: 0.7; animation-timing-function: ease-in; }
    100% { transform: translate3d(var(--travel-x), var(--end-y), 0) rotate(var(--spin)) scale(0.8); opacity: 0; }
}

@keyframes popper-burst {
    0% { transform: scale(1); opacity: 1; }
    10% { transform: translate(-3px, 3px) rotate(-6deg) scale(0.9); }
    22%, 70% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

@keyframes celebration-message {
    0% { opacity: 0; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.1); }
    35%, 75% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

@media (max-width: 480px) {
    .party-popper { width: 30px; height: 30px; }
    .party-popper-left { left: 4px; }
    .party-popper-right { right: 4px; }
    .confetti-streamer { width: 7px; height: 22px; }
    .confetti-large { width: 6px; height: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .celebration-message { animation: none; }
    .party-popper { display: none; }
}

.level-select h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.level-button {
    min-height: 90px;
    padding: 14px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 8px;

    border: 2px solid #4b5563;
    border-radius: 14px;

    background: #374151;
    color: white;

    cursor: pointer;

    transition:
        transform 0.15s,
        background 0.15s,
        border-color 0.15s;
}

.level-button:hover:not(.locked) {
    transform: translateY(-2px);
    background: #4b5563;
    border-color: #60a5fa;
}

.level-number {
    font-size: 18px;
    font-weight: bold;
}

.level-stars {
    color: #facc15;
    font-size: 20px;
    letter-spacing: 2px;
}

.level-status {
    color: #60a5fa;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
}

.level-lock {
    font-size: 20px;
    opacity: 0.65;
}

.level-button.locked {
    background: #182130;
    border-color: #2b3545;
    color: #64748b;

    cursor: not-allowed;
    opacity: 0.65;
}


.level-button.locked {
    background: #1f2937;
    color: #6b7280;
    cursor: not-allowed;
}
.stars-progress {
    margin-top: -10px;
    margin-bottom: 20px;

    color: #facc15;

    font-size: 15px;
    font-weight: bold;
}
@media (max-width: 480px) {
    .game-instructions {
        font-size: 12px;
        margin-bottom: 12px;
    }
    body {
    padding: 10px 0 30px;
    }
    .game-container {
        width: calc(100% - 24px);
        padding: 20px 16px;
        border-radius: 20px;
    }

    h1 {
        font-size: 48px;
        letter-spacing: 4px;
    }

    .subtitle {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .game-info {
        font-size: 16px;
    }

    .board {
        gap: 10px;
    }

    .cell {
        min-height: 88px;
        font-size: 20px;
    }

    .result-data {
        flex-direction: column;
    }

    .result-buttons {
        flex-direction: column;
    }

    .game-actions {
        flex-direction: column;
    }

    .result-buttons button,
    .game-actions button {
        width: 100%;
    }

}

@media (max-height: 750px) {

    .game-container {
        margin: 10px auto;
        padding: 18px 16px;
    }

    h1 {
        margin-bottom: 10px;
        font-size: 46px;
    }

    .subtitle {
        margin-bottom: 18px;
    }

    .board {
        gap: 8px;
    }

    .cell {
        min-height: 76px;
    }

    .result-screen {
        margin-top: 16px;
        padding: 16px;
    }

    .result-stars {
        margin-bottom: 14px;
        font-size: 30px;
    }

    .result-data {
        gap: 8px;
        margin-bottom: 16px;
    }

    .result-buttons {
        gap: 8px;
    }

    .result-buttons button,
    .game-actions button {
        padding: 10px;
        font-size: 14px;
    }

}
@media (min-height: 800px) {

    body {
        align-items: center;
    }

}

.game-instructions {
    max-width: 320px;
    margin: 0 auto 14px;

    color: #9ca3af;

    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

.stage-select {
    display: block;
}

.stage-select h2 {
    margin-bottom: 20px;
}

.stage-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stage-button {
    width: 100%;
    min-height: 110px;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 8px;

    padding: 18px;

    border: 2px solid #4b5563;
    border-radius: 16px;

    background: #374151;
    color: white;

    cursor: pointer;
}

.stage-button:hover:not(.locked) {
    background: #4b5563;
    border-color: #60a5fa;
}

.stage-title {
    font-size: 20px;
    font-weight: bold;
}

.stage-name {
    color: #9ca3af;
    font-size: 14px;
}

.stage-stars {
    color: #facc15;
    font-size: 17px;
    font-weight: bold;
}

.stage-lock {
    font-size: 22px;
}

.stage-button.locked {
    background: #182130;
    border-color: #2b3545;
    color: #64748b;
    opacity: 0.65;
    cursor: not-allowed;
}

.coming-soon {
    width: 100%;
    min-width: 0;
    padding: 16px 12px;
    border: 1px dashed #74658f;
    border-radius: 16px;
    background: linear-gradient(135deg, #a78bfa0d, #60a5fa08);
    color: #c4b5fd;
    overflow-wrap: anywhere;
}

.coming-soon-icon {
    display: block;
    margin-bottom: 6px;
    font-size: 20px;
}

.coming-soon h3 {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 1.3;
}

.coming-soon p {
    margin: 0;
    color: #aeb6c5;
    font-size: 13px;
    line-height: 1.45;
}
