:root {
  --ink: #2a1d12;
  --paper: #f3e8cc;
  --paper-2: #e6d6ad;
  --gold: #c9a24a;
  --gold-dark: #8a6a24;
  --sea: #1f3d58;
  --text: #f5ecd6;
  --muted: #b9ab8a;
  --panel: rgba(24, 18, 12, 0.88);
  --panel-border: rgba(201, 162, 74, 0.55);
  --danger: #c0392b;
  --ok: #5fbf5f;
  --serif: 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--sea); color: var(--text); font-family: var(--sans); font-size: 14px;
  /* A game, not a page: no text gets selected by drags, double clicks or Ctrl + A. */
  -webkit-user-select: none; user-select: none;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
/* Except what you type: names, chat, editor fields. */
input, select { -webkit-user-select: text; user-select: text; }

#backdrop { position: fixed; inset: 0; width: 100%; height: 100%; filter: saturate(0.85) brightness(0.55) blur(1px); }

.screen { position: fixed; inset: 0; }
.screen.menu { display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }

.card {
  position: relative; width: 100%; max-width: 440px; padding: 28px 30px;
  background: linear-gradient(180deg, rgba(36, 27, 18, 0.95), rgba(24, 18, 12, 0.95));
  border: 1px solid var(--panel-border); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.card.wide { max-width: 720px; }
.card h1 { font-family: var(--serif); font-size: 34px; margin: 0 0 6px; color: var(--gold); letter-spacing: 0.5px; }
.card h2 { font-family: var(--serif); font-size: 24px; margin: 0 0 8px; color: var(--gold); }
.card h3 { font-family: var(--serif); font-size: 16px; margin: 22px 0 10px; color: var(--paper-2); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tagline { color: var(--muted); margin: 0 0 22px; line-height: 1.45; }
label { display: block; margin-bottom: 6px; color: var(--paper-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

input {
  width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid rgba(201, 162, 74, 0.4);
  background: rgba(0, 0, 0, 0.35); color: var(--text); outline: none;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 162, 74, 0.25); }

button {
  cursor: pointer; padding: 8px 14px; border-radius: 6px; border: 1px solid rgba(201, 162, 74, 0.45);
  background: rgba(255, 255, 255, 0.06); color: var(--text); transition: background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { background: rgba(201, 162, 74, 0.18); border-color: var(--gold); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(180deg, #d8b25a, #a9822f); color: #1d140a; font-weight: 600; border-color: #e3c06e; }
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #e6c26a, #b98f36); }
button.link { background: none; border: none; padding: 0; color: var(--gold); text-decoration: underline; }
#name-form button { margin-top: 14px; width: 100%; padding: 11px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 18px; }
#create-form { margin-top: 14px; }
#create-form input { flex: 1; }

.game-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.game-item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 10px 14px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06);
}
.game-item .name { font-weight: 600; }
.game-item .meta { color: var(--muted); font-size: 12px; }
.game-item.mine { border-color: var(--gold); background: rgba(201, 162, 74, 0.1); }
.game-item .players { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); font-size: 12px; }
.chip small { color: var(--muted); }
.chip.offline { opacity: 0.5; font-style: italic; }
.chip.out { text-decoration: line-through; }
.lobby-online { margin: -4px 0 10px; }
.warning { margin: 14px 0 0; padding: 10px 12px; border-radius: 6px; background: rgba(192, 57, 43, 0.25); border: 1px solid rgba(192, 57, 43, 0.7); color: #ffd9d2; line-height: 1.45; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.badge.lobby { background: rgba(95, 191, 95, 0.18); color: #8fdc8f; }
.badge.running { background: rgba(201, 162, 74, 0.2); color: var(--gold); }
.badge.ended { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed rgba(255, 255, 255, 0.12); border-radius: 8px; }

.room-players { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; }
.room-players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); }
.swatch { display: inline-block; vertical-align: middle; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.6); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25); flex: none; }
.tag { margin-left: auto; font-size: 11px; color: var(--muted); }

/* Game options in the waiting room: the host edits them, everyone else sees them. */
.room-options { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; }
.room-options label { margin: 0; }
.room-options select {
  padding: 8px 10px; border-radius: 6px; border: 1px solid rgba(201, 162, 74, 0.4);
  background: rgba(0, 0, 0, 0.35); color: var(--text); outline: none; cursor: pointer;
}
.room-options select option { background: #241b12; color: var(--text); }
.room-options select:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 162, 74, 0.25); }
.room-options input { width: 84px; padding: 8px 10px; }
.room-options select:disabled, .room-options input:disabled { opacity: 0.7; cursor: default; }
.opt-summary { margin: 10px 0 0; line-height: 1.45; }

/* ------------------------------------------------------------ game HUD */
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: default; }
/* Edit map mode (admins): a gold frame round the map while cities can be dragged. */
#view.map-editing { outline: 3px solid rgba(201, 162, 74, 0.7); outline-offset: -3px; }
.hud { position: absolute; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }

#topbar { top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 18px; padding: 6px 12px; height: 42px; }
#topbar .stat { display: flex; align-items: center; gap: 6px; font-size: 16px; white-space: nowrap; }
#topbar .stat small { color: var(--muted); font-size: 12px; }
#topbar .title { flex: 1; text-align: center; font-family: var(--serif); color: var(--paper-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar .buttons { display: flex; gap: 6px; }
#topbar .buttons button { padding: 4px 10px; font-size: 13px; }
#topbar .buttons button.active { background: rgba(201, 162, 74, 0.32); border-color: var(--gold); color: var(--paper); }
.coin, .tower, .army, .hourglass, .honor { width: 16px; height: 16px; display: inline-block; flex: none; }
/* Honor: a five-pointed star, silver so it never reads as gold. */
.honor { background: radial-gradient(circle at 40% 35%, #ffffff, #c9ccd6 55%, #7d8494); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
/* The honor stat opens the Honor window. */
#stat-honor { cursor: pointer; padding: 3px 6px; margin: -3px -6px; border-radius: 6px; }
#stat-honor:hover { background: rgba(201, 204, 214, 0.14); }
.hourglass { background: var(--paper-2); clip-path: polygon(10% 0, 90% 0, 90% 8%, 58% 50%, 90% 92%, 90% 100%, 10% 100%, 10% 92%, 42% 50%, 10% 8%); }
#hud-turn-next { font-variant-numeric: tabular-nums; min-width: 72px; }
#stat-turn.soon #hud-turn-next { color: var(--gold); }
.coin { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe9a0, #c9a24a 60%, #7a5a1a); border: 1px solid #5a400f; }
.tower { background: var(--paper-2); clip-path: polygon(0 100%, 0 25%, 20% 25%, 20% 0, 40% 0, 40% 25%, 60% 25%, 60% 0, 80% 0, 80% 25%, 100% 25%, 100% 100%); }
.army { background: var(--paper-2); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.feed { position: absolute; top: 60px; left: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; max-width: min(420px, 60vw); }
.feed div { background: rgba(20, 15, 10, 0.78); border-left: 3px solid var(--gold); padding: 4px 10px; border-radius: 4px; font-size: 13px; transition: opacity 0.6s; }
.feed div.good { border-left-color: var(--ok); }
.feed div.bad { border-left-color: var(--danger); }
/* Player and city names in a player's colour (hud.js colorTag). Colours too dark for the panel get a light backing. */
.who { font-weight: 700; }
.who.dark { background: rgba(240, 230, 205, 0.92); padding: 0 4px; border-radius: 3px; }


#minimap-wrap { left: 8px; bottom: 8px; padding: 4px; line-height: 0; }
#minimap { display: block; cursor: pointer; border-radius: 4px; }
/* Its top-right corner resizes it (input.js onGripDown; double click: default size). */
.minimap-grip {
  position: absolute; top: 0; right: 0; width: 18px; height: 18px; cursor: nesw-resize;
  background: rgba(20, 15, 10, 0.9); border-top-right-radius: 8px; clip-path: polygon(0 0, 100% 0, 100% 100%);
  opacity: 0.7; transition: opacity 0.15s;
}
.minimap-grip svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--paper-2); stroke-width: 1.4; stroke-linecap: round; }
#minimap-wrap:hover .minimap-grip, .minimap-grip.dragging { opacity: 1; }
.minimap-grip:hover svg, .minimap-grip.dragging svg { stroke: var(--gold); }
body.resizing-minimap, body.resizing-minimap * { cursor: nesw-resize !important; user-select: none; }
/* One of your cities was captured: the frame glows red a few times (render.js alertMinimap). */
#minimap-wrap.alert { animation: minimap-alert 0.9s ease-out 4; }
@keyframes minimap-alert {
  0%, 25% { border-color: #ff4a3a; box-shadow: 0 0 0 2px rgba(255, 74, 58, 0.85), 0 0 22px rgba(255, 74, 58, 0.6); }
}

/* Centred between the minimap (left) and the build column (right), clear of both. --minimap-w (the
   minimap's width with its frame, set by render.js) counts once the player makes it wider than the
   build column. */
.panel {
  --clear-left: max(272px, var(--minimap-w, 0px) + 20px);
  left: calc((var(--clear-left) + 100vw - 272px) / 2); transform: translateX(-50%); bottom: 8px;
  min-width: 360px; max-width: calc(100vw - 272px - var(--clear-left)); min-height: 92px; padding: 10px 14px;
}
.panel .hint { color: var(--muted); padding: 8px 4px; line-height: 1.5; }
/* Death: Liberator. The Liberate button under a city a fallen player looks at. */
.panel .liberate { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.panel .liberate button { flex: none; }
.panel .liberate span { line-height: 1.4; }
.panel .liberate + .liberate { margin-top: 6px; }
/* Liberators' marks on a city: marked for liberation, smuggled from. */
.panel .city-marks { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 12px; color: var(--paper-2); }
.panel .panel-close {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center; font-size: 20px; line-height: 1;
  color: var(--muted); background: none; border: 1px solid transparent; border-radius: 5px;
}
.panel .panel-close:hover { color: var(--paper); background: rgba(255, 255, 255, 0.08); border-color: transparent; }
.panel .panel-close + .hint { padding-right: 30px; }
.panel .head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.panel .head h4 { margin: 0; font-family: var(--serif); font-size: 18px; color: var(--paper); }
.panel .head .sub { color: var(--muted); font-size: 12px; }
.hpbar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 4px 0 8px; }
.hpbar > i { display: block; height: 100%; background: linear-gradient(90deg, #4caf50, #8bd36b); }
/* Right-hand column for your selected cities: upgrades on top, units to train below. */
.build-col { position: absolute; right: 8px; bottom: 8px; width: 252px; display: flex; flex-direction: column; gap: 8px; }
.build-box {
  display: flex; flex-direction: column; gap: 5px; padding: 8px 10px 10px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.build-box h5 { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 3px; font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--gold); }
.build-box h5 small { font-family: var(--sans); font-size: 11px; font-weight: 400; color: var(--muted); }
.build-btn {
  display: grid; grid-template-columns: 30px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; row-gap: 1px;
  align-items: baseline; width: 100%; text-align: left; padding: 5px 8px 5px 5px;
}
.build-btn img { grid-column: 1; grid-row: 1 / 3; align-self: center; width: 30px; height: 30px; }
.build-btn .nm { grid-column: 2; grid-row: 1; font-weight: 600; }
.build-btn .nm kbd { font-size: 10px; color: var(--muted); margin-left: 4px; }
.build-btn .cost { grid-column: 3; grid-row: 1; font-size: 11px; color: var(--muted); white-space: nowrap; text-align: right; }
.build-btn .eff { grid-column: 2 / 4; grid-row: 2; font-size: 11px; color: var(--muted); }
.queue { display: flex; gap: 6px; align-items: center; margin-top: 8px; min-height: 30px; }
.queue .label { color: var(--muted); font-size: 12px; }
.qitem { position: relative; width: 30px; height: 30px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.15); cursor: pointer; overflow: hidden; padding: 0; }
.qitem img { width: 26px; height: 26px; margin: 1px; position: relative; }
.qitem .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); }
.qitem:hover { border-color: var(--danger); }
.build-btn.built { border-color: rgba(95, 191, 95, 0.6); background: rgba(95, 191, 95, 0.12); opacity: 1; }
.build-btn.built .cost { color: #8fdc8f; }
/* A unit that needs a technology first (ships: Seafaring): bright and framed in amber, saying why; a click opens Technologies */
.build-btn.locked { border-color: rgba(240, 168, 60, 0.85); background: rgba(240, 168, 60, 0.12); }
.build-btn.locked:hover:not(:disabled) { background: rgba(240, 168, 60, 0.24); }
.build-btn.locked img { filter: grayscale(1); opacity: 0.6; }
.build-btn.locked .cost, .build-btn.locked .eff { color: #ffc46b; font-weight: 600; }
/* Barracks for honor (Brotherhood of Arms): the Honor window's look, near-black with a faint red glow,
   a crimson frame and the silver honor star. */
.build-btn.honor-buy {
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(150, 22, 28, 0.35), transparent 75%),
    linear-gradient(180deg, #1d0d0d, #0d0908);
  border: 1px solid #6e161b; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.build-btn.honor-buy:hover:not(:disabled) { background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(170, 28, 34, 0.5), transparent 75%), linear-gradient(180deg, #2a1011, #110a09); border-color: #a8323a; }
.build-btn.honor-buy .nm { color: #efe2cf; }
.build-btn.honor-buy .cost { display: inline-flex; align-items: center; gap: 3px; color: #e4e7ee; }
.build-btn.honor-buy .cost .honor { width: 11px; height: 11px; }
.build-btn.honor-buy .eff { color: #c9a79c; }
.build-btn.honor-buy.built { border-color: rgba(95, 191, 95, 0.6); }
.build-btn.honor-buy.built .cost { color: #8fdc8f; }
/* A Barracks in the queue paid with honor: a small silver star in its corner. */
.qitem.honor-paid { border-color: #6e161b; }
.qitem .honor { position: absolute; right: 1px; top: 1px; width: 10px; height: 10px; }
.stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.city-list { display: block; max-width: 560px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--paper-2); }
.stats b { color: var(--paper-2); font-weight: 600; }
.unit-groups { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.unit-group { display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px; font-size: 12px; }
.unit-group img { width: 22px; height: 22px; }
.unit-group b { font-size: 14px; }
/* Your selected units: compact, and never taller than 215px; past that the unit icons scroll
   (hud.js drops the help line first when the icons need the room). */
.panel.units { display: flex; flex-direction: column; max-height: 215px; min-height: 0; padding: 7px 10px 8px; }
.panel.units > * { flex: none; }
.panel.units .head { margin-bottom: 4px; }
.panel.units .head h4 { font-size: 15px; }
.panel.units .unit-tiles { flex: 0 1 auto; min-height: 0; max-height: none; }
.panel.units .hpbar { margin: 5px 0 4px; }
.panel.units .unit-help { font-size: 11px; line-height: 1.35; }
/* One icon per selected unit with its HP. Marked with Shift + click: framed in gold until Shift is released. */
.unit-tiles { display: flex; flex-wrap: wrap; gap: 3px; max-height: 190px; overflow-y: auto; }
.unit-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 32px; padding: 2px 2px 3px; border-radius: 4px; }
/* A transport's tile: how many units are on board, like the badge over the boat on the map */
.unit-tile .tile-count { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px;
  background: rgba(28, 19, 11, 0.92); border: 1px solid #e8c04a; color: #fff4c8; font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; }
.unit-tile img { display: block; width: 24px; height: 24px; }
.unit-tile .uhp { display: block; width: 100%; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); overflow: hidden; }
.unit-tile .uhp > i { display: block; height: 100%; }
.unit-tile.disbanding, .unit-tile.disbanding:hover:not(:disabled) { border-color: var(--danger); background: rgba(192, 57, 43, 0.18); }
.unit-tile.picked, .unit-group.picked, .unit-tile.picked:hover:not(:disabled), .unit-group.picked:hover:not(:disabled) {
  border-color: var(--gold); background: rgba(201, 162, 74, 0.32); box-shadow: inset 0 0 0 1px var(--gold);
}

.overlay { background: rgba(24, 18, 12, 0.97); left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 18px 22px; z-index: 5; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.25), 0 12px 40px rgba(0, 0, 0, 0.6); min-width: 340px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow-y: auto; }
.overlay h3, .overlay h2 { font-family: var(--serif); color: var(--gold); margin: 0 0 10px; }
.overlay table { border-collapse: collapse; width: 100%; }
.overlay td, .overlay th { padding: 5px 10px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.overlay th { color: var(--muted); font-weight: 500; font-size: 12px; }
/* Same size on every page, so the tabs stay put when you switch. */
#help { width: min(820px, calc(100vw - 32px)); min-height: min(790px, calc(100vh - 32px)); flex-direction: column; }
#help:not([hidden]) { display: flex; }
#help-close { align-self: flex-start; margin-top: auto; }
.help-page { padding-bottom: 14px; }
#help td:first-child { color: var(--gold); white-space: nowrap; vertical-align: top; }
#help p { line-height: 1.5; }
#help b { color: var(--paper); }
#help h3.help-sub { margin-top: 18px; }
.help-tabs { display: flex; gap: 4px; margin: -4px 0 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.help-tabs button, .help-tabs button:hover:not(:disabled) {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 6px 14px; margin-bottom: -1px; color: var(--muted);
}
.help-tabs button:hover:not(:disabled) { color: var(--paper); }
.help-tabs button.active, .help-tabs button.active:hover:not(:disabled) { color: var(--gold); border-bottom-color: var(--gold); }
/* Technologies window (T): tabs like the help, one card per technology. */
#tech { width: min(660px, calc(100vw - 32px)); }
.tech-page > p { line-height: 1.5; margin: 0 0 12px; }
/* A technology: its picture on the left; name, one-line summary, details and research on the right */
.tech-card { display: flex; align-items: flex-start; gap: 14px; padding: 12px 14px; margin-bottom: 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); }
.tech-card.done { border-color: rgba(95, 191, 95, 0.45); background: rgba(95, 191, 95, 0.07); }
.tech-icon { flex: none; width: 60px; height: 60px; padding: 3px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(201, 162, 74, 0.45); }
.tech-body { flex: 1; min-width: 0; }
.tech-head { display: flex; align-items: center; gap: 10px; }
.tech-head b { font-size: 16px; color: var(--paper); font-family: var(--serif); }
.tech-head .small { margin-left: auto; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--gold); }
.pips i.on { background: var(--gold); }
.tech-summary { color: var(--paper-2); font-size: 14px; font-weight: 600; margin-top: 3px; }
.tech-text { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 5px 0 10px; }
.tech-actions { display: flex; align-items: center; gap: 10px; }
.tech-price { color: var(--paper-2); font-size: 13px; }
.tech-done { color: #8fdc8f; font-weight: 600; }
.tech-progress { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.tech-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a9822f, #e6c26a); }
.tech-close { margin-top: 6px; }
.tech-actions + .tech-actions { margin-top: 8px; }
.tech-queued { color: var(--gold); font-size: 13px; white-space: nowrap; }
/* Tech window: the levels queued after the research running (all tabs), each with ✕. */
.plan-queue { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.plan-item { display: inline-flex; align-items: center; gap: 6px; padding: 2px 3px 2px 8px; border-radius: 4px; font-size: 13px;
  color: var(--paper); background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(201, 162, 74, 0.35); }
.plan-item button { padding: 0 6px; font-size: 11px; line-height: 18px; }
#honor .tech-queued { color: #ffb3a8; }
/* Honor window: the Tech window's cards on near-black, with blood red only as accents (a faint glow at
   the top, a crimson frame, the progress bar and the Close button). */
#honor {
  width: min(620px, calc(100vw - 32px));
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(150, 22, 28, 0.32), transparent 75%),
    linear-gradient(180deg, #1d0d0d 0%, #120b0a 35%, #0d0908 100%);
  border: 2px solid #6e161b;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.7), inset 0 0 0 1px rgba(0, 0, 0, 0.7);
}
#honor h3 { color: #efe2cf; font-size: 22px; letter-spacing: 1px; text-shadow: 0 0 12px rgba(200, 30, 30, 0.45); }
#honor > p { line-height: 1.5; margin: 0 0 12px; }
#honor > p { color: var(--muted); }
#honor .tech-card { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.08); }
/* A tradition: one row as tall as its picture, learning it on the right; the details are its tooltip. */
#honor .honor-card { align-items: center; gap: 12px; padding: 6px 10px; margin-bottom: 6px; cursor: help; }
#honor .honor-card .tech-icon { width: 48px; height: 48px; padding: 2px; }
#honor .honor-card .tech-summary { font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#honor .honor-card .tech-actions { flex: none; margin-left: auto; }
#honor .honor-card .tech-actions button { padding: 6px 14px; cursor: pointer; }
#honor .honor-card .tech-actions button:disabled { cursor: default; }
#honor .honor-card .tech-progress { flex: none; width: 90px; }
#honor .honor-card:hover { border-color: rgba(168, 50, 58, 0.55); }
#honor .honor-card.done:hover { border-color: rgba(143, 220, 143, 0.55); }
#honor .tech-card.done { background: rgba(255, 255, 255, 0.04); border-color: rgba(143, 220, 143, 0.35); }
#honor .tech-icon { background: rgba(0, 0, 0, 0.4); border-color: rgba(255, 255, 255, 0.14); }
#honor .tech-progress { background: rgba(255, 255, 255, 0.07); }
#honor .tech-progress i { background: linear-gradient(90deg, #5a0a0e, #b3202a); }
#honor button.primary { background: linear-gradient(180deg, #8e1c22, #5c0e12); color: #f6e8dc; border-color: #a8323a; }
#honor button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #a2242b, #6c1116); }
#honor button:not(.primary) { background: rgba(255, 255, 255, 0.04); color: var(--text); border-color: rgba(255, 255, 255, 0.18); }
#honor button:not(.primary):hover:not(:disabled) { background: rgba(168, 50, 58, 0.18); border-color: #a8323a; }
.honor-have { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 18px; }
.honor-have .honor { width: 20px; height: 20px; }
.honor-sub { font-family: var(--serif); color: var(--paper-2); font-size: 15px; margin: 4px 0 8px; }
/* The ultimate tradition (Eternal Glory): its name is always written in red, wherever it shows. */
.ultimate { color: #ff4a3d; font-weight: 700; text-shadow: 0 0 8px rgba(220, 30, 30, 0.55); }
#honor .tech-head b.ultimate { color: #ff4a3d; }
.ultimate-tag { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #ffb3a8;
  border: 1px solid rgba(255, 74, 61, 0.6); border-radius: 3px; padding: 1px 5px; }
.ultimate-lock { color: #ffb3a8; font-size: 13px; white-space: nowrap; }
/* Units box with Eternal Glory: pay with gold or with honor. */
.pay-switch { display: flex; align-items: center; gap: 4px; margin: 0 0 4px; }
.pay-switch .muted { margin-right: 4px; }
.pay-switch button { padding: 2px 8px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.pay-switch button .honor { width: 11px; height: 11px; }
.pay-switch button.active { background: rgba(201, 162, 74, 0.28); border-color: var(--gold); }
.pay-switch button.active:has(.honor) { background: linear-gradient(180deg, #2a1011, #110a09); border-color: #a8323a; }
/* Players list: traditions, an icon each; the ultimate one framed in red (its countdown, while learned, in red text). */
.overlay td.trads { white-space: nowrap; }
.overlay td.trads img { width: 22px; height: 22px; vertical-align: middle; margin-right: 2px; border-radius: 3px; background: rgba(0, 0, 0, 0.35); }
.overlay td.trads img.ultimate-icon {
  margin-left: 3px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(150, 22, 28, 0.6), transparent 75%),
    linear-gradient(180deg, #1d0d0d, #0d0908);
  box-shadow: 0 0 0 1.5px #6e161b, 0 0 0 2.5px rgba(0, 0, 0, 0.7);
}
.overlay td.trads .ultimate { font-size: 12px; margin-left: 4px; vertical-align: middle; }
/* Feed: the ultimate tradition, announced to everyone. */
.feed div.ultimate { border-left-color: #c8262c; color: #ffcfc8; text-shadow: none; }
.me-row td { background: rgba(201, 162, 74, 0.12); }
.overlay td.num, .overlay th.num { text-align: right; font-variant-numeric: tabular-nums; }
.overlay td.kills { color: #8fdc8f; }
.overlay td.income { color: var(--gold); }
.overlay td.losses { color: #f0a090; }

/* ------------------------------------------------------------ results screen (results.js) */
/* The game is over: the results bar takes the place of the top bar; open, the results cover the whole screen. */
#screen-game.game-over #topbar { display: none; }
.results { position: absolute; z-index: 8; color: var(--text); }
.results:not(.open) { top: 8px; left: 8px; right: 8px; }
.results.open { inset: 0; background: radial-gradient(ellipse 120% 80% at 50% 0%, #2a2016, #16100a 70%); }
.results h3 { font-family: var(--serif); color: var(--gold); margin: 0 0 10px; font-size: 18px; }
.results h4 { margin: 0; font-size: 13px; font-weight: 600; color: var(--paper-2); }
/* A player's name: a dot in their exact colour, then the name in that colour made readable (results.js ink). */
.pname { white-space: nowrap; }
.pname b { font-weight: 700; }
.pdot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; vertical-align: 0.05em; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4); }
.detail-head .pdot { width: 15px; height: 15px; margin-right: 10px; vertical-align: 0.08em; }

.results-bar {
  display: flex; align-items: center; gap: 14px; height: 42px; padding: 0 6px 0 14px; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}
.results-bar .results-title { font-family: var(--serif); color: var(--gold); font-size: 19px; flex: none; }
.results-bar .results-line { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.results-bar .results-time { flex: none; }
.results-gap { flex: 1; }
.results-bar button { padding: 5px 12px; font-size: 13px; flex: none; }

.results-full { display: flex; flex-direction: column; height: 100%; }
.results-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px 20px;
  padding: 16px 24px 0; border-bottom: 1px solid rgba(201, 162, 74, 0.35); background: rgba(36, 27, 18, 0.6);
}
.results-heading h2 { font-family: var(--serif); color: var(--gold); font-size: 30px; line-height: 1.1; margin: 0; }
.results-heading .results-line { margin: 4px 0 12px; }
.results-tabs { margin: 0; border-bottom: none; }
.results-tabs button, .results-tabs button:hover:not(:disabled) { padding: 8px 20px 10px; font-size: 15px; }
.results-actions { justify-self: end; display: flex; gap: 8px; padding-bottom: 12px; }
.results-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 24px 28px; }
.results-page { max-width: 1320px; margin: 0 auto; }
.results-section { margin-top: 26px; }
.results-empty { max-width: 560px; margin: 40px auto; }

/* Tables: the Players list and a player's army. */
.table-wrap { overflow-x: auto; }
.results-table { border-collapse: collapse; width: 100%; }
.results-table th, .results-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.07); white-space: nowrap; }
.results-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.results-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.results-table td.kills { color: #8fdc8f; }
.results-table td.losses { color: #f0a090; }
.results-table td.income { color: var(--gold); }
.results-table tr.clickable { cursor: pointer; }
.results-table tr.clickable:hover td, .results-table tr.clickable:focus-visible td { background: rgba(201, 162, 74, 0.1); }
.results-table tr.clickable:focus-visible { outline: none; }
.results-table tr.me-row td { background: rgba(201, 162, 74, 0.12); }
.results-table tr.me-row:hover td { background: rgba(201, 162, 74, 0.2); }
.results-table td.go { color: var(--muted); font-size: 18px; width: 1%; }
.results-table .who-cell { font-size: 15px; }
.results-table.compact td, .results-table.compact th { padding: 5px 8px; }
.results-table .total-row td { border-bottom: none; color: var(--paper-2); font-weight: 600; }
.status { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; vertical-align: 1px; background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.status.winner { background: rgba(201, 162, 74, 0.25); color: var(--gold); }
.status.eliminated, .status.left { color: #f0a090; background: rgba(192, 57, 43, 0.16); }
.icons { white-space: nowrap; }
.icon-badge { position: relative; display: inline-block; margin-right: 4px; vertical-align: middle; line-height: 0; }
.icon-badge img { width: 24px; height: 24px; border-radius: 4px; background: rgba(0, 0, 0, 0.35); }
.icon-badge small {
  position: absolute; right: -4px; bottom: -3px; min-width: 13px; height: 13px; padding: 0 2px; border-radius: 7px; line-height: 12px;
  text-align: center; font-size: 9px; font-weight: 700; background: #1c130b; border: 1px solid var(--gold); color: var(--paper);
}
.icon-badge.ultimate-icon img {
  background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(150, 22, 28, 0.6), transparent 75%), linear-gradient(180deg, #1d0d0d, #0d0908);
  box-shadow: 0 0 0 1.5px #6e161b;
}

/* Charts: a crosshair tooltip, line keys, a legend under them. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h3 { margin: 0; }
.chart-note { margin: 6px 0 8px; }
.segmented { display: inline-flex; border: 1px solid rgba(201, 162, 74, 0.4); border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.segmented button, .segmented button:hover:not(:disabled) { border: none; border-radius: 0; padding: 5px 12px; font-size: 13px; background: transparent; color: var(--muted); }
.segmented button + button { border-left: 1px solid rgba(201, 162, 74, 0.25); }
.segmented button:hover:not(:disabled) { color: var(--paper); background: rgba(201, 162, 74, 0.1); }
.segmented button.active, .segmented button.active:hover:not(:disabled) { background: rgba(201, 162, 74, 0.28); color: var(--paper); }
.chart { position: relative; width: 100%; }
.chart.pickable canvas { cursor: pointer; }
.chart-canvas { display: block; }
.chart-tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 120px; max-width: 260px; padding: 7px 10px; border-radius: 6px;
  background: rgba(22, 16, 10, 0.97); border: 1px solid var(--panel-border); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5); font-size: 12.5px;
}
.chart-tip-head { color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.chart-tip-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; line-height: 1.6; }
.chart-tip-row b { font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; color: var(--text); }
.chart-tip-row span { color: var(--paper-2); overflow: hidden; text-overflow: ellipsis; }
.line-key { display: inline-block; flex: none; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.chart-legend.inline { margin: 0; gap: 4px 12px; font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend:not(.inline) .legend-item { cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.chart-legend:not(.inline) .legend-item:hover { background: rgba(255, 255, 255, 0.06); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card { padding: 10px 12px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06); }
.chart-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

/* A player's page. */
.detail-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-switch { display: flex; flex-wrap: wrap; gap: 6px; }
.player-chip, .player-chip:hover:not(:disabled) { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 6px; border-radius: 99px; font-size: 12px; }
.player-chip.active { border-color: var(--gold); background: rgba(201, 162, 74, 0.25); }
.player-chip .swatch { width: 11px; height: 11px; }
.detail-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h3 { font-size: 28px; margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile { padding: 10px 14px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-family: var(--serif); font-size: 26px; color: var(--paper); font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile-sub { font-size: 12px; color: var(--muted); }
.detail-columns { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 32px; }
.unit-cell img { width: 22px; height: 22px; vertical-align: middle; margin-right: 8px; }
.build-list { display: flex; flex-wrap: wrap; gap: 8px; }
.build-item { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 5px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); }
.build-item img { width: 24px; height: 24px; }
.milestones { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.milestones li { display: grid; grid-template-columns: 64px 22px 1fr; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.milestones img { width: 22px; height: 22px; border-radius: 4px; background: rgba(0, 0, 0, 0.35); }
.milestones .m-turn { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.milestones .m-dot { width: 8px; height: 8px; margin: 0 7px; border-radius: 50%; background: var(--muted); }
.milestones li.won .m-dot { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.milestones li.fell .m-dot, .milestones li.out .m-dot, .milestones li.left .m-dot { background: #f0a090; }
.milestones li.back .m-dot { background: #8fdc8f; }

/* Timeline: the map turn by turn, with the standings and the turn's events beside it. */
.results-body.timeline-body { overflow: hidden; display: flex; padding: 14px 18px; }
.timeline { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.tl-main { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.tl-map { position: relative; flex: 1; min-height: 0; border-radius: 8px; overflow: hidden; background: var(--sea); border: 1px solid rgba(201, 162, 74, 0.3); }
.tl-canvas { position: absolute; left: 0; top: 0; display: block; }
.tl-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-controls button { padding: 5px 10px; min-width: 36px; line-height: 1.2; }
.tl-slider { flex: 1; min-width: 160px; padding: 0; accent-color: var(--gold); border: none; background: none; box-shadow: none !important; }
.tl-label { color: var(--paper-2); font-variant-numeric: tabular-nums; min-width: 150px; text-align: center; }
.tl-speed { padding: 5px 8px; border-radius: 6px; border: 1px solid rgba(201, 162, 74, 0.4); background: rgba(0, 0, 0, 0.35); color: var(--text); }
.tl-speed option { background: #241b12; }
.tl-side {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.06);
}
.tl-side h3 { margin: 0; font-size: 22px; }
.tl-side h4 { margin-top: 6px; }
.tl-standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tl-standings li { display: grid; grid-template-columns: minmax(0, 110px) 1fr 34px 30px; align-items: center; gap: 8px; font-size: 13px; }
.tl-standings li.tl-neutral { display: block; }
.tl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.tl-bar i { display: block; height: 100%; border-radius: 4px; }
.tl-standings b { text-align: right; font-variant-numeric: tabular-nums; }
.tl-standings small { font-variant-numeric: tabular-nums; }
.tl-standings small.up { color: #8fdc8f; }
.tl-standings small.down { color: #f0a090; }
.tl-events { display: grid; gap: 4px; font-size: 13px; line-height: 1.45; }
.tl-events p { margin: 0; padding: 3px 0 3px 8px; border-left: 2px solid rgba(201, 162, 74, 0.35); }
.tl-events p.muted { border-left-color: transparent; padding-left: 0; }
.tl-events p.ev { border-left-color: rgba(143, 220, 143, 0.5); }
.tl-events p.ev.won { border-left-color: var(--gold); }
.tl-events p.ev.fell, .tl-events p.ev.out, .tl-events p.ev.left { border-left-color: rgba(240, 160, 144, 0.6); }
.tl-tip { min-width: 0; }

@media (max-width: 900px) {
  .results-head { grid-template-columns: 1fr; align-items: start; padding: 12px 16px 0; }
  .results-actions { justify-self: start; padding-bottom: 8px; }
  .results-body { padding: 14px 16px 24px; }
  .results-bar .results-line, .results-bar .results-time { display: none; }
  .chart-grid, .detail-columns { grid-template-columns: 1fr; }
  .results-body.timeline-body { overflow-y: auto; display: block; }
  .timeline { display: flex; flex-direction: column; }
  .tl-map { flex: none; height: 60vh; }
}

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none;
  max-width: min(340px, calc(100vw - 12px)); padding: 7px 11px; border-radius: 6px;
  background: rgba(22, 16, 10, 0.97); border: 1px solid var(--panel-border);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  color: var(--text); font-size: 12.5px; line-height: 1.45; white-space: pre-line;
}

.top-center { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; max-width: calc(100vw - 32px); }
.banner { background: rgba(20, 15, 10, 0.88); border: 1px solid var(--panel-border); padding: 10px 18px; border-radius: 8px; font-size: 15px; text-align: center; }
/* Players close to the target: one line each, the one who wins when the turn ends in red (gold if it is you). */
.race { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.race div { background: rgba(20, 15, 10, 0.86); border: 1px solid var(--panel-border); border-radius: 6px; padding: 3px 12px; font-size: 14px; white-space: nowrap; }
.race div.wins { border-color: var(--danger); box-shadow: 0 0 10px rgba(200, 60, 40, 0.45); }
.race div.wins.me { border-color: var(--gold); box-shadow: 0 0 10px rgba(201, 162, 74, 0.5); }
.race div.more { font-size: 12px; color: var(--muted); }
/* Before a game starts: who has loaded it, then the countdown in big numbers. The map stays usable around it. */
.prestart { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 4; text-align: center; background: rgba(20, 15, 10, 0.88); border: 1px solid var(--panel-border); border-radius: 10px; padding: 14px 28px 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); max-width: calc(100vw - 32px); }
.prestart .label { font-size: 15px; }
.prestart b { display: block; font-family: var(--serif); color: var(--gold); font-size: 56px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.prestart.go b { font-size: 64px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #7a2a20; color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); z-index: 50; }

/* ------------------------------------------------------------ debug tools (DEBUG builds only) */
.dev-console {
  position: fixed; left: 0; right: 0; top: 0; height: 40vh; z-index: 100; display: flex; flex-direction: column;
  background: rgba(8, 10, 14, 0.92); border-bottom: 2px solid #4ac8ff; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  font: 13px/1.45 Consolas, 'Courier New', monospace; color: #d8e2ea;
}
.dev-console-log { flex: 1; overflow-y: auto; padding: 8px 12px; white-space: pre-wrap; }
.dev-console-log .cmd { color: #ffffff; }
.dev-console-log .err { color: #ff7a6a; }
.dev-console-log .dim { color: #7f8c99; }
.dev-console-input { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.dev-console-input span { color: #4ac8ff; }
.dev-console-input input, .dev-console-input input:focus { flex: 1; background: transparent; border: none; box-shadow: none; padding: 2px 0; color: #ffffff; font: inherit; }
.dev-overlays { position: absolute; top: 60px; right: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; z-index: 4; }
.dev-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.dev-nav-legend { background: rgba(0, 0, 0, 0.66); padding: 7px 10px; border-radius: 4px; font: 12px Consolas, monospace; display: grid; gap: 3px; min-width: 230px; }
.dev-nav-legend b { color: #4ac8ff; font-weight: 600; margin-bottom: 2px; }
.dev-nav-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 7px; vertical-align: -2px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 2px; }
.dev-nav-cursor { color: #c9d4de; margin-top: 3px; min-height: 1em; }
.dev-stat-fps { font: 600 16px Consolas, monospace; text-shadow: 0 1px 2px #000; }
.dev-stat-unit { background: rgba(0, 0, 0, 0.6); padding: 6px 10px; border-radius: 4px; font: 13px Consolas, monospace; min-width: 160px; }
.dev-stat-unit div { display: flex; justify-content: space-between; gap: 16px; }
.dev-stat-graph { border-radius: 4px; }
.dev-badge { position: fixed; right: 8px; bottom: 4px; z-index: 60; font: 11px Consolas, monospace; color: rgba(255, 216, 74, 0.8); pointer-events: none; text-shadow: 0 1px 2px #000; }

@media (max-width: 900px) {
  #topbar { gap: 10px; }
  #topbar .title { display: none; }
  /* Above the minimap, which is smaller here by default (render.js miniDefaultWidth). */
  .panel { left: 8px; right: 226px; transform: none; min-width: 0; max-width: none; bottom: calc(var(--minimap-h, 142px) + 16px); }
  .build-col { top: 60px; bottom: auto; width: 210px; }
  .build-btn .eff { display: none; }
  .build-btn .cost { white-space: normal; }
}

/* ------------------------------------------------------------ game balance editor (admins) */
.balance-editor { width: min(1120px, calc(100vw - 32px)); max-height: calc(100vh - 80px); display: flex; flex-direction: column; padding: 16px 18px; z-index: 20; }
.balance-editor .editor-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.balance-editor .editor-head h3 { margin: 0; }
.balance-editor .editor-body { overflow: auto; margin: 8px 0; padding-right: 4px; }
.balance-editor h4 { margin: 14px 0 6px; font-family: var(--serif); color: var(--paper-2); font-size: 15px; }
.editor-table { border-collapse: collapse; width: 100%; }
.editor-table th { font-size: 11px; color: var(--muted); font-weight: 500; text-align: left; padding: 4px 6px; white-space: nowrap; }
.editor-table td { padding: 3px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.editor-table td.row-name { font-weight: 600; white-space: nowrap; color: var(--paper); }
.editor-table input { width: 84px; padding: 4px 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.editor-table input.changed { border-color: var(--gold); background: rgba(201, 162, 74, 0.16); }
.editor-table input:disabled { opacity: 0.6; }
.balance-editor .editor-foot { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.balance-editor .editor-status { flex: 1; font-size: 12px; color: var(--muted); }
.balance-editor .editor-status.ok { color: #8fdc8f; }
.balance-editor .editor-status.dirty { color: var(--gold); }
.balance-editor .editor-status.err { color: #ff8a7a; }

/* Delete key: units losing HP until they die */
.disband-note { margin-top: 6px; padding: 4px 8px; border-radius: 4px; font-size: 12px;
  color: #ffb3a8; background: rgba(150, 20, 28, 0.35); border: 1px solid rgba(220, 60, 60, 0.45); }
.disband-note[hidden] { display: none; }

/* Your selected transports: one place per unit they can carry, and the Unload button */
.cargo { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.cargo-row { display: flex; align-items: center; gap: 3px; margin-bottom: 4px; }
.cargo-row .cargo-ship { width: 34px; height: 34px; margin-right: 4px; flex: none; }
.cargo-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 32px; padding: 2px 2px 3px;
  border-radius: 4px; border: 1px solid rgba(127, 216, 255, 0.35); background: rgba(40, 90, 130, 0.25); }
.cargo-slot img { display: block; width: 26px; height: 26px; }
.cargo-slot.empty { border-style: dashed; background: rgba(0, 0, 0, 0.2); }
.cargo-slot.empty img { visibility: hidden; }
.cargo-slot .uhp { display: block; width: 100%; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); overflow: hidden; }
.cargo-slot .uhp > i { display: block; height: 100%; }
.cargo-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.cargo-actions button { flex: none; }
.cargo-actions kbd { font-size: 10px; margin-left: 6px; opacity: 0.75; }
/* Units panel: Make Hero and Make Healer. */
.hero-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }
.hero-row button { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.hero-row kbd { font-size: 10px; margin-left: 2px; opacity: 0.75; }
.hero-row .honor { width: 13px; height: 13px; }
