:root {
  --bg: #0b0e0b;
  --bg2: #121712;
  --panel: #151c15;
  --panel-2: #1b241b;
  --line: #2a3628;
  --gold: #d4b46a;
  --gold-dim: #8a7340;
  --text: #e7eadc;
  --muted: #8d947c;
  --player: #4a9be8;
  --player-dim: #1d4e7a;
  --enemy: #e0564e;
  --enemy-dim: #7a2420;
  --faction-green: #3ecf7a;
  --faction-gold: #e8b84a;
  --faction-purple: #9b6bff;
  --faction-teal: #2ec4b6;
  --ok: #7dcf6b;
  --danger: #e07060;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ui-dw: 1600;
  --ui-dh: 900;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
/* Layout is authored at 1600×900, then stretched to fill the window. */
#app {
  width: calc(var(--ui-dw) * 1px);
  height: calc(var(--ui-dh) * 1px);
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  transform-origin: 0 0;
  transform: scale(
    var(--ui-sx, calc(100vw / 1600px)),
    var(--ui-sy, calc(100vh / 900px))
  );
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#menu {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: safe center;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}
.menu-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(11,14,11,0.3), rgba(11,14,11,0.92)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(212,180,106,0.05) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(212,180,106,0.05) 31px 32px),
    radial-gradient(800px 400px at 20% 20%, rgba(74,155,232,0.18), transparent 55%),
    radial-gradient(700px 380px at 80% 80%, rgba(224,86,78,0.16), transparent 55%);
}
.menu-card {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 32px));
  margin: 24px 0;
  background: linear-gradient(180deg, #1a2218, #12180f);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 40px 32px;
  box-shadow: var(--shadow);
}
.kicker {
  letter-spacing: 0.28em;
  font-size: 11px;
  color: var(--gold);
}
h1 {
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 8px 0 12px;
}
.lead, .hint { color: var(--muted); line-height: 1.7; }
.pick-label { margin: 22px 0 10px; color: var(--gold); font-size: 13px; }
.map-picks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mode-picks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.side-picks { grid-template-columns: 1fr 1fr; }
#diff-picks.side-picks { grid-template-columns: repeat(3, 1fr); }
.side-picks .mode-pick[data-side="player"].selected {
  border-color: #5aaef0;
  background: linear-gradient(180deg, #1a2a38, #141c24);
  box-shadow: inset 0 0 0 1px rgba(90, 174, 240, 0.28);
}
.side-picks .mode-pick[data-side="ai"].selected {
  border-color: #ef6a62;
  background: linear-gradient(180deg, #3a1c1a, #241414);
  box-shadow: inset 0 0 0 1px rgba(239, 106, 98, 0.28);
}
.mode-pick {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 14px 12px;
  text-align: left;
  transition: 0.15s border-color, 0.15s transform, 0.15s background;
}
.mode-pick:hover { border-color: var(--gold-dim); }
.mode-pick.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #24301c, #1a2416);
  box-shadow: inset 0 0 0 1px rgba(212,180,106,0.25);
}
.mode-note { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 4px; }
.online-row { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 10px; margin-top: 12px; }
.turn-range-row { grid-template-columns: 1fr 1fr; margin-top: 0; }
.turn-range-row input[type="number"] { text-align: center; }
.online-field { display: flex; flex-direction: column; gap: 6px; color: var(--gold); font-size: 12px; }
.online-field input {
  height: 40px;
  padding: 6px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
}
.online-field input:focus { outline: none; border-color: var(--gold); }
.net-code {
  font-size: 28px;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-align: center;
  margin: 12px 0 16px;
  font-weight: 700;
}
#modal-net .ghost, #modal-net .primary, #modal-handover .primary { width: 100%; }
#modal-net .ghost { margin-bottom: 8px; }
#net-banner {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 48, 70, 0.92);
  border: 1px solid var(--player);
  padding: 8px 16px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 9;
}
body[data-side="ai"] .shop-item.active {
  border-color: var(--enemy);
  box-shadow: inset 0 0 0 1px var(--enemy);
}
body[data-side="ai"] .pill.gold { color: #e8a39e; }
.menu-settings {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 4;
  background: rgba(18, 24, 16, 0.88);
  padding: 8px 14px;
}
.menu-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  cursor: pointer;
  user-select: none;
  line-height: 1.45;
}
.menu-check.locked {
  opacity: 0.45;
  cursor: default;
}
.menu-check input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  flex-shrink: 0;
}
.check-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.setting-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.setting-row input {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  accent-color: var(--gold);
  flex-shrink: 0;
}
.setting-row b { display: block; margin-bottom: 4px; }
.setting-desc { display: block; color: var(--muted); font-size: 13px; line-height: 1.55; }
.setting-row-number {
  cursor: default;
  align-items: center;
  justify-content: space-between;
}
.setting-row-number input[type="number"] {
  width: 72px;
  height: 36px;
  margin-top: 0;
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  text-align: center;
  accent-color: var(--gold);
}
.setting-row-number input[type="number"]:focus {
  outline: none;
  border-color: var(--gold);
}
#modal-settings .primary { width: 100%; margin-top: 16px; }
.map-pick, .primary, .ghost {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 14px 12px;
  text-align: left;
  transition: 0.15s border-color, 0.15s transform, 0.15s background;
}
.map-pick:hover, .ghost:hover { border-color: var(--gold-dim); }
.map-pick.locked {
  opacity: 0.42;
  cursor: not-allowed;
}
.map-pick.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #24301c, #1a2416);
  box-shadow: inset 0 0 0 1px rgba(212,180,106,0.25);
}
.map-name { display: block; font-weight: 700; }
.map-size { display: block; color: var(--gold); margin: 4px 0; }
.map-meta { display: block; color: var(--muted); font-size: 12px; }
.primary {
  text-align: center;
  background: linear-gradient(180deg, #d8bc78, #b38d3d);
  color: #1a1408;
  font-weight: 700;
  border: none;
  padding: 12px 18px;
}
#menu-home { margin-top: 22px; }
.menu-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.save-load-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.save-meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
}
.menu-card .primary, .menu-card .ghost {
  width: 100%;
  margin-top: 0;
  text-align: center;
  padding: 12px 18px;
}
.primary:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.hint { margin-top: 14px; font-size: 12px; }

