/* ==========================================================================
   Snake page

   Loaded after styles.css and built from its tokens and pieces (the shell,
   eyebrows, chips, the spec list), so the game reads as one more page of
   the site rather than an embed dropped into it.
   ========================================================================== */

/* Several elements below set their own display, which beats the browser's
   built-in rule for [hidden]; main.js toggles them with the attribute. */
[hidden] {
    display: none !important;
}

.game {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.game-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 24px;
}

.game-heading {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-lede {
    grid-area: lede;
    max-width: var(--measure);
    color: var(--paper-dim);
    font-size: clamp(1rem, 2vw, 1.1rem);
    line-height: 1.62;
}

/* --------------------------------------------------------------------------
   Mode switch: a two-way segmented control. The pressed half takes the
   ochre fill, since choosing a mode is the page's first interaction.
   -------------------------------------------------------------------------- */

.mode-switch {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: rgba(18, 29, 34, 0.82);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

.mode-button {
    padding: 9px 18px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--paper-dim);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mode-button:hover {
    color: var(--paper);
}

.mode-button[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-ink);
}

/* --------------------------------------------------------------------------
   Panel: the board with its description, HUD and controls. On phones it is
   one column with the stats just above the board and the description
   moved below it, so the stats and the whole board fit on screen together.
   On wide screens everything but the board moves to a column beside it,
   which starts the board high enough on the page to fit a laptop screen,
   and the player's own stats sit under the board, where there is room.
   -------------------------------------------------------------------------- */

.game-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "hud"
        "board"
        "controls"
        "perks"
        "scores"
        "stats"
        "lede";
    gap: 14px;
}

@media (min-width: 880px) {
    .game-panel {
        grid-template-columns: minmax(0, 620px) minmax(220px, 1fr);
        grid-template-rows: auto auto auto auto 1fr auto;
        grid-template-areas:
            "board lede"
            "board hud"
            "board controls"
            "board perks"
            "board scores"
            "stats scores";
        column-gap: 28px;
        align-items: start;
    }
}

.hud {
    grid-area: hud;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 12px 18px;
    padding: 14px 18px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: rgba(18, 29, 34, 0.82);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

@media (min-width: 880px) {
    .hud {
        grid-template-columns: repeat(3, 1fr);
    }

    .game-lede {
        font-size: 0.98rem;
    }
}

.hud-wide {
    grid-column: 1 / -1;
}

.hud dt {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--paper-faint);
}

.hud dd {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    color: var(--paper);
}

.hud-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--contour);
}

/* The slot holds the board's place in the panel's grid. Outside full screen
   it is a plain wrapper; full screen (below) measures the board against it. */
.board-slot {
    grid-area: board;
    min-width: 0;
}

/* The board keeps to the window's height as well as its width, so the
   whole thing stays on screen while playing on a short laptop display. */
.board {
    position: relative;
    width: 100%;
    max-width: min(620px, calc(100vh - 48px));
    max-width: min(620px, calc(100svh - 48px));
    margin-inline: auto;
    aspect-ratio: 1;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: rgba(9, 16, 19, 0.82);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: border-color 0.2s ease;
}

@media (min-width: 880px) {
    .board {
        margin-inline: 0;
    }
}

.board:focus-within {
    border-color: var(--rule-strong);
}

/* Swipes on the board must never scroll the page. */
#board-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#board-canvas:focus-visible {
    outline: none;
}

/* --------------------------------------------------------------------------
   Menus drawn over the board: start, pause, level, draft and game over.
   -------------------------------------------------------------------------- */

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overflow-y: auto;
    background: rgba(12, 19, 23, 0.74);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    touch-action: none;
}

/* Only a menu taller than the board lets a vertical drag scroll it; any
   other menu takes swipes as steering, which starts the game. */
.overlay.is-scrollable {
    touch-action: pan-y;
}

.overlay-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    margin: auto;
    text-align: center;
}

.overlay-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5vw, 2.2rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

.overlay-text {
    color: var(--paper-dim);
    font-size: 0.95rem;
    line-height: 1.55;
    text-wrap: pretty;
}

.overlay-hint {
    color: var(--paper-faint);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
}

.overlay-quote {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 4px 0;
}

.overlay-quote p {
    font-family: var(--font-display);
    font-size: clamp(1.05rem, 3vw, 1.3rem);
    font-weight: 600;
    line-height: 1.25;
    color: var(--accent);
    text-wrap: balance;
}

.overlay-quote cite {
    font-style: normal;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--paper-faint);
}

.overlay-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 22px;
    margin: 4px 0;
}

.overlay-stats dt {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--paper-faint);
}

.overlay-stats dd {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.overlay-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
}

