.civ-skin {
  --m-chrome: rgba(18, 20, 23, 0.94);
  --m-panel: color-mix(in srgb, var(--d-ground) 62%, transparent);
  --m-glow-bg: rgba(245, 184, 66, 0.10);
  --m-glow-ring: rgba(245, 184, 66, 0.45);
  --m-glow-in: rgba(245, 184, 66, 0.14);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--d-ground);
  color: var(--d-text);
  font-family: var(--d-sans);
  font-size: 14px;
  line-height: 1.45;
}

.map-top {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--d-rule);
  background: var(--d-ground);
}
.civ-skin .map-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  flex: none;
  color: var(--d-text);
  font: 600 13px/1 var(--d-mono);
  letter-spacing: 0.22em;
  text-decoration: none;
}
.map-rule { flex: none; width: 1px; height: 24px; background: var(--d-rule); }
.map-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.map-name h1 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 600 22px/1.2 var(--d-display);
  letter-spacing: 0.02em;
}
.map-mode { white-space: nowrap; font: 11px/1 var(--d-mono); letter-spacing: 0.14em; color: var(--d-blue); }
.map-top :is(.map-brand-word, .map-name h1, .map-countdown, .map-behind, .map-cta, .map-desk) { text-box: trim-both cap alphabetic; }
.map-top .map-name h1 { padding-block: 6px; }
.civ-skin .map-desk { min-height: 32px; gap: 6px; padding: 0 10px 0 8px; }
.map-brand-back { display: none; }
.civ-skin .map-desk svg { display: block; flex: none; }
.map-access {
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 11px/1 var(--d-mono);
  letter-spacing: 0.12em;
}
.map-behind {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--d-amber-line);
  border-radius: 3px;
  color: var(--d-amber);
  white-space: nowrap;
}
.civ-skin .map-cta { min-height: 32px; padding: 0 12px; letter-spacing: 0.12em; }
.map-live { display: inline-flex; align-items: center; gap: 8px; padding: 0 6px; color: var(--d-amber); white-space: nowrap; }
.map-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--d-amber); animation: desk-blink 1.6s ease-in-out infinite; }

.civ-skin .civ-map { background: var(--d-ground); }

.civ-skin .civ-stats-panel {
  left: 12px;
  top: 12px;
  bottom: 72px;
  width: 300px;
  max-width: calc(100% - 24px);
  border: 1px solid var(--d-rule);
  background: var(--m-panel);
  backdrop-filter: blur(2px);
}
.civ-skin .civ-desk:has(.civ-corner:not([hidden])) .civ-stats-panel { bottom: 219px; }
.civ-skin .civ-stats-head {
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--d-rule);
  font: 11px/1 var(--d-mono);
  letter-spacing: 0.14em;
  color: var(--d-muted);
}
.civ-stat-tabs { flex: 1 1 auto; display: flex; min-width: 0; }
.civ-skin .civ-stat-tab {
  flex: 1 1 0;
  min-height: 40px;
  padding: 0 8px;
  border-bottom: 2px solid transparent;
  color: var(--d-muted);
}
.civ-skin .civ-stat-tab[aria-selected="true"] { color: var(--d-text); border-bottom-color: var(--d-amber); }
.civ-skin .civ-stat-tab:hover { color: var(--d-text); }
.civ-skin .civ-stats-close {
  flex: 0 0 44px;
  width: 44px;
  height: auto;
  min-height: 40px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--d-rule);
  border-radius: 0;
  color: var(--d-muted);
}
.civ-skin .civ-stats-close:hover { color: var(--d-text); }
.civ-skin .civ-stats-pane { padding: 12px 14px; scrollbar-width: thin; scrollbar-color: var(--d-rule) transparent; }

