:root {
    --paper: #f3e7c9;
    --paper-deep: #d6c28a;
    --ink: #12151c;
    --ink-soft: #2d3142;
    --wash: rgba(23, 18, 13, 0.08);
    --wash-strong: rgba(23, 18, 13, 0.16);
    --bronze: #c58a3b;
    --bronze-soft: #e2b268;
    --red: #a12f1a;
    --red-glow: #ff6a3a;
    --green: #3f5c3d;
    --line: rgba(255, 215, 140, 0.22);
    --shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
    --bg-base: #0b1022;
    --bg-mid: #1a2244;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    height: 100%;
    background-color: var(--bg-base);
}

body {
    font-family: "STSong", "Songti SC", "Noto Serif SC", "SimSun", serif;
    color: var(--paper);
    position: relative;
    min-height: 100vh;
    height: 100%;
    overflow-x: hidden;
    background-color: var(--bg-base);
    background-image:
        url("./assets/bg-sanguo.png"),
        radial-gradient(ellipse at 50% 40%, rgba(255, 140, 60, 0.18), transparent 55%),
        radial-gradient(ellipse at 20% 85%, rgba(180, 80, 40, 0.22), transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(70, 120, 230, 0.25), transparent 60%),
        linear-gradient(180deg, #0a0f1e 0%, #111935 50%, #0a0f1e 100%);
    background-size: cover, auto, auto, auto, auto;
    background-position: center center, center, center, center, center;
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    background-attachment: fixed;
}

@media (aspect-ratio < 16/9) {
    body {
        background-size: cover, auto, auto, auto, auto;
    }
}

@media (aspect-ratio > 21/9) {
    body {
        background-size: cover, auto, auto, auto, auto;
    }
}

body.campaign-mode,
body.battle-mode {
    overflow: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(10, 15, 30, 0.2) 0%, transparent 35%, rgba(10, 15, 30, 0.35) 100%),
        radial-gradient(ellipse at 15% 50%, rgba(255, 140, 60, 0.12), transparent 45%),
        radial-gradient(ellipse at 85% 50%, rgba(255, 140, 60, 0.12), transparent 45%);
    mix-blend-mode: screen;
}

body::after {
    content: "";
    position: fixed;
    right: 0;
    bottom: 0;
    left: auto;
    top: auto;
    z-index: 1;
    width: 320px;
    height: 180px;
    pointer-events: none;
    background:
        linear-gradient(225deg,
            rgba(10, 15, 30, 0.98) 0%,
            rgba(10, 15, 30, 0.96) 20%,
            rgba(12, 18, 35, 0.88) 45%,
            rgba(16, 24, 48, 0.6) 70%,
            transparent 100%);
    filter: saturate(1.1);
}

button,
input,
select {
    font: inherit;
}

.app-shell {
    max-width: 1600px;
    margin: 0 auto;
    padding: 22px 28px 36px;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
    position: relative;
    z-index: 2;
}

#app {
    min-height: 0;
    position: relative;
    z-index: 2;
}

body.campaign-mode .app-shell,
body.battle-mode .app-shell {
    padding: 14px 20px 18px;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

body.campaign-mode #app,
body.battle-mode #app {
    max-height: 100%;
    height: 100%;
    overflow: hidden;
}

.topbar,
.panel,
.city-item,
.force-card,
.general-card,
.action-card,
.battle-cell {
    position: relative;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 10px 4px 0;
}

body.campaign-mode .topbar,
body.battle-mode .topbar {
    margin-bottom: 10px;
    padding-top: 6px;
}

.topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 190, 110, 0.45) 20%, rgba(255, 220, 150, 0.65) 50%, rgba(255, 190, 110, 0.45) 80%, transparent);
    opacity: 0.8;
}

.topbar h1,
.screen h2,
.screen h3 {
    margin: 0;
    font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
    letter-spacing: 0.08em;
}

.topbar h1 {
    font-size: clamp(2.2rem, 4.6vw, 3.6rem);
    color: var(--paper);
    text-shadow:
        0 1px 0 rgba(10, 15, 30, 0.5),
        0 0 12px rgba(255, 150, 70, 0.35),
        0 0 32px rgba(255, 120, 50, 0.18);
}

