:root {
    color-scheme: dark;
    --bg: #081424;
    --panel: #101f34;
    --panel-border: #263c53;
    --text: #eaf0f6;
    --muted: #a6b8ca;
    --cyan: #70d8ef;
    --gold: #f8cb76;
    --radius: 16px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; color: var(--text); background: radial-gradient(ellipse at top right, #123151, var(--bg) 58%) fixed; }
a { color: var(--cyan); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.site-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--panel-border); background: #07121fdd; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 850; letter-spacing: .13em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--gold); border-radius: 10px; color: var(--gold); font-size: 1.5rem; font-family: Georgia, serif; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .63rem; font-weight: 500; letter-spacing: .01em; }
.version { border: 1px solid var(--panel-border); padding: 7px 9px; border-radius: 100px; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.content { width: min(100%, 1240px); margin-inline: auto; padding: 20px 14px 52px; flex: 1; }
.intro { margin-bottom: 20px; }
.eyebrow, .panel-kicker { color: var(--cyan); font-size: .72rem; font-weight: 760; letter-spacing: .13em; margin: 0 0 8px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 7.5vw, 3.5rem); line-height: 1.08; letter-spacing: -.045em; }
.intro > p:last-child { color: var(--muted); line-height: 1.65; max-width: 760px; margin-bottom: 0; }
h2 { font-size: 1.2rem; margin-bottom: 0; }
.notice { color: #cdd9e5; background: #14273c; border-left: 3px solid var(--gold); border-radius: 8px; padding: 12px 14px; line-height: 1.5; margin-bottom: 18px; font-size: .88rem; }
.notice strong { color: var(--gold); }
.dashboard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.panel, .info-card { min-width: 0; background: #101e31ed; border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: 0 8px 26px #01071050; }
.panel { padding: 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.panel-header h2 { margin: 0; }
.metric { padding: 7px 10px; border: 1px solid var(--panel-border); border-radius: 9px; color: var(--gold); font-family: ui-monospace, "Cascadia Code", monospace; white-space: nowrap; }
.map-scroll { overflow: auto; max-height: min(65vh, 680px); padding-bottom: 5px; overscroll-behavior: contain; }
.map-heading-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.map-recenter { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--panel-border); background: #19334c; color: var(--text); font-size: .82rem; }
.map-recenter:disabled { opacity: .55; cursor: not-allowed; }
.hex-map { width: max-content; padding: 6px 28px 12px 6px; }
.hex-map-row { display: flex; width: max-content; gap: 0; }
.hex-map-row:nth-child(even) { margin-left: 21px; }
.hex-map-row + .hex-map-row { margin-top: -12px; }
.map-cell { display: grid; place-items: center; border: 1px solid transparent; width: 42px; height: 48px; flex: 0 0 42px; padding: 0; color: #e6f6fc; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); font-family: ui-monospace, Consolas, monospace; font-size: 1rem; font-weight: 700; touch-action: manipulation; }
.map-cell:hover, .map-cell:focus-visible { border-color: #f6db9c; filter: brightness(1.3); }
.map-cell.water { background: var(--empire-water, #163b59); color: var(--empire-water-text, #fff); }
.map-cell.land { background: var(--empire-land, #285e53); color: var(--empire-land-text, #fff); }
.map-cell.mountain { background: var(--empire-mountain, #686b76); color: var(--empire-mountain-text, #fff); }
.map-cell.owned { background: var(--empire-owned, #73512e); color: var(--empire-owned-text, #fff); }
/* Selected commodity: highlight only the outgoing edge(s) of owned source hexes. */
.map-top-controls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin: 12px 0 8px; }
.map-route-controls { flex: 1 1 320px; min-width: 0; }
.map-route-highlights { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 4px; }
.map-route-highlights label { font-size: .83rem; font-weight: 700; color: #c5dbea; }
.map-route-highlights select { min-height: 44px; padding: 7px 10px; border-radius: 8px; border: 1px solid #587998; background: #10273e; color: #f4fbff; font: inherit; }
.map-route-highlights select:focus-visible { outline: 2px solid #ffe09a; outline-offset: 2px; }
.map-route-picker { display: inline-flex; align-items: center; gap: 12px; min-width: 0; max-width: 100%; }
.map-route-picker select { min-width: 0; }
.map-route-highlight-key { display: inline-flex; align-items: center; gap: 7px; color: #cbe6e2; font-size: .8rem; }
.map-route-highlight-key span { width: 21px; border-top: 5px solid var(--empire-route, #56e0e0); border-radius: 4px; box-shadow: 0 0 6px #5bffe58c; }
.map-legend { display: flex; gap: 10px 16px; flex-wrap: wrap; margin: 8px 0; font-size: .81rem; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.legend-swatch.water { background: var(--empire-water, #163b59); }
.legend-swatch.land { background: var(--empire-land, #285e53); }
.legend-swatch.mountain { background: var(--empire-mountain, #686b76); }
.legend-swatch.owned { background: var(--empire-owned, #73512e); }
.legend-swatch.unknown { background: var(--empire-unknown, #081424); color: #0b1422; border-color: #1b2939; }
.legend-swatch.selected-ring { border: 2px solid var(--empire-selected, #ffe09a); }
.legend-swatch.source-fill { background: var(--empire-source, #e69f00); }
.legend-swatch.destination-fill { background: var(--empire-destination, #0072b2); }
.legend-swatch.route-ring { background: var(--empire-route, #56e0e0); height: 4px; }
.map-cell { position: relative; }
.map-cell-symbol { grid-area: 1 / 1; position: relative; z-index: 1; pointer-events: none; }
.map-cell-pending { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); z-index: 2; pointer-events: none; font-size: .56rem; font-weight: 800; line-height: 1; padding: 1px 3px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: var(--gold); }
.map-cell.has-pending-designation { border-color: #e59b26; border-style: dashed; }
.map-cell.has-pending-designation .map-cell-symbol { transform: translateY(4px); }
.map-cell.has-pending-designation.is-source .map-cell-symbol, .map-cell.has-pending-designation.is-destination .map-cell-symbol { transform: translateY(0); }
.map-route-edge-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.map-route-edge { fill: none; stroke: var(--empire-route, #56e0e0); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 2px #0a3030); }
.hint, .muted { font-size: .83rem; line-height: 1.5; color: var(--muted); }
.hint { margin: 13px 0 0; }
.online-status { color: #a6e7c4; font-size: .76rem; border: 1px solid #2c7356; padding: 6px 8px; border-radius: 100px; white-space: nowrap; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.quick-actions button { border: 1px solid #34536e; background: #162f4a; color: #d3ecfb; border-radius: 9px; min-height: 44px; padding: 7px 8px; font-weight: 650; }
.quick-actions button:hover { background: #214566; }
.console-output { height: 270px; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; padding: 13px; border: 1px solid #2c465e; border-radius: 10px; background: #060f1b; color: #d0eac9; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .81rem; line-height: 1.7; }
.console-line { min-height: 1.3em; }
.console-line:first-child { color: var(--gold); font-weight: bold; }
.command-form { padding-top: 14px; }
.command-form label { display: block; margin-bottom: 8px; color: #cfdceb; font-size: .85rem; font-weight: 650; }
.command-input-row { display: flex; align-items: center; gap: 9px; border: 1px solid #47617c; border-radius: 10px; background: #0a1625; padding: 5px 5px 5px 11px; }
.command-input-row > span { color: var(--cyan); font-family: monospace; }
.command-input-row input { min-width: 0; width: 100%; flex: 1; background: transparent; color: white; border: 0; height: 37px; outline: none; }
.command-input-row:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.command-input-row input:focus-visible { outline: none; }
.command-input-row input::placeholder { color: #849aaf; }
.command-input-row button { min-height: 44px; padding: 9px 15px; border: 0; border-radius: 7px; background: var(--gold); color: #211c16; font-weight: 800; }
.below-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.info-card { padding: 18px; }
.info-card h2 { margin-bottom: 10px; }
.info-card p:not(.panel-kicker) { color: var(--muted); line-height: 1.5; font-size: .92rem; }
.info-card code { display: block; width: fit-content; max-width: 100%; overflow-x: auto; margin: 8px 0 12px; padding: 10px 12px; border: 1px solid #335370; border-radius: 9px; background: #081525; color: #ddedbb; font-size: .9rem; }
.footer { color: #8ea4bc; border-top: 1px solid var(--panel-border); padding: 16px; text-align: center; font-size: .77rem; line-height: 1.5; }
@media (min-width: 600px) {
    .content { padding: 30px 25px 70px; }
    .panel { padding: 24px; }
    .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .console-output { height: 340px; }
    .below-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { padding: 14px 25px; }
}
@media (min-width: 950px) {
    .dashboard { grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); align-items: stretch; }
    .console-output { height: 355px; }
}
@media (prefers-reduced-motion: no-preference) {
    button { transition: background-color .12s ease, filter .12s ease; }
}

.game-picker { display: flex; align-items: flex-start; flex-direction: column; gap: 8px; padding: 15px 16px; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); }
.game-picker label { color: var(--cyan); font-weight: 750; font-size: .84rem; }
.game-picker select { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 9px; border: 1px solid #47617c; background: #0a1625; color: var(--text); font: inherit; }
.game-picker span { color: var(--muted); font-size: .8rem; }
.game-picker select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (min-width: 600px) {
    .game-picker { flex-direction: row; align-items: center; }
    .game-picker select { width: min(370px, 45%); }
}

.refresh-games { min-height: 44px; border: 1px solid #47617c; color: var(--text); background: #162f4a; border-radius: 9px; padding: 8px 12px; }
.refresh-games:hover { background: #214566; }
/* No terrain/ownership is disclosed outside the current frontier. */
.map-cell.unknown { background: var(--empire-unknown, #081424); border: 0; pointer-events: none; }
.map-cell.foreign, .legend-swatch.foreign { background: var(--empire-foreign, #70457a); color: var(--empire-foreign-text, #fff); }
.top-links { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; font-size: .78rem; }
/* Navigation remains accessible hyperlinks, but is presented as a touch-friendly button bar. */
.player-status-links .nav-button,
.top-links .nav-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid #456780;
    border-radius: 9px;
    background: #162f4a;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
    touch-action: manipulation;
}
.top-links .nav-button-home { border-color: var(--cyan); }
.player-status-links .nav-button:hover,
.top-links .nav-button:hover { background: #214566; border-color: #70d8ef; color: #fff; }
.top-links .nav-button.active {
    background: #285575;
    border-color: var(--cyan);
    box-shadow: inset 0 -3px 0 var(--cyan);
    color: #fff;
}
.top-links .nav-button-signout { border-color: #6a5a56; background: #2e2730; }
.top-links .nav-button-signout:hover { background: #51343c; border-color: #e9a69d; }
@media (max-width: 700px) {
    .player-status-links .nav-button,
    .top-links .nav-button { flex: 0 0 auto; padding-inline: 12px; }
}
.login-card { width: min(92vw, 420px); margin: 8vh auto; padding: 28px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); }
.login-card label { display: block; margin: 17px 0; }
.login-card input, .admin-field { width: 100%; display: block; min-height: 44px; padding: 8px 12px; border-radius: 8px; color: var(--text); background: #0a1625; border: 1px solid #47617c; }
.login-card button, .admin-action { min-height: 44px; padding: 9px 17px; border: 0; border-radius: 8px; font: inherit; font-weight: 750; color: #211c16; background: var(--gold); }
.login-error { color: #ffb0a7; }
.admin-section { margin-bottom: 18px; padding: 18px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); }
.admin-fields { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 14px 0; }
.admin-fields label { display: block; }
.admin-fields input { margin-top: 4px; }
@media (min-width: 650px) { .admin-fields { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* Global player directory: clear hierarchy and deliberate column spacing. */
.admin-list-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.admin-list-heading h2 { margin: 0; }
.admin-list-heading .muted { margin: 7px 0 0; }
.admin-secondary { min-height: 44px; padding: 9px 16px; border: 1px solid #42607c; border-radius: 9px; color: var(--text); background: #1a324c; white-space: nowrap; }
.admin-secondary:hover { background: #284665; }
.admin-game-option { border: 1px solid var(--panel-border); border-radius: 9px; padding: 12px; margin: 12px 0; }
.admin-game-option h3 { font-size: 1rem; margin: 0 0 8px; }
.admin-game-option p[role="status"] { margin: 8px 0 0; }
.admin-game-option p[role="status"]:empty { display: none; }
.admin-game-option button:disabled { opacity: .5; cursor: not-allowed; }
.admin-game-option button { white-space: normal; }
.registration-request { border: 1px solid var(--panel-border); border-radius: 8px; padding: 12px; margin: 12px 0; overflow-wrap: anywhere; }
.registration-request h3 { margin: 0 0 8px; }
.registration-actions { display: flex; flex-wrap: wrap; gap: 10px; }
#registrations details { margin-top: 16px; overflow-wrap: anywhere; }
/* Only a session conflict exposes this action: make its consequence obvious. */
.player-status-bar .session-takeover-danger {
    border: 2px solid #ffb5b8; background: #a51f2d; color: #fff;
    font-weight: 700;
}
.player-status-bar .session-takeover-danger:hover { background: #c12c3b; }
.player-status-bar .session-takeover-danger:focus-visible {
    outline: 3px solid #ffe1e2; outline-offset: 2px;
}
.player-table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; margin-top: 20px; border: 1px solid #35516d; border-radius: 12px; background: #0b192a; }
.player-table-scroll:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.player-table { width: 100%; min-width: 700px; table-layout: fixed; border-collapse: separate; border-spacing: 0; text-align: left; color: var(--text); }
.player-table th, .player-table td { padding: 16px 20px; border-bottom: 1px solid #2c4158; vertical-align: middle; font-size: .91rem; line-height: 1.5; }
.player-table thead th { background: #1a3048; color: #d8e8f5; font-size: .76rem; text-transform: uppercase; letter-spacing: .055em; font-weight: 750; white-space: nowrap; }
.player-table th:nth-child(1), .player-table td:nth-child(1) { width: 25%; }
.player-table th:nth-child(2), .player-table td:nth-child(2) { width: 19%; }
.player-table th:nth-child(3), .player-table td:nth-child(3) { width: 16%; }
.player-table th:nth-child(4), .player-table td:nth-child(4) { width: 40%; }
.player-table tbody th { font-weight: 750; }
.player-table tbody tr:nth-child(even) { background: #12263d; }
.player-table tbody tr:hover { background: #203a55; }
.player-table tbody tr:last-child > * { border-bottom: 0; }
.player-username { color: #8eddf2; overflow-wrap: anywhere; }
.player-role { display: inline-block; color: #dfebf5; font-weight: 600; }
.player-state { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid; border-radius: 8px; font-size: .79rem; font-weight: 700; white-space: nowrap; }
.player-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.player-state--enabled { color: #a6e9c7; background: #143a33; border-color: #32634f; }
.player-state--disabled { color: #f6c8aa; background: #473125; border-color: #865644; }
.player-unassigned { color: #9db0c3; font-style: italic; }
.player-memberships { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.player-memberships li { display: inline-flex; flex-wrap: wrap; gap: 7px; align-items: center; padding: 4px 9px; border: 1px solid #36536d; border-radius: 7px; background: #152e47; color: #dcebf6; font-size: .82rem; overflow-wrap: anywhere; }
.player-game-id { color: #8dddf2; font-weight: 750; }
.player-assignment-separator { color: #7f9bb5; }
.player-table-hint { display: none; margin: 8px 2px 0; color: var(--muted); font-size: .75rem; }
@media (max-width: 740px) {
    .player-table th, .player-table td { padding: 13px 16px; }
    .player-table-hint { display: block; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Nation directory reuses the player-table layout and introduces numeric alignment. */
.game-admin-picker { display: block; width: min(100%, 420px); margin: 18px 0 15px; font-weight: 700; }
.game-admin-picker select { margin-top: 8px; }
.nation-table th:nth-child(1), .nation-table td:nth-child(1) { width: 21%; }
.nation-table th:nth-child(2), .nation-table td:nth-child(2) { width: 36%; }
.nation-table th:nth-child(3), .nation-table td:nth-child(3) { width: 21%; }
.nation-table th:nth-child(4), .nation-table td:nth-child(4) { width: 22%; }
.nation-coordinate, .nation-count { font-variant-numeric: tabular-nums; }
.nation-count { font-weight: 750; text-align: right; }
.nation-table thead th:last-child { text-align: right; }
.admin-empty { margin: 16px 0 0; padding: 15px; border: 1px dashed #35516d; border-radius: 10px; color: var(--muted); }
.admin-form-message { margin: 14px 0 0; padding: 12px 14px; background: #182e43; border-left: 3px solid var(--cyan); border-radius: 7px; }

/* Player creation messages stay directly beside the action that produced them. */
.admin-player-feedback { margin: 14px 0 0; padding: 12px 15px; border-radius: 9px; line-height: 1.5; font-weight: 600; }
.admin-player-feedback--success { color: #baf5d0; border: 1px solid #3c7d60; background: #153d30; }
.admin-player-feedback--error { color: #ffd0c8; border: 1px solid #b66b63; background: #44272e; }
.admin-action:disabled { cursor: progress; opacity: .75; }

/* Management-only accounts get a full-width console, never a player sector grid. */
.dashboard.dashboard-admin { grid-template-columns: minmax(0, 1fr); }

/* Player-owned sector inventory; independent horizontal scrolling on narrow screens. */
.owned-sector-panel { margin-top: 16px; }
.owned-table-scroll { overflow-x: auto; overscroll-behavior-inline: contain; border: 1px solid #35516d; border-radius: 12px; background: #0b192a; }
.owned-table { width: 100%; min-width: 830px; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.owned-table th, .owned-table td { padding: 12px 13px; border-bottom: 1px solid #2c4158; vertical-align: middle; white-space: nowrap; }
.owned-table thead th { background: #1a3048; color: #e0eaf4; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.owned-table tbody tr:nth-child(even) { background: #12263d; }
.owned-table tbody tr:hover { background: #203a55; }
.owned-table tbody tr.selected { background: #214d60; box-shadow: inset 3px 0 0 var(--cyan); }
.owned-table tbody tr:last-child > * { border-bottom: 0; }
.owned-table .numeric { text-align: right; }
.owned-table thead th:nth-child(n+3):nth-child(-n+8) { text-align: right; }
/* Report numbers use identical header/value alignment in every report view.
   Keep coordinates and designations left-aligned and permit horizontal scrolling. */
.owned-table.report-table thead th:nth-child(n+3),
.owned-table.report-table tbody td:nth-child(n+3) { text-align: right; }
.sector-coordinates { color: #a7e6f1; font-weight: 800; }
.sector-type { color: var(--gold); font-family: ui-monospace, monospace; font-weight: 850; }
.sector-select { min-height: 38px; padding: 7px 12px; border-radius: 8px; border: 1px solid #5987a7; background: #193851; color: #e6f6ff; }
.sector-select[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.sector-editor { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-top: 16px; padding: 16px; border: 1px solid #32546f; border-radius: 12px; background: #132c43; }
.sector-editor h3 { margin: 0 0 6px; font-size: 1.12rem; }
.sector-editor p { margin-bottom: 0; }
.sector-edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.sector-edit-actions label { width: 100%; font-size: .83rem; font-weight: 700; }
.sector-edit-actions select { min-height: 44px; min-width: 190px; max-width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid #47617c; background: #0a1625; color: var(--text); font: inherit; }
.sector-edit-actions button { min-height: 44px; padding: 9px 14px; border: 0; border-radius: 8px; background: var(--gold); color: #211c16; font-weight: 800; }
.sector-edit-actions button:disabled { opacity: .6; cursor: wait; }
@media (max-width: 599px) { .owned-table th, .owned-table td { padding: 11px 10px; } .sector-edit-actions { width: 100%; } .sector-edit-actions select { flex: 1; } }

/* v0.6.0: mobile-first economic controls and schedule readout */
.update-status { flex-basis: 100%; font-size: .88rem; opacity: .9; margin: .2rem 0; }
.sector-edit-actions { display: flex; align-items: flex-end; flex-wrap: wrap; gap: .7rem; margin-top: 1rem; }
.sector-edit-actions label { display: flex; flex-direction: column; flex: 1 1 145px; min-width: 0; gap: .3rem; }
.sector-edit-actions input, .sector-edit-actions select { width: 100%; max-width: 100%; min-height: 2.5rem; }
.sector-edit-actions button { min-height: 2.5rem; }


/* Nation economy view: compact numbers, touch-first management controls. */
.economy-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 20px; }
.economy-metrics div { border: 1px solid var(--panel-border); border-radius: 10px; padding: 14px; background: #142b43; }
.economy-metrics span { display: block; color: var(--muted); font-size: .78rem; margin-bottom: 6px; }
.economy-metrics strong { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.economy-table { min-width: 980px; }
.economy-tools { margin-top: 18px; }
.economy-form-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; }
.economy-form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: .9rem; }
.economy-form-grid select, .economy-form-grid input { min-width: 0; width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #47617c; border-radius: 9px; background: #0a1625; color: var(--text); }
.economy-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.economy-actions button { min-height: 44px; padding: 9px 14px; background: #234565; color: var(--text); border: 1px solid #51728c; border-radius: 9px; }
.economy-actions button:disabled { opacity: .5; cursor: not-allowed; }
.update-report-list { display: grid; gap: 12px; }
.update-report { padding: 12px 16px; border: 1px solid #34516e; border-radius: 10px; background: #0c1c2d; }
.update-report h3 { margin: 0 0 9px; color: var(--gold); font-size: .98rem; }
.update-report p { margin: 4px 0; color: #cad9e5; font-size: .88rem; line-height: 1.5; }
@media (min-width:650px) { .economy-metrics { grid-template-columns: repeat(5,minmax(0,1fr)); } .economy-form-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } }

/* Signed-in identity is visible on every authenticated page. */
.top-links { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.signed-in-user { padding: 6px 10px; border: 1px solid var(--panel-border); border-radius: 10px; font-size: .82rem; color: var(--muted); white-space: normal; overflow-wrap: anywhere; }
.signed-in-user strong { color: var(--text); }
.account-role { color: var(--gold); }
@media (max-width: 700px) { .topbar { flex-wrap: wrap; } .top-links { width: 100%; justify-content: flex-start; gap: 10px; } }

/* Signed-in nation's daily time budget (shared across tabs and transports). */
.playing-time-status { padding: .35rem 1rem; font-size: .88rem; text-align: center;
    border-bottom: 1px solid #334b66; color: #d4e7f6; }

/* World editor: clearly identify the selected absolute sector. */
.god-world-scroll { max-height: min(70vh, 760px); }
.god-world-scroll .god-selected { outline: 3px solid #f5c56b; outline-offset: -2px; z-index: 1; }
.god-world-scroll .map-cell { cursor: pointer; }
.god-world-scroll .hex-map-row { position: relative; }
.god-nation-controls { margin: 8px 0; }
.god-nation-controls label { display: inline-flex; align-items: center; gap: 6px; }
.god-nation-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; list-style: none; margin: 6px 0; padding: 0; font-size: .82rem; }
.god-nation-legend li { overflow-wrap: anywhere; }
.god-nation-key { display: inline-block; min-width: 1.5em; text-align: center; font-weight: 700; color: var(--gold); }
.god-nation-watermark { position: absolute; top: 5px; z-index: 3; pointer-events: none; text-align: center; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 10px/10px system-ui; color: rgba(255,255,255,.75); text-shadow: 0 1px 2px #000; }
.god-nation-number { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); pointer-events: none; font: 700 9px/9px system-ui; color: rgba(255,255,255,.8); text-shadow: 0 1px 2px #000; }


.economy-table button { min-height: 38px; padding: 7px 12px; border: 1px solid #51728c; border-radius: 8px; background: #234565; color: var(--text); }
.economy-table button:disabled { opacity: .5; }

/* Mouse right-click menu and accessible sector action button use the same commands. */
.sector-context-menu { position: fixed; left: 8px; top: 8px; z-index: 120;
    display: flex; flex-direction: column; gap: 4px;
    width: min(244px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
    overflow-y: auto; overscroll-behavior: contain;
    padding: 10px; border: 1px solid #7597b9; border-radius: 12px;
    box-shadow: 0 14px 32px #020916cc; color: var(--text); background: #11253b; }
.sector-context-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.context-sector-kind { font-size: .78rem; color: #a9c5dd; margin-bottom: 4px; }
.sector-context-menu button[role="menuitem"], .sector-context-menu a[role="menuitem"] {
    display: block; width: 100%; min-height: 36px; padding: 7px 9px; text-align: left;
    border: 1px solid transparent; border-radius: 6px; background: #1b3854;
    text-decoration: none; color: #f0f5fa; font-size: .88rem; }
.sector-context-menu button:hover:not(:disabled), .sector-context-menu a:hover,
.sector-context-menu button:focus-visible, .sector-context-menu a:focus-visible { background: #2e5679; border-color: #b1d4f0; }
.sector-context-menu button:disabled { opacity: .42; cursor: not-allowed; }
.sector-context-menu .context-close { flex: 0 0 auto; border: 0; color: white; background: transparent; font-size: 1.35rem; }
.context-source-hint { font-size: .77rem; color: #b7c6d5; padding: 4px 2px; }
.map-selection-heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#sector-editor, #map-selection { scroll-margin-top: 155px; }

/* Map-selected endpoints are shown on the hexes; keep only actionable controls here. */
.movement-selections { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 9px 16px;
    flex: 1 1 460px; min-width: 0; margin: 0; }
.movement-selections:has(.movement-quick-actions, .map-route-open, .movement-selection-warning) {
    padding: 10px; border: 1px solid #36516a; border-radius: 10px; background: #112337; }
.sector-edit-actions input[readonly] {
    background: #0a1928; border: 1px solid #55718b; color: #ffe2a4;
    cursor: default; font-family: ui-monospace, Consolas, monospace; }
.movement-selection-status { flex: 1 1 100%; font-size: .84rem; margin: 2px 0; }


/* Contextual commands for the selected hex directly below the map. */
.map-cell.is-selected { filter: brightness(1.2); }

.map-selection { padding: 1rem; margin-top: 1rem; border: 1px solid #47617c; border-radius: .75rem; background: #101e30; }
.map-selection-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.map-selection-heading h3 { margin: 0; }
.map-selection h4 { margin: 1rem 0 .3rem; font-size: .95rem; color: #d6e9ff; }
.map-selection button, .sector-editor button { cursor: pointer; }
.map-selection-heading button, .map-selection > button { border: 1px solid #637f9c; background: #16344a; color: #fff; padding: .6rem; border-radius: .5rem; }
.map-sector-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .5rem; margin: .75rem 0; }
.map-sector-stats span { padding: .45rem; border: 1px solid #36516a; border-radius: .4rem; }
.world-panel .sector-editor { margin-top: 1rem; }

/* Persistent cross-page player summary (read-only: does not consume BTUs/time). */
.site-header { position: sticky; top: 0; z-index: 60; background: #07121ff5; box-shadow: 0 2px 12px #01071088; }
.player-status-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 9px 16px; border-bottom: 1px solid var(--panel-border); background: #102238; }
.player-status-metrics { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; }
.player-status-metric { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; font-size: .85rem; }
.player-status-label { color: var(--muted); }
.player-status-value { color: var(--gold); font-family: ui-monospace, Consolas, monospace; font-size: 1rem; font-variant-numeric: tabular-nums; }
.player-status-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; font-size: .82rem; }
.status-ok { color: #a6e7c4; }
.status-warning { color: #ffcd8c; }
@media (max-width: 700px) {
    .player-status-bar { padding: 8px 12px; gap: 6px; }
    .player-status-metrics { gap: 5px 12px; }
    .player-status-metric { font-size: .78rem; }
    .player-status-value { font-size: .91rem; }
    .player-status-links { margin-left: 0; }
}

.route-edit-link { display: inline-flex; align-items: center; min-height: 36px; margin-right: 8px; padding: 6px 12px; border: 1px solid #47617c; border-radius: 7px; color: #b6e5ff; text-decoration: none; background: #162f4a; }
.route-edit-link:hover, .route-edit-link:focus-visible { background: #214566; }
#all-routes, #supply-title { scroll-margin-top: 145px; }

/* Movement controls stay in the top toolbar after Set Dest. */
.movement-quick-actions { flex: 1 1 100%; display: flex; align-items: center; flex-wrap: wrap;
    gap: 8px 12px; padding: 10px; background: #19344a; border: 1px solid #467b9d; border-radius: 8px; }
.movement-quick-actions { min-width: 0; }
.movement-quick-actions select { min-width: 0; max-width: 100%; }
.movement-quick-actions input[type="number"] { width: 92px; min-width: 0; }
.movement-quick-actions label { font-weight: 600; font-size: .86rem; }
.movement-quick-actions button { padding: 9px 14px; background: #2b6f88; border: 1px solid #6dbcd5;
    color: white; border-radius: 7px; cursor: pointer; }
.movement-quick-actions button:disabled { opacity: .55; cursor: not-allowed; }
/* Keep the movement limit legible and adjacent to its amount on narrow screens. */
.movement-limit { flex: 1 1 100%; grid-column: 1 / -1; min-width: 0; display: flex;
    flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px;
    background: #0a1928; border: 1px solid #6dbcd5; border-radius: 8px; }
.movement-limit-status { flex: 1 1 190px; min-width: 0; display: flex; flex-wrap: wrap;
    align-items: baseline; gap: 4px 8px; }
.movement-limit-label { font-size: .95rem; font-weight: 700; color: #e4f1fb; }
.movement-limit-value { font-size: 1.4rem; line-height: 1.2; color: #ffe2a4; font-variant-numeric: tabular-nums; }
.movement-limit-detail { flex-basis: 100%; font-size: .82rem; color: #c4d7e8; }
.movement-limit .movement-limit-use { min-height: 44px; padding: 8px 14px; border: 1px solid #6dbcd5;
    border-radius: 7px; background: #2b6f88; color: white; font-weight: 700; cursor: pointer; }
.movement-limit .movement-limit-use:disabled { opacity: .55; cursor: not-allowed; }
.movement-selection-warning { flex-basis: 100%; color: #ffd9ab; margin: 0; }

/* Map-first Home page. The map stays mounted while tools expand underneath. */
.dashboard-map-first { grid-template-columns: minmax(0, 1fr); align-items: start; }
.home-expander { min-width: 0; background: #101e31ed; border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: clip; margin-top: 14px; }
.home-expander-heading { margin: 0; font-size: 1rem; }
.home-expander-toggle { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; min-height: 50px; padding: 12px 16px; background: #17324b; border: 0; color: var(--text); text-align: left; font-weight: 720; }
.home-expander-toggle:hover, .home-expander-toggle[aria-expanded="true"] { background: #224969; }
.home-expander-toggle:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.home-expander-body { min-width: 0; padding: 12px; }
.home-expander-body > .panel { box-shadow: none; }
.home-expander-body .intro { display: none; }
.embedded-refresh { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 7px 0 13px; }
.embedded-refresh button { padding: 9px 13px; min-height: 44px; border: 1px solid #456780; background: #162f4a; color: var(--text); border-radius: 9px; }
.embedded-refresh span { color: var(--muted); font-size: .84rem; }
.inline-link { padding: 0; border: 0; background: none; color: var(--cyan); text-decoration: underline; cursor: pointer; font-size: inherit; }
.inline-link:hover { color: #b3effb; }
@media (min-width: 950px) { .dashboard.dashboard-map-first { grid-template-columns: minmax(0, 1fr); } }

/* Context-menu actions with settings open a focused dialog; the map remains mounted. */
.map-route-open { min-height: 40px; padding: 8px 12px; border: 1px solid #76acd0;
    border-radius: 8px; background: #215276; color: #f3faff; cursor: pointer; }
.map-route-open:hover { background: #316b91; }
.map-route-dialog-backdrop { position: fixed; z-index: 180; inset: 0; background: #020a17c9;
    display: grid; place-items: center; padding: 12px; }
.map-route-dialog { width: min(580px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto;
    border: 1px solid #7496b5; border-radius: 14px; background: #122840;
    box-shadow: 0 20px 48px #000b; padding: clamp(14px, 3vw, 24px); color: var(--text); }
.map-route-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.map-route-dialog-heading h3 { margin: 0; }
.map-route-dialog-heading button { font-size: 1.4rem; background: transparent; color: inherit; border: 0;
    cursor: pointer; min-width: 42px; min-height: 42px; }
.map-route-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.map-route-fields label { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: .87rem; }
.map-route-fields input, .map-route-fields select { min-height: 42px; width: 100%; box-sizing: border-box; }
.map-route-fields input[readonly] { background: #0a1928; color: #ffe2a4; cursor: default; }
.route-field { position: relative; min-width: 0; }
.route-field-label { display: block; min-height: 26px; padding-right: 34px; }
.route-dialog-intro { margin-top: 6px; }
.route-dialog-intro p#map-route-dialog-help { margin: 0; padding: 4px 34px 4px 0; color: var(--muted); font-size: .85rem; }
.route-field-help summary { position: absolute; top: 0; right: 0; display: grid; place-items: center;
    width: 28px; height: 28px; box-sizing: border-box; border: 1px solid #7496b5; border-radius: 50%;
    color: #f8cb76; background: #122840; font-weight: 600; font-size: .85rem; cursor: pointer; list-style: none; }
.route-field-help summary::-webkit-details-marker { display: none; }
.route-field-help summary:hover, .route-field-help[open] summary { background: #215276; }
.route-field-help summary:focus-visible { outline: 2px solid #f8cb76; outline-offset: 2px; }
.route-field-help-text { margin: 6px 0 0; padding: 8px; border: 1px solid #597893; border-radius: 6px;
    background: #0a1928; color: var(--text); font-size: .85rem; line-height: 1.4; overflow-wrap: anywhere; }
.route-reserve-summary { grid-column: 1 / -1; font-size: .87rem; }
.route-reserve-summary .route-field-label { padding-top: 4px; }
.map-route-fields .route-food-summary { padding: 8px 12px; margin: 0; }
.map-route-fields .route-food-summary p { margin: 0; }
.map-route-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.map-route-dialog-actions button { min-height: 44px; padding: 8px 14px; cursor: pointer; }
.map-route-dialog-actions button:disabled { opacity: .6; cursor: progress; }
.map-route-error { color: #ffd9ab; margin-top: 10px; }
@media (max-width: 520px) { .map-route-fields { grid-template-columns: minmax(0, 1fr); } }

/* Right-click sector actions share the map route dialog's accessible, viewport-bound surface. */
.sector-action-dialog { width: min(620px, 100%); }
.sector-action-dialog-wide { width: min(1020px, 100%); }
.sector-action-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px;
    padding: 12px; border: 1px solid #37536e; border-radius: 8px; margin-top: 12px; }
.sector-action-stats span { min-width: 0; overflow-wrap: anywhere; }
.sector-action-output { white-space: pre-wrap; overflow-wrap: anywhere; font: 0.88rem/1.55 monospace;
    border-radius: 8px; background: #091a2a; padding: 12px; max-height: 36dvh; overflow: auto; }
@media (max-width: 520px) { .sector-action-stats { grid-template-columns: minmax(0,1fr); } }

/* Phase 3/4 mobile-first fleet and aircraft mission builders (v0.9.83). */
.operations-panel h3 { margin: 0 0 13px; color: #d4eafe; font-size: 1.08rem; }
.operations-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.operations-toolbar button, .operations-buttons button {
    border: 1px solid #53728e; border-radius: 9px; background: #173a56;
    color: #f2f9ff; padding: 9px 13px; min-height: 44px; font-weight: 650;
}
.operations-buttons button[type="submit"] { background: #d8a850; border-color: #efce80; color: #181d25; }
.operations-toolbar button:disabled, .operations-buttons button:disabled { opacity: .5; cursor: not-allowed; }
.operations-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.operations-form { min-width: 0; border: 1px solid #34546d; border-radius: 12px; padding: 14px; background: #0a1a2d; }
.operations-form > label, .operations-form .operations-grid > label { display: block; margin-top: 12px; font-size: .86rem; font-weight: 650; color: #d9e8f8; }
.operations-form input, .operations-form select { display: block; width: 100%; min-width: 0; min-height: 44px; margin-top: 5px; padding: 8px 10px; border: 1px solid #577894; border-radius: 8px; background: #0f2941; color: #f0f7fd; font: inherit; }
.operations-form input:focus-visible, .operations-form select:focus-visible { outline: 3px solid #f8cb76; outline-offset: 1px; }
.operations-coordinate-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.operations-coordinate-pair label { min-width: 0; font-weight: 650; font-size: .86rem; }
.operations-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.operations-fleet { margin-top: 14px; }
.operations-preview-label { margin: 14px 0 5px; font-size: .85rem; font-weight: 750; color: #d8eefd; }
.operations-preview { white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; border: 1px solid #537894; border-radius: 9px; color: #d7f0db; background: #071827; font-size: .86rem; max-height: 240px; overflow-y: auto; }
.operations-status { margin: 12px 0; color: #cbdfed; font-size: .87rem; }
@media (min-width: 760px) { .operations-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* v0.9.84: accessible mobile-first carrier deck and construction controls. */
.operations-deck { margin-top: 18px; padding: 14px; border: 1px solid #34546d; border-radius: 12px; background: #091c30; }
.operations-deck-heading h3 { margin-bottom: 6px; }
.operations-deck-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
.operations-deck-card { min-width: 0; border: 1px solid #4a6a87; border-radius: 9px; padding: 12px; overflow-wrap: anywhere; }
.operations-deck-card h4 { margin: 0 0 8px; color: #e9f6fe; }
.operations-deck-card p { margin: 7px 0; }
.operations-deck-planes { padding-left: 18px; }
.operations-deck-planes li { margin: 10px 0; }
.operations-deck-planes li span { display: block; margin: 3px 0; }
.operations-deck-planes button { border: 1px solid #6087aa; border-radius: 7px; padding: 8px 12px; min-height: 40px; color: #fff; background: #1d4969; }
.operations-construction { margin-top: 14px; }
@media (min-width: 760px) { .operations-deck-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* v0.9.86: map-assisted aircraft, ship and fleet mission builders. */
.operations-map-target { display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: center;
  margin: 10px 0 16px; padding: 12px; border: 1px solid #496c89; border-radius: 9px;
  background: #0c2135; color: #d8e7f4; font-size: .9rem; }
.operations-map-target strong { color: #f7d08b; }
.operations-use-map { width: 100%; margin-top: 10px; min-height: 44px; padding: 9px 12px;
  border: 1px solid #81a8d1; border-radius: 8px; color: #f1f8ff;
  background: #1b496d; font: inherit; cursor: pointer; }
.operations-use-map:disabled { opacity: .45; cursor: not-allowed; }
.operations-use-map:focus-visible { outline: 3px solid #f8cb76; outline-offset: 2px; }

.operations-unit-picker { margin-top: 12px; border: 1px solid #456681;
  border-radius: 9px; padding: 9px 12px; }
.operations-unit-picker summary { cursor: pointer; font-weight: 650; }
.operations-unit-pick-grid { display: grid; gap: 8px; max-height: 280px;
  overflow-y: auto; margin-top: 12px; }
.operations-unit-pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px; border: 1px solid #385777; border-radius: 8px; }
.operations-unit-pick span { flex: 1 1 160px; }
.operations-unit-pick button { min-height: 40px; padding: 7px 10px; color: #f4f9ff;
  background: #1b496d; border: 1px solid #789fbe; border-radius: 7px; }
.operations-unit-pick button[aria-pressed="true"] { background: #665024; border-color: #d3b46a; }
.operations-unit-pick button:focus-visible { outline: 3px solid #f8cb76; }

/* v0.9.86: complete searchable graphical command catalog and argument popups. */
.gui-command-palette { padding: .9rem; }
.gui-command-palette > details > summary { cursor:pointer; font-weight:700; font-size:1.05rem; padding:.6rem 0; }
.gui-command-palette > details > input { display:block; width:100%; max-width:42rem; min-height:44px; margin:.35rem 0 .8rem; }
.gui-command-groups { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr)); gap:.85rem; }
.gui-command-group { background:var(--panel-bg, transparent); border:1px solid var(--panel-border,#a8b3c2); border-radius:12px; padding:.7rem; }
.gui-command-group h3 { margin:.2rem 0 .6rem; font-size:1rem; }
.gui-command-buttons { display:flex; flex-wrap:wrap; gap:.4rem; }
.gui-command-button { min-height:42px; padding:.45rem .65rem; border-radius:8px; text-align:left; }
.gui-command-button span { opacity:.7; padding-left:.2rem; }
.gui-command-modal { width:min(96vw,650px); max-height:90dvh; overflow-y:auto; }
.gui-command-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,245px),1fr)); gap:.75rem; padding:.5rem 0; }
.gui-command-fields label { display:flex; flex-direction:column; gap:.25rem; min-width:0; }
.gui-command-fields input,.gui-command-fields select,.gui-command-fields textarea { width:100%; min-height:42px; }
.gui-command-preview { display:grid; gap:.4rem; margin:1rem 0; }
.gui-command-preview code { display:block; white-space:pre-wrap; overflow-wrap:anywhere; padding:.65rem; border:1px solid var(--panel-border,#9ba9b8); border-radius:8px; }
.gui-command-result { white-space:pre-wrap; overflow-wrap:anywhere; padding:.75rem; border:1px solid var(--panel-border,#9ba9b8); margin:.45rem; max-height:25rem; overflow:auto; }
@media(max-width:550px){.gui-command-fields{grid-template-columns:1fr}.gui-command-modal{width:98vw;max-height:95dvh}}


/* v0.9.87: roster-driven command popups and touch-friendly formation selectors. */
.gui-command-field { display:flex; flex-direction:column; gap:.3rem; min-width:0; }
.gui-command-field > label { font-weight:600; }
.gui-command-field > input,.gui-command-field > select,
.gui-command-field > textarea { width:100%; min-height:44px; }
.gui-command-unit-list { display:flex; flex-wrap:wrap; gap:.35rem;
  max-height:11rem; overflow-y:auto; padding:.55rem;
  border:1px solid var(--panel-border,#9ba9b8); border-radius:8px; }
.gui-command-unit-list small { flex:1 0 100%; }
.gui-command-unit-chip { min-height:40px; border-radius:8px; padding:.45rem .65rem;
  border:1px solid var(--panel-border,#9ba9b8); }
.gui-command-unit-chip[aria-pressed="true"] { background:#22577c; color:#fff; border-color:#8accf6; }
.gui-command-unit-chip:focus-visible { outline:3px solid #e6b354; outline-offset:2px; }
.gui-command-unit-chip:disabled { opacity:.5; cursor:not-allowed; }


/* v0.9.91: observed-sector logistics pickers and fleet mission preview. */
.gui-command-sector-pickers, .gui-command-fleet-planner {
  border: 1px solid var(--panel-border,#7593ad); border-radius: 10px;
  margin: 12px 0; padding: 12px; min-width: 0;
}
.gui-command-sector-pickers > strong, .gui-command-fleet-planner > strong { display: block; margin-bottom: 6px; }
.gui-command-sector-choice { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.15fr) auto;
  align-items: center; gap: 8px; margin: 9px 0; }
.gui-command-sector-choice select, .gui-command-fleet-planner select {
  width: 100%; min-width: 0; min-height: 44px; }
.gui-command-sector-choice button, .gui-command-planner-actions button {
  min-height: 44px; padding: 7px 10px; border-radius: 8px; }
.gui-command-fleet-planner label { display: block; font-weight: 650; margin: 8px 0 4px; }
.gui-command-planner-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.gui-command-route-hexes { display: flex; flex-wrap: wrap; gap: 5px; max-height: 160px;
  overflow-y: auto; margin: 10px 0; }
.gui-command-route-hexes span { border: 1px solid var(--panel-border,#7593ad);
  border-radius: 6px; padding: 4px 7px; font-family: ui-monospace,monospace; }
@media (max-width: 650px) {
  .gui-command-sector-choice { grid-template-columns: minmax(0,1fr); }
  .gui-command-sector-choice button { width: 100%; }
}

/* v0.9.91: resource-aware naval and logistics command dialogs. */
.gui-command-ship-context, .gui-command-cargo-context, .gui-command-logistics-context {
  border: 1px solid var(--panel-border,#7593ad); border-radius: 10px;
  padding: 12px; margin: 12px 0; overflow-wrap:anywhere;
}
.gui-command-ship-context > strong, .gui-command-cargo-context > strong,
.gui-command-logistics-context > strong { display:block; margin-bottom:8px; }
.gui-command-ship-context p, .gui-command-cargo-context p,
.gui-command-logistics-context p { margin:7px 0; }
.gui-command-ship-context small { display:block; margin:5px 0; }
.gui-command-quantity-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.gui-command-quantity-actions button, .gui-command-logistics-context button {
  min-height:44px; padding:8px 12px; border-radius:8px;
}
.gui-command-warning { border-left:3px solid #c77e14; padding-left:10px; }
@media(max-width:550px){
  .gui-command-quantity-actions button { flex:1 1 28%; }
}

/* v0.9.91: accessible naval target selection and readiness details in command modal. */
.gui-command-naval-targeting, .gui-command-gunnery-preview {
    margin-block: .65rem; padding: .85rem; border: 1px solid var(--border, #8b98a6);
    border-radius: .6rem; display: grid; gap: .55rem;
}
.gui-command-naval-targeting select { width:100%; max-width:100%; min-height:44px; }
.gui-command-gunnery-preview .gui-command-quantity-actions { display:flex; flex-wrap:wrap; gap:.4rem; }
.gui-command-gunnery-preview .gui-command-quantity-actions button { min-height:44px; }

/* Fleet forms: owner-only roster, co-located ship selection and touch targets. */
.gui-command-fleet-roster { margin: .8rem 0; padding: .8rem;
  border:1px solid var(--panel-border,#7593ad); border-radius:10px; min-width:0; }
.gui-command-fleet-roster > strong { display:block; margin-bottom:.4rem; }
.gui-command-active-fleets, .gui-command-fleet-actions {
  display:flex; flex-wrap:wrap; gap:.5rem; margin:.6rem 0; }
.gui-command-active-fleets button, .gui-command-fleet-actions button {
  min-height:44px; min-width:0; padding:.5rem .75rem; border-radius:8px; }
.gui-command-active-fleets button[aria-pressed="true"] {
  outline:2px solid var(--accent,#538ed6); outline-offset:1px; }
.gui-command-fleet-members { max-height:10rem; overflow-y:auto; margin:.5rem 0;
  padding-left:1.25rem; overflow-wrap:anywhere; }
.gui-command-fleet-members li { margin:.3rem 0; }
@media (max-width:550px) {
  .gui-command-fleet-actions button { flex:1 1 100%; }
  .gui-command-active-fleets button { flex:1 1 45%; }
}

/* v0.9.93 — readable, keyboard accessible fleet approach and naval previews. */
.gui-command-route-steps { list-style:none; padding:.5rem; margin:.5rem 0; }
.gui-command-route-steps li { display:flex; gap:.55rem; align-items:center;
  min-height:44px; border:1px solid var(--panel-border,#7593ad);
  border-radius:9px; padding:.4rem .6rem; background:var(--panel-bg,transparent); }
.gui-command-route-direction { min-width:3.4rem; font-weight:700; }
.gui-command-contact-preview,.gui-command-sail-preview { padding:.7rem;
  margin:.5rem 0; border:1px solid var(--panel-border,#7593ad); border-radius:9px; }
.gui-command-sail-preview strong { display:block; margin-bottom:.35rem; }
@media(max-width:550px) {
  .gui-command-route-steps { max-height:11rem; overflow-y:auto; }
  .gui-command-route-steps li { flex:1 1 100%; }
  #gui-fleet-contact { min-height:44px; }
}

/* v0.9.94: observed-only aircraft route and readiness preview in command popups. */
.gui-command-air-planner { border:1px solid var(--panel-border,#7593ad); border-radius:10px;
  padding:12px; margin:12px 0; min-width:0; overflow-wrap:anywhere; }
.gui-command-air-planner > strong { display:block; margin-bottom:6px; }
.gui-command-air-planner label { display:block; margin:8px 0 4px; font-weight:650; }
.gui-command-air-planner select { width:100%; min-height:44px; max-width:100%; }
.gui-command-air-planner .gui-command-planner-actions button { min-height:44px; }
.gui-command-air-steps li { display:flex; gap:6px; align-items:center;
  border:1px solid var(--panel-border,#7593ad); border-radius:6px; padding:4px 7px; }
.gui-command-air-steps li span { border:0; padding:0; }
.gui-command-air-warnings { margin:.6rem 0; padding:.7rem .7rem .7rem 1.8rem;
  border-left:3px solid #c77e14; }
.gui-command-air-warnings li { margin-bottom:.35rem; }
@media(max-width:550px) {
  .gui-command-air-planner .gui-command-planner-actions button { width:100%; }
}

/* Ground attack and fortress FIRE preparation in the graphical command popup. */
.gui-command-ground-planner { border: 1px solid var(--panel-border); border-radius: 12px; padding: 1rem; display: grid; gap: .65rem; min-width: 0; }
.gui-command-ground-sources { display: grid; gap: .5rem; max-height: 15rem; overflow: auto; }
.gui-command-ground-source { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; border-bottom: 1px solid var(--panel-border); padding-bottom: .5rem; }
.gui-command-ground-source span { flex: 1 1 11rem; }
.gui-command-ground-sources button, .gui-command-ground-contingents button { min-height: 2.7rem; }
.gui-command-ground-contingents { display: grid; gap: .35rem; margin: 0; padding-left: 1.25rem; }
.gui-command-ground-contingents li { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.gui-command-ground-warnings { color: var(--gold); margin: 0; padding-left: 1.25rem; }
@media (max-width: 600px) { .gui-command-ground-sources { max-height: 12rem; } .gui-command-ground-source button { flex: 1 1 8rem; } }
.gui-command-ground-contingents input[type="number"] { flex: 0 1 6rem; min-width: 4.25rem; }

/* SPY uses owned army sectors only; the controls wrap on narrow screens. */
.gui-command-spy-planner { margin: .6rem 0; padding: .8rem; border: 1px solid var(--border, #8c98a5); border-radius: .6rem; }
.gui-command-spy-sources { display:flex; flex-wrap:wrap; gap:.45rem; max-height:12rem; overflow:auto; margin:.5rem 0; }
.gui-command-spy-sources button { min-height:2.5rem; white-space:normal; }

/* Treaty warnings require an explicit choice without cluttering all command forms. */
.gui-command-treaty-confirmation { margin:.75rem 0; border:1px solid var(--panel-border,#9ba9b8); border-radius:8px; padding:.8rem; }
.gui-command-treaty-confirmation label { display:flex; align-items:flex-start; gap:.55rem; }
.gui-command-treaty-confirmation input { min-width:1.15rem; min-height:1.15rem; margin-top:.12rem; }

/* Authenticated player issue reporting (mobile-first). */
.issue-report-panel { max-width: 48rem; }
.issue-report-form { display: grid; gap: .65rem; }
.issue-report-form label { font-weight: 650; margin-top: .4rem; }
.issue-report-form input,
.issue-report-form select,
.issue-report-form textarea { width: 100%; max-width: 100%; box-sizing: border-box; min-height: 2.7rem; }
.issue-report-form textarea { min-height: 6rem; resize: vertical; }
.issue-report-form button { min-height: 2.8rem; justify-self: start; }
@media (max-width: 560px) { .issue-report-form button { width: 100%; } }

.game-management-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.god-map-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .5rem; }

/* Leaderboard: compact ranking tables, with horizontal scrolling for detailed scores. */
.power-table-scroll { overflow-x: auto; max-width: 100%; }
.power-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.power-table th, .power-table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid #8294a655; }
.power-table td:last-child { white-space: nowrap; }
.power-note { font-size: .85rem; }

.power-history-chart { display: block; width: 100%; max-width: 42rem; height: auto; margin: .75rem 0; }

/* Keyboard navigation and small-screen alpha guidance. */
.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 10000; transform: translateY(-200%); padding: .75rem 1rem; border-radius: .5rem; background: #10273e; color: #fff; }
.skip-link:focus { transform: none; }
select:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.alpha-guidance { margin: .75rem 0; line-height: 1.5; overflow-wrap: anywhere; }

/* Selection outline and endpoint fills; route edges stay independent. */
.map-selection-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-selection-overlay polygon { fill: none; stroke-width: 2; stroke-linejoin: round; }
.map-ring-selected { stroke: var(--empire-selected, #ffe09a); }
.map-cell.is-source { background: var(--empire-source, #e69f00); color: var(--empire-source-text, #000); }
.map-cell.is-destination { background: var(--empire-destination, #0072b2); color: var(--empire-destination-text, #fff); }
.map-cell[data-sector-role-cycle] { user-select: none; }
/* The sector panel is outside the clipped map and is scrollable by mouse or touch. */
.sector-info-popup { position: fixed; z-index: 65; width: min(350px, calc(100vw - 16px));
    max-height: min(60vh, 560px); max-height: min(60dvh, 560px); display: flex; flex-direction: column;
    background: #101e30; border: 1px solid #597893; border-radius: 10px; box-shadow: 0 8px 28px #000a;
    color: var(--text); font-size: .85rem; }
.sector-info-popup[hidden] { display: none; }
.sector-info-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px; border-bottom: 1px solid #36516a; }
.sector-info-header strong { flex: 1 1 100%; overflow-wrap: anywhere; }
.sector-info-header button { background: #19334c; color: var(--text); border: 1px solid #597893; border-radius: 6px; min-height: 36px; padding: 4px 10px; }
.sector-info-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 4px 12px 12px; }
.sector-info-body h4 { margin: 12px 0 6px; color: var(--cyan); font-size: .9rem; }
.sector-info-body p { margin: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sector-info-body .resource-renewable { color: #a6e7b0; }
.sector-info-body .resource-depletable { color: #f8cb76; }
.sector-info-body progress { display: block; width: 100%; height: 8px; accent-color: #70b77a; }
.sector-info-body .resource-depletable progress { accent-color: #d6a04b; }
.sector-info-popup:focus-within { border-color: var(--gold); }

/* Give statistics and warnings their natural height; scroll details first.
   Only when the fixed content exceeds the viewport may the whole panel scroll. */
.sector-info-popup { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.sector-info-header { flex: 0 0 auto; padding: 6px 10px; }
.sector-info-header strong { flex: 1 1 140px; }
.sector-info-summary { flex: 0 0 auto; padding: 5px 9px; border-bottom: 1px solid #36516a; }
.sector-info-summary[hidden] { display: none; }
.sector-info-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 6px; }
.sector-info-stats p { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.sector-info-stats .sector-primary-product { grid-column: 1 / -1; color: #f8cb76; }
.sector-info-stats .sector-staffing-target { grid-column: 1 / -1; }
.sector-info-warning, .sector-info-critical { margin-top: 5px; padding: 5px 7px; border-radius: 4px; }
.sector-info-warning { background: var(--empire-warning, #fff3cd); color: var(--empire-warning-text, #000); }
.sector-info-critical { background: var(--empire-critical, #ffd4e5); color: var(--empire-critical-text, #000); }
.sector-info-warning p, .sector-info-critical p { margin: 3px 0 0; }
.sector-info-body { flex: 1 1 auto; min-height: 40px; max-height: min(50vh, 400px); max-height: min(50dvh, 400px); }
.campaign-status { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 6px 0; font-size: .82rem; }
.nation-news { width: 100%; font-size: .82rem; }
.nation-news summary { cursor: pointer; color: var(--cyan); padding: 5px 0; }
.nation-news-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.nation-news-grid section { max-height: 240px; overflow-y: auto; overflow-wrap: anywhere; padding: 6px 9px; border: 1px solid #36516a; border-radius: 5px; }
.nation-news-grid h3 { font-size: .9rem; margin: 0 0 6px; }
.nation-news-grid p { margin: 5px 0; }
.nation-latest-event, .news-critical { font-size: .82rem; overflow-wrap: anywhere; padding: 3px 6px; }
.news-critical { color: #ffbec0; background: #532b33; border-radius: 4px; }
@media(max-width: 700px) { .nation-news-grid { grid-template-columns: 1fr; } }

/* Accessible display preferences: labels do not depend on color perception. */
.map-role-marker { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); z-index: 2; color: #fff; background: #000; font: bold 10px/12px system-ui; padding: 0 3px; border-radius: 2px; pointer-events: none; }
.map-cell.is-source .map-cell-symbol, .map-cell.is-destination .map-cell-symbol { transform: translateY(-4px); }
.map-cell:focus-visible { outline: none; filter: brightness(1.3); }
.map-cell:focus-visible::after { content: ""; position: absolute; inset: 3px; background: transparent; border: 2px dashed currentColor; pointer-events: none; }
.sector-info-popup { width: min(440px, calc(100vw - 16px)); }
.sector-info-warning, .sector-info-critical { line-height: 1.3; padding: 9px 12px; overflow-wrap: anywhere; }
.display-settings { max-width: 840px; }
.display-settings > label { display: block; margin-top: 16px; }
.display-settings > select { width: 100%; background: var(--panel); color: var(--text); padding: 10px; border: 1px solid var(--muted); border-radius: 5px; font: inherit; }
.display-color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.display-color-grid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.display-color-grid input { min-width: 48px; min-height: 44px; background: var(--panel); border: 1px solid var(--muted); border-radius: 5px; }
.display-map-preview { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0; }
.display-map-preview > div { display: grid; justify-items: center; gap: 4px; font-size: .85rem; }
.display-warning-preview { font-size: .85rem; margin: 14px 0; display: grid; gap: 8px; }

.sector-forecast-dialog { width: min(460px, 100%); }
.sector-forecast-results { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.sector-forecast-results li { overflow-wrap: anywhere; }
.sector-forecast-results li:last-child { font-size: .85rem; opacity: .85; }
.sector-combat-actions { margin: 8px 0; }
.sector-combat-actions summary { cursor: pointer; }

.route-management-item { border: 1px solid #7496b5; border-radius: 8px; padding: 12px; margin: 8px 0; }
.route-management-item p { margin: 5px 0; }
#manage-routes-title { overflow-wrap: anywhere; }

/* Home game selection lives in the shared header, above the player metrics. */
.home-game-picker { flex-direction: column; align-items: stretch; min-width: 0; margin: 0; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--panel-border); border-radius: 0; background: #102238; }
.site-header:has(.home-game-picker) .current-game-status { display: none; }
.home-welcome { margin-bottom: 16px; }
.home-welcome p { margin: 0; }
/* A naming form can be opened from a console far below the header. Allow
   the header to scroll away so the whole form is reachable on short screens. */
.site-shell:has(.home-country-forms) .site-header { position: static; }
.home-country-forms { width: 100%; min-width: 0; margin: 0; }
.home-game-picker .game-picker-controls { width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.home-game-picker .game-picker-controls select { flex: 1 1 220px; width: 100%; min-width: 0; max-width: 370px; }
.home-game-picker .game-picker-controls button { max-width: 100%; overflow-wrap: anywhere; }
.home-game-picker .update-status { flex-basis: auto; overflow-wrap: anywhere; }
.home-country-forms .country-name-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; max-width: 640px; min-width: 0; padding: 16px; overflow-wrap: anywhere; }
.country-name-form input { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 9px; border: 1px solid #47617c; background: #0a1625; color: var(--text); }
.country-name-form p { margin: 0; color: var(--muted); font-size: .88rem; }
.country-name-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.country-name-actions button { min-width: 0; white-space: normal; min-height: 44px; padding: 8px 14px; border: 1px solid #47617c; border-radius: 9px; color: var(--text); background: #162f4a; max-width: 100%; overflow-wrap: anywhere; }
.country-name-actions button:first-child { background: var(--gold); color: #211c16; font-weight: 750; }
.country-name-actions button:disabled { opacity: .55; cursor: not-allowed; }
@media (max-width: 599px) {
    .home-game-picker { padding: 8px 12px; }
    .home-game-picker .game-picker-controls select { flex-basis: 100%; max-width: 100%; }
    .country-name-actions button { flex: 1 1 140px; }
}

/* Dedicated diplomacy page: responsive, no map-width dependencies. */
.diplomacy-panel { display: grid; gap: .85rem; min-width: 0; }
.diplomacy-panel h2, .diplomacy-panel h3, .diplomacy-panel p { margin: 0; overflow-wrap: anywhere; }
.diplomacy-controls, .diplomacy-tabs, .diplomacy-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.diplomacy-tabs button[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: -3px; }
.diplomacy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: .75rem; }
.diplomacy-entry { min-width: 0; display: grid; gap: .5rem; border: 1px solid #607589; border-radius: .5rem; padding: .85rem; overflow-wrap: anywhere; }
.diplomacy-panel select, .diplomacy-panel input:not([type="checkbox"]), .diplomacy-panel textarea { min-width: 0; max-width: 100%; width: 100%; box-sizing: border-box; }
.diplomacy-controls select { flex: 1 1 12rem; width: auto; }
.diplomacy-check { display: flex; gap: .5rem; align-items: center; }
.diplomacy-check input { width: auto; flex: 0 0 auto; }

/* Consistent action palette. Map terrain and selection colors are independent. */
:root {
    --action-blue: #19334c;
    --action-blue-hover: #284665;
    --action-gold: #f8cb76;
    --action-gold-hover: #ffda94;
    --action-red: #a62e3d;
    --action-red-hover: #bf3b4a;
}
:where(button:not(.map-cell)) {
    background: var(--action-blue); color: var(--text);
    border: 1px solid #597893; border-radius: 8px;
    padding: 8px 12px; min-height: 44px; font: inherit;
}
:where(button:not(.map-cell):not(:disabled):hover) { background: var(--action-blue-hover); }
:where(button:not(.map-cell):disabled) { opacity: .55; cursor: not-allowed; }
.site-shell button.action-primary, button.action-primary {
    background: var(--action-gold); color: #211c16; border-color: #e3b764; font-weight: 750;
}
.site-shell button.action-primary:hover:not(:disabled), button.action-primary:hover:not(:disabled) { background: var(--action-gold-hover); }
.site-shell button.action-danger, button.action-danger {
    background: var(--action-red); color: #fff; border-color: #e48690; font-weight: 650;
}
.site-shell button.action-danger:hover:not(:disabled), button.action-danger:hover:not(:disabled) { background: var(--action-red-hover); }
.diplomacy-panel button { min-height: 44px; }
.diplomacy-tabs button[aria-pressed="true"] { background: #285575; border-color: var(--cyan); }

/* JIT distribution settings stay together in both route editors. */
.route-distribution, .route-food-summary { grid-column: 1 / -1; min-width: 0; border: 1px solid #597893; border-radius: 8px; padding: 12px; margin: 4px 0; }
.route-distribution legend { color: #f8cb76; font-weight: 600; padding: 0 5px; }
.route-distribution p, .route-food-summary p { margin: 8px 0; }
.route-food-summary strong { color: #f8cb76; }

/* Sort data in Blazor rather than moving DOM nodes outside its renderer. */
.table-sort {
    display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
    padding: .15rem .25rem; border: 0; border-radius: .25rem;
    background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.table-sort:hover, .table-sort:focus-visible { color: #f8cb76; }
th[aria-sort="ascending"] .table-sort, th[aria-sort="descending"] .table-sort { color: #f8cb76; }

/* Compact production forecast; retain contained scrolling on narrow screens. */
.production-table-scroll .report-table { min-width: 0; }
.production-table-scroll .report-table th, .production-table-scroll .report-table td { padding: 7px 5px; }
.production-table-scroll .table-sort { gap: .15rem; padding: .1rem 0; }
.production-table-scroll .report-table thead th { letter-spacing: 0; }

/* Census is compact at desktop widths and scrolls independently on smaller screens.
   A bounded height keeps the horizontal scrollbar reachable in large nations. */
.census-table-scroll { width: 100%; max-width: 100%; min-width: 0; max-height: min(60vh, 36rem); overflow: auto; overscroll-behavior: contain; }
.census-table-scroll .report-table { min-width: 0; }
.census-table-scroll .report-table th, .census-table-scroll .report-table td { padding: 7px 5px; }
.census-table-scroll .table-sort { gap: .15rem; padding: .1rem 0; }
.census-table-scroll .report-table thead th { position: sticky; top: 0; z-index: 1; letter-spacing: 0; }
.census-table-scroll:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* Report sector coordinates are keyboard/touch links without widening the tables. */
.report-sector-row { cursor: pointer; }
.report-sector-link {
    font: inherit; color: inherit; background: transparent; border: 0;
    padding: 0; min-height: 0; min-width: 0; border-radius: 0;
    cursor: pointer; text-decoration: underline; text-underline-offset: .15em;
}
.report-sector-link:hover, .report-sector-link:focus-visible { color: #f8cb76; }

.map-route-cycle-edge { stroke: #ff5252; stroke-width: 6; filter: drop-shadow(0 0 2px #661010); }

/* In-game Help navigation and read-only sector reference. */
.help-menu { position: relative; }
.help-menu > summary { list-style: none; cursor: pointer; gap: .4rem; }
.help-menu > summary::-webkit-details-marker { display: none; }
.help-menu > summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.help-menu-links { position: absolute; z-index: 2; top: calc(100% + 5px); left: 0; width: max-content; min-width: 160px; max-width: calc(100vw - 32px); padding: 5px; background: #142c44; border: 1px solid #456780; border-radius: 9px; box-shadow: 0 8px 24px #010710aa; }
.help-menu-links a, .help-menu-links button { display: flex; align-items: center; min-height: 44px; padding: 8px 10px; text-decoration: none; color: var(--text); border-radius: 5px; }
.help-menu-links a:hover, .help-menu-links a:focus-visible, .help-menu-links button:hover, .help-menu-links button:focus-visible { background: #285575; }
.sector-help-basics h2, .sector-help-group h2 { margin-bottom: 12px; }
.sector-help-basics p:last-child { margin-bottom: 0; }
.sector-help-group { margin: 24px 0; }
.sector-help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.sector-help-card h3 { margin: 0 0 12px; font-size: 1rem; color: var(--cyan); }
.sector-help-card h3 code { display: inline-grid; place-items: center; min-width: 26px; min-height: 26px; border-radius: 5px; background: #285575; color: var(--text); }
.sector-help-card dl { margin: 0; display: grid; grid-template-columns: minmax(0, 100px) minmax(0, 1fr); gap: 7px 10px; font-size: .86rem; }
.sector-help-card dt { color: var(--muted); }
.sector-help-card dd { margin: 0; overflow-wrap: anywhere; }
.sector-help-unavailable { font-size: .82rem; color: var(--muted); margin: 12px 0 0; }

.help-menu-links button { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
/* show(), not showModal(): no backdrop or inert game content. */
.sector-help-popup { position: fixed; inset: clamp(76px, 14vh, 130px) 12px auto auto; margin: 0; width: min(440px, 46vw); max-height: min(72dvh, calc(100dvh - 90px)); padding: 0; border: 1px solid #456780; border-radius: 10px; color: var(--text); background: #142c44; box-shadow: 0 8px 24px #010710aa; z-index: 110; overflow: hidden; }
.sector-help-popup[open] { display: flex; flex-direction: column; }
.sector-help-popup-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #456780; }
.sector-help-popup-header h2 { margin: 0; font-size: 1.1rem; }
.sector-help-popup-header button { min-width: 44px; min-height: 44px; cursor: pointer; }
.sector-help-popup-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; }
.sector-help-popup .sector-help-grid { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 700px) {
    .sector-help-popup { inset: auto 8px 8px auto; width: min(440px, calc(100vw - 16px)); max-height: 55dvh; }
}

/* Completed campaign celebration, separate from the read-only game map. */
.campaign-victory { border-color: var(--gold); margin-bottom: 16px; }
.victory-title { color: var(--gold); font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 800; overflow-wrap: anywhere; margin: 8px 0; }
