/**
 * Solo Fun Games pages — center the active game in the viewport
 * so players do not need to scroll to find the playfield.
 */
body.games-solo-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Hub-style intro is only for games.html */
body.games-solo-page > .games-header {
    display: none !important;
}

body.games-solo-page > .games-container.games-container-solo,
body.games-solo-page > .members-section {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0 auto;
    padding: calc(88px * var(--boss-ui-scale, 1)) 1.25rem 1.5rem;
    box-sizing: border-box;
    gap: 0;
}

body.games-solo-page > .games-container.games-container-solo {
    grid-template-columns: 1fr;
}

body.games-solo-page .games-container.games-container-solo .game-card,
body.games-solo-page .members-section .members-game-card {
    width: min(1100px, 100%);
    max-width: 100%;
    margin: 0 auto;
    justify-self: center;
    align-self: center;
}

/* Scramble playfield fits under the fixed nav without clipping ENTER */
body.games-solo-page .games-container.games-container-solo .game-card.scramble-game-card {
    padding-bottom: 0.75rem;
}
body.games-solo-page .game-card.scramble-game-card .game-header {
    padding: 0.85rem 1.15rem;
}
body.games-solo-page .game-card.scramble-game-card .scramble-game-body {
    margin-top: 0.35rem;
    padding: 0 0.75rem 0.35rem;
}
body.games-solo-page .game-card.scramble-game-card .members-scramble-command-root {
    width: 100%;
    height: clamp(420px, calc(100dvh - 210px), 760px);
    min-height: 420px;
}

/* Compact boards — must beat the general .game-card width above */
body.games-solo-page .games-container.games-container-solo .game-card.wordle-game-card {
    width: min(480px, 100%);
}
/* 2048 — +30% vs prior solo size (380 → ~494, board 320 → ~416) */
body.games-solo-page .games-container.games-container-solo .game-card.game-2048-card {
    width: min(494px, 100%);
}
body.games-solo-page .game-card.game-2048-card .game-header {
    padding: 0.9rem 1.05rem;
}
body.games-solo-page .game-card.game-2048-card .game-title {
    font-size: 1.35rem;
}
body.games-solo-page .game-2048-body {
    padding: 0.85rem 1rem 1.1rem;
}
body.games-solo-page .game-2048-scoreboard {
    margin-bottom: 0.75rem;
    gap: 0.6rem;
}
body.games-solo-page .game-2048-score-box {
    padding: 0.45rem 0.6rem;
}
body.games-solo-page .game-2048-score-box strong {
    font-size: 1.35rem;
}
body.games-solo-page .game-2048-controls-hint {
    margin-bottom: 0.75rem;
    gap: 0.7rem;
}
body.games-solo-page .game-2048-controls-hint-text {
    font-size: 0.82rem;
    line-height: 1.35;
}
body.games-solo-page .game-2048-board {
    padding: 0.55rem;
    max-width: 416px;
    margin: 0 auto;
}
body.games-solo-page .game-2048-bg {
    gap: 0.55rem;
}
/* Match play2048.co tile type: Clear Sans, ~55% of tile box */
body.games-solo-page .game-2048-tile {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    letter-spacing: -0.04em;
    font-size: 55% !important;
}
body.games-solo-page .game-2048-tile.game-2048-digits-3 {
    font-size: 45% !important;
}
body.games-solo-page .game-2048-tile.game-2048-digits-4 {
    font-size: 35% !important;
}
body.games-solo-page .game-2048-tile.game-2048-digits-5 {
    font-size: 28% !important;
}
body.games-solo-page .game-2048-attrib {
    margin-top: 0.7rem;
    font-size: 0.78rem;
}

/* Memory Match — tighter card frame + grid +20% (502 → ~602) */
body.games-solo-page .games-container.games-container-solo #memory.game-card {
    width: min(640px, 100%);
}
body.games-solo-page #memory .game-header {
    padding: 1rem 1.15rem;
}
body.games-solo-page #memoryArea {
    height: clamp(520px, calc(100dvh - 240px), 640px) !important;
}
body.games-solo-page #memory .memory-grid {
    width: min(100%, 602px) !important;
    max-width: 602px !important;
    gap: 12px !important;
    padding: 12px !important;
}
body.games-solo-page #memory .game-controls {
    padding: 1rem 1.15rem 1.2rem;
}