.subtitle,
.muted,
.body-copy,
.log-item,
.battle-hint-card,
.summary-note {
    color: rgba(243, 231, 201, 0.72);
}

.subtitle {
    margin-top: 6px;
    max-width: 880px;
    line-height: 1.8;
    color: rgba(243, 231, 201, 0.72);
}

.topbar-actions,
.footer-action,
.summary-stats,
.scenario-meta,
.tabs,
.badge-list,
.battle-header-actions,
.battle-actions,
.battle-layout,
.campaign-layout,
.city-panel-head,
.sidebar-head,
.selection-row,
.city-map-legend,
.action-form,
.battle-unit-tags,
.battle-info-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.screen {
    display: grid;
    gap: 18px;
    min-height: 0;
    height: 100%;
}

.center-screen {
    min-height: 60vh;
    place-items: center;
}

.panel {
    background:
        linear-gradient(180deg, rgba(24, 32, 60, 0.78) 0%, rgba(16, 22, 44, 0.9) 100%),
        radial-gradient(circle at top left, rgba(255, 150, 70, 0.12), transparent 45%);
    border: 1px solid rgba(255, 200, 120, 0.24);
    border-radius: 22px;
    padding: 20px;
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 230, 180, 0.12),
        inset 0 -1px 0 rgba(10, 15, 30, 0.4);
    overflow: hidden;
    color: var(--paper);
    backdrop-filter: blur(10px) saturate(1.15);
}

.panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 190, 110, 0.8) 20%, rgba(255, 230, 170, 0.95) 50%, rgba(255, 190, 110, 0.8) 80%, transparent 100%);
    pointer-events: none;
}

.panel::after {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(255, 220, 150, 0.1);
    border-radius: 18px;
    pointer-events: none;
}

.hero-panel,
.scenario-panel,
.campaign-summary,
.battle-header {
    padding: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 0.82rem;
    letter-spacing: 0.22em;
    color: var(--bronze-soft);
    text-shadow: 0 0 12px rgba(255, 150, 80, 0.35);
}

.ghost-button,
.primary-button,
.mini-button,
.tab-button,
.city-item,
.force-card,
.action-button,
.skill-button {
    border: 1px solid rgba(255, 200, 130, 0.28);
    background: linear-gradient(180deg, rgba(34, 44, 78, 0.8), rgba(24, 32, 62, 0.92));
    color: var(--paper);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.12);
}

.ghost-button,
.primary-button,
.mini-button,
.action-button,
.skill-button {
    border-radius: 999px;
    padding: 10px 18px;
}

.primary-button {
    background:
        linear-gradient(135deg, rgba(255, 140, 70, 0.95), rgba(180, 40, 30, 0.95));
    color: #fff7e6;
    border-color: transparent;
    box-shadow:
        0 12px 32px rgba(255, 100, 50, 0.28),
        inset 0 1px 0 rgba(255, 230, 180, 0.35);
}

.ghost-button:hover,
.primary-button:hover,
.mini-button:hover,
.tab-button:hover,
.city-item:hover,
.force-card:hover,
.action-button:hover,
.skill-button:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 220, 150, 0.55);
    box-shadow:
        0 14px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 230, 180, 0.22),
        0 0 20px rgba(255, 160, 90, 0.18);
}

.ghost-button[disabled],
.primary-button[disabled],
.mini-button[disabled],
.action-button[disabled],
.skill-button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.scenario-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    gap: 20px;
}

.scenario-copy,
.ink-panel,
.city-panel,
.command-panel,
.side-panel,
.battle-board-panel,
.battle-info-panel,
.battle-action-panel,
.battle-log-panel,
.city-sidebar {
    display: grid;
    gap: 16px;
}

.body-copy,
.narrative-list,
.log-item {
    line-height: 1.75;
}

.narrative-list {
    display: grid;
    gap: 10px;
}

.narrative-item {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255, 248, 230, 0.58);
    border: 1px dashed rgba(23, 18, 13, 0.14);
}

.scenario-meta,
.summary-stats,
.metrics-grid,
.battle-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.meta-card,
.stat-card,
.metric-card,
.battle-info-card {
    padding: 14px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(40, 52, 94, 0.82), rgba(24, 32, 60, 0.92));
    border: 1px solid rgba(255, 210, 140, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.08);
}

