/* ── Welcome page ────────────────────────────────────────────────────────────── */

.welcome-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(74,144,212,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(212,74,74,0.06) 0%, transparent 60%),
        var(--bg);
}

.welcome-card {
    width: 420px;
    padding: 48px 40px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

.welcome-logo {
    text-align: center;
    margin-bottom: 36px;
}

.welcome-logo h1 {
    font-size: 3.2rem;
    letter-spacing: 0.04em;
    color: var(--gold);
    text-shadow: 0 0 30px rgba(212,168,64,0.4);
    font-weight: normal;
    margin-bottom: 8px;
}

.welcome-logo .subtitle {
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.new-game-form .form-group {
    margin-bottom: 22px;
}

.mode-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
}

.mode-tabs .tab {
    flex: 1;
    padding: 9px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: 'Georgia', serif;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.05em;
}

.mode-tabs .tab.active {
    background: var(--gold-dim);
    color: var(--gold);
}

.mode-tabs .tab:first-child {
    border-right: 1px solid var(--border);
}

.preset-desc {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
    line-height: 1.4;
    min-height: 2.4em;
}

.size-options {
    display: flex;
    gap: 20px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.radio-option input[type="radio"] {
    accent-color: var(--gold);
    width: 15px;
    height: 15px;
}

/* ── Game page layout ────────────────────────────────────────────────────────── */

.game-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* ── Top bar ─────────────────────────────────────────────────────────────────── */

#top-bar {
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 24px;
    z-index: 10;
}

#top-bar .game-title {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    color: var(--gold);
    font-weight: normal;
    flex: 0 0 auto;
}

#top-bar .turn-badge {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    flex: 0 0 auto;
}

#top-bar .turn-badge span {
    color: var(--text);
    font-size: 0.9rem;
}

#top-bar .player-stats {
    display: flex;
    align-items: center;
    gap: 32px;
    flex: 1;
    justify-content: flex-end;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.stat-block.right {
    align-items: flex-end;
}

.stat-name {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-values {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.stat-values span {
    color: var(--text);
    font-weight: bold;
}

.vs-divider {
    font-size: 0.75rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

/* ── Main layout ─────────────────────────────────────────────────────────────── */

#main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ── Map ─────────────────────────────────────────────────────────────────────── */

#map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #1e5a9e;
}

/* Canvas fills the container — Voronoi territories painted here */
#map-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* SVG floats on top; pointer-events:none so clicks fall through to canvas */
#map-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
}

/* Resolving overlay */
#resolving-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10,10,20,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

#resolving-overlay.hidden { display: none; }

.resolving-msg {
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* Game over overlay */
#gameover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10,10,20,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 30;
    gap: 16px;
}

#gameover-overlay.hidden { display: none; }

.gameover-title {
    font-size: 3rem;
    letter-spacing: 0.25em;
    font-weight: normal;
}

.gameover-subtitle {
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

/* ── Side panel ──────────────────────────────────────────────────────────────── */

#side-panel {
    flex: 0 0 272px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

.panel-section {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 10px;
}

/* Region info */
#region-info .region-name {
    font-size: 1rem;
    color: var(--gold);
    margin-bottom: 6px;
}

#region-info .region-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
}

#region-info .region-row span:last-child {
    color: var(--text);
}

#region-info .no-selection {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
}

/* Pending moves */
#moves-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.move-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}

.move-arrow {
    color: var(--gold);
    flex: 0 0 auto;
}

.move-regions {
    flex: 1;
    color: var(--text-dim);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.move-regions b {
    color: var(--text);
}

.move-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
    flex: 0 0 auto;
    line-height: 1;
    transition: color 0.15s;
}

.move-remove:hover {
    color: var(--danger);
}

.no-moves-msg {
    padding: 12px 16px;
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
}

/* Combat log */
#combat-log {
    max-height: 180px;
    overflow-y: auto;
    padding: 0;
}

.log-entry {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-dim);
}

.log-entry .log-outcome {
    font-weight: bold;
}

.log-entry .log-outcome.won { color: var(--success); }
.log-entry .log-outcome.lost { color: var(--danger); }

/* ── Bottom bar ──────────────────────────────────────────────────────────────── */

#bottom-bar {
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    gap: 12px;
    z-index: 10;
}

#bottom-bar .move-hint {
    flex: 1;
    font-size: 0.78rem;
    color: var(--text-dim);
    font-style: italic;
}

#abandon-btn, #download-campaign, #offer-draw, #resign-btn {
    flex: 0 0 auto;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    font-family: 'Georgia', serif;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