.civ-skin .civ-stat-tile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(36px, auto);
  align-items: baseline;
  gap: 3px 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--d-rule);
}
.civ-skin .civ-stat-tile:last-of-type { border-bottom: 1px solid var(--d-rule); }
.civ-skin .civ-stat-label { margin: 0; font: 10px/1.4 var(--d-mono); letter-spacing: 0.12em; color: var(--d-blue); text-transform: uppercase; }
.civ-skin .civ-stat-source:hover,
.civ-skin .civ-stat-source:focus-visible { color: var(--d-text); }
.civ-skin .civ-stat-label .leave-desk-arrow { width: 9px; height: 9px; margin-right: 4px; vertical-align: -1px; }
.civ-skin .civ-stat-value { font: 600 22px/1 var(--d-display); color: var(--d-text); text-align: right; white-space: nowrap; }
.civ-skin .civ-stat-age { order: 1; grid-column: 1 / -1; margin: 0; font: 10px/1.4 var(--d-mono); letter-spacing: 0.04em; color: var(--d-muted); }
.civ-skin .civ-stat-unit { font: inherit; color: var(--d-body); }
.civ-skin .civ-stat-change { margin: 0; font: 10px/1 var(--d-mono); text-align: right; color: var(--d-green); }
.civ-skin .civ-stat-change.down { color: var(--d-alert); }
.civ-stat-updated { margin: 0; padding-top: 10px; font: 10px/1.4 var(--d-mono); letter-spacing: 0.1em; color: var(--d-muted); }
.civ-stat-updated span { color: var(--d-body); }
.civ-skin .civ-stat-empty { padding: 4px 0; color: var(--d-muted); }

.civ-skin .civ-legend { display: block; padding: 0; font: 10px/1.4 var(--d-mono); letter-spacing: 0.12em; color: var(--d-text); }
.civ-skin .civ-legend div { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--d-rule); }
.civ-skin .civ-legend dt { flex: 0 0 28px; display: flex; align-items: center; justify-content: center; }
.civ-skin .civ-legend svg { width: 18px; height: 18px; }
.civ-skin .civ-legend dd { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; color: var(--d-text); }
.civ-skin .civ-legend dd small { margin-left: auto; font-size: 10px; letter-spacing: 0.08em; color: var(--d-muted); white-space: nowrap; }
.civ-skin .civ-legend .civ-legend-note { display: block; max-width: none; padding: 10px 0 0; border-bottom: 0; }
.civ-skin .civ-legend .civ-legend-note p { color: var(--d-muted); opacity: 1; }

.civ-skin .civ-log {
  top: 12px;
  right: 12px;
  bottom: 72px;
  width: 340px;
  max-width: calc(100% - 24px);
  border: 1px solid var(--d-rule);
  background: var(--m-panel);
  backdrop-filter: blur(2px);
}
.civ-skin .civ-log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  min-height: 40px;
  padding: 6px 6px 6px 12px;
  border-bottom: 1px solid var(--d-rule);
  font: 11px/1.3 var(--d-mono);
  letter-spacing: 0.14em;
  color: var(--d-blue);
}
.civ-log-title { flex: 1 1 auto; }
.civ-log-count { color: var(--d-text); }
.civ-log-hint { order: 5; flex: 1 0 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; letter-spacing: 0.1em; color: var(--d-muted); }
.civ-skin .civ-lock,
.civ-skin .civ-top,
.civ-wire-close {
  float: none;
  flex: none;
  width: 32px;
  height: 28px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--d-muted);
  cursor: pointer;
}
.civ-skin .civ-lock:hover,
.civ-skin .civ-top:hover,
.civ-wire-close:hover { border-color: var(--d-muted); color: var(--d-text); }
.civ-skin .civ-lock[aria-pressed="true"] { color: var(--d-amber); border-color: var(--d-amber-line); }
.civ-skin .civ-top svg { display: block; flex: none; }
.civ-wire-close { display: none; }

