/* ============================================
   WAR ROOM - WW2 Command Center Theme
   ============================================ */

/* -- Theme Variables -- */
:root {
    --color-bg-dark: #2c2c1e;
    --color-bg-medium: #3a3a28;
    --color-bg-light: #4a4a32;
    --color-parchment: #e8d5a3;
    --color-parchment-light: #f0e4c1;
    --color-parchment-dark: #d4bf8a;
    --color-brass: #b8860b;
    --color-brass-light: #d4a017;
    --color-brass-dark: #8b6508;
    --color-olive: #556b2f;
    --color-olive-dark: #3d4f22;
    --color-olive-light: #6b8e3a;
    --color-ink: #1a1a0e;
    --color-ink-light: #3d3d2e;
    --color-border: #8b7d56;
    --color-border-light: #a69570;
    --color-text-dark: #2c2416;
    --color-text-medium: #5c4f3a;
    --color-text-light: #8a7d66;
    --color-red-accent: #8b2020;
    --color-green-accent: #3d6b35;
    --font-display: 'Special Elite', cursive;
    --font-body: 'Share Tech Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg-dark);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(85, 107, 47, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 101, 8, 0.1) 0%, transparent 40%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
    min-height: 100vh;
    color: var(--color-text-dark);
    touch-action: manipulation;
}

.screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* ============================================
   Auth Screen (Landing Page)
   --------------------------------------------
   Full-bleed landing artwork (WAR ROOM title is baked into the image).
   The login/register form is anchored as a percentage of the artwork so it
   always sits directly under the "WAR ROOM" lettering: bottom-right on the
   wide (desktop) art, bottom-center on the tall (mobile) art.
   ============================================ */
#auth-screen {
    position: fixed;
    inset: 0;
    padding: 0;
    overflow: hidden;
}

/* Aspect-ratio-locked layer that covers the viewport. Because the artwork
   fills this layer exactly (100% 100%) and the form is positioned as a % of
   it, the form tracks the title through any cover-cropping. Defaults to the
   wide art; the portrait media query below swaps in the tall art. */
.auth-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max(100vw, 100vh * 1.83318);
    height: max(100vh, 100vw / 1.83318);
    background-image: url('landing_wide.jpg');
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

.auth-panel {
    position: absolute;
    /* Bottom-right quadrant, centered under "WAR ROOM" on the wide art. */
    left: 69.5%;
    top: 63%;
    transform: translateX(-50%);
    width: min(340px, 82vw);
    max-height: 35%;
    overflow-y: auto;
    padding: 20px 22px;
    background: rgba(20, 20, 12, 0.74);
    border: 2px solid var(--color-brass-dark);
    border-radius: 4px;
    box-shadow:
        0 0 0 1px rgba(184, 134, 11, 0.35),
        0 8px 28px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* Portrait / mobile: swap to the tall art and center the form under the
   title in the bottom-center. */
@media (max-aspect-ratio: 1 / 1) {
    .auth-stage {
        width: max(100vw, 100vh * 0.55800);
        height: max(100vh, 100vw / 0.55800);
        background-image: url('landing_tall.jpg');
    }

    .auth-panel {
        left: 51%;
        top: 68%;
        max-height: 30%;
    }
}

.auth-panel .form-container h2 {
    margin-bottom: 16px;
    color: var(--color-parchment-light);
    font-family: var(--font-display);
    font-size: 1.25em;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

/* Lighter link/helper text so it reads on the dark panel. */
.auth-panel .form-container p {
    color: var(--color-parchment);
}

.auth-panel .form-container input {
    margin-bottom: 12px;
}

.form-container h2 {
    margin-bottom: 20px;
    color: var(--color-olive-dark);
    font-family: var(--font-display);
    font-size: 1.3em;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.form-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    font-size: 15px;
    font-family: var(--font-body);
    background: var(--color-parchment-light);
    color: var(--color-text-dark);
    transition: border-color 0.3s;
}

.form-container input:focus {
    outline: none;
    border-color: var(--color-brass);
    box-shadow: 0 0 4px rgba(184, 134, 11, 0.3);
}

.form-container input::placeholder {
    color: var(--color-text-light);
}

.form-container button {
    width: 100%;
    padding: 12px;
    background: var(--color-olive);
    color: var(--color-parchment-light);
    border: 2px solid var(--color-olive-dark);
    border-radius: 3px;
    font-size: 15px;
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 15px;
}

.form-container button:hover {
    background: var(--color-olive-dark);
    border-color: var(--color-olive);
}

.form-container button:active {
    transform: scale(0.98);
}

.form-container p {
    text-align: center;
    color: var(--color-text-medium);
    font-size: 0.9em;
}

.form-container a {
    color: var(--color-brass-dark);
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px dotted var(--color-brass);
}

.form-container a:hover {
    color: var(--color-brass);
}

.message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 3px;
    text-align: center;
    display: none;
    font-family: var(--font-body);
}

.message.error {
    background: #f8d7da;
    color: var(--color-red-accent);
    border: 1px solid var(--color-red-accent);
    display: block;
}

.message.success {
    background: #d4edda;
    color: var(--color-green-accent);
    border: 1px solid var(--color-green-accent);
    display: block;
}

/* "or" divider between password login and Google SSO */
.sso-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 5px 0 15px;
}

.sso-divider::before,
.sso-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--color-border);
}

.sso-divider span {
    padding: 0 10px;
}

/* Google sign-in button — visually distinct from the olive password button */
.form-container button.btn-google {
    background: var(--color-parchment-light);
    color: var(--color-text-dark);
    border: 2px solid var(--color-border);
}

.form-container button.btn-google:hover {
    background: #fff;
    border-color: var(--color-brass);
}

/* Lobby SSO-link control + linked badge */
#link-google-btn {
    margin-right: 10px;
}

#sso-linked-badge {
    margin-right: 10px;
    color: var(--color-text-medium);
    font-size: 0.85em;
}

/* ============================================
   Lobby Screen
   ============================================ */
.lobby-container {
    background: var(--color-parchment);
    background-image:
        linear-gradient(135deg, rgba(212, 191, 138, 0.5) 0%, rgba(232, 213, 163, 0.8) 50%, rgba(212, 191, 138, 0.5) 100%);
    border: 3px solid var(--color-brass-dark);
    border-radius: 4px;
    padding: 40px;
    box-shadow:
        0 0 0 1px var(--color-brass),
        0 4px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    max-width: 620px;
    width: 100%;
    position: relative;
}

.lobby-container::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid var(--color-brass);
    border-radius: 2px;
    pointer-events: none;
    opacity: 0.4;
}

.lobby-banner {
    display: block;
    width: 100%;
    height: auto;
    margin-bottom: 4px;
    border: 1px solid var(--color-brass-dark);
    border-radius: 2px;
}

.lobby-games-header {
    color: var(--color-ink);
    font-family: var(--font-display);
    font-size: 1.2em;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 20px 0 4px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
    text-shadow: 1px 1px 0 rgba(184, 134, 11, 0.3);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--color-border);
    color: var(--color-text-dark);
    font-weight: bold;
}

.btn-primary {
    padding: 14px 24px;
    background: var(--color-olive);
    color: var(--color-parchment-light);
    border: 2px solid var(--color-olive-dark);
    border-radius: 3px;
    font-size: 15px;
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 20px;
}

.btn-primary:hover {
    background: var(--color-olive-dark);
    border-color: var(--color-olive);
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--color-bg-medium);
    color: var(--color-parchment);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 13px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-secondary:hover {
    background: var(--color-bg-light);
    border-color: var(--color-brass);
}

.btn-toggle {
    padding: 6px 12px;
    font-size: 11px;
}

#games-list {
    margin-top: 20px;
}

.game-item {
    padding: 15px;
    background: var(--color-parchment-light);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-olive);
    border-radius: 3px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--color-text-dark);
    font-size: 0.9em;
}

.game-item:hover {
    background: var(--color-parchment-dark);
    border-left-color: var(--color-brass);
}

.game-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Optional owner-set name — shown only when the game was named. */
.game-item-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.game-item-headline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.game-item-status {
    font-weight: bold;
}

.game-item-times {
    display: flex;
    flex-wrap: wrap;
    column-gap: 14px;
    font-size: 0.85em;
    color: var(--color-text-light);
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}

/* Invited games: host attribution */
.game-item-hosted-by {
    display: block;
    font-size: 0.9em;
    margin-top: 4px;
}

/* Vacant-nation pause indicator in the lobby listing */
.game-item-paused {
    color: #b00020;
    font-weight: bold;
    font-size: 0.9em;
}

.game-item-finished {
    border-left-color: var(--color-text-light);
    opacity: 0.8;
}

.games-list-section {
    margin: 18px 0 8px;
    font-size: 0.8em;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-light);
}

