/* 11/18/2026 - Keep shared navigation and algebraic move lists usable on wide and narrow boards. */
/* 11/18/2026 - Style shared copyable SCP export controls on each game-board surface. */
/* 11/17/2026 - Reserve a corner for each faction gem while keeping compact characters vertically centered and badge paints independent. */
/* 11/17/2026 - Show the actual six faction colors on cream tiles and outline light glyphs and swatches for contrast. */
/* 11/9/2026 - Make history selectable and fit clear review controls into the existing action row on every screen. */
/* 11/9/2026 - Reserve the measured landscape board width so the side panel cannot shrink it on smaller phones. */
/* 11/9/2026 - Put controls and racks beside a full-height board on short landscape screens while preserving portrait play. */
/* 11/9/2026 - Publish the compact mobile board layout through the existing web UI release workflow. */
/* 11/9/2026 - Give phones a full-width board and compact player rows so gameplay uses the available space. */
/* Shared Six Courts presentation. All modes and color themes use this layout. */

        :root {
            color-scheme: dark;
            --ink: #f7f2e7;
            --muted: #b8b1a5;
            --panel: rgba(21, 25, 38, 0.92);
            --panel-soft: rgba(31, 36, 53, 0.9);
            --line: rgba(255, 255, 255, 0.12);
            --gold: #d9ad62;
            --gold-soft: rgba(217, 173, 98, 0.22);
            --tabletop: #17271f;
            --tabletop-dark: #0b1411;
            --danger-soft: rgba(209, 72, 72, 0.18);
            --success-soft: rgba(79, 192, 134, 0.2);
        }

        * {
            box-sizing: border-box;
        }

        html,
        body {
            min-height: 100%;
        }

        body {
            margin: 0;
            color: var(--ink);
            background:
                radial-gradient(circle at 15% 10%, rgba(88, 117, 85, 0.22), transparent 34rem),
                radial-gradient(circle at 88% 22%, rgba(109, 75, 120, 0.18), transparent 30rem),
                linear-gradient(145deg, var(--tabletop) 0%, var(--tabletop-dark) 72%);
            background-attachment: fixed;
            font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        }

        body::before {
            position: fixed;
            inset: 0;
            z-index: -1;
            content: "";
            opacity: 0.17;
            background-image:
                repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(255, 255, 255, 0.035) 4px),
                repeating-linear-gradient(90deg, transparent 0, transparent 5px, rgba(0, 0, 0, 0.06) 6px);
            pointer-events: none;
        }

        [v-cloak] {
            display: none;
        }

        .game-shell {
            width: min(1680px, 100%);
            margin: 0 auto;
            padding: 1.25rem;
        }

        .brand-kicker,
        .section-kicker {
            color: var(--gold);
            font-size: 0.75rem;
            font-weight: 800;
            letter-spacing: 0.18em;
            text-transform: uppercase;
        }

        .display-title {
            margin: 0;
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(2.5rem, 7vw, 5.5rem);
            font-weight: 700;
            line-height: 0.92;
            letter-spacing: -0.04em;
        }

        .subtitle {
            color: #d6cec0;
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(1rem, 2.2vw, 1.35rem);
            font-style: italic;
        }

        .glass-panel,
        .game-card,
        .player-panel {
            border: 1px solid var(--line);
            border-radius: 1.25rem;
            background: linear-gradient(160deg, rgba(39, 45, 62, 0.96), rgba(16, 20, 31, 0.96));
            box-shadow: 0 1.2rem 3.5rem rgba(0, 0, 0, 0.28);
        }

        .setup-hero {
            position: relative;
            overflow: hidden;
            min-height: 18rem;
        }

        .setup-hero::after {
            position: absolute;
            right: -6rem;
            bottom: -8rem;
            width: 24rem;
            height: 24rem;
            border: 1px solid rgba(217, 173, 98, 0.18);
            border-radius: 50%;
            content: "36";
            color: rgba(217, 173, 98, 0.08);
            font-family: Georgia, "Times New Roman", serif;
            font-size: 14rem;
            font-weight: 700;
            line-height: 1.45;
            text-align: center;
            transform: rotate(-10deg);
            pointer-events: none;
        }

        .setup-control-card {
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1rem;
            background: rgba(8, 12, 19, 0.34);
        }

        .player-count-button {
            min-width: 4.5rem;
            border-color: rgba(217, 173, 98, 0.42);
            color: #e9dcc5;
        }

        .player-count-button:hover,
        .player-count-button.active {
            border-color: var(--gold);
            color: #17130e;
            background: var(--gold);
        }

        .btn-gold {
            border-color: #e6c17d;
            color: #17130e;
            background: linear-gradient(135deg, #efd293, #c99445);
            box-shadow: 0 0.7rem 1.5rem rgba(201, 148, 69, 0.2);
            font-weight: 800;
        }

        .btn-gold:hover,
        .btn-gold:focus-visible {
            border-color: #f5d99e;
            color: #100e0b;
            background: linear-gradient(135deg, #f6dfaa, #d9a657);
        }

        .form-select,
        .form-control {
            border-color: rgba(255, 255, 255, 0.16);
            color: var(--ink);
            background-color: rgba(6, 9, 15, 0.76);
        }

        .form-select:focus,
        .form-control:focus {
            border-color: var(--gold);
            color: var(--ink);
            background-color: rgba(6, 9, 15, 0.9);
            box-shadow: 0 0 0 0.2rem var(--gold-soft);
        }

        .form-select option {
            color: #111827;
            background: #ffffff;
        }

        .rule-loop {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 0.5rem;
            color: #e9dcc5;
            font-size: 0.8rem;
            font-weight: 800;
            letter-spacing: 0.08em;
        }

        .rule-loop .arrow {
            color: var(--gold);
        }

        .topbar {
            position: sticky;
            top: 0;
            z-index: 30;
            margin: -1.25rem -1.25rem 1.25rem;
            padding: 0.9rem 1.25rem;
            border-bottom: 1px solid var(--line);
            background: rgba(10, 14, 21, 0.88);
            box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.22);
            backdrop-filter: blur(16px);
        }

        .topbar-title {
            font-family: Georgia, "Times New Roman", serif;
            font-size: 1.45rem;
            font-weight: 700;
            letter-spacing: -0.02em;
        }

        .status-card {
            position: relative;
            overflow: hidden;
            border: 1px solid rgba(217, 173, 98, 0.24);
            border-radius: 1.15rem;
            background: linear-gradient(125deg, rgba(217, 173, 98, 0.12), rgba(31, 36, 53, 0.82) 40%, rgba(17, 21, 32, 0.94));
            box-shadow: 0 1rem 2.4rem rgba(0, 0, 0, 0.22);
        }

        .status-card::before {
            position: absolute;
            inset: 0 auto 0 0;
            width: 0.3rem;
            content: "";
            background: var(--gold);
        }

        .status-title {
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(1.2rem, 2.2vw, 1.75rem);
            font-weight: 700;
        }

        .status-event {
            color: #d8d0c2;
        }

        .capture-banner {
            border: 1px solid rgba(217, 173, 98, 0.35);
            border-radius: 0.9rem;
            color: #f0dfbe;
            background: rgba(217, 173, 98, 0.13);
            animation: capture-pop 320ms ease-out;
        }

        @keyframes capture-pop {
            from {
                opacity: 0;
                transform: translateY(-0.4rem) scale(0.98);
            }
            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        .board-card {
            padding: clamp(0.75rem, 2vw, 1.35rem);
        }

        .board-stage {
            max-width: 920px;
            margin: 0 auto;
        }

        .column-label-row {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: clamp(0.25rem, 0.8vw, 0.55rem);
            margin: 0 0 0.3rem 1.65rem;
            color: rgba(255, 255, 255, 0.52);
            font-size: clamp(0.62rem, 1.3vw, 0.78rem);
            font-weight: 800;
            text-align: center;
        }

        .board-row-shell {
            display: grid;
            grid-template-columns: 1.3rem minmax(0, 1fr);
            gap: 0.35rem;
        }

        .row-label-column {
            display: grid;
            grid-template-rows: repeat(6, minmax(0, 1fr));
            gap: clamp(0.25rem, 0.8vw, 0.55rem);
            color: rgba(255, 255, 255, 0.52);
            font-size: clamp(0.62rem, 1.3vw, 0.78rem);
            font-weight: 800;
            place-items: center;
        }

        .game-board {
            display: grid;
            grid-template-columns: repeat(6, minmax(0, 1fr));
            gap: clamp(0.25rem, 0.8vw, 0.55rem);
            padding: clamp(0.4rem, 1.1vw, 0.75rem);
            border: 1px solid rgba(217, 173, 98, 0.28);
            border-radius: 1.1rem;
            background:
                linear-gradient(135deg, rgba(217, 173, 98, 0.06), transparent 45%),
                rgba(4, 9, 8, 0.52);
            box-shadow:
                inset 0 0 0 1px rgba(255, 255, 255, 0.04),
                inset 0 1.4rem 3rem rgba(0, 0, 0, 0.38),
                0 1.1rem 2.5rem rgba(0, 0, 0, 0.3);
        }

        .board-cell {
            position: relative;
            display: grid;
            min-width: 0;
            aspect-ratio: 1 / 1;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.11);
            border-radius: clamp(0.42rem, 1.2vw, 0.78rem);
            color: rgba(255, 255, 255, 0.34);
            background:
                radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.04), transparent 52%),
                rgba(28, 43, 35, 0.78);
            box-shadow: inset 0 0 1.1rem rgba(0, 0, 0, 0.2);
            place-items: stretch;
            transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
        }

        .board-cell:disabled {
            opacity: 1;
        }

        .board-cell:not(:disabled):hover {
            z-index: 3;
            transform: translateY(-2px) scale(1.025);
        }

        .board-cell-legal {
            border-color: rgba(97, 227, 157, 0.9);
            background: rgba(52, 131, 87, 0.38);
            box-shadow:
                inset 0 0 1.2rem rgba(45, 210, 125, 0.12),
                0 0 0 2px rgba(73, 221, 142, 0.14),
                0 0 1.4rem rgba(73, 221, 142, 0.3);
        }

        .board-cell-legal:not(:disabled):hover {
            background: rgba(61, 157, 101, 0.5);
            box-shadow:
                inset 0 0 1.2rem rgba(45, 210, 125, 0.18),
                0 0 0 3px rgba(73, 221, 142, 0.22),
                0 0 1.8rem rgba(73, 221, 142, 0.45);
        }

        .board-cell-illegal {
            opacity: 0.52;
            filter: saturate(0.65);
        }

        .board-cell-last {
            box-shadow: 0 0 0 3px rgba(255, 225, 157, 0.7), 0 0 1.5rem rgba(255, 211, 112, 0.48);
        }

        .board-cell-captured {
            border-color: rgba(217, 173, 98, 0.56);
            background: rgba(217, 173, 98, 0.12);
        }

        .cell-coordinate {
            position: absolute;
            right: 0.3rem;
            bottom: 0.2rem;
            z-index: 2;
            color: rgba(255, 255, 255, 0.34);
            font-size: clamp(0.45rem, 1.1vw, 0.65rem);
            font-weight: 700;
            pointer-events: none;
        }

        .legal-marker {
            display: grid;
            width: 100%;
            height: 100%;
            color: rgba(170, 255, 209, 0.78);
            font-size: clamp(1rem, 4vw, 2rem);
            font-weight: 300;
            place-items: center;
        }

        .board-tile,
        .hand-tile,
        .removed-tile {
            --faction-color: #52616b;
            --faction-dark: #28313a;
            --tile-ink: #ffffff;
            border-color: var(--faction-dark);
            color: var(--tile-ink);
            background:
                linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent 35%),
                linear-gradient(155deg, var(--faction-color), var(--faction-dark));
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
        }

        .board-tile {
            position: relative;
            display: grid;
            width: 100%;
            height: 100%;
            padding: clamp(0.18rem, 0.8vw, 0.45rem);
            border: 1px solid var(--faction-dark);
            border-radius: inherit;
            box-shadow:
                inset 0 0 0 1px rgba(255, 255, 255, 0.16),
                inset 0 -0.7rem 1rem rgba(0, 0, 0, 0.14),
                0 0.32rem 0.8rem rgba(0, 0, 0, 0.26);
            text-align: left;
            grid-template-rows: auto 1fr auto;
        }

        .board-tile-faction {
            overflow: hidden;
            font-size: clamp(0.42rem, 1.1vw, 0.72rem);
            font-weight: 900;
            letter-spacing: 0.06em;
            text-overflow: ellipsis;
            text-transform: uppercase;
            white-space: nowrap;
        }

        .board-tile-mark {
            align-self: center;
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(1.15rem, 5vw, 3.2rem);
            font-weight: 700;
            line-height: 0.9;
            text-align: center;
        }

        .board-tile-type {
            overflow: hidden;
            font-size: clamp(0.43rem, 1.2vw, 0.75rem);
            font-weight: 800;
            text-align: center;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .summary-stat {
            border: 1px solid rgba(255, 255, 255, 0.09);
            border-radius: 0.8rem;
            background: rgba(3, 6, 11, 0.28);
        }

        .summary-stat-value {
            font-family: Georgia, "Times New Roman", serif;
            font-size: 1.45rem;
            font-weight: 700;
        }

        .summary-stat-label {
            color: var(--muted);
            font-size: 0.65rem;
            font-weight: 800;
            letter-spacing: 0.1em;
            text-transform: uppercase;
        }

        .faction-swatch {
            width: 0.78rem;
            height: 0.78rem;
            flex: 0 0 auto;
            border: 1px solid rgba(255, 255, 255, 0.42);
            border-radius: 0.25rem;
            background: var(--faction-color);
            box-shadow: 0 0 0.7rem rgba(255, 255, 255, 0.08);
        }

        .move-log {
            max-height: 27rem;
            overflow-y: auto;
            scrollbar-color: rgba(217, 173, 98, 0.35) transparent;
        }

        .log-entry {
            display: grid;
            grid-template-columns: auto 1fr;
            gap: 0.6rem;
            padding: 0.62rem 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.07);
            color: #d7d0c4;
            font-size: 0.82rem;
            line-height: 1.35;
        }

        .log-entry:last-child {
            border-bottom: 0;
        }

        .log-number {
            display: inline-grid;
            width: 1.6rem;
            height: 1.6rem;
            border: 1px solid rgba(217, 173, 98, 0.26);
            border-radius: 50%;
            color: var(--gold);
            background: rgba(217, 173, 98, 0.08);
            font-size: 0.67rem;
            font-weight: 800;
            place-items: center;
        }

        .player-panel {
            position: relative;
            overflow: hidden;
            transition: border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease, transform 180ms ease;
        }

        .player-panel::before {
            position: absolute;
            inset: 0 auto 0 0;
            width: 0.24rem;
            content: "";
            background: transparent;
        }

        .player-panel-current {
            border-color: rgba(217, 173, 98, 0.62);
            box-shadow: 0 0 0 2px rgba(217, 173, 98, 0.12), 0 1.4rem 3rem rgba(0, 0, 0, 0.32), 0 0 2rem rgba(217, 173, 98, 0.12);
            transform: translateY(-2px);
        }

        .player-panel-current::before {
            background: var(--gold);
        }

        .player-panel-eliminated {
            opacity: 0.52;
            filter: grayscale(0.62);
        }

        .player-state-badge {
            border: 1px solid rgba(255, 255, 255, 0.14);
            color: #dcd5c9;
            background: rgba(255, 255, 255, 0.07);
        }

        .player-state-badge.current {
            border-color: rgba(217, 173, 98, 0.45);
            color: #f5ddb0;
            background: rgba(217, 173, 98, 0.16);
        }

        .player-state-badge.eliminated {
            border-color: rgba(216, 88, 88, 0.35);
            color: #f0b3b3;
            background: var(--danger-soft);
        }

        .hand-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(5.55rem, 1fr));
            gap: 0.55rem;
        }

        .hand-grid.compact {
            grid-template-columns: repeat(auto-fill, minmax(4.7rem, 1fr));
            gap: 0.42rem;
        }

        .hand-tile {
            position: relative;
            display: grid;
            min-height: 6.25rem;
            overflow: hidden;
            padding: 0.55rem;
            border: 1px solid var(--faction-dark);
            border-radius: 0.8rem;
            box-shadow:
                inset 0 0 0 1px rgba(255, 255, 255, 0.15),
                inset 0 -1.2rem 1.8rem rgba(0, 0, 0, 0.16),
                0 0.42rem 0.9rem rgba(0, 0, 0, 0.2);
            text-align: left;
            transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease, outline-color 140ms ease;
            grid-template-rows: auto 1fr auto;
        }

        .compact .hand-tile {
            min-height: 5.2rem;
            padding: 0.4rem;
        }

        .hand-tile:disabled {
            opacity: 1;
        }

        .hand-tile-selectable:not(:disabled):hover {
            z-index: 2;
            transform: translateY(-4px) scale(1.025);
            box-shadow:
                inset 0 0 0 1px rgba(255, 255, 255, 0.2),
                0 0.8rem 1.35rem rgba(0, 0, 0, 0.28),
                0 0 1.2rem rgba(217, 173, 98, 0.28);
        }

        .hand-tile-selected {
            z-index: 3;
            outline: 3px solid #f3d79d;
            outline-offset: 2px;
            box-shadow: 0 0 0 5px rgba(217, 173, 98, 0.18), 0 0 2rem rgba(217, 173, 98, 0.58);
            transform: translateY(-4px) scale(1.035);
        }

        .hand-tile-faction {
            overflow: hidden;
            font-size: 0.62rem;
            font-weight: 900;
            letter-spacing: 0.07em;
            text-overflow: ellipsis;
            text-transform: uppercase;
            white-space: nowrap;
        }

        .hand-tile-mark {
            align-self: center;
            font-family: Georgia, "Times New Roman", serif;
            font-size: 2.15rem;
            font-weight: 700;
            line-height: 1;
            text-align: center;
        }

        .compact .hand-tile-mark {
            font-size: 1.65rem;
        }

        .hand-tile-type {
            overflow: hidden;
            font-size: 0.72rem;
            font-weight: 800;
            text-align: center;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .compact .hand-tile-type {
            font-size: 0.62rem;
        }

        .empty-hand {
            border: 1px dashed rgba(255, 255, 255, 0.16);
            border-radius: 0.8rem;
            color: var(--muted);
            background: rgba(0, 0, 0, 0.12);
            font-size: 0.84rem;
            text-align: center;
        }

        .removed-pool {
            display: flex;
            flex-wrap: wrap;
            gap: 0.34rem;
        }

        .removed-tile {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            padding: 0.25rem 0.42rem;
            border: 1px solid var(--faction-dark);
            border-radius: 0.45rem;
            font-size: 0.64rem;
            font-weight: 800;
            filter: grayscale(0.25);
        }

        .game-over-backdrop {
            position: fixed;
            inset: 0;
            z-index: 100;
            display: grid;
            padding: 1.25rem;
            background: rgba(2, 5, 9, 0.82);
            backdrop-filter: blur(10px);
            place-items: center;
        }

        .game-over-card {
            width: min(650px, 100%);
            overflow: hidden;
            border: 1px solid rgba(217, 173, 98, 0.54);
            border-radius: 1.45rem;
            background:
                radial-gradient(circle at 50% -15%, rgba(217, 173, 98, 0.24), transparent 45%),
                linear-gradient(160deg, #272d3d, #0d111b 72%);
            box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.65), 0 0 3rem rgba(217, 173, 98, 0.14);
            animation: result-in 300ms ease-out;
        }

        @keyframes result-in {
            from {
                opacity: 0;
                transform: translateY(1rem) scale(0.96);
            }
            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        .result-title {
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(2.1rem, 8vw, 4.25rem);
            font-weight: 700;
            letter-spacing: -0.04em;
        }

        .result-subtitle {
            color: var(--gold);
            font-size: 0.78rem;
            font-weight: 900;
            letter-spacing: 0.16em;
            text-transform: uppercase;
        }

        .spinner-border-sm {
            width: 0.9rem;
            height: 0.9rem;
            border-width: 0.15em;
        }

        .text-game-muted {
            color: var(--muted) !important;
        }

        .border-game {
            border-color: var(--line) !important;
        }

        .small-caps {
            font-size: 0.66rem;
            font-weight: 800;
            letter-spacing: 0.1em;
            text-transform: uppercase;
        }

        @media (max-width: 1199.98px) {
            .topbar {
                position: static;
            }

            .move-log {
                max-height: 18rem;
            }
        }

        @media (max-width: 575.98px) {
            .game-shell {
                padding: 0.75rem;
            }

            .topbar {
                margin: -0.75rem -0.75rem 0.8rem;
                padding: 0.75rem;
            }

            .board-card {
                padding: 0.5rem;
                border-radius: 0.9rem;
            }

            .column-label-row {
                margin-left: 1.25rem;
            }

            .board-row-shell {
                grid-template-columns: 1rem minmax(0, 1fr);
                gap: 0.2rem;
            }

            .game-board,
            .row-label-column,
            .column-label-row {
                gap: 0.18rem;
            }

            .game-board {
                padding: 0.28rem;
                border-radius: 0.7rem;
            }

            .board-cell {
                border-radius: 0.32rem;
            }

            .board-tile-faction,
            .cell-coordinate {
                display: none;
            }

            .board-tile {
                grid-template-rows: 1fr auto;
            }

            .board-tile-mark {
                font-size: clamp(1.1rem, 8vw, 2.1rem);
            }

            .board-tile-type {
                font-size: clamp(0.35rem, 2.3vw, 0.6rem);
            }

            .hand-grid,
            .hand-grid.compact {
                grid-template-columns: repeat(auto-fill, minmax(4.25rem, 1fr));
            }

            .hand-tile,
            .compact .hand-tile {
                min-height: 5rem;
                padding: 0.38rem;
            }

            .hand-tile-mark,
            .compact .hand-tile-mark {
                font-size: 1.55rem;
            }

            .hand-tile-faction,
            .hand-tile-type,
            .compact .hand-tile-type {
                font-size: 0.55rem;
            }
        }

        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                scroll-behavior: auto !important;
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }


        /* Viewport-fit gameplay revision */
        .setup-rules-button {
            position: absolute;
            top: 1rem;
            right: 1rem;
            z-index: 3;
        }

        .setup-player-row {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(8.5rem, 0.8fr);
            gap: 0.65rem;
            align-items: end;
        }

        .game-shell-play {
            width: min(1920px, 100%);
            min-height: 100dvh;
            padding: 0.65rem;
        }

        .compact-topbar {
            margin: -0.65rem -0.65rem 0.65rem;
            padding: 0.55rem 0.7rem;
        }

        .min-w-0 {
            min-width: 0;
        }

        .topbar-grid {
            display: grid;
            grid-template-columns: auto minmax(0, 1fr) auto;
            gap: 0.8rem;
            align-items: center;
        }

        .topbar-brand {
            min-width: 10.5rem;
        }

        .compact-topbar .topbar-title {
            font-size: 1rem;
            white-space: nowrap;
        }

        .topbar-command {
            display: flex;
            min-width: 0;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 0.4rem 0.65rem;
            border: 1px solid rgba(217, 173, 98, 0.2);
            border-radius: 0.8rem;
            background: rgba(217, 173, 98, 0.07);
        }

        .topbar-command .status-title {
            font-size: clamp(0.98rem, 1.45vw, 1.25rem);
            line-height: 1.15;
        }

        .topbar-command .status-event {
            max-width: 58vw;
            margin-top: 0.12rem;
            font-size: 0.72rem;
        }

        .topbar-metrics {
            display: flex;
            flex: 0 0 auto;
            gap: 0.35rem;
        }

        .topbar-metrics span {
            padding: 0.28rem 0.52rem;
            border: 1px solid var(--line);
            border-radius: 999px;
            color: #ddd5c7;
            background: rgba(0, 0, 0, 0.18);
            font-size: 0.65rem;
            font-weight: 800;
            white-space: nowrap;
        }

        .topbar-actions {
            display: flex;
            flex-wrap: nowrap;
            gap: 0.35rem;
        }

        .compact-capture-banner {
            font-size: 0.76rem;
        }

        .game-workspace {
            display: grid;
            grid-template-columns: minmax(30rem, 1.12fr) minmax(31rem, 0.88fr);
            gap: 0.75rem;
            min-height: 0;
            align-items: start;
        }

        .board-column,
        .game-rail,
        .player-command-grid,
        .rail-lower-grid {
            min-width: 0;
        }

        .board-card-fit {
            display: flex;
            min-height: 32rem;
            height: calc(100dvh - 5.9rem);
            flex-direction: column;
            justify-content: flex-start;
        }

        .board-toolbar {
            display: flex;
            min-height: 2rem;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            margin-bottom: 0.35rem;
        }

        .coordinate-toggle {
            color: var(--muted);
            font-size: 0.7rem;
            white-space: nowrap;
        }

        .coordinate-toggle .form-check-input {
            border-color: rgba(255, 255, 255, 0.25);
            background-color: rgba(0, 0, 0, 0.34);
        }

        .coordinate-toggle .form-check-input:checked {
            border-color: var(--gold);
            background-color: var(--gold);
        }

        .board-card-fit .board-stage {
            width: min(100%, calc(100dvh - 10.2rem));
            max-width: none;
            margin: auto;
        }

        .board-card-fit .column-label-row {
            margin: 0.28rem 0 0 1.65rem;
        }

        .game-rail {
            display: grid;
            max-height: calc(100dvh - 5.9rem);
            overflow-y: auto;
            gap: 0.75rem;
            padding-right: 0.1rem;
            align-content: start;
            scrollbar-color: rgba(217, 173, 98, 0.3) transparent;
        }

        .rail-section-heading {
            display: flex;
            align-items: end;
            justify-content: space-between;
            gap: 0.75rem;
            margin-bottom: 0.45rem;
        }

        .player-command-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.5rem;
        }

        .player-panel-compact {
            padding: 0.6rem;
            border-radius: 0.85rem;
            box-shadow: 0 0.6rem 1.4rem rgba(0, 0, 0, 0.2);
        }

        .player-panel-compact.player-panel-current {
            transform: none;
        }

        .player-editor-line {
            display: grid;
            grid-template-columns: minmax(0, 1fr) minmax(7.1rem, 0.82fr) auto;
            gap: 0.32rem;
            align-items: center;
        }

        .player-name-input,
        .player-controller-select {
            min-width: 0;
            height: 1.9rem;
            padding-top: 0.2rem;
            padding-bottom: 0.2rem;
            font-size: 0.72rem;
        }

        .player-name-input {
            font-weight: 800;
        }

        .player-state-compact {
            padding: 0.36rem 0.45rem;
            font-size: 0.52rem;
        }

        .player-meta-row {
            display: flex;
            flex-wrap: wrap;
            gap: 0.3rem 0.65rem;
            margin: 0.38rem 0;
            color: var(--muted);
            font-size: 0.62rem;
        }

        .player-elimination-reason {
            color: #efb0b0;
        }

        .player-panel-compact .hand-grid,
        .player-panel-compact .hand-grid.compact {
            grid-template-columns: repeat(auto-fill, minmax(2rem, 1fr));
            gap: 0.2rem;
        }

        .player-panel-compact.player-panel-current .hand-grid {
            grid-template-columns: repeat(auto-fill, minmax(2.18rem, 1fr));
        }

        .player-panel-compact .hand-tile,
        .player-panel-compact .compact .hand-tile {
            min-height: 0;
            aspect-ratio: 1 / 1;
            padding: 0.16rem;
            border-radius: 0.38rem;
            grid-template-rows: auto 1fr;
        }

        .player-panel-compact .hand-tile-faction {
            font-size: clamp(0.31rem, 0.45vw, 0.44rem);
            letter-spacing: 0.02em;
        }

        .player-panel-compact .hand-tile-mark,
        .player-panel-compact .compact .hand-tile-mark {
            font-size: clamp(0.9rem, 1.45vw, 1.18rem);
        }

        .player-panel-compact .hand-tile-type,
        .player-panel-compact .compact .hand-tile-type {
            display: none;
        }

        .player-panel-compact .hand-tile-selectable:not(:disabled):hover {
            transform: translateY(-2px) scale(1.025);
        }

        .player-panel-compact .hand-tile-selected {
            outline-width: 2px;
            outline-offset: 1px;
            transform: translateY(-1px) scale(1.025);
        }

        .empty-hand-compact {
            padding: 0.45rem;
            font-size: 0.66rem;
        }

        .rail-lower-grid {
            display: grid;
            grid-template-columns: minmax(0, 1.1fr) minmax(13rem, 0.9fr);
            gap: 0.75rem;
        }

        .match-state-card,
        .moves-card {
            padding: 0.75rem;
            border-radius: 0.9rem;
            box-shadow: 0 0.75rem 1.8rem rgba(0, 0, 0, 0.2);
        }

        .match-stat-grid {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 0.35rem;
        }

        .compact-summary-stat {
            padding: 0.42rem 0.3rem;
            text-align: center;
        }

        .compact-summary-stat .summary-stat-value {
            font-size: 1rem;
            line-height: 1.1;
        }

        .compact-summary-stat .summary-stat-label {
            font-size: 0.5rem;
        }

        .filter-grid {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 0.28rem;
        }

        .filter-button {
            display: flex;
            min-width: 0;
            min-height: 1.75rem;
            align-items: center;
            justify-content: flex-start;
            gap: 0.3rem;
            padding: 0.24rem 0.34rem;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 0.42rem;
            color: #ddd6ca;
            background: rgba(2, 5, 9, 0.24);
            font-size: 0.58rem;
            font-weight: 800;
            text-overflow: ellipsis;
            white-space: nowrap;
            transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
        }

        .filter-button:hover,
        .filter-button.active {
            border-color: rgba(255, 235, 180, 0.9);
            background: rgba(217, 173, 98, 0.12);
            box-shadow: inset 0 0 0 1px rgba(255, 235, 180, 0.24), 0 0 0.65rem rgba(217, 173, 98, 0.12);
        }

        .filter-button .faction-swatch {
            width: 0.62rem;
            height: 0.62rem;
            border-radius: 0.18rem;
        }

        .character-filter-button strong {
            display: inline-grid;
            width: 1rem;
            height: 1rem;
            flex: 0 0 auto;
            border: 1px solid rgba(111, 227, 255, 0.38);
            border-radius: 50%;
            color: #a9efff;
            place-items: center;
            font-size: 0.55rem;
        }

        .player-roster {
            display: grid;
            gap: 0.22rem;
        }

        .player-roster-item {
            display: grid;
            grid-template-columns: 0.85rem minmax(0, 1fr) auto;
            gap: 0.32rem;
            align-items: center;
            padding: 0.26rem 0.36rem;
            border: 1px solid rgba(255, 255, 255, 0.07);
            border-radius: 0.4rem;
            color: #d9d2c6;
            background: rgba(0, 0, 0, 0.16);
            font-size: 0.62rem;
        }

        .player-roster-item.current {
            border-color: rgba(217, 173, 98, 0.42);
            background: rgba(217, 173, 98, 0.09);
        }

        .player-roster-item.out {
            color: #a79898;
            background: rgba(90, 24, 31, 0.15);
        }

        .player-roster-item.out .player-roster-name {
            text-decoration: line-through;
            text-decoration-thickness: 2px;
        }

        .roster-status-mark {
            color: var(--gold);
            font-size: 0.75rem;
            font-weight: 900;
            text-align: center;
        }

        .player-roster-item.out .roster-status-mark {
            color: #ef7777;
            font-size: 0.9rem;
        }

        .player-roster-name {
            overflow: hidden;
            font-weight: 800;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .player-roster-detail {
            color: var(--muted);
            white-space: nowrap;
        }

        .moves-card .move-log {
            max-height: clamp(6rem, 14dvh, 9rem);
        }

        .moves-card .log-entry {
            gap: 0.42rem;
            padding: 0.42rem 0;
            font-size: 0.7rem;
        }

        .moves-card .log-number {
            width: 1.35rem;
            height: 1.35rem;
            font-size: 0.56rem;
        }

        

        .tile-filter-faction-match::after {
            border-color: #fff0a6;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.42), 0 0 0.8rem rgba(255, 240, 166, 0.45);
        }

        .tile-filter-type-match::after {
            border-color: #68e4ff;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.42), 0 0 0.8rem rgba(104, 228, 255, 0.42);
        }

        .tile-filter-double-match::after {
            border-color: #fff4bf;
            box-shadow: inset 0 0 0 3px #68e4ff, inset 0 0 0 4px rgba(0, 0, 0, 0.36), 0 0 0.95rem rgba(255, 244, 191, 0.52);
        }

        .tile-filter-dim {
            filter: brightness(0.55) saturate(0.62);
        }

        .rules-modal-backdrop {
            position: fixed;
            inset: 0;
            z-index: 200;
            display: grid;
            padding: 1rem;
            background: rgba(2, 5, 9, 0.84);
            backdrop-filter: blur(9px);
            place-items: center;
        }

        .rules-modal-card {
            width: min(650px, 100%);
            max-height: calc(100dvh - 2rem);
            overflow: auto;
            border: 1px solid rgba(217, 173, 98, 0.48);
            border-radius: 1.15rem;
            background: linear-gradient(160deg, #272d3d, #0d111b 72%);
            box-shadow: 0 2rem 7rem rgba(0, 0, 0, 0.65);
        }

        .rules-modal-header,
        .rules-modal-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            padding: 1rem 1.15rem;
        }

        .rules-modal-header {
            border-bottom: 1px solid var(--line);
        }

        .rules-modal-footer {
            justify-content: flex-end;
            border-top: 1px solid var(--line);
        }

        .rules-modal-body {
            display: grid;
            gap: 0.65rem;
            padding: 1rem 1.15rem;
        }

        .rules-intro,
        .rules-tip {
            padding: 0.7rem 0.8rem;
            border: 1px solid rgba(217, 173, 98, 0.2);
            border-radius: 0.7rem;
            color: #ded6ca;
            background: rgba(217, 173, 98, 0.08);
            font-size: 0.83rem;
            line-height: 1.45;
        }

        .rules-step {
            display: grid;
            grid-template-columns: 1.65rem minmax(0, 1fr);
            gap: 0.65rem;
            align-items: start;
            color: #ddd6ca;
            font-size: 0.82rem;
            line-height: 1.42;
        }

        .rules-step-number {
            display: inline-grid;
            width: 1.65rem;
            height: 1.65rem;
            border: 1px solid rgba(217, 173, 98, 0.45);
            border-radius: 50%;
            color: var(--gold);
            background: rgba(217, 173, 98, 0.09);
            font-weight: 900;
            place-items: center;
        }

        .rules-tip {
            border-color: rgba(104, 228, 255, 0.2);
            color: #cdeff5;
            background: rgba(104, 228, 255, 0.07);
        }

        @media (max-width: 1279.98px) {
            .game-workspace {
                grid-template-columns: minmax(27rem, 1.05fr) minmax(27rem, 0.95fr);
            }

            .topbar-brand {
                min-width: 8.5rem;
            }

            .compact-topbar .topbar-title {
                font-size: 0.86rem;
            }

            .player-editor-line {
                grid-template-columns: minmax(0, 1fr) minmax(5.4rem, 0.8fr);
            }

            .player-state-compact {
                grid-column: 1 / -1;
                justify-self: start;
                padding: 0.2rem 0.4rem;
            }

            .rail-lower-grid {
                grid-template-columns: 1fr;
            }
        }

        @media (max-width: 1099.98px) {
            .game-workspace {
                grid-template-columns: minmax(25rem, 1fr) minmax(24rem, 0.9fr);
            }

            .topbar-grid {
                grid-template-columns: auto minmax(0, 1fr);
            }

            .topbar-actions {
                grid-column: 1 / -1;
                justify-content: flex-end;
            }

            .board-card-fit,
            .game-rail {
                height: calc(100dvh - 8.4rem);
                max-height: calc(100dvh - 8.4rem);
            }

            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 12.4rem));
            }
        }

        @media (min-width: 640px) and (max-width: 899.98px) {
            .game-workspace {
                grid-template-columns: minmax(19rem, 1.08fr) minmax(16rem, 0.92fr);
            }

            .player-command-grid {
                grid-template-columns: 1fr;
                gap: 0.3rem;
            }
        }

        @media (max-width: 639.98px) {
            .game-shell-play {
                padding: 0.5rem;
            }

            .compact-topbar {
                position: sticky;
                margin: -0.5rem -0.5rem 0.5rem;
            }

            .game-workspace {
                display: block;
            }

            .board-card-fit {
                min-height: 0;
                height: auto;
            }

            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 9rem));
            }

            .game-rail {
                max-height: none;
                margin-top: 0.6rem;
                overflow: visible;
            }

            .rail-lower-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
            }
        }

        @media (max-width: 575.98px) {
            .setup-rules-button {
                top: 0.65rem;
                right: 0.65rem;
            }

            .setup-player-row {
                grid-template-columns: minmax(0, 1fr) minmax(7rem, 0.8fr);
                gap: 0.4rem;
            }

            .topbar-grid {
                grid-template-columns: minmax(0, 1fr) auto;
                gap: 0.45rem;
            }

            .topbar-brand {
                min-width: 0;
            }

            .compact-topbar .topbar-title {
                display: none;
            }

            .topbar-command {
                grid-column: 1 / -1;
                grid-row: 2;
                padding: 0.32rem 0.45rem;
            }

            .topbar-command .status-event {
                max-width: 62vw;
                font-size: 0.64rem;
            }

            .topbar-metrics span {
                padding: 0.2rem 0.38rem;
                font-size: 0.57rem;
            }

            .topbar-actions {
                grid-column: 2;
                grid-row: 1;
            }

            .topbar-actions .btn {
                padding: 0.22rem 0.38rem;
                font-size: 0.62rem;
            }

            .board-card-fit .board-stage {
                width: 100%;
            }

            .board-card-fit .column-label-row {
                margin-left: 1.25rem;
            }

            .coordinate-toggle {
                font-size: 0.61rem;
            }

            .cell-coordinate {
                display: block;
            }

            .player-command-grid {
                grid-template-columns: repeat(2, minmax(0, 1fr));
                gap: 0.35rem;
            }

            .rail-section-heading .text-game-muted {
                display: none;
            }

            .player-panel-compact {
                padding: 0.42rem;
            }

            .player-editor-line {
                grid-template-columns: minmax(0, 1fr) minmax(5.3rem, 0.75fr);
                gap: 0.22rem;
            }

            .player-name-input,
            .player-controller-select {
                height: 1.7rem;
                padding-right: 0.24rem;
                padding-left: 0.24rem;
                font-size: 0.61rem;
            }

            .player-meta-row {
                gap: 0.18rem 0.42rem;
                margin: 0.26rem 0;
                font-size: 0.52rem;
            }

            .player-panel-compact .hand-grid,
            .player-panel-compact .hand-grid.compact,
            .player-panel-compact.player-panel-current .hand-grid {
                grid-template-columns: repeat(auto-fill, minmax(1.42rem, 1fr));
                gap: 0.13rem;
            }

            .player-panel-compact .hand-tile,
            .player-panel-compact .compact .hand-tile {
                padding: 0.08rem;
                border-radius: 0.27rem;
            }

            .player-panel-compact .hand-tile-faction {
                display: none;
            }

            .player-panel-compact .hand-tile-mark,
            .player-panel-compact .compact .hand-tile-mark {
                font-size: 0.88rem;
            }

            .rail-lower-grid {
                grid-template-columns: 1fr;
            }

            .filter-button {
                font-size: 0.52rem;
            }

            .rules-modal-backdrop {
                padding: 0.5rem;
            }

            .rules-modal-card {
                max-height: calc(100dvh - 1rem);
            }
        }


        /* Six Courts v16 */
        html {
            scroll-behavior: auto !important;
        }

        .setup-hero::after {
            right: -2rem;
            content: "6";
        }

        .setup-variant-option {
            padding: 0.75rem 0.85rem;
            border: 1px solid rgba(217, 173, 98, 0.2);
            border-radius: 0.8rem;
            background: rgba(217, 173, 98, 0.07);
        }

        .setup-variant-option .form-check-input {
            border-color: rgba(255, 255, 255, 0.28);
            background-color: rgba(0, 0, 0, 0.3);
        }

        .setup-variant-option .form-check-input:checked {
            border-color: var(--gold);
            background-color: var(--gold);
        }

        .board-toolbar {
            flex-wrap: wrap;
            align-items: center;
            margin-bottom: 0.45rem;
        }

        .board-card-fit .board-stage {
            margin: 0 auto;
        }

        .board-toolbar-controls {
            display: flex;
            min-width: 0;
            flex-wrap: wrap;
            align-items: center;
            justify-content: flex-end;
            gap: 0.32rem;
        }

        .board-filter-group {
            display: inline-flex;
            align-items: center;
            gap: 0.18rem;
        }

        .board-filter-button {
            display: inline-grid;
            width: 1.72rem;
            height: 1.72rem;
            flex: 0 0 auto;
            padding: 0;
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 0.35rem;
            color: #e8e2d8;
            background: rgba(3, 6, 11, 0.52);
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.24);
            font-size: 0.68rem;
            font-weight: 900;
            line-height: 1;
            place-items: center;
            transition: border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
        }

        .board-filter-button:hover {
            border-color: rgba(255, 255, 255, 0.72);
            filter: brightness(1.08);
        }

        .board-faction-filter {
            border-color: var(--faction-dark);
            background:
                linear-gradient(145deg, rgba(255, 255, 255, 0.22), transparent 42%),
                linear-gradient(155deg, var(--faction-color), var(--faction-dark));
        }

        .board-faction-filter.active {
            border-color: #fff0a6;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(255, 240, 166, 0.34), 0 0 0.75rem rgba(255, 240, 166, 0.34);
        }

        .board-character-filter.active {
            border-color: #68e4ff;
            color: #c7f7ff;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(104, 228, 255, 0.28), 0 0 0.75rem rgba(104, 228, 255, 0.3);
        }


        .board-tile,
        .hand-tile,
        .player-panel-compact .hand-tile,
        .player-panel-compact .compact .hand-tile {
            display: block;
            padding: 0;
            grid-template-rows: none;
        }

        .board-tile::before,
        .hand-tile::before {
            position: absolute;
            inset: 0;
            z-index: 1;
            border-radius: inherit;
            content: "";
            background:
                radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.28), transparent 32%),
                linear-gradient(145deg, transparent 52%, rgba(0, 0, 0, 0.2));
            pointer-events: none;
        }

        .board-tile-faction,
        .board-tile-mark,
        .board-tile-type,
        .hand-tile-faction,
        .hand-tile-mark,
        .hand-tile-type {
            display: none !important;
        }

        .player-display-line {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 0.45rem;
            align-items: center;
        }

        .player-identity-block {
            display: flex;
            min-width: 0;
            align-items: center;
            gap: 0.5rem;
        }

        .player-display-name {
            min-width: 0;
            overflow: hidden;
            color: #f1ece3;
            font-size: 0.84rem;
            font-weight: 900;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .player-controller-display {
            display: inline-flex;
            flex: 0 0 auto;
            align-items: center;
            gap: 0.3rem;
            padding: 0.22rem 0.45rem;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 999px;
            color: #cfc8bc;
            background: rgba(0, 0, 0, 0.22);
            font-size: 0.58rem;
            font-weight: 800;
            white-space: nowrap;
        }

        .controller-indicator {
            width: 0.4rem;
            height: 0.4rem;
            border-radius: 50%;
            background: var(--gold);
            box-shadow: 0 0 0.5rem rgba(217, 173, 98, 0.42);
        }

        .player-edit-button {
            display: inline-grid;
            width: 1.75rem;
            height: 1.75rem;
            padding: 0;
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 0.45rem;
            color: #d9d1c3;
            background: rgba(0, 0, 0, 0.2);
            place-items: center;
            transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
        }

        .player-edit-button:hover,
        .player-edit-button:focus-visible {
            border-color: var(--gold);
            color: #f0cf8e;
            background: rgba(217, 173, 98, 0.1);
        }

        .player-edit-button svg {
            width: 0.9rem;
            height: 0.9rem;
            fill: currentColor;
        }

        .player-panel-eliminated {
            opacity: 0.55;
            filter: grayscale(0.72);
        }

        .player-panel-eliminated::after {
            position: absolute;
            inset: 0;
            z-index: 7;
            border-radius: inherit;
            content: "";
            background:
                linear-gradient(32deg, transparent calc(50% - 1px), rgba(239, 103, 103, 0.58) calc(50% - 1px), rgba(239, 103, 103, 0.58) calc(50% + 1px), transparent calc(50% + 1px)),
                linear-gradient(-32deg, transparent calc(50% - 1px), rgba(239, 103, 103, 0.58) calc(50% - 1px), rgba(239, 103, 103, 0.58) calc(50% + 1px), transparent calc(50% + 1px));
            pointer-events: none;
        }

        .player-panel-eliminated .player-display-name {
            text-decoration: line-through;
            text-decoration-color: rgba(239, 103, 103, 0.9);
            text-decoration-thickness: 2px;
        }

        .player-panel-compact .hand-grid,
        .player-panel-compact .hand-grid.compact {
            grid-template-columns: repeat(auto-fill, minmax(2.42rem, 1fr));
            gap: 0.27rem;
        }

        .player-panel-compact.player-panel-current .hand-grid {
            grid-template-columns: repeat(auto-fill, minmax(2.62rem, 1fr));
        }

        .player-panel-compact .hand-tile,
        .player-panel-compact .compact .hand-tile {
            min-height: 0;
            aspect-ratio: 1 / 1;
            border-radius: 0.48rem;
        }

        .hidden-hand-placeholder,
        .eliminated-hand-space {
            display: flex;
            min-height: 3.1rem;
            align-items: center;
            justify-content: center;
            gap: 0.3rem;
            padding: 0.42rem;
            overflow: hidden;
            border: 1px dashed rgba(255, 255, 255, 0.12);
            border-radius: 0.65rem;
            background: rgba(0, 0, 0, 0.16);
        }

        .hidden-hand-back {
            width: clamp(1.35rem, 2.5vw, 1.9rem);
            aspect-ratio: 0.72 / 1;
            border: 1px solid rgba(217, 173, 98, 0.38);
            border-radius: 0.28rem;
            background:
                linear-gradient(135deg, rgba(217, 173, 98, 0.16), transparent 55%),
                repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.045) 0 3px, transparent 3px 6px),
                #121824;
            box-shadow: 0 0.25rem 0.55rem rgba(0, 0, 0, 0.28);
        }

        .eliminated-hand-space {
            min-height: 2.3rem;
            border-color: rgba(239, 103, 103, 0.16);
            background: rgba(83, 22, 28, 0.08);
        }

        .rail-lower-grid {
            display: block;
        }

        .match-moves-card {
            padding: 0.75rem;
            border-radius: 0.9rem;
            box-shadow: 0 0.75rem 1.8rem rgba(0, 0, 0, 0.2);
        }

        .moves-section {
            margin-top: 0.65rem;
            padding-top: 0.6rem;
            border-top: 1px solid rgba(255, 255, 255, 0.09);
        }

        .match-moves-card .move-log {
            max-height: clamp(5.25rem, 12dvh, 7.75rem);
        }

        .match-moves-card .log-entry {
            gap: 0.42rem;
            padding: 0.4rem 0;
            font-size: 0.7rem;
        }

        .match-moves-card .log-number {
            width: 1.35rem;
            height: 1.35rem;
            font-size: 0.56rem;
        }

        .player-edit-modal-card {
            width: min(480px, 100%);
        }

        @media (max-width: 1099.98px) {
            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 12.9rem));
            }
        }

        @media (max-width: 639.98px) {
            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 10.5rem));
            }
        }

        @media (max-width: 575.98px) {
            .board-toolbar {
                align-items: flex-start;
            }

            .board-toolbar-controls {
                width: 100%;
                justify-content: flex-start;
            }

            .board-filter-button {
                width: 1.58rem;
                height: 1.58rem;
            }

            .coordinate-toggle {
                margin-left: auto;
            }

            .player-identity-block {
                display: grid;
                gap: 0.22rem;
            }

            .player-controller-display {
                width: fit-content;
                padding: 0.16rem 0.34rem;
                font-size: 0.5rem;
            }

            .player-display-name {
                font-size: 0.7rem;
            }

            .player-edit-button {
                width: 1.55rem;
                height: 1.55rem;
            }

            .player-panel-compact .hand-grid,
            .player-panel-compact .hand-grid.compact {
                grid-template-columns: repeat(auto-fill, minmax(1.78rem, 1fr));
                gap: 0.17rem;
            }

            .player-panel-compact.player-panel-current .hand-grid {
                grid-template-columns: repeat(auto-fill, minmax(1.92rem, 1fr));
            }

            .hidden-hand-placeholder {
                min-height: 2.55rem;
            }

            .hidden-hand-back {
                width: 1.2rem;
            }
        }



        /* Six Courts \2014  v4 layout and tile-label repair */
        .board-tile-faction,
        .board-tile-type,
        .hand-tile-faction,
        .hand-tile-type {
            display: none !important;
        }

        .board-tile-mark,
        .hand-tile-mark {
            position: relative;
            z-index: 3;
            display: grid !important;
            width: 100%;
            height: 100%;
            color: var(--tile-ink);
            font-family: Georgia, "Times New Roman", serif;
            font-weight: 800;
            line-height: 1;
            text-align: center;
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.48);
            place-items: center;
            pointer-events: none;
        }

        .board-tile-mark {
            font-size: clamp(1rem, min(4.6vw, 5.2vh), 3rem);
        }

        .hand-tile-mark,
        .player-panel-compact .hand-tile-mark,
        .player-panel-compact .compact .hand-tile-mark {
            font-size: clamp(1rem, 1.7vw, 1.55rem);
        }

        .game-workspace {
            grid-template-columns: minmax(30rem, 1.18fr) minmax(20rem, 0.72fr);
        }

        .board-column {
            display: grid;
            height: calc(100dvh - 5.9rem);
            min-height: 0;
            grid-template-rows: minmax(0, 1fr) auto;
            gap: 0.65rem;
        }

        .board-card-fit {
            min-height: 0;
            height: auto;
            overflow: hidden;
        }

        .board-card-fit .board-stage {
            width: min(100%, calc(100dvh - 15.25rem));
            max-width: none;
            margin: auto;
        }

        .current-player-section {
            min-width: 0;
        }

        .current-player-panel {
            padding: 0.62rem 0.72rem;
            border-radius: 0.95rem;
        }

        .current-player-panel .player-meta-row {
            margin: 0.28rem 0 0.18rem;
        }

        .current-player-hand-rack,
        .player-panel-compact .current-player-hand-rack,
        .player-panel-compact.player-panel-current .current-player-hand-rack {
            display: flex;
            width: 100%;
            min-width: 0;
            flex-wrap: nowrap;
            gap: 0.34rem;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 0.22rem 0.12rem 0.42rem;
            grid-template-columns: none;
            scrollbar-color: rgba(217, 173, 98, 0.42) transparent;
            scroll-snap-type: x proximity;
        }

        .current-player-hand-rack .hand-tile,
        .player-panel-compact .current-player-hand-rack .hand-tile {
            width: clamp(2.65rem, 4.15vw, 3.35rem);
            min-width: clamp(2.65rem, 4.15vw, 3.35rem);
            flex: 0 0 clamp(2.65rem, 4.15vw, 3.35rem);
            aspect-ratio: 1 / 1;
            border-radius: 0.52rem;
            scroll-snap-align: start;
        }

        .current-player-hand-rack .hand-tile-mark,
        .player-panel-compact .current-player-hand-rack .hand-tile-mark {
            font-size: clamp(1.25rem, 2.35vw, 1.95rem);
        }

        .opponent-player-list,
        .player-command-grid {
            grid-template-columns: minmax(0, 1fr);
            gap: 0.45rem;
        }

        .opponent-player-panel .hand-grid,
        .opponent-player-panel .hand-grid.compact {
            grid-template-columns: repeat(auto-fill, minmax(2.35rem, 1fr));
            gap: 0.25rem;
        }

        .opponent-player-panel .hand-tile,
        .opponent-player-panel .compact .hand-tile {
            aspect-ratio: 1 / 1;
        }

        @media (max-width: 1099.98px) {
            .board-column {
                height: calc(100dvh - 8.4rem);
            }

            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 17.6rem));
            }
        }

        @media (min-width: 640px) and (max-width: 899.98px) {
            .game-workspace {
                grid-template-columns: minmax(21rem, 1.08fr) minmax(16rem, 0.92fr);
            }

            .board-card-fit .board-stage {
                width: min(100%, calc(100dvh - 17.8rem));
            }

            .current-player-hand-rack .hand-tile,
            .player-panel-compact .current-player-hand-rack .hand-tile {
                width: 2.55rem;
                min-width: 2.55rem;
                flex-basis: 2.55rem;
            }
        }

        @media (max-width: 639.98px) {
            .board-column {
                display: grid;
                height: auto;
                grid-template-rows: auto auto;
            }

            .board-card-fit {
                overflow: visible;
            }

            .board-card-fit .board-stage {
                width: 100%;
            }

            .game-rail {
                margin-top: 0.65rem;
            }

            .player-command-grid,
            .opponent-player-list {
                grid-template-columns: minmax(0, 1fr);
            }
        }

        @media (max-width: 575.98px) {
            .current-player-panel {
                padding: 0.5rem;
            }

            .current-player-hand-rack .hand-tile,
            .player-panel-compact .current-player-hand-rack .hand-tile {
                width: 2.35rem;
                min-width: 2.35rem;
                flex-basis: 2.35rem;
            }

            .current-player-hand-rack .hand-tile-mark,
            .player-panel-compact .current-player-hand-rack .hand-tile-mark {
                font-size: 1.28rem;
            }

            .opponent-player-panel .hand-grid,
            .opponent-player-panel .hand-grid.compact {
                grid-template-columns: repeat(auto-fill, minmax(1.95rem, 1fr));
            }
        }


        @media (min-width: 640px) {
            .board-card-fit {
                container-type: size;
            }

            @supports (width: 1cqh) {
                .board-card-fit .board-stage {
                    width: min(100%, calc(100cqh - 2.4rem));
                }
            }
        }

        /* Six Courts \2014  setup and legal-move hints */
        .setup-variant-option-disabled {
            opacity: 0.48;
            filter: grayscale(0.55);
        }

        .setup-variant-option-disabled,
        .setup-variant-option-disabled .form-check-input,
        .setup-variant-option-disabled .form-check-label {
            cursor: not-allowed;
        }

        .board-switch-group {
            display: inline-flex;
            flex: 0 0 auto;
            align-items: center;
            gap: 0.55rem;
            margin-left: auto;
        }

        .board-switch-group .coordinate-toggle {
            margin-left: 0;
        }

        .board-cell-hinted:not(.board-cell-legal) {
            border-color: rgba(217, 173, 98, 0.32);
            background: rgba(53, 67, 52, 0.78);
        }

        .cell-hint-layer {
            position: absolute;
            inset: clamp(0.14rem, 0.4vw, 0.3rem);
            z-index: 2;
            display: grid;
            min-width: 0;
            min-height: 0;
            pointer-events: none;
            place-items: center;
        }

        .cell-hint-grid {
            display: grid;
            width: 100%;
            height: 100%;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            grid-template-rows: repeat(2, minmax(0, 1fr));
            gap: clamp(0.07rem, 0.2vw, 0.14rem);
            align-content: center;
        }

        .cell-hint-tile {
            --faction-color: #52616b;
            --faction-dark: #28313a;
            --tile-ink: #ffffff;
            display: grid;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
            border: 1px solid var(--faction-dark);
            border-radius: clamp(0.12rem, 0.3vw, 0.24rem);
            color: var(--tile-ink);
            background:
                linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 42%),
                linear-gradient(155deg, var(--faction-color), var(--faction-dark));
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 0.12rem 0.25rem rgba(0, 0, 0, 0.22);
            font-family: Georgia, "Times New Roman", serif;
            font-size: clamp(0.42rem, min(1.35vw, 1.55vh), 0.82rem);
            font-weight: 900;
            line-height: 1;
            text-align: center;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.52);
            place-items: center;
        }

        .cell-hint-overflow {
            display: grid;
            width: 100%;
            height: 100%;
            color: rgba(240, 222, 181, 0.92);
            font-size: clamp(1.05rem, min(4.2vw, 4.4vh), 2.25rem);
            font-weight: 700;
            line-height: 1;
            text-shadow: 0 0 0.8rem rgba(217, 173, 98, 0.35);
            place-items: center;
        }

        .cell-hint-layer + .cell-coordinate {
            z-index: 4;
            padding: 0 0.12rem;
            border-radius: 0.2rem;
            background: rgba(0, 0, 0, 0.42);
        }

        @media (max-width: 575.98px) {
            .board-toolbar-controls {
                gap: 0.25rem;
            }

            .coordinate-toggle {
                font-size: 0.66rem;
            }

            .cell-hint-layer {
                inset: 0.12rem;
            }
        }
        /* ==================================================================
           AI-TEST FEATURE \2014  CSS START
           Delete this block with the marked setup HTML and JavaScript block
           to remove the AI-Test feature cleanly.
           ================================================================== */
        .ai-test-launch {
            padding-top: 1rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .ai-test-seed-controls {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 0.55rem;
            align-items: end;
            margin-top: 0.75rem;
        }

        .ai-test-seed-controls .form-label {
            color: var(--muted);
            font-size: 0.68rem;
            font-weight: 800;
            letter-spacing: 0.1em;
            text-transform: uppercase;
        }

        .ai-test-panel {
            scroll-margin-top: 1rem;
            overflow: hidden;
        }

        .ai-test-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 1rem;
        }

        .ai-test-meta-line {
            display: flex;
            flex-wrap: wrap;
            gap: 0.45rem 1rem;
            margin-top: 0.55rem;
            color: var(--muted);
            font-size: 0.78rem;
            font-variant-numeric: tabular-nums;
        }

        .ai-test-progress {
            height: 0.8rem;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 999px;
            background: rgba(5, 8, 13, 0.62);
        }

        .ai-test-progress .progress-bar {
            background: linear-gradient(90deg, #bd8d44, #efd293);
            transition: width 180ms linear;
        }

        .ai-test-metric {
            height: 100%;
            padding: 0.85rem 1rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.9rem;
            background: rgba(7, 10, 17, 0.42);
        }

        .ai-test-metric-label {
            margin-bottom: 0.2rem;
            color: var(--muted);
            font-size: 0.7rem;
            font-weight: 800;
            letter-spacing: 0.12em;
            text-transform: uppercase;
        }

        .ai-test-metric-value {
            font-size: clamp(0.95rem, 2vw, 1.18rem);
            font-weight: 800;
            font-variant-numeric: tabular-nums;
            overflow-wrap: anywhere;
        }

        .ai-test-current {
            padding: 0.75rem 0.9rem;
            border-left: 3px solid var(--gold);
            border-radius: 0.3rem 0.8rem 0.8rem 0.3rem;
            color: #e9dcc5;
            background: rgba(217, 173, 98, 0.08);
            font-size: 0.9rem;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
        }

        .ai-test-results-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
            gap: 0.8rem;
        }

        .ai-test-result-card {
            min-width: 0;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.95rem;
            background: rgba(7, 10, 17, 0.42);
        }

        .ai-test-result-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 0.8rem 0.9rem 0.65rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }

        .ai-test-result-title {
            margin: 0;
            font-size: 0.9rem;
            font-weight: 800;
            line-height: 1.3;
        }

        .ai-test-result-count {
            flex: 0 0 auto;
            color: var(--gold);
            font-size: 0.76rem;
            font-weight: 900;
            font-variant-numeric: tabular-nums;
        }

        .ai-test-card-note {
            padding: 0.48rem 0.9rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
            color: var(--muted);
            font-size: 0.7rem;
            line-height: 1.35;
        }

        .ai-test-table-label {
            padding: 0.62rem 0.9rem 0.2rem;
            color: #d8c8aa;
            font-size: 0.67rem;
            font-weight: 900;
            letter-spacing: 0.1em;
            text-transform: uppercase;
        }

        .ai-test-table {
            --bs-table-bg: transparent;
            --bs-table-color: var(--ink);
            --bs-table-border-color: rgba(255, 255, 255, 0.07);
            margin-bottom: 0;
            font-size: 0.8rem;
        }

        .ai-test-table th,
        .ai-test-table td {
            padding: 0.42rem 0.7rem;
            vertical-align: middle;
        }

        .ai-test-table th:first-child,
        .ai-test-table td:first-child {
            padding-left: 0.9rem;
        }

        .ai-test-table th:last-child,
        .ai-test-table td:last-child {
            padding-right: 0.9rem;
        }

        .ai-test-table th {
            color: var(--muted);
            font-size: 0.62rem;
            letter-spacing: 0.07em;
            text-transform: uppercase;
            white-space: nowrap;
        }

        .ai-test-table td:not(:first-child),
        .ai-test-table th:not(:first-child) {
            text-align: right;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }

        .ai-test-seat-table {
            border-top: 1px solid rgba(255, 255, 255, 0.04);
        }

        .ai-test-card-footer {
            display: flex;
            justify-content: space-between;
            gap: 0.75rem;
            padding: 0.58rem 0.9rem;
            border-top: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--muted);
            font-size: 0.7rem;
            font-variant-numeric: tabular-nums;
        }

        .ai-test-error-note {
            padding: 0.65rem 0.9rem;
            border-top: 1px solid rgba(255, 255, 255, 0.08);
            color: #f4b7b7;
            font-size: 0.75rem;
            overflow-wrap: anywhere;
        }

        @media (max-width: 575.98px) {
            .ai-test-header {
                flex-direction: column;
            }

            .ai-test-header .btn-group,
            .ai-test-header .btn {
                width: 100%;
            }

            .ai-test-seed-controls {
                grid-template-columns: 1fr;
            }

            .ai-test-card-footer {
                flex-direction: column;
                gap: 0.2rem;
            }
        }


        .ai-test-json-panel {
            overflow: hidden;
            border: 1px solid rgba(92, 199, 229, 0.24);
            border-radius: 0.9rem;
            background: rgba(7, 10, 17, 0.5);
        }

        .ai-test-json-summary {
            padding: 0.8rem 0.95rem;
            color: #bcecff;
            font-weight: 800;
            cursor: pointer;
            user-select: none;
        }

        .ai-test-json-body {
            padding: 0 0.95rem 0.95rem;
        }

        .ai-test-json-textarea {
            min-height: 14rem;
            max-height: 24rem;
            resize: vertical;
            border-color: rgba(255, 255, 255, 0.12);
            color: #dbe9ef;
            background: rgba(2, 5, 10, 0.75);
            font: 0.72rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
            white-space: pre;
        }

        .ai-test-json-textarea:focus {
            color: #ffffff;
            background: rgba(2, 5, 10, 0.9);
            box-shadow: 0 0 0 0.2rem rgba(92, 199, 229, 0.12);
        }

        /* ==================================================================
           AI-TEST FEATURE \2014  CSS END
           ================================================================== */


        /* Six Courts v16 \2014  Crown scoring */
        .crown-track {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 0.28rem;
            min-height: 1.55rem;
            margin-top: 0.45rem;
        }

        .crown-token {
            width: 1.45rem;
            height: 1.45rem;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            border: 1px solid rgba(255, 255, 255, 0.18);
            background: rgba(8, 10, 22, 0.58);
            color: rgba(255, 255, 255, 0.22);
            font-size: 0.78rem;
            line-height: 1;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
        }

        .crown-token-earned {
            border-color: rgba(247, 207, 92, 0.78);
            background: linear-gradient(145deg, #f5cf62, #b97916);
            color: #241607;
            box-shadow: 0 0 0 1px rgba(255, 226, 129, 0.18), 0 0 12px rgba(235, 179, 48, 0.22);
        }

        .final-round-badge {
            border-color: rgba(247, 207, 92, 0.56) !important;
            color: #f8d76f !important;
            background: rgba(117, 76, 9, 0.22) !important;
        }

        .player-panel-empty-hand {
            opacity: 0.82;
        }

        .result-crown-list {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 0.5rem;
        }


        /* Legacy action-control styles retained for the draw-bag action selector */
        .movement-setting-option {
            border-color: rgba(92, 199, 229, 0.28);
            background: rgba(92, 199, 229, 0.07);
        }

        .movement-setting-current {
            display: inline-flex;
            margin-top: 0.55rem;
            padding: 0.25rem 0.55rem;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 999px;
            color: #cceef7;
            background: rgba(4, 10, 16, 0.45);
            font-size: 0.72rem;
            font-weight: 800;
            letter-spacing: 0.03em;
        }

        .turn-action-bar {
            display: flex;
            min-height: 2.5rem;
            align-items: center;
            justify-content: space-between;
            gap: 0.65rem;
            margin: 0 0 0.55rem;
            padding: 0.48rem 0.58rem;
            border: 1px solid rgba(255, 255, 255, 0.09);
            border-radius: 0.75rem;
            background: rgba(5, 10, 16, 0.44);
        }

        .turn-action-buttons {
            display: inline-flex;
            flex: 0 0 auto;
            gap: 0.35rem;
        }

        .turn-action-button {
            min-width: 6.8rem;
            border-color: rgba(255, 255, 255, 0.18);
            color: #d9d4cb;
            background: rgba(10, 14, 24, 0.55);
        }

        .turn-action-button.active {
            border-color: rgba(217, 173, 98, 0.85);
            color: #241607;
            background: linear-gradient(145deg, #efc765, #b87c20);
            box-shadow: 0 0 0 2px rgba(217, 173, 98, 0.12);
        }

        .turn-action-help {
            min-width: 0;
            color: var(--muted);
            font-size: 0.72rem;
            line-height: 1.25;
            text-align: right;
        }

        .board-cell-source-option {
            cursor: pointer;
            box-shadow:
                inset 0 0 0 2px rgba(92, 199, 229, 0.34),
                inset 0 0 1.1rem rgba(0, 0, 0, 0.2);
        }

        .board-cell-source-selected {
            z-index: 2;
            border-color: rgba(92, 199, 229, 0.95);
            box-shadow:
                inset 0 0 0 3px rgba(92, 199, 229, 0.72),
                0 0 1.3rem rgba(92, 199, 229, 0.38);
        }

        .board-cell-last-source:not(.board-cell-source-selected) {
            box-shadow:
                inset 0 0 0 2px rgba(150, 196, 216, 0.5),
                0 0 0 2px rgba(150, 196, 216, 0.18);
        }

        .lifted-tile-button {
            position: relative;
            box-shadow:
                0 0 0 2px rgba(92, 199, 229, 0.48),
                0 0 1rem rgba(92, 199, 229, 0.22) !important;
        }

        .lifted-tile-caption {
            position: absolute;
            right: 0.12rem;
            bottom: 0.08rem;
            padding: 0.05rem 0.18rem;
            border-radius: 0.22rem;
            color: #e8faff;
            background: rgba(3, 20, 27, 0.82);
            font-size: 0.43rem;
            font-weight: 900;
            letter-spacing: 0.05em;
            line-height: 1.1;
            text-transform: uppercase;
        }

        @media (max-width: 767.98px) {
            .turn-action-bar {
                align-items: stretch;
                flex-direction: column;
            }

            .turn-action-buttons {
                width: 100%;
            }

            .turn-action-button {
                min-width: 0;
                flex: 1 1 0;
            }

            .turn-action-help {
                min-height: 1.8rem;
                text-align: left;
            }
        }


        /* Six Courts v16 \2014  two-set draw bag and rack exchange */
        .hand-tile-exchange-selected {
            box-shadow:
                0 0 0 3px rgba(92, 199, 229, 0.92),
                0 0.55rem 1.15rem rgba(0, 0, 0, 0.32),
                0 0 1.2rem rgba(92, 199, 229, 0.42) !important;
            transform: translateY(-0.28rem);
        }

        .exchange-confirm-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.85rem;
            margin-top: 0.75rem;
            padding-top: 0.75rem;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .exchange-confirm-row .btn {
            flex: 0 0 auto;
            min-width: 8.5rem;
        }

        @media (max-width: 575.98px) {
            .exchange-confirm-row {
                align-items: stretch;
                flex-direction: column;
            }

            .exchange-confirm-row .btn {
                width: 100%;
            }
        }
        .board-cell-lift-source { outline: 2px solid #75d7e8; outline-offset: -3px; }
        .board-cell-lift-selected { outline: 4px solid #f6ce68; outline-offset: -4px; }
        .board-cell-lift-selected .board-tile { opacity: 0.45; }
        .lift-preview { display: flex; align-items: center; gap: 0.8rem; }
        .lift-preview-tile { width: 3.25rem; height: 3.25rem; flex: 0 0 auto; }
    

/* Presentation only. Original rules, Vue handlers and bindings are retained. */
:root {
  --surface: #17241f; --surface-soft: #1b2c25; --field: #142119;
  --page: #0c1913; --ink: #f7f1df; --muted: #a7b6ab; --line: #344638;
  --gold: #d6ba7a; --gold-soft: #d6ba7a26; --on-accent: #152117;
  --board: #243d30; --cell: #294635; --cell-line: #47634c;
  --radius: 16px; --tile-radius: 9px; --font: Arial, Helvetica, sans-serif;
  --display: Georgia, 'Times New Roman', serif; --shadow: 0 12px 36px #00000020;
  --success: #4cba8d; --success-bg: #163f31;
  --bs-body-color: var(--ink); --bs-body-bg: var(--page);
}
body { background: var(--page); color: var(--ink); font-family: var(--font); }
body::before { display: none; }
a { color: inherit; }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.game-shell { width: min(1320px, 100%); padding: 28px; }
.game-shell.py-md-5 { padding-top: 40px !important; }
.game-shell-play { width: min(1480px, 100%); padding: 22px; }
.text-game-muted, .subtitle, .coordinate-toggle, .player-meta-row, .small-caps, .turn-action-help { color: var(--muted) !important; }
.brand-kicker, .section-kicker { color: var(--gold); font: 700 10px/1.4 var(--font); letter-spacing: .18em; }
.display-title { font-family: var(--display); font-size: clamp(3.6rem, 6.5vw, 6.8rem); line-height: .97; letter-spacing: -.055em; margin-bottom: 24px; }
.setup-hero { border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.setup-hero::after { display: none; }
.setup-hero > .row { align-items: stretch !important; }
.setup-hero .col-lg-7 { display: flex; flex-direction: column; justify-content: center; }
.setup-hero .lead { font-size: 16px; line-height: 1.8; max-width: 31rem; }
.setup-control-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.setup-control-card h2 { font-family: var(--display); font-size: 27px; letter-spacing: -.025em; }
.setup-player-row { gap: 12px; }
.setup-player-row .small-caps { font-size: 10px; letter-spacing: .08em; }
.setup-rules-button { right: 24px; top: 18px; }
.glass-panel, .game-card, .player-panel, .rules-modal-card, .game-over-card { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.game-card h2, .rules-modal-card h2, .game-over-card h2 { font-family: var(--display); }
.btn { border-radius: calc(var(--radius) * .5); font-size: 12px; font-weight: 650; padding: 9px 14px; }
.btn-lg { font-size: 14px; padding: 13px 20px; }
.btn-gold, .btn-gold:hover, .btn-gold:focus-visible, .player-count-button.active { color: var(--on-accent); border-color: var(--gold); background: var(--gold); box-shadow: none; }
.btn-gold:hover { filter: brightness(1.07); }
.btn-outline-light, .btn-outline-warning, .btn-outline-info, .player-count-button { color: var(--ink); background: transparent; border: 1px solid var(--line); box-shadow: none; }
.btn-outline-light:hover, .btn-outline-info:hover, .btn-outline-warning:hover, .player-count-button:hover { color: var(--on-accent); background: var(--gold); border-color: var(--gold); }
.btn:disabled { opacity: .4; color: var(--muted); border-color: var(--line); background: transparent; }
.form-control, .form-select, .form-control:focus, .form-select:focus { color: var(--ink); background-color: var(--field); border: 1px solid var(--line); border-radius: calc(var(--radius) * .45); font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
.form-select:focus, .form-control:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.form-select option { background: var(--surface); color: var(--ink); }
.form-select { --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b9094' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); }
.setup-variant-option, .summary-stat, .ai-test-metric, .ai-test-result-card, .ai-test-json-panel { border-color: var(--line); background: var(--field); border-radius: calc(var(--radius) * .6); }
.ai-test-launch, .ai-test-result-header, .ai-test-card-footer, .ai-test-card-note, .exchange-confirm-row { border-color: var(--line); }
.ai-test-table { --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.ai-test-current, .ai-test-table-label, .ai-test-json-summary { color: var(--ink); background: var(--gold-soft); }
.ai-test-progress { border-color: var(--line); background: var(--field); }
.ai-test-progress .progress-bar { background: var(--gold); }
.ai-test-json-textarea { color: var(--ink); background: var(--field); }
.rule-loop { color: var(--muted); font-size: 10px; gap: 10px; letter-spacing: .04em; }
.rule-loop .arrow { color: var(--gold); }
.hero-tiles { display: flex; gap: 8px; margin: 16px 0 36px; padding: 14px 0; }
.hero-tile { display: grid; position: relative; place-items: center; width: clamp(40px, 5vw, 64px); aspect-ratio: 1; border: 1px solid var(--faction-dark); border-radius: var(--tile-radius); background: var(--faction-color); color: var(--tile-ink); font: 700 clamp(24px, 3vw, 38px)/1 var(--display); box-shadow: 0 6px 0 var(--faction-dark), 0 12px 14px #00000018; transform: rotate(var(--tilt)); }
.hero-note { margin-top: 30px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.topbar.compact-topbar { position: relative; top: auto; margin: 0 0 20px; padding: 0 0 20px; color: var(--ink); background: transparent; border-color: var(--line); box-shadow: none; backdrop-filter: none; }
.topbar-grid { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 24px; }
.topbar-title { font-family: var(--display); font-size: 29px; font-weight: 700; letter-spacing: -.04em; white-space: nowrap; }
.topbar-brand { min-width: 0; }
.compact-topbar .topbar-title { display: block; font-size: var(--brand-size,29px); }
.topbar-command .status-title { font-size: var(--status-size,18px); line-height: 1.35; }
.topbar-command .status-event { max-width: 450px; font-size: 11px; }
.topbar-brand::after { content: "THE STRATEGY TABLE"; display: block; color: var(--muted); font-size: 8px; letter-spacing: .22em; margin-top: 4px; }
.topbar-command { display: flex; min-width: 0; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; padding: 10px 16px; border: 1px solid var(--line); border-radius: calc(var(--radius) * .65); background: var(--surface); }
.status-title { color: var(--ink); font-family: var(--display); font-size: 19px; line-height: 1.3; }
.status-event { max-width: 450px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.topbar-metrics { display: flex; flex-wrap: wrap; gap: 5px; }
.topbar-metrics span { color: var(--muted); background: var(--field); border-color: var(--line); border-radius: 5px; padding: 4px 7px; font-size: 10px; font-weight: 500; }
.topbar-actions { flex-wrap: wrap; gap: 6px; }
.game-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 295px; gap: 22px; align-items: start; }
.board-column { display: grid; height: auto; min-width: 0; grid-template-rows: auto auto; gap: 18px; }
.board-card-fit { height: auto; min-height: 0; max-height: none; overflow: visible; container-type: normal; padding: 20px; }
.board-card-fit .board-stage { width: min(100%, 580px); max-width: 580px; margin: 18px auto 0; }
.board-toolbar { gap: 12px; align-items: center; margin-bottom: 14px; }
.board-toolbar-controls { flex-wrap: wrap; gap: 8px; }
.board-filter-group { gap: 4px; }
.board-filter-button { width: 25px; height: 25px; border-radius: 5px; border-color: var(--line); color: var(--ink); background: var(--field); box-shadow: none; font: 700 11px/1 var(--display); }
.board-faction-filter { border-color: #181818; background: var(--faction-color); box-shadow: 0 0 0 1px #ffffff; }
.board-faction-filter.active, .board-character-filter.active { border-color: var(--gold); outline: 2px solid var(--gold); outline-offset: 2px; color: var(--ink); box-shadow: none; }
.board-switch-group { gap: 12px; }
.coordinate-toggle { font-size: 10px; }
.form-check-input, .coordinate-toggle .form-check-input, .setup-variant-option .form-check-input { border-color: var(--line); background-color: var(--field); }
.form-check-input:checked, .coordinate-toggle .form-check-input:checked, .setup-variant-option .form-check-input:checked { border-color: var(--gold); background-color: var(--gold); }
.turn-action-bar { gap: 10px; padding: 8px; margin: 0; background: var(--field); border-color: var(--line); border-radius: calc(var(--radius) * .55); }
.turn-action-buttons { gap: 5px; flex-wrap: wrap; }
.turn-action-button { color: var(--muted); min-width: 80px; padding: 9px 11px; background: transparent; border-color: transparent; font-size: 11px; }
.turn-action-button.active { color: var(--on-accent); background: var(--gold); border-color: var(--gold); box-shadow: none; }
.turn-action-help { max-width: 250px; font-size: 10px; line-height: 1.5; }
.game-board { padding: 12px; gap: 7px; background: var(--board); border: 1px solid var(--cell-line); border-radius: calc(var(--radius) * .7); box-shadow: none; }
.board-cell { padding: 0; border: 1px solid var(--cell-line); border-radius: var(--tile-radius); background: var(--cell); box-shadow: none; }
.board-cell:not(:disabled):hover { transform: translateY(-1px); }
.board-cell-legal { background: var(--success-bg); border-color: var(--success); box-shadow: inset 0 0 0 1px var(--success); }
.board-cell-legal:not(:disabled):hover { background: var(--success-bg); box-shadow: inset 0 0 0 2px var(--success); }
.board-cell-hinted:not(.board-cell-legal) { background: var(--cell); border-color: var(--gold); }
.board-cell-last { box-shadow: 0 0 0 2px var(--gold); border-color: var(--gold); }
.board-cell-captured { background: var(--gold-soft); border-color: var(--gold); }
.cell-coordinate { color: var(--muted); font: 9px/1.2 var(--font); }
.column-label-row, .row-label-column { color: var(--muted); font: 10px/1 var(--font); }
.board-row-shell { grid-template-columns: 16px minmax(0,1fr); gap: 6px; }
.board-card-fit .column-label-row { margin: 10px 12px 0 34px; }
.legal-marker { color: var(--success); }
.cell-hint-overflow { color: var(--gold); text-shadow: none; }
.board-tile, .hand-tile, .removed-tile { color: var(--tile-ink); border-color: var(--faction-dark); background: linear-gradient(145deg, var(--faction-color), var(--faction-dark)); text-shadow: none; }
.board-tile, .hand-tile { border-radius: var(--tile-radius); box-shadow: inset 0 1px 0 #ffffff38, inset 0 -4px 0 #00000018; }
.board-tile::before, .hand-tile::before { background: linear-gradient(145deg, #ffffff14, transparent 60%); }
.board-tile-mark, .hand-tile-mark { font-family: var(--display); text-shadow: none; }
.board-tile-mark { font-size: clamp(24px, 4vw, 38px); }
.current-player-panel { padding: 18px; border: 1px solid var(--gold); border-radius: var(--radius); }
.player-panel-current { box-shadow: var(--shadow); }
.player-panel-current::before { background: var(--gold); width: 3px; }
.player-display-name { color: var(--ink); font-size: 14px; font-weight: 700; }
.player-controller-display { color: var(--muted); background: var(--field); border-color: var(--line); border-radius: 5px; font-size: 9px; }
.controller-indicator { background: var(--gold); box-shadow: none; }
.player-edit-button { width: 28px; height: 28px; color: var(--muted); background: var(--field); border-color: var(--line); border-radius: 6px; }
.player-meta-row { font-size: 10px; gap: 14px; margin: 8px 0; }
.current-player-panel .player-meta-row { margin: 7px 0; }
.crown-track { gap: 6px; margin: 8px 0; }
.crown-token { width: 22px; height: 22px; border-color: var(--line); color: var(--muted); background: var(--field); box-shadow: none; opacity: .65; }
.crown-token-earned { color: var(--on-accent); background: var(--gold); border-color: var(--gold); opacity: 1; }
.current-player-hand-rack, .player-panel-compact .current-player-hand-rack, .player-panel-compact.player-panel-current .current-player-hand-rack { gap: 8px; padding: 8px 4px 10px; }
.current-player-hand-rack .hand-tile, .player-panel-compact .current-player-hand-rack .hand-tile { width: clamp(38px, 4.5vw, 58px); min-width: clamp(38px, 4.5vw, 58px); flex-basis: clamp(38px, 4.5vw, 58px); border-radius: var(--tile-radius); }
.current-player-hand-rack .hand-tile-mark, .player-panel-compact .current-player-hand-rack .hand-tile-mark { font-size: 27px; }
.hand-tile-selected, .player-panel-compact .hand-tile-selected { outline: 3px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 0 5px var(--gold-soft); }
.game-rail { display: grid; height: auto; max-height: none; overflow: visible; gap: 22px; padding: 0; }
.rail-section-heading { margin-bottom: 12px; align-items: center; }
.rail-section-heading .small { font-size: 10px; }
.opponent-player-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
.opponent-player-panel { padding: 16px; }
.opponent-player-panel .hand-grid, .opponent-player-panel .hand-grid.compact { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px; }
.opponent-player-panel .hand-tile, .opponent-player-panel .compact .hand-tile { border-radius: var(--tile-radius); }
.opponent-player-panel .hand-tile-mark { font-size: 24px; }
.rail-lower-grid { display: block; }
.match-moves-card { padding: 18px; }
.match-moves-card h2 { font-size: 14px; }
.match-moves-card .move-log { max-height: 200px; }
.match-moves-card .log-entry { color: var(--muted); font-size: 11px; line-height: 1.6; padding: 9px 0; border-color: var(--line); }
.match-moves-card .log-number { color: var(--gold); background: var(--field); border-color: var(--line); border-radius: 5px; width: 20px; height: 20px; font-size: 9px; }
.hidden-hand-placeholder { background: transparent; border-color: var(--line); }
.hidden-hand-back { border-color: var(--line); background: repeating-linear-gradient(45deg, var(--surface) 0 3px, var(--gold-soft) 3px 5px); }
.text-bg-dark { color: var(--muted) !important; background: var(--field) !important; }
.border-game, .rules-modal-header { border-color: var(--line) !important; }
.rules-modal-card, .game-over-card { background: var(--surface); }
.rules-modal-body { color: var(--ink); }
.rules-intro, .rules-tip, .rules-step { color: var(--ink); }
.rules-intro, .rules-tip { border-color: var(--line); background: var(--field); }
.rules-step-number { color: var(--gold); background: var(--gold-soft); border-color: var(--line); }
.rules-modal-card .btn-close { filter:none;background:var(--ink);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 6 12 12M6 18 18 6' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E") center/contain no-repeat; }
.rules-modal-body .rule-box { color: var(--ink); background: var(--field); border-color: var(--line); }
.rules-modal-backdrop, .game-over-backdrop { background: #0c132ab3; backdrop-filter: blur(8px); }
.capture-banner { color: var(--ink); border-color: var(--gold); background: var(--gold-soft); }
.result-title { color: var(--ink); font-family: var(--display); }
.result-subtitle { color: var(--gold); }
.tile-dimmed { opacity: .28; }
.board-tile.tile-filter-faction-match::after, .hand-tile.tile-filter-faction-match::after,
.board-tile.tile-filter-type-match::after, .hand-tile.tile-filter-type-match::after,
.board-tile.tile-filter-double-match::after, .hand-tile.tile-filter-double-match::after {
  content: ''; position: absolute; inset: 0; width: auto; height: auto; transform: none; opacity: 1;
  background: transparent; border: 3px solid var(--gold); border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--surface); z-index: 4; pointer-events: none;
}
.board-tile.tile-filter-type-match::after, .hand-tile.tile-filter-type-match::after { border-color: #299abb; }
.board-tile.tile-filter-double-match::after, .hand-tile.tile-filter-double-match::after { border-color: var(--gold); box-shadow: inset 0 0 0 2px #299abb; }
@media (max-width: 1100px) {
  .game-workspace { grid-template-columns: minmax(0,1fr) 245px; gap: 16px; }
  .topbar-grid { grid-template-columns: 1fr auto; gap: 12px; }
  .topbar-command { grid-row: 2; grid-column: 1 / -1; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .board-column { height: auto; }
  .board-card-fit { padding: 14px; }
  .board-card-fit .board-stage { width: 100%; }
  .board-toolbar { align-items: flex-start; }
  .board-toolbar-controls { justify-content: flex-start; }
  .turn-action-bar { flex-direction: column; align-items: stretch; }
  .turn-action-buttons { display: flex; }
  .turn-action-button { flex: 1; min-width: 0; }
  .turn-action-help { max-width: none; text-align: left; }
}
@media (max-width: 760px) {
  .game-shell, .game-shell-play { padding: 14px; }
  .game-shell.py-md-5 { padding-top: 20px !important; }
  .game-workspace { display: flex; flex-direction: column; gap: 20px; }
  .board-column, .game-rail { width: 100%; height: auto; }
  .game-rail { margin: 0; }
  .topbar.compact-topbar { padding-bottom: 14px; margin-bottom: 14px; }
  .topbar-grid { gap: 14px; }
  .topbar-title { font-size: 25px; }
  .compact-topbar .topbar-title { font-size: 25px; }
  .topbar-command .status-event { max-width: 75vw; font-size: 10px; }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn { padding: 7px 9px; font-size: 10px; }
  .topbar-command { padding: 12px; }
  .topbar-metrics { flex-wrap: wrap; }
  .topbar-brand::after { font-size: 7px; }
  .board-card-fit .board-stage { width: 100%; margin-top: 14px; }
  .board-toolbar { flex-direction: column; }
  .board-toolbar-controls { width: 100%; gap: 9px; }
  .board-switch-group { width: 100%; margin: 4px 0 0; }
  .coordinate-toggle { margin-left: 0; }
  .board-filter-button { width: 26px; height: 26px; }
  .game-board { padding: 7px; gap: 5px; }
  .board-tile-mark { font-size: clamp(20px, 6vw, 34px); }
  .current-player-panel, .opponent-player-panel { padding: 14px; }
  .current-player-hand-rack .hand-tile, .player-panel-compact .current-player-hand-rack .hand-tile { width: 40px; min-width: 40px; flex-basis: 40px; }
  .opponent-player-panel .hand-grid, .opponent-player-panel .hand-grid.compact { grid-template-columns: repeat(8, minmax(0,1fr)); }
  .opponent-player-panel .hand-tile-mark { font-size: 20px; }
  .player-identity-block { display: flex; flex-wrap: wrap; gap: 8px; }
  .player-display-name { font-size: 14px; }
  .player-controller-display { font-size: 9px; }
  .hero-tiles { gap: 7px; }
  .hero-tile { width: 44px; }
  .display-title { font-size: 58px; }
}
@media (max-width: 370px) {
  .game-shell-play { padding: 8px; }
  .topbar-title { font-size: 22px; }
  .topbar-actions .btn { padding: 6px; }
  .board-filter-button { width: 23px; height: 23px; }
  .board-toolbar-controls { gap: 6px; }
  .player-meta-row { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

:root { color-scheme: dark; --page: #0c1913; --surface: #13251d; --surface-soft: #193027; --field: #0e2018; --ink: #f1ead7; --muted: #a5b5a8; --line: #33473a; --gold: #d3b776; --gold-soft: #d3b77619; --on-accent: #132116; --board: #223b2c; --cell: #294936; --cell-line: #49664e; --radius: 12px; --tile-radius: 6px; --display: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif; --shadow: 0 16px 40px #0000001e; }
body { --brand-size: 35px; background-image: radial-gradient(ellipse at 45% 0, #284b2a38, transparent 65%); }
.game-shell-play { max-width: 1390px; }
.topbar-title { font-weight: 400; letter-spacing: -.045em; font-size: 35px; }
.topbar-brand::after { content: 'THE ROYAL CLUB'; color: var(--gold); letter-spacing: .23em; }
.topbar-command { border-color: transparent; background: transparent; border-left: 1px solid var(--line); border-radius: 0; padding-left: 26px; }
.topbar-metrics span { background: transparent; border: 0; border-right: 1px solid var(--line); border-radius: 0; padding-right: 12px; }
.topbar-metrics span:last-child { border-right: 0; }
.setup-hero { border: 1px solid #786947; box-shadow: inset 0 0 0 7px #13251d, inset 0 0 0 8px #334638; }
.display-title { font-weight: 400; }
.setup-hero .lead { font-family: var(--display); font-size: 19px; }
.hero-tile { background: #f2e9d3; color: var(--faction-color); border: 1px solid #dbc6a0; box-shadow: 0 5px 0 #b8a582, 0 14px 14px #0000002b; }
.hero-tile::after { content: ''; position: absolute; inset: 5px; border: 1px solid var(--faction-color); border-radius: 3px; opacity: .6; }
.hero-note { color: var(--gold); }
.board-card { border-color: #4c5139; background: linear-gradient(145deg, #1b2c21, #14261c); box-shadow: inset 0 0 0 5px #16271d, inset 0 0 0 6px #374532, 0 16px 40px #00000029; padding: 24px; }
.board-card .section-kicker::before { content: '\265B'; font-size: 17px; margin-right: 9px; vertical-align: -1px; }
.game-board { border: 7px solid #3a3527; outline: 1px solid #6f6346; background: repeating-linear-gradient(10deg, #233b2c 0 2px, #263d2f 2px 4px); padding: 12px; gap: 7px; border-radius: 8px; box-shadow: 0 0 0 3px #151e15, inset 0 0 24px #00000055, 0 10px 20px #00000025; }
.board-cell { background: #2b4635; border-color: #46604b; box-shadow: inset 0 2px 5px #00000025; }
.board-tile, .hand-tile { background: linear-gradient(140deg, #fff9e8, #e1d4b7); border-color: #c5af85; box-shadow: inset 0 1px 0 #fff, inset 0 -4px 0 #baaa8b, 0 2px 3px #00000024; }
.board-tile::before, .hand-tile::before { inset: 5px; border: 1px solid var(--faction-color); border-radius: 2px; background: none; opacity: .65; }
.board-tile-mark, .hand-tile-mark { color: var(--faction-dark); font-weight: 500; }

.cell-hint-tile { background: #eee3cc; color: var(--faction-color); border-color: var(--faction-color); text-shadow: none; box-shadow: none; }
.board-cell-legal { border-color: #8ab693; background: #3d6445; box-shadow: inset 0 0 0 1px #8ab693; }
.board-cell-legal:not(:disabled):hover { background: #4a7551; }
.player-display-name { font-family: var(--display); font-size: 18px; font-weight: 500; }
.current-player-panel { background: #192b20; border-color: #8a7950; }
.current-player-panel .crown-track { position: absolute; right: 55px; top: 13px; }
.crown-token { border: 0; background: transparent; font-size: 18px; }
.crown-token-earned { color: var(--gold); background: transparent; }
.player-controller-display { border-radius: 30px; }
.hand-tile-selected { background: #fff3c8; }
.match-moves-card { background: transparent; border: 0; box-shadow: none; padding: 5px 2px; }
.match-moves-card h2 { font-size: 18px; font-weight: 400; }
.turn-action-bar { background: #0b1b13; }
.turn-action-button.active { background: linear-gradient(#d9c38b, #bda264); border-color: #d4bd83; }
@media (max-width:760px) { .board-card { padding: 15px; } .game-board { border-width: 5px; padding: 7px; gap: 5px; } .topbar-command { padding-left: 0; border-left: 0; } .current-player-panel .crown-track { position: static; } .board-tile::before, .hand-tile::before { inset: 4px; }  }

/* Shared presentation for the four Royal Club studies. No gameplay changes. */
:root{--radius:8px;--tile-radius:5px;--shadow:none;--brand-size:29px;--status-size:14px}
body{background-image:none}
.game-shell-play{max-width:1080px;padding:30px 28px 40px}
.topbar.compact-topbar{margin-bottom:28px;padding-bottom:18px;border:0}
.topbar-grid{grid-template-columns:1fr auto 1fr;gap:18px}
.topbar-brand::after{display:none}
.topbar-title{font-weight:400!important;letter-spacing:-.04em}
.topbar-command{padding:0;border:0;background:transparent;display:block;text-align:center}
.topbar-command .status-title{justify-content:center;font:14px/1.5 var(--font)}
.topbar-command .status-event{display:none}
.topbar-metrics{justify-content:center;margin-top:3px}
.topbar-metrics span{display:none}
.topbar-metrics span:nth-child(3),.topbar-metrics .final-round-badge{display:inline;border:0;padding:0;font-size:10px}
.topbar-actions{justify-content:flex-end;gap:6px}
.icon-control,.topbar-actions .btn{display:inline-flex;align-items:center;justify-content:center;width:42px;height:42px;min-width:42px;padding:10px;border:0;border-radius:50%;background:transparent;color:var(--muted);position:relative}
.icon-control:hover,.topbar-actions .btn:hover{background:var(--gold-soft);color:var(--ink)}
.ui-icon{width:20px;height:20px;display:block;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;flex:none}
.sr-label{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip-path:inset(50%)!important;white-space:nowrap!important;padding:0!important;border:0!important}
[data-tooltip]{position:relative}
[data-tooltip]::after{content:attr(data-tooltip);position:absolute;bottom:calc(100% + 8px);left:50%;transform:translateX(-50%);background:var(--ink);color:var(--page);border-radius:5px;padding:7px 9px;white-space:nowrap;font:11px/1.3 var(--font);pointer-events:none;opacity:0;z-index:50;transition:opacity .15s}
[data-tooltip]:hover::after,[data-tooltip]:focus-visible::after{opacity:1}
.game-workspace{max-width:910px;margin:auto;grid-template-columns:minmax(0,1fr) 210px;gap:26px}
.board-column{gap:20px}
.board-card{padding:0;border:0;background:transparent;box-shadow:none;position:relative;display:flex;flex-direction:column}
.board-card-fit .board-stage{width:100%;max-width:560px;margin:0 auto}
.board-tools{position:absolute;right:0;top:-48px;z-index:10}
.board-tools summary,.history-drawer>summary{list-style:none;cursor:pointer}
summary::-webkit-details-marker{display:none}
.board-tools[open]>summary,.history-drawer[open]>summary{color:var(--gold);background:var(--gold-soft)}
.board-toolbar{position:absolute;right:0;top:48px;margin:0;padding:18px;min-width:270px;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:0 15px 40px #0003;display:block}
.board-toolbar>.section-kicker{display:none}
.board-toolbar-controls{display:flex;flex-direction:column;align-items:stretch;gap:16px}
.board-filter-group{justify-content:space-between;gap:8px}
.board-filter-button{width:29px;height:29px;min-width:29px}
.board-switch-group{display:flex;gap:22px}
.coordinate-toggle{font-size:11px}
.turn-action-bar{order:2;border:0;border-radius:0;background:transparent;margin:12px 0 0;padding:0;display:flex;align-items:center;justify-content:center;gap:16px;min-height:44px}
.turn-action-buttons{gap:6px;flex-wrap:nowrap;width:auto;flex:0 0 auto}
.topbar-actions>.btn:last-child::after,.board-tools>summary::after{left:auto;right:0;transform:none}
.turn-action-button,.turn-action-buttons>.btn{width:44px;height:44px;min-width:44px;border-radius:50%;padding:11px;border:0;display:flex;align-items:center;justify-content:center;position:relative;flex:none;color:var(--muted)}
.turn-action-button.active{background:var(--gold-soft);color:var(--gold);border:0;box-shadow:none}
.turn-action-button:not(:disabled):hover{background:var(--gold-soft);color:var(--ink)}
.turn-action-help{font-size:10px;line-height:1.5;text-align:left;max-width:220px;color:var(--muted)}
.lift-count{position:absolute;right:2px;top:1px;font:9px/1 var(--font);color:var(--muted)}
.game-board{padding:9px;gap:4px;border:1px solid var(--cell-line);outline:0;border-radius:7px;background:var(--board);box-shadow:0 12px 30px #0002}
.board-cell{border:1px solid transparent;border-radius:4px;background:var(--cell);box-shadow:none}
.board-cell:nth-child(12n+2),.board-cell:nth-child(12n+4),.board-cell:nth-child(12n+6),.board-cell:nth-child(12n+7),.board-cell:nth-child(12n+9),.board-cell:nth-child(12n+11){background:var(--cell-alt,var(--cell))}
.board-cell-legal,.board-cell-legal:nth-child(n){background:var(--success-bg);border:1px solid var(--success);box-shadow:inset 0 0 0 1px var(--success)}
.board-cell-last{outline:1px solid var(--gold);outline-offset:-2px;box-shadow:none}
.board-tile,.hand-tile{background:linear-gradient(135deg,#fcf6e7,#e9dfc7);border:1px solid #c5b998;border-radius:var(--tile-radius);box-shadow:inset 0 1px 0 #fff9,inset 0 -3px 0 #bfb292,0 2px 3px #0002}
.board-tile::before,.hand-tile::before{display:none}

.board-tile-mark,.hand-tile-mark{color:var(--faction-dark);font-family:Georgia,'Times New Roman',serif;font-weight:400}
.board-tile-mark{font-size:clamp(24px,4vw,38px)}
.cell-coordinate{font-size:7px;opacity:.45;right:3px;bottom:3px}
.row-label-column,.column-label-row{font:9px/1 var(--font);opacity:.55}
.board-row-shell{grid-template-columns:12px minmax(0,1fr);gap:6px}
.board-card-fit .column-label-row{margin:10px 10px 0 28px}
.current-player-panel{padding:0 0 6px;border:0;border-radius:0;background:transparent;box-shadow:none;display:grid;grid-template-columns:1fr auto;gap:0 12px;max-width:560px;margin:auto}
.current-player-panel::before{display:none}
.current-player-panel .player-display-line{grid-column:1;grid-row:1;justify-content:flex-start;gap:8px}
.current-player-panel .crown-track{position:static;grid-column:2;grid-row:1;margin:0;align-self:center}
.current-player-panel .player-meta-row{display:none}
.current-player-panel .current-player-hand-rack,.current-player-panel .lift-preview,.current-player-panel .exchange-confirm-row,.current-player-panel .empty-hand{grid-column:1/-1}
.player-controller-display{display:none}
.player-display-name{font:15px/1.4 var(--display);font-weight:400}
.player-edit-button{border:0;background:transparent;width:30px;height:30px;border-radius:50%;color:var(--muted)}
.player-edit-button svg{width:13px;height:13px}
.crown-track{gap:3px;margin:0}
.crown-token{font-size:18px;width:20px;height:24px;border:0;background:transparent;color:var(--muted);opacity:.22}
.crown-token-earned{background:transparent;color:var(--gold);opacity:1}
.current-player-hand-rack,.player-panel-compact .current-player-hand-rack,.player-panel-compact.player-panel-current .current-player-hand-rack{justify-content:center;flex-wrap:nowrap;overflow:visible;padding:13px 8px 12px;margin-top:6px;gap:6px;border-bottom:5px solid var(--rack-edge,#655237);background:linear-gradient(0deg,var(--rack-fill,#816a47) 0 10px,transparent 10px);border-radius:0 0 5px 5px;box-shadow:0 6px 8px -6px #0008}
.current-player-hand-rack .hand-tile,.player-panel-compact .current-player-hand-rack .hand-tile{width:calc((100% - 42px)/8);min-width:0;max-width:58px;flex:0 1 58px;aspect-ratio:1/1.08;height:auto}
.current-player-hand-rack .hand-tile-mark,.player-panel-compact .current-player-hand-rack .hand-tile-mark{font-size:27px}
.hand-tile-selected,.player-panel-compact .hand-tile-selected{transform:translateY(-8px);outline:2px solid var(--gold);outline-offset:2px;box-shadow:0 5px 8px #0003}
.game-rail{gap:22px;padding-top:0;overflow:visible}
.rail-section-heading{display:none}
.opponent-player-list{gap:0}
.opponent-player-panel{padding:12px 0;border:0;border-bottom:1px solid var(--line);border-radius:0;background:transparent;box-shadow:none;position:relative}
.seat-summary{list-style:none;cursor:pointer;display:grid;grid-template-columns:1fr auto;gap:5px;padding-right:18px;position:relative;align-items:center;min-height:40px}
.seat-summary::after{content:'';position:absolute;right:2px;top:16px;width:5px;height:5px;border-right:1px solid var(--muted);border-bottom:1px solid var(--muted);transform:rotate(45deg)}
.opponent-player-panel[open] .seat-summary::after{transform:rotate(225deg)}
.seat-summary .player-display-line{grid-column:1;gap:2px;justify-content:flex-start}
.seat-summary .player-identity-block{min-width:0}
.seat-summary .crown-track{grid-column:2;grid-row:1}
.seat-summary .player-meta-row{grid-column:1/-1;margin:0;font-size:9px;gap:10px}
.seat-summary .player-meta-row>span:first-child{display:none}
.opponent-player-panel:not([open]) .player-meta-row,.opponent-player-panel:not([open]) .player-edit-button{display:none}
.opponent-player-panel .hand-grid,.opponent-player-panel .hand-grid.compact{margin-top:12px;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px}
.opponent-player-panel .hand-tile-mark{font-size:24px}
.history-drawer{position:relative;padding:0;border:0;background:transparent;box-shadow:none}
.history-drawer>summary{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:11px;padding:10px 0}
.history-drawer .move-log{padding:10px 0;max-height:240px}
.history-drawer .history-count{margin-left:auto;color:var(--muted);font:10px var(--font)}
.history-drawer .log-entry{font-size:10px}
.capture-banner{font-size:11px;border-radius:5px;background:var(--gold-soft)}
.setup-hero{box-shadow:none;border:0;background:transparent;padding:30px!important}
.setup-hero .brand-kicker,.setup-hero .rule-loop,.hero-note{display:none}
.setup-hero .lead{font:18px/1.5 var(--display);max-width:330px}
.display-title{font-size:clamp(56px,7vw,86px)}
.hero-tiles{gap:7px;margin:28px 0;max-width:380px}
.hero-tile{width:50px;border-radius:5px;transform:none;font-weight:400}
.hero-tile::after{display:none}
.setup-card{border-radius:10px;box-shadow:none}
@media(max-width:760px){
 .game-shell-play{padding:20px 14px 30px;max-width:620px}
 .topbar.compact-topbar{margin-bottom:20px;padding:0 0 12px}
 .topbar-grid{grid-template-columns:1fr auto;gap:8px}
 .compact-topbar .topbar-title{font-size:27px}
 .topbar-actions{grid-column:2;grid-row:1;gap:0}
 .topbar-actions .btn{width:38px;height:38px;min-width:38px;padding:9px}
 .topbar-command{grid-column:1/-1;grid-row:2;display:flex;justify-content:space-between;align-items:center;margin-top:5px;text-align:left}
 .topbar-command .status-title{font-size:12px;justify-content:flex-start}
 .topbar-metrics{margin:0}
 .game-workspace{display:flex;flex-direction:column;gap:22px}
 .board-column{gap:16px;width:100%}
 .board-card-fit{padding:0}
 .board-card-fit .board-stage{margin-top:0}
 .board-tools{top:auto;bottom:0;right:0}
 .board-toolbar{top:auto;bottom:48px;right:0;min-width:260px}
 .turn-action-bar{justify-content:flex-start;gap:10px;margin-top:9px;padding-right:44px;min-height:44px;flex-direction:row}
 .turn-action-buttons{gap:2px}
 .turn-action-button,.turn-action-buttons>.btn{min-width:40px;width:40px;height:40px;flex:none}
 .turn-action-help{font-size:9px;max-width:180px}
 .game-board{gap:3px;padding:6px}
 .board-tile-mark{font-size:29px}
 
 .current-player-hand-rack,.player-panel-compact .current-player-hand-rack{gap:4px;padding:11px 3px 10px}
 .current-player-hand-rack .hand-tile,.player-panel-compact .current-player-hand-rack .hand-tile{width:calc((100% - 28px)/8);min-width:0;max-width:52px;flex:0 1 52px}
 .current-player-hand-rack .hand-tile-mark,.player-panel-compact .current-player-hand-rack .hand-tile-mark{font-size:24px}
 .current-player-panel{padding:0;border:0}
 .game-rail{width:100%;gap:12px}
 .opponent-player-list{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
 .opponent-player-panel{padding:8px 0}
 .seat-summary{display:flex;flex-wrap:wrap;gap:4px;justify-content:space-between;padding-right:12px}
 .seat-summary .player-display-name{font-size:14px}
 .seat-summary .player-meta-row{flex-basis:100%;gap:5px}
 .crown-token{width:15px;font-size:15px}
 .opponent-player-panel .hand-grid,.opponent-player-panel .hand-grid.compact{grid-template-columns:repeat(4,minmax(0,1fr))}
 .opponent-player-panel .hand-tile-mark{font-size:23px}
 .setup-hero{padding:16px 8px!important}
}
@media(max-width:370px){.game-shell-play{padding:16px 10px}.turn-action-help{max-width:130px}.board-tile-mark{font-size:26px}.current-player-hand-rack .hand-tile-mark{font-size:21px}}

:root{--page:#211c18;--surface:#302820;--surface-soft:#302820;--field:#211c18;--ink:#eee3ce;--muted:#b6a48f;--line:#4c4033;--gold:#d4ac70;--gold-soft:#d4ac7020;--board:#775536;--cell:#c6ac7d;--cell-alt:#96764e;--cell-line:#906e47;--success:#e9cc82;--success-bg:#aa925d;--rack-fill:#937044;--rack-edge:#5c3e23;--tile-radius:3px}
.game-shell-play{max-width:1150px;padding-top:38px}
.game-workspace{max-width:1000px;grid-template-columns:minmax(0,1fr) 215px;gap:48px}
.topbar.compact-topbar{padding-bottom:25px;border-bottom:1px solid var(--line);margin-bottom:48px}
.topbar-title{letter-spacing:.02em;font-variant:small-caps}
.board-card-fit .board-stage{max-width:620px}
.game-board{padding:16px;gap:3px;border:5px solid #503720;outline:1px solid #8b6942;border-radius:3px;background:repeating-linear-gradient(5deg,#76502f 0 1px,#775231 1px 5px);box-shadow:0 20px 28px #0005,inset 0 0 0 2px #9c784c}
.board-cell{border-radius:1px}
.board-tile,.hand-tile{background:linear-gradient(135deg,#fff6db,#e3d2ac);border-color:#b4a17a;box-shadow:inset 0 -4px 0 #b9a783,0 2px 3px #38271144}
.board-tile-mark{font-size:40px}
.current-player-panel{max-width:620px;padding-left:18px}
.current-player-hand-rack,.player-panel-compact .current-player-hand-rack{padding-bottom:16px;border-bottom-width:7px;background:linear-gradient(0deg,#8c653a 0 17px,transparent 17px)}
.board-tools{top:-45px}
.game-rail{padding-top:0}
.opponent-player-panel{padding:17px 0}
.opponent-player-panel:first-child{padding-top:0}
.turn-action-bar{justify-content:space-between;padding-left:20px}
.turn-action-help{max-width:250px}
@media(max-width:760px){.game-shell-play{padding:20px 15px 30px}.topbar.compact-topbar{margin-bottom:22px;padding-bottom:15px}.game-workspace{display:flex;gap:20px}.game-board{padding:9px;border-width:4px}.board-tile-mark{font-size:29px}.board-tools{top:auto;bottom:0}.turn-action-bar{justify-content:flex-start;padding-left:16px;padding-right:44px}.turn-action-help{max-width:165px}.opponent-player-panel{padding:8px 0}.opponent-player-panel:first-child{padding-top:8px}}



/* Shared layout for all five Walnut icon studies. Palette overrides are colors only. */
:root{--wood-a:#76502f;--wood-b:#775231;--wood-rim:#503720;--wood-line:#8b6942;--wood-inlay:#9c784c;--tile-face:#fff6db;--tile-face-end:#e3d2ac;--tile-edge:#b4a17a;--tile-foot:#b9a783;--rack-fill:#8c653a;--rack-edge:#5c3e23;--lift-used:#8e8072;--lift-ready:#e1ba79}
.game-board{border-color:var(--wood-rim);outline-color:var(--wood-line);background:repeating-linear-gradient(5deg,var(--wood-a) 0 1px,var(--wood-b) 1px 5px);box-shadow:0 20px 28px #0005,inset 0 0 0 2px var(--wood-inlay)}
.board-tile,.hand-tile,.hero-tile{background:linear-gradient(135deg,var(--tile-face),var(--tile-face-end));border-color:var(--tile-edge);box-shadow:inset 0 -4px 0 var(--tile-foot),0 2px 3px #0003}
.current-player-hand-rack,.player-panel-compact .current-player-hand-rack{background:linear-gradient(0deg,var(--rack-fill) 0 17px,transparent 17px);border-bottom-color:var(--rack-edge)}
.piece-symbols{position:absolute;width:0;height:0;overflow:hidden;pointer-events:none}
.piece-icon{display:block;width:1em;height:1em;fill:currentColor;stroke:var(--faction-mark-stroke,none);stroke-width:var(--faction-mark-stroke-width,0);stroke-linejoin:round;paint-order:stroke fill;flex:none}
.board-tile-mark,.hand-tile-mark{display:grid;place-items:center;line-height:1;color:var(--faction-color)}
.board-tile-mark .piece-icon{width:46px;height:46px;max-width:72%;max-height:72%;overflow:visible}
.board-tile-mark{width:100%;height:100%}
.current-player-hand-rack .hand-tile-mark,.player-panel-compact .current-player-hand-rack .hand-tile-mark{font-size:31px}
.hand-tile-mark .piece-icon{width:1em;height:1em}

.board-character-filter .piece-icon{width:20px;height:20px}
.cell-hint-tile .piece-icon{width:85%;height:85%;max-height:24px}
.hero-tile .piece-icon{width:32px;height:32px}
.lift-preview-tile .piece-icon{width:31px;height:31px}
.piece-legend{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;padding:16px 0 22px;color:var(--ink)}
.piece-legend>span{display:flex;flex-direction:column;align-items:center;gap:7px;font:11px var(--font)}
.piece-legend .piece-icon{width:30px;height:30px}
.turn-action-bar{justify-content:flex-start;flex-wrap:wrap;gap:12px}
.turn-action-help{max-width:320px}
.turn-action-button.lift-action{width:132px;min-width:132px;padding:8px 9px;gap:5px;border-radius:24px}
.lift-count{display:none}
.lift-token{width:24px;height:28px;display:block;flex:none;color:var(--lift-used);fill:none;stroke:currentColor;stroke-width:1.5;stroke-linejoin:round;stroke-linecap:round}
.lift-token .lift-arrow{fill:none;opacity:1;stroke:currentColor;stroke-width:1.2}
.lift-token.lift-ready{color:var(--lift-ready)}
.lift-token.lift-ready .lift-arrow{fill:currentColor;stroke:none}
.lift-action.active{box-shadow:inset 0 0 0 1px var(--gold);background:var(--gold-soft)}
.lift-action:disabled{opacity:1}
.lift-action:disabled .lift-token.lift-ready{opacity:.65}
.game-rail{gap:20px}
.opponent-player-panel{padding:18px 0;border-bottom:1px solid var(--line)}
.opponent-player-panel:first-child{padding-top:0}
.seat-heading{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px;align-items:center;cursor:default;padding:0}
.seat-heading .player-display-line{grid-column:1;grid-row:1;min-width:0;gap:4px;justify-content:flex-start}
.seat-heading .player-identity-block{min-width:0;flex:0 1 auto}
.seat-heading .player-display-name{font-size:16px}
.opponent-player-panel .seat-heading .player-edit-button{display:flex;width:25px;height:27px;min-width:25px;margin:0}
.seat-heading .crown-track{grid-column:2;grid-row:1;gap:2px;margin:0}
.seat-heading .player-meta-row{display:flex!important;grid-column:1/-1;grid-row:2;margin:4px 0 8px;gap:0}
.seat-heading .player-meta-row>span:first-child,.seat-heading .player-meta-row>span:nth-child(2){display:none}
.lift-reserve{display:inline-flex;align-items:center;gap:5px;font-size:10px;color:var(--muted)}

.lift-reserve .lift-token{width:19px;height:23px}
.opponent-player-panel .hand-grid,.opponent-player-panel .hand-grid.compact{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin-top:0}
.opponent-player-panel .hand-tile,.opponent-player-panel .compact .hand-tile{aspect-ratio:1/1.04}
.opponent-player-panel .hand-tile-mark{font-size:28px}

.opponent-player-panel .empty-hand{margin-top:8px}
.cell-hint-tile{background:var(--tile-face);border-color:var(--faction-color)}
@media(max-width:760px){
 .board-tile-mark .piece-icon{width:34px;height:34px;max-width:72%;max-height:72%}
 .current-player-hand-rack .hand-tile-mark,.player-panel-compact .current-player-hand-rack .hand-tile-mark{font-size:25px}
 
 .turn-action-bar{gap:8px;min-height:44px}
 .turn-action-button.lift-action{width:132px;min-width:132px;height:42px}
 .turn-action-help{flex-basis:100%;max-width:none;font-size:10px;padding:3px 0 0}
 .opponent-player-list{grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
 .opponent-player-panel,.opponent-player-panel:first-child{padding:10px 0 14px}
 .seat-heading .player-display-name{font-size:14px}
 .seat-heading .crown-track{gap:0}
 .seat-heading .crown-token{width:13px;font-size:14px}
 .opponent-player-panel .player-edit-button{width:21px;min-width:21px}
 .seat-heading .player-meta-row{margin:2px 0 10px}
 .lift-reserve{gap:4px}
 .lift-reserve .lift-token{width:18px;height:22px}
 .opponent-player-panel .hand-grid,.opponent-player-panel .hand-grid.compact{gap:4px}
 .opponent-player-panel .hand-tile-mark{font-size:24px}
 
 .piece-legend{grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
}


/* Shared production controls. Palettes may not override these dimensions. */
.opponent-lifts{grid-column:1/-1;margin:4px 0 10px}
.lift-action .lift-reserve{gap:5px}
.lift-action .lift-token{width:24px;height:28px}
.theme-picker,.account-picker{position:relative;flex:none}
.theme-picker>summary,.account-picker>summary{list-style:none;cursor:pointer}
.theme-menu,.account-menu{position:absolute;right:0;top:48px;z-index:100;min-width:205px;padding:10px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:8px;box-shadow:0 12px 30px #0003}
.theme-menu-label{padding:6px 10px 10px;color:var(--muted);font-size:11px}
.theme-menu button{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:10px;border:0;border-radius:4px;background:transparent;color:var(--ink);font-size:12px;text-align:left}
.theme-menu button:hover,.theme-menu button[aria-pressed=true]{background:var(--gold-soft);color:var(--gold)}
.theme-menu p{font-size:12px;margin:8px}
.account-menu{width:310px;max-width:calc(100vw - 30px);padding:18px;text-align:left}
.account-menu .btn{width:auto;height:auto;min-width:0;border-radius:5px;display:inline-flex;padding:8px 12px;font-size:12px;border:1px solid var(--line)}
.account-menu form{font-size:12px}.account-menu small{font-size:11px}
.setup-navigation{display:flex;justify-content:flex-end;align-items:center;gap:18px;font-size:12px;padding:0 20px}
.setup-navigation a{color:var(--muted);text-decoration:none}
.setup-navigation a:hover{color:var(--ink)}
.sc h1,.sc h2,.sc h3,.sc h4{color:var(--ink)}
.sc-panel{background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:8px}
.sc-name{max-width:340px}.sc-seat-select{max-width:250px}.sc-seat-label{min-width:60px}.sc-history{max-width:480px}
.sc-kicker{font-size:10px;letter-spacing:.12em;color:var(--gold);font-weight:700}
.sc .text-secondary{color:var(--muted)!important}
.sc .border-secondary{border-color:var(--line)!important}
.sc .btn-warning{background:var(--gold);border-color:var(--gold);color:var(--on-accent)}
.sc .form-control,.sc .form-select{background-color:var(--field);color:var(--ink);border-color:var(--line)}
.room-controls{margin:0 0 18px}.room-controls>summary{color:var(--muted);font-size:12px;margin-bottom:14px;cursor:pointer}
.room-controls:not([open]){margin:0}.room-controls[open]{margin-bottom:30px}
.online-metrics{display:flex;justify-content:center;gap:14px;margin-top:3px;font-size:10px;color:var(--muted)}
.online-note{font-size:12px;color:var(--muted);text-align:center;margin:-20px 0 20px}
.online-game .board-cell:disabled{opacity:1;cursor:default}
.online-game .hand-tile:disabled{opacity:1}
.online-game .board-cell-source{outline:2px solid var(--gold);outline-offset:-3px}
.sc-current .player-display-name{color:var(--gold)}
.rack-waiting{margin-left:10px;font:10px var(--font);color:var(--muted)}
.sc-moves{padding-left:18px;list-style:decimal}.sc-moves .log-entry{display:list-item;margin:0 0 10px}
.rules-backdrop{position:fixed;inset:0;z-index:200;display:grid;place-items:center;padding:20px;background:#0009}
.rules-backdrop .rules-modal-card{width:min(680px,100%);max-height:90vh;overflow:auto;font-size:14px;line-height:1.7}
.rules-backdrop li{margin-bottom:9px}
@media(max-width:760px){
 .topbar-actions{gap:0}.topbar-actions>.icon-control,.topbar-actions>details>summary{width:36px;min-width:36px;height:38px;padding:8px}
 .online-metrics{justify-content:flex-end;gap:8px}.online-note{margin:0 0 15px}
 .opponent-lifts{margin:2px 0 10px}.sc-seat-select{max-width:100%}
}

.form-control::placeholder{color:var(--muted);opacity:.8}

/* Keep the local seats still while turns and controllers change. */
.local-turn-controls{max-width:620px;margin:auto;padding-left:18px}
.local-turn-controls:empty{display:none}
.local-turn-controls .exchange-confirm-row{margin-top:14px}
.current-player-panel>.hidden-hand-placeholder{grid-column:1/-1}
@media(max-width:760px){
 .current-player-section,.game-rail{width:100%;max-width:620px;margin-inline:auto;padding-left:18px}
 .current-player-panel{width:100%;max-width:none;padding-left:0}
 .local-turn-controls{padding-left:0}
 .opponent-player-panel:only-child{grid-column:1/-1}
 .current-player-hand-rack,.player-panel-compact .current-player-hand-rack,
 .player-panel-compact.player-panel-current .current-player-hand-rack,
 .opponent-player-panel:only-child .hand-grid,
 .opponent-player-panel:only-child .hand-grid.compact{display:flex;justify-content:center;flex-wrap:nowrap;gap:4px;padding:13px 8px 12px;margin-top:6px;border-bottom:5px solid var(--rack-edge);background:linear-gradient(0deg,var(--rack-fill) 0 10px,transparent 10px);border-radius:0 0 5px 5px;box-shadow:0 6px 8px -6px #0008}
 .opponent-player-panel:only-child .hand-grid .hand-tile{width:calc((100% - 28px)/8);min-width:0;max-width:52px;flex:0 1 52px;aspect-ratio:1/1.08}
 .opponent-player-panel:only-child .hand-tile-mark{font-size:25px}
}

/* One compact header at desktop and tablet widths; a short status row on phones. */
.game-shell-play,.game-shell-setup{padding-top:12px}
.game-shell-setup .setup-navigation{min-height:38px;margin-bottom:8px;padding:0 30px;gap:6px}
.setup-navigation>a{margin-right:12px}
.setup-navigation>.icon-control,.setup-navigation .theme-picker>summary{width:38px;height:38px;min-width:38px;padding:9px}
.game-shell-setup .setup-hero{padding-top:12px!important}
.topbar.compact-topbar{margin:0 0 12px;padding:0 0 8px}
.topbar-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;align-items:center}
.topbar-brand{grid-column:1;grid-row:1;min-width:0}
.compact-topbar .topbar-title{font-size:32px;line-height:1.1;margin:0}
.topbar-command{grid-column:2;grid-row:1;display:flex;flex-direction:column;flex-wrap:nowrap;gap:2px;margin:0;padding:0;border:0;text-align:center}
.topbar-command .status-title{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;line-height:1.3}
.topbar-metrics,.online-metrics{margin:0;gap:8px;justify-content:center}
.topbar-actions{grid-column:3;grid-row:1;justify-self:end;justify-content:flex-end;align-items:center;flex-wrap:nowrap;gap:2px}
.topbar-actions>.btn,.topbar-actions>.icon-control,.topbar-actions>details>summary{width:38px;height:38px;min-width:38px;padding:9px}
.topbar-actions [data-tooltip]::after{top:calc(100% + 6px);bottom:auto}
.board-tools{top:auto;bottom:0;right:0}
.board-toolbar{top:auto;bottom:48px}
.turn-action-bar{flex-direction:row;align-items:center;padding-right:44px}
@media(max-width:760px){
 .game-shell-setup .setup-navigation{padding:0 8px}
 .topbar-grid{grid-template-columns:minmax(0,1fr) auto;gap:3px 6px}
 .compact-topbar .topbar-title{font-size:clamp(22px,6.4vw,27px)}
 .topbar-actions{grid-column:2;grid-row:1;gap:0}
 .topbar-actions>.btn,.topbar-actions>.icon-control,.topbar-actions>details>summary{width:36px;height:36px;min-width:36px;padding:8px}
 .topbar-command{grid-column:1/-1;grid-row:2;flex-direction:row;justify-content:space-between;gap:12px;text-align:left}
 .topbar-command .status-title{min-width:0;font-size:12px}
 .topbar-metrics,.online-metrics{flex-shrink:0;justify-content:flex-end;gap:6px}
}


/* Fit side-by-side play to both viewport dimensions. Stacked phone layouts use
   the available width and let racks, notices and history extend the page. */
.game-workspace {
  --game-rail-width: 240px;
  --game-column-gap: 28px;
  width: 100%;
  max-width: calc(var(--board-stage-size, 620px) + var(--game-rail-width) + var(--game-column-gap));
  grid-template-columns: minmax(0, 1fr) var(--game-rail-width);
  gap: var(--game-column-gap);
}
.game-shell-play { padding-bottom: 12px; }
.board-column { gap: 12px; }
.board-card-fit .board-stage { width: min(100%, var(--board-stage-size, 620px)); }
.board-card-fit .game-board { aspect-ratio: 1; grid-template-rows: repeat(6, minmax(0, 1fr)); }
.board-card-fit .board-cell { min-height: 0; aspect-ratio: auto; padding: 0; }
.board-card-fit .board-tile { min-height: 0; }
.board-card-fit .board-tile-mark { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.game-rail { min-height: 0; max-height: var(--play-height, none); overflow: auto; scrollbar-width: thin; align-content: start; }
.game-rail .player-command-section { min-height: 0; }
.current-player-panel { width: 100%; }
.hand-tile-mark .piece-icon { max-width: 75%; max-height: 75%; }

/* Compact short, wide windows while keeping your rack underneath the board.
   The board fit includes the rack height; history scrolls within the right rail. */
@media (min-width: 761px) and (max-height: 900px), (min-width: 600px) and (max-height: 500px) {
  .game-shell-play { max-width: 1150px; padding: 8px 16px 10px; }
  .game-workspace {
    --game-rail-width: clamp(240px, 30vw, 290px);
    --game-column-gap: 20px;
    max-width: calc(max(290px, var(--board-stage-size, 620px)) + var(--game-rail-width) + var(--game-column-gap));
    display: grid;
    gap: 10px var(--game-column-gap);
  }
  .game-rail { padding: 0; gap: 8px; }
  .current-player-section { padding: 0; }
  .current-player-panel, .local-turn-controls { padding-left: 0; }
  .opponent-player-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .opponent-player-panel, .opponent-player-panel:first-child { padding: 4px 0 8px; }
  .opponent-player-panel .hand-grid, .opponent-player-panel .hand-grid.compact {
    display: grid; grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 3px; padding: 0; margin: 4px 0 0; border: 0; background: none; box-shadow: none;
  }
  .opponent-player-panel:only-child .hand-grid .hand-tile { width: 100%; max-width: none; }
  .opponent-player-panel .hand-tile-mark { font-size: 24px; }
  .opponent-lifts { margin: 0; }
  .opponent-lifts .lift-token { width: 15px; height: 18px; }
  .opponent-player-list:has(> .opponent-player-panel:nth-child(3)) .seat-heading { grid-template-columns: minmax(0, 1fr) auto auto; }
  .opponent-player-list:has(> .opponent-player-panel:nth-child(3)) .opponent-lifts { grid-column: 3; grid-row: 1; }
  .opponent-player-panel .hidden-hand-placeholder { padding: 4px 0; }
  .current-player-hand-rack, .player-panel-compact .current-player-hand-rack,
  .player-panel-compact.player-panel-current .current-player-hand-rack { padding: 9px 4px 8px; margin-top: 3px; gap: 3px; }
  .current-player-hand-rack .hand-tile, .player-panel-compact .current-player-hand-rack .hand-tile { width: calc((100% - 21px) / 8); }
  .current-player-hand-rack .hand-tile-mark, .player-panel-compact .current-player-hand-rack .hand-tile-mark { font-size: 25px; }
  .lift-preview { gap: 6px; margin-top: 6px !important; }
  .lift-preview-tile { width: 32px; height: 34px; }
  .lift-preview .small { font-size: 10px; }
  .history-drawer > summary { padding: 6px 0; }
  .turn-action-bar { margin-top: 6px; }
}
@media (max-width: 760px) and (min-height: 501px), (max-width: 599px) {
  .game-workspace { max-width: none; gap: 12px; }
  .game-rail { overflow: visible; max-height: none; }
  .game-shell-play { padding-bottom: 12px; }
  .board-column { gap: 8px; }
}

/* A translucent square and visible rim keep the last placement readable even
   underneath an opaque tile. A dashed source and up-arrow distinguish a lift. */
:root { --last-move-fill: #dfc07666; --last-move-edge: #e1ba79; }
.board-cell-last, .board-cell-last-source:not(.board-cell-source-selected) {
  outline: 0; box-shadow: none;
}
.board-cell-last, .board-cell-last-source { opacity: 1; filter: none; }
.board-cell-last::after, .board-cell-last-source::after {
  content: ''; position: absolute; inset: 0; z-index: 2;
  border: 3px solid var(--last-move-edge); border-radius: inherit;
  background: var(--last-move-fill); pointer-events: none;
}
.board-cell-last-source:not(.board-cell-last)::after { border-style: dashed; }
.board-cell-last-source::before {
  content: '\2191'; position: absolute; top: 3px; left: 3px; z-index: 3;
  display: grid; place-items: center; width: 24%; height: 28%; min-width: 12px; min-height: 14px;
  border-radius: 2px; background: var(--last-move-edge); color: var(--page);
  font: bold clamp(12px, 2vw, 20px)/1 Arial, sans-serif; pointer-events: none;
}
.board-cell-lift-source { outline-color: var(--gold); }
.board-cell-lift-selected, .online-game .board-cell-source {
  outline: 3px solid var(--gold); outline-offset: -3px;
}

/* Compact game controls: keep lift previews in the existing action row. */
.topbar-actions { position: relative; }
.topbar-actions > .board-tools { position: static; inset: auto; }
.topbar-actions .board-toolbar {
  top: calc(100% + 8px); right: 0; bottom: auto; z-index: 30;
  width: min(300px, calc(100vw - 32px)); min-width: 0;
}
.board-row-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
.current-player-panel, .current-player-section { padding-left: 0; }
.turn-action-bar { min-height: 44px; margin-top: 10px; padding: 0; justify-content: center; }
.turn-action-buttons { align-items: center; gap: 8px; }
.turn-action-button.lift-action {
  width: auto; min-width: 0; height: 44px; padding: 8px 10px;
  border: 1px solid transparent; border-radius: 10px;
}
.lift-action .lift-reserve { gap: 4px; }
.lift-action .lift-token { width: 18px; height: 22px; }
.lift-action.active { border-color: var(--gold); background: var(--gold-soft); box-shadow: none; }
.turn-action-buttons > .lift-preview-tile {
  display: grid; place-items: center; width: 40px; height: 42px;
  min-width: 40px; min-height: 0; flex: 0 0 40px; aspect-ratio: 1 / 1.05;
  padding: 0; margin: 0; border-radius: var(--tile-radius);
}
.lift-preview-tile .hand-tile-mark { width: 100%; height: 100%; font-size: 28px; }
/* Increase character artwork 15% without changing the tile dimensions. */
.board-tile-mark .piece-icon, .hand-tile-mark .piece-icon,
.hero-tile .piece-icon { transform: scale(1.265); }
.cell-hint-tile .piece-icon { transform: scale(1.1); }
.ai-levels-dialog {
  width: min(650px, calc(100vw - 32px)); margin: auto; padding: 0;
  font-size: 14px; line-height: 1.7;
}
.ai-levels-dialog::backdrop { background: #0c132ab3; backdrop-filter: blur(8px); }
.ai-levels-dialog li + li { margin-top: 8px; }
.new-game-dialog {
  width: min(320px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  margin: auto; padding: 18px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 70px #0005;
}
.new-game-dialog::backdrop { background: #0008; }
.new-game-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.new-game-heading h2 { margin: 0; font: 24px/1.2 var(--display); }
.new-game-heading .icon-control { width: 36px; height: 36px; padding: 8px; }
.new-game-options { display: grid; gap: 8px; }
.new-game-options button {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 12px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: transparent;
  font: 14px/1.4 var(--font); text-align: left;
}
.new-game-options button:hover { background: var(--gold-soft); border-color: var(--gold); }
.new-game-options button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 760px) { .game-rail { padding-left: 0; } }
@media (max-width: 370px) {
  .topbar-actions > .btn, .topbar-actions > .icon-control, .topbar-actions > details > summary {
    width: 32px; height: 32px; min-width: 32px; padding: 6px;
  }
}

/* Compact racks work in both stacked portrait and the short landscape side panel. */
@media (max-width: 760px) and (min-height: 501px), (max-width: 599px),
       (min-width: 560px) and (max-height: 500px) and (orientation: landscape) {
  .game-shell-play { max-width: none; padding: 8px 8px 12px; }
  .topbar.compact-topbar { margin-bottom: 8px; padding: 0 2px 6px; }
  .topbar-command > .min-w-0 { min-width: 0; }
  .game-workspace { gap: 8px; }
  .board-column { gap: 2px; }
  .board-card-fit .board-stage { width: 100%; max-width: none; }
  .game-board { border-width: 3px; padding: 5px; gap: 3px; }
  .board-tile-mark .piece-icon { width: 72%; height: 72%; }
  .turn-action-bar { min-height: 44px; margin-top: 2px; gap: 4px; }
  .turn-action-buttons { gap: 4px; max-width: 100%; flex-wrap: wrap; }
  .current-player-section, .game-rail { max-width: none; }
  .current-player-panel { grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; }
  .current-player-panel .player-display-line, .seat-heading { min-width: 0; min-height: 32px; }
  .player-identity-block { min-width: 0; flex: 1 1 auto; }
  .current-player-panel .player-display-name, .seat-heading .player-display-name { font-size: 15px; }
  .player-edit-button, .opponent-player-panel .seat-heading .player-edit-button {
    width: 32px; min-width: 32px; height: 32px; flex: 0 0 32px;
  }
  .game-rail { margin: 0; padding: 0; gap: 6px; }
  .opponent-player-list { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .opponent-player-panel, .opponent-player-panel:first-child { padding: 0 0 6px; border-bottom: 0; }
  .seat-heading { grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 8px; }
  .seat-heading .opponent-lifts { grid-column: 2; grid-row: 1; margin: 0; display: flex; align-items: center; }
  .seat-heading .crown-track { grid-column: 3; grid-row: 1; }
  .opponent-lifts .lift-reserve { gap: 2px; }
  .opponent-lifts .lift-token { width: 14px; height: 18px; }
  .seat-heading .crown-token { width: 15px; font-size: 16px; }
  .current-player-hand-rack, .player-panel-compact .current-player-hand-rack,
  .player-panel-compact.player-panel-current .current-player-hand-rack,
  .opponent-player-panel .hand-grid, .opponent-player-panel .hand-grid.compact,
  .opponent-player-panel:only-child .hand-grid, .opponent-player-panel:only-child .hand-grid.compact {
    display: flex; justify-content: center; flex-wrap: nowrap; gap: 3px;
    padding: 10px 4px 7px; margin-top: 0; border-bottom: 4px solid var(--rack-edge);
    background: linear-gradient(0deg, var(--rack-fill) 0 8px, transparent 8px);
    border-radius: 0 0 5px 5px; box-shadow: 0 6px 8px -6px #0008;
  }
  .current-player-hand-rack .hand-tile, .player-panel-compact .current-player-hand-rack .hand-tile,
  .opponent-player-panel .hand-grid .hand-tile, .opponent-player-panel:only-child .hand-grid .hand-tile {
    width: calc((100% - 21px) / 8); min-width: 0; max-width: 64px; flex: 0 1 64px;
    height: auto; aspect-ratio: 1 / 1.08;
  }
  .current-player-hand-rack .hand-tile-mark, .player-panel-compact .current-player-hand-rack .hand-tile-mark,
  .opponent-player-panel .hand-grid .hand-tile-mark,
  .opponent-player-panel:only-child .hand-tile-mark { font-size: clamp(24px, 8vw, 32px); }
  .current-player-panel > .hidden-hand-placeholder, .opponent-player-panel .hidden-hand-placeholder {
    min-height: 0; padding: 8px 0;
  }
  .history-drawer { border-top: 1px solid var(--line); }
  .history-drawer > summary { min-height: 40px; padding: 10px 2px; }
  .online-note { margin-bottom: 8px; }
}

/* Keep the board in view while extra seats, room controls and history scroll
   naturally beside it. Scope the grid to active games, leaving lobbies alone. */
@media (min-width: 560px) and (max-height: 500px) and (orientation: landscape) {
  .game-shell-play:has(.game-workspace) {
    --landscape-layout: 1;
    --landscape-panel-min: 280px;
    display: grid;
    grid-template-columns: var(--landscape-board-size, min(calc(100dvh - 12px), calc(100vw - 304px))) minmax(var(--landscape-panel-min), 420px);
    grid-template-rows: repeat(5, max-content) minmax(0, 1fr);
    gap: 4px 12px;
    align-items: start;
    align-content: start;
    width: 100%;
    max-width: calc(var(--landscape-board-size, 620px) + 444px);
    min-height: 0;
    padding: 6px;
  }
  .game-shell-play:has(.game-workspace) > section[aria-label="Lobby"],
  .game-shell-play:has(.game-workspace) .online-game,
  .game-shell-play:has(.game-workspace) .game-workspace,
  .game-shell-play:has(.game-workspace) .board-column,
  .game-shell-play:has(.game-workspace) .board-card { display: contents; }
  .board-card-fit .board-stage {
    grid-column: 1;
    grid-row: 1 / -1;
    position: sticky;
    top: var(--landscape-sticky-top, 6px);
    align-self: start;
    width: 100%;
    max-width: none;
    margin: 0;
  }
  .game-shell-play:has(.game-workspace) > .topbar,
  .game-shell-play:has(.game-workspace) > .alert,
  .game-shell-play:has(.game-workspace) .room-controls,
  .game-shell-play:has(.game-workspace) .online-note,
  .turn-action-bar, .current-player-section, .game-rail {
    grid-column: 2;
    min-width: 0;
    align-self: start;
    order: 0;
    margin: 0;
  }
  .game-shell-play:has(.game-workspace) .room-controls:not([open]) { display: none; }
  .topbar.compact-topbar { margin: 0; padding: 0 0 5px; }
  .topbar-grid { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 4px; }
  .compact-topbar .topbar-title { font-size: 20px; }
  .topbar-actions { grid-column: 2; gap: 0; }
  .topbar-actions > .btn, .topbar-actions > .icon-control, .topbar-actions > details > summary {
    width: 32px; min-width: 32px; height: 32px; padding: 6px;
  }
  .topbar-command { grid-column: 1 / -1; grid-row: 2; flex-direction: row; justify-content: space-between; gap: 6px; text-align: left; }
  .topbar-command .status-title { font-size: 11px; }
  .topbar-metrics, .online-metrics { flex-shrink: 0; justify-content: flex-end; gap: 5px; }
  .online-metrics { flex-wrap: wrap; max-width: 65%; font-size: 10px; }
  .turn-action-bar { min-height: 36px; padding: 0; justify-content: flex-start; }
  .turn-action-button.lift-action { height: 36px; padding: 4px 6px; }
  .turn-action-buttons > .lift-preview-tile { width: 32px; min-width: 32px; height: 34px; flex-basis: 32px; }
  .turn-action-buttons > .btn:not(.lift-action) { width: 36px; min-width: 36px; height: 36px; padding: 8px; }
  .current-player-section, .game-rail { width: 100%; max-width: none; padding: 0; }
  .current-player-panel { padding: 0; }
  .current-player-panel .player-display-line, .seat-heading { min-height: 28px; }
  .player-edit-button, .opponent-player-panel .seat-heading .player-edit-button { width: 28px; min-width: 28px; height: 28px; flex-basis: 28px; }
  .game-rail { max-height: none; overflow: visible; gap: 4px; }
  .opponent-player-panel, .opponent-player-panel:first-child { padding: 0; }
  .opponent-player-list { gap: 4px; }
  .opponent-player-list:has(> .opponent-player-panel:nth-child(3)) .opponent-lifts { grid-column: 2; }
  .opponent-player-panel > .small { margin: 0; font-size: 10px; }
  .current-player-hand-rack, .player-panel-compact .current-player-hand-rack,
  .player-panel-compact.player-panel-current .current-player-hand-rack,
  .opponent-player-panel .hand-grid, .opponent-player-panel .hand-grid.compact,
  .opponent-player-panel:only-child .hand-grid, .opponent-player-panel:only-child .hand-grid.compact {
    padding-bottom: 4px; border-bottom-width: 3px;
  }
  .current-player-hand-rack .hand-tile, .player-panel-compact .current-player-hand-rack .hand-tile,
  .opponent-player-panel .hand-grid .hand-tile, .opponent-player-panel:only-child .hand-grid .hand-tile { max-width: 42px; flex-basis: 42px; }
  .history-drawer > summary { min-height: 32px; padding: 6px 2px; }
}

/* Replay changes only the viewed board; the live turn, racks and clocks continue. */
.board-stage { scroll-margin-top: var(--landscape-sticky-top, 8px); }
.game-board.board-in-review { outline: 2px solid var(--gold); outline-offset: -2px; }
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; width: 100%; gap: 4px; }
.replay-step, .replay-live {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 40px; min-height: 40px; padding: 8px;
  color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 6px;
  font: 12px/1.2 var(--font);
}
.replay-live { width: auto; min-width: 55px; color: var(--gold); border-color: var(--gold); }
.replay-step:hover:not(:disabled), .replay-live:hover { background: var(--gold-soft); }
.replay-step:disabled { opacity: .35; }
.replay-live-note { flex: 1 1 130px; color: var(--muted); font: 10px/1.4 var(--font); }
.history-drawer .history-move {
  display: flex; align-items: baseline; gap: 8px; width: 100%; margin: 0;
  padding: 9px 5px; border: 0; border-bottom: 1px solid var(--line); border-radius: 3px;
  color: var(--muted); background: transparent; text-align: left; line-height: 1.5;
}
.history-move > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.history-move .log-number { flex-shrink: 0; }
.history-drawer .history-move[aria-current="step"] { color: var(--ink); background: var(--gold-soft); box-shadow: inset 3px 0 var(--gold); }
.history-drawer .history-move:hover:not(:disabled) { color: var(--ink); background: var(--gold-soft); }
.history-drawer .history-move:disabled { opacity: .75; cursor: default; }
.history-message { margin: 6px 0; color: var(--muted); font: 11px/1.5 var(--font); }
.history-retry { padding: 3px 6px; color: var(--gold); background: transparent; border: 1px solid var(--line); border-radius: 4px; }
.history-move:focus-visible, .replay-step:focus-visible, .replay-live:focus-visible, .history-retry:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
@media (min-width: 560px) and (max-height: 500px) and (orientation: landscape) {
  .replay-step, .replay-live { min-height: 36px; padding: 6px; }
  .replay-step { width: 36px; }
}

/* Faction identity uses a colored character plus a distinct reference-inspired gem. */
.faction-tile { position: relative; }
.faction-tile > .board-tile-mark,
.faction-tile > .hand-tile-mark { width: 100%; height: 100%; }
.faction-tile > .board-tile-mark > .piece-icon,
.faction-tile > .hand-tile-mark > .piece-icon,
.faction-tile > .piece-icon {
    width: 70%; height: 70%; max-width: 70%; max-height: 70%;
    transform: translateX(-15%);
}
.faction-gem {
    position: absolute; top: clamp(1px, 3%, 2px); right: clamp(1px, 3%, 2px); z-index: 2;
    display: block; width: clamp(7px, 27%, 18px); height: auto; aspect-ratio: 1;
    overflow: visible; pointer-events: none; fill: none; stroke: none;
    filter: drop-shadow(0 1px 1px #00000030);
}
.cell-hint-tile.faction-tile > .piece-icon {
    width: 66%; height: 66%; max-width: 66%; max-height: 66%;
    transform: translateX(-15%);
}
.cell-hint-tile .faction-gem { top: 1px; right: 1px; width: min(8px, 30%); }

/* SCP export stays usable inside the compact board tools and learning rails. */
.scp-export{display:block;max-width:100%;font-family:var(--font)}
.scp-export>summary{cursor:pointer;list-style:none;display:inline-flex;align-items:center;justify-content:center}
.scp-export>summary::-webkit-details-marker{display:none}
.scp-export-panel{max-width:440px;min-width:min(300px,80vw);margin-top:9px;padding:12px;border:1px solid var(--line);border-radius:8px;background:var(--surface)}
.scp-export-label{display:block;font-size:12px;font-weight:650;margin:0 0 8px;color:var(--ink)}
.scp-export-text{font:12px/1.5 ui-monospace,SFMono-Regular,Consolas,monospace;overflow-wrap:anywhere;width:100%;margin-bottom:10px}
.scp-export-error,.scp-export-warning,.scp-export-note{font-size:12px;line-height:1.5;margin:8px 0 0;color:var(--muted)}
.scp-export-error{color:#e98181}.scp-export-warning{color:var(--gold)}

.sc-site-nav {display:flex;align-items:center;gap:.7rem;position:relative;color:var(--ink);text-align:left;min-width:0}
.sc-site-brand {font:600 clamp(16px,2vw,23px)/1.1 var(--display,Georgia,serif);color:var(--ink)!important;text-decoration:none;white-space:nowrap}
.sc-site-menu {position:relative;font:500 13px/1.35 var(--font,system-ui);z-index:35}
.sc-site-menu summary {display:flex;align-items:center;gap:5px;min-height:36px;padding:5px 9px;border:1px solid var(--line);border-radius:6px;cursor:pointer;list-style:none}
.sc-site-menu summary::-webkit-details-marker {display:none}
.sc-site-links {position:absolute;top:calc(100% + 6px);left:0;display:grid;grid-template-columns:1fr 1fr;gap:14px;padding:16px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 30px #0004;width:min(310px,75vw);z-index:40}
.sc-site-links section {display:flex;flex-direction:column;align-items:stretch}
.sc-site-links strong {font-size:11px;color:var(--muted);padding:3px 6px}
.sc-site-links a {display:block;font:500 13px/1.35 var(--font,system-ui);color:var(--ink)!important;text-decoration:none;padding:8px 6px;border-radius:4px}
.sc-site-links a:hover,.sc-site-links a[aria-current],.sc-score-move:hover,.sc-score-move[aria-current] {background:var(--gold-soft);color:var(--ink)}
.sc-analysis-link {display:inline-flex;gap:.4rem;align-items:center;min-height:36px;color:var(--gold)!important;font:600 13px/1.25 var(--font,system-ui);text-decoration:underline;text-underline-offset:3px}
.sc-score-sheet {width:100%;color:var(--ink)}
.sc-score-round {display:grid;grid-template-columns:2em repeat(var(--seat-count),minmax(0,1fr));gap:2px;align-items:center;font:500 clamp(11px,1.8vw,15px)/1.5 ui-monospace,monospace}
.sc-round-number {color:var(--muted);text-align:right}
.sc-score-move,.sc-score-events button {background:transparent;border:0;border-radius:3px;color:inherit;padding:5px 2px;text-align:center;width:auto;display:block;font:inherit}
.sc-score-move:disabled,.sc-score-events button:disabled {opacity:1}
.sc-score-events {margin-top:6px;font:400 12px/1.5 var(--font,system-ui);color:var(--muted)}
.sc-score-events summary {cursor:pointer}
.sc-score-events button {text-align:left}
.game-shell .topbar-brand {overflow:visible}
@media(max-width:600px){.sc-site-nav{gap:.35rem}.sc-site-links{left:-74px}.sc-site-brand{font-size:16px}}
