html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Catan app layout */

body {
    background: #f4f1ea;
}

.catan-app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- Cities & Knights --- */

.expansion-switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.pirate-ship {
    width: 1.3em;
    height: 1.3em;
    vertical-align: -0.3em;
}

.improvement-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    padding: 0.35rem 0;
    border-top: 1px solid #e5e7eb;
}

.improvement-row:first-of-type {
    border-top: none;
}

.improvement-track {
    font-weight: 600;
    min-width: 7rem;
}

.improvement-pips {
    display: inline-flex;
    gap: 3px;
}

.improvement-pip {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid var(--track-color);
    background: #fff;
}

.improvement-pip-on {
    background: var(--track-color);
}

.improvement-pip-ability {
    box-shadow: 0 0 0 1px #2f2a24;
}

.improvement-name {
    font-size: 0.85rem;
    color: #4b5563;
}

/* Which dice give a progress card of this track, on its own line under the pips. */
.improvement-draw {
    flex-basis: 100%;
    font-size: 0.8rem;
    color: var(--catan-ink-soft);
}

.improvement-draw-dice {
    margin-left: 0.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    border: 1px solid var(--track-color);
    color: var(--catan-ink);
    font-weight: 600;
    white-space: nowrap;
}

.player-improvements {
    display: inline-flex;
    gap: 2px;
}

.player-improvement {
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 3px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.knight-menu {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.decision-panel {
    border-left: 4px solid #d4a22b;
}

.decision-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.board-pick-panel {
    border-left: 4px solid #3a6fb0;
}

.board-tooltip {
    position: fixed;
    z-index: 1100;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    background: #2f2a24;
    color: #fff;
    font-size: 0.8rem;
    white-space: pre;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.board-tooltip::before {
    content: "";
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--tooltip-color);
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.board-tooltip[hidden] {
    display: none;
}

.app-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--app-topbar-height);
    margin-bottom: 0.5rem;
}

:root {
    --app-topbar-height: 2rem;
    /* Room the manual, fullscreen, 2D/3D and language controls take at the right of the top row. */
    --app-topbar-controls: 17rem;
}

/* The game's turn status sits in the empty left part of the layout's top row. It's rendered by the game page (the
   layout can't show game state), so it's pulled up into that row and kept clear of the controls on the right. */
.play-status {
    display: flex;
    align-items: center;
    height: var(--app-topbar-height);
    margin-top: calc(-1 * (var(--app-topbar-height) + 0.5rem));
    margin-bottom: 0.5rem;
    margin-right: calc(var(--app-topbar-controls) + 0.5rem);
    min-width: 0;
}

/* Too narrow to share the row with the controls (small phones): the status gets its own line under it. */
@media (max-width: 359px) {
    .play-status {
        height: auto;
        margin-top: 0;
        margin-right: 0;
    }
}

.play-status .turn-indicator {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.1;
}

.language-switcher {
    display: inline-flex;
    border: 1px solid #c9c2b3;
    border-radius: 999px;
    overflow: hidden;
    background: #fffdf6;
}

.language-switcher button {
    border: none;
    background: transparent;
    padding: 0.2rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b6457;
    cursor: pointer;
}

.language-switcher button.active {
    background: #2f2a24;
    color: #fff;
}

/* Full screen toggle (FullscreenButton.razor + fullscreen.js): shows the icon for what a click will do */
.fullscreen-toggle button {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    font-size: 1rem;
}

.fullscreen-toggle .fs-exit,
.is-fullscreen .fullscreen-toggle .fs-enter,
.fullscreen-unsupported .fullscreen-toggle {
    display: none;
}

.is-fullscreen .fullscreen-toggle .fs-exit {
    display: inline;
}

.home-page {
    max-width: 900px;
    margin: 0 auto;
    text-align: center;
}

.home-hero h1 {
    margin-bottom: 0.25rem;
}

.home-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2rem;
}

.home-card, .lobby-card, .winner-card {
    width: 320px;
    padding: 1.5rem;
    text-align: left;
}

.winner-card.results {
    width: 100%;
    max-width: 1100px;
}

/* --- Results page (WinnerView, GameStatsCharts) --- */

/* The final ranking: a tile per player, the winner's in gold. */
.podium {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.75rem;
    margin: 1rem 0 1.5rem;
}

.podium-player {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-areas: "rank token name" "points points points" "awards awards awards";
    align-items: center;
    gap: 0.35rem 0.5rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid #e3d3a8;
    border-left: 5px solid var(--player-color);
    border-radius: 12px;
    background: #fdf8ea;
}