.game-item-scenario {
    display: inline-block;
    background: var(--color-olive);
    color: var(--color-parchment-light);
    font-weight: bold;
    padding: 1px 7px;
    border-radius: 3px;
    letter-spacing: 0.02em;
}

/* Nation roster: two side-by-side columns (Allies / Axis) filling the
   space between the game info and the delete button. */
.game-item-controls {
    display: flex;
    gap: 16px;
    margin: 0 14px;
    flex-shrink: 0;
    align-items: flex-start;
}

.nation-control-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nation-control {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 1.05em;
    line-height: 1;
}

.nation-control-type {
    font-size: 0.85em;
}

.btn-delete-game {
    background: var(--color-red-accent);
    color: var(--color-parchment-light);
    border: none;
    border-radius: 3px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-delete-game:hover {
    opacity: 1;
}

/* ============================================
   Game Screen — fullscreen map stage with HUD
   ============================================ */
.game-layout {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

/* Wide layout: action drawer widens for battle boards & multi-nation tables
   (Phase 4 battle/debrief/raid sub-phases, Phase 6 morale, Phase 7 purchase).
   Compact menus (hotspot selection, stance allocation, etc.) stay at the
   default drawer width so they don't cover the map with empty space. */
.game-layout.phase4-layout .action-panel {
    width: min(880px, calc(100vw - 24px));
}

/* Narrow layout: Phase 5 landing/reorganization and Phase 7 unit placement
   are simple option/assignment menus that only need modest width */
.game-layout.narrow-action-layout .action-panel {
    width: min(520px, calc(100vw - 24px));
}

/* -- HUD top bar -- */
.hud-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(44, 44, 30, 0.92) 0%, rgba(44, 44, 30, 0.75) 100%);
    border-bottom: 1px solid var(--color-brass-dark);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    z-index: 40;
}

.hud-top-left,
.hud-top-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.hud-top-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* Mobile-only: on desktop the round is part of the centered status bar.
   Visibility is decided by the mobile media query alone (no JS-added class
   required) so the readout can't vanish when a client ends up running a
   fresh stylesheet with stale scripts (partially-evicted mobile caches). */
.hud-top-round {
    display: none;
}

/* -- HUD bottom bar: panel toggle buttons (Actions/Intel/Nations/Layers/Log/Menu) -- */
.hud-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: linear-gradient(0deg, rgba(44, 44, 30, 0.92) 0%, rgba(44, 44, 30, 0.75) 100%);
    border-top: 1px solid var(--color-brass-dark);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.4);
    z-index: 40;
}

/* Compact player status: one small flag icon per nation in the top bar.
   Clicking it summons the full status window (.hud-status-stack). */
.hud-status-summary {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--color-bg-medium);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-body);
}

.hud-status-summary:hover {
    background: var(--color-bg-light);
    border-color: var(--color-brass);
}

.hud-status-summary.active {
    border-color: var(--color-brass);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.4);
}

.hud-status-mini {
    position: relative;
    font-size: 16px;
    line-height: 1;
    padding: 1px 1px 3px;
}

.hud-status-mini.pending {
    opacity: 0.4;
    filter: grayscale(0.6);
}

.hud-status-mini.submitted::after {
    content: '\2713';
    position: absolute;
    right: -4px;
    bottom: -2px;
    font-size: 10px;
    font-weight: bold;
    color: #7ddf7d;
    text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.hud-status-mini.active-turn {
    transform: scale(1.25);
}

/* Presence: the nation's assigned player has no connected socket. */
.hud-status-mini.offline::before {
    content: '';
    position: absolute;
    top: 0;
    right: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b00020;
    box-shadow: 0 0 0 1px #000;
}

.hud-status-mini.active-turn::after {
    content: '';
    position: absolute;
    left: 1px;
    right: 1px;
    bottom: -2px;
    height: 2px;
    background: var(--color-brass-light);
    border-radius: 1px;
}

/* Phase 2: the nation the GUI is planning for, boxed in its national colour
   (with a parchment outer ring so darker colours still read on the dark bar).
   Full opacity even while pending, so the active flag never looks greyed out. */
.hud-status-mini.planning {
    opacity: 1;
    filter: none;
    padding: 2px 3px 4px;
    margin: 0 2px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--nation-color) 45%, transparent);
    box-shadow: 0 0 0 2px var(--nation-color), 0 0 0 3px var(--color-parchment-light);
}

.hud-btn {
    padding: 7px 12px;
    background: var(--color-bg-medium);
    color: var(--color-parchment);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 12px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-btn:hover {
    background: var(--color-bg-light);
    border-color: var(--color-brass);
}

.hud-btn.active {
    background: var(--color-olive-dark);
    border-color: var(--color-brass);
    color: var(--color-parchment-light);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.4);
}

/* -- Player status window (turn order, phase 2/7 submission details) --
   Hidden until summoned from the compact status icons in the top bar. */
.hud-status-stack {
    display: none;
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: min(920px, calc(100vw - 24px));
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 45;
}

.hud-status-stack.open {
    display: flex;
}

/* -- HUD popovers (map layers, menu) -- */
/* Open upward from the bottom bar. The right offset here positions the Layers
   popover before its script hook runs; positionPopoverAboveButton() then sets
   an inline left (and clears right) so it sits over the Layers button, which
   slides horizontally with the center-justified bottom bar. The Menu popover
   keeps this right offset (see #hud-menu-panel) since its button is corner-pinned. */
.hud-popover {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 12px;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--color-parchment);
    background-image:
        linear-gradient(180deg, rgba(240, 228, 193, 0.6) 0%, rgba(232, 213, 163, 1) 100%);
    border: 2px solid var(--color-border);
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 50;
    min-width: 220px;
}

.hud-popover.open {
    display: flex;
}

/* The Menu button lives in the top bar, so its popover drops down from the top. */
#hud-menu-panel {
    top: 52px;
    bottom: auto;
    right: 12px;
}

.hud-popover h4 {
    color: var(--color-olive-dark);
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 0.9em;
    margin-bottom: 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

/* -- HUD drawers (Information / Actions / National Summaries) -- */
.hud-drawer {
    display: none;
    position: absolute;
    flex-direction: column;
    z-index: 35;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.hud-drawer.open {
    display: flex;
}

.hud-drawer h3 {
    flex-shrink: 0;
}

.hud-drawer-body {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.hud-drawer-left {
    top: 64px;
    left: 12px;
    bottom: 64px;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 128px);
}

.hud-drawer-right {
    top: 64px;
    right: 12px;
    bottom: 64px;
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100vh - 128px);
}

.hud-drawer-bottom {
    /* Size the drawer to the table's own width instead of a fixed 1100px: the
       table is only as wide as its column count (.nation-table: width:
       max-content — 130px label + ~96px per nation), so a fixed drawer width
       leaves dead space beside it. width: max-content makes the drawer hug the
       table; max-width caps it to the viewport on narrow screens, where the
       table then scrolls horizontally within the body. Center with
       left/right:0 + auto margins rather than left:50% + translateX: with a
       shrink-to-content width the translate approach leaves the box's
       available width ambiguous and mis-positions it as it narrows. */
    left: 0;
    right: 0;
    margin-inline: auto;
    bottom: 60px;
    width: max-content;
    max-width: calc(100vw - 24px);
    max-height: 45vh;
}

.panel {
    background: var(--color-parchment);
    background-image:
        linear-gradient(180deg, rgba(240, 228, 193, 0.6) 0%, rgba(232, 213, 163, 1) 100%);
    border: 2px solid var(--color-border);
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    overflow: auto;
}

.panel h3 {
    color: var(--color-olive-dark);
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-border);
}

/* Attributes Panel */
#territory-info {
    font-size: 14px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

#territory-info h4 {
    margin: 10px 0 5px 0;
    color: var(--color-text-dark);
    font-family: var(--font-display);
}

#territory-info p {
    margin: 5px 0;
}

#territory-info .units-section {
    margin-top: 10px;
}

#territory-info .unit-command {
    margin-left: 10px;
    margin-bottom: 8px;
    padding: 5px;
    background: rgba(240, 228, 193, 0.7);
    border-radius: 3px;
}

.attribute {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(240, 228, 193, 0.6);
    border-radius: 3px;
    border: 1px solid rgba(139, 125, 86, 0.3);
}

.attribute .label {
    font-weight: bold;
    color: var(--color-olive-dark);
    display: block;
    margin-bottom: 5px;
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85em;
}

.attribute span:last-child {
    color: var(--color-text-dark);
    font-size: 1.1em;
}

.phase-action {
    color: var(--color-green-accent);
    font-size: 0.9em;
    line-height: 1.5;
}

.phase-action-block {
    background: rgba(61, 107, 53, 0.1) !important;
    border-left: 3px solid var(--color-olive);
}