.overlay-button,
.control-button {
    padding: 11px 20px;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: rgba(18, 29, 34, 0.9);
    color: var(--paper);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.overlay-button:hover,
.control-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-bright);
}

.overlay-button.is-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
}

.overlay-button.is-primary:hover {
    background: var(--accent-bright);
    color: var(--accent-ink);
    transform: translateY(-1px);
}

.overlay-badge {
    margin-top: -2px;
}

/* Rarity tiers (rarity.js), one colour each, as --rarity and the same colour
   as an RGB triple for translucent fills. rarity.js holds the same values for
   the canvas; tests/snake/rarity.test.js fails if the two drift apart. */
.rarity-common {
    --rarity: #c9d3d6;
    --rarity-rgb: 201, 211, 214;
}

.rarity-uncommon {
    --rarity: #6fb5a4;
    --rarity-rgb: 111, 181, 164;
}

.rarity-rare {
    --rarity: #6aa6e8;
    --rarity-rgb: 106, 166, 232;
}

.rarity-epic {
    --rarity: #a98bf0;
    --rarity-rgb: 169, 139, 240;
}

.rarity-legendary {
    --rarity: #f3c873;
    --rarity-rgb: 243, 200, 115;
}

.rarity-cursed {
    --rarity: #ec6a7e;
    --rarity-rgb: 236, 106, 126;
}

/* Draft cards: the three upgrades on offer after a cleared level. */
.draft-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}

.draft-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 14px;
    border: 1px solid var(--rule-strong);
    border-radius: 12px;
    background: rgba(18, 29, 34, 0.94);
    color: var(--paper);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.draft-card:hover,
.draft-card:focus-visible {
    border-color: var(--accent);
    background: rgba(22, 36, 42, 0.98);
    transform: translateY(-2px);
}

.draft-meta {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--contour);
}

.draft-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
}

.draft-text {
    color: var(--paper-dim);
    font-size: 0.86rem;
    line-height: 1.45;
}

/* A card's border, and the tier named in its meta line, wear its tier's
   colour. Every tier colour clears 4.5:1 against the card, so the name can be
   set in it; the name is always there as text too, so colour is never the
   only signal. */
.draft-card[class*="rarity-"] {
    border-color: rgba(var(--rarity-rgb), 0.5);
}

.draft-card[class*="rarity-"]:hover,
.draft-card[class*="rarity-"]:focus-visible {
    border-color: var(--rarity);
}

.draft-tier {
    color: var(--rarity, var(--contour));
}

.draft-card.rarity-epic,
.draft-card.rarity-legendary {
    box-shadow: 0 0 18px rgba(var(--rarity-rgb), 0.16);
}

/* Legendary cards catch the light: a soft band sweeps across them. */
.draft-card.rarity-legendary {
    background-image: linear-gradient(110deg, transparent 40%, rgba(var(--rarity-rgb), 0.12) 50%, transparent 60%);
    background-size: 250% 100%;
    animation: rarity-shimmer 3.2s linear infinite;
}

@keyframes rarity-shimmer {
    from {
        background-position: 150% 0;
    }

    to {
        background-position: -100% 0;
    }
}

/* A curse's price, under what it gives. */
.draft-cost {
    color: var(--rarity);
    font-size: 0.86rem;
    line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
    .draft-card.rarity-legendary {
        animation: none;
    }
}

/* --------------------------------------------------------------------------
   Controls under the HUD, and the run's upgrades
   -------------------------------------------------------------------------- */

.game-controls {
    grid-area: controls;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.control-button {
    flex: 1 1 auto;
}

.control-button:disabled {
    color: var(--paper-faint);
    border-color: var(--rule);
    cursor: default;
}

#ability-button:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.perk-chips {
    grid-area: perks;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    list-style: none;
}

.game-panel > .perk-chips {
    justify-content: flex-start;
}

/* Each upgrade in the HUD shows what it does on hover, tap or focus. The
   reminder hangs under the whole list rather than its own chip, so it is never
   wider than the column and can't run off the edge of the screen. */
.game-panel > .perk-chips {
    position: relative;
}