#game-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  user-select: none;
}
#topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #101510;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.14em; min-width: 120px; }
.brand-mark {
  width: 12px; height: 12px; border-radius: 2px;
  background: linear-gradient(135deg, var(--player), var(--enemy));
}
.status-pills { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
}
.pill.gold { color: var(--gold); }
.top-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
#topbar .primary {
  width: auto;
  margin: 0;
  padding: 8px 16px;
  white-space: nowrap;
}
.ghost {
  padding: 8px 12px;
  text-align: center;
  background: transparent;
}
.ghost.small { padding: 4px 8px; font-size: 12px; }
.ghost.active { border-color: var(--gold); color: var(--gold); }

#workspace { flex: 1; display: flex; min-height: 0; }
#stage-wrap { flex: 1; position: relative; overflow: hidden; background: #0e130e; }
#stage-wrap.air-view { background: #0b1218; }
#board { display: block; width: 100%; height: 100%; cursor: default; }
.layer-switch {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 8;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(12, 16, 12, 0.92);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.layer-switch button {
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: 0.08em;
}
.layer-switch button:hover { background: rgba(255, 255, 255, 0.04); }
.layer-switch button.active {
  background: linear-gradient(180deg, #d8bc78, #b38d3d);
  color: #1a1408;
  font-weight: 700;
}
#stage-wrap.air-view .layer-switch button.active {
  background: linear-gradient(180deg, #7eb7e8, #3d7aaf);
  color: #071018;
}
#layer-tag {
  position: absolute;
  right: 16px;
  top: 12px;
  z-index: 8;
  pointer-events: none;
  letter-spacing: 0.28em;
  font-size: 12px;
  color: rgba(212, 180, 106, 0.7);
  padding: 6px 10px;
  border: 1px solid rgba(138, 115, 64, 0.35);
  border-radius: 8px;
  background: rgba(12, 16, 12, 0.55);
}
#stage-wrap.air-view #layer-tag {
  color: rgba(158, 208, 255, 0.8);
  border-color: rgba(90, 160, 210, 0.4);
}
body[data-mode="tutorial"] #layer-tag { display: none; }
.end-turn-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #d8bc78, #b38d3d);
  color: #1a1408;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.end-turn-btn:hover { filter: brightness(1.06); }
.next-idle-btn {
  position: absolute;
  right: 16px;
  bottom: 74px;
  z-index: 6;
  padding: 10px 16px;
  font-size: 13px;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(12, 16, 12, 0.92);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.next-idle-btn:hover { border-color: var(--gold-dim); }

#city-card {
  position: absolute;
  pointer-events: none;
  z-index: 7;
  min-width: 150px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(12, 16, 12, 0.94);
  border: 1px solid var(--gold);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -110%);
  text-align: center;
}
#city-card .city-card-owner {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
#city-card .city-card-hp {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}
#city-card .city-card-hp span { font-size: 13px; color: var(--muted); font-weight: 500; }
#city-card .city-card-garr { margin-top: 4px; font-size: 12px; color: var(--muted); }