/* Fullscreen map background */
.map-container {
    position: absolute;
    inset: 0;
    z-index: 0;
}

#game-canvas {
    background: var(--color-bg-dark);
    background-image:
        radial-gradient(ellipse at 30% 40%, rgba(85, 107, 47, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 70%, rgba(139, 101, 8, 0.08) 0%, transparent 45%);
    cursor: pointer;
    width: 100%;
    height: 100%;
    display: block;
}

.map-zoom-controls {
    position: fixed;
    bottom: 60px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(232, 213, 163, 0.95);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 4px 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 10;
    user-select: none;
}

.map-zoom-controls button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-parchment-light);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-dark);
    padding: 0;
    line-height: 1;
    font-family: var(--font-body);
}

.map-zoom-controls button:hover {
    background: var(--color-parchment-dark);
}

.map-zoom-controls button:active {
    background: var(--color-border-light);
}

.map-zoom-controls .zoom-reset-btn {
    width: auto;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 600;
}

#zoom-level-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-medium);
    min-width: 36px;
    text-align: center;
}

/* Action Panel */
.action-section {
    margin-bottom: 20px;
}

.action-section h4 {
    color: var(--color-olive-dark);
    margin-bottom: 10px;
    font-family: var(--font-display);
    letter-spacing: 1px;
}

.action-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(240, 228, 193, 0.6);
    border: 2px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--font-body);
    color: var(--color-text-dark);
}

.action-btn:hover {
    background: var(--color-parchment-dark);
    border-color: var(--color-brass);
}

.action-btn.active {
    background: var(--color-olive);
    color: var(--color-parchment-light);
    border-color: var(--color-olive-dark);
}

/* Phase 4 hotspot-selection buttons: owner-coloured backgrounds are set
   inline per button, so the hover cue brightens whatever colour is there
   rather than swapping it. Disabled (no units to commit) buttons stay flat. */
.phase4-hotspot-btn {
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}

.phase4-hotspot-btn:not(:disabled):hover {
    filter: brightness(1.07);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Phase 4 elimination tables (per-battle debrief, per-hotspot combined summary,
   grand total) carry one column per nation in the fight, so a full roster
   out-measures the drawer. Scroll the columns inside this wrapper instead of
   letting the rows spill past the panel background, and pin the unit-type
   column so every row stays identifiable while the nations scroll. */
.elim-table-scroll {
    overflow-x: auto;
}

.elim-table {
    /* max-content lets the table grow past the wrapper — that excess is what
       scrolls; min-width keeps a narrow table filling the panel as before. */
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.elim-table th:first-child,
.elim-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    /* Collapsed borders belong to the table grid, so they scroll out from under
       the pinned cells — redraw the column's own edges as inset shadows. The
       outer shadow doubles as the cue that there is more table to the right.
       Each pinned cell also needs an opaque background of its own (set inline
       by phase4-debrief.js); a row background alone paints below the cells
       scrolling underneath and would show through. */
    box-shadow:
        inset 1px 0 0 #ddd,
        inset -1px 0 0 #ddd,
        3px 0 5px -2px rgba(0, 0, 0, 0.18);
}

#selection-info {
    padding: 10px;
    background: rgba(240, 228, 193, 0.5);
    border-radius: 3px;
    min-height: 100px;
    color: var(--color-text-medium);
    border: 1px solid rgba(139, 125, 86, 0.3);
}

.cancelled-orders-panel {
    background: #fff3cd;
    border: 2px solid #d4a017;
    border-radius: 3px;
    padding: 15px;
    margin-bottom: 20px;
}

.cancelled-orders-panel h4 {
    color: #856404;
    margin-bottom: 10px;
    font-family: var(--font-display);
}

.cancelled-list {
    max-height: 200px;
    overflow-y: auto;
}

.cancelled-item {
    background: var(--color-parchment-light);
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 3px;
    font-size: 14px;
    border-left: 3px solid #d4a017;
}

.pending-order {
    background: rgba(61, 107, 53, 0.1);
    border: 1px solid var(--color-olive);
    padding: 10px;
    border-radius: 3px;
    margin-top: 10px;
    color: var(--color-olive-dark);
}

.submitted-players {
    background: rgba(61, 107, 53, 0.15);
    border: 1px solid var(--color-olive);
    padding: 10px;
    border-radius: 3px;
    margin-bottom: 10px;
    color: var(--color-olive-dark);
}

/* Game Setup Mode (Phase 0): hide map/HUD chrome, show a centered setup panel */
.game-layout.game-setup-mode .map-container,
.game-layout.game-setup-mode .hud-status-stack,
.game-layout.game-setup-mode .hud-popover,
.game-layout.game-setup-mode .hud-bottom-bar,
.game-layout.game-setup-mode .map-zoom-controls,
.game-layout.game-setup-mode .attributes-panel,
.game-layout.game-setup-mode .nation-summary-panel {
    display: none;
}

/* Setup-mode Return to Lobby button: hidden by default, shown only in setup mode */
.setup-lobby-return {
    display: none;
}

.game-layout.game-setup-mode {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    padding: 24px 12px;
}

.game-layout.game-setup-mode .setup-lobby-return {
    display: block;
    margin-bottom: 12px;
}

.game-layout.game-setup-mode .action-panel {
    display: flex;
    position: static;
    max-width: 500px;
    width: 100%;
    max-height: none;
    flex-shrink: 0;
}

/* Game screen hosts a fixed fullscreen stage; no page padding */
#game-screen {
    padding: 0;
}

.btn-lobby-return {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-body);
}

/* Read-only spectator indicator in the game top bar (admin watching a game). */
.spectator-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 12px;
    white-space: nowrap;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 768px) {
    .panel {
        padding: 15px;
    }

    /* Drawers become full-width sheets on small screens; they sit above the
       bottom bar so the toggle buttons stay reachable. */
    .hud-drawer-left,
    .hud-drawer-right {
        top: auto;
        left: 8px;
        right: 8px;
        bottom: 52px;
        width: auto;
        max-height: 60vh;
    }

    .hud-drawer-bottom {
        left: 8px;
        right: 8px;
        transform: none;
        width: auto;
        bottom: 52px;
        max-height: 60vh;
    }

    /* Let the top bar reflow rather than overlap: Lobby + compact status icons. */
    .hud-top-bar {
        flex-wrap: wrap;
        padding: 6px 8px;
        gap: 6px 8px;
    }

    /* Two rows on mobile: Lobby + Round + Menu share the first row (the round
       fills the gap the bar's space-between would otherwise leave empty), and
       the status bar wraps to a full-width second row of its own. */
    .hud-top-left {
        order: 1;
        flex: 0 0 auto;
    }

    .hud-top-round {
        order: 2;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        flex: 1 1 auto;
        min-width: 0;
        font-family: var(--font-display);
        font-size: 12px;
        letter-spacing: 0.5px;
        color: var(--color-parchment);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hud-top-right {
        order: 3;
        flex: 0 0 auto;
    }

    .hud-top-center {
        order: 4;
        flex: 1 1 100%;
        justify-content: flex-end;
    }

    /* Bottom-bar buttons share the row evenly so they never collide. */
    .hud-bottom-bar {
        justify-content: space-between;
        padding: 6px 8px;
        gap: 6px;
    }

    .hud-bottom-bar .hud-btn {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }

    .hud-btn {
        padding: 6px 8px;
        font-size: 11px;
        letter-spacing: 0;
    }

    /* The compact status icons can shrink and scroll rather than push
       past the edge of their row. */
    .hud-status-summary {
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    /* Show the phase status on mobile, but let it shrink so it shares
       the second row with the turn-order icons. */
    .hud-top-center .game-status-bar {
        min-width: 0;
        flex: 0 1 auto;
        padding: 4px 10px;
        font-size: 11px;
        letter-spacing: 0.5px;
    }

    /* The round moved up to the first row's empty middle, so drop it here
       rather than showing it twice. */
    .hud-top-center .game-status-round {
        display: none;
    }

    .lobby-container {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .panel h3 {
        font-size: 1.1em;
    }
}

/* Touch feedback */
button:active,
.action-btn:active,
.game-item:active {
    transform: scale(0.98);
}

/* ============================================
   Territory Metadata Display
   ============================================ */
.units-section {
    margin-top: 15px;
    padding: 10px;
    background: rgba(240, 228, 193, 0.5);
    border-radius: 3px;
    border: 1px solid rgba(139, 125, 86, 0.3);
}

.unit-command {
    margin: 8px 0;
    padding: 8px;
    background: var(--color-parchment-light);
    border-left: 3px solid var(--color-olive);
    border-radius: 3px;
    font-size: 13px;
}

#selection-info h4 {
    color: var(--color-olive-dark);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
    font-family: var(--font-display);
    letter-spacing: 1px;
}

#selection-info p {
    margin: 8px 0;
    line-height: 1.5;
}

#selection-info hr {
    margin: 15px 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

/* ============================================
   Nation Summary Table
   ============================================ */
#nation-summary-table {
    overflow-x: auto;
}