#abandon-btn:hover { color: var(--danger); border-color: var(--danger); }
#abandon-btn:disabled, #download-campaign:disabled, #offer-draw:disabled, #resign-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#end-turn-btn {
    flex: 0 0 160px;
    padding: 12px;
    background: var(--gold);
    color: #1a1000;
    border: none;
    font-family: 'Georgia', serif;
    font-size: 0.88rem;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

#end-turn-btn:hover { background: #e0b848; }
#end-turn-btn:active { transform: scale(0.98); }
#end-turn-btn:disabled {
    background: #3a3a28;
    color: #666;
    cursor: not-allowed;
    transform: none;
}

/* ── Summary page ────────────────────────────────────────────────────────────── */

.summary-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.summary-card {
    width: 480px;
    padding: 56px 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    text-align: center;
    box-shadow: 0 0 80px rgba(0,0,0,0.7);
}

.summary-result {
    font-size: 3.5rem;
    letter-spacing: 0.3em;
    font-weight: normal;
    margin-bottom: 8px;
}

.summary-result.victory { color: var(--gold); text-shadow: 0 0 40px rgba(212,168,64,0.5); }
.summary-result.defeat  { color: var(--p2);   text-shadow: 0 0 40px rgba(212,74,74,0.3); }

.summary-winner {
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    margin-bottom: 36px;
}

.summary-stats {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    margin-bottom: 32px;
}

.summary-stat {
    flex: 1;
    padding: 16px;
    border-right: 1px solid var(--border);
}

.summary-stat:last-child { border-right: none; }

.summary-stat-val {
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 4px;
}

.summary-stat-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* Legend */
.map-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(13,13,26,0.85);
    border: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    z-index: 5;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

/* The camera moves only the map, leaving controls and panels in place. */
#map-world {
    position: absolute;
    inset: 0;
    transform-origin: 0 0;
    touch-action: none;
    user-select: none;
}
#map-canvas { touch-action: none; user-select: none; }
#map-container.is-panning #map-canvas { cursor: grabbing !important; }
#map-container:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.map-navigation {
    max-width: calc(100% - 24px);
    flex-wrap: wrap;
    justify-content: flex-end;
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: rgba(22, 28, 37, .93);
    border: 1px solid #536064;
    border-radius: 5px;
    z-index: 5;
}
.map-navigation button {
    min-width: 34px;
    min-height: 34px;
    padding: 4px 9px;
    border: 0;
    background: transparent;
    color: #f0e8d0;
    cursor: pointer;
    font: 14px Arial, sans-serif;
}
.map-navigation button:hover:not(:disabled) { background: #384950; }
.map-navigation button:disabled { opacity: .35; cursor: default; }
.map-navigation button:focus-visible { outline: 2px solid var(--gold); }
#map-zoom-level { min-width: 46px; text-align: center; font: 12px Arial, sans-serif; color: #c3ccce; }
#map-navigation-help {
    position: absolute;
    top: 61px;
    right: 12px;
    max-width: calc(100% - 24px);
    margin: 0;
    padding: 5px 8px;
    background: rgba(22, 28, 37, .85);
    color: #c3ccce;
    font: 11px Arial, sans-serif;
    pointer-events: none;
    z-index: 5;
}

/* Campaign tools and readable strategy feedback. */
.welcome-page { padding: 28px 12px; }
.welcome-card { width: min(480px, 100%); }
#saved-campaigns { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 22px; }
#saved-campaigns h2 { font-size: 1rem; font-weight: normal; color: var(--gold); }
.save-explainer { font: 12px/1.5 Arial,sans-serif; color: var(--text-dim); margin: 10px 0; }
#campaign-list { max-height: 280px; overflow: auto; }
.saved-campaign { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
    padding: 12px; margin-top: 8px; background: var(--surface-hi); border: 1px solid var(--border); color: var(--text); cursor: pointer; text-align: left; }