.civ-skin .civ-wire li { padding: 9px 12px 10px; transition: background-color 0.6s ease, box-shadow 0.6s ease; }
.civ-skin .civ-wire li.wire-lockbox,
.civ-skin .civ-wire li.wire-lockbox li { transition: none; }
.civ-skin .civ-wire li[data-headline-id]:hover,
.civ-skin .civ-wire li.pointed,
.civ-skin .civ-wire li.wire-shared {
  margin: 0;
  padding: 9px 12px 10px;
  background: var(--m-glow-bg);
  box-shadow: inset 0 0 0 1px var(--m-glow-ring), inset 0 0 28px var(--m-glow-in);
  transition-duration: 0.15s;
}
.civ-skin .civ-wire li.wire-new { padding: 9px 12px 10px; }
.wire-onmap,
.wire-sharedtag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 5px;
  border: 1px solid var(--d-blue-line);
  border-radius: 2px;
  font: 9px/1.4 var(--d-mono);
  letter-spacing: 0.1em;
  color: var(--d-blue);
}
.wire-onmap { margin-left: auto; }
.wire-onmap-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--d-blue); }
.wire-sharedtag { margin-left: auto; border-color: var(--d-amber-line); color: var(--d-amber); }
.wire-onmap + .wire-sharedtag { margin-left: 0; }
.civ-skin .wire-replay { order: 1; margin: 0; min-height: 28px; padding: 0 8px; border-color: var(--d-rule); font: 9px/1 var(--d-mono); letter-spacing: 0.1em; }
.civ-skin .civ-wire .wire-empty { color: var(--d-muted); }

.civ-skin .civ-media { right: 364px; bottom: 60px; border: 1px solid var(--d-rule); border-radius: 0; background: var(--d-ground); }
.civ-skin .civ-corner { left: 12px; right: auto; width: 240px; }
.map-corner-live {
  position: absolute;
  left: 8px;
  top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 48px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 10px/1.4 var(--d-mono);
  letter-spacing: 0.14em;
  color: var(--d-alert);
  text-shadow: 0 1px 2px var(--d-ground);
  pointer-events: none;
}
.map-corner-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--d-alert); animation: desk-blink 1.6s ease-in-out infinite; }
.map-corner-hide {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 28px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 12, 14, 0.7);
  border: 0;
  border-radius: 3px;
  color: var(--d-muted);
  cursor: pointer;
}
.map-corner-hide:hover { color: var(--d-text); }

.civ-skin .civ-home,
.civ-skin .civ-zoom { top: 12px; border-radius: 3px; border-color: var(--d-rule); background: var(--m-chrome); color: var(--d-muted); }
.civ-skin .civ-home:hover { color: var(--d-amber); border-color: var(--d-muted); }
.civ-skin .civ-zoom { font-family: var(--d-mono); }
@media (min-width: 801px) {
  .civ-skin .civ-stats-panel:not([hidden]) ~ .civ-map .civ-home { left: 324px; }
  .civ-skin .civ-stats-panel:not([hidden]) ~ .civ-map .civ-zoom { left: 362px; }
}
.civ-skin .civ-schemes { top: 12px; border-color: var(--d-rule); background: var(--m-chrome); }
.civ-skin .civ-schemes button { border-right-color: var(--d-rule); color: var(--d-muted); font-family: var(--d-mono); }
.civ-skin .civ-schemes button.on { background: var(--d-amber); color: var(--d-ground); }

.civ-skin .civ-eta .maplibregl-popup-content {
  padding: 8px 10px;
  background: var(--d-raised);
  border: 1px solid var(--d-rule);
  border-top: 2px solid var(--d-amber);
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font: 10px/1.5 var(--d-mono);
  letter-spacing: 0.12em;
  color: var(--d-blue);
}
.civ-skin .civ-map .maplibregl-ctrl-bottom-right { right: 54px; bottom: 8px; }
.civ-embed .civ-map .maplibregl-ctrl-bottom-right { right: 0; bottom: 0; }