.nation-table {
    /* Fixed layout keeps every nation column the same width regardless of how
       much each cell holds. Columns are sized to fit the pips / command title
       (see the width rules below); the table shrinks to that content but never
       overflows its drawer (max-width caps it, shrinking columns evenly). */
    table-layout: fixed;
    width: max-content;
    max-width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9em;
}

/* Type/label column — wide enough for the longest row label */
.nation-table th:first-child,
.nation-table td:first-child {
    width: 130px;
}

/* Nation columns — only as wide as the 4 pip columns or a command title need */
.nation-table th:not(:first-child),
.nation-table td:not(:first-child) {
    width: 96px;
}

.nation-table th {
    background: var(--color-bg-medium);
    color: var(--color-parchment);
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--color-bg-dark);
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85em;
}

.nation-table td {
    padding: 10px 8px;
    border: 1px solid var(--color-border);
    vertical-align: top;
    /* Long content (territory names, reserve lists) wraps within the fixed
       column width rather than forcing the column wider */
    overflow-wrap: break-word;
    word-break: break-word;
}

.nation-table tr:nth-child(even) {
    background: rgba(212, 191, 138, 0.3);
}

.nation-table .resource-row {
    font-weight: 600;
    color: var(--color-text-dark);
}

/* Projected Phase 1 income shown in parentheses next to the stockpile */
.nation-table .resource-income {
    font-weight: normal;
    font-size: 0.82em;
    color: var(--color-green-accent);
}

.nation-table .command-item {
    margin: 5px 0;
    padding: 5px;
    background: rgba(240, 228, 193, 0.5);
    border-radius: 3px;
    font-size: 0.85em;
}

.nation-table .command-territory {
    display: block;
    font-weight: normal;
    font-size: 0.85em;
    line-height: 1.2;
    color: var(--color-text-light);
}

.nation-table .command-id {
    display: block;
    font-weight: 700;
    font-size: 1.3em;
    line-height: 1.15;
    color: var(--color-olive-dark);
}

/* Reserve command lists wrap onto new lines within the narrow column */
.nation-table .reserve-commands {
    display: block;
    overflow-wrap: break-word;
    word-break: break-word;
}

.nation-table .unit-counts {
    color: var(--color-text-medium);
}

/* ============================================
   Resource Color Labels
   ============================================ */
.resource-oil,
.resource-iron,
.resource-osr {
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.resource-oil {
    color: #c0392b;
    background: rgba(192, 57, 43, 0.1);
    border-bottom: 2px solid #c0392b;
}

.resource-iron {
    color: #2471a3;
    background: rgba(36, 113, 163, 0.1);
    border-bottom: 2px solid #2471a3;
}

.resource-osr {
    background: var(--color-bg-dark);
    color: #e8c840;
    border-bottom: 2px solid #d4a017;
}

/* Resource reduction in embattled territories */
.resource-reduction {
    font-weight: 700;
    color: var(--color-red-accent);
}

/* Unit squares - PRESERVED (do not change colors) */
.unit-squares {
    display: grid;
    grid-template-columns: repeat(4, 12px);
    gap: 2px;
    margin-top: 3px;
}

.unit-square {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.unit-squares-inline {
    display: flex;
    gap: 2px;
    margin-top: 3px;
}

/* Unit badge - the unit's sprite on a chip whose colour is the unit colour and whose
   shape is the command class: land = square, air = circle, naval = elongated hexagon.
   Same shape language as the map's commands and the Phase 7 glyphs (renderP7Glyph).
   Outline is painted by the wrapper showing through 1px around the clipped fill, so
   the shape still reads on a surface already tinted with the same unit colour. */
.unit-badge {
    display: inline-flex;
    padding: 1px;
    background: rgba(0, 0, 0, 0.45);
    flex-shrink: 0;
    vertical-align: middle;
}

.unit-badge__fill {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.unit-badge--land,
.unit-badge--land .unit-badge__fill {
    border-radius: 3px;
}

.unit-badge--land .unit-badge__fill {
    padding: 2px;
}

.unit-badge--air,
.unit-badge--air .unit-badge__fill {
    border-radius: 50%;
}

.unit-badge--air .unit-badge__fill {
    padding: 3px;
}

/* Flat-top hexagon, stretched to give side-on hulls room to read */
.unit-badge--naval,
.unit-badge--naval .unit-badge__fill {
    clip-path: polygon(12% 0, 88% 0, 100% 50%, 88% 100%, 12% 100%, 0 50%);
}

.unit-badge--naval .unit-badge__fill {
    padding: 1px 5px;
}

/* Fixed-width slot so a wide naval badge and a square land badge leave their labels
   starting at the same x in a stacked list */
.unit-badge-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Black silhouette, scaled to fit whatever the badge's fill box leaves it */
.unit-sprite {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ============================================
   Phase 7 Summary — placement glyphs
   ============================================ */
/* Glyphs are inline SVG (square/circle/hexagon) so every shape — including the
   hexagon — carries a matching thin boundary, mirroring the map's commands. */
.p7-glyph {
    display: inline-block;
    width: 13px;
    height: 13px;
    vertical-align: middle;
    margin: 0 2px;
}

.p7-placement-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1px;
    padding: 1px 0;
    line-height: 1.4;
}
.p7-placement-terr {
    font-family: monospace;
    font-weight: bold;
    font-size: 0.85em;
    margin-right: 6px;
    min-width: 34px;
}
.p7-placement-tag {
    font-size: 0.7em;
    font-style: italic;
    color: #555;
    margin-left: 6px;
}

.p7-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
    font-size: 0.8em;
    color: #444;
    margin: 8px 0 10px;
}
.p7-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

/* ============================================
   Phase 7 Production — unit purchase table
   ============================================ */
/* Each resource cost lives in a fixed column under one header row, so amounts
   line up down each column and the ⛽/🔩/🌽 symbols aren't repeated per row.
   Rows keep the rounded, gapped unit-colour band the old stacked pills had. */

/* The Actions drawer is only ~365px of usable width, so on the narrowest
   viewports the fixed columns can still out-measure it. Keep the table inside
   this scroller so any excess scrolls within the box instead of the coloured
   rows spilling past the panel background. */
.p7-purchase-scroll {
    overflow-x: auto;
}
.p7-purchase-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    margin-top: 4px;
}
.p7-purchase-table th {
    padding: 0 4px 4px;
    text-align: center;
    font-size: 0.78em;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}
.p7-purchase-table th.p7-col-unit {
    text-align: left;
}
.p7-purchase-table td {
    padding: 4px;
    vertical-align: middle;
}
.p7-purchase-table td:first-child {
    padding-left: 6px;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}
.p7-purchase-table td:last-child {
    padding-right: 6px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.p7-purchase-table .p7-unit-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    font-weight: bold;
    white-space: nowrap;
}
.p7-purchase-table .p7-cost {
    width: 34px;
    text-align: center;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}
.p7-purchase-table .p7-cost--zero {
    color: rgba(0, 0, 0, 0.28);
    font-weight: normal;
}
.p7-purchase-table .p7-qty-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}
.p7-purchase-table .p7-qty-count {
    width: 20px;
    text-align: center;
    font-weight: bold;
}

/* ============================================
   Phase 1 Summary Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 14, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: var(--color-parchment);
    background-image:
        linear-gradient(180deg, rgba(240, 228, 193, 0.6) 0%, rgba(232, 213, 163, 1) 100%);
    border: 3px solid var(--color-brass-dark);
    border-radius: 4px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow:
        0 0 0 1px var(--color-brass),
        0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    color: var(--color-olive-dark);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--color-border);
    font-family: var(--font-display);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.modal-content h4 {
    color: var(--color-text-dark);
    margin: 15px 0 10px 0;
    font-size: 1.1em;
    font-family: var(--font-display);
}

/* Game Log */
.game-log-entries {
    max-height: 50vh;
    overflow-y: auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.85em;
    line-height: 1.6;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.3);
}

.game-log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.game-log-entry:last-child {
    border-bottom: none;
}

.game-log-meta {
    color: #888;
    font-size: 0.9em;
    margin-right: 6px;
}

.phase1-income-report {
    margin-bottom: 20px;
}

.income-entry {
    padding: 8px 12px;
    margin: 5px 0;
    background: rgba(240, 228, 193, 0.5);
    border-left: 3px solid var(--color-olive);
    border-radius: 3px;
}

.income-entry strong {
    color: var(--color-text-dark);
    min-width: 120px;
    display: inline-block;
}

.phase1-embattled {
    margin-bottom: 20px;
}