#toast, #hover-tip, #ai-banner {
  position: absolute;
  pointer-events: none;
}
#toast {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(20, 24, 16, 0.92);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  padding: 8px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
#hover-tip {
  left: 12px; top: 52px;
  background: rgba(12, 16, 12, 0.88);
  border: 1px solid var(--line);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  max-width: 320px;
}
#ai-banner {
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: rgba(122, 36, 32, 0.9);
  border: 1px solid var(--enemy);
  padding: 8px 16px;
  border-radius: 999px;
}
#ai-intent {
  position: absolute;
  left: 10px;
  top: 52px;
  z-index: 18;
  max-width: min(320px, calc(100% - 20px));
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(10, 14, 10, 0.92);
  border: 1px solid rgba(212, 180, 106, 0.55);
  box-shadow: 0 8px 22px rgba(0,0,0,0.4);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}
#ai-intent .ai-intent-h {
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
#ai-intent b { color: #9ad0ff; font-weight: 600; }
#ai-intent .ai-intent-muted { color: var(--muted); }
html.touch-ui #ai-intent {
  top: 46px;
  bottom: auto;
  left: 8px;
  right: auto;
  max-width: min(270px, calc(100% - 96px));
  max-height: min(34vh, 240px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 12px;
  z-index: 16;
}

#side {
  width: 332px;
  border-left: 1px solid var(--line);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#side-play, #side-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
