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

body {
    min-height: 100vh;
    font-family: Arial, sans-serif;
    background:
        radial-gradient(circle at top left, #ffeaa7, transparent 35%),
        radial-gradient(circle at bottom right, #74b9ff, transparent 35%),
        linear-gradient(135deg, #a29bfe, #55efc4);
    overflow-x: hidden;
}

.game-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-card {
    width: 100%;
    max-width: 1100px;
    background: #ffffff;
    border: 6px solid #2d3436;
    border-radius: 30px;
    padding: 26px;
    box-shadow: 10px 10px 0 #2d3436;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.eyebrow {
    font-size: 16px;
    font-weight: 900;
    color: #6c5ce7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    font-size: 42px;
    color: #2d3436;
}

.badge {
    background: #ffde59;
    border: 4px solid #2d3436;
    border-radius: 18px;
    padding: 12px 18px;
    font-weight: 900;
    font-size: 22px;
}

.intro {
    font-size: 22px;
    color: #2d3436;
    margin-bottom: 24px;
    font-weight: 700;
}

.game-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 26px;
    align-items: start;
}

.preview-box {
    background: #f1f2f6;
    border: 4px solid #2d3436;
    border-radius: 24px;
    padding: 16px;
    text-align: center;
}

.preview-box h2 {
    font-size: 26px;
    margin-bottom: 14px;
}

.preview-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 18px;
    border: 4px solid #2d3436;
    background-size: cover;
    background-position: center;
}

.puzzle-area {
    display: flex;
    justify-content: center;
}

.puzzle-grid {
    width: min(68vw, 560px);
    height: min(68vw, 560px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    background: #2d3436;
    border: 6px solid #2d3436;
    border-radius: 24px;
    overflow: hidden;
    touch-action: none;
}

.puzzle-slot {
    background: #dfe6e9;
    position: relative;
    overflow: hidden;
}

.puzzle-piece {
    width: 100%;
    height: 100%;
    background-size: 400% 400%;
    background-repeat: no-repeat;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.puzzle-piece:active {
    cursor: grabbing;
}

.puzzle-piece.dragging {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.95;
    transform: scale(1.06);
    border: 4px solid #ffde59;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

.puzzle-piece.locked {
    cursor: default;
    animation: correctPop 0.35s ease;
    filter: saturate(1.2);
}

.message {
    min-height: 50px;
    margin-top: 22px;
    text-align: center;
    font-size: 30px;
    font-weight: 900;
    color: #2d3436;
}

.message.good {
    color: #00b894;
    animation: popText 0.3s ease;
}

.message.bad {
    color: #d63031;
    animation: shakeText 0.3s ease;
}

.restart-btn {
    display: block;
    margin: 20px auto 0;
    border: 4px solid #2d3436;
    background: #6c5ce7;
    color: white;
    padding: 16px 34px;
    border-radius: 18px;
    font-size: 26px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 6px 6px 0 #2d3436;
}

.restart-btn:hover {
    transform: translateY(-2px);
}

.hidden {
    display: none;
}

.confetti {
    position: fixed;
    top: -20px;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    z-index: 10000;
    animation: fall linear forwards;
}

@keyframes correctPop {
    0% {
        transform: scale(0.85);
    }
    70% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes popText {
    0% {
        transform: scale(0.8);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes shakeText {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-8px);
    }
    50% {
        transform: translateX(8px);
    }
    75% {
        transform: translateX(-8px);
    }
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

@media (max-width: 850px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .preview-box {
        max-width: 260px;
        margin: 0 auto;
    }

    .puzzle-grid {
        width: min(90vw, 520px);
        height: min(90vw, 520px);
    }

    h1 {
        font-size: 34px;
    }

    .intro {
        font-size: 19px;
    }
}

@media (max-width: 480px) {
    .game-card {
        padding: 16px;
        border-width: 4px;
        box-shadow: 6px 6px 0 #2d3436;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
    }

    h1 {
        font-size: 30px;
    }

    .message {
        font-size: 24px;
    }
}