.embattled-entry {
    padding: 8px 12px;
    margin: 5px 0;
    background: #fff3cd;
    border-left: 3px solid #d4a017;
    border-radius: 3px;
}

.phase1-collapse-penalties {
    margin-bottom: 20px;
}

.collapse-entry {
    padding: 8px 12px;
    margin: 5px 0;
    background: #f2dede;
    border-left: 3px solid #a94442;
    border-radius: 3px;
}

/* ============================================
   Phase 2 Orders Grid
   ============================================ */
.orders-grid {
    margin-top: 10px;
}

.order-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(240, 228, 193, 0.5);
    border-radius: 3px;
    border: 1px solid var(--color-border);
    position: relative;
}

.order-cell input[type="text"] {
    font-size: 13px;
    font-family: var(--font-body);
    background: var(--color-parchment-light);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 6px 8px;
    color: var(--color-text-dark);
}

.order-cell input[type="text"]:focus {
    outline: none;
    border-color: var(--color-brass);
    box-shadow: 0 0 4px rgba(184, 134, 11, 0.3);
}

/* Oil bid +/- buttons */
.oil-bid-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--color-olive);
    border-radius: 3px;
    background: rgba(85, 107, 47, 0.1);
    color: var(--color-olive-dark);
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: var(--font-body);
}

.oil-bid-btn:hover:not(:disabled) {
    background: var(--color-olive);
    color: var(--color-parchment-light);
}

.oil-bid-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Phase 2 order panel painted in the planning nation's colours. The inline
   style (phase2NationThemeStyle) supplies --nation-color/-light/-text; the
   accent is a darkened --nation-color so pale colours (Great Britain's wheat,
   China's yellow) still give visible borders on the light tint. */
.phase2-nation-panel {
    --nation-accent: color-mix(in srgb, var(--nation-color) 70%, #000);
    background: var(--nation-light);
    border: 3px solid var(--nation-accent);
    border-radius: 4px;
    padding: 0 8px 10px;
    overflow: hidden;
}

.phase2-nation-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 -8px 12px;
    padding: 8px 10px;
    background: var(--nation-color);
    color: var(--nation-text);
    border-bottom: 2px solid var(--nation-accent);
}

.phase2-nation-banner-flag {
    font-size: 2em;
    line-height: 1;
}

.phase2-nation-banner-label {
    margin: 0;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
}

.phase2-nation-banner-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.2em;
    letter-spacing: 1px;
}

.phase2-nation-panel .order-cell {
    border-color: var(--nation-accent);
    background: rgba(255, 255, 255, 0.45);
}

/* Give back the width the panel's border and padding take on narrow drawers. */
.phase2-nation-panel .order-command-box,
.phase2-nation-panel .order-territory-box {
    padding: 8px 4px;
}

.phase2-nation-panel .order-command-box.filled {
    border-color: var(--nation-accent);
    background: color-mix(in srgb, var(--nation-color) 30%, transparent);
    color: var(--color-text-dark);
}

/* Order cell clickable boxes */
.order-command-box,
.order-territory-box {
    padding: 8px;
    text-align: center;
    border: 2px dashed var(--color-border-light);
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-body);
    transition: all 0.15s ease;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.order-command-box:hover,
.order-territory-box:hover {
    border-color: var(--color-brass);
    background: rgba(184, 134, 11, 0.1);
}

.order-command-box.filled {
    border: 2px solid var(--color-olive);
    background: rgba(61, 107, 53, 0.1);
    color: var(--color-olive-dark);
}

.order-territory-box.filled {
    border: 2px solid var(--color-brass-dark);
    background: rgba(184, 134, 11, 0.1);
    color: var(--color-brass-dark);
}

.order-command-box .placeholder,
.order-territory-box .placeholder {
    color: var(--color-text-light);
    font-weight: normal;
    font-style: italic;
}

.order-clear-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--color-red-accent);
    color: var(--color-parchment-light);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.order-clear-btn:hover {
    opacity: 1;
}

/* ============================================
   Command Selector Modal
   ============================================ */
.command-selector-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.command-selector-item {
    padding: 12px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--color-parchment-light);
}

.command-selector-item:hover {
    border-color: var(--color-brass);
    background: rgba(184, 134, 11, 0.1);
}

.command-selector-item.land,
.command-selector-item.naval,
.command-selector-item.air {
    /* Intentionally no colored left-border — it clashes with unit composition colors */
}

.command-selector-name {
    font-weight: bold;
    font-size: 1em;
    margin-bottom: 2px;
    color: var(--color-text-dark);
}

.command-selector-location {
    font-size: 0.85em;
    color: var(--color-text-medium);
}

.command-selector-units {
    font-size: 0.8em;
    color: var(--color-text-light);
    margin-top: 2px;
}

/* ============================================
   Destination Selector Modal
   ============================================ */
.dest-section {
    margin-bottom: 12px;
}

.dest-section-header {
    font-weight: bold;
    font-size: 0.85em;
    color: var(--color-olive-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-display);
}

.dest-item {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 4px;
    font-size: 0.9em;
    transition: all 0.15s ease;
    background: var(--color-parchment-light);
}

.dest-item:hover {
    border-color: var(--color-brass);
    background: rgba(184, 134, 11, 0.1);
}

.dest-item.stay {
    background: rgba(240, 228, 193, 0.5);
    border-style: dashed;
}

.dest-item.extended {
    border-left: 3px solid #d4a017;
}

.dest-item.rail {
    border-left: 3px solid #5a7d6a;
}

.dest-id {
    font-weight: bold;
    color: var(--color-text-dark);
    margin-right: 4px;
}

.dest-tag {
    font-size: 0.75em;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    float: right;
}

.dest-tag.sea {
    background: rgba(85, 107, 47, 0.15);
    color: var(--color-olive-dark);
}

.dest-tag.rail {
    background: rgba(90, 125, 106, 0.15);
    color: #3d5c4a;
}

/* Destination modal with mini-map */
.dest-modal-with-map {
    max-width: 820px !important;
}

.dest-modal-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.dest-modal-map-panel {
    flex-shrink: 0;
}

.dest-modal-map-panel canvas {
    border: 2px solid var(--color-brass-dark);
    border-radius: 4px;
    display: block;
}

.dest-modal-list-panel {
    flex: 1;
    min-width: 0;
    max-height: 350px;
    overflow-y: auto;
}

/* Stack vertically on narrow screens */
@media (max-width: 700px) {
    .dest-modal-layout {
        flex-direction: column;
        align-items: stretch;
    }
    .dest-modal-map-panel canvas {
        width: 100%;
        height: auto;
    }
    .dest-modal-list-panel {
        max-height: 250px;
    }
}

/* ============================================
   Persistent Game Status Bar
   ============================================ */
.game-status-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    background: var(--color-bg-medium);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 13px;
    color: var(--color-parchment);
    font-family: var(--font-display);
    letter-spacing: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-status-separator {
    color: var(--color-border);
}

/* ============================================
   Phase 2/7 Order Submission Status Bar
   ============================================ */
.phase2-status-bar,
.phase7-status-bar {
    padding: 10px 20px;
    background: var(--color-bg-dark);
    border: 2px solid var(--color-brass-dark);
    border-radius: 4px;
}

.status-bar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
    font-size: 13px;
}