#side-editor { display: none; overflow: hidden; }
#editor-bar {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}
#editor-name {
  width: 140px;
  height: 32px;
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
#editor-load {
  height: 32px;
  max-width: 200px;
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.editor-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.editor-check input { accent-color: var(--gold); }
.editor-picks { display: flex; gap: 6px; flex-wrap: wrap; }
.editor-picks.wrap { margin-top: 6px; }
.editor-pick {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 10px;
  font-size: 12px;
  text-align: center;
}
.editor-pick:hover { border-color: var(--gold-dim); }
.editor-pick.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, #24301c, #1a2416);
  color: var(--gold);
}
.editor-pick[data-owner="player"].selected {
  border-color: var(--player);
  color: #9fd0ff;
  background: linear-gradient(180deg, #1a2a38, #141c24);
}
.editor-pick[data-owner="ai"].selected {
  border-color: var(--enemy);
  color: #f0b8b0;
  background: linear-gradient(180deg, #3a1c1a, #241414);
}
.editor-sec {
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold);
}
.editor-money {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.editor-money label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.editor-money input {
  width: 88px;
  height: 30px;
  padding: 4px 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  text-align: center;
}
#editor-units {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
}
#editor-hint { margin-top: 8px; }
body[data-editor="1"] #topbar {
  height: auto;
  min-height: 56px;
  flex-wrap: wrap;
  padding: 8px 14px;
  row-gap: 8px;
}
body[data-editor="1"] .status-pills,
body[data-editor="1"] .top-actions,
body[data-editor="1"] .end-turn-btn,
body[data-editor="1"] .next-idle-btn,
body[data-editor="1"] .log-float-btn,
body[data-editor="1"] #log-bar,
body[data-editor="1"] #side-play,
body[data-editor="1"] #ai-banner,
body[data-editor="1"] #net-banner {
  display: none !important;
}
body[data-editor="1"] #editor-bar { display: flex !important; }
body[data-editor="1"] #side-editor { display: flex !important; }
body[data-editor="1"] #workspace { flex: 1; }
.panel {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.panel.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.panel h2 { font-size: 14px; letter-spacing: 0.12em; color: var(--gold); }
.muted { color: var(--muted); font-size: 12px; }
#shop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-height: 390px;
  overflow: auto;
}
.shop-sec {
  grid-column: 1 / -1;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--gold);
  padding: 6px 2px 0;
}
.atk-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.tag.air { color: #9ad0ff; border-color: #355a7a; }
.shop-item.civ b { color: #d4c48a; }
.shop-item.navy { border-color: #2a6a88; }
.shop-item.navy b { color: #8ec8e8; }
.help-sec {
  grid-column: 1 / -1;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--gold);
  padding: 8px 2px 0;
}
.shop-item {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 8px;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
}
.shop-item.air { border-color: #355a7a; }
.shop-item.bld { border-color: #5a5030; }
.shop-item.civ { border-color: #6a6040; }
.shop-item b { display: block; font-size: 13px; }
.shop-item .price { color: var(--gold); }
.shop-item:hover { border-color: var(--gold-dim); }
.shop-item.active { border-color: var(--player); box-shadow: inset 0 0 0 1px var(--player); }
.shop-item.locked { opacity: 0.45; }
.shop-item.poor { opacity: 0.55; }

#inspect { flex: 1; overflow: auto; font-size: 13px; line-height: 1.55; }
.stat-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed #243024; }
.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-right: 4px;
  color: var(--muted);
}
.tag.def { color: #9ad0ff; border-color: #355a7a; }
.tag.enemy { color: var(--enemy); }
.tag.truce { color: var(--gold); border-color: var(--gold-dim); }
.city-upgrades { margin-top: 4px; }
.upgrade-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 7px 8px;
  text-align: left;
  font-size: 12px;
  line-height: 1.35;
}
.upgrade-btn b { display: inline; font-size: 13px; margin-right: 8px; }
.upgrade-btn .price { color: var(--gold); }
.upgrade-btn:hover:not(:disabled) { border-color: var(--gold-dim); }
.upgrade-btn:disabled, .upgrade-btn.poor { opacity: 0.55; cursor: default; }
.city-hp-big {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  margin: 8px 0 4px;
}
.city-hp-big span { font-size: 14px; color: var(--muted); font-weight: 500; }


/* 战争迷雾：隐藏底部行动/战报栏（联机仅藏战报，保留聊天） */
#log-bar.fog-hide,
body[data-fog="1"] #log-bar.fog-hide {
  display: none !important;
}
#log-bar.fog-hide-battle #log,
#log-bar.fog-hide-battle #tab-log {
  display: none !important;
}
#log-bar.fog-hide-battle #chat-pane {
  display: flex !important;
}
#log-bar.fog-hide-battle .log-tabs {
  display: flex;
}

#log-bar {
  height: 92px;
  border-top: 1px solid var(--line);
  background: #0d120d;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  z-index: 21;
}
.log-tabs, #chat-pane { display: none; }
.log-tabs {
  flex-shrink: 0;
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.log-tab {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.log-tab:hover { color: var(--text); }
.log-tab.active { color: var(--gold); background: rgba(212, 180, 106, 0.08); }
.log-tab .chat-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--gold);
  vertical-align: middle;
}
#log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
#log .me, #chat-log .me { color: var(--player); }
#log .foe, #chat-log .foe { color: var(--enemy); }
#log .sys { color: var(--gold); }
#chat-pane {
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
#chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
#chat-log b { margin-right: 6px; }
#chat-form {
  display: flex;
  gap: 6px;
  padding: 4px 8px 6px;
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  height: 28px;
  padding: 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