.meta-card span,
.stat-card span,
.metric-card span,
.battle-info-card span {
    display: block;
    font-size: 0.88rem;
    color: rgba(243, 231, 201, 0.7);
    color: rgba(243, 231, 201, 0.72);
}

.meta-card strong,
.stat-card strong,
.metric-card strong,
.battle-info-card strong {
    display: block;
    margin-top: 6px;
    font-size: 1.1rem;
    color: var(--paper);
    text-shadow: 0 0 12px rgba(255, 160, 90, 0.18);
}

.world-map {
    min-height: 420px;
    border-radius: 20px;
    border: 1px solid rgba(255, 200, 120, 0.22);
    background:
        radial-gradient(circle at 20% 20%, rgba(123, 32, 24, 0.08), transparent 24%),
        linear-gradient(180deg, rgba(255, 200, 120, 0.08), rgba(16, 22, 44, 0.3)),
        linear-gradient(180deg, #202a4e 0%, #182144 100%);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.08);
}

.world-map svg,
.city-map-card svg {
    width: 100%;
    height: 100%;
    display: block;
}

.force-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.force-card {
    padding: 18px;
    border-radius: 24px;
    text-align: left;
    display: grid;
    gap: 14px;
}

.force-card.active {
    background:
        linear-gradient(180deg, rgba(255, 140, 70, 0.22), rgba(180, 40, 30, 0.24)),
        linear-gradient(180deg, rgba(38, 50, 88, 0.9), rgba(22, 28, 56, 0.96));
    border-color: rgba(255, 180, 110, 0.6);
    box-shadow:
        0 18px 44px rgba(255, 100, 50, 0.2),
        0 0 26px rgba(255, 150, 80, 0.22);
}

.force-banner {
    height: 120px;
    border-radius: 20px;
    border: 1px solid rgba(255, 210, 140, 0.22);
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255, 160, 90, 0.22), rgba(16, 22, 44, 0.5));
}

.force-banner svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chip-row,
.battle-unit-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(255, 200, 130, 0.12);
    border: 1px solid rgba(255, 210, 140, 0.2);
    color: rgba(243, 231, 201, 0.85);
}

.footer-action {
    justify-content: space-between;
    align-items: center;
}

.campaign-screen {
    gap: 10px;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    grid-template-rows: auto 1fr;
    overflow: hidden;
}

.campaign-layout {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.grand-map-panel,
.command-panel {
    display: grid;
    gap: 10px;
    min-height: 0;
}

.grand-map-panel {
    height: 100%;
    min-height: 0;
    padding: 12px;
    overflow: hidden;
}

.grand-map-toolbar,
.map-toolbar-actions,
.campaign-title,
.city-panel-head,
.sidebar-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.map-toolbar-actions {
    align-items: stretch;
    justify-content: flex-end;
}

.focus-summary {
    min-width: 320px;
    max-width: 440px;
    padding: 10px 12px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(30, 40, 74, 0.86), rgba(20, 28, 56, 0.92));
    border: 1px solid rgba(255, 210, 140, 0.24);
    color: rgba(243, 231, 201, 0.82);
    line-height: 1.45;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.1);
}

.focus-summary strong {
    display: block;
    color: var(--paper);
    font-size: 1rem;
    text-shadow: 0 0 12px rgba(255, 160, 90, 0.25);
}

.focus-neighbors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.focus-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 200, 130, 0.14);
    border: 1px solid rgba(255, 210, 140, 0.22);
    color: rgba(243, 231, 201, 0.92);
    font-size: 0.76rem;
    line-height: 1.4;
}

.campaign-map-frame {
    position: relative;
    top: 0;
    min-height: 0;
    height: 100%;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(255, 210, 140, 0.26);
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 150, 80, 0.22), transparent 40%),
        radial-gradient(circle at 70% 80%, rgba(90, 150, 255, 0.18), transparent 50%),
        linear-gradient(180deg, rgba(22, 30, 60, 0.6), rgba(12, 18, 40, 0.9));
    box-shadow:
        inset 0 1px 0 rgba(255, 230, 180, 0.12),
        inset 0 -1px 0 rgba(10, 15, 30, 0.5);
}

.campaign-map-stage {
    min-height: 0;
    height: 100%;
}

