* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        sans-serif;
    color: #fff;
    background:
        radial-gradient(
            circle at 20% 20%,
            rgba(124, 58, 237, 0.55),
            transparent 30%
        ),
        radial-gradient(
            circle at 80% 80%,
            rgba(37, 99, 235, 0.45),
            transparent 35%
        ),
        linear-gradient(180deg, #080b1f 0%, #17153c 50%, #2b1551 100%);
}

button {
    font: inherit;
    cursor: pointer;
}

.game-wrap {
    width: min(100vw, 430px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 14px 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.game-header h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.04em;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-size: 24px;
}

.score-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.04);
}

.score-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.score-card .label {
    color: #b8b8d8;
    font-size: 12px;
    font-weight: 800;
}

.score-card strong {
    font-size: 28px;
    line-height: 1;
}

.action-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-panel button {
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    color: #fff;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
}

.action-panel button:first-child {
    background: #2563eb;
}

.board-wrap {
    padding: 8px;
    border-radius: 22px;
    background: rgba(0, 0, 0, 0.28);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
}

.board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    aspect-ratio: 1 / 1;
}

.cell {
    position: relative;
    border-radius: 9px;
    background: #0b1429;
    border: 2px solid #1c2c50;
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.03);
}

.cell.filled,
.mini-cell.filled {
    border: 2px solid rgba(255, 255, 255, 0.45);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 25%),
        linear-gradient(180deg, #ffd94a, #e69c00);
    box-shadow:
        inset 0 -4px 0 rgba(122, 68, 0, 0.35),
        inset 0 3px 0 rgba(255, 255, 255, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.25);
}

.cell.c2,
.mini-cell.c2 {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 25%),
        linear-gradient(180deg, #60a5fa, #1d4ed8);
}

.cell.c3,
.mini-cell.c3 {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 25%),
        linear-gradient(180deg, #f87171, #b91c1c);
}

.cell.c4,
.mini-cell.c4 {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 25%),
        linear-gradient(180deg, #4ade80, #15803d);
}

.cell.c5,
.mini-cell.c5 {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.7), transparent 25%),
        linear-gradient(180deg, #c084fc, #7e22ce);
}

.cell.ghost {
    outline: 2px solid rgba(255, 255, 255, 0.9);
    background: rgba(96, 165, 250, 0.35);
}

.cell.hint {
    animation: hintPulse 0.8s ease-in-out infinite alternate;
}

@keyframes hintPulse {
    from {
        outline: 2px solid rgba(255, 255, 255, 0.45);
    }
    to {
        outline: 3px solid #facc15;
    }
}

.arrow::after,
.mini-cell.arrow::after {
    content: attr(data-arrow);
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
}

.block-tray {
    min-height: 118px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    align-items: end;
    padding: 10px 0 0;
}

.block-slot {
    min-height: 105px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.03);
}

.block-slot.selected {
    border-color: #93c5fd;
    background: rgba(37, 99, 235, 0.2);
}

.block-slot.empty {
    opacity: 0.3;
}

.mini-block {
    display: grid;
    gap: 4px;
}

.mini-cell {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 7px;
}

.mini-cell.blank {
    opacity: 0;
}

.guide {
    margin: 0;
    text-align: center;
    color: #f8fafc;
    font-weight: 800;
    font-size: 15px;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.65);
}

.modal.hidden {
    display: none;
}

.modal-box {
    width: min(100%, 320px);
    padding: 26px;
    border-radius: 22px;
    text-align: center;
    background: #111827;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.modal-box h2 {
    margin: 0 0 8px;
}

.modal-box p {
    margin: 0 0 14px;
    color: #cbd5e1;
}

.modal-box strong {
    display: block;
    margin-bottom: 18px;
    font-size: 36px;
}

.modal-box button {
    width: 100%;
    height: 44px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    font-weight: 900;
    background: #2563eb;
}

@media (max-width: 380px) {
    .board {
        gap: 5px;
    }

    .cell {
        border-radius: 7px;
    }

    .mini-cell {
        width: 22px;
        height: 22px;
    }

    .game-header h1 {
        font-size: 19px;
    }
}
body,
.game-wrap,
.board,
.block-tray {
    user-select: none;
    -webkit-user-select: none;
}

.board,
.block-tray,
.block-slot,
.cell {
    touch-action: none;
}

.cell,
.block-slot {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
}

.cell.blocked {
    outline: 2px solid rgba(248, 113, 113, 0.95);
    background: rgba(239, 68, 68, 0.28);
}

.cell.clearing {
    animation: pangClear 0.23s ease-out forwards;
}

@keyframes pangClear {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    60% {
        transform: scale(1.16);
        filter: brightness(1.6);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.floating-block {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(1.08);
    filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.45));
}

.floating-block .mini-cell {
    width: 30px;
    height: 30px;
}

.block-slot {
    color: #fff;
}

.block-slot.empty {
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    font-weight: 800;
}