#chat-input:focus { outline: none; border-color: var(--gold); }
#btn-chat-send { padding: 4px 10px; flex-shrink: 0; }
body[data-online="1"] #log-bar { height: 128px; }
body[data-online="1"] .log-tabs { display: flex; }
body[data-online="1"] #log-bar.chat-open #log { display: none; }
body[data-online="1"] #log-bar.chat-open #chat-pane { display: flex; }
#modal-net { inset: 0; bottom: 0; /* full overlay; was bottom:128px click-through */ }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: grid;
  place-items: center;
  z-index: 50; /* above #log-bar (21) so help/settings/end aren't click-through */
}
.modal-card {
  width: min(520px, calc(100% - 24px));
  background: #161c14;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.modal-card.wide { width: min(860px, calc(100% - 24px)); max-height: calc(100% - 40px); overflow: auto; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0 16px; }
.help-grid h3 { color: var(--gold); font-size: 14px; margin: 8px 0 6px; }
.help-grid p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.help-units { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; font-size: 12px; color: var(--muted); }
.help-units div { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #12180f; }

#end-title { font-size: 36px; margin: 8px 0 10px; }
#end-desc { color: var(--muted); line-height: 1.65; }
.modal-card.end-card { width: min(640px, calc(100% - 24px)); max-height: calc(100% - 40px); overflow: auto; }
.end-report { margin: 16px 0 18px; }
.end-report-meta { color: var(--gold); font-size: 13px; letter-spacing: 0.04em; margin-bottom: 12px; }
.end-report-head {
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: center;
}
.end-report-head .me { color: var(--player); }
.end-report-head .foe { color: var(--enemy); }
.end-report-row {
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed #243024;
  font-size: 14px;
  text-align: center;
}
.end-report-row .lbl { color: var(--muted); font-size: 12px; }
.end-report-row .me { color: var(--player); font-weight: 700; }
.end-report-row .foe { color: var(--enemy); font-weight: 700; }
.end-report h3 {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.14em;
  margin: 14px 0 8px;
}
.end-report-events {
  max-height: 168px;
  overflow: auto;
  background: #12180f;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.end-report-events .me { color: var(--player); }
.end-report-events .foe { color: var(--enemy); }
.end-report-events .sys { color: var(--gold); }
.end-report-empty { color: var(--muted); font-size: 13px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #314031; border-radius: 8px; }

#tut-card {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 30;
  width: min(320px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(22, 30, 20, 0.96), rgba(12, 16, 12, 0.96));
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  box-sizing: border-box;
  min-height: 0;
  overflow: hidden;
}
.tut-progress {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--gold);
  margin-bottom: 6px;
  flex-shrink: 0;
}
#tut-card h2 {
  font-size: 20px;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  flex-shrink: 0;
}
#tut-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}
#tut-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0;
  padding-right: 4px;
  white-space: normal;
}
#tut-task {
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--gold);
  font-weight: 600;
  flex-shrink: 0;
}
#tut-task.hidden { display: none !important; }
.tut-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  padding-top: 4px;
  background: linear-gradient(180deg, rgba(12, 16, 12, 0), rgba(12, 16, 12, 0.96) 28%);
}
.tut-actions .primary, .tut-actions .ghost {
  flex: 1 1 40%;
  padding: 10px 10px;
  text-align: center;
  min-height: 40px;
}
#tut-skip {
  flex-basis: 100%;
}
.shop-item.tut-pulse,
.end-turn-btn.tut-pulse,
#btn-end.tut-pulse,
#btn-ranged.tut-pulse,
#btn-air-atk.tut-pulse,
.upgrade-btn.tut-pulse,
.layer-switch button.tut-pulse {
  border-color: var(--gold);
  animation: tutPulse 1.1s ease-in-out infinite;
}
.layer-switch button.tut-pulse {
  position: relative;
  z-index: 1;
}
@keyframes tutPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 180, 106, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(212, 180, 106, 0); }
}


.cheat-float-btn {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 6;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(40, 28, 18, 0.88);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.cheat-float-btn:hover { border-color: var(--gold); filter: brightness(1.06); }
.cheat-panel {
  position: absolute;
  left: 12px;
  bottom: 58px;
  z-index: 7;
  width: min(320px, calc(100% - 24px));
  max-height: min(58vh, 420px);
  overflow: auto;
  padding: 10px 12px 12px;
  border-radius: 12px;
  background: rgba(18, 22, 30, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
.cheat-panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.cheat-panel-h strong { color: var(--gold); font-size: 14px; }
.cheat-section { margin-top: 8px; }
.cheat-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.cheat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.cheat-row .ghost.small,
.cheat-row button {
  padding: 5px 8px;
  font-size: 12px;
  min-height: 0;
}
.cheat-row select {
  flex: 1 1 90px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
}
.cheat-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
html.touch-ui .cheat-float-btn {
  left: 10px;
  bottom: 12px;
  min-height: 40px;
}
html.touch-ui .cheat-panel {
  left: 10px;
  bottom: 58px;
  max-height: 48dvh;
}

@media (max-width: 980px) {
  .map-picks, .mode-picks, .side-picks, .help-grid, .help-units, .online-row { grid-template-columns: 1fr; }
  #side { width: 280px; }
  h1 { font-size: 36px; }
}

html.touch-ui, html.touch-ui body {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
}
html.touch-ui #app {
  transform: none;
  width: 100%;
  height: 100%;
  height: 100dvh;
  position: relative;
  left: 0;
  top: 0;
}
html.touch-ui #menu {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Touch: make menu taps reliable (QQ/WeChat WebView click synthesis) */
html.touch-ui #menu button,
html.touch-ui #menu .mode-pick,
html.touch-ui #menu .map-pick,
html.touch-ui #menu .menu-check {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(212, 180, 106, 0.22);
}
html.touch-ui #menu {
  touch-action: pan-y;
}

