/* Component appearance stays below the shared control interaction layer. */
@layer app {
:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #182126;
    color: #eef3f5;
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body, #app { min-height: 100%; margin: 0; }

body {
    min-width: 320px;
    background:
        radial-gradient(circle at 18% 0%, rgba(68, 112, 102, .28), transparent 36rem),
        #182126;
}

a { color: #7fd7c5; }
button, input { font: inherit; }

.app-header {
    min-height: 62px;
    padding: env(safe-area-inset-top) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #34434a;
    background: rgba(13, 18, 21, .86);
    backdrop-filter: blur(12px);
}

.brand {
    color: #f5d675;
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.prototype-label, .eyebrow {
    color: #7fd7c5;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .14em;
}

main {
    padding: 24px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.7rem, 4vw, 2.5rem); }
h2 { margin-bottom: 0; font-size: 1rem; }
.muted { color: #aab7bc; }

.welcome-card, .loading-card, .error-card {
    max-width: 720px;
    margin: 8vh auto 0;
    padding: clamp(24px, 5vw, 48px);
    border: 1px solid #415258;
    border-radius: 18px;
    background: rgba(23, 31, 35, .88);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}

.welcome-card code {
    display: block;
    margin: 16px 0;
    padding: 14px;
    overflow-wrap: anywhere;
    border-radius: 8px;
    background: #0e1518;
    color: #f5d675;
}

.entry-page { max-width: 1040px; margin: 0 auto; }
.account-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: .7rem 1rem;
    border: 1px solid #415258;
    border-radius: 12px;
    background: rgba(23, 31, 35, .9);
}
.account-card form { margin: 0; }
.account-maintenance-link { text-decoration: none; }
.entry-intro { max-width: 720px; margin: 4vh auto 28px; text-align: center; }
.entry-intro > p:last-child { max-width: 620px; margin-right: auto; margin-left: auto; color: #b6c1c5; }

.resume-card, .entry-card, .entry-error {
    border: 1px solid #415258;
    border-radius: 16px;
    background: rgba(23, 31, 35, .9);
    box-shadow: 0 20px 48px rgba(0, 0, 0, .2);
}

.resume-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 18px;
    padding: 20px 24px;
}

.resume-card h2 { margin: 3px 0 7px; font-size: 1.2rem; }
.resume-card p { margin-bottom: 0; }
.resume-card code { color: #f5d675; overflow-wrap: anywhere; }

.entry-actions { display: flex; align-items: center; gap: 12px; }
.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.entry-card { padding: clamp(22px, 4vw, 34px); }
.entry-card h2 { margin: 4px 0 8px; font-size: 1.35rem; }
.entry-card form { display: grid; gap: 16px; margin-top: 24px; }
.entry-card label { display: grid; gap: 7px; color: #dce4e7; font-size: .84rem; font-weight: 700; }
.entry-card input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #52656c;
    border-radius: 8px;
    outline: none;
    background: #10181b;
    color: #f4f7f8;
}
.entry-card input:focus { border-color: #7fd7c5; box-shadow: 0 0 0 3px rgba(127, 215, 197, .16); }

.tables-scroll { overflow-x: auto; margin-top: 18px; }
.your-tables-table { width: 100%; min-width: 860px; border-collapse: separate; border-spacing: 0; text-align: left; border: 1px solid rgba(121, 147, 155, .28); border-radius: 10px; overflow: hidden; }
.your-tables-table th, .your-tables-table td { padding: 14px 18px; border-bottom: 1px solid rgba(121, 147, 155, .22); vertical-align: middle; }
.your-tables-table th + th, .your-tables-table td + td { border-left: 1px solid rgba(121, 147, 155, .18); }
.your-tables-table th { background: rgba(13, 21, 24, .72); color: #aab7bc; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.your-tables-table td { color: #dce4e7; font-size: .86rem; }
.your-tables-table tbody tr:nth-child(even) { background: rgba(11, 17, 20, .22); }
.your-tables-table td:last-child { width: 1%; white-space: nowrap; text-align: right; }
.your-tables-table tbody tr:last-child td { border-bottom: 0; }
.your-tables-table time { color: #b6c1c5; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-time-compact, .table-action-compact { display: none; }
.your-tables-mobile-list { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.player-name-list { display: grid; gap: 13px; }
.inline-input-row { display: flex; gap: 8px; }
.primary-button, .text-button, .remove-player-button {
    border: 0;
    border-radius: 8px;
    font-weight: 800;
}
.primary-button { min-height: 44px; padding: 10px 16px; background: #f5d675; color: #182126; --control-hover-background: #ffe58c; }
.text-button { padding: 8px 10px; background: transparent; color: #7fd7c5; }
.add-player-button { justify-self: start; }
.remove-player-button { flex: 0 0 44px; background: #2a373c; color: #f0aaa5; font-size: 1.35rem; --control-hover-background: #3a292b; }

.entry-error {
    display: grid;
    gap: 4px;
    margin-top: 18px;
    padding: 15px 18px;
    border-color: #a65353;
    color: #ffd5d1;
}
.text-link { font-size: .82rem; font-weight: 700; }

.maintenance-shell { min-height: 100dvh; }
.maintenance-header {
    min-height: 62px;
    padding: env(safe-area-inset-top) max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #34434a;
    background: rgba(13, 18, 21, .92);
    backdrop-filter: blur(12px);
}
.maintenance-return {
    margin-left: auto;
    padding: 8px 10px;
    border-radius: 8px;
    color: #7fd7c5;
    font-size: .84rem;
    font-weight: 800;
    text-decoration: none;
}
.maintenance-main { max-width: 1080px; margin: 0 auto; }
.maintenance-intro { max-width: 720px; margin: 4vh 0 28px; }
.maintenance-intro > p:last-child { margin-bottom: 0; color: #b6c1c5; }
.maintenance-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.maintenance-card, .maintenance-panel, .maintenance-notice {
    border: 1px solid #415258;
    border-radius: 16px;
    background: rgba(23, 31, 35, .9);
    box-shadow: 0 20px 48px rgba(0, 0, 0, .2);
}
.maintenance-card {
    display: flex;
    min-height: 230px;
    flex-direction: column;
    padding: 26px;
    color: inherit;
    text-decoration: none;
}
.maintenance-card h2 { margin: 4px 0 8px; font-size: 1.35rem; }
.maintenance-card > p:not(.eyebrow) { color: #b6c1c5; }
.maintenance-card-action { margin-top: auto; color: #7fd7c5; font-weight: 800; }
.maintenance-panel { padding: clamp(22px, 4vw, 34px); }
.maintenance-panel h2 { margin-bottom: 20px; font-size: 1.25rem; }
.maintenance-notice { max-width: 640px; margin: 8vh auto 0; padding: 24px; }
.maintenance-notice h1 { font-size: 1.45rem; }
.maintenance-denied { border-color: #a65353; color: #ffd5d1; }
.maintenance-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0 0; }
.maintenance-facts div { padding: 12px; border-radius: 9px; background: rgba(10, 17, 20, .52); }
.maintenance-facts dt { color: #aab7bc; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.maintenance-facts dd { margin: 4px 0 0; color: #f5d675; font-size: 1.05rem; font-weight: 800; }
.maintenance-facts-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }
.maintenance-json { margin-top: 24px; }
.maintenance-json summary { color: #7fd7c5; font-weight: 800; }
.maintenance-json pre { max-height: 420px; margin: 14px 0 0; padding: 16px; overflow: auto; border: 1px solid #34434a; border-radius: 10px; background: #0e1518; color: #dce4e7; font-size: .78rem; line-height: 1.5; }
.maintenance-back-link { margin-top: 22px; }
.maintenance-success { border-color: #4f9d84; color: #d3f5e8; }
.maintenance-editor {
    display: grid;
    grid-template-columns: 190px minmax(360px, 1fr) 260px;
    overflow: hidden;
    border: 1px solid #415258;
    border-radius: 16px;
    background: rgba(23, 31, 35, .9);
    box-shadow: 0 20px 48px rgba(0, 0, 0, .2);
}
.maintenance-tile-list, .maintenance-feature-panel { padding: 18px; background: rgba(10, 17, 20, .36); }
.maintenance-tile-list { border-right: 1px solid #34434a; }
.maintenance-feature-panel { border-left: 1px solid #34434a; }
.maintenance-editor-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.maintenance-editor-heading h2 { margin: 0; font-size: 1rem; }
.maintenance-editor-heading span { color: #aab7bc; font-size: .72rem; }
.maintenance-tile-list-scroll { display: grid; gap: 6px; max-height: 650px; overflow: auto; padding-right: 4px; }
.maintenance-tile-choice, .maintenance-feature-choice, .maintenance-rotation-picker button {
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #dce4e7;
    font: inherit;
    text-align: left;
}
.maintenance-tile-choice { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; padding: 6px; }
.maintenance-tile-choice img { width: 34px; height: 34px; image-rendering: auto; }
.maintenance-tile-choice span { overflow: hidden; font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.maintenance-tile-choice small { color: #819198; font-size: .65rem; }
.maintenance-tile-choice.selected, .maintenance-feature-choice.selected, .maintenance-rotation-picker button.selected { border-color: #7fd7c5; background: rgba(127, 215, 197, .12); }
.maintenance-editor-workspace { min-width: 0; padding: clamp(18px, 3vw, 30px); }
.maintenance-review-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 18px; }
.maintenance-review-controls label { display: flex; align-items: center; gap: 8px; font-size: .84rem; }
.maintenance-review-controls label:first-child { min-width: 0; flex: 1 1 100%; flex-wrap: wrap; }
.maintenance-review-notice { max-width: none; margin: 18px 0; line-height: 1.6; }
.maintenance-editor-canvas.reviewing { cursor: default; touch-action: pan-y; }
.maintenance-review-controls select { padding: 8px; max-width: 100%; color: #edf5f5; background: #15272d; border: 1px solid #52656c; border-radius: 8px; }
.maintenance-tile-rotor > .maintenance-scoring-overlay { position: absolute; inset: 0; pointer-events: none; }
.maintenance-review-facts { margin-top: 16px; color: #c1ced2; font-size: .78rem; overflow-wrap: anywhere; }
.maintenance-review-facts p { margin: 8px 0; line-height: 1.6; }
.maintenance-review-facts h3 { font-size: .9rem; }
.maintenance-dirty-state { padding: 5px 8px; border: 1px solid #415258; border-radius: 999px; color: #aab7bc; font-size: .7rem; font-weight: 800; }
.maintenance-dirty-state.dirty { border-color: #f5d675; color: #f5d675; }
.maintenance-rotation-picker { display: flex; gap: 7px; margin: 18px 0; }
.maintenance-rotation-picker button { display: grid; grid-template-columns: 30px auto; align-items: center; gap: 5px; padding: 5px 7px; font-size: .7rem; }
.maintenance-rotation-picker img { width: 30px; height: 30px; transform: rotate(var(--tile-editor-rotation)); }
.maintenance-editor-canvas {
    position: relative;
    width: min(100%, 520px);
    aspect-ratio: 1;
    margin: 0 auto;
    overflow: hidden;
    touch-action: none;
    outline: none;
    border: 1px solid #52656c;
    border-radius: 12px;
    background-color: #10181b;
    background-image: linear-gradient(rgba(127, 215, 197, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(127, 215, 197, .06) 1px, transparent 1px);
    background-size: 10% 10%;
    cursor: crosshair;
}
.maintenance-editor-canvas:focus-visible { box-shadow: 0 0 0 3px rgba(127, 215, 197, .34); }
.maintenance-tile-rotor { position: absolute; inset: 0; transform: rotate(var(--tile-editor-rotation)); }
.maintenance-tile-rotor > img { display: block; width: 100%; height: 100%; user-select: none; }
.maintenance-anchor {
    position: absolute;
    z-index: 2;
    left: var(--anchor-x);
    top: var(--anchor-y);
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 2px dashed currentColor;
    border-radius: 999px;
    background: rgba(16, 24, 27, .28);
    color: #dce4e7;
    --control-cursor: grab;
    --control-hover-background: color-mix(in srgb, currentColor 42%, transparent);
    touch-action: none;
}
.maintenance-anchor.authored { border-style: solid; background: color-mix(in srgb, currentColor 42%, transparent); }
.maintenance-anchor.selected { z-index: 3; width: 28px; height: 28px; border-width: 3px; box-shadow: 0 0 0 3px rgba(238, 243, 245, .6); }
.maintenance-anchor:active { --control-cursor: grabbing; }
.terrain-road { color: #efbf63; }
.terrain-city { color: #e58378; }
.terrain-field { color: #83c981; }
.terrain-monastery { color: #8eb9e8; }
.terrain-garden { color: #c594df; }
.maintenance-editor-help { max-width: 520px; margin: 14px auto 0; color: #aab7bc; font-size: .76rem; line-height: 1.45; }
.maintenance-feature-list { display: grid; gap: 7px; }
.maintenance-feature-choice { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 9px; width: 100%; padding: 9px; }
.maintenance-feature-choice strong, .maintenance-feature-choice small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.maintenance-feature-choice strong { font-size: .76rem; }
.maintenance-feature-choice small { margin-top: 3px; color: #aab7bc; font-size: .66rem; }
.maintenance-feature-terrain { width: 10px; height: 10px; margin-top: 3px; border-radius: 999px; background: currentColor; }
.maintenance-feature-actions { display: grid; gap: 7px; margin-top: 16px; }
.maintenance-feature-actions .text-button { width: 100%; color: #b9e6db; font-size: .73rem; text-align: left; }
.danger-button { color: #f0aaa5 !important; }
.maintenance-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-top: 18px; }
.maintenance-editor-actions h2 { margin-bottom: 7px; }
.maintenance-editor-actions p { margin-bottom: 0; font-size: .82rem; }
.maintenance-action-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.maintenance-download { display: inline-flex; align-items: center; text-decoration: none; }
.maintenance-file-button { position: relative; display: inline-flex; align-items: center; }
.maintenance-file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }

@media (max-width: 1020px) {
    .maintenance-editor { grid-template-columns: 170px minmax(0, 1fr); }
    .maintenance-feature-panel { grid-column: 1 / -1; border-top: 1px solid #34434a; border-left: 0; }
    .maintenance-feature-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .maintenance-feature-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
    .maintenance-editor { display: block; }
    .maintenance-tile-list { border-right: 0; border-bottom: 1px solid #34434a; }
    .maintenance-tile-list-scroll { display: flex; max-height: none; overflow-x: auto; padding-bottom: 4px; }
    .maintenance-tile-choice { grid-template-columns: 32px; width: 68px; flex: 0 0 68px; justify-items: center; }
    .maintenance-tile-choice span, .maintenance-tile-choice small { display: none; }
    .maintenance-editor-workspace { padding: 18px; }
    .maintenance-rotation-picker { overflow-x: auto; }
    .maintenance-editor-actions { align-items: flex-start; flex-direction: column; }
    .maintenance-action-row { justify-content: flex-start; }
}

.game-page { max-width: 1500px; margin: 0 auto; }

.game-app-shell {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}
.game-app-main {
    height: 100%;
    padding: 0;
    overflow: hidden;
}
.game-app-shell .pwa-status-stack {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100;
}
.game-page {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    overflow: hidden;
}

.game-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.game-summary-actions { display: flex; align-items: center; gap: 14px; }

.connection-badge {
    padding: 8px 12px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.connection-badge.connected { color: #78dca5; }
.connection-badge.connecting, .connection-badge.reconnecting { color: #f5d675; }
.connection-badge.disconnected { color: #f08a83; }

.connection-retry, .pwa-status button {
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid currentColor;
    border-radius: 8px;
    background: transparent;
    color: #f5d675;
    font-weight: 800;
}

.pwa-status-stack {
    display: grid;
    gap: 1px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.pwa-status {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    min-height: 46px;
    padding: 7px max(24px, env(safe-area-inset-right)) 7px max(24px, env(safe-area-inset-left));
    border-bottom: 1px solid rgba(255, 255, 255, .16);
    background: #29383e;
    color: #eef3f5;
    font-size: .82rem;
}

.pwa-offline { background: #562d2d; }
.pwa-update { background: #334a43; }
.pwa-install { background: #293c44; }
.client-update-controls { margin: 18px 0; padding: 16px; border: 1px solid #415258; border-radius: 12px; background: rgba(23, 31, 35, .9); }
.client-update-controls h2 { margin-bottom: 12px; }
.client-update-controls p { margin-bottom: 10px; font-size: .82rem; overflow-wrap: anywhere; }
.client-update-controls code { color: #f5d675; }
.client-update-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.client-update-controls [role="alert"] { color: #ffd5d1; }

.error-card {
    display: grid;
    gap: 10px;
    border-color: #a65353;
    color: #ffd5d1;
}

.error-card button {
    width: fit-content;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    background: #f5d675;
    color: #182126;
    font-weight: 800;
    --control-hover-background: #ffe58c;
}

.board-stage, .held-tile-tray, .turn-actions-card {
    border: 1px solid #34464c;
    border-radius: 14px;
    background: rgba(20, 28, 32, .9);
}

.game-stage {
    position: absolute;
    inset: 0;
}

.board-stage {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
}
.board-stage-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.board-stage-heading .eyebrow { margin-bottom: 4px; }
.board-stage-heading h2 { font-size: 1.14rem; }
.board-stage-meta {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px 10px;
    max-width: 380px;
    color: #9eabb0;
    font-size: .72rem;
}
.board-stage-meta strong { color: #dce4e7; font-variant-numeric: tabular-nums; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-heading > span { color: #9eabb0; font-size: .78rem; }

.board-hud {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    max-width: min(68vw, calc(100% - 32px));
    overflow: hidden;
    pointer-events: none;
}

.game-utility-overlay {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
}
.game-utility-overlay > :is(.connection-badge, .game-tile-count, .game-exit-link, .field-ownership-toggle, .detail-toggle, .connection-retry) {
    box-sizing: border-box;
    display: inline-flex;
    width: 116px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    text-align: center;
}
.game-exit-link {
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #52656c;
    border-radius: 8px;
    background: rgba(13, 20, 23, .86);
    color: #dce4e7;
    font-size: .75rem;
    font-weight: 800;
    text-decoration: none;
}
.game-tile-count {
    border: 1px solid #52656c;
    border-radius: 8px;
    background: rgba(13, 20, 23, .86);
    color: #dce4e7;
    font-size: .85rem;
    font-weight: 800;
}
.field-ownership-toggle {
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid #52656c;
    border-radius: 8px;
    background: rgba(13, 20, 23, .86);
    color: #dce4e7;
    font-size: .75rem;
    font-weight: 800;
}
.field-ownership-toggle.active { border-color: #f5d675; background: rgba(245, 214, 117, .16); color: #fff2af; }
.game-utility-overlay .detail-toggle {
    min-height: 36px;
    padding: 8px 10px;
    border-color: #52656c;
    background: rgba(13, 20, 23, .86);
    font-size: .75rem;
}

/* The toolbar is an overlay; the viewport must fill the entire board rather
   than occupy an auto-sized grid row above an empty flexible row. */
.navigable-board { width: 100%; height: 100%; }

.board-toolbar {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.board-help { color: #9eabb0; font-size: .76rem; }
.board-control-group { display: flex; align-items: center; gap: 6px; }
.board-control-group button, .placement-control-group button {
    min-width: 38px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid #52656c;
    border-radius: 7px;
    background: #182328;
    color: #eef3f5;
    font-weight: 800;
}
.board-viewport:focus-visible {
    outline: 3px solid rgba(127, 215, 197, .68);
    outline-offset: 2px;
}
.board-zoom-output { min-width: 48px; color: #b8c5ca; font-size: .74rem; text-align: right; }
.placement-control-group { display: flex; align-items: center; gap: 7px; }
.placement-control-group > span {
    min-width: 42px;
    color: #f5d675;
    font-size: .78rem;
    font-weight: 800;
}
.placement-hint { color: #dce4e7; font-size: .72rem; font-weight: 700; }
.board-control-error {
    padding: 10px 12px;
    border: 1px solid #a65353;
    border-radius: 8px;
    background: rgba(76, 36, 36, .82);
    color: #ffd5d1;
    font-size: .8rem;
}
.board-control-error details { margin-top: 7px; }
.board-control-error summary { font-weight: 700; }
.board-control-error code { display: block; margin-top: 5px; overflow-wrap: anywhere; }

.board-viewport {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    overflow-anchor: none;
    border-radius: 10px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    background-color: #222e33;
}
.board-viewport.is-panning { cursor: grabbing; }

.board-surface {
    --tile-size: 92px;
    position: relative;
    width: calc(var(--board-columns) * var(--tile-size));
    height: calc(var(--board-rows) * var(--tile-size));
    transform-origin: 0 0;
    will-change: transform;
}

.board-surface::before {
    content: "";
    position: absolute;
    inset: calc(var(--tile-size) * -8);
    z-index: 0;
    background-image:
        linear-gradient(#405159 1px, transparent 1px),
        linear-gradient(90deg, #405159 1px, transparent 1px);
    background-position: 0 0;
    background-size: var(--tile-size) var(--tile-size);
    pointer-events: none;
}

.board-tile {
    position: absolute;
    z-index: 1;
    left: calc((var(--tile-x) - var(--minimum-x)) * var(--tile-size));
    top: calc((var(--tile-y) - var(--minimum-y)) * var(--tile-size));
    width: var(--tile-size);
    height: var(--tile-size);
}
.board-tile.has-feature-target { z-index: 4; }

.recent-tile-highlight {
    z-index: 3;
    pointer-events: none;
    border: 2px solid var(--player-color);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .65);
}
.recent-tile-highlight::after {
    content: "";
    position: absolute;
    inset: -2px;
    border: 2px solid var(--player-color);
    box-shadow: 0 0 7px 2px var(--player-color), inset 0 0 5px var(--player-color);
    opacity: .22;
    animation: recent-tile-glow 2.4s ease-in-out 2;
}
@keyframes recent-tile-glow {
    0%, 100% { opacity: .22; }
    50% { opacity: .65; }
}

.board-tile-image {
    display: block;
    width: 100%;
    height: 100%;
    transform: rotate(var(--tile-rotation));
    border: 1px solid rgba(0, 0, 0, .5);
    pointer-events: none;
}

.board-tile-ghost {
    z-index: 2;
    opacity: .7;
    pointer-events: none;
}
.board-tile-ghost .board-tile-image {
    border: 3px solid #f5d675;
    filter: saturate(.78) brightness(.92);
}

.tile-preview-actions { display: flex; gap: 8px; }
.tile-preview-actions .turn-action { flex: 1; }
.board-deployed-follower, .board-feature-target {
    position: absolute;
    z-index: 5;
    left: var(--feature-x);
    top: var(--feature-y);
    display: grid;
    place-items: center;
    width: calc(var(--tile-size) * .30);
    height: calc(var(--tile-size) * .30);
    margin: calc(var(--tile-size) * -.15);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--player-color);
    filter: drop-shadow(0 2px 2px rgb(0 0 0 / var(--meeple-shadow-opacity, .84)));
}
.board-deployed-follower .follower-token, .board-feature-target .follower-token {
    width: 66%;
    height: 88%;
    flex-basis: auto;
    transform: scale(calc(1.65 * var(--meeple-scale, 1)));
    transform-origin: center;
}
.board-feature-target {
    z-index: 7;
    width: calc(var(--tile-size) * .224);
    height: calc(var(--tile-size) * .224);
    margin: calc(var(--tile-size) * -.112);
    border: 2px solid #f5d675;
    border-radius: 50%;
    background: rgba(245, 214, 117, .11);
}
.board-feature-target, .board-withdrawable-abbot { --control-hover-background: rgba(127, 215, 197, .2); }
.board-withdrawable-abbot {
    z-index: 7;
    border: 2px solid #f5d675;
    border-radius: 50%;
    background: rgba(245, 214, 117, .11);
}
.board-deployed-follower.is-field .follower-token:not(.pig) { transform: rotate(90deg) scale(calc(1.65 * var(--meeple-scale, 1))); }
.board-deployed-follower .follower-token.large-meeple { transform: scale(calc(1.9 * var(--meeple-scale, 1))); }
.board-deployed-follower.is-field .follower-token.large-meeple { transform: rotate(90deg) scale(calc(1.9 * var(--meeple-scale, 1))); }
.board-deployed-follower.pending-turn { opacity: .56; }
.board-field-ownership {
    position: absolute;
    z-index: 3;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--field-ownership-fill);
    -webkit-mask-image: var(--field-ownership-mask);
    -webkit-mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-image: var(--field-ownership-mask);
    mask-size: 100% 100%;
    mask-repeat: no-repeat;
    opacity: var(--farm-overlay-opacity, .82);
    filter: brightness(var(--farm-colour-darkness, 1));
    pointer-events: none;
}

.legal-tile-target {
    position: absolute;
    z-index: 3;
    left: calc((var(--tile-x) - var(--minimum-x)) * var(--tile-size));
    top: calc((var(--tile-y) - var(--minimum-y)) * var(--tile-size));
    width: var(--tile-size);
    height: var(--tile-size);
    padding: 0;
    border: 3px solid #e2a93b;
    border-radius: 4px;
    background: rgba(95, 30, 34, .18);
    color: #fff;
    --control-hover-background: rgba(245, 214, 117, .1);
}
.legal-tile-target.selected {
    border-color: #f5d675;
    background: rgba(245, 214, 117, .1);
}
.legal-tile-target > .placement-coordinate {
    position: absolute;
    right: 5px;
    bottom: 5px;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(8, 12, 14, .8);
    font-size: 10px;
    font-weight: 800;
}

.board-coordinate {
    position: absolute;
    top: 4px;
    left: 5px;
    z-index: 1;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(8, 12, 14, .7);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.35;
    pointer-events: none;
}

.turn-dock {
    position: absolute;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 58px));
    z-index: 10;
    width: min(250px, calc(100vw - 32px));
}
.current-tile-overlay {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: max(16px, env(safe-area-inset-left));
    z-index: 10;
    width: min(160px, calc(100vw - 32px));
}
.held-tile-tray, .turn-actions-card { padding: 11px; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); }
.held-tile-tray img { display: block; width: min(100%, 150px); aspect-ratio: 1; margin: 0 auto 12px; }
.held-tile-tray strong, .held-tile-tray span { display: block; overflow-wrap: anywhere; }
.held-tile-tray span { margin-top: 4px; color: #aab7bc; font-size: .8rem; }

.player-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 8px;
    border-top: 1px solid #34464c;
}

.player-row.active { color: #f5d675; }

.command-error {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    padding: 13px 16px;
    border: 1px solid #a65353;
    border-radius: 10px;
    background: rgba(76, 36, 36, .86);
    color: #ffd5d1;
}
.command-error div { display: grid; gap: 3px; }
.command-error code { color: #f4a49e; font-size: .72rem; }
.command-error button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.4rem;
    line-height: 1;
}

.game-result-card {
    margin-bottom: 16px;
    padding: 20px 22px;
    border: 1px solid #d7ae42;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(85, 68, 25, .8), rgba(20, 28, 32, .94));
}
.game-result-card h2 { margin: 3px 0 6px; font-size: 1.45rem; }
.game-result-card p:last-child { margin-bottom: 0; }
.game-result-card strong { color: #f5d675; }

.game-activity {
    position: fixed;
    top: 78px;
    right: 24px;
    z-index: 20;
    max-width: min(430px, calc(100vw - 32px));
    padding: 13px 17px;
    border: 1px solid #7fd7c5;
    border-radius: 10px;
    background: rgba(16, 29, 32, .96);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .32);
    color: #f4f8f7;
    font-size: .86rem;
    font-weight: 800;
    animation: game-activity-feedback 4.6s ease forwards;
}

@keyframes game-activity-feedback {
    0% { opacity: 0; transform: translateY(-8px); }
    8%, 68% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); visibility: hidden; }
}

.turn-actions-card { display: grid; gap: 9px; }
.turn-actions-card .section-heading { margin-bottom: 2px; }
.turn-guidance { margin-bottom: 3px; color: #b8c5ca; font-size: .82rem; line-height: 1.45; }
.feature-action, .secondary-action {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #52656c;
    border-radius: 8px;
    background: #182328;
    color: #eef3f5;
    text-align: left;
}
.feature-action strong, .feature-action span { display: block; }
.feature-action span { margin-top: 2px; color: #aab7bc; font-size: .74rem; }
.abbot-action { border-color: #8b739e; }
.follower-picker { display: flex; flex-wrap: nowrap; gap: 6px; min-width: 0; max-width: 100%; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.turn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid #52656c;
    border-radius: 7px;
    background: #182328;
    color: #dce4e7;
    font-size: .74rem;
    font-weight: 800;
    cursor: pointer;
    --control-hover-background: #263c46;
}
.turn-action .follower-token { color: #f5d675; }
.turn-action.selected { border-color: #f5d675; background: rgba(245, 214, 117, .15); color: #fff2af; }
.secondary-action { text-align: center; font-weight: 800; }
.commit-turn-button { width: 100%; }
.turn-requirement {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.turn-requirement.required { background: rgba(245, 214, 117, .14); color: #f5d675; }
.turn-requirement.optional { background: rgba(127, 215, 197, .12); color: #7fd7c5; }
.turn-connection-note { margin: 2px 0 0; color: #f5d675; font-size: .76rem; line-height: 1.4; }

.player-scorecard {
    padding: 10px;
    border: 1px solid #34464c;
    border-left: 4px solid var(--player-color);
    border-radius: 9px;
    background: rgba(13, 20, 23, .72);
}
.player-scorecard.active {
    border: 2px solid var(--player-color);
    border-left-width: 4px;
}
.player-scorecard.winner { border-color: #d7ae42; }
.player-scorecard > header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
}
.player-colour-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--player-color);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .12);
}
.player-scorecard-name { min-width: 0; overflow-wrap: anywhere; font-weight: 800; }
.player-scorecard-name small { color: #aab7bc; font-weight: 500; }
.player-score { color: #f5d675; font-size: 1.15rem; }
.player-score small { color: #aab7bc; font-size: .62rem; text-transform: uppercase; }
.player-scorecard.compact {
    min-width: 112px;
    padding: 7px 8px;
    border-color: rgba(86, 108, 114, .78);
    border-left-width: 3px;
    border-radius: 8px;
    background: rgba(13, 20, 23, .84);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .24);
}
.player-scorecard.compact.active {
    border: 2px solid var(--player-color);
    border-left-width: 3px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .24);
}
.player-scorecard.compact > header {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 5px;
    margin: 0;
}
.player-scorecard.compact .player-colour-dot { width: 8px; height: 8px; }
.player-scorecard.compact .player-scorecard-name { font-size: .69rem; }
.player-scorecard.compact .player-scorecard-name small { display: none; }
.player-scorecard.compact .player-score { font-size: .92rem; }
.player-scorecard.compact .player-score small { display: none; }
.compact-follower-supplies { display: flex; gap: 7px; margin-top: 5px; }
.compact-follower-supply { display: inline-flex; align-items: center; gap: 2px; color: #dce4e7; font-size: .68rem; }
.compact-follower-supply .follower-token { flex-basis: 10px; width: 10px; height: 15px; transform: scale(.78); transform-origin: left center; margin-right: -2px; }
.follower-supply-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding-top: 7px;
    border-top: 1px solid #2c3a40;
    color: #dce4e7;
    font-size: .72rem;
}
.follower-supply-row + .follower-supply-row { margin-top: 7px; }
.follower-supply-row > span:first-child { display: grid; }
.follower-supply-row small { color: #93a2a8; font-size: .64rem; }
.follower-token-strip { display: flex; align-items: center; gap: 3px; min-height: 20px; }
.empty-supply { color: #77868c; font-size: .66rem; font-style: italic; }

.follower-token {
    display: block;
    flex: 0 0 13px;
    width: 13px;
    height: 19px;
    color: var(--player-color);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .75));
}
.follower-token > circle, .follower-token > path:not(.follower-token-mitre-seam) { fill: currentColor; }
.follower-token-mitre-seam { fill: none; stroke: rgba(255, 255, 255, .8); stroke-width: 4; stroke-linecap: round; }
.follower-token-large-badge { fill: #172329 !important; stroke: currentColor; stroke-width: 4; }
.follower-token-large-label { fill: none !important; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.player-online-indicator { display: block; width: 8px; height: 8px; border-radius: 2px; background: #61d985; box-shadow: 0 0 5px rgba(97, 217, 133, .5); }

.game-detail-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.detail-toggle, .drawer-close-button {
    min-height: 38px;
    border: 1px solid #465960;
    border-radius: 8px;
    background: rgba(20, 31, 35, .9);
    color: #dce4e7;
    font-weight: 800;
}
.detail-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
}
.detail-toggle strong {
    min-width: 20px;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(127, 215, 197, .13);
    color: #7fd7c5;
    font-size: .72rem;
    text-align: center;
}
.detail-toggle[aria-expanded="true"] {
    border-color: #7fd7c5;
    background: rgba(37, 67, 63, .84);
    color: #f4f8f7;
}
.game-detail-drawer {
    position: fixed;
    top: 82px;
    right: max(24px, env(safe-area-inset-right));
    z-index: 30;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(460px, calc(100vw - 48px));
    max-height: calc(100dvh - 106px);
    overflow: hidden;
    border: 1px solid #52656c;
    border-radius: 14px;
    background: rgba(20, 28, 32, .98);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .42);
}
.game-detail-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 15px 16px 13px;
    border-bottom: 1px solid #34464c;
}
.game-detail-drawer-header .eyebrow { margin-bottom: 3px; }
.game-detail-drawer-header h2 { font-size: 1.1rem; }
.drawer-close-button { padding: 7px 10px; }
.game-detail-drawer-content { min-height: 0; overflow: auto; padding: 12px; }
.appearance-settings { display: grid; gap: 15px; }
.appearance-settings > label { display: grid; gap: 7px; color: #dce4e7; font-size: .82rem; font-weight: 750; }
.appearance-settings > label > span { display: flex; justify-content: space-between; gap: 12px; }
.appearance-settings output { color: #f5d675; font-variant-numeric: tabular-nums; }
.appearance-settings input[type="range"] { width: 100%; accent-color: #7fd7c5; }
.appearance-settings .appearance-settings-toggle { display: flex; align-items: center; gap: 9px; }
.appearance-settings .appearance-settings-toggle input { width: 1rem; height: 1rem; margin: 0; accent-color: #7fd7c5; }
.player-details-card { display: grid; gap: 8px; }
.deployed-followers-card, .history-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid #34464c;
    border-radius: 14px;
    background: rgba(20, 28, 32, .9);
}
.deployed-follower-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.deployed-follower-list li {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-left: 3px solid var(--player-color);
    border-radius: 7px;
    background: rgba(11, 17, 20, .7);
}
.deployed-follower-list .follower-token { transform: scale(1.12); }
.deployed-follower-list li > span:last-child { display: grid; }
.deployed-follower-list small { color: #9eabb0; line-height: 1.4; }

.history-card { max-height: none; }
.history-error { color: #f4a49e; }
.turn-history-list { display: grid; gap: 10px; }
.turn-history {
    overflow: hidden;
    border: 1px solid #34464c;
    border-left: 4px solid var(--player-color);
    border-radius: 9px;
    background: rgba(11, 17, 20, .7);
}
.turn-history > header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #2d3b40;
    color: #dce4e7;
    font-size: .78rem;
}
.turn-history > ol { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.turn-history > ol > li { padding: 8px 10px; }
.turn-history > ol > li + li { border-top: 1px solid #26343a; }
.history-action-line { display: flex; justify-content: space-between; gap: 12px; font-size: .78rem; }
.history-action-line time { flex: 0 0 auto; color: #819198; font-size: .65rem; font-variant-numeric: tabular-nums; }
.history-outcomes { display: grid; gap: 3px; margin: 6px 0 0; padding: 0; list-style: none; font-size: .7rem; }
.score-outcome { color: #f5d675; }
.return-outcome { color: #7fd7c5; }

.boot-screen {
    min-height: 100vh;
    display: grid;
    place-content: center;
    gap: 8px;
    text-align: center;
}

.boot-screen strong { color: #f5d675; font-size: 2rem; }
.boot-screen span { color: #aab7bc; }

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 16px 16px 16px;
    z-index: 1000;
    padding: 14px 18px;
    border: 1px solid #a65353;
    border-radius: 10px;
    background: #4c2424;
}

#blazor-error-ui .dismiss { float: right; margin-left: 16px; }

@media (max-width: 900px) {
    main {
        padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }
    .game-stage { grid-template-columns: 1fr; }
    .turn-dock { grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr); }
    .board-viewport { min-height: clamp(400px, 62vh, 680px); }
    .board-hud {
        position: static;
        z-index: auto;
        flex-wrap: wrap;
        justify-content: flex-start;
        max-width: none;
        margin: 0 0 10px;
        overflow: visible;
        pointer-events: auto;
    }
    .tables-scroll { overflow-x: visible; }
    .your-tables-table { min-width: 0; table-layout: fixed; }
    .your-tables-table th, .your-tables-table td { padding: 10px 8px; overflow-wrap: anywhere; }
    .your-tables-table th { font-size: .63rem; letter-spacing: .035em; }
    .your-tables-table td { font-size: .76rem; }
    .your-tables-table th:nth-child(1), .your-tables-table td:nth-child(1) { width: 18%; }
    .your-tables-table th:nth-child(2), .your-tables-table td:nth-child(2) { width: 9%; text-align: center; }
    .your-tables-table th:nth-child(3), .your-tables-table td:nth-child(3) { width: 19%; }
    .your-tables-table th:nth-child(4), .your-tables-table td:nth-child(4) { width: 25%; }
    .your-tables-table th:nth-child(5), .your-tables-table td:nth-child(5) { width: 11%; text-align: center; }
    .your-tables-table th:nth-child(6), .your-tables-table td:nth-child(6) { width: 18%; }
    .your-tables-table td:last-child { white-space: normal; }
    .your-tables-table time { white-space: normal; }
    .table-time-full, .table-action-full { display: none; }
    .table-time-compact, .table-action-compact { display: inline; }
    .your-tables-table .primary-button { min-height: 36px; padding: 7px 8px; font-size: .72rem; }
}

@media (max-width: 900px) and (min-width: 640px) and (orientation: landscape) {
    .game-stage { grid-template-columns: minmax(0, 1fr) minmax(240px, 290px); }
    .turn-dock { grid-template-columns: 1fr; }
    .board-viewport { min-height: clamp(260px, calc(100dvh - 210px), 480px); }
    .board-stage-heading { margin-bottom: 8px; }
    .board-hud { margin-bottom: 7px; }
    .player-scorecard.compact { min-width: 96px; }
}

@media (max-width: 560px) {
    .app-header {
        min-height: 54px;
        padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    }
    .prototype-label { display: none; }
    .maintenance-header { min-height: 54px; padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
    .maintenance-main { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
    .maintenance-facts-wide { grid-template-columns: 1fr; }
    .game-summary { align-items: center; }
    .game-summary-actions { align-items: flex-end; flex-direction: column-reverse; }
    .pwa-status { justify-content: space-between; padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
    .entry-intro { margin-top: 2vh; text-align: left; }
    .entry-grid { grid-template-columns: 1fr; }
    .resume-card { align-items: flex-start; flex-direction: column; }
    .resume-card .entry-actions { width: 100%; }
    .resume-card .primary-button { flex: 1; }
    .board-stage { padding: 13px; }
    .board-stage-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
    .board-stage-meta { justify-content: flex-start; }
    .board-hud { gap: 5px; margin-bottom: 8px; }
    .player-scorecard.compact { min-width: 92px; padding: 6px 7px; }
    .player-scorecard.compact .player-scorecard-name { max-width: 44px; font-size: .62rem; }
    .turn-dock { grid-template-columns: 1fr; }
    .held-tile-tray { display: grid; grid-template-columns: minmax(90px, 130px) minmax(0, 1fr); column-gap: 14px; align-items: center; }
    .held-tile-tray .section-heading { grid-column: 1 / -1; }
    .held-tile-tray img { width: 100%; margin: 0; }
    .held-tile-tray strong, .held-tile-tray span { grid-column: 2; }
    .game-activity { top: 64px; right: 16px; }
    .board-toolbar { align-items: flex-end; flex-wrap: wrap; }
    .board-help { max-width: 130px; }
    .placement-control-group { width: 100%; }
    .board-control-group { margin-left: auto; }
    .board-control-group button, .placement-control-group button { min-width: 44px; min-height: 44px; }
    .board-surface { --tile-size: 76px; }
    .board-viewport { min-height: min(58dvh, 560px); }
    .game-detail-controls { gap: 6px; }
    .detail-toggle { flex: 1 1 0; justify-content: center; min-width: 0; padding: 7px 8px; font-size: .76rem; }
    .game-detail-drawer {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-height: min(74dvh, 680px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 18px 18px 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .game-detail-drawer-content { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .your-tables-table th, .your-tables-table td { padding: 8px 5px; }
    .your-tables-table td { font-size: .68rem; }
    .your-tables-table .primary-button { min-height: 34px; padding: 6px; font-size: .66rem; }
}

@media (max-width: 720px) {
    .notification-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .notification-actions button {
        min-width: 0;
        min-height: 44px;
        padding: 8px;
        line-height: 1.15;
    }
    .notification-actions button:first-child,
    .notification-actions button:last-child { grid-column: 1 / -1; }

    .tables-scroll { display: none; }
    .your-tables-mobile-list { display: grid; gap: 10px; margin-top: 18px; }
    .table-summary {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        gap: 5px 12px;
        padding: 13px;
        border: 1px solid rgba(121, 147, 155, .28);
        border-radius: 10px;
        background: rgba(11, 17, 20, .22);
    }
    .table-summary-title { display: grid; gap: 2px; min-width: 0; }
    .table-summary-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .table-summary-title span { color: #aab7bc; font-size: .76rem; }
    .table-summary-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 2px 8px;
        margin: 0;
        color: #b6c1c5;
        font-size: .72rem;
    }
    .table-summary-meta span + span::before { content: "· "; color: #718187; }
    .table-summary .primary-button {
        grid-column: 2;
        grid-row: 1 / -1;
        align-self: center;
        min-height: 44px;
        padding: 8px 10px;
        font-size: .76rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
    .game-activity { position: static; max-width: none; margin-bottom: 16px; }
}

/* Immersive game route: these follow the legacy responsive rules above so
   active games remain a single fixed board workspace at every viewport size. */
.game-page .game-stage { position: absolute; inset: 0; }
.game-page .board-stage { width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; }
.game-page .navigable-board { width: 100%; height: 100%; }
.game-page .board-viewport { min-height: 0; height: 100%; }
.game-page .game-detail-controls {
    position: absolute;
    bottom: max(174px, calc(env(safe-area-inset-bottom) + 158px));
    left: max(16px, env(safe-area-inset-left));
    z-index: 10;
    margin: 0;
}
.game-page .game-result-card {
    position: absolute;
    top: max(84px, calc(env(safe-area-inset-top) + 68px));
    left: 50%;
    z-index: 20;
    width: min(480px, calc(100vw - 32px));
    margin: 0;
    transform: translateX(-50%);
}
.game-page > .loading-card, .game-page > .error-card {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-content: center;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
}

@media (max-width: 900px) {
    .game-page .board-hud {
        position: absolute;
        top: max(12px, env(safe-area-inset-top));
        left: max(12px, env(safe-area-inset-left));
        max-width: calc(100vw - 24px);
        margin: 0;
    }
    .game-page .turn-dock {
        right: max(12px, env(safe-area-inset-right));
        bottom: max(68px, calc(env(safe-area-inset-bottom) + 52px));
        width: min(240px, calc(100vw - 24px));
    }
    .game-page .current-tile-overlay { bottom: max(12px, env(safe-area-inset-bottom)); left: max(12px, env(safe-area-inset-left)); }
}

@media (max-width: 560px) {
    .game-page .game-utility-overlay { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
    .game-page .connection-badge { min-height: 32px; padding: 6px 8px; font-size: .62rem; }
    .game-page .game-tile-count { min-height: 32px; padding: 6px 8px; }
    .game-page .game-exit-link { min-height: 32px; padding: 7px 8px; font-size: .67rem; }
    .game-page .field-ownership-toggle { min-height: 32px; padding: 7px 8px; font-size: .67rem; }
    .game-page .board-hud { top: max(52px, calc(env(safe-area-inset-top) + 42px)); gap: 4px; max-width: calc(100vw - 24px); }
    .game-page .player-scorecard.compact { min-width: 78px; padding: 5px 6px; }
    .game-page .player-scorecard.compact .player-scorecard-name { max-width: 36px; }
    .game-page .turn-dock {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(62px, calc(env(safe-area-inset-bottom) + 48px));
        width: min(188px, calc(100vw - 20px));
    }
    .game-page .current-tile-overlay { bottom: max(10px, env(safe-area-inset-bottom)); left: max(10px, env(safe-area-inset-left)); width: 116px; }
    .game-page .held-tile-tray { display: grid; grid-template-columns: 1fr; gap: 6px; align-items: start; }
    .game-page .held-tile-tray .section-heading { display: block; margin: 0; }
    .game-page .held-tile-tray .section-heading h2 { font-size: .72rem; white-space: nowrap; }
    .game-page .held-tile-tray img { width: 72px; margin: 0 auto; }
    .game-page .held-tile-tray strong, .game-page .held-tile-tray span { display: none; }
    .game-page .turn-actions-card { gap: 6px; }
    .game-page .turn-actions-card .section-heading h2 { font-size: .8rem; }
    .game-page .turn-guidance { font-size: .7rem; }
    .game-page .game-detail-controls { bottom: max(116px, calc(env(safe-area-inset-bottom) + 104px)); left: max(10px, env(safe-area-inset-left)); }
    .game-page .detail-toggle { min-height: 34px; padding: 6px 7px; }
    .game-page .board-toolbar { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
    .game-page .board-toolbar .board-help { display: none; }
    .game-page .placement-control-group { width: auto; }
    .game-page .placement-hint { display: none; }
}

/* The fixed left rail keeps colours and scores in place when scorecards minimise. */
.game-page .board-hud {
    z-index: 10;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 216px;
    max-height: calc(100dvh - 220px);
    overflow: visible;
    pointer-events: auto;
}
.game-page .board-hud.is-collapsed { width: 92px; }
.board-scorecards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    overflow: auto;
}
.game-page .player-scorecard.compact {
    position: relative;
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 216px;
    min-width: 216px;
    height: 84px;
    padding: 8px;
    cursor: pointer;
}
.game-page .player-scorecard.compact:hover { background: rgba(31, 49, 55, .94); }
.game-page .player-scorecard.compact:focus-visible { outline: 2px solid #8fc9f0; outline-offset: 2px; }
.game-page .player-scorecard.compact > header { display: contents; }
.game-page .player-scorecard.compact .player-colour-dot {
    position: absolute;
    top: 10px;
    left: 8px;
    width: 12px;
    height: 12px;
}
.game-page .player-scorecard.compact .player-scorecard-metrics {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    height: 30px;
    gap: 5px;
}
.game-page .player-scorecard.compact .player-score {
    font-variant-numeric: tabular-nums;
}
.game-page .player-scorecard.compact .player-online-indicator {
    position: absolute;
    top: 10px;
    right: 8px;
}
.game-page .player-scorecard.compact .player-scorecard-name {
    position: absolute;
    top: 8px;
    left: 48px;
    right: 8px;
    max-width: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .75rem;
}
.game-page .compact-follower-supplies {
    position: absolute;
    bottom: 8px;
    left: 48px;
    right: 8px;
    gap: 14px;
    margin-top: 0;
    height: 30px;
    align-items: center;
}
.game-page .player-scorecard.compact.minimized { width: 92px; min-width: 92px; }
.game-page .player-scorecard.minimized .player-scorecard-name,
.game-page .player-scorecard.minimized .compact-follower-supplies { display: none; }
.game-page .player-scorecard.minimized .player-scorecard-metrics { right: 8px; justify-content: space-between; }
.game-page .player-meeple-total { display: inline-flex; align-items: center; gap: 3px; color: #dce4e7; font-size: .84rem; font-variant-numeric: tabular-nums; }
.game-page .player-meeple-total .follower-token { width: 26px; height: 30px; flex-basis: 26px; }
.game-page .compact-follower-supply { gap: 6px; font-size: .8rem; }
.game-page .compact-follower-supply .follower-token {
    flex-basis: 26px;
    width: 26px;
    height: 30px;
    transform: none;
    margin-right: 0;
}
.game-page .held-tile-tray img { margin-bottom: 0; }
.legal-tile-target > .tile-rotation-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: transparent;
    color: white;
    font-family: sans-serif;
    font-size: calc(var(--tile-size) * .65);
    line-height: 1;
    opacity: .4;
    text-shadow: 0 1px 4px #000;
    pointer-events: none;
}
.game-menu-dialog {
    box-sizing: border-box;
    position: fixed;
    inset: 0;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid #52656c;
    border-radius: 14px;
    background: #141c20;
    color: #eef3f5;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .42);
}
.game-menu-dialog::backdrop {
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.game-menu-dialog h2:focus { outline: none; }
.game-menu-dialog:has(.scoring-breakdown) { width: min(860px, calc(100vw - 24px)); }
.scoring-replay-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 16px 0; }
.scoring-replay-controls label { display: grid; gap: 5px; font-size: .8rem; }
.scoring-replay-controls select { min-height: 44px; padding: 8px; border: 1px solid #52656c; border-radius: 7px; background: #182328; color: #eef3f5; }
.scoring-breakdown h3 { margin: 0 0 8px; }
.scoring-replay-status { border: 1px solid #52656c; border-radius: 8px; padding: 12px; margin-bottom: 16px; background: #182328; }
.scoring-replay-status p { margin: 8px 0 0; }
.scoring-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.scoring-table th, .scoring-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid #34464c; }
.scoring-table th { color: #aab7bc; }
.scoring-summary { table-layout: fixed; }
.scoring-summary th, .scoring-summary td { padding: 12px 5px; text-align: center; font-variant-numeric: tabular-nums; }
.scoring-summary th:first-child { width: 24%; text-align: left; overflow-wrap: anywhere; }
.scoring-summary tbody th .player-colour-dot { display: inline-block; margin-right: 6px; }
.scoring-summary .scoring-total { color: #f5d675; font-weight: 800; }
@media (max-width: 480px) {
    .game-menu-dialog:has(.scoring-breakdown) .game-detail-drawer-content { padding: 12px 6px; }
    .scoring-summary { font-size: .68rem; }
    .scoring-summary th, .scoring-summary td { padding: 10px 2px; }
    .scoring-summary tbody th .player-colour-dot { width: 7px; height: 7px; margin-right: 3px; }
}
.scoring-table .current-scoring-feature { background: rgba(245, 214, 117, .15); }
.game-menu-items { display: grid; gap: 10px; }
.game-menu-items > :is(a, button) {
    padding: 14px;
    border: 1px solid #34464c;
    border-radius: 8px;
    background: #1b282e;
    color: #eef3f5;
    font-size: .95rem;
    text-align: left;
    text-decoration: none;
}
.game-menu-items strong { float: right; }
.maintenance-panel { margin-top: 24px; }
.maintenance-table-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.maintenance-table-controls label, .maintenance-pan-setting { display: grid; gap: 7px; }
.maintenance-table-controls label:first-child { flex: 1 1 280px; }
.maintenance-table-controls :is(input, select) {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid #52656c;
    border-radius: 8px;
    background: #0e1518;
    color: #eef3f5;
    font: inherit;
}
.maintenance-table-controls button, .maintenance-pagination button, .maintenance-save-navigation {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #52656c;
    border-radius: 8px;
    background: #24343a;
    color: #eef3f5;
    font: inherit;
}
.maintenance-table-scroll { overflow: auto; }
.maintenance-player-table { width: 100%; border-collapse: collapse; text-align: left; }
.maintenance-player-table :is(th, td) { padding: 12px; border-bottom: 1px solid #34464c; }
.maintenance-player-table th { white-space: nowrap; }
.maintenance-player-table td small { display: block; margin-top: 4px; color: #aab7bc; white-space: nowrap; }
.maintenance-player-table code { font-size: .75rem; }
.maintenance-lobby-table { table-layout: fixed; min-width: 950px; }
.maintenance-lobby-table td { overflow-wrap: anywhere; }
.maintenance-lobby-table th { white-space: normal; }
.game-page.cancelled .game-result-card { background: #142025; }
.game-page.cancelled :is(.held-tile-tray, .turn-dock) { display: none; }
.maintenance-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.maintenance-pan-setting { max-width: 480px; margin: 18px 0; }
@media (max-width: 560px) {
    .game-page .board-hud { width: 216px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 240px); }
}
@media (max-width: 380px) {
    .game-page .board-hud {
        top: max(173px, calc(env(safe-area-inset-top) + 163px));
        max-height: calc(100dvh - 359px);
    }
}

/* Compact home menus and bounded table lists. */
.home-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}
.home-navigation button { min-height: 44px; }
.home-navigation button[aria-pressed="true"] {
    background: #f5d675;
    color: #182126;
}
.home-navigation .primary-button { margin-left: auto; }
.home-page > .entry-card { padding: clamp(16px, 3vw, 26px); }
.home-page h1 { font-size: clamp(1.35rem, 4vw, 1.9rem); }
.home-page .tables-scroll { margin-top: 12px; overflow-x: visible; }
.home-page .your-tables-table { min-width: 0; table-layout: fixed; }
.home-page .your-tables-table th,
.home-page .your-tables-table td { padding: 10px; overflow-wrap: anywhere; }
.home-page .your-tables-table time { white-space: normal; }
.home-page .your-tables-table td:last-child { width: auto; white-space: normal; }
.home-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
.home-pagination button { min-height: 44px; }
.home-page code { overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .home-navigation { gap: 4px; margin-bottom: 12px; }
    .home-navigation button { flex: 1 0 auto; padding: 8px; font-size: .8rem; }
    .home-navigation .primary-button { margin-left: 0; }
    .home-page .your-tables-mobile-list { margin-top: 12px; gap: 8px; }
    .home-page .table-summary { padding: 10px; }
    .home-page .table-summary-meta { grid-column: 1; }
    .home-page .account-card { flex-wrap: wrap; }
}

/* Shared home/in-game appearance editor and live board sample. */
.home-game-settings { margin: 0 0 16px; min-height: 44px; }
.home-appearance-dialog,
.game-menu-dialog:has(.appearance-editor) { width: min(860px, calc(100vw - 24px)); }
.appearance-editor { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 24px; align-items: start; }
.appearance-preview { margin: 0; display: grid; gap: 14px; justify-items: center; }
.appearance-preview figcaption { font-weight: 800; }
.appearance-preview p { font-size: .82rem; line-height: 1.5; }
.appearance-preview-tile { position: relative; width: 224px; height: 224px; --tile-size:224px; }
.appearance-editor .appearance-settings-toggle input { min-height: 0; }

.friends-list-table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; }
.friends-list-table th, .friends-list-table td { padding: 10px 8px; border-bottom: 1px solid #415258; overflow-wrap: anywhere; }
.friends-list-table th { color: #aab7bc; font-size: .8rem; }
.friends-list-table td:last-child { font-variant-numeric: tabular-nums; }
.friend-name-link { padding: 6px 0; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; text-align: left; overflow-wrap: anywhere; }
.friend-online { color: #61d985; font-weight: 700; }
.friends-list-note { margin: 12px 0 0; font-size: .78rem; }

.goods-inventory-table { width: 100%; margin-top: 18px; table-layout: fixed; }
.goods-inventory-table caption { text-align: left; font-weight: 800; padding: 8px 0; }
.goods-inventory-table th, .goods-inventory-table td { overflow-wrap: anywhere; }
}

.table-setup-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.table-player-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.table-player-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #40545c; }
.table-player-list strong { overflow-wrap: anywhere; }
.lobby-player-row { flex-wrap: wrap; align-items: center; margin: 12px 0; }
.entry-card .expansion-option { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.entry-card .expansion-option input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; padding: 0; flex: 0 0 18px; accent-color: #7fd7c5; }
.friends-picker-dialog { width: min(520px, calc(100vw - 32px)); }
@media (max-width: 600px) { .table-setup-columns { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

.follower-token > path.follower-token-detail {
    fill: none;
    stroke: #172329;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.follower-picker .turn-action .follower-token { color: var(--player-color); }
.builder-turn-notice {
    margin: 6px 0;
    padding: 8px;
    border: 1px solid #d7ae42;
    color: #f5dfa2;
    font-size: .8rem;
    overflow-wrap: anywhere;
}
.scorecard-goods {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 8px;
    font-size: .7rem;
    color: #dce4e7;
    font-variant-numeric: tabular-nums;
}
.game-page .player-scorecard.compact.has-trade-goods:not(.minimized) { height: 128px; }
.game-page .player-scorecard.has-trade-goods .compact-follower-supplies {
    top: 36px;
    bottom: auto;
    height: auto;
    flex-wrap: wrap;
    gap: 4px 8px;
}
.game-page .player-scorecard.has-trade-goods .compact-follower-supply { gap: 3px; }
.game-page .player-scorecard.has-trade-goods .compact-follower-supply .follower-token {
    flex-basis: 20px;
    width: 20px;
    height: 24px;
}
.game-page .player-scorecard.compact .scorecard-goods {
    position: absolute;
    bottom: 8px;
    left: 48px;
    right: 8px;
    margin: 0;
    font-size: .68rem;
}
.game-page .player-scorecard.minimized .scorecard-goods { display: none; }

.game-page .turn-actions-card {
    max-height: calc(100dvh - 160px);
    overflow-y: auto;
}

.scorecard-good { display: inline-flex; align-items: center; gap: 3px; }
.scorecard-good img { width: 24px; height: 24px; flex: 0 0 24px; image-rendering: auto; }
.follower-picker .follower-choice {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 6px;
    border-radius: 4px;
}
.follower-picker .follower-choice .follower-token { flex-basis: 28px; width: 28px; height: 30px; }
