:root {
    --pattern-tile: clamp(46px, 13vw, 72px);
    --option-tile: clamp(74px, 21vw, 100px);
    --tile-radius: 16px;
    --tile-bg: #fffdf7;
    --tile-border: rgba(99, 102, 241, 0.35);
    --ink: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    touch-action: manipulation;
}

body {
    min-height: 100dvh;
    background:
        radial-gradient(circle at 14% 16%, rgba(34, 211, 238, 0.26), transparent 26%),
        radial-gradient(circle at 86% 80%, rgba(168, 85, 247, 0.22), transparent 30%),
        linear-gradient(150deg, #0f172a 0%, #312e81 48%, #0e7490 100%);
    color: #fff;
    font-family: 'Fredoka One', 'Nunito', cursive;
    overflow: visible;
    user-select: none;
    -webkit-user-select: none;
}

button {
    font: inherit;
}

.score-display {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    min-width: 82px;
    min-height: 44px;
    font-size: clamp(1.25rem, 4vw, 1.8rem);
    line-height: 1;
}

.star {
    display: inline-block;
    animation: score-pop 0.36s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.shape-main {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(20px, 5vh, 40px);
    padding: 96px 14px 28px;
}

.prompt-banner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 2.5vw, 14px);
    min-height: 64px;
    max-width: min(92vw, 520px);
    padding: 10px 22px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.26);
    box-shadow: 0 16px 36px rgba(2, 6, 23, 0.34);
    backdrop-filter: blur(10px);
}

.prompt-icon {
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    line-height: 1;
}

.prompt-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: clamp(1rem, 3.4vw, 1.4rem);
    line-height: 1.12;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 4px rgba(2, 6, 23, 0.4);
}

.level-badge {
    min-width: 72px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #312e81;
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    box-shadow: 0 4px 0 rgba(49, 46, 129, 0.22);
}

.pattern-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(5px, 1.6vw, 10px);
    max-width: 96vw;
}

.options-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 4vw, 26px);
}

.tile {
    border-radius: var(--tile-radius);
    background: var(--tile-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 6px 0 rgba(49, 46, 129, 0.55), 0 10px 20px rgba(2, 6, 23, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.pattern-tile {
    width: var(--pattern-tile);
    height: var(--pattern-tile);
    transition: opacity 0.22s ease, transform 0.22s ease, filter 0.22s ease;
}

.option-tile {
    width: var(--option-tile);
    height: var(--option-tile);
    cursor: pointer;
    border: 3px solid var(--tile-border);
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.18s ease;
}

.pattern-tile.is-hidden {
    opacity: 0;
    transform: scale(0.62);
    filter: blur(4px);
}

.pattern-tile.is-revealed {
    animation: reveal-tile 0.34s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.options-row {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.options-row.is-waiting {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.96);
}

.option-tile:disabled {
    cursor: default;
}

.option-tile:active,
.option-tile.pressing {
    transform: translateY(4px);
    box-shadow: 0 2px 0 rgba(49, 46, 129, 0.55), 0 5px 12px rgba(2, 6, 23, 0.3);
}

.pattern-tile.is-gap {
    background: rgba(255, 255, 255, 0.10);
    border: 3px dashed rgba(255, 255, 255, 0.6);
    box-shadow: none;
}

.pattern-tile.is-gap::after {
    content: '?';
    font-family: 'Fredoka One', cursive;
    font-size: calc(var(--pattern-tile) * 0.5);
    color: rgba(255, 255, 255, 0.85);
}

.pattern-tile.is-filled::after {
    content: '';
}

.shape-art {
    width: 86%;
    height: 86%;
    display: block;
    overflow: visible;
    filter: drop-shadow(0 4px 0 rgba(15, 23, 42, 0.14));
}

.shape-art.size-small {
    width: 56%;
    height: 56%;
}

.shape-art.size-medium {
    width: 74%;
    height: 74%;
}

.shape-art.size-large {
    width: 90%;
    height: 90%;
}

.pattern-tile .shape-art {
    filter: drop-shadow(0 3px 0 rgba(15, 23, 42, 0.12));
}

.pattern-tile.is-filled {
    background: var(--tile-bg);
    border: 3px solid #4ade80;
    box-shadow: 0 6px 0 #15803d, 0 0 22px rgba(74, 222, 128, 0.5);
}

.pattern-tile.tile-pop {
    animation: tile-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pattern-row.celebrate .pattern-tile {
    animation: tile-bounce 0.5s ease;
}

.option-tile.is-wrong {
    border-color: #f87171;
    animation: option-shake 0.42s ease;
}

.option-tile.hint-glow {
    animation: hint-glow 1.1s ease-in-out infinite;
}

@keyframes tile-pop {
    0% { transform: scale(0.2); opacity: 0; }
    60% { transform: scale(1.18); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes reveal-tile {
    0% {
        transform: scale(0.62);
        opacity: 0;
        filter: blur(4px);
    }
    70% {
        transform: scale(1.12);
        opacity: 1;
        filter: blur(0);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes tile-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-14px); }
}

@keyframes option-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@keyframes hint-glow {
    0%, 100% { box-shadow: 0 6px 0 rgba(49, 46, 129, 0.55), 0 0 0 rgba(74, 222, 128, 0); }
    50% { box-shadow: 0 6px 0 rgba(49, 46, 129, 0.55), 0 0 22px rgba(74, 222, 128, 0.8); }
}

@keyframes score-pop {
    from {
        transform: scale(0.35);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    top: -10px;
    width: 10px;
    height: 14px;
    z-index: 1000;
    pointer-events: none;
    animation-name: confetti-fall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@media (max-width: 420px) {
    :root {
        --pattern-tile: clamp(34px, 10.5vw, 58px);
        --option-tile: clamp(68px, 22vw, 92px);
    }

    .shape-main {
        padding-left: 10px;
        padding-right: 10px;
        gap: 22px;
    }

    .pattern-row {
        gap: 4px;
    }

    .prompt-banner {
        min-height: 58px;
        padding: 9px 14px;
        flex-wrap: wrap;
    }

    .level-badge {
        min-width: 66px;
        font-size: 0.76rem;
    }
}