.campaign-map-stage svg {
    width: 100%;
    height: 100%;
    display: block;
}

.map-corner-card {
    position: absolute;
    z-index: 2;
    min-width: 220px;
    max-width: 280px;
    padding: 12px 14px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(30, 40, 72, 0.9), rgba(18, 26, 52, 0.94));
    border: 1px solid rgba(255, 210, 140, 0.22);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 230, 180, 0.08);
    color: var(--paper);
    backdrop-filter: blur(8px);
}

.map-corner-card span {
    display: block;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    color: var(--bronze-soft);
    text-shadow: 0 0 10px rgba(255, 150, 80, 0.3);
}

.map-corner-card strong {
    display: block;
    margin-top: 6px;
    font-size: 0.98rem;
    line-height: 1.5;
    color: var(--paper);
}

.map-corner-card.top-left {
    top: 18px;
    left: 18px;
}

.map-corner-card.bottom-left {
    bottom: 18px;
    left: 18px;
}

.city-popup {
    position: absolute;
    z-index: 5;
    left: 60%;
    top: 44%;
    width: min(var(--popup-max-w, 440px), 54%);
    max-width: calc(100% - 24px);
    max-height: var(--popup-max-h, 80%);
    transform: none;
    pointer-events: none;
    contain: layout paint;
}

.city-popup-shell {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(30, 42, 78, 0.94), rgba(18, 26, 54, 0.98)),
        radial-gradient(circle at top left, rgba(255, 150, 80, 0.18), transparent 45%);
    border: 1px solid rgba(255, 210, 140, 0.28);
    box-shadow:
        0 28px 64px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 230, 180, 0.14),
        inset 0 0 0 1px rgba(255, 170, 100, 0.08);
    backdrop-filter: blur(12px) saturate(1.15);
    pointer-events: auto;
    overflow: auto;
    max-height: inherit;
    color: var(--paper);
}

.city-popup-shell::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 16px;
    border: 1px solid rgba(255, 220, 150, 0.12);
    pointer-events: none;
}

.city-popup-arrow {
    position: absolute;
    top: 26px;
    left: -10px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, rgba(30, 42, 78, 0.98), rgba(24, 34, 64, 0.98));
    border-left: 1px solid rgba(255, 210, 140, 0.22);
    border-bottom: 1px solid rgba(255, 210, 140, 0.22);
    transform: rotate(45deg);
    box-shadow: -6px 8px 18px rgba(0, 0, 0, 0.35);
}

.city-popup.flip-left .city-popup-arrow {
    left: auto;
    right: -10px;
    border-left: none;
    border-bottom: none;
    border-right: 1px solid rgba(255, 210, 140, 0.22);
    border-top: 1px solid rgba(255, 210, 140, 0.22);
}

.city-popup.flip-up .city-popup-arrow {
    top: auto;
    bottom: -10px;
}

.city-popup-head,
.compact-section {
    display: grid;
    gap: 8px;
}

.compact-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.compact-panel {
    gap: 10px;
}

.compact-tabs {
    gap: 8px;
}

.compact-tab-panel {
    max-height: 210px;
    overflow: auto;
    padding-right: 4px;
}

.compact-section .general-list {
    max-height: 146px;
    overflow: auto;
    padding-right: 4px;
}

.compact-roster {
    gap: 8px;
}

.compact-general-card {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(40, 52, 94, 0.86), rgba(24, 32, 60, 0.94));
    border: 1px solid rgba(255, 210, 140, 0.16);
    color: var(--paper);
}

.compact-general-card strong {
    font-size: 0.95rem;
    color: var(--paper);
}

.compact-general-meta,
.compact-general-skills {
    font-size: 0.82rem;
    color: rgba(243, 231, 201, 0.74);
    line-height: 1.5;
}

.map-command-deck.inline-mode,
.map-target-deck.inline-mode {
    position: static;
    width: 100%;
    display: grid;
    gap: 10px;
}

.command-deck-card,
.target-deck-card {
    position: relative;
    padding: 12px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(38, 50, 88, 0.86), rgba(22, 30, 58, 0.94));
    border: 1px solid rgba(255, 210, 140, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.08);
    overflow: hidden;
}