.podium-winner {
    border-color: #d9a52a;
    background: linear-gradient(160deg, #fff6d1, #fbe9a8);
    box-shadow: 0 0 0 2px rgba(217, 165, 42, 0.35);
}

.podium-rank {
    grid-area: rank;
    font-family: 'Cinzel', Georgia, serif;
    font-weight: 700;
    color: var(--catan-ink-soft);
}

.podium-player .player-token {
    grid-area: token;
}

.podium-name {
    grid-area: name;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-points {
    grid-area: points;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
}

.podium-points small {
    font-size: 0.8rem;
    color: var(--catan-ink-soft);
}

.podium-awards {
    grid-area: awards;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.podium-awards:empty {
    display: none;
}

/* Charts: blocks on light parchment, two per row where there's room. */
.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stats-chart {
    min-width: 0;
    padding: 0.9rem 1rem;
    border: 1px solid #e3d3a8;
    border-radius: 12px;
    background: #fdf8ea;
}

.stats-chart-wide {
    grid-column: 1 / -1;
}

.stats-chart h4 {
    margin: 0 0 0.4rem;
}

.chart-subtitle {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
}

.stats-chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.color-dot-outline {
    box-shadow: 0 0 0 1px #64748b;
}

.chart-grid {
    stroke: #e6dcc0;
    stroke-width: 1;
}

.chart-baseline {
    stroke: #b9a77c;
    stroke-width: 1;
}

.chart-target {
    stroke: #9c8a5c;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.chart-axis {
    fill: var(--catan-ink-soft);
    font-size: 11px;
}

.chart-axis-red {
    fill: #b71c1c;
    font-weight: 700;
}

.chart-label {
    fill: var(--catan-ink);
    font-size: 12px;
    font-weight: 600;
}

.chart-line {
    fill: none;
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-line-outline {
    stroke-width: 4;
}

.chart-hover {
    fill: transparent;
}

.chart-hover:hover {
    fill: rgba(47, 42, 36, 0.06);
}

.dice-bar {
    fill: #2a78a8;
}

.dice-bar-red {
    fill: #b71c1c;
}

.dice-expected {
    stroke: var(--catan-ink);
    stroke-width: 2;
    stroke-linecap: round;
}

.chart-bar-group:hover .dice-bar {
    opacity: 0.8;
}

/* Small multiples: one bar chart per statistic. */
.stat-multiples {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1rem 1.5rem;
}

.stat-multiple-title {
    margin-bottom: 0.3rem;
    font-weight: 700;
    font-size: 0.9rem;
}

.stat-bar-row {
    display: grid;
    grid-template-columns: 5.5rem 1fr 2rem;
    align-items: center;
    gap: 0.5rem;
    padding: 1px 0;
    font-size: 0.8rem;
}

.stat-bar-row:hover {
    background: rgba(47, 42, 36, 0.05);
}

.stat-bar-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-bar-track {
    height: 10px;
}

.stat-bar {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: 0 4px 4px 0;
}

.stat-bar-outline {
    box-shadow: inset 0 0 0 1px #64748b;
}

.stat-bar-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Each chart is drawn twice (GameStatsCharts): the narrow drawing is for phones, so its text keeps its size. */
.chart-variant-narrow {
    display: none !important;
}

@media (max-width: 600px) {
    .chart-variant-wide {
        display: none !important;
    }

    .chart-variant-narrow {
        display: block !important;
    }

    .stats-chart {
        padding: 0.7rem 0.6rem;
    }

    .podium-points {
        font-size: 1.5rem;
    }
}

.stats-details summary {
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.game-timing {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    color: #4b5563;
}

.stats-table-wrapper {
    overflow-x: auto;
    border: 1px solid #d9c38f;
    border-radius: 10px;
    background: #fdf8ea;
}

/* Every row has its own light background, so the table reads as one block on the sandbank: a darker header row and
   alternating rows. Sticky first-column cells take their row's background so scrolled cells don't show through. */
.stats-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}

.stats-table th, .stats-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #eadcb4;
    text-align: right;
    white-space: nowrap;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-table thead tr {
    background: #efdfb4;
}

.stats-table th {
    font-weight: 600;
    color: var(--catan-ink);
}

.stats-table tbody tr {
    background: #fdf8ea;
}

.stats-table tbody tr:nth-child(even) {
    background: #f6ecd2;
}

.stats-table th:first-child, .stats-table td.stats-player {
    text-align: left;
    position: sticky;
    left: 0;
    background: inherit;
    box-shadow: 1px 0 0 #eadcb4;
}

.stats-table tr.stats-winner {
    background: #fff3c4;
    font-weight: 600;
}

.stats-player .color-dot {
    margin-right: 0.35rem;
    vertical-align: middle;
}

/* Points to win (Home): a narrow number field with its name next to it. */
.points-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.points-field .rz-form-field {
    width: 6.5rem;
}

.home-games {
    margin-top: 1.5rem;
    text-align: left;
}

.games-table td {
    text-align: left;
    vertical-align: middle;
}

.games-players {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

.games-table .room-code + .rz-badge {
    margin-left: 0.5rem;
}

/* Game lists (Home): headers line up with their (left-aligned) cells; the players column wraps its names, so the
   other columns stay compact and the buttons stay in view. Long headers (Dutch "Punten om te winnen") may wrap over
   two lines. */
.games-table th {
    text-align: left;
    vertical-align: bottom;
}

/* The status (with its badge) may wrap too; dates, durations, room codes and buttons stay on one line. */
.games-table td.games-status {
    white-space: normal;
}

.games-table th,
.games-table td {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

.games-status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.4rem;
}

.games-table .games-players-cell {
    min-width: 9rem;
    white-space: normal;
}

.games-table .games-num {
    text-align: center;
}

.games-table th.games-num {
    white-space: normal;
    min-width: 5rem;
    max-width: 7rem;
}

.games-player {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.games-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

.spectator-badge {
    font-size: 0.85rem;
    opacity: 0.85;
}

.lobby-view, .winner-view {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.room-code {
    font-family: monospace;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.lobby-player, .score-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-dot {
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.hint {
    color: #6b7280;
    font-size: 0.85rem;
}

.join-prompt {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.game-page {
    min-height: 60vh;
}

.play-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #2f2a24;
    color: #f4f1ea;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.play-main {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.play-board-column {
    flex: 2;
    min-width: 320px;
}

.play-sidebar {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem; /* room for the sandbanks' water rings */
}

.sidebar-card h4 {
    margin-top: 0;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    flex-wrap: wrap;
}

.player-row-active {
    background: rgba(255, 215, 0, 0.15);
    border-radius: 0.25rem;
    padding-left: 0.3rem;
}

.player-name {
    font-weight: 600;
}

.player-vp, .player-cards, .player-devcards {
    font-size: 0.85rem;
    color: #4b5563;
}

.card-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    padding-top: 0.5rem;
}

.card-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.card-caption {
    font-size: 0.7rem;
    color: #4b5563;
    text-align: center;
    max-width: 64px;
    line-height: 1.1;
}

/* Sized for 5 layers offset by 3px each (MaxStackLayers / StackOffset in PlayView.razor). */
.card-stack {
    position: relative;
    width: 48px;
    height: 62px;
}

.card-stack-clickable {
    cursor: pointer;
    transition: transform 0.12s ease;
}

.card-stack-clickable:hover {
    transform: translateY(-3px);
}

.card-stack-inactive .game-card {
    filter: saturate(0.45) brightness(0.95);
}

.game-card {
    position: absolute;
    width: 36px;
    height: 50px;
    border-radius: 5px;
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%),
        var(--card-color);
    border: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), 1px 1px 2px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon {
    font-size: 1.3rem;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.card-count {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #2f2a24;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.card-stack-empty .game-card {
    background: transparent;
    border: 1px dashed #b8b2a6;
    box-shadow: none;
}

.card-stack-empty .card-icon {
    opacity: 0.35;
    filter: grayscale(1);
}

/* Scrolls when the popup is taller than the window; auto margins center it when it fits.
   No transforms here: a transformed ancestor would offset Radzen's absolutely positioned dropdown panels. */
.card-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(20, 16, 12, 0.45);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

/* Wide enough for three buttons in a row (Play, Discard, Cancel); on narrower screens they wrap. */
.card-popup-shell {
    margin: auto;
    width: min(420px, 100%);
}

.card-popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.game-card.game-card-large {
    position: relative;
    width: 150px;
    height: 210px;
    border-radius: 12px;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.55), 2px 4px 10px rgba(0, 0, 0, 0.3);
}

.game-card-large .card-icon {
    font-size: 4rem;
}

@media (max-height: 640px) {
    .game-card.game-card-large {
        width: 110px;
        height: 154px;
    }

    .game-card-large .card-icon {
        font-size: 2.8rem;
    }
}

.card-title {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
    padding: 0 0.5rem;
}

.card-popup-description {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: #374151;
}

.card-popup-choice {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.card-popup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.resource-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.resource-stepper .rz-numeric {
    width: 5rem;
}

.inline-panel {
    margin-top: 1rem;
    padding: 1rem;
}

/* Trade offer popup (TradeOfferPopup.razor): floats at the bottom without blocking the page. It sits below the
   sticky action bar (z-index 50), so the knight menu and card popups that render inside the bar stay on top. */
.trade-popup {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 40;
    width: min(26rem, calc(100vw - 1.5rem));
    max-height: 45vh;
    overflow-y: auto;
    padding: 0.6rem 0.9rem;
    background: #fffdf6;
    border: 2px solid #f2c230;
    border-radius: 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    animation: trade-popup-in 0.25s ease-out;
}

.trade-popup-offer + .trade-popup-offer {
    border-top: 1px solid #e8e0cc;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.trade-popup-title {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.trade-popup-swap {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.2rem 0.6rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

.trade-popup-label {
    font-size: 0.8rem;
    color: #6b6457;
}

.trade-popup-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.trade-popup-card {
    font-weight: 700;
    white-space: nowrap;
}

.trade-popup-actions {
    display: flex;
    gap: 0.4rem;
}

.trade-popup .hint {
    margin: 0.3rem 0 0.2rem;
}

@keyframes trade-popup-in {
    from { opacity: 0; transform: translate(-50%, 1rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .trade-popup {
        animation: none;
    }
}

@media (max-width: 700px) {
    .trade-popup {
        bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
}

.game-log-entries {
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.game-log-entry {
    padding: 0.15rem 0;
    border-bottom: 1px dashed #e5e7eb;
}

.log-time {
    color: #9ca3af;
    margin-right: 0.5rem;
}
/* Dice (DiceDisplay) */
.dice-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.25rem 0 0.5rem;
    min-height: 2.25rem;
}

.die {
    display: inline-flex;
    width: 2.1rem;
    height: 2.1rem;
    filter: drop-shadow(1px 2px 1.5px rgba(0, 0, 0, 0.3));
}

.die svg {
    width: 100%;
    height: 100%;
}

.dice-total {
    font-size: 1.15rem;
    font-weight: 700;
    margin-left: 0.2rem;
}

/* Cities & Knights: the red die and the event die, laid out like the number dice ("= Green 3"). */
.dice-event-row {
    margin-bottom: 0.1rem;
}

.dice-event-result {
    color: color-mix(in srgb, var(--gate-color) 75%, #000);
}

.dice-rolling .die {
    animation: dice-tumble 0.7s cubic-bezier(0.3, 0.7, 0.4, 1);
}

.dice-rolling .die:nth-child(2) {
    animation-delay: 0.06s;
}

.dice-rolling .die:nth-child(3) {
    animation-delay: 0.12s;
}

.dice-rolling .dice-total {
    animation: dice-total-in 0.9s ease-out;
}

@keyframes dice-tumble {
    0% { transform: translate(-1.2rem, -0.6rem) rotate(-300deg) scale(0.6); opacity: 0; }
    55% { transform: translate(0.15rem, 0.1rem) rotate(20deg) scale(1.08); opacity: 1; }
    80% { transform: rotate(-6deg) scale(0.98); }
    100% { transform: none; }
}

@keyframes dice-total-in {
    0%, 60% { opacity: 0; }
    100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .dice-rolling .die,
    .dice-rolling .dice-total {
        animation: none;
    }
}

/* Themed heading font */
h1, h2, h3,
.play-header .turn-indicator,
.sidebar-card h4 {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    letter-spacing: 0.02em;
}

/* SVG icons in UI text (UiIcons) — sized with the surrounding text */
.ui-icon {
    display: inline-block;
    width: 1.25em;
    height: 1.25em;
    vertical-align: -0.28em;
    flex-shrink: 0;
}

/* Glyphs on coloured card faces are white, like the card titles */
.card-icon .ui-glyph {
    color: #fff;
}

.game-card-large .card-icon .ui-icon {
    width: 1em;
    height: 1em;
}

/* 3D board prototype */
.board3d {
    width: 100%;
    height: min(80vh, 900px);
    min-height: 420px;
    border-radius: 0.75rem;
    overflow: hidden;
    touch-action: none;
}

.board3d canvas {
    display: block;
}

.board3d-wrap {
    position: relative;
}

/* Zoom / reset buttons over the bottom-right corner of the 3D board */
.board3d-controls {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.board3d-controls .rz-button {
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Phones: a shorter 3D board so the sidebar below stays within reach */
@media (max-width: 700px) {
    .board3d {
        height: min(62vh, 100vw);
        min-height: 320px;
    }
}

/* Site password page */
.access-card {
    max-width: 22rem;
    margin: 3rem auto;
    padding: 1.5rem;
    background: linear-gradient(160deg, #fdf6e3, #f1e1bb);
    border: 1px solid #c9ad7a;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 2px 0 #a8864f, 0 8px 18px rgba(30, 18, 6, 0.35);
    text-align: center;
}

.access-card h1 {
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
}

.access-input {
    width: 100%;
    margin: 0.5rem 0 0.75rem;
}

.access-button {
    width: 100%;
}

.access-error {
    color: #b3261e;
    margin: 0 0 0.75rem;
}

/* Action bar (PlayView): whose turn it is plus all action buttons, stuck to the top of the screen while scrolling.
   Kept below popups (z-index 1000) and free of transforms/filters, which would break the knight and card popups
   that render inside it. */
.action-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    border: 2px solid transparent;
}

.action-bar-mine {
    border-color: #f2c230;
}

/* Nothing to say and no buttons (e.g. another player's turn): no bar at all, more room for the board. */
.action-bar:not(:has(button, .action-bar-instruction)) {
    display: none;
}

.action-bar-instruction {
    width: 100%;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 700;
}

.your-turn-badge {
    flex-shrink: 0;
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    background: #f2c230;
    color: #2f2a24;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.action-bar-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.action-bar-buttons:empty {
    display: none;
}

/* The knight buttons join the same row of buttons. */
.action-group {
    display: contents;
}

.action-bar .rz-button {
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
}

/* Phones: one row of buttons that scrolls sideways, so the bar stays short. */
@media (max-width: 700px) {
    .action-bar {
        padding: 0.4rem 0.6rem;
    }

    .action-bar .turn-indicator {
        font-size: 0.9rem;
    }

    .action-bar-buttons {
        flex-wrap: nowrap;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .action-bar .rz-button {
        flex-shrink: 0;
    }
}


/* Who a proposed trade goes to (PlayView): "Everyone" or any selection of the other players. */
.trade-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* Hand bar (PlayView): resources and development/progress cards fixed to the bottom of the screen. One row that
   scrolls sideways when it doesn't fit, so its height is known and the page and trade popup can make room for it.
   No transform or filter here: the progress-card popup inside it is position: fixed against the viewport. */
.play-view-with-hand {
    --hand-bar-height: 6.9rem;
    padding-bottom: calc(var(--hand-bar-height) + 0.5rem);
}

.hand-bar {
    position: fixed;
    /* Same left and right edges as the page content (.catan-app: max 1400px wide, 1rem padding), so the bar lines
       up with the action bar and the board. Percentages of a fixed element are of the viewport without scrollbar. */
    left: max(1rem, calc((100% - 1400px) / 2 + 1rem));
    right: max(1rem, calc((100% - 1400px) / 2 + 1rem));
    bottom: 0;
    border-radius: 0.6rem 0.6rem 0 0;
    z-index: 50;
    height: var(--hand-bar-height);
    display: flex;
    align-items: stretch;
    gap: 1.5rem;
    padding: 0.35rem 1rem 0.7rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    background: #fffdf6;
    border-top: 3px solid #f2c230;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

.hand-bar-section {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-width: 0;
}

.hand-bar-section + .hand-bar-section {
    padding-left: 1.5rem;
    border-left: 1px solid #e8e0cc;
}

.hand-bar-label {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
}

.hand-bar .card-hand {
    flex-wrap: nowrap;
    gap: 0.6rem;
    padding-top: 0.6rem;
}

/* No names under the cards here, to keep the bar low: the card buttons in the action bar, the tooltips and the
   card popup name them. */
.hand-bar .card-caption {
    display: none;
}

/* The bar has a fixed height, so text in it must stay short: wide enough that the longest hint takes three lines. */
.hand-bar-empty {
    max-width: 24rem;
    margin: 0.3rem 0 0;
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: normal;
}

.hand-bar-heading {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    white-space: nowrap;
}

.hand-bar-extra {
    font-size: 0.75rem;
    color: var(--catan-ink-soft);
}

/* The trade popup floats just above the hand bar. */
.play-view-with-hand .trade-popup {
    bottom: calc(var(--hand-bar-height) + 0.75rem);
    max-height: calc(100vh - var(--hand-bar-height) - 9rem);
}

/* Card buttons in the action bar, edged in the card's colour. */
.action-bar .card-action {
    border-left: 4px solid var(--card-color);
}

.action-bar .card-action .card-icon-inline,
.action-bar .card-action svg {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
}

@media (max-width: 700px) {
    /* Phones usually scroll the bar sideways, so leave room for the scrollbar under the cards. */
    .play-view-with-hand {
        --hand-bar-height: 7.7rem;
    }

    .hand-bar {
        gap: 1rem;
        padding: 0.3rem 0.6rem 0.65rem;
    }

    .hand-bar-section + .hand-bar-section {
        padding-left: 1rem;
    }
}

/* Bank and player trade dialogs (PlayView), opened from the action bar. */
.trade-dialog h4 {
    margin: 0;
}

.trade-dialog-shell {
    width: min(380px, 100%);
}

.trade-dialog-bank {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.trade-dialog-bank .rz-dropdown {
    flex: 1 1 0;
    min-width: 0;
}

.trade-dialog-label {
    align-self: flex-start;
    margin: 0.2rem 0 -0.4rem;
    font-weight: 700;
    font-size: 0.85rem;
}

.trade-dialog-intro {
    margin: -0.4rem 0 0;
    text-align: center;
}

/* TradeCardPicker: resource cards you tap to add, with a − to take one back. */
.trade-picker {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem 0.35rem;
    width: 100%;
}

.trade-pick {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.trade-pick-card {
    position: relative;
    width: 34px;
    height: 47px;
    padding: 0;
    border-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.35);
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%),
        var(--card-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.trade-pick-card:hover:not(:disabled) {
    transform: translateY(-2px);
}

.trade-pick-card:focus-visible {
    outline: 3px solid #3a6fb0;
    outline-offset: 2px;
}

.trade-pick-on .trade-pick-card {
    box-shadow: 0 0 0 3px #f2c230, 0 2px 4px rgba(0, 0, 0, 0.3);
}

.trade-pick-card:disabled {
    cursor: default;
}

.trade-pick-none .trade-pick-card {
    opacity: 0.35;
    filter: grayscale(0.6);
}

.trade-pick-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
}

.trade-pick-icon svg {
    width: 100%;
    height: 100%;
}

.trade-pick-card .card-count {
    position: absolute;
    top: -8px;
    right: -8px;
}

.trade-pick-minus {
    position: absolute;
    left: -9px;
    top: -8px;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #b8b2a6;
    background: #fff;
    color: #2f2a24;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.trade-pick-owned {
    font-size: 0.7rem;
    color: #6b6457;
}

.trade-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
    min-height: 2.2rem;
    padding: 0.3rem 0.5rem;
    border-radius: 0.5rem;
    background: #f6f1e4;
    text-align: center;
}

.trade-summary-ready {
    background: #fdf3d1;
}

.trade-summary-side {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.trade-summary-card {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-weight: 700;
}

.trade-summary-arrow {
    font-weight: 700;
    color: #6b6457;
}

.trade-dialog .trade-targets {
    align-self: flex-start;
}

/* Build menu (PlayView): one row per thing you can build, with its cost. */
.build-menu h4 {
    margin: 0;
}

.build-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
}

.build-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e0d8c4;
    border-radius: 0.5rem;
    background: #fffdf6;
    color: #2f2a24;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s ease, border-color 0.1s ease;
}

.build-option:hover:not(:disabled) {
    background: #fdf3d1;
    border-color: #f2c230;
}

.build-option:focus-visible {
    outline: 3px solid #3a6fb0;
    outline-offset: 2px;
}

.build-option:disabled {
    cursor: default;
    opacity: 0.45;
}

/* Unavailable, but still clickable: hovering shows why (title), tapping shows it in a bubble (.reason-popover). */
.build-option {
    position: relative;
}

.build-option.build-option-blocked {
    cursor: help;
}

.build-option.build-option-blocked > :not(.reason-popover) {
    opacity: 0.45;
}

.build-option.build-option-blocked:hover {
    background: #fffdf6;
    border-color: #e0d8c4;
}

/* The "why not" bubble under a tapped unavailable option. */
.reason-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0.75rem;
    right: 0.75rem;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.45rem;
    background: #3b3026;
    color: #fffaf0;
    font-size: 0.85rem;
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.reason-popover::before {
    content: "";
    position: absolute;
    top: -5px;
    left: 1.1rem;
    width: 10px;
    height: 10px;
    background: inherit;
    transform: rotate(45deg);
}

.reason-popover .build-cost {
    color: inherit;
}

.knight-action {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* A card or button that can't be used now: looks inactive, but a click still says why. */
.card-action-inactive {
    opacity: 0.55;
}


.build-option-icon {
    font-size: 1.4rem;
}

.build-option-name {
    flex: 1;
    font-weight: 700;
}

.build-option-cost {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.build-cost {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.build-option-note {
    font-size: 0.85rem;
    color: #6b6457;
}

.build-option-free {
    font-weight: 700;
    color: #3f8f5a;
}

/* City improvement rows in the improvements menu: edged in the track's colour. */
.build-option[style*="--track-color"] {
    border-left: 5px solid var(--track-color);
}

.build-option-icon .ui-icon {
    width: 1.4rem;
    height: 1.4rem;
}

/* Illustrated cards (CardArt, made by design/generate_cards.py): the image is the whole card, so the plain card's
   colour, border and icon give way to it. The large card in the play popup gets the translated name on its banner. */
.game-card.game-card-art {
    background: var(--card-img) center / 100% 100% no-repeat;
    border: none;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.game-card-art .card-icon {
    display: none;
}

/* Small cards (hand bar, trade picker): too small for the illustration, so the same parchment frame and coloured
   header as the big card, with one big clear icon on a light panel in the middle. */
.card-stack-art .game-card,
.trade-pick-card.trade-pick-art {
    background:
        linear-gradient(var(--card-color), var(--card-color)) 3px 3px / calc(100% - 6px) 8px no-repeat,
        radial-gradient(circle at 50% 45%, #fffdf4 30%, color-mix(in srgb, var(--card-color) 28%, #fff8e6) 100%)
            3px 13px / calc(100% - 6px) calc(100% - 16px) no-repeat,
        linear-gradient(160deg, #fbf0cf, #e3c98c);
    border: 1px solid #9c7c45;
    border-radius: 5px;
    box-shadow: inset 0 0 0 1px #fff7df, 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.card-stack-art .card-icon {
    margin-top: 10px;
    font-size: 1.15rem;
    filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.8));
}

.card-stack-art .card-icon .ui-glyph {
    color: color-mix(in srgb, var(--card-color) 85%, #000);
}

.trade-pick-art .trade-pick-icon {
    margin-top: 10px;
    width: 22px;
    height: 22px;
}

.game-card.game-card-large.game-card-art {
    width: 170px;
    height: 241px;
    justify-content: flex-start;
    box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.3);
}

/* The banner sits at 18-52 of the card's 340 height, between 54 and 220 of its 240 width (after the colour icon). */
.game-card-art .card-title {
    position: absolute;
    top: 5.3%;
    left: 22.5%;
    right: 8.5%;
    height: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #3b2a12;
    text-shadow: none;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    /* Sized to fit the banner (69% of the card's width) whatever the name's length (--chars) and the card's size:
       Cinzel capitals are about 0.75em wide. */
    font-size: min(0.85rem, calc(69cqi / (var(--chars, 8) * 0.75)));
    line-height: 1;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.game-card.game-card-art {
    container-type: inline-size;
}

.trade-pick-art.trade-pick-card {
    width: 34px;
    height: 48px;
}

@media (max-height: 640px) {
    .game-card.game-card-large.game-card-art {
        width: 120px;
        height: 170px;
    }
}

/* Game manual (ManualButton): a wide, scrolling popup with a tab per game. */
.manual-shell {
    width: min(720px, 100%);
}

.manual {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.manual-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.manual-header h3 {
    margin: 0;
}

.manual-close {
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #2f2a24;
}

.manual-tabs {
    display: flex;
    gap: 0.4rem;
    border-bottom: 2px solid #e8e0cc;
}

.manual-tabs button {
    white-space: nowrap;
    padding: 0.4rem 0.9rem;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: none;
    font: inherit;
    font-weight: 700;
    color: #6b6457;
    cursor: pointer;
}

.manual-tabs button.active {
    color: #2f2a24;
    border-bottom-color: #f2c230;
}

.manual-body {
    line-height: 1.5;
}

.manual-body h4 {
    margin: 1rem 0 0.3rem;
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
}

.manual-body h4:first-child {
    margin-top: 0.3rem;
}

.manual-body p,
.manual-body ul,
.manual-body ol {
    margin: 0 0 0.4rem;
}

.manual-body ul,
.manual-body ol {
    padding-left: 1.3rem;
}

.manual-table {
    border-collapse: collapse;
    width: 100%;
}

.manual-table td {
    padding: 0.3rem 0.5rem 0.3rem 0;
    border-bottom: 1px solid #efe7d4;
    vertical-align: middle;
}

.manual-table td:first-child {
    font-weight: 700;
    white-space: nowrap;
}

.manual-cost {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    white-space: nowrap;
    vertical-align: middle;
}

/* =====================================================================================================
   Theme: the deep sea with parchment cards, so every part of the page matches the board and the
   playing cards. Radzen's components follow through its CSS variables; our own parts use the --catan-*
   tokens below. Loaded after Radzen's theme, so these values win.
   ===================================================================================================== */
:root {
    --catan-parchment: #fbf1d8;
    --catan-parchment-deep: #f1e1bb;
    --catan-ink: #3b2a12;
    --catan-ink-soft: #6b5a3e;
    --catan-gold: #c9962b;
    --catan-line: #c9ad7a;
    --catan-wood: #3e2a18;
    --catan-wood-light: #5a3d22;

    --rz-primary: #9c4a1d;
    --rz-primary-light: #b85f2e;
    --rz-primary-lighter: rgba(156, 74, 29, 0.14);
    --rz-primary-dark: #823c16;
    --rz-primary-darker: #6a3011;
    --rz-on-primary: #ffffff;
    --rz-secondary: #3f6b3a;
    --rz-secondary-light: #4f8248;
    --rz-secondary-lighter: rgba(63, 107, 58, 0.15);
    --rz-secondary-dark: #33582f;
    --rz-secondary-darker: #284625;
    --rz-on-secondary: #ffffff;
    --rz-text-color: var(--catan-ink);
    --rz-text-secondary-color: var(--catan-ink-soft);

    --rz-card-background-color: var(--catan-parchment);
    --rz-card-border: 1px solid var(--catan-line);
    --rz-card-border-radius: 12px;
    --rz-card-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 2px 0 #a8864f, 0 8px 18px rgba(30, 18, 6, 0.35);

    --rz-input-background-color: #fffaf0;
    --rz-input-border: 1px solid var(--catan-line);
}

/* The page: light, fresh water with a very faint honeycomb of pointy-top hexagons, like the island's own tiles (a
   seamless SVG tile), and a little more depth towards the bottom. */
body {
    color: var(--catan-ink);
    background-color: #a9e2ec;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2251.96%22 height=%2290.00%22 viewBox=%220 0 51.96 90.00%22%3E%3Cpath d=%22M0.00 -30.00 L-25.98 -15.00 L-51.96 -30.00 L-51.96 -60.00 L-25.98 -75.00 L-0.00 -60.00Z M51.96 -30.00 L25.98 -15.00 L-0.00 -30.00 L0.00 -60.00 L25.98 -75.00 L51.96 -60.00Z M103.92 -30.00 L77.94 -15.00 L51.96 -30.00 L51.96 -60.00 L77.94 -75.00 L103.92 -60.00Z M155.88 -30.00 L129.90 -15.00 L103.92 -30.00 L103.92 -60.00 L129.90 -75.00 L155.88 -60.00Z M-25.98 15.00 L-51.96 30.00 L-77.94 15.00 L-77.94 -15.00 L-51.96 -30.00 L-25.98 -15.00Z M25.98 15.00 L0.00 30.00 L-25.98 15.00 L-25.98 -15.00 L-0.00 -30.00 L25.98 -15.00Z M77.94 15.00 L51.96 30.00 L25.98 15.00 L25.98 -15.00 L51.96 -30.00 L77.94 -15.00Z M129.90 15.00 L103.92 30.00 L77.94 15.00 L77.94 -15.00 L103.92 -30.00 L129.90 -15.00Z M0.00 60.00 L-25.98 75.00 L-51.96 60.00 L-51.96 30.00 L-25.98 15.00 L-0.00 30.00Z M51.96 60.00 L25.98 75.00 L-0.00 60.00 L0.00 30.00 L25.98 15.00 L51.96 30.00Z M103.92 60.00 L77.94 75.00 L51.96 60.00 L51.96 30.00 L77.94 15.00 L103.92 30.00Z M155.88 60.00 L129.90 75.00 L103.92 60.00 L103.92 30.00 L129.90 15.00 L155.88 30.00Z M-25.98 105.00 L-51.96 120.00 L-77.94 105.00 L-77.94 75.00 L-51.96 60.00 L-25.98 75.00Z M25.98 105.00 L0.00 120.00 L-25.98 105.00 L-25.98 75.00 L-0.00 60.00 L25.98 75.00Z M77.94 105.00 L51.96 120.00 L25.98 105.00 L25.98 75.00 L51.96 60.00 L77.94 75.00Z M129.90 105.00 L103.92 120.00 L77.94 105.00 L77.94 75.00 L103.92 60.00 L129.90 75.00Z M0.00 150.00 L-25.98 165.00 L-51.96 150.00 L-51.96 120.00 L-25.98 105.00 L-0.00 120.00Z M51.96 150.00 L25.98 165.00 L-0.00 150.00 L0.00 120.00 L25.98 105.00 L51.96 120.00Z M103.92 150.00 L77.94 165.00 L51.96 150.00 L51.96 120.00 L77.94 105.00 L103.92 120.00Z M155.88 150.00 L129.90 165.00 L103.92 150.00 L103.92 120.00 L129.90 105.00 L155.88 120.00Z%22 fill=%22none%22 stroke=%22%23ffffff%22 stroke-opacity=%220.32%22 stroke-width=%221.2%22 stroke-linejoin=%22round%22/%3E%3C/svg%3E"),
        radial-gradient(ellipse 90% 70% at 40% 45%, rgba(255, 255, 255, 0.45), transparent 70%),
        linear-gradient(180deg, #a3dfea 0%, #c4ecf2 30%, #c4ecf2 70%, #86d2e0 100%);
    background-size: 51.96px 90.00px, auto, auto;
    background-position: center;
    background-attachment: fixed;
}

/* The game with the 3D board: the deep sea texture of the 2D board under a dark-blue vignette. */
body:has(.play-view-immersive .board3d) {
    background-color: #1f8fb5;
    background-image:
        radial-gradient(ellipse at 50% 40%, rgba(11, 58, 85, 0) 50%, rgba(11, 58, 85, 0.5) 100%),
        url("img/sea.jpg");
    background-size: auto, 300px 300px;
    background-position: 0 0;
}

/* Text that sits straight on the light water: dark ink with a soft light halo. */
.home-hero h1,
.home-hero p,
.play-status .turn-indicator {
    color: var(--catan-ink);
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* Parchment cards and popups. */
.rz-card {
    background: linear-gradient(160deg, #fdf6e3, var(--catan-parchment-deep));
    color: var(--catan-ink);
}

.rz-card h1, .rz-card h2, .rz-card h3, .rz-card h4 {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    color: var(--catan-ink);
    letter-spacing: 0.02em;
}

.hint {
    color: var(--catan-ink-soft);
}

/* Buttons: light ones on parchment, dark ones in wood. */
.rz-button.rz-light {
    background: #f8ecd2;
    color: var(--catan-ink);
    box-shadow: inset 0 0 0 1px var(--catan-line);
}

.rz-button.rz-light:not(.rz-state-disabled):hover {
    background: #fdf3dd;
}

.rz-button.rz-dark {
    background: linear-gradient(180deg, var(--catan-wood-light), var(--catan-wood));
    color: #fbf1d8;
}

/* The action bar, hand bar and every card/block on the pages as sandbanks (popups and the manual stay parchment):
   sand like the island's beach, with a fine grain. */
.play-header,
.play-view-immersive .hand-bar,
.rz-card:not(.card-popup):not(.manual),
.home-card.access-card {
    color: var(--catan-ink);
    background:
        radial-gradient(circle at 20% 30%, rgba(160, 120, 60, 0.10) 0 1px, transparent 1.5px) 0 0 / 7px 9px,
        radial-gradient(circle at 70% 80%, rgba(255, 255, 255, 0.25) 0 1px, transparent 1.5px) 0 0 / 13px 11px,
        radial-gradient(circle at 40% 60%, rgba(150, 110, 50, 0.08) 0 1.5px, transparent 2px) 0 0 / 17px 23px,
        linear-gradient(180deg, #f3e2ad, #e5cd8c);
    border: none;
    border-radius: 18px;
}

/* Margin so the shallow-water ring around the sandbank isn't cut off at the page edge. */
.play-view > .play-header {
    top: 10px;
    margin: 10px 10px calc(1rem + 10px);
}

.action-bar-mine {
    border-color: #d99a22;
}

.action-bar-instruction {
    color: var(--catan-ink);
}

/* The hand bar, offer popup and menus on parchment. */
.hand-bar,
.trade-popup {
    background: linear-gradient(160deg, #fdf6e3, var(--catan-parchment-deep));
}

.build-option {
    background: #fffaf0;
    border-color: var(--catan-line);
}

.manual-tabs {
    border-bottom-color: var(--catan-line);
}

/* --- Player boards (PlayerPanel) --- */
.player-board {
    margin-bottom: 0.5rem;
    padding: 0.45rem 0.6rem;
    border: 1px solid #e0cc9f;
    border-left: 6px solid var(--player-color);
    border-radius: 8px;
    background: color-mix(in srgb, var(--player-color) 9%, #fffaf0);
    box-shadow: 0 1px 2px rgba(60, 40, 10, 0.2);
}

.player-board:last-child {
    margin-bottom: 0;
}

.player-board-active {
    box-shadow: 0 0 0 2px #f2c230, 0 2px 10px rgba(242, 194, 48, 0.55);
}

.player-board-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.player-token {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--player-color);
    border: 2px solid rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
    color: #fff;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-weight: 700;
}

.player-board-name {
    min-width: 2.5em;
    font-weight: 700;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Whose turn it is: the gold glow around the board plus a small gold arrow before the name. */
.player-board-active .player-board-name::before {
    content: "\25B6\00a0";
    font-size: 0.75em;
    color: var(--catan-gold);
}

.player-board-you {
    flex-shrink: 0;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.player-board-you {
    background: var(--catan-ink);
    color: #fbf1d8;
}

.player-board-vp {
    margin-left: auto;
    flex-shrink: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 0.15rem;
    color: var(--catan-ink-soft);
}

.player-board-vp .ui-icon {
    align-self: center;
    color: var(--catan-gold);
}

.player-board-vp strong {
    font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--catan-ink);
}

.player-board-vp small {
    font-size: 0.8rem;
}

.player-board-stats,
.player-board-awards {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.player-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.08rem 0.45rem;
    border: 1px solid #e0cc9f;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    font-size: 0.8rem;
    font-weight: 600;
    color: #4a3b22;
}

.player-stat .ui-icon {
    color: var(--catan-ink-soft);
}

/* Someone's progress cards as everyone may see them: a small card per colour, with how many (ProgressCardColors). */
.progress-colors {
    display: inline-flex;
    gap: 0.15rem;
    margin-left: 0.1rem;
}

.progress-color {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Player board: the progress-card count opens a bubble with their colours. */
.player-stat-progress {
    position: relative;
    cursor: pointer;
}

.reason-popover.progress-popover {
    left: 0;
    right: auto;
    white-space: nowrap;
}

.progress-popover .progress-colors {
    gap: 0.6rem;
}

.progress-color-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0.85rem;
    height: 1.1rem;
    padding: 0 0.15rem;
    border: 1px solid rgba(0, 0, 0, 0.35);
    border-radius: 3px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* Spy: the opponents to choose from, each with the colours of their cards. */
.spy-targets {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.spy-target {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid #d8c59a;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--catan-ink);
    text-align: left;
    cursor: pointer;
}

.spy-target:disabled {
    opacity: 0.55;
    cursor: default;
}

.spy-target-selected {
    border-color: #9c5a1c;
    background: #fff3d6;
    box-shadow: 0 0 0 2px rgba(156, 90, 28, 0.35);
}

.spy-target-name {
    flex: 1;
    font-weight: 600;
}

.spy-target .hint {
    margin: 0;
}

/* Spy, after choosing: the other player's cards in full, side by side (wrapping on a phone); click one to take it. */
.card-popup-shell.spy-reveal-shell {
    width: min(820px, 100%);
}

.spy-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.spy-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 180px;
    padding: 0.6rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.spy-card:hover,
.spy-card:focus-visible {
    border-color: #d8c59a;
    background: rgba(255, 255, 255, 0.6);
}

.spy-card .card-popup-description {
    flex: 1;
}

.spy-card-take {
    padding: 0.3rem 0.9rem;
    border-radius: 6px;
    background: #9c4a1c;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

@media (max-width: 520px) {
    .spy-card {
        width: 140px;
    }

    .spy-card .game-card.game-card-large.game-card-art {
        width: 120px;
        height: 170px;
    }
}

.player-award {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.55rem;
    border: 1px solid #9c7310;
    border-radius: 999px;
    background: linear-gradient(180deg, #f7d66b, #d9a52a);
    color: var(--catan-ink);
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Text only for screen readers. */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* =====================================================================================================
   Immersive game layout (PlayView .play-view-immersive): the board (2D or 3D) fills the whole screen and
   everything else floats over it as sandbanks. The board keeps the island in the part the floating bars leave
   free: board-insets.js publishes that part as --free-top/right/bottom/left for the 2D board, and board3d.js
   measures the same elements (marked data-board-inset) for the 3D scene.
   Sandbanks have a 10px ring of shallow water (see .play-header), hence the 12px+ gaps between them.
   ===================================================================================================== */
.play-view-immersive {
    --side-w: 344px;
    --float-top: calc(var(--app-topbar-height) + 1.6rem);
    --hand-gap: 14px;
    padding-bottom: 0;
}

/* Views without a hand bar (final board, spectating, map vote): nothing to keep clear at the bottom. */
.play-view-immersive:not(.play-view-with-hand) {
    --hand-bar-height: 0px;
    --hand-gap: 0px;
}

body:has(.play-view-immersive) {
    overflow: hidden;
}

.play-view-immersive .play-board-column {
    position: fixed;
    inset: 0;
    z-index: 0;
    min-width: 0;
}

/* 3D: the canvas covers the screen. */
.play-view-immersive .board3d-wrap,
.play-view-immersive .board3d {
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0;
}

/* 2D: the board is drawn in the free part of the screen, without its own sea rectangle, so the page's water
   runs on behind the bars. */
.play-view-immersive .play-board-column .hex-board-wrapper {
    position: fixed;
    top: var(--free-top, 0px);
    right: var(--free-right, 0px);
    bottom: var(--free-bottom, 0px);
    left: var(--free-left, 0px);
    width: auto;
    max-width: none;
    margin: 0;
    padding: 1.25rem;
}

.play-view-immersive .play-board-column .hex-board {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* The 2D board's own sea rectangle is not drawn anywhere: the page around it is water already. Pieces near the edge
   (ports) may then reach past the drawing area. */
.board-ocean {
    display: none;
}

.hex-board {
    overflow: visible;
}

/* The top row (manual, full screen, 2D/3D, language) and the turn status float at the top. */
body:has(.play-view-immersive) .app-topbar {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
    z-index: 60;
    margin: 0;
}

.play-view-immersive .play-status {
    position: fixed;
    top: 0.75rem;
    left: 1rem;
    z-index: 60;
    height: var(--app-topbar-height);
    margin: 0;
}

/* The action bar: top left, leaving room for the side panel. */
.play-view-immersive > .play-header {
    position: fixed;
    top: var(--float-top);
    left: 1.25rem;
    right: calc(var(--side-w) + 0.5rem + 12px);
    margin: 0;
    z-index: 50;
}

/* The side panel: a scrolling column of sandbanks on the right, between the top row and the hand bar. Its padding
   keeps the water rings of the blocks from being cut off by the scrolling. */
.play-view-immersive .play-sidebar {
    position: fixed;
    top: calc(var(--float-top) - 12px);
    right: 0.5rem;
    bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 10px);
    width: var(--side-w);
    min-width: 0;
    z-index: 40;
    gap: 24px;
    overflow-y: auto;
    padding: 12px;
    scrollbar-width: thin;
}

.play-view-immersive .sidebar-card {
    flex-shrink: 0;
}

.play-view-immersive.panel-toggled .play-sidebar {
    display: none;
}

.play-view-immersive.panel-toggled > .play-header {
    right: 1.25rem;
}

/* Zoom / reset buttons of the 3D board: bottom right of the free area. */
.play-view-immersive .board3d-controls {
    position: fixed;
    right: calc(var(--side-w) + 1.5rem);
    bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 1.5rem);
    z-index: 30;
}

.play-view-immersive.panel-toggled .board3d-controls {
    right: 1.25rem;
}

/* Panels that normally sit under the board (discarding, choosing a victim, decisions) float top left. */
.play-view-immersive .play-board-column .inline-panel {
    position: fixed;
    top: calc(var(--free-top, 10rem) + 1.25rem);
    left: 1.25rem;
    z-index: 45;
    width: min(420px, calc(100vw - 2.5rem));
    max-height: calc(100vh - var(--free-top, 10rem) - var(--free-bottom, 8rem) - 2.5rem);
    overflow-y: auto;
    margin: 0;
}

/* The toggle for the side panel, in the top row left of the other buttons. */
.panel-toggle {
    position: fixed;
    top: 0.75rem;
    right: calc(var(--app-topbar-controls) + 1.5rem);
    z-index: 60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--app-topbar-height);
    padding: 0 0.6rem;
    border: 1px solid #c9c2b3;
    border-radius: 999px;
    background: #fffdf6;
    color: var(--catan-ink);
    cursor: pointer;
}

/* The game menu (GameMenu, ⋮) at the very right of the top row: the other top-row buttons (in the layout) and the
   side-panel button move left to make room. Over a board the row floats (fixed); on the results page it's the
   normal top row of the page (absolute, so it scrolls with it). */
body:has(.game-menu) {
    --game-menu-space: calc(var(--app-topbar-height) + 0.5rem);
}

body:has(.game-menu) .app-topbar {
    padding-right: var(--game-menu-space);
}

/* On game screens the manual, 2D/3D and language live in the game menu; only full screen stays in the top row. */
body:has(.game-menu) .app-topbar .topbar-manual,
body:has(.game-menu) .app-topbar .topbar-board-view,
body:has(.game-menu) .app-topbar .topbar-language {
    display: none;
}

body:has(.game-menu) {
    --app-topbar-controls: 2.6rem;
}

/* The start page keeps only the language and full screen in the top row. */
body:has(.home-page) .app-topbar .topbar-manual,
body:has(.home-page) .app-topbar .topbar-board-view {
    display: none;
}

.game-menu-choice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    color: var(--catan-ink);
    white-space: nowrap;
}

.game-menu-choice > span:first-of-type {
    flex: 1;
}

.game-menu {
    position: absolute;
    top: 1rem;
    right: max(1rem, calc((100% - 1400px) / 2 + 1rem));
    z-index: 65;
}

.play-view-immersive .game-menu {
    position: fixed;
    top: 0.75rem;
    right: 1rem;
}

.play-view-immersive:has(.game-menu) .panel-toggle {
    right: calc(var(--app-topbar-controls) + 1.5rem + var(--game-menu-space));
}

.game-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--app-topbar-height);
    height: var(--app-topbar-height);
    padding: 0;
    border: 1px solid #c9c2b3;
    border-radius: 50%;
    background: #fffdf6;
    color: var(--catan-ink);
    cursor: pointer;
}

.game-menu-backdrop {
    position: fixed;
    inset: 0;
}

.game-menu-list {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 13rem;
    padding: 0.35rem;
    border: 1px solid var(--catan-line);
    border-radius: 10px;
    background: linear-gradient(160deg, #fdf6e3, var(--catan-parchment-deep));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.game-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--catan-ink);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.game-menu-item:hover:not(:disabled) {
    background: rgba(150, 110, 50, 0.15);
}

.game-menu-item:disabled {
    opacity: 0.5;
    cursor: default;
}

/* The vote on ending the game, for every player: a floating card at the top, under the action bar. */
.end-game-vote {
    position: fixed;
    top: calc(var(--free-top, 9rem) + 0.75rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 58;
    width: min(24rem, calc(100vw - 1.5rem));
    padding: 0.7rem 0.9rem;
    border: 2px solid #b33a2a;
    border-radius: 0.75rem;
    background: linear-gradient(160deg, #fdf6e3, var(--catan-parchment-deep));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.end-game-vote .hint {
    margin: 0.25rem 0;
}

/* The hand bar: a sandbank across the bottom, clear of the screen edge. */
.play-view-immersive .hand-bar {
    left: 1.25rem;
    right: 1.25rem;
    bottom: var(--hand-gap);
    border-radius: 18px;
}

.play-view-immersive .hand-bar-section + .hand-bar-section {
    border-left-color: rgba(150, 110, 50, 0.3);
}

/* The trade offer popup floats just above the hand bar. */
.play-view-immersive .trade-popup {
    bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 1.25rem);
}

/* Phones and small tablets: no room for a side column, so the panel is a full-width sheet that starts hidden. */
@media (max-width: 899px) {
    .play-view-immersive {
        --hand-gap: 12px;
    }

    .play-view-immersive > .play-header,
    .play-view-immersive.panel-toggled > .play-header {
        left: 0.85rem;
        right: 0.85rem;
    }

    .play-view-immersive .play-sidebar {
        left: 0;
        right: 0;
        width: auto;
        padding: 12px 0.85rem;
        display: none;
    }

    /* Opened, it's a sheet over everything (the toggle button stays above it to close it again). */
    .play-view-immersive.panel-toggled .play-sidebar {
        display: flex;
        z-index: 55;
    }

    .play-view-immersive .board3d-controls,
    .play-view-immersive.panel-toggled .board3d-controls {
        right: 0.9rem;
    }

    .play-view-immersive .hand-bar {
        left: 0.85rem;
        right: 0.85rem;
    }

    .play-view-immersive .play-board-column .hex-board-wrapper {
        padding: 0.75rem;
    }

    /* The side panel with the dice starts hidden here, so the last roll floats at the top right of the board. */
    .play-view-immersive .board-dice {
        display: block;
        position: fixed;
        top: calc(var(--free-top, 9rem) + 0.5rem);
        right: 0.85rem;
        z-index: 35;
        padding: 0.3rem 0.6rem;
        border-radius: 12px;
        background: rgba(255, 253, 246, 0.85);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }

    .play-view-immersive .board-dice .dice-row {
        gap: 0.3rem;
        margin: 0;
        min-height: 0;
    }

    .play-view-immersive .board-dice .dice-event-row {
        margin-top: 0.25rem;
    }

    .play-view-immersive .board-dice .die {
        width: 1.7rem;
        height: 1.7rem;
    }

    .play-view-immersive .board-dice .dice-total {
        font-size: 1rem;
    }

    /* Nothing rolled yet this turn: no empty box over the board. */
    .play-view-immersive .board-dice:has(.hint) {
        display: none;
    }

    /* Full screen isn't offered on phones (the browser's own controls do that, if at all). */
    .app-topbar .topbar-fullscreen {
        display: none;
    }

    body:has(.game-menu) {
        --app-topbar-controls: 0rem;
    }
}

.board-dice {
    display: none;
}

/* Narrow phones: the top row is full with its buttons, so the turn status gets its own line under it (with the
   action bar below that), and the side-panel button moves to the bottom right (above the 3D zoom buttons). */
@media (max-width: 520px) {
    .play-view-immersive .play-status {
        top: var(--float-top);
        left: 0.75rem;
    }

    .play-view-immersive > .play-header,
    .play-view-immersive.panel-toggled > .play-header {
        top: calc(var(--float-top) + var(--app-topbar-height) + 0.9rem);
    }

    .play-view-immersive .play-sidebar {
        top: calc(var(--float-top) + var(--app-topbar-height) + 0.9rem - 12px);
    }

    .play-view-immersive .panel-toggle,
    .play-view-immersive:has(.game-menu) .panel-toggle {
        top: auto;
        right: 0.9rem;
        bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 1.5rem);
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
        border-radius: 50%;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    }

    .play-view-immersive:has(.board3d-controls) .panel-toggle {
        bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 1.5rem + 3 * 2.5rem + 3 * 0.35rem);
    }
}

/* Hand bar tabs: only on phones (below), where resources and cards don't fit side by side. */
.hand-tabs {
    display: none;
}

/* Phones: everything within thumb reach and nothing off-screen. The top row holds just the turn status, the side-panel
   button and the menu; the action bar sits at the bottom above the hand, with icon buttons and the main button of the
   moment (roll, end turn…) pinned at its right; playing a card goes through the hand; the hand shows resources or
   cards (tabs) as small cards that all fit; and the 3D board is zoomed by pinching instead of with buttons. After the
   narrow-phone rules above, which this replaces. */
@media (max-width: 600px) {
    .play-view-with-hand {
        --hand-bar-height: 6.4rem;
    }

    .play-view-immersive .play-status {
        top: 0.75rem;
        left: 0.75rem;
        right: calc(2 * var(--app-topbar-height) + 2.25rem);
        overflow: hidden;
    }

    .play-view-immersive .panel-toggle,
    .play-view-immersive:has(.game-menu) .panel-toggle,
    .play-view-immersive:has(.board3d-controls) .panel-toggle {
        top: 0.75rem;
        bottom: auto;
        right: calc(1rem + var(--app-topbar-height) + 0.5rem);
        width: var(--app-topbar-height);
        height: var(--app-topbar-height);
        padding: 0;
        border-radius: 50%;
        box-shadow: none;
    }

    .play-view-immersive .play-sidebar {
        top: calc(var(--app-topbar-height) + 1rem);
    }

    .play-view-immersive > .play-header,
    .play-view-immersive.panel-toggled > .play-header {
        top: auto;
        bottom: calc(var(--hand-bar-height) + var(--hand-gap) + 10px);
        left: 0.85rem;
        right: 0.85rem;
        padding: 0.35rem 0.45rem;
    }

    .play-view-immersive .action-bar-instruction {
        padding: 0 0.2rem;
        font-size: 0.85rem;
        line-height: 1.2;
    }

    /* Buttons of one size: as tall as the tallest, and sharing the width equally. */
    .play-view-immersive .action-bar-buttons {
        align-items: stretch;
        gap: 0.25rem;
    }

    .play-view-immersive .action-bar .rz-button:not(.action-bar-primary) {
        flex: 1 1 0;
    }

    /* A shorter label where the full one would take two lines (data-short-label). */
    .play-view-immersive .action-bar .rz-button[data-short-label] .rz-button-text {
        display: none;
    }

    .play-view-immersive .action-bar .rz-button[data-short-label] {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
    }

    .play-view-immersive .action-bar .rz-button[data-short-label]::after {
        content: attr(data-short-label);
    }

    /* Cards are played from the hand (tapping one opens the same popup), so the bar keeps only the actions. */
    .play-view-immersive .action-bar .card-action {
        display: none;
    }

    /* Icon over a short label, so the actions fit side by side. */
    .play-view-immersive .action-bar .rz-button {
        min-width: 3rem;
        max-width: 4.8rem;
        padding: 0.25rem 0.3rem;
        font-size: 0.66rem;
        letter-spacing: 0;
        text-transform: none;
        line-height: 1.05;
        white-space: normal;
    }

    .play-view-immersive .action-bar .rz-button .rz-button-box {
        flex-direction: column;
        gap: 0.15rem;
    }

    .play-view-immersive .action-bar .rz-button .rz-button-icon-left {
        margin: 0;
        font-size: 1.25rem;
    }

    /* The main button stays in view at the right, however far the others scroll; its colour sets it apart. */
    .play-view-immersive .action-bar .action-bar-primary {
        order: 99;
        position: sticky;
        right: 0;
        margin-left: auto;
        min-width: 3.8rem;
        font-weight: 700;
        box-shadow: -6px 0 8px -4px rgba(0, 0, 0, 0.3);
    }

    .play-view-immersive .board3d-controls {
        display: none;
    }

    /* Offers and panels keep clear of the action bar and hand at the bottom (measured by board-insets.js). */
    .play-view-immersive .trade-popup {
        bottom: calc(var(--free-bottom, 12rem) + 0.5rem);
        max-height: calc(100vh - var(--free-bottom, 12rem) - var(--free-top, 3rem) - 1.5rem);
    }

    /* The hand: tabs, then one row of small cards that all fit. */
    .play-view-immersive .hand-bar {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.35rem 0.6rem 0.4rem;
        overflow: hidden;
    }

    .hand-tabs {
        display: flex;
        gap: 0.3rem;
    }

    .hand-tab {
        display: inline-flex;
        align-items: center;
        gap: 0.3rem;
        padding: 0.1rem 0.6rem;
        border: 1px solid var(--catan-line);
        border-radius: 999px;
        background: transparent;
        color: var(--catan-ink);
        font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
        font-size: 0.75rem;
        font-weight: 700;
    }

    .hand-tab-active {
        border-color: #9c5a1c;
        background: #9c5a1c;
        color: #fff;
    }

    .hand-tab-count {
        min-width: 1.1rem;
        padding: 0 0.3rem;
        border-radius: 999px;
        background: rgba(0, 0, 0, 0.12);
        font-family: system-ui, sans-serif;
        font-size: 0.7rem;
        text-align: center;
    }

    .hand-bar.hand-show-cards .hand-section-resources,
    .hand-bar:not(.hand-show-cards) .hand-bar-section:not(.hand-section-resources) {
        display: none;
    }

    .play-view-immersive .hand-bar-section + .hand-bar-section {
        padding-left: 0;
        border-left: none;
    }

    /* The tabs name both parts. */
    .play-view-immersive .hand-bar .hand-bar-label,
    .play-view-immersive .hand-bar .hand-bar-heading {
        display: none;
    }

    .play-view-immersive .hand-bar .card-hand {
        gap: 0.3rem;
        padding-top: 0.45rem;
    }

    /* One small card per kind (no stack), sized so eight kinds fit across. */
    .play-view-immersive .hand-bar .card-stack {
        width: min(38px, calc((100vw - 4.5rem) / 8));
        height: auto;
        aspect-ratio: 36 / 50;
    }

    .play-view-immersive .hand-bar .card-stack .game-card {
        left: 0 !important;
        top: 0 !important;
        width: 100%;
        height: 100%;
    }

    .play-view-immersive .hand-bar .card-stack .game-card:not(:last-child) {
        display: none;
    }

    .play-view-immersive .hand-bar .card-stack .card-count {
        top: -7px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        font-size: 0.7rem;
        line-height: 18px;
    }

    .play-view-immersive .hand-bar .hand-bar-empty {
        margin-top: 0.4rem;
        font-size: 0.75rem;
    }
}

/* A popup's overlay is inside the bar that opened it, so while one is open that bar goes above everything else
   floating over the board (the top row, the turn status, the side-panel button). After the immersive layout rules,
   which give these bars their normal stacking. */
body .app-topbar:has(.card-popup-overlay),
.play-header:has(.card-popup-overlay),
.hand-bar:has(.card-popup-overlay),
.play-sidebar:has(.card-popup-overlay),
.play-board-column:has(.card-popup-overlay) {
    z-index: 1000;
}