body.games-solo-page .games-container.games-container-solo .game-card.chess-game-card {
    /* Match Cinematic Chess play area (~780 board + moves column) */
    width: min(1100px, 100%);
}
body.games-solo-page .games-container.games-container-solo .game-card.xiangqi-game-card {
    /* Match Classic Chess play area (~780 board + moves column) */
    width: min(1100px, 100%);
}

/* Mobile: board sizing after under-board controls moved into the toolbar */
@media (max-width: 640px) {
    body.games-solo-page #chess .chess-board-wrap {
        width: min(96vw, calc(100dvh - 18rem));
        max-width: 100%;
    }
    body.games-solo-page #chess .chess-game-area {
        min-height: 0;
        overflow: visible;
    }
}

/* Solitaire — +20% vs prior solo size (640 → 768, felt max 600 → 720) */
body.games-solo-page .games-container.games-container-solo #solitaire.game-card {
    width: min(768px, 100%);
}
body.games-solo-page #solitaire .game-area.solitaire-table {
    height: clamp(576px, calc(100dvh - 240px), 720px);
    width: 100%;
}

/* Immersive play: hide site chrome footer on solo game pages (Wordle-style). */
body.games-solo-page > footer {
    display: none !important;
}

/* Use the full viewport under the nav for the game */
body.games-solo-page > .games-container.games-container-solo,
body.games-solo-page > .members-section {
    min-height: calc(100vh - calc(73px * var(--boss-ui-scale, 1)));
    min-height: calc(100dvh - calc(73px * var(--boss-ui-scale, 1)));
    padding-bottom: 1rem;
}

@media (max-width: 800px) {
    body.games-solo-page > .games-container.games-container-solo,
    body.games-solo-page > .members-section {
        padding: calc(80px * var(--boss-ui-scale, 1)) 0.75rem 1rem;
    }
    body.games-solo-page .game-card.scramble-game-card .members-scramble-command-root {
        /* Use nearly the full phone viewport so the crossword + controls all fit */
        height: calc(100dvh - 8.75rem);
        min-height: 520px;
        max-height: none;
    }
}

@media (max-width: 640px) {
    body.games-solo-page .game-card.scramble-game-card .game-header {
        padding: 0.55rem 0.75rem;
    }
    body.games-solo-page .game-card.scramble-game-card .game-title {
        font-size: 1.15rem;
    }
    body.games-solo-page .game-card.scramble-game-card .scramble-game-body {
        margin-top: 0.15rem;
        padding: 0 0.4rem 0.25rem;
    }
    body.games-solo-page .game-card.scramble-game-card .members-scramble-command-root {
        height: calc(100dvh - 7.25rem);
        min-height: 0;
    }
}

/* —— Chess / Xiangqi / Cinematic Chess Full View (game only; site chrome hidden) —— */
body.chess-fullview-open,
body.xiangqi-fullview-open,
body.cinematic-chess-fullview-open {
    overflow: hidden !important;
}

body.chess-fullview-open > nav,
body.chess-fullview-open > .games-header,
body.chess-fullview-open > footer,
body.chess-fullview-open .local-dev-banner,
body.xiangqi-fullview-open > nav,
body.xiangqi-fullview-open > .games-header,
body.xiangqi-fullview-open > footer,
body.xiangqi-fullview-open .local-dev-banner,
body.cinematic-chess-fullview-open > nav,
body.cinematic-chess-fullview-open > .games-header,
body.cinematic-chess-fullview-open > footer,
body.cinematic-chess-fullview-open .local-dev-banner {
    display: none !important;
}

body.chess-fullview-open > .games-container.games-container-solo,
body.xiangqi-fullview-open > .games-container.games-container-solo,
body.cinematic-chess-fullview-open > .games-container.games-container-solo {
    /* Keep the card in-place (no DOM move) so iframes do not reload */
    padding: 0 !important;
    margin: 0 !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    max-width: none !important;
    width: 100% !important;
    overflow: visible !important;
    align-items: stretch !important;
    justify-content: stretch !important;
}

body.chess-fullview-open > .games-container.games-container-solo .game-card.chess-game-card,
body.xiangqi-fullview-open > .games-container.games-container-solo .game-card.xiangqi-game-card,
body.cinematic-chess-fullview-open > .games-container.games-container-solo .game-card.cinematic-chess-game-card {
    width: 100% !important;
}