.status-bar-label {
    font-weight: 600;
    color: var(--color-brass-light);
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.status-bar-legend {
    color: var(--color-parchment-dark);
    font-size: 12px;
}

.phase2-status-flags,
.phase7-status-flags {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.status-flag {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: var(--color-parchment);
    border: 2px solid var(--color-border);
    border-radius: 3px;
    min-width: 80px;
    transition: all 0.3s ease;
}

.status-flag.submitted {
    border-color: var(--color-brass);
    background: var(--color-parchment-light);
    box-shadow: 0 0 6px rgba(184, 134, 11, 0.3);
}

.status-flag.pending {
    border-color: var(--color-bg-light);
    background: var(--color-bg-medium);
}

.status-flag.pending:not(.submitted):hover {
    border-color: var(--color-brass);
    background: var(--color-bg-light);
}

.status-flag.selected {
    border-color: var(--nation-color, var(--color-parchment));
    background: var(--color-bg-light);
    box-shadow: 0 0 0 2px var(--nation-color, var(--color-brass)), 0 0 10px rgba(184, 134, 11, 0.4);
}

.status-checkmark {
    font-size: 20px;
    margin-top: 4px;
}

.status-flag-emoji {
    font-size: 28px;
    margin: 4px 0;
}

.status-nation {
    font-size: 11px;
    text-align: center;
    margin-top: 2px;
    font-family: var(--font-body);
    font-weight: 600;
}

/* Ensure nation labels are readable against their flag background */
.status-flag.submitted .status-nation {
    color: var(--color-text-dark);
}

.status-flag.pending .status-nation {
    color: var(--color-parchment-dark);
}

.status-flag.selected .status-nation {
    color: var(--color-parchment-light);
}

/* ============================================
   Turn Order Bar
   ============================================ */
.turn-order-bar {
    padding: 10px 20px;
    background: rgba(232, 213, 163, 0.92);
    border: 2px solid var(--color-brass-dark);
    border-radius: 4px;
}

.turn-order-flags {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.turn-flag {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: var(--color-parchment-light);
    border: 2px solid var(--color-border);
    border-radius: 3px;
    min-width: 80px;
    transition: all 0.3s ease;
}

.turn-flag.active-turn {
    border: 3px solid var(--color-brass);
    box-shadow: 0 0 12px rgba(184, 134, 11, 0.5);
    transform: scale(1.1);
}

.turn-position {
    font-size: 0.8em;
    color: var(--color-text-medium);
    font-weight: bold;
    font-family: var(--font-display);
}

.turn-flag-emoji {
    font-size: 2em;
    margin: 4px 0;
    line-height: 1;
}

.turn-nation {
    font-size: 0.85em;
    color: var(--color-text-dark);
    font-weight: 600;
    margin-top: 2px;
    text-align: center;
    word-wrap: break-word;
    font-family: var(--font-body);
}

/* Turn Order Selection Modal */
.phase2-turn-selection {
    margin-bottom: 20px;
}

/* Bid ladder: each row wears its nation's colour, set inline by phase2.js */
.turn-order-bid-table-wrap {
    overflow-x: auto;
}

.turn-order-bid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    font-size: 0.95em;
}

.turn-order-bid-table thead th {
    padding: 4px 10px;
    text-align: left;
    font-family: var(--font-display);
    font-size: 0.8em;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-text-medium);
    border-bottom: 1px solid var(--color-border);
}

.turn-order-bid-table thead th:last-child,
.turn-order-bid-table td.bid-position {
    text-align: center;
}

.turn-order-bid-row td {
    padding: 8px 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.turn-order-bid-row td:first-child {
    border-radius: 3px 0 0 3px;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.turn-order-bid-row td:last-child {
    border-radius: 0 3px 3px 0;
    box-shadow: inset -1px 1px 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.18);
}

.turn-order-bid-row.picked {
    opacity: 0.75;
}

/* The nation on the clock gets a brass frame so the ladder shows whose move it is */
.turn-order-bid-row.choosing {
    outline: 2px solid var(--color-brass-light);
    outline-offset: -2px;
}

.turn-order-bid-row .bid-rank {
    font-family: var(--font-display);
    font-weight: bold;
    width: 1%;
    white-space: nowrap;
}

.turn-order-bid-row .bid-nation {
    font-weight: 600;
    white-space: nowrap;
}

.turn-order-bid-row .bid-flag {
    font-size: 1.4em;
    margin-right: 8px;
    vertical-align: -0.12em;
}

.turn-order-bid-row .bid-amount {
    white-space: nowrap;
}

.bid-position-badge {
    display: inline-block;
    min-width: 26px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.28);
    font-family: var(--font-display);
    font-weight: bold;
}

.bid-position-choosing {
    font-size: 0.85em;
    font-style: italic;
    opacity: 0.9;
}

/* Whose turn it is to pick */
.turn-order-active-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 18px 0 12px 0;
    padding: 10px 16px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 0 0 2px var(--color-brass-dark);
}

.turn-order-active-flag {
    font-size: 2.1em;
    line-height: 1;
}

.turn-order-active-nation {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.15em;
    letter-spacing: 1px;
}

.turn-order-active-hint {
    margin: 2px 0 0 0;
    font-size: 0.82em;
    opacity: 0.85;
}

.turn-order-position-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.btn-position {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-position.open {
    background: var(--color-parchment-light);
    color: var(--color-text-dark);
}

.btn-position.taken {
    cursor: not-allowed;
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.btn-position-num {
    font-family: var(--font-display);
    font-size: 0.85em;
    letter-spacing: 1px;
}

.btn-position-flag {
    font-size: 1.9em;
    line-height: 1.1;
}

/* An open slot shows its ordinal; hovering previews the flag of the nation
   about to claim it. Both glyphs share the row so the tile height is stable. */
.btn-position-ordinal {
    font-family: var(--font-display);
    font-size: 1.9em;
    line-height: 1.1;
    color: var(--color-brass-dark);
}

.btn-position.open .btn-position-flag,
.btn-position.open:hover .btn-position-ordinal {
    display: none;
}

.btn-position.open:hover .btn-position-flag {
    display: block;
}

.btn-position-owner {
    font-size: 0.75em;
    text-align: center;
    word-break: break-word;
}

.btn-position.open .btn-position-owner {
    color: var(--color-text-medium);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-position:not([disabled]):hover {
    border-color: var(--color-brass);
    box-shadow: 0 0 10px rgba(184, 134, 11, 0.5);
    transform: scale(1.05);
}

.btn-position[disabled] {
    opacity: 0.85;
}

/* An open slot shown to a player who is not choosing: no flag preview. */
.btn-position.open[disabled] {
    cursor: not-allowed;
}

.btn-position.open[disabled]:hover .btn-position-ordinal {
    display: block;
}

/* Phone widths: shrink the ladder so all four columns still fit the modal */
@media (max-width: 480px) {
    .turn-order-bid-table {
        font-size: 0.8em;
    }
    .turn-order-bid-row td {
        padding: 6px 5px;
    }
    .turn-order-bid-row .bid-flag {
        margin-right: 4px;
    }
    .turn-order-bid-row .bid-nation {
        white-space: normal;
    }
    .turn-order-position-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }
}

/* ============================================
   Form Elements (selects, inputs in game)
   ============================================ */
#nation-select {
    font-family: var(--font-body);
    background: var(--color-parchment-light);
    border: 2px solid var(--color-border);
    border-radius: 3px;
    color: var(--color-text-dark);
    padding: 8px;
    font-size: 14px;
}

#nation-select:focus {
    outline: none;
    border-color: var(--color-brass);
    box-shadow: 0 0 4px rgba(184, 134, 11, 0.3);
}

/* ============================================
   Bug Report
   ============================================ */
.btn-bug-report {
    padding: 8px 20px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.btn-bug-report:hover {
    opacity: 1;
}

/* ============================================
   Rules Reference Overlay
   ============================================ */
.rules-ref-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg-dark);
    z-index: 10000;
    overflow-y: auto;
}

.rules-ref-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 30px 40px;
}

.rules-ref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 25px;
    border-bottom: 3px solid var(--color-brass-dark);
}

.rules-ref-header h2 {
    font-family: var(--font-display);
    color: var(--color-parchment);
    letter-spacing: 3px;
    text-transform: uppercase;
    font-size: 1.8em;
    margin: 0;
}

.rules-ref-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-rules-download {
    text-decoration: none;
    display: inline-block;
    padding: 10px 20px;
    font-size: 13px;
}

.btn-rules-ref {
    padding: 8px 20px;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.btn-rules-ref:hover {
    opacity: 1;
}

.rules-ref-body {
    color: var(--color-parchment);
    line-height: 1.7;
    font-size: 14px;
}

.rules-ref-body h3 {
    font-family: var(--font-display);
    color: var(--color-brass-light);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 1.3em;
    margin: 35px 0 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-bg-light);
}

.rules-ref-body h4 {
    font-family: var(--font-display);
    color: var(--color-parchment-light);
    font-size: 1.05em;
    margin: 20px 0 8px;
    letter-spacing: 1px;
}

.rules-ref-body p {
    margin: 8px 0;
    color: var(--color-parchment-dark);
}

.rules-ref-body ul, .rules-ref-body ol {
    margin: 8px 0 8px 20px;
    color: var(--color-parchment-dark);
}

.rules-ref-body li {
    margin: 4px 0;
}

.rules-ref-body strong {
    color: var(--color-parchment-light);
}

.rules-ref-section {
    background: var(--color-bg-medium);
    border: 1px solid var(--color-bg-light);
    border-radius: 4px;
    padding: 20px;
    margin: 15px 0;
}

.rules-ref-phase {
    background: var(--color-bg-medium);
    border-left: 4px solid var(--color-olive);
    border-radius: 0 4px 4px 0;
    padding: 15px 20px;
    margin: 12px 0;
}

.rules-ref-phase-title {
    font-family: var(--font-display);
    color: var(--color-olive-light);
    font-size: 1.1em;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.rules-ref-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.rules-ref-table th {
    background: var(--color-bg-light);
    color: var(--color-parchment-light);
    padding: 8px 12px;
    text-align: left;
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85em;
    border-bottom: 2px solid var(--color-brass-dark);
}

.rules-ref-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-bg-light);
    color: var(--color-parchment-dark);
}

.rules-ref-table tr:hover td {
    background: rgba(85, 107, 47, 0.1);
}