.command-deck-card::before,
.target-deck-card::before {
    content: "";
    position: absolute;
    inset: 7px;
    border-radius: 14px;
    border: 1px solid rgba(255, 220, 150, 0.08);
    pointer-events: none;
}

.command-deck-card::after,
.target-deck-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 18px;
    right: 18px;
    height: 3px;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(90deg, rgba(255, 180, 100, 0.85), rgba(220, 60, 40, 0.78));
}

.command-deck-card h4,
.target-deck-card h4,
.map-mini-title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
    letter-spacing: 0.08em;
    color: var(--paper);
}

.deck-row,
.deck-action-grid,
.route-form-grid,
.route-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.deck-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.deck-button,
.route-chip {
    border-radius: 999px;
    border: 1px solid rgba(255, 210, 140, 0.24);
    background:
        linear-gradient(180deg, rgba(48, 60, 102, 0.88), rgba(28, 36, 68, 0.96));
    color: var(--paper);
    padding: 8px 12px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.1);
}

.deck-button:hover,
.route-chip:hover {
    transform: translateY(-1px);
    box-shadow:
        0 10px 22px rgba(0, 0, 0, 0.4),
        0 0 18px rgba(255, 160, 90, 0.16);
    border-color: rgba(255, 220, 150, 0.52);
}

.deck-button.active,
.route-chip.active {
    background:
        linear-gradient(135deg, rgba(255, 160, 90, 0.36), rgba(220, 60, 40, 0.36));
    border-color: rgba(255, 200, 140, 0.62);
    box-shadow:
        0 10px 28px rgba(255, 100, 50, 0.22),
        inset 0 1px 0 rgba(255, 230, 180, 0.2);
}

.deck-button.primary {
    background:
        linear-gradient(135deg, rgba(255, 150, 70, 0.96), rgba(190, 45, 30, 0.96));
    color: #fff7e6;
    border-color: transparent;
    box-shadow:
        0 12px 28px rgba(255, 100, 50, 0.32),
        inset 0 1px 0 rgba(255, 230, 180, 0.34);
}

.deck-copy {
    font-size: 0.9rem;
    line-height: 1.6;
    color: rgba(243, 231, 201, 0.78);
    margin-top: 8px;
}

.route-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.map-inline-select,
.map-inline-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(255, 210, 140, 0.22);
    background:
        linear-gradient(180deg, rgba(46, 58, 100, 0.9), rgba(26, 34, 66, 0.96));
    padding: 9px 11px;
    color: var(--paper);
}

.deck-note {
    padding: 10px 12px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 120, 80, 0.12), rgba(200, 60, 40, 0.1));
    border: 1px dashed rgba(255, 180, 140, 0.32);
    color: rgba(243, 231, 201, 0.78);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 8px;
}

.map-log-panel {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 3;
    width: min(340px, calc(100% - 32px));
    max-height: 180px;
    padding: 14px 16px;
    background:
        linear-gradient(180deg, rgba(28, 38, 74, 0.92), rgba(16, 22, 48, 0.96));
    border: 1px solid rgba(255, 210, 140, 0.22);
    backdrop-filter: blur(8px);
    color: var(--paper);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.08), 0 20px 40px rgba(0, 0, 0, 0.5);
}

.map-log-panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 190, 120, 0.7), transparent);
    pointer-events: none;
    border-radius: 22px 22px 0 0;
}

.map-log-panel h3 {
    margin: 0 0 10px;
    color: var(--paper);
    text-shadow: 0 0 12px rgba(255, 160, 90, 0.2);
}

.map-log-panel .log-list {
    max-height: 112px;
    overflow: auto;
    gap: 8px;
}

.general-list,
.log-list {
    display: grid;
    gap: 12px;
}

.city-item-head,
.city-item-meta,
.general-card-head,
.battle-unit-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.city-item strong,
.general-card strong,
.battle-unit-row strong {
    font-size: 1rem;
}