html.touch-ui .menu-card {
  width: min(720px, calc(100% - 20px));
  padding: 22px 18px 20px;
}
html.touch-ui h1 { font-size: 28px; }
html.touch-ui button,
html.touch-ui .mode-pick,
html.touch-ui .map-pick {
  min-height: 44px;
}
html.touch-ui #game-screen {
  height: 100%;
  height: 100dvh;
}
html.touch-ui #topbar {
  height: auto;
  min-height: 48px;
  flex-wrap: wrap;
  padding: 6px 8px;
  gap: 8px;
}
html.touch-ui .status-pills { order: 3; width: 100%; }
html.touch-ui .pill { font-size: 12px; padding: 5px 10px; }
html.touch-ui .top-actions button,
html.touch-ui .ghost,
html.touch-ui #topbar .primary {
  min-height: 40px;
  padding: 8px 12px;
}
html.touch-ui #workspace {
  flex-direction: row;
  min-height: 0;
}
html.touch-ui #stage-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}
html.touch-ui #board { touch-action: none; }
html.touch-ui #side {
  flex: 0 0 240px;
  width: 240px;
  max-width: 42vw;
  border-left: 1px solid var(--line);
  border-top: none;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0);
  order: 2;
}
html.touch-ui #stage-wrap { order: 1; }
html.touch-ui .end-turn-btn {
  right: 10px;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  padding: 14px 22px;
  font-size: 16px;
}
html.touch-ui .next-idle-btn {
  right: 10px;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  min-height: 40px;
}
/* 竖屏：提示横屏；侧栏仍可用但不鼓励竖屏玩 */
@media (orientation: portrait) {
  html.touch-ui #workspace { flex-direction: column; }
  html.touch-ui #stage-wrap { min-height: 52%; flex: 1 1 auto; }
  html.touch-ui #side {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    max-height: 34%;
    min-height: 140px;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  html.touch-ui #topbar { font-size: 12px; }
  html.touch-ui .hint { font-size: 12px; line-height: 1.45; }
}
@media (orientation: landscape) {
  html.touch-ui #workspace { flex-direction: row; }
  html.touch-ui #stage-wrap { flex: 1 1 auto; min-width: 0; }
  html.touch-ui #side {
    flex: 0 0 220px;
    width: 220px;
    max-width: 36vw;
    max-height: none;
  }
}
@media (orientation: landscape) and (max-height: 480px) {
  html.touch-ui #side {
    flex: 0 0 200px;
    width: 200px;
    max-width: 34vw;
  }
  html.touch-ui .shop-item { min-height: 40px; padding: 6px 8px; }
}
html.touch-ui .layer-switch button {
  min-width: 64px;
  min-height: 40px;
}
html.touch-ui .shop-item { min-height: 44px; }
html.touch-ui #tut-card {
  left: 8px;
  right: 8px;
  top: 8px;
  width: auto;
  max-width: none;
  height: auto;
  max-height: calc(100% - 16px);
  padding: 12px 12px 10px;
  z-index: 40;
  overflow: hidden;
}
html.touch-ui #tut-card h2 { font-size: 18px; }
html.touch-ui #tut-card p,
html.touch-ui #tut-body { font-size: 13px; line-height: 1.55; }
html.touch-ui #tut-body {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
html.touch-ui #tut-task { flex-shrink: 0; }
html.touch-ui .tut-actions { flex-shrink: 0; }
html.touch-ui #tut-card .tut-actions { position: relative; z-index: 2; }
html.touch-ui .tut-actions .primary,
html.touch-ui .tut-actions .ghost {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 15px;
  pointer-events: auto;
  position: relative;
  z-index: 41;
}
html.touch-ui #tut-card {
  pointer-events: auto;
}
/* Hide battle-log float during tutorial so it does not steal taps near tut UI */
html.touch-ui body[data-mode="tutorial"] #btn-log-float {
  display: none !important;
}
@media (orientation: portrait) {
  html.touch-ui #tut-card {
    height: auto;
    max-height: calc(100% - 16px);
  }
}
/* 教程中未高亮的浮动按钮降低遮挡；需要点「结束回合」时仍有 tut-pulse */
html.touch-ui body[data-mode="tutorial"] .end-turn-btn:not(.tut-pulse),
html.touch-ui body[data-mode="tutorial"] .next-idle-btn:not(.tut-pulse) {
  opacity: 0.28;
  pointer-events: none;
}
html.touch-ui body[data-mode="tutorial"] .end-turn-btn.tut-pulse,
html.touch-ui body[data-mode="tutorial"] .next-idle-btn.tut-pulse {
  opacity: 1;
  pointer-events: auto;
  z-index: 45;
}
html.touch-ui #modal-help .modal-card,
html.touch-ui #modal-end .modal-card,
html.touch-ui #modal-settings .modal-card {
  max-height: 88dvh;
  overflow: auto;
}