.rules-ref-tip {
    background: rgba(85, 107, 47, 0.15);
    border: 1px solid var(--color-olive-dark);
    border-radius: 4px;
    padding: 12px 16px;
    margin: 12px 0;
    font-size: 0.9em;
    color: var(--color-parchment-dark);
}

.rules-ref-tip strong {
    color: var(--color-olive-light);
}

.rules-ref-toc {
    list-style: none;
    margin: 0;
    padding: 0;
    column-count: 2;
    column-gap: 20px;
}

.rules-ref-toc li {
    margin: 4px 0;
}

.rules-ref-toc a {
    color: var(--color-brass-light);
    text-decoration: none;
    transition: color 0.2s;
}

.rules-ref-toc a:hover {
    color: var(--color-parchment-light);
    text-decoration: underline;
}

.bug-report-modal-content {
    max-width: 540px;
}

/* Claude opponent settings modal */
.claude-settings-modal-content {
    max-width: 560px;
}

.manage-players-modal-content {
    max-width: 640px;
}

/* Vacant-nation pause banner (game screen, under the top bar) */
.pause-banner {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    background: #fde8e8;
    border: 1px solid #b00020;
    color: #7a0015;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.9em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    max-width: 90%;
    text-align: center;
}

#claude-settings-body {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.claude-side-panel {
    flex: 1 1 220px;
    border: 1px solid var(--color-olive-dark, #6b6b47);
    border-radius: 6px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.03);
}

.claude-side-panel h4 {
    margin: 0 0 10px 0;
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--color-olive-dark, #6b6b47);
}

.claude-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.claude-setting-row label {
    font-weight: bold;
    font-size: 0.85em;
    color: var(--color-text-medium, #555);
}

.claude-setting-row select {
    flex: 1;
    max-width: 160px;
    padding: 4px 6px;
    font-size: 0.85em;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.claude-setting-row button {
    width: 100%;
    font-size: 0.82em;
}

.claude-side-status {
    font-size: 0.8em;
    color: var(--color-text-medium, #555);
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.bug-report-info {
    color: var(--color-text-medium);
    font-size: 0.9em;
    margin-bottom: 16px;
    line-height: 1.5;
}

.bug-report-label {
    display: block;
    font-weight: bold;
    color: var(--color-olive-dark);
    font-family: var(--font-display);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.bug-report-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--color-parchment-light);
    color: var(--color-text-dark);
}

.bug-report-input:focus,
.bug-report-textarea:focus {
    outline: none;
    border-color: var(--color-brass);
    box-shadow: 0 0 4px rgba(184, 134, 11, 0.3);
}

.bug-report-textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--color-parchment-light);
    color: var(--color-text-dark);
    resize: vertical;
}

.bug-report-context {
    padding: 8px 12px;
    background: rgba(240, 228, 193, 0.5);
    border-radius: 3px;
    border: 1px solid rgba(139, 125, 86, 0.3);
    margin-bottom: 16px;
    font-size: 0.85em;
    color: var(--color-text-medium);
}

.bug-report-context-label {
    font-weight: bold;
    color: var(--color-olive-dark);
    margin-right: 6px;
}

.bug-report-actions {
    display: flex;
    gap: 10px;
}

.btn-bug-submit {
    flex: 1;
    margin-bottom: 0;
}

.bug-report-actions .btn-secondary {
    flex: 0;
    white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Collapsible "Advanced Options" in game setup
   ------------------------------------------------------------------------- */
#setup-advanced-options summary::-webkit-details-marker {
    display: none;
}

#setup-advanced-options[open] .advanced-options-caret {
    transform: rotate(90deg);
}

/* -------------------------------------------------------------------------
   Players & nations (game/players.js): the roster and nation table shared by
   the setup screen and the Manage Players modal
   ------------------------------------------------------------------------- */
.players-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 8px 10px;
    margin-bottom: 10px;
}

.players-panel-title,
.nation-assign-group-title {
    font-weight: bold;
    font-size: 0.85em;
    color: #444;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.players-panel-title {
    margin-bottom: 6px;
}

.players-roster-list {
    list-style: none;
    margin: 0 0 8px 0;
    padding: 0;
}

.players-roster-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.9em;
    border-bottom: 1px dotted #e6e6e6;
}

.players-roster-entry:last-child {
    border-bottom: none;
}

.players-roster-name {
    font-weight: bold;
    overflow-wrap: anywhere;
}

.players-roster-detail {
    margin-left: auto;
    color: #777;
    font-size: 0.85em;
    white-space: nowrap;
}

/* Presence: green online, red offline (as on the HUD flags), hollow for an
   invited player who holds no nation yet and so cannot be in the game. */
.players-presence {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bbb;
}