.city-item-meta,
.general-card p,
.force-card p,
.battle-unit-row span {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.metrics-grid {
    gap: 12px;
}

.tabs {
    gap: 10px;
}

.tab-button {
    border-radius: 999px;
    padding: 10px 14px;
}

.tab-button.active {
    background: linear-gradient(135deg, rgba(138, 90, 40, 0.18), rgba(123, 32, 24, 0.18));
    border-color: rgba(138, 90, 40, 0.3);
}

.tab-panel,
.command-group,
.action-grid,
.panel-list,
.selection-panel {
    display: grid;
    gap: 14px;
}

.status-panel,
.action-card,
.general-card,
.prisoner-card,
.battle-hint-card {
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 250, 239, 0.74);
    border: 1px solid rgba(23, 18, 13, 0.09);
}

.action-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.action-card {
    display: grid;
    gap: 12px;
}

.action-card h4,
.general-card h4 {
    margin: 0;
    font-size: 1rem;
}

.action-card p,
.selection-help,
.action-meta,
.battle-hint-card,
.log-list.compact .log-item {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--ink-soft);
}

.action-form {
    align-items: center;
}

.inline-select,
.inline-input {
    width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(23, 18, 13, 0.16);
    background: rgba(255, 251, 241, 0.92);
    padding: 10px 12px;
    color: var(--ink);
}

.general-card {
    display: grid;
    gap: 12px;
}

.portrait {
    height: 136px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(23, 18, 13, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(23, 18, 13, 0.08));
}

.portrait svg {
    width: 100%;
    height: 100%;
    display: block;
}

.stat-bars {
    display: grid;
    gap: 8px;
}

.stat-bar {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: center;
    font-size: 0.88rem;
}

.bar-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(23, 18, 13, 0.08);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--red), var(--bronze-soft));
}

.side-section {
    display: grid;
    gap: 12px;
}

.region-label {
    font-size: 14px;
    letter-spacing: 0.22em;
    fill: rgba(23, 18, 13, 0.42);
}