.game-card.chess-game-card.is-fullview,
.game-card.xiangqi-game-card.is-fullview,
.game-card.cinematic-chess-game-card.is-fullview {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 2147483000 !important;
    pointer-events: auto;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.game-card.chess-game-card.is-fullview,
.game-card.xiangqi-game-card.is-fullview {
    background: #0a0e14 !important;
}

.game-card.chess-game-card.is-fullview .chess-game-area {
    /* Shared frozen column: menu + board + moves + buttons (Cinematic-sized) */
    --chess-column-max: min(96vw, 1020px);
    --chess-history-w: 220px;
    --chess-play-gap: 0.75rem;
    --chess-board-max: 780px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    /* Center menu + board as one block in the viewport */
    justify-content: center;
    padding: 0.75rem 1rem;
    gap: 0.7rem;
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-game-area {
    --xiangqi-column-max: min(96vw, 1020px);
    --xiangqi-history-w: 220px;
    --xiangqi-play-gap: 0.75rem;
    --xiangqi-board-max: 780px;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    justify-content: center;
    padding: 0.75rem 1rem;
    gap: 0.7rem;
}

.game-card.chess-game-card.is-fullview .chess-toolbar,
.game-card.chess-game-card.is-fullview .chess-play-row {
    width: 100%;
    max-width: var(--chess-column-max);
    margin-inline: auto;
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-toolbar,
.game-card.xiangqi-game-card.is-fullview .xiangqi-play-row {
    width: 100%;
    max-width: var(--xiangqi-column-max);
    margin-inline: auto;
}

.game-card.chess-game-card.is-fullview .chess-toolbar {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.55rem;
    flex: 0 0 auto;
    padding: 0.55rem 0.15rem 0.7rem;
    margin: 0;
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-toolbar {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.55rem;
    flex: 0 0 auto;
    padding: 0.55rem 0.15rem 0.7rem;
    margin: 0;
}

.game-card.chess-game-card.is-fullview .chess-clock-wrap {
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-clock-wrap {
    flex-direction: row;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
}

.game-card.chess-game-card.is-fullview .chess-board-wrap {
    /* Reserve room for toolbar only (New Game / Take Back are in the menu) */
    width: min(
        calc(var(--chess-column-max) - var(--chess-history-w) - var(--chess-play-gap)),
        calc(100dvh - 9.5rem)
    );
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-board-wrap {
    width: min(
        calc(var(--xiangqi-column-max) - var(--xiangqi-history-w) - var(--xiangqi-play-gap)),
        calc(100dvh - 9.5rem)
    );
}

.game-card.chess-game-card.is-fullview .chess-move-history {
    width: var(--chess-history-w);
    max-height: min(
        calc(var(--chess-column-max) - var(--chess-history-w) - var(--chess-play-gap)),
        calc(100dvh - 9.5rem)
    );
}

.game-card.xiangqi-game-card.is-fullview .xiangqi-move-history {
    width: var(--xiangqi-history-w);
    max-height: min(
        calc(var(--xiangqi-column-max) - var(--xiangqi-history-w) - var(--xiangqi-play-gap)),
        calc(100dvh - 9.5rem)
    );
}

.game-card.cinematic-chess-game-card.is-fullview {
    background: #05080c !important;
    min-height: 100dvh !important;
    max-height: none !important;
    border: none !important;
}

.game-card.cinematic-chess-game-card.is-fullview .cinematic-chess-root {
    flex: 1 1 auto;
    min-height: 0 !important;
    height: 100%;
}

.chess-fullview-btn[aria-pressed="true"],
.xiangqi-fullview-btn[aria-pressed="true"] {
    border-color: rgba(46, 196, 214, 0.7);
    background: rgba(46, 196, 214, 0.18);
    color: #fff;
    box-shadow: 0 0 14px rgba(46, 196, 214, 0.16);
}

@media (max-width: 720px) {
    .game-card.chess-game-card.is-fullview .chess-game-area {
        --chess-column-max: min(96vw, 780px);
        gap: 0.7rem;
    }
    .game-card.chess-game-card.is-fullview .chess-board-wrap {
        width: min(96vw, calc(100dvh - 20rem));
    }
    .game-card.chess-game-card.is-fullview .chess-move-history {
        width: 100%;
        max-width: var(--chess-column-max);
        max-height: 140px;
    }
    .game-card.xiangqi-game-card.is-fullview .xiangqi-game-area {
        --xiangqi-column-max: min(96vw, 780px);
        gap: 0.7rem;
    }
    .game-card.xiangqi-game-card.is-fullview .xiangqi-board-wrap {
        width: min(96vw, calc(100dvh - 20rem));
    }
    .game-card.xiangqi-game-card.is-fullview .xiangqi-move-history {
        width: 100%;
        max-width: var(--xiangqi-column-max);
        max-height: 140px;
    }
}
