.tetris-frame {
    --board-h: min(calc(100svh - 150px), 700px);
    width: fit-content;
    max-width: calc(100% - 32px);
}

.tetris-layout {
    display: grid;
    grid-template-columns: 150px calc(var(--board-h) / 2) 150px;
    grid-template-areas: "hold board next" "stats board .";
    grid-template-rows: auto 1fr;
    column-gap: 18px;
    row-gap: 18px;
    align-items: start;
    justify-content: center;
}

.tetris-hold {
    grid-area: hold;
}

.tetris-next {
    grid-area: next;
}

.tetris-stats {
    grid-area: stats;
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 0;
}

.tetris-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 0 0 12px;
}

.tetris-board {
    grid-area: board;
    width: 100%;
    aspect-ratio: 1 / 2;
}

.tetris-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tetris-panel .arcade-label {
    font-family: var(--g-font-mono);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--g-ink-3);
}

.tetris-panel canvas {
    display: block;
    width: 100%;
    background: var(--g-canvas);
    border: 1px solid var(--g-rule-strong);
}

.tetris-hold canvas {
    aspect-ratio: 5 / 4;
}

.tetris-next canvas {
    aspect-ratio: 5 / 13;
}

.tetris-pad {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    width: min(100%, 560px);
    margin: 12px auto 0;
}

body.tool-page .tetris-pad .arcade-btn {
    min-height: 50px;
    padding: 0;
}

.tetris-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (pointer: coarse) {
    .tetris-frame {
        --board-h: min(calc(100svh - 230px), 700px);
    }
}

@media (max-width: 899px) {
    .tetris-frame {
        --board-h: min(calc(100svh - 262px), 640px);
        width: calc(100% - 20px);
        max-width: none;
        padding: 10px;
    }

    .tetris-layout {
        grid-template-columns: 58px 1fr 58px;
        grid-template-areas: "hold stats next" "board board board" "pause pause pause";
        grid-template-rows: auto auto auto;
        column-gap: 10px;
        row-gap: 10px;
        align-items: center;
    }

    .tetris-stats {
        grid-template-columns: 1fr 1fr;
    }

    .tetris-board {
        width: calc(var(--board-h) / 2);
        max-width: 100%;
        justify-self: center;
    }

    .tetris-next canvas {
        aspect-ratio: 5 / 4;
    }

    .tetris-board .arcade-card {
        padding: 12px 10px 10px;
    }

    .tetris-board .arcade-copy,
    .tetris-board .arcade-hint {
        display: none;
    }

    .tetris-board .arcade-card h2 {
        margin-bottom: 10px;
        font-size: 1.25rem;
    }

    .tetris-board .arcade-seg {
        margin-bottom: 10px;
    }

    .tetris-board .arcade-seg label {
        min-height: 36px;
        padding: 0 2px;
        font-size: 0.56rem;
        letter-spacing: 0.04em;
    }

    .tetris-board .arcade-btn {
        width: 100%;
        padding: 0 8px;
    }

    .tetris-stats dd {
        font-size: 1rem;
    }

    .tetris-stats {
        gap: 2px 12px;
    }

    .arcade-lead,
    .arcade-keys {
        display: none;
    }

    .arcade-intro {
        margin-bottom: 16px;
    }
}

@media (max-width: 899px) and (max-height: 640px) {
    .tetris-frame {
        --board-h: min(calc(100svh - 252px), 640px);
    }

    body.tool-page .tetris-pad .arcade-btn {
        min-height: 44px;
    }
}

.tetris-frame.is-fullscreen {
    --board-h: min(calc(100dvh - 110px), 900px);
    width: auto;
}

.tetris-frame.is-fullscreen .tetris-bar,
.tetris-frame.is-fullscreen .tetris-layout {
    width: 100%;
    max-width: 760px;
}

@media (pointer: coarse), (max-width: 899px) {
    .tetris-frame.is-fullscreen {
        --board-h: min(calc(100dvh - 240px), 900px);
    }

    .tetris-frame.is-fullscreen .tetris-layout {
        max-width: none;
    }
}