.players-presence.online { background: #2e9d3a; }
.players-presence.offline { background: #b00020; }
.players-presence.pending { background: transparent; box-shadow: inset 0 0 0 1px #888; }

.players-remove {
    flex: none;
    border: none;
    background: none;
    color: #999;
    font-size: 1.15em;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.players-remove:hover,
.players-remove:focus-visible {
    color: #b00020;
}

.players-invite {
    display: flex;
    gap: 6px;
}

.players-invite input {
    flex: 1;
    min-width: 0;
    padding: 5px 6px;
    font-size: 0.85em;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.players-invite .btn-secondary {
    font-size: 0.8em;
    padding: 4px 10px;
}

.players-message {
    margin: 6px 0 0 0;
    font-size: 0.8em;
    color: #3d6b35;
}

.players-message.error {
    color: #b00020;
}

.players-hint {
    margin: 6px 0 0 0;
    font-size: 0.78em;
    color: #888;
}

/* Bulk menus are actions: picking a controller applies it to every nation in
   the group, then the menu resets to "Assign all…". */
.nation-assign-bulk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8em;
    color: #555;
}

.nation-assign-bulk select {
    padding: 2px 4px;
    font-size: 1em;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.nation-assign-group {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #ddd;
}

.nation-assign-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.nation-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.nation-assign-row.vacant {
    background: #fde8e8;
    border-radius: 4px;
    padding: 3px 4px;
}

.nation-assign-flag {
    flex: none;
    width: 24px;
    text-align: center;
}

.nation-assign-name {
    flex: none;
    width: 120px;
    font-size: 0.9em;
    font-weight: 500;
}

.nation-assign-row select {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.85em;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.nation-assign-vacant {
    font-size: 0.75em;
    font-weight: bold;
    color: #b00020;
    background: #fde8e8;
    border-radius: 3px;
    padding: 1px 5px;
}

/* Phones: the nation's menu drops under its name instead of squeezing it. */
@media (max-width: 600px) {
    .nation-assign-row {
        flex-wrap: wrap;
    }

    .nation-assign-name {
        flex: 1;
        width: auto;
    }

    .nation-assign-row select {
        flex-basis: 100%;
    }
}

/* ===== Tutorial mode ===== */

/* Tutorial modals stack above every other overlay (phase summaries, turn
   order selection) so the instructions always read first. */
.tutorial-overlay {
    z-index: 10050;
}

.tutorial-content {
    max-width: 640px;
    border-color: #4a90d9;
    box-shadow:
        0 0 0 1px #6faee6,
        0 10px 40px rgba(0, 0, 0, 0.5);
}

.tutorial-badge {
    display: inline-block;
    background: #4a90d9;
    color: #fff;
    font-size: 0.72em;
    font-weight: bold;
    letter-spacing: 2px;
    padding: 3px 10px;
    border-radius: 3px;
    margin-bottom: 10px;
}

.tutorial-content p,
.tutorial-content li {
    line-height: 1.5;
}

.tutorial-content ul,
.tutorial-content ol {
    margin: 10px 0;
    padding-left: 22px;
}

.tutorial-order-list li {
    margin-bottom: 8px;
}

.tutorial-why {
    font-size: 0.88em;
    color: #4a4a3a;
}

/* Reference tables inside tutorial cards (casualty points, CP → stress
   conversion, homeland zone penalties). */
.tutorial-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9em;
}

.tutorial-table th,
.tutorial-table td {
    border: 1px solid #d5d0c0;
    padding: 5px 8px;
    text-align: left;
    vertical-align: top;
}

.tutorial-table thead th {
    background: rgba(74, 144, 217, 0.12);
}

.tutorial-table-num {
    text-align: center;
    white-space: nowrap;
}

/* The CP → stress chart is a wide two-row grid; shrink it to fit the modal. */
.tutorial-table-wide {
    font-size: 0.82em;
}

.tutorial-table-wide th,
.tutorial-table-wide td {
    padding: 4px 5px;
}

.tutorial-zone-cell {
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
}

/* Homeland Status Track: colored zone chips, White → Gray. */
.tutorial-zone-track {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 12px 0;
}

.tutorial-zone-chip {
    display: inline-block;
    padding: 3px 9px;
    border: 1px solid #b0aa98;
    border-radius: 10px;
    font-size: 0.85em;
    font-weight: bold;
    color: #2a2a22;
}

.tutorial-zone-arrow {
    color: #888;
    font-size: 0.85em;
}

.tutorial-requirement {
    margin-top: 15px;
    padding: 10px 12px;
    background: rgba(74, 144, 217, 0.12);
    border-left: 4px solid #4a90d9;
    border-radius: 3px;
    font-size: 0.92em;
}

.tutorial-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.tutorial-nav .btn-primary {
    margin-left: auto;
}

.tutorial-page-dots {
    color: #777;
    font-size: 0.85em;
}

/* Movement-example galleries in the Phase 2 tutorial cards: side by side on
   desktop, stacked into a vertical scroll on narrow screens. */
.tutorial-examples {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 12px 0;
}

.tutorial-example {
    flex: 1 1 0;
    min-width: 150px;
    max-width: 220px;
    margin: 0;
    text-align: center;
}

.tutorial-example img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #6faee6;
    border-radius: 4px;
}

.tutorial-example figcaption {
    margin-top: 6px;
    font-size: 0.82em;
    color: #4a4a3a;
}

/* Caveat line under a movement-example gallery (e.g. the one-space limit on
   going ashore). */
.tutorial-example-note {
    margin: -2px 0 0;
    text-align: center;
    font-size: 0.85em;
    color: #4a4a3a;
}

@media (max-width: 600px) {
    .tutorial-examples {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: center;
    }

    .tutorial-example {
        width: 100%;
        max-width: 280px;
    }
}

#tutorial-guide-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 9500;
    background: #4a90d9;
    color: #fff;
    border: 1px solid #2f6cab;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

#tutorial-guide-btn:hover {
    background: #3a7fc4;
}

/* ============================================
   Ares Analyzer (viewer add-on; see game/ares.js)
   Everything below is inert outside Ares mode: the transport bar stays
   display:none until ares.js shows it, the policy panel div stays empty,
   and the body.ares-mode rules only fire when ares.js adds that class.
   ============================================ */

/* -- Lobby branding -- */
.ares-lobby-subtitle {
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.85em;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: var(--color-brass-dark);
    margin-bottom: 10px;
}

/* -- Phase playback transport bar: floating strip centered under the HUD
      top bar, matching its aesthetics -- */
.ares-transport-bar {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: linear-gradient(180deg, rgba(44, 44, 30, 0.92) 0%, rgba(44, 44, 30, 0.8) 100%);
    border: 1px solid var(--color-brass-dark);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    z-index: 46;
}

/* Phase 0 hides all HUD chrome; the transport only applies from Phase 1 on
   anyway (ares.js also gates on phase), so hide it with the rest. */
.game-layout.game-setup-mode .ares-transport-bar {
    display: none !important;
}

.ares-transport-btn {
    padding: 3px 10px;
    background: var(--color-bg-medium);
    color: var(--color-parchment);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.2s;
}

.ares-transport-btn:hover:not(:disabled) {
    background: var(--color-bg-light);
    border-color: var(--color-brass);
}

.ares-transport-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.ares-transport-mode {
    color: var(--color-parchment);
    font-family: var(--font-body);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ares-transport-pos {
    color: var(--color-brass-light);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: bold;
}

/* -- Intel drawer takeover: the policy trace replaces the phase hint and
      pact status blocks (territory info below stays available) -- */
body.ares-mode #phase-action-block,
body.ares-mode #hud-info-panel #sjnap-status,
body.ares-mode #hud-info-panel #ssnap-status,
body.ares-mode #hud-info-panel #stalin-doctrine-status {
    display: none !important;
}

/* In Ares the Intel drawer IS the analyzer's main surface, and the MAJOR-012
   bundle table carries the full value vector in-table (no tooltips) — give
   it real width. Ares-mode only: the ordinary game's Information drawer
   keeps its 360px. */
body.ares-mode #hud-info-panel {
    width: min(1180px, calc(100vw - 24px));
}

/* Turn-order flags become trace selectors in Ares mode */
.turn-flag.ares-clickable {
    cursor: pointer;
}

.turn-flag.ares-clickable:hover {
    border-color: var(--color-brass);
    box-shadow: 0 0 8px rgba(184, 134, 11, 0.4);
}

/* -- Policy panel -- */
.ares-panel-title {
    font-family: var(--font-display);
    font-size: 0.95em;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--color-olive-dark);
    margin-bottom: 6px;
}

.ares-nation-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.ares-nation-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: var(--color-parchment-light);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: 10px;
    color: var(--color-text-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.ares-nation-chip:hover {
    border-color: var(--color-brass);
}

.ares-nation-chip.selected {
    background: var(--color-olive-dark);
    color: var(--color-parchment-light);
    border-color: var(--color-brass);
    box-shadow: 0 0 0 1px var(--color-brass);
}

.ares-pager {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.ares-pager-btn {
    padding: 2px 8px;
    background: var(--color-parchment-light);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--color-text-dark);
    cursor: pointer;
}

.ares-pager-btn:hover {
    border-color: var(--color-brass);
}

.ares-pager-label {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text-dark);
}

.ares-live-btn.active {
    background: var(--color-olive-dark);
    color: var(--color-parchment-light);
    border-color: var(--color-brass);
}

.ares-empty {
    color: var(--color-text-medium);
    font-style: italic;
    font-size: 0.9em;
    margin: 10px 0;
}

.ares-jump-label {
    font-size: 11px;
    color: var(--color-text-medium);
    margin-bottom: 4px;
}

.ares-jump-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* -- Decision record cards -- */
.ares-record-card {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.35);
    margin: 10px 0;
    padding: 8px;
}

.ares-record-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 4px;
}

.ares-record-event {
    font-family: var(--font-body);
    font-weight: bold;
    font-size: 12px;
    color: var(--color-olive-dark);
}

.ares-record-meta {
    font-size: 10px;
    color: var(--color-text-medium);
}

.ares-section {
    margin-top: 8px;
}

.ares-section h5 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-text-medium);
    margin: 0 0 4px;
}

.ares-caption {
    font-size: 10px;
    color: var(--color-text-medium);
    margin: 2px 0 4px;
}

.ares-decision-headline {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text-dark);
    margin-bottom: 3px;
}

/* -- Trace tables (candidates, ranking, fill, baskets, placements...) --
      Scroll inside their own wrapper so 200-500 row tables stay usable
      within the drawer body. -- */
.ares-table-wrap {
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--color-border-light);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.25);
}

.ares-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--color-text-dark);
}

.ares-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-parchment-dark);
    text-align: left;
    padding: 3px 6px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.ares-table td {
    padding: 2px 6px;
    border-bottom: 1px solid rgba(139, 125, 86, 0.25);
    white-space: nowrap;
}

.ares-table th.num,
.ares-table td.num {
    text-align: right;
}

/* Long-text cells (bundle members, valuation detail) break lines instead of
   stretching the row into a horizontal scroll. */
.ares-table td.wrap {
    white-space: normal;
    overflow-wrap: anywhere;
    min-width: 150px;
    max-width: 320px;
}

.ares-table tr.ares-row-chosen {
    background: rgba(184, 134, 11, 0.28);
    font-weight: bold;
}

.ares-table tr.ares-row-rejected {
    opacity: 0.45;
}

.ares-table tr.ares-row-dim {
    opacity: 0.65;
}

.ares-badge-rail {
    display: inline-block;
    padding: 0 3px;
    margin-left: 4px;
    border-radius: 2px;
    background: var(--color-olive);
    color: var(--color-parchment-light);
    font-size: 9px;
    letter-spacing: 1px;
    vertical-align: middle;
}

/* -- Key-value cards -- */
.ares-kv {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--color-text-dark);
}

.ares-kv-row {
    display: flex;
    gap: 6px;
    padding: 1px 0;
    align-items: baseline;
}

.ares-kv-key {
    color: var(--color-text-medium);
    min-width: 110px;
    flex-shrink: 0;
}

.ares-kv-value {
    word-break: break-word;
}

/* -- Raw JSON fallbacks -- */
.ares-raw {
    margin-top: 6px;
    font-size: 10px;
    color: var(--color-text-medium);
}

.ares-raw summary {
    cursor: pointer;
}

.ares-raw pre {
    max-height: 240px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid var(--color-border-light);
    border-radius: 3px;
    padding: 6px;
    font-size: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* -- Footnote for pure-rule AI decisions (no trace records) -- */
.ares-footnote {
    margin-top: 12px;
    padding-top: 6px;
    border-top: 1px dashed var(--color-border-light);
    font-size: 10px;
    color: var(--color-text-medium);
}

.ares-footnote .ares-rule-item {
    margin-top: 2px;
    padding-left: 8px;
}