.perk-chip {
    cursor: help;
    transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

/* The run's upgrades wear their tier's colour. Declared before .is-spent,
   which has the same specificity, so a spent chip still greys out. */
.chip[class*="rarity-"] {
    border-color: rgba(var(--rarity-rgb), 0.45);
    background: rgba(var(--rarity-rgb), 0.12);
    color: var(--rarity);
}

/* An upgrade used up for now (Hardened Scales' shields this level, the last
   Second Wind, Stonewalker's time, Burrow while it recharges). The reminder
   inside keeps its full colour. */
.perk-chip.is-spent {
    border-color: var(--rule);
    background: transparent;
    color: var(--paper-faint);
}

.perk-chip.is-spent .perk-label {
    text-decoration: line-through;
    text-decoration-color: rgba(233, 239, 241, 0.25);
}

.perk-chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.perk-tip {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 5;
    padding: 10px 12px;
    border: 1px solid var(--rule-strong);
    border-radius: 10px;
    background: var(--ink-raised);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 0.86rem;
    font-weight: 400;
    letter-spacing: normal;
    line-height: 1.5;
    text-transform: none;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s;
}

.perk-chip:hover .perk-tip,
.perk-chip:focus .perk-tip {
    opacity: 1;
    visibility: visible;
}

/* The chip under the pointer wins over one left focused. */
.perk-chips:hover .perk-chip:not(:hover) .perk-tip {
    opacity: 0;
    visibility: hidden;
}

/* --------------------------------------------------------------------------
   The popup for anyone caught faking a score or sending a bot
   (leaderboard.js). A native modal dialog, dressed as one of the menus.
   -------------------------------------------------------------------------- */

.busted {
    /* The site's reset zeroes margins, which is what centres a modal. */
    margin: auto;
    width: min(440px, calc(100vw - 32px));
    padding: 28px 24px 24px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--ink-raised);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    color: var(--paper);
}

.busted::backdrop {
    background: rgba(12, 19, 23, 0.8);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.busted .overlay-button {
    margin-top: 8px;
}

@media (prefers-reduced-motion: no-preference) {
    .busted[open] {
        animation: busted-wobble 0.55s ease-out;
    }
}

@keyframes busted-wobble {
    0% {
        transform: scale(0.85);
        opacity: 0;
    }
    35% {
        transform: scale(1.03) rotate(-2.5deg);
        opacity: 1;
    }
    60% {
        transform: rotate(1.5deg);
    }
    80% {
        transform: rotate(-0.5deg);
    }
    100% {
        transform: none;
    }
}

/* --------------------------------------------------------------------------
   Leaderboard (leaderboard.js): the board beside the game, and the form on
   the game-over menu that posts to it.
   -------------------------------------------------------------------------- */

.scoreboard {
    grid-area: scores;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px 16px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: rgba(18, 29, 34, 0.82);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

.scoreboard-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.scoreboard-head h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
}

.scoreboard-mode {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--contour);
}

.scoreboard-list {
    display: flex;
    flex-direction: column;
    list-style: none;
}

.scoreboard-list li {
    display: grid;
    grid-template-columns: 1.8em minmax(0, 1fr) auto auto;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-top: 1px solid var(--rule);
    font-size: 0.9rem;
}

.scoreboard-list li:first-child {
    border-top: 0;
}

.scoreboard-rank {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--paper-faint);
}

.scoreboard-list li:first-child .scoreboard-rank {
    color: var(--accent);
}

/* Long names are cut short rather than pushing the score off the row. */
.scoreboard-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scoreboard-detail {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--contour);
}

.scoreboard-score {
    font-family: var(--font-display);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.scoreboard-list li.is-you .scoreboard-name,
.scoreboard-list li.is-you .scoreboard-score {
    color: var(--accent);
}

/* Top scores or most played: a small two-way switch, a quieter cousin of
   the mode switch at the top of the page. */
.board-views {
    display: flex;
    gap: 6px;
}

.board-view {
    padding: 5px 12px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: transparent;
    color: var(--paper-faint);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.board-view:hover {
    color: var(--paper);
}

.board-view[aria-pressed="true"] {
    border-color: var(--contour);
    color: var(--contour);
}

.scoreboard-note {
    color: var(--paper-faint);
    font-size: 0.82rem;
}

.scoreboard-totals {
    color: var(--paper-faint);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
}

.scoreboard-totals:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   Your stats (stats.js): this browser's own tally, per mode.
   -------------------------------------------------------------------------- */

.my-stats {
    grid-area: stats;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px 16px;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: rgba(18, 29, 34, 0.82);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
}

.my-stats h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
}

.my-stats-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 10px 18px;
}

.my-stats-list dt {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--paper-faint);
}

.my-stats-list dd {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.scoreboard-note.is-error,
.post-status.is-error {
    color: #e98a6f;
}

.post-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin-top: 2px;
}

.post-row {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 320px;
}

