.tetris-layout {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(15rem, 19rem);
    gap: 1.5rem;
    align-items: start;
}

.tetris-board-wrap {
    display: flex;
    justify-content: center;
    overflow: auto;
    max-width: 100%;
}

.tetris-board {
    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    width: min(100%, 360px);
    aspect-ratio: 1 / 2;
    padding: 4px;
    gap: 2px;
    background: #cbd5e1;
    border: 2px solid #94a3b8;
    border-radius: 4px;
}

.tetris-cell {
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 2px;
    background: #f1f5f9;
}

.tetris-cell.filled {
    border-color: #1e293b;
    box-shadow: inset 0 0 0 2px rgb(255 255 255 / 18%);
}

.tetris-next {
    display: grid;
    grid-template-columns: repeat(4, 24px);
    grid-template-rows: repeat(4, 24px);
    gap: 2px;
}

.tetris-mini-cell {
    border-radius: 2px;
    background: var(--card-border);
}

.tetris-panel {
    padding: 1rem;
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    background: var(--card-bg);
}

.tetris-panel li + li {
    margin-top: 0.35rem;
}

.tetris-panel kbd {
    min-width: 1.5rem;
    display: inline-block;
    text-align: center;
}

.tetris-touch-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(3rem, 1fr));
    gap: 0.5rem;
}

.tetris-touch-controls [data-action="rotate-ccw"] {
    grid-column: 1;
}

.tetris-touch-controls [data-action="rotate-cw"] {
    grid-column: 3;
}

.tetris-name {
    width: min(18rem, 100%);
}

.tetris-cell.block-I,
.tetris-mini-cell.block-I { background: #38bdf8; }
.tetris-cell.block-O,
.tetris-mini-cell.block-O { background: #facc15; }
.tetris-cell.block-T,
.tetris-mini-cell.block-T { background: #c084fc; }
.tetris-cell.block-S,
.tetris-mini-cell.block-S { background: #4ade80; }
.tetris-cell.block-Z,
.tetris-mini-cell.block-Z { background: #fb7185; }
.tetris-cell.block-J,
.tetris-mini-cell.block-J { background: #60a5fa; }
.tetris-cell.block-L,
.tetris-mini-cell.block-L { background: #fb923c; }

[data-bs-theme="dark"] .tetris-board {
    background: #0f172a;
    border-color: #475569;
}

[data-bs-theme="dark"] .tetris-cell {
    border-color: #334155;
    background: #172033;
}

[data-bs-theme="dark"] .tetris-cell.filled {
    border-color: #e2e8f0;
}

[data-bs-theme="dark"] .tetris-cell.block-I,
[data-bs-theme="dark"] .tetris-mini-cell.block-I { background: #0369a1; }
[data-bs-theme="dark"] .tetris-cell.block-O,
[data-bs-theme="dark"] .tetris-mini-cell.block-O { background: #a16207; }
[data-bs-theme="dark"] .tetris-cell.block-T,
[data-bs-theme="dark"] .tetris-mini-cell.block-T { background: #7e22ce; }
[data-bs-theme="dark"] .tetris-cell.block-S,
[data-bs-theme="dark"] .tetris-mini-cell.block-S { background: #15803d; }
[data-bs-theme="dark"] .tetris-cell.block-Z,
[data-bs-theme="dark"] .tetris-mini-cell.block-Z { background: #be123c; }
[data-bs-theme="dark"] .tetris-cell.block-J,
[data-bs-theme="dark"] .tetris-mini-cell.block-J { background: #1d4ed8; }
[data-bs-theme="dark"] .tetris-cell.block-L,
[data-bs-theme="dark"] .tetris-mini-cell.block-L { background: #c2410c; }

@media (max-width: 760px) {
    .tetris-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .tetris-side {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
        gap: 0.75rem;
    }
}