.map-chrome {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font: 11px/1 var(--d-mono);
  letter-spacing: 0.12em;
  pointer-events: none;
}
.map-chrome > * { pointer-events: auto; }
.civ-skin .map-chip {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  background: var(--m-chrome);
  border: 1px solid var(--d-rule);
  border-radius: 3px;
  color: var(--d-muted);
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.civ-skin button.map-chip { cursor: pointer; color: var(--d-text); }
.civ-skin button.map-chip:hover,
.civ-skin a.map-chip:hover { border-color: var(--d-muted); color: var(--d-text); }
.map-key-mark { width: 8px; height: 8px; background: var(--d-amber); }
.civ-skin .map-chrome .civ-stats-chip { display: none; }
.civ-skin .civ-desk:has(.civ-stats-panel[hidden]) .map-chrome .civ-stats-chip { display: inline-flex; }
.civ-skin .map-wire-chip { display: none; }
.map-wire-count { color: var(--d-blue); }

.map-modes { display: inline-flex; margin: 0; background: var(--m-chrome); border: 1px solid var(--d-rule); border-radius: 3px; overflow: hidden; }
.map-modes button {
  min-width: 44px;
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  color: var(--d-muted);
  font: 600 11px/1 var(--d-mono);
  letter-spacing: 0.12em;
  cursor: pointer;
}
.map-modes button + button { border-left: 1px solid var(--d-rule); }
.map-modes button:not(:disabled):hover { color: var(--d-text); }
.map-modes button[aria-pressed="true"] { background: var(--d-amber); color: var(--d-ground); }
.map-modes button:disabled { cursor: default; opacity: 0.5; }

.map-scheme b { font-weight: inherit; color: var(--d-text); }
.civ-skin .map-scheme .civ-scheme { color: var(--d-blue); }
.civ-skin .map-scheme .civ-scheme-glyph { width: 12px; height: 12px; }

.civ-skin .civ-traffic { padding: 0 12px; font-size: 11px; letter-spacing: 0.12em; color: var(--d-blue); cursor: help; }
.civ-skin .civ-traffic.empty { color: var(--d-amber); border-color: var(--d-amber-line); }
.civ-skin .civ-traffic::after { top: auto; bottom: calc(100% + 6px); right: auto; left: 0; border-color: var(--d-rule); border-radius: 3px; background: var(--d-raised); color: var(--d-text); }

.civ-skin .map-open { margin-left: auto; }
.civ-skin .map-sound { margin-left: auto; min-height: 36px; background: var(--m-chrome); }

.civ-embed .map-chrome { top: 8px; bottom: auto; left: 8px; right: 8px; }
@media (max-width: 460px) { .civ-embed .map-open { display: none; } }

@media (max-width: 800px) {
  .map-top { gap: 8px; padding: 0 10px; }
  .map-brand-word,
  .map-mode,
  .map-countdown,
  .map-behind-more { display: none; }
  .civ-skin .map-brand { min-width: 44px; justify-content: center; }
  .map-rule { display: none; }
  .map-name h1 { font-size: 20px; }
  .map-access { gap: 6px; letter-spacing: 0.08em; }
  .map-behind { min-height: 44px; padding: 0 8px; }
  .civ-skin .map-cta { min-height: 44px; }
  .civ-skin .map-desk { display: none; }
  .civ-skin .map-brand { gap: 2px; }
  .map-brand-back { display: block; flex: none; color: var(--d-muted); }

  .civ-skin .civ-desk { grid-template-rows: minmax(0, 1fr); }
  .civ-skin .civ-stats-panel:not([hidden]) { width: calc(100% - 24px); bottom: 60px; z-index: 5; border: 1px solid var(--d-rule); background: var(--d-raised); }
  .civ-skin .civ-log { position: absolute; display: none; top: 12px; left: 12px; right: 12px; bottom: 60px; width: auto; border: 1px solid var(--d-rule); background: var(--d-raised); z-index: 5; }
  .civ-skin .civ-desk.wire-open .civ-log { display: flex; }
  .civ-wire-close { display: inline-flex; width: 44px; height: 44px; }
  .civ-skin .civ-lock,
  .civ-skin .civ-top { width: 44px; height: 44px; }
  .civ-skin .civ-home { width: 44px; height: 44px; }
  .civ-skin .civ-zoom { height: 44px; }
  .civ-skin .civ-stat-source { display: inline-flex; align-items: center; min-height: 44px; margin: -15px 0; }
  .civ-skin .civ-stat-tab { min-height: 44px; }
  .civ-skin .civ-stats-close { min-height: 44px; }

  .civ-skin .map-chip,
  .map-modes button,
  .civ-skin .map-sound { min-height: 44px; }
  .civ-skin .map-chrome .civ-stats-chip,
  .civ-skin .map-wire-chip { display: inline-flex; }
  .civ-skin .civ-desk:has(.civ-stats-panel:not([hidden])) .map-chrome .civ-stats-chip,
  .civ-skin .civ-desk.wire-open .map-wire-chip { border-color: var(--d-amber-line); color: var(--d-amber); }
  .map-modes,
  .civ-skin .map-scheme { display: none; }
  .map-chrome { gap: 6px; letter-spacing: 0.06em; }
  .civ-skin .map-chip { padding: 0 10px; }
  .civ-skin .civ-corner { display: none; }
  .civ-skin .civ-media { left: 12px; right: 12px; width: auto; bottom: 68px; }
  .civ-skin .civ-map .maplibregl-ctrl-bottom-right { bottom: 14px; }
  .civ-embed .map-chip,
  .civ-embed .map-modes button { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .map-live-dot,
  .map-corner-dot { animation: none; }
  .civ-skin .civ-wire li { transition: none; }
}

.map-switch {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(var(--cols), 64px);
  grid-auto-rows: 64px;
  overflow: hidden;
  pointer-events: none;
}
.map-switch i {
  position: relative;
  display: block;
  background: var(--d-raised);
  box-shadow: inset 0 0 0 1px var(--d-rule);
  backface-visibility: hidden;
  will-change: transform, opacity;
}
.map-switch i::after { content: ""; position: absolute; inset: 0; background: var(--d-amber); opacity: 0; }
.civ-skin .civ-stats-panel,
.civ-skin .civ-log,
.civ-skin .civ-corner { z-index: 4; }
.map-switch-static {
  display: block;
  background-color: var(--d-raised);
  background-image:
    linear-gradient(to bottom, var(--d-rule) 0 1px, transparent 1px 63px, var(--d-rule) 63px 64px),
    linear-gradient(to right, var(--d-rule) 0 1px, transparent 1px 63px, var(--d-rule) 63px 64px);
  background-size: 64px 64px;
}
.map-switch.closing i { animation: map-tile-in 480ms cubic-bezier(0.3, 0, 0.2, 1) var(--d) both; }
.map-switch.closing i::after { animation: map-tile-flash-in 480ms linear var(--d) both; }
.map-switch.closed i { transform: none; }
.map-switch.opening i { animation: map-tile-out 480ms cubic-bezier(0.4, 0, 0.7, 0.2) var(--d) both; }
.map-switch.opening i::after { animation: map-tile-flash-out 480ms linear var(--d) both; }
@keyframes map-tile-in {
  from { transform: perspective(300px) rotateY(-90deg); }
  to { transform: perspective(300px) rotateY(0); }
}
@keyframes map-tile-out {
  from { transform: perspective(300px) rotateY(0); opacity: 1; }
  to { transform: perspective(300px) rotateY(90deg); opacity: 0; }
}
@keyframes map-tile-flash-in { from { opacity: 1; } 60% { opacity: 0.35; } to { opacity: 0; } }
@keyframes map-tile-flash-out { from { opacity: 0; } 45% { opacity: 0.25; } to { opacity: 0; } }
.map-switch-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: 600 12px/1 var(--d-mono);
  letter-spacing: 0.22em;
  color: var(--d-amber);
  text-shadow: 0 0 12px rgba(245, 184, 66, 0.45);
  animation: map-switch-label 1.1s ease-in-out infinite alternate;
}
.map-switch.opening .map-switch-label { animation: map-switch-label-out 200ms ease-out both; }
@keyframes map-switch-label { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes map-switch-label-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .map-switch.closing i,
  .map-switch.opening i { animation: none; }
  .map-switch.closing { animation: map-switch-fade 200ms both; }
  .map-switch.opening { animation: map-switch-fade 200ms reverse both; }
  .map-switch-label { animation: none; }
}
@keyframes map-switch-fade { from { opacity: 0; } to { opacity: 1; } }