.online-field.peer-hide-host { opacity: 0.55; }
.online-field.peer-hide-host input:disabled { cursor: not-allowed; }

/* V1.2-fix: continue / volume / unit sheet / save slots / replay */
.continue-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  text-align: left;
  min-height: 56px;
}
.continue-btn .continue-title { font-size: 1.05em; font-weight: 700; }
.continue-btn .save-meta { opacity: 0.85; font-size: 0.82em; font-weight: 400; white-space: normal; }
.setting-row-range {
  align-items: stretch;
  cursor: default;
  flex-direction: column;
  gap: 10px;
}
.setting-row-range > span:first-child { display: block; width: 100%; }
.vol-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.12);
}
/* 覆盖 .setting-row input 的 16x16，避免 iOS 把滑条压没 */
.setting-row .vol-wrap input[type="range"],
.vol-wrap input[type="range"] {
  flex: 1 1 auto;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none;
  height: 32px !important;
  margin: 0 !important;
  padding: 0;
  touch-action: none;
  display: block;
  opacity: 1;
  visibility: visible;
  /* iOS：appearance:none + 透明底会整条消失；保留可见轨道底色 */
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  accent-color: var(--gold);
}
.vol-wrap input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
.vol-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--gold, #d4a017);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  /* iOS 必需：否则 thumb 可能不绘制 */
  position: relative;
  z-index: 1;
}
.vol-wrap input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
}
.vol-wrap input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold, #d4a017);
  border: 2px solid #fff;
}
#opt-music-vol-label {
  flex: 0 0 auto;
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.setting-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.setting-actions .primary { flex: 1; min-width: 120px; }
#modal-unit-sheet {
  z-index: 40;
  padding: env(safe-area-inset-top, 0) 8px env(safe-area-inset-bottom, 0);
  align-items: center;
  justify-items: center;
}
.unit-sheet-card {
  display: flex;
  flex-direction: column;
  width: min(860px, calc(100vw - 16px));
  max-height: min(88vh, 820px);
  max-height: min(88dvh, 820px);
  overflow: hidden;
  min-height: 0;
  padding: 18px 16px 14px;
  box-sizing: border-box;
}
.unit-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.unit-sheet-head h2 { margin: 0; font-size: 1.25em; }
.unit-sheet-card > .setting-desc { flex-shrink: 0; margin: 8px 0 0; }
.unit-sheet-list {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 120px;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}
.unit-sheet-section {
  margin-top: 6px;
  padding: 6px 2px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
  font-weight: 700;
  flex-shrink: 0;
}
.unit-sheet-row {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.22);
  flex-shrink: 0;
}
.unit-sheet-row h3 { margin: 0 0 4px; font-size: 1em; }
.unit-sheet-meta { font-size: 0.86em; opacity: 0.92; line-height: 1.45; word-break: break-word; }
.unit-sheet-note { font-size: 0.8em; opacity: 0.78; margin-top: 4px; line-height: 1.4; word-break: break-word; }
.save-slots-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 14px; }
.save-slot-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  min-height: 58px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.25);
  color: inherit;
  cursor: pointer;
  width: 100%;
}
.save-slot-btn:hover, .save-slot-btn:focus { border-color: rgba(120,180,255,0.55); outline: none; }
.save-slot-btn.empty { opacity: 0.75; }
.save-slot-btn .slot-name { font-weight: 700; }
.save-slot-btn .slot-meta { font-size: 0.84em; opacity: 0.88; white-space: normal; }
.replay-bar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 14, 22, 0.92);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  max-width: calc(100vw - 24px);
}
.replay-bar.hidden { display: none !important; }
#replay-status { font-size: 0.9em; margin-right: 4px; min-width: 7em; }
html.touch-ui .setting-row-range { flex-direction: column; align-items: stretch; }
html.touch-ui .vol-wrap { width: 100%; }
html.touch-ui .setting-row .vol-wrap input[type="range"],
html.touch-ui .vol-wrap input[type="range"] {
  height: 36px !important;
  min-height: 36px;
}
html.touch-ui .vol-wrap input[type="range"]::-webkit-slider-thumb {
  width: 32px;
  height: 32px;
  margin-top: -12px;
}
html.touch-ui .vol-wrap input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
}
html.touch-ui .save-slot-btn { min-height: 64px; padding: 14px 16px; }
html.touch-ui .replay-bar { gap: 10px; padding: 12px 14px; }
html.touch-ui #modal-unit-sheet {
  place-items: stretch center;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}