.river-path {
    fill: none;
    stroke: rgba(70, 114, 133, 0.68);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.road-path {
    fill: none;
    stroke: rgba(108, 84, 51, 0.12);
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 6 8;
    opacity: 0.42;
}

.road-path.muted {
    opacity: 0.12;
}

.road-path.subdued {
    opacity: 0.24;
}

.road-path.active-route {
    stroke-width: 5.5;
    stroke-dasharray: none;
    opacity: 1;
    filter: url(#route-glow);
}

.road-path.active-route.friendly-route {
    stroke: rgba(138, 90, 40, 0.92);
}

.road-path.active-route.neutral-route {
    stroke: rgba(87, 79, 68, 0.9);
}

.road-path.active-route.hostile-route {
    stroke: rgba(123, 32, 24, 0.95);
}

.route-anchor {
    stroke: rgba(255, 248, 230, 0.95);
    stroke-width: 2;
    filter: url(#route-glow);
}

.route-anchor.friendly-route {
    fill: rgba(138, 90, 40, 0.94);
}

.route-anchor.neutral-route {
    fill: rgba(87, 79, 68, 0.9);
}

.route-anchor.hostile-route {
    fill: rgba(123, 32, 24, 0.95);
}

.border-path {
    fill: none;
    stroke: rgba(23, 18, 13, 0.18);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.relief-stroke {
    fill: none;
    stroke: rgba(90, 77, 55, 0.24);
    stroke-width: 2;
    stroke-linecap: round;
}

.map-city-node {
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.map-city-node:hover {
    transform: translateY(-2px);
}

.map-city-node.faded {
    opacity: 0.34;
}

.map-city-label {
    font-size: 13px;
    fill: #17120d;
    paint-order: stroke;
    stroke: rgba(255, 249, 236, 0.84);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.map-city-meta {
    font-size: 11px;
    fill: rgba(23, 18, 13, 0.68);
}

.map-city-halo {
    fill: rgba(255, 248, 230, 0.2);
}

.map-city-core {
    stroke-width: 2.5;
}

.map-city-ring {
    fill: none;
    stroke-width: 2;
}

.map-city-node.active .map-city-ring {
    stroke: rgba(123, 32, 24, 0.88);
    stroke-width: 3.5;
}

.map-city-node.neighbor .map-city-ring {
    stroke: rgba(138, 90, 40, 0.74);
    stroke-width: 3;
}

.map-city-node.player .map-city-core {
    fill: rgba(255, 248, 230, 0.96);
}

.map-city-node.enemy .map-city-core {
    fill: rgba(123, 32, 24, 0.94);
}

.map-city-node.neutral .map-city-core {
    fill: rgba(87, 79, 68, 0.82);
}

.map-army-dot {
    fill: #17120d;
}

.log-item {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 250, 239, 0.62);
    border: 1px dashed rgba(23, 18, 13, 0.12);
}

.battle-screen {
    gap: 18px;
}

.battle-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
}

.battle-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}

.battle-cell {
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    padding: 6px;
    border: 1px solid rgba(23, 18, 13, 0.1);
    display: grid;
    align-content: space-between;
    overflow: hidden;
}

.terrain-plain { background: #d7c89d; }
.terrain-grass { background: #d0c38f; }
.terrain-forest { background: #98a678; }
.terrain-mountain { background: #a39d92; }
.terrain-village { background: #c79d6c; }
.terrain-city { background: #b67a5f; }
.terrain-camp { background: #aa8f67; }
.terrain-river { background: #7da7b8; }

.battle-cell.reachable {
    box-shadow: inset 0 0 0 3px rgba(63, 92, 61, 0.58);
}

.battle-cell.attackable {
    box-shadow: inset 0 0 0 3px rgba(123, 32, 24, 0.6);
}

.battle-cell.selected {
    box-shadow: inset 0 0 0 3px rgba(138, 90, 40, 0.75);
}

.battle-cell.capture-target {
    outline: 2px dashed rgba(255, 244, 214, 0.92);
    outline-offset: -6px;
}

.cell-coord,
.cell-terrain {
    font-size: 0.72rem;
    color: rgba(23, 18, 13, 0.75);
}

.unit-token {
    border-radius: 12px;
    padding: 8px 6px;
    background: rgba(255, 248, 230, 0.88);
    border: 1px solid rgba(23, 18, 13, 0.12);
    display: grid;
    gap: 3px;
}

.unit-token.attacker {
    background: rgba(123, 32, 24, 0.2);
}

.unit-token.defender {
    background: rgba(63, 92, 61, 0.2);
}

.unit-token.active-turn {
    box-shadow: 0 0 0 2px rgba(138, 90, 40, 0.38);
}

.unit-token.dead {
    opacity: 0.45;
}

.unit-name {
    font-weight: 700;
    font-size: 0.88rem;
}

.unit-sub,
.status-mini {
    font-size: 0.74rem;
    color: var(--ink-soft);
}

.battle-sidebar {
    display: grid;
    gap: 18px;
}

.battle-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.battle-actions .action-button,
.battle-actions .skill-button {
    border-radius: 16px;
    min-height: 52px;
}

#battle-hint {
    min-height: 92px;
}

.notice {
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(123, 32, 24, 0.08);
    border: 1px solid rgba(123, 32, 24, 0.16);
    color: var(--ink-soft);
}

.success {
    background: rgba(63, 92, 61, 0.1);
    border-color: rgba(63, 92, 61, 0.18);
}

@media (max-width: 820px) {
    .campaign-layout,
    .battle-layout {
        grid-template-columns: 1fr;
    }

    .campaign-screen {
        min-height: auto;
        grid-template-rows: auto;
        overflow: visible;
    }

    .app-shell {
        overflow: visible;
        min-height: auto;
    }

    .campaign-map-frame {
        height: auto;
        min-height: 640px;
    }

    .city-popup {
        left: 16px !important;
        right: 16px;
        top: auto !important;
        bottom: 16px;
        width: auto;
        max-height: min(58vh, 560px);
        transform: none !important;
    }

    .city-popup-arrow {
        display: none;
    }

    .map-log-panel {
        left: 16px;
        right: 16px;
        width: auto;
        bottom: 16px;
        max-height: 132px;
    }
}

@media (max-width: 900px) {
    .scenario-panel {
        grid-template-columns: 1fr;
    }

    .topbar,
    .footer-action,
    .sidebar-head,
    .city-panel-head,
    .grand-map-toolbar,
    .map-toolbar-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .battle-board {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .campaign-map-stage,
    .campaign-map-frame {
        min-height: 560px;
    }

    .focus-summary {
        min-width: 0;
        max-width: 100%;
    }

    .compact-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .app-shell {
        padding: 18px 14px 32px;
    }

    .battle-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .force-grid,
    .action-grid {
        grid-template-columns: 1fr;
    }
}