/* 16px text: iOS zooms the page into any input set smaller. */
.post-name {
    flex: 1;
    min-width: 0;
    padding: 10px 16px;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: rgba(9, 16, 19, 0.92);
    color: var(--paper);
    font-family: var(--font-body);
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.post-name::placeholder {
    color: var(--paper-faint);
}

.post-name:focus {
    border-color: var(--accent);
}

.post-note,
.post-status {
    font-size: 0.74rem;
    color: var(--paper-faint);
}

.post-status:empty {
    display: none;
}

.post-done {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    color: var(--contour);
}

/* --------------------------------------------------------------------------
   Full screen (fullscreen.js)

   The panel covers the whole window: through the Fullscreen API where the
   browser allows it, and by position: fixed alone where it doesn't (Safari
   on iPhone), so the layout below is the same either way. Only what play
   needs stays: the HUD, the board, the buttons and the run's upgrades; the
   lede, leaderboard and stats come back on leaving.

   The board is the biggest square that fits the space left. The slot is a
   size container, so min(100cqw, 100cqh) is that square, and it follows a
   window resize or a phone turning round with no script. The grid is the
   same as ever; only the cells get bigger.
   -------------------------------------------------------------------------- */

html.snake-full,
html.snake-full body {
    overflow: hidden;
}

.game-panel.is-full {
    --full-pad: 16px;
    --full-side: clamp(210px, 24vw, 300px);
    position: fixed;
    inset: 0;
    z-index: 100;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: var(--full-pad);
    /* A very short screen (a phone on its side) still reaches every button. */
    overflow: auto;
    background: var(--ink);
    /* Taller than wide: HUD above the board, buttons below. The board's row
       is capped at the window's width, which is as tall as a square board
       can be here, so the HUD and buttons stay against it and the group
       sits in the middle rather than at the screen's top and bottom. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, calc(100vw - 2 * var(--full-pad))) auto auto;
    grid-template-areas:
        "hud"
        "board"
        "controls"
        "perks";
    align-content: start;
    align-content: safe center;
    gap: 12px;
}

.game-panel.is-full > .game-lede,
.game-panel.is-full > .scoreboard,
.game-panel.is-full > .my-stats {
    display: none;
}

.game-panel.is-full > .board-slot {
    container-type: size;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Browsers without container units keep the normal board size. */
@supports (width: 1cqw) {
    .game-panel.is-full .board {
        flex: none;
        width: min(100cqw, 100cqh);
        max-width: none;
        margin: 0;
    }
}

/* Wider than tall: the HUD and buttons move to a column beside the board.
   The board's column is capped at the window's height, so on a wide screen
   board and column sit together in the middle instead of drifting apart. */
@media (orientation: landscape) {
    .game-panel.is-full {
        grid-template-columns: minmax(0, calc(100vh - 2 * var(--full-pad))) var(--full-side);
        grid-template-columns: minmax(0, calc(100dvh - 2 * var(--full-pad))) var(--full-side);
        grid-template-rows: auto auto auto minmax(0, 1fr);
        grid-template-areas:
            "board hud"
            "board controls"
            "board perks"
            "board .";
        justify-content: center;
        align-content: start;
        align-items: start;
        column-gap: 24px;
    }
}

/* A short screen (a phone on its side) gets the compact HUD and buttons the
   page uses on a narrow phone, so the side column fits beside the board
   without scrolling in Classic, and with little in the Roguelike. */
@media (max-height: 500px) {
    .game-panel.is-full {
        --full-pad: 10px;
        row-gap: 8px;
    }

    .game-panel.is-full .hud {
        grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
        padding: 8px 12px;
        gap: 4px 10px;
    }

    .game-panel.is-full .hud dt {
        font-size: 0.58rem;
        letter-spacing: 0.1em;
    }

    .game-panel.is-full .hud dd {
        font-size: 1.02rem;
    }

    .game-panel.is-full .game-controls {
        gap: 6px;
    }

    .game-panel.is-full .control-button {
        padding: 8px 12px;
    }
}

@media (max-width: 640px) {
    .mode-switch {
        width: 100%;
    }

    .mode-button {
        flex: 1;
    }

    .hud {
        grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
        padding: 10px 14px;
        gap: 8px 10px;
    }

    .hud dt {
        font-size: 0.58rem;
        letter-spacing: 0.1em;
    }

    .hud dd {
        font-size: 1.02rem;
    }

    .overlay-title {
        font-size: 1.3rem;
    }

    .overlay-card {
        gap: 7px;
    }

    .draft-grid {
        gap: 6px;
    }

    .draft-name {
        font-size: 0.95rem;
    }

    .overlay {
        padding: 12px;
    }

    .overlay-text {
        font-size: 0.88rem;
    }

    .draft-card {
        gap: 1px;
        padding: 7px 11px;
    }

    .draft-text,
    .draft-cost {
        font-size: 0.78rem;
        line-height: 1.35;
    }
}