.saved-campaign:hover { border-color: var(--gold); }
.saved-campaign span { color: var(--text-dim); font-size: 12px; }
.campaign-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font: 12px/1.5 Arial,sans-serif; }
#campaign-title { display: block; width: 100%; color: #d7c8a5; overflow-wrap: anywhere; }
.campaign-tools button, #skip-replay { background: #26383f; border: 1px solid #546369; color: #e8e0d0; padding: 7px 10px; cursor: pointer; }
.rules-help { width: 100%; color: #aeb6b9; }
.rules-help summary, #campaign-timeline summary { cursor: pointer; color: var(--gold); }
.rules-help p { margin-top: 10px; }
#battle-forecast { font: 12px/1.5 Arial,sans-serif; color: #c5c9ca; }
#battle-forecast p { margin-top: 10px; }
#battle-forecast .forecast-odds { font-size: 17px; color: #e7cf94; }
#battle-forecast small { display: block; margin-top: 10px; color: #969e9f; }
#timeline-list { font: 12px/1.6 Arial,sans-serif; }
#timeline-list p { padding: 10px 0; border-bottom: 1px solid var(--border); }
#replay-controls { position: absolute; left: 16px; bottom: 54px; right: 16px; z-index: 15;
    display: flex; align-items: center; justify-content: space-between; gap: 15px;
    padding: 14px; color: #f0e6cf; background: rgba(20,29,35,.95); border: 1px solid #66716d; font: 13px/1.4 Arial,sans-serif; }
#replay-controls[hidden] { display: none; }
#save-status { color: #9daf9c; font: 11px Arial,sans-serif; max-width: 180px; }
#side-panel { overflow-y: auto; }
#review-campaign { margin-top: 20px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* Quiet atlas animation: no canvas redraws, and no motion when requested. */
@keyframes sea-drift { from { transform: translateX(-4px); opacity:.08; } to { transform: translateX(5px); opacity:.18; } }
.ocean-wave { animation:sea-drift 9s ease-in-out infinite alternate; }
.world-paused .ocean-wave { animation-play-state:paused; }
@media (prefers-reduced-motion:reduce) { .ocean-wave { animation:none; } }
.region-art { display:block; width:100%; height:80px; object-fit:cover; border-radius:4px; margin:0 0 12px; opacity:.82; }
#threat-description { color:#d3be97; line-height:1.5; }

.order-tools { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
.order-tools button { background:#292c38; border:1px solid #555568; color:#e7dfce; padding:7px 10px; border-radius:4px; cursor:pointer; }
.order-tools button:disabled { opacity:.4; cursor:default; }
.region-link { background:none; border:0; padding:0; color:#d9bd78; text-decoration:underline; text-underline-offset:3px; cursor:pointer; font:inherit; }
.battle-explanation { margin-top:10px; line-height:1.5; }
.battle-explanation summary { color:#d2c4a2; cursor:pointer; }
.battle-explanation ul { padding-left:18px; }
.battle-explanation p,.log-entry p { margin:7px 0; }
.battle-note,.battle-explanation small,#turn-recap small,#turn-movements small,#map-mode-legend { color:#aaaab7; line-height:1.5; }
#turn-recap p,#turn-movements p { line-height:1.6; margin:8px 0; }
#map-mode { width:100%; background:#292c38; color:#e7dfce; padding:7px; border:1px solid #555568; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

.campaign-tools label[for="map-mode"] { display:block; margin-top:12px; }

/* Only the active pane scrolls; the remaining section headings stay reachable. */
#side-panel { min-height:0; overflow-y:auto; }
.sidebar-section { display:flex; flex-direction:column; flex:0 0 auto; min-height:0; border-bottom:1px solid var(--border); }
.sidebar-section.is-expanded { flex:1 1 0; min-height:120px; }
.sidebar-heading { flex:0 0 auto; margin:0; font:inherit; }
.sidebar-toggle { display:flex; align-items:center; gap:6px; width:100%; min-height:42px; padding:12px 16px; border:0; background:transparent; color:var(--text-dim); text-align:left; font:11px/1.5 Arial,sans-serif; letter-spacing:.05em; cursor:pointer; }
.sidebar-toggle:hover { background:rgba(255,255,255,.04); color:var(--text); }
.sidebar-toggle[aria-expanded="true"] { color:var(--gold); background:rgba(212,168,64,.06); }
.sidebar-toggle:focus-visible { outline:2px solid var(--gold); outline-offset:-3px; }
.sidebar-chevron { margin-left:auto; font-size:18px; line-height:1; }
.sidebar-toggle[aria-expanded="true"] .sidebar-chevron { transform:rotate(90deg); }
.sidebar-turn { color:var(--text-dim); font-size:10px; }
.sidebar-body { flex:1 1 0; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:14px 16px; scrollbar-gutter:stable; }
.sidebar-body[hidden] { display:none; }
.sidebar-empty { color:var(--text-dim); font-size:13px; line-height:1.6; }
#side-panel #moves-list,#side-panel #combat-log { overflow:visible; max-height:none; flex:none; }
.sidebar-body .move-item,.sidebar-body .log-entry { padding:10px 0; }
.sidebar-body .order-tools { margin-top:0; margin-bottom:12px; }

.turn-battles-heading { margin-top:20px; padding-top:16px; border-top:1px solid var(--border); }

/* The compact inspector stays visible while other sections expand and scroll. */
.region-summary { position:sticky; top:0; z-index:2; flex:0 0 144px; height:144px; min-height:0; overflow-y:auto; padding:12px 16px; background:var(--surface); border-bottom:1px solid var(--border); scrollbar-gutter:stable; }
#region-info .region-name { margin:0 0 3px; font-size:14px; line-height:1.3; overflow-wrap:anywhere; }
.region-meta { font:11px/1.5 Arial,sans-serif; color:var(--text-dim); overflow-wrap:anywhere; }
.region-stats { display:flex; flex-wrap:wrap; gap:4px 12px; margin:6px 0 3px; font:11px/1.5 Arial,sans-serif; }
.region-stats b { color:var(--text); font-size:12px; }
.region-isolated { color:#e6a16a; }
#region-info .no-selection { margin:0; font-size:12px; }
.region-summary #battle-forecast .forecast-odds { font-size:13px; margin:7px 0 3px; }
.sidebar-section.is-expanded { min-height:90px; }

#campaign-replay-controls { position:absolute; bottom:55px; left:16px; right:16px; z-index:16; padding:12px; border:1px solid #66716d; border-radius:5px; background:rgba(20,29,35,.96); color:#eee5cf; font:12px/1.5 Arial,sans-serif; }
#campaign-replay-controls[hidden],#open-campaign-replay[hidden] { display:none; }
.campaign-replay-row { display:flex; align-items:center; gap:9px; flex-wrap:wrap; }
#campaign-replay-caption { flex:1; }
#campaign-replay-controls button { background:#293b40; color:#eee5cf; border:1px solid #647178; padding:7px 12px; cursor:pointer; }
#campaign-replay-controls button:disabled { opacity:.4; cursor:default; }
#campaign-replay-slider { width:100%; margin:12px 0 4px; accent-color:var(--gold); }
#campaign-replay-note { color:#b6bec0; }
#replay-campaign { margin-top:20px; }

/* Geographic campaign gallery: native radios support keyboard navigation. */
.welcome-card { width: min(940px, 100%); }
.map-picker { border: 0; min-width: 0; margin: 0 0 22px; }
.map-picker legend { color: var(--gold); margin-bottom: 12px; }
.map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.map-card { position: relative; display: flex; flex-direction: column; padding: 10px; border: 2px solid var(--border); border-radius: 8px; background: #131d27; cursor: pointer; transition: border-color .15s, background .15s; }
.map-card:hover { border-color: var(--text-dim); }
.map-card:has(input:checked) { border-color: var(--gold); background: #29271f; }
.map-card:has(input:focus-visible) { outline: 3px solid var(--p1); outline-offset: 3px; }
.map-card:has(input:disabled) { opacity: .65; cursor: wait; }
.map-card input { position: absolute; top: 10px; right: 10px; accent-color: var(--gold); width: 16px; height: 16px; }
.map-card img { width: 100%; height: auto; aspect-ratio: 5 / 3; object-fit: contain; border-radius: 4px; }
.map-card strong { margin: 8px 0 4px; font-size: .92rem; color: var(--text); }
.map-card span { font-size: .78rem; color: var(--text-dim); }
@media (max-width: 620px) { .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) { .map-grid { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
    .welcome-card { padding: 28px 18px; }
    .welcome-logo h1 { font-size: clamp(1.7rem, 7vw, 2.6rem); letter-spacing: .04em; }
    .map-card strong { font-size: .8rem; letter-spacing: .02em; overflow-wrap: anywhere; }
    .map-card span { font-size: .7rem; letter-spacing: .02em; }
}

#planning-preview { position: absolute; z-index: 8; max-width: min(280px, calc(100% - 16px)); padding: 10px 12px; border: 1px solid #d4a840; border-radius: 6px; background: rgba(15,22,30,.96); color: #fff1ce; font: 12px/1.5 Arial, sans-serif; pointer-events: none; box-shadow: 0 4px 16px #0006; }
.order-hit { pointer-events: stroke; cursor: crosshair; }
#map-world.is-planning .order-hit { cursor:var(--region-cursor,pointer); }
.order-hit:focus { stroke: #ffffff70; outline: none; }
.troop-projection { fill: #ffe09a; stroke: #14232e; stroke-width: 3px; paint-order: stroke; font: bold 11px Arial, sans-serif; }
.order-pulse { animation: order-pulse .55s ease-out both; }
.order-placed { animation: order-placed .3s ease-out both; }
@keyframes order-pulse { from { opacity: 1; } to { opacity: 0; stroke-width: 12px; } }
@keyframes order-placed { from { opacity: .15; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .order-pulse, .order-placed { animation: none; } }

#map-briefing { margin: 12px 0 20px; padding: 14px 16px; border-left: 3px solid var(--gold); background: #1b252c; font: 13px/1.6 Arial, sans-serif; }
#map-briefing p { margin: 0 0 8px; }
#map-briefing summary { cursor: pointer; color: var(--gold); }
#map-briefing a { display: inline-block; margin: 4px 16px 0 0; color: #b7d5ee; }
#battle-status { flex: 0 0 auto; padding: 8px 20px; border-bottom: 1px solid var(--border); background: #24271f; color: #e1d9bc; font: 12px/1.5 Arial, sans-serif; display: flex; gap: 8px 20px; flex-wrap: wrap; }
#battle-status[hidden] { display: none; }
#battle-title { color: var(--gold); }
#battle-rules { color: var(--text-dim); }
@media (max-width: 620px) { #battle-status { padding: 6px 10px; gap: 3px 12px; font-size: 11px; } #battle-rules { width: 100%; } }

@media (max-width: 700px) {
    .game-page { height: 100dvh; }
    #top-bar { flex: 0 0 auto; padding: 8px 10px; gap: 6px 16px; flex-wrap: wrap; }
    #top-bar .game-title { font-size: .85rem; }
    #top-bar .player-stats { flex: 1 1 100%; min-width: 0; gap: 10px; justify-content: space-between; }
    .stat-block { flex: 1; min-width: 0; }
    .stat-name { font-size: .6rem; overflow-wrap: anywhere; }
    .stat-values { font-size: .7rem; }
    #main { flex-direction: column; min-height: 0; overflow-y: auto; }
    #map-container { flex: 1 0 52dvh; min-height: 360px; }
    #side-panel { width: 100%; flex: 0 0 auto; overflow: visible; border-left: 0; border-top: 1px solid var(--border); }
    .sidebar-section.is-expanded { flex: 0 0 auto; min-height: 0; }
    .sidebar-body { flex: 0 0 auto; max-height: 50dvh; }
    .region-summary { max-height: 30dvh; padding: 8px 12px; }
    .map-navigation { top: 8px; right: 8px; }
    #map-navigation-help { display: none; }
    #bottom-bar { flex: 0 0 auto; display: grid; grid-template-columns: auto auto auto 1fr 1fr; grid-template-areas: "status status hint hint hint" "exit download resign draw next"; gap: 5px 4px; padding: 7px 10px; }
    #bottom-bar .move-hint { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .65rem; }
    #abandon-btn { grid-area: exit; }
    #download-campaign { grid-area: download; letter-spacing:0; }
    #resign-btn { grid-area: resign; letter-spacing: 0; }
    #offer-draw { grid-area: draw; letter-spacing: 0; }
    #end-turn-btn { grid-area: next; }
    #save-status { grid-area: status; }
    #move-hint { grid-area: hint; }
    #abandon-btn, #download-campaign, #offer-draw, #resign-btn, #end-turn-btn { padding: 9px 4px; font-size: .7rem; }
}
#battle-terrain-notes { font: 12px/1.5 Arial, sans-serif; color: var(--text-dim); }
#battle-terrain-notes summary { color: var(--gold); cursor: pointer; }
#battle-terrain-notes a { color: #9ec8e8; }

#download-campaign:hover { color:var(--gold); border-color:var(--gold); }
.download-status:not([hidden]) { position:fixed; z-index:30; left:12px; bottom:90px; max-width:min(420px,calc(100vw - 24px)); margin:0; padding:10px 14px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text); font:12px/1.5 Arial,sans-serif; box-shadow:0 4px 16px #0004; pointer-events:none; }
#completed-download-status { font:12px/1.5 Arial,sans-serif; color:var(--text-dim); }

.is-campaign-replay #draw-offer-status, .is-campaign-replay #offer-draw, .is-campaign-replay #resign-btn { display: none; }

#resign-btn:hover { color: var(--danger); border-color: var(--danger); }