html.touch-ui #modal-unit-sheet .unit-sheet-card,
html.touch-ui #modal-unit-sheet .modal-card {
  width: calc(100% - 4px);
  max-width: none;
  max-height: calc(100dvh - 16px);
  max-height: calc(100% - 16px);
  margin: 0 auto;
}
#modal-save-slots { z-index: 40; }
html.touch-ui #modal-save-slots {
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}
html.touch-ui #modal-save-slots .modal-card {
  max-height: calc(100dvh - 16px);
  width: calc(100% - 4px);
  max-width: none;
}
html.touch-ui .unit-sheet-list { min-height: 40vh; }
html.touch-ui #btn-unit-sheet {
  min-height: 44px;
  width: 100%;
}



/* 触控联机：默认折叠地图区，减少滚到创建房间的成本 */
.maps-toggle-btn {
  width: 100%;
  margin: 8px 0 4px;
}
#skirmish-maps.maps-folded,
#turn-range-wrap.maps-folded {
  display: none;
}
html.touch-ui .cheat-float-btn {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* === touch log sheet (mobile battle log) === */
.log-float-btn {
  display: none;
  position: absolute;
  left: 12px;
  bottom: 16px;
  z-index: 6;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(12, 16, 12, 0.92);
  border: 1px solid var(--line);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 13px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.log-float-btn .log-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 2px rgba(212, 180, 106, 0.25);
  flex-shrink: 0;
}
.log-float-btn .log-unread-dot.hidden { display: none !important; }
.log-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.log-sheet-backdrop.hidden {
  display: none !important;
  pointer-events: none !important;
}
.log-sheet-head {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--line);
}
.log-sheet-title {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.12em;
}
.log-sheet-close {
  min-height: 36px;
  padding: 6px 12px;
}

/* Desktop: float stays hidden; log-bar unchanged */
body[data-editor="1"] .log-float-btn {
  display: none !important;
}

/* Touch: hide docked log-bar (keep in DOM for log appends) */
html.touch-ui #log-bar {
  display: none;
}
html.touch-ui .log-float-btn {
  display: inline-flex;
  left: 10px;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  min-height: 40px;
  z-index: 6;
}
html.touch-ui .log-float-btn.hidden {
  display: none !important;
}
/* cheat sits higher on touch; log float takes lower-left */
html.touch-ui .cheat-float-btn {
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

html.touch-ui body[data-log-open="1"] #log-sheet-backdrop:not(.hidden) {
  display: block;
  pointer-events: auto;
}
html.touch-ui body[data-log-open="1"] #log-bar:not(.fog-hide) {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: min(45dvh, 320px);
  max-height: min(45dvh, 320px);
  z-index: 35;
  border-top: 1px solid var(--gold-dim);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #0d120d;
}
html.touch-ui body[data-log-open="1"][data-online="1"] #log-bar:not(.fog-hide) {
  height: min(52dvh, 380px);
  max-height: min(52dvh, 380px);
}
html.touch-ui body[data-log-open="1"] #log-bar.fog-hide {
  display: none !important;
}
html.touch-ui body[data-log-open="1"] .log-sheet-head {
  display: flex;
}
html.touch-ui body[data-log-open="1"] #log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
html.touch-ui body[data-log-open="1"] #chat-pane {
  min-height: 0;
}
html.touch-ui body[data-editor="1"] #log-sheet-backdrop {
  display: none !important;
}

/* WeChat: ensure tap targets receive touches inside scrollable menu */
html.touch-ui #menu button,
html.touch-ui #menu .mode-pick,
html.touch-ui #menu .map-pick {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  z-index: 2;
}

/* 横屏锁定提示（触摸竖屏时盖住对局） */
.rotate-tip {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 8, 6, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.rotate-tip.hidden { display: none !important; }
.rotate-tip-card {
  max-width: 360px;
  text-align: center;
  padding: 28px 22px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a2216, #12180f);
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
}
.rotate-tip-icon { font-size: 42px; margin-bottom: 8px; }
.rotate-tip-title {
  margin: 0 0 8px;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 0.12em;
}
.rotate-tip-desc {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}
html.portrait-blocked #game-screen {
  filter: brightness(0.35);
  pointer-events: none;
}
html.touch-ui .save-slots-list {
  max-height: min(62dvh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.save-slots-loading {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.net-share-wrap { margin: 10px 0 14px; }
.net-share-link {
  display: block;
  word-break: break-all;
  color: var(--gold);
  font-size: 13px;
  line-height: 1.45;
}
