:root {
  --bg: #000000;
  --panel: #0b100d;
  --panel-2: #101710;
  --card: #192219;
  --card-2: #30402e;
  --line: #39432e;
  --line-2: #706947;
  --text: #f3ead1;
  --text-2: #c3cbb9;
  --muted: #a6ae98;
  --cyan: #dec581;
  --cyan-d: #bda365;
  --green: #9ccea2;
  --warm: #ffb454;
  --warm-d: #c08a3a;
  --red: #ff4466;
  --gold: #ffd34d;
  --sci: #b388ff;
  --p1: #00d4ff;
  --p2: #ff7a59;
  --focus: #f5dca0;
  --focus-glow: rgba(222,197,129,0.25);
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --font-num: 'SF Mono', 'Consolas', 'Roboto Mono', ui-monospace, monospace;
  --font-ui:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The game is designed at a fixed 600x600 layout for the Meta Display glasses.
   On glasses, the device viewport IS 600x600 so the scale below is 1.0 and
   nothing changes. On phone or PC, html/body fills the window and #app stays
   600x600 but is scaled+centered to fit. Click coordinates are translated by
   onCanvasClick using canvas.getBoundingClientRect so taps land correctly. */
html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  touch-action: manipulation;     /* faster tap response on mobile, no 300ms delay */
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  position: relative;
  width: 600px;
  height: 600px;
  flex-shrink: 0;
  /* The --app-scale variable is set by JS on load + resize to
     min(window.innerWidth, window.innerHeight) / 600. On the glasses
     (600x600 viewport) it stays at 1.0; on phone/PC it fits the window. */
  transform: scale(var(--app-scale, 1));
  transform-origin: center center;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

/* ====================================================================
   TITLE SCREEN
   ==================================================================== */
#title {
  background:
    radial-gradient(circle at 50% 30%, rgba(0,212,255,0.18), transparent 50%),
    radial-gradient(circle at 30% 80%, rgba(179,136,255,0.10), transparent 50%),
    var(--bg);
  overflow: hidden;
}
#title::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 50%, rgba(255,255,255,0.02) 100%);
  pointer-events: none;
}
.title-bg-hex {
  /* Oversized by one drift period and moved via transform, so the endless
     background scroll runs on the GPU compositor instead of repainting the
     full 600×600 gradient every frame (the panel is hard-locked at 30Hz). */
  position: absolute;
  inset: -480px -280px 0 0;
  opacity: 0.10;
  pointer-events: none;
  background-image:
    radial-gradient(circle, transparent 8px, transparent 9px),
    repeating-linear-gradient(60deg, rgba(0,212,255,0.6) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(-60deg, rgba(0,212,255,0.6) 0 1px, transparent 1px 28px);
  animation: drift 60s linear infinite;
  will-change: transform;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-280px, 480px, 0); }
}
.title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 28px;
  position: relative;
  z-index: 1;
}
.title-mark {
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.title-mark::before,
.title-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--cyan);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  opacity: 0.55;
}
.title-mark::after {
  transform: scale(0.78);
  border-color: var(--green);
  opacity: 0.8;
}
.title-hex {
  font-size: 56px;
  color: var(--cyan);
  line-height: 1;
  filter: drop-shadow(0 0 14px rgba(0,212,255,0.7));
  position: relative;
  z-index: 1;
  font-weight: 900;
}
.title-name {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #7ce5ff 50%, #00d4ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(0,212,255,0.35);
  margin-top: 4px;
}
.title-sub {
  color: var(--text-2);
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 12px;
  opacity: 0.85;
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 280px;
}

.title-actions-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.title-actions-row .nav-item.small {
  flex: 1;
  font-size: 12px;
  padding: 8px 10px;
}

.title-audio {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  width: 280px;
}

/* Save share modal — used for both Export and Import */
.share-hint {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
  margin: 4px 0 10px;
}
.share-hint b { color: var(--cyan); }
.share-code {
  width: 100%;
  height: 320px;
  resize: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-num);
  font-size: 11px;
  line-height: 1.35;
  padding: 8px 10px;
  word-break: break-all;
  margin-bottom: 10px;
}
.share-code:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.share-actions {
  display: flex;
  gap: 8px;
}
.share-actions .nav-item {
  flex: 1;
}

/* Cloud sync screen */
.cloud-status {
  font-size: 12px;
  line-height: 1.45;
  border-radius: var(--r-md);
  padding: 9px 11px;
  margin: 2px 0 12px;
  background: var(--card);
  border-left: 3px solid var(--line-2);
  color: var(--text-2);
}
.cloud-status b { color: var(--text); }
.cloud-status code { font-family: var(--font-num); color: var(--cyan); }
.cloud-status.ok    { border-left-color: var(--green); }
.cloud-status.warn  { border-left-color: #ffd34d; }
.cloud-status.err   { border-left-color: #ff6b6b; }
.cloud-status .cloud-dot { font-size: 13px; vertical-align: -1px; }
.cloud-status .cloud-dot.ok   { color: var(--green); }
.cloud-status .cloud-dot.warn { color: #ffd34d; }
.cloud-status .cloud-dot.err  { color: #ff6b6b; }
.cloud-qr {
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  display: block;
  width: max-content;
  margin: 0 auto 12px;
}
.cloud-qr img { display: block; width: 150px; height: 150px; }
#cloud-screen .modal-card { overflow-y: auto; }
.cloud-link {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--cyan);
  word-break: break-all;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.cloud-code-row { display: flex; gap: 8px; margin: 4px 0 10px; }
.cloud-actions-row { display: flex; gap: 8px; margin: 4px 0 10px; }
.cloud-actions-row .nav-item { flex: 1; font-size: 12px; padding: 9px 8px; min-height: 40px; }

/* On-screen code keyboard (neural-band driven) */
.kb-display {
  font-family: var(--font-num);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--cyan);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin: 6px 0 12px;
  min-height: 26px;
  text-align: center;
  word-break: break-all;
}
.kb-grid { display: grid; gap: 6px; }
.kb-key {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-num);
  font-size: 16px;
  padding: 10px 0;
  min-height: 40px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.1s;
}
.kb-key.kb-special { font-size: 13px; color: var(--text-2); }
.kb-key.kb-set { color: var(--green); border-color: rgba(0,255,136,0.4); }
.kb-key.kb-cancel { color: var(--red); border-color: rgba(255,68,102,0.4); }
.kb-key.kb-focused {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.16);
  box-shadow: 0 0 12px var(--focus-glow);
  transform: translateY(-1px);
}
.cloud-code-input {
  flex: 1; min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-num);
  font-size: 15px;
  letter-spacing: 1px;
  padding: 8px 10px;
}
.cloud-code-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.cloud-code-row .nav-item { flex: 0 0 auto; }
.cloud-link-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 6px 0 4px; }

/* Event log panel */
.log-body {
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
  padding-right: 2px;
}
.log-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.35;
  padding: 5px 8px;
  background: var(--panel-2);
  border-radius: var(--r-sm);
  border-left: 2px solid var(--line-2);
}
.log-row.win { border-left-color: var(--green); }
.log-row.err { border-left-color: var(--red); }
.log-turn {
  flex: 0 0 30px;
  color: var(--muted);
  font-family: var(--font-num);
  font-size: 11px;
}
.log-msg { color: var(--text-2); }
.log-row.win .log-msg { color: #b8f0d0; }
.log-row.err .log-msg { color: #ffc0cc; }
.log-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

/* World report / standings */
.standings-body {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 2px;
}
.rep-civ {
  background: var(--panel-2);
  border-left: 3px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}
.rep-civ.dead { opacity: 0.5; }
.rep-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
}
.rep-stats {
  font-size: 12px;
  color: var(--text-2);
  font-family: var(--font-num);
  margin-bottom: 5px;
}
.rep-vic {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rep-vbar {
  font-size: 11px;
  color: var(--muted);
  background: var(--card);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-num);
}
.rep-seed {
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-num);
  padding: 6px 10px;
  margin-bottom: 4px;
  background: var(--panel-2);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--gold);
}
.rep-seed b { color: var(--gold); letter-spacing: 1px; }
/* World Report: per-civ closest-victory "finish line" bar */
.rep-finish { margin: 5px 0 2px; }
.rep-finish-lbl { font-size: 11px; color: var(--text-2); font-family: var(--font-num); }
.rep-finish.hot .rep-finish-lbl { color: var(--red); font-weight: 700; }
.rep-finish-bar { display: block; height: 5px; margin-top: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.rep-finish-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffe9a0); border-radius: 3px; }
.rep-finish.hot .rep-finish-bar > i { background: linear-gradient(90deg, var(--red), #ff8aa0); }

/* In-game finish-line banner — only shown once the victory race heats up */
.victory-race {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--font-num);
  background: rgba(16,16,32,0.92);
  border: 1px solid var(--line-2);
  cursor: pointer;
  white-space: nowrap;
}
.victory-race.mine  { color: var(--green); border-color: rgba(0,255,136,0.5); box-shadow: 0 0 12px rgba(0,255,136,0.2); }
.victory-race.rival { color: var(--red);   border-color: rgba(255,68,102,0.55); box-shadow: 0 0 12px rgba(255,68,102,0.25); }
.victory-race .vr-bar { display: inline-block; width: 54px; height: 5px; background: var(--panel); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.victory-race .vr-bar > i { display: block; height: 100%; border-radius: 3px; }
.victory-race.mine  .vr-bar > i { background: var(--green); }
.victory-race.rival .vr-bar > i { background: var(--red); }
/* Daily Challenge button tag (best turn / streak) on the title screen */
.daily-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  margin-left: 6px;
  letter-spacing: 0.5px;
}
.audio-toggle {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.audio-toggle:hover { background: var(--panel-2); color: var(--text); }
.audio-toggle.on {
  color: var(--cyan);
  border-color: var(--cyan-d);
  background: rgba(0,212,255,0.06);
}
.audio-toggle .audio-state {
  font-weight: 700;
  margin-left: 4px;
}
.audio-toggle:focus {
  outline: 2px solid var(--focus);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

/* ====================================================================
   CIV SELECT
   ==================================================================== */
#civ-select {
  background:
    radial-gradient(circle at 50% 30%, rgba(0,212,255,0.10), transparent 50%),
    var(--bg);
  padding: 0;
}
#civ-select .header {
  background: linear-gradient(to bottom, var(--panel), transparent);
  border-bottom: 1px solid var(--line);
}
.civ-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 8px;
  overflow-y: auto;
}
.civ-card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  align-items: stretch;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  min-height: 88px;
}
.civ-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--civ-color, var(--cyan));
}
.civ-card:focus {
  outline: none;
  border-color: var(--civ-color, var(--cyan));
  box-shadow: 0 0 24px var(--civ-glow, var(--focus-glow));
  transform: translateY(-1px);
}
.civ-emblem {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--civ-color, var(--cyan));
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: var(--civ-color, var(--cyan));
  font-size: 28px;
  font-weight: 800;
  align-self: center;
}
.civ-body { flex: 1; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.civ-name {
  font-size: 17px;
  font-weight: 800;
  color: var(--civ-color, var(--cyan));
  letter-spacing: 1px;
}
.civ-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.civ-bonus {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  margin-top: 2px;
}
.civ-hint {
  padding: 8px 16px 14px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-num);
  letter-spacing: 1px;
  text-align: center;
}

/* --- Game Setup Options (map size, difficulty) --- */
.setup-row {
  padding: 6px 14px;
}
.setup-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
  font-family: var(--font-num);
}
.setup-options {
  display: flex;
  gap: 6px;
}
.setup-btn {
  flex: 1;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 6px 4px;
  color: var(--text-2);
  font-size: 12px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  font-family: var(--font-ui);
}
.setup-btn b {
  display: block;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 1px;
}
.setup-desc {
  display: block;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.2;
}
.setup-btn.active {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.10);
}
.setup-btn.active b {
  color: var(--cyan);
}
.setup-btn:focus {
  border-color: var(--focus);
  box-shadow: 0 0 8px var(--focus-glow);
}

/* Difficulty slider — a labelled 5-stop track. Each stop is a focusable
   button so it works with D-pad focus + Enter and with direct tap/click. */
.diff-current {
  color: var(--cyan);
  font-weight: 700;
  margin-left: 6px;
}
.diff-slider {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 10px;
  padding: 0 2px;
}
/* base track + cyan fill, vertically centred on the dots */
.diff-slider::before {
  content: '';
  position: absolute;
  left: 12px; right: 12px; top: 8px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
}
.diff-slider-fill {
  position: absolute;
  left: 12px; top: 8px;
  height: 3px;
  background: var(--cyan-d);
  border-radius: 2px;
  transition: width 0.18s ease;
}
.diff-stop {
  position: relative;
  z-index: 1;
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-ui);
  padding: 0;
}
.diff-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line);
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.diff-stop.filled .diff-dot {
  background: var(--cyan-d);
  border-color: var(--cyan-d);
}
.diff-stop.active .diff-dot {
  background: var(--cyan);
  border-color: var(--cyan);
  transform: scale(1.4);
  box-shadow: 0 0 10px var(--focus-glow);
}
.diff-stop-label {
  font-size: 11px;
  letter-spacing: 0.3px;
}
.diff-stop.active .diff-stop-label {
  color: var(--cyan);
  font-weight: 700;
}
.diff-stop:focus { outline: none; }
.diff-stop:focus .diff-dot {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.diff-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
  min-height: 13px;
}

/* ====================================================================
   FOCUS / BUTTONS
   ==================================================================== */
.focusable {
  cursor: pointer;
  border: 2px solid transparent;
  transition:
    transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
  position: relative;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 22px var(--focus-glow);
}
.focusable:focus::before,
.focusable:focus::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--focus);
  pointer-events: none;
}
.focusable:focus::before {
  top: -3px; left: -3px;
  border-right: none; border-bottom: none;
}
.focusable:focus::after {
  bottom: -3px; right: -3px;
  border-left: none; border-top: none;
}

.nav-item {
  padding: 12px 14px;
  background: var(--panel-2);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  min-height: 46px;
}
.nav-item:focus { background: var(--card); transform: translateY(-1px); }
.nav-item.primary {
  background: linear-gradient(180deg, var(--cyan) 0%, var(--cyan-d) 100%);
  color: #001018;
  box-shadow: 0 4px 14px rgba(0,212,255,0.25);
}
.nav-item.primary:focus {
  background: linear-gradient(180deg, #33ddff 0%, var(--cyan) 100%);
}
.nav-item.danger { background: var(--red); color: white; }
.nav-item:disabled, .nav-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.back-btn {
  background: transparent;
  color: var(--text);
  font-size: 20px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-num);
}
.back-btn:focus {
  border-color: var(--focus);
  box-shadow: 0 0 14px var(--focus-glow);
  outline: none;
}

/* ====================================================================
   GAME SCREEN — Canvas + HUD
   ==================================================================== */
#game { background: var(--bg); }

#map {
  display: block;
  width: 600px;
  height: 540px;
  background: var(--bg);
  image-rendering: pixelated;
  /* We handle pan/pinch ourselves via pointer events, so stop the browser
     from scrolling or zooming the page on touch drags. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(to bottom, rgba(6,6,12,0.95), rgba(8,8,14,0.6) 70%, transparent);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  z-index: 5;
  font-family: var(--font-num);
}

/* Diplomacy menu header row — informational, non-interactive */
.action-row.diplomacy-header {
  background: var(--panel-2);
  border-left: 3px solid var(--cyan);
  opacity: 1;
  cursor: default;
  margin-top: 6px;
}
.action-row.diplomacy-header .action-title { color: var(--cyan); }
.action-row.diplomacy-header .action-sub { color: var(--text-2); }

.hud-cell {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  background: rgba(16,16,32,0.88);
  border: 1px solid rgba(46,46,74,0.6);
  border-radius: 99px;
  color: var(--text);
}
.hud-cell.turn { background: rgba(0,212,255,0.10); border-color: rgba(0,212,255,0.4); }
.hud-cell.age-cell {
  font-size: 10px;
  letter-spacing: 1.5px;
  font-weight: 700;
  color: #ffd34d;
  background: rgba(255,211,77,0.08);
  border-color: rgba(255,211,77,0.35);
  padding: 3px 7px;
}
.hud-cell.age-cell.classical { color: #7ce5ff; background: rgba(124,229,255,0.08); border-color: rgba(124,229,255,0.35); }
.hud-cell.age-cell.medieval  { color: #ff7a59; background: rgba(255,122,89,0.08);  border-color: rgba(255,122,89,0.35); }
.hud-cell.age-cell.renaissance{color: #b388ff; background: rgba(179,136,255,0.08); border-color: rgba(179,136,255,0.35); }
.hud-cell.age-cell.industrial{ color: #ffd34d; background: rgba(255,211,77,0.08);  border-color: rgba(255,211,77,0.35); }
.hud-cell.age-cell.modern    { color: #00ff88; background: rgba(0,255,136,0.08);   border-color: rgba(0,255,136,0.35); }
.hud-cell.age-cell.information{ color: #ff5cf0; background: rgba(255,92,240,0.08);  border-color: rgba(255,92,240,0.40); }
.hud-cell.hud-tech {
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
  background: rgba(179,136,255,0.08);
  border-color: rgba(179,136,255,0.4);
}
.hud-cell.hud-tech span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hud-cell.hud-civ {
  background: rgba(0,212,255,0.10);
  border-color: var(--civ-color, rgba(0,212,255,0.4));
}
.hud-cell.hud-civ .hud-ico.c { color: var(--civ-color, var(--cyan)); }
.hud-cell.hud-civ #hud-civ-name {
  color: var(--civ-color, var(--cyan));
  font-weight: 800;
}
.hud-lbl {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
}
.hud-ico {
  display: inline-flex;
  width: 14px; height: 14px;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}
.hud-ico.g { color: var(--gold); }
.hud-ico.s { color: var(--sci); }
.hud-ico.cu { color: #c98bff; }

.hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 70px;
  background: linear-gradient(to top, rgba(6,6,12,0.97), rgba(8,8,14,0.85) 70%, rgba(8,8,14,0.3));
  border-top: 1px solid rgba(46,46,74,0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px;
  font-size: 11px;
  z-index: 5;
}
.hud-row { display: flex; align-items: center; gap: 6px; }
.hud-row-1 { gap: 4px; }
.hud-row-2 {
  min-width: 0;
  gap: 10px;
  justify-content: space-between;
}
.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 99px;
  background: rgba(16,16,32,0.88);
  border: 1px solid rgba(46,46,74,0.6);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-2);
  white-space: nowrap;
  font-family: var(--font-num);
  transition: all 0.2s ease;
}
.chip-lbl {
  font-size: 9px;
  color: var(--text-2);
  letter-spacing: 1.2px;
}
.chip-val {
  color: var(--text);
  font-weight: 800;
}
.mode-pill, .zoom-pill { cursor: pointer; }
.mode-pill {
  background: linear-gradient(180deg, rgba(0,212,255,0.20), rgba(0,168,212,0.15));
  border-color: rgba(0,212,255,0.5);
  color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,212,255,0.15);
}
.mode-pill .chip-val { color: var(--cyan); }
.mode-pill.scroll {
  background: linear-gradient(180deg, rgba(255,180,84,0.20), rgba(192,138,58,0.15));
  border-color: rgba(255,180,84,0.5);
  box-shadow: 0 0 12px rgba(255,180,84,0.15);
}
.mode-pill.scroll .chip-val { color: var(--warm); }
.zoom-pill .chip-val { color: var(--text); letter-spacing: 0px; font-size: 11px; }
.units-pill .chip-val { color: var(--green); }
.units-pill.empty { opacity: 0.5; }
.units-pill.empty .chip-val { color: var(--muted); }
/* ERA chip — Era-Point progress, glows gold during a Golden Age */
.era-pill { cursor: pointer; }
.era-pill .chip-val { color: var(--warm); }
.era-pill.golden {
  color: #ffd34d;
  border-color: rgba(255,211,77,0.6);
  background: rgba(255,211,77,0.12);
  box-shadow: 0 0 8px rgba(255,211,77,0.35);
}
.era-pill.golden .chip-lbl,
.era-pill.golden .chip-val { color: #ffd34d; }
/* Chip glows pulse by fading a STATIC box-shadow layer (::after) in and out —
   opacity animates on the compositor; animating box-shadow itself repaints
   the chip every frame, which the 30Hz panel can't afford. */
.era-pill.golden, .era-pill.near { position: relative; }
.era-pill.golden::after, .era-pill.near::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  animation: glowPulse 1.6s ease-in-out infinite;
}
.era-pill.golden::after { box-shadow: 0 0 18px rgba(255,211,77,0.75); }
/* Era-Point bar nearly full — an amber glint hints a Golden Age is close */
.era-pill.near {
  border-color: rgba(255,180,84,0.6);
}
.era-pill.near::after { box-shadow: 0 0 13px rgba(255,180,84,0.55); animation-duration: 1.8s; }
.era-pill.near .chip-val { color: var(--warm); }
@keyframes glowPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* Golden Age detonation — a one-shot radial gold flash over the game screen */
#game.golden-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: radial-gradient(circle at 50% 45%, rgba(255,211,77,0.40), rgba(255,180,84,0.12) 45%, transparent 72%);
  animation: goldenFlash 0.85s ease-out forwards;
}
@keyframes goldenFlash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}
/* MENU chip — visible entry point to the global menu (clickable on phone/PC) */
.menu-chip {
  cursor: pointer;
  color: var(--cyan);
  border-color: rgba(0,212,255,0.45);
  letter-spacing: 1.5px;
}
.menu-chip:hover { background: rgba(0,212,255,0.16); border-color: rgba(0,212,255,0.75); }

.hud-tile {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.hud-hint {
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--font-num);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 320px;
  text-align: right;
}
.end-turn-chip {
  margin-left: auto;
  cursor: pointer;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(60,60,90,0.4);
  border: 1px solid var(--line-2);
  color: var(--muted);
  transition: all 0.25s ease;
}
.end-turn-chip.ready {
  background: linear-gradient(180deg, var(--green), #00cc66);
  color: #001a0d;
  border-color: var(--green);
  box-shadow: 0 0 20px rgba(0,255,136,0.45);
  position: relative;
}
/* Pulse = opacity on a static-glow layer (compositor), not animated box-shadow */
.end-turn-chip.ready::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 24px rgba(0,255,136,0.6);
  animation: glowPulse 1.4s ease-in-out infinite;
}

/* "A unit is selected" — the whole bottom HUD shifts to amber so the selected
   state never reads the same as the free-cursor state at a glance. */
.hud-bottom.unit-selected {
  border-top-color: rgba(255,180,84,0.55);
  box-shadow: inset 0 2px 0 rgba(255,180,84,0.28);
}
.hud-bottom.unit-selected .hud-hint {
  color: var(--warm);
  font-weight: 700;
  max-width: 360px;
}

/* Turn summary banner */
.turn-summary {
  position: absolute;
  top: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: rgba(10,10,20,0.92);
  border: 1px solid var(--cyan);
  border-radius: var(--r-md);
  padding: 8px 14px;
  min-width: 200px;
  max-width: 460px;
  font-size: 11px;
  z-index: 7;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 0 20px rgba(0,212,255,0.25);
}
.turn-summary.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.turn-summary-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cyan);
  font-weight: 700;
  margin-bottom: 4px;
  font-family: var(--font-num);
}
.turn-summary-body {
  color: var(--text);
  line-height: 1.5;
  font-size: 11px;
}
.turn-summary-body .ev-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.turn-summary-body .ev-row .ev-ico {
  width: 12px;
  color: var(--cyan);
  font-weight: 700;
  flex-shrink: 0;
}
.turn-summary-body .ev-row.err .ev-ico { color: var(--red); }
.turn-summary-body .ev-row.win .ev-ico { color: var(--green); }
.turn-summary-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 11px;
}
.end-turn-flash {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,212,255,0.20);
  color: var(--cyan);
  padding: 14px 32px;
  border-radius: 99px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 30px rgba(0,212,255,0.5);
  z-index: 8;
  pointer-events: none;
  animation: flash-in 0.6s ease-out;
}
@keyframes flash-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

.toast {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--card);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--cyan);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9;
  pointer-events: none;
  max-width: 480px;
  text-align: center;
  letter-spacing: 0.5px;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); box-shadow: 0 0 14px rgba(255,68,102,0.3); }
.toast.success { border-color: var(--green); box-shadow: 0 0 14px rgba(0,255,136,0.3); }

/* ====================================================================
   MODALS
   ==================================================================== */
.screen.modal {
  background: radial-gradient(circle at center, rgba(0,0,0,0.75), rgba(0,0,0,0.92));
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  /* Sit above the title (its .title-wrap is z-index:1 in the root stacking
     context) and the in-game HUD (z-index ≤ 9) so modals always fully cover. */
  z-index: 50;
}
.modal-card {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  width: 100%;
  max-width: 380px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.7),
    0 0 80px rgba(0,212,255,0.08) inset;
}
/* Corner brackets */
.modal-card::before,
.modal-card::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--cyan);
  pointer-events: none;
  opacity: 0.7;
}
.modal-card::before {
  top: -2px; left: -2px;
  border-right: none; border-bottom: none;
  border-top-left-radius: var(--r-lg);
}
.modal-card::after {
  bottom: -2px; right: -2px;
  border-left: none; border-top: none;
  border-bottom-right-radius: var(--r-lg);
}
.modal-card.wide { max-width: 540px; }
.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  text-transform: uppercase;
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.modal-header h2 { flex: 1; }

.action-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 410px;
  padding-right: 4px;
}
.action-list::-webkit-scrollbar { width: 4px; }
.action-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--card);
  border-radius: var(--r-md);
  font-size: 13px;
  text-align: left;
  color: var(--text);
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.action-row:focus {
  background: var(--card-2);
  border-color: rgba(0,212,255,0.3);
  transform: translateY(-1px);
}
.action-row.disabled { opacity: 0.35; pointer-events: none; }
.tech-age-header {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #ffd34d;
  text-transform: uppercase;
  padding: 8px 4px 4px;
  border-bottom: 1px solid rgba(255,211,77,0.2);
  margin-top: 4px;
}

/* Tech-tree dependency graph */
.tech-graph { position: relative; width: 100%; padding: 4px 0 6px; }
.tech-edges { position: absolute; top: 0; left: 0; z-index: 0; overflow: visible; pointer-events: none; }
.tier-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.tier-row:last-child { margin-bottom: 4px; }
.tech-node {
  position: relative;
  z-index: 1;
  /* 94px: widest tier in BOTH trees is 5 nodes — 5×94 + 4×6 gap = 494px,
     inside the wide card's ~502px content box. Sized for glasses legibility. */
  width: 94px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 6px 6px 7px;
  text-align: center;
  color: var(--text);
  cursor: default;
  transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease;
}
.tech-node .tn-badge { font-size: 11px; font-family: var(--font-num); color: var(--muted); margin-bottom: 1px; }
.tech-node .tn-name { font-size: 13px; font-weight: 700; line-height: 1.15; }
.tech-node .tn-sub { font-size: 11px; color: var(--text-2); margin-top: 3px; line-height: 1.3; }
.tech-node .tn-bar { height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.tech-node .tn-bar i { display: block; height: 100%; background: var(--sci); }
.tech-node.avail { border-color: var(--cyan); cursor: pointer; }
.tech-node.avail .tn-badge { color: var(--cyan); }
.tech-node.avail:hover, .tech-node.avail:focus { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--cyan); outline: none; }
.tech-node.done { border-color: rgba(110,210,150,.5); opacity: .9; }
.tech-node.done .tn-badge { color: #6ed296; }
.tech-node.cur { border-color: var(--sci); box-shadow: 0 0 0 1px var(--sci); }
.tech-node.cur .tn-badge { color: var(--sci); }
.tech-node.locked { opacity: .5; cursor: pointer; }
.tech-node.locked:hover { opacity: .7; }
/* queued: in the research plan — dashed cyan, badge shows plan position */
.tech-node.queued { border-style: dashed; border-color: var(--cyan); opacity: .8; cursor: pointer; }
.tech-node.queued .tn-badge { color: var(--cyan); }
.tech-node.queued:hover { opacity: 1; }

/* Research plan chips (under the current-research box) */
.research-queue { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 8px 0 2px; }
.research-queue .rq-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.rq-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px dashed var(--cyan); color: var(--text);
  border-radius: 999px; padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.rq-chip:hover { background: var(--panel-2); }
.rq-chip .rq-x { color: var(--muted); font-weight: 700; }
.action-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--cyan);
  flex-shrink: 0;
  font-family: var(--font-num);
}
/* Turn-summary teaser lines — what's coming next turn */
.ev-row.teaser { color: var(--cyan); font-style: italic; opacity: 0.9; }

/* Leader portrait — pixel face filling the icon chip */
.ldr-portrait {
  width: 26px; height: 26px;
  border-radius: 5px;
  image-rendering: pixelated;
  display: block;
}
.action-row.primary .action-icon {
  background: linear-gradient(180deg, var(--cyan), var(--cyan-d));
  color: #001018;
  border-color: var(--cyan);
}
.action-row.danger .action-icon {
  color: var(--red);
  border-color: rgba(255,68,102,0.4);
}
.action-body { flex: 1; min-width: 0; }
.action-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
}
.action-sub {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 1px;
  font-family: var(--font-num);
}
.action-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
  font-family: var(--font-num);
}

/* ====================================================================
   CITY / TECH SCREENS
   ==================================================================== */
.city-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin: 2px 0;
}
.city-stats > div {
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
}
.city-stats .lbl {
  font-size: 10px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.city-stats > div > span:last-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan);
  font-family: var(--font-num);
}
.city-build-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
  font-weight: 700;
}
.city-current {
  background: var(--card);
  padding: 9px 11px;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--cyan);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Build queue UI */
.city-queue-section { display: block; }
.city-queue-section.hidden { display: none; }
.city-queue-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}
.city-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 2px solid var(--warm);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-ui);
  cursor: pointer;
}
.queue-chip:focus {
  outline: 2px solid var(--focus);
  box-shadow: 0 0 0 3px var(--focus-glow);
}
.queue-chip .queue-x {
  color: var(--muted);
  font-weight: 700;
}
.queue-chip:hover .queue-x { color: var(--red); }

.prod-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin-bottom: 4px;
}
.prod-row .action-row { flex: 1; margin-bottom: 0; }
.queue-add {
  flex: 0 0 36px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--warm);
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
}
.queue-add:hover { background: var(--card); color: var(--warm); }
.queue-add:focus {
  outline: 2px solid var(--focus);
  box-shadow: 0 0 0 3px var(--focus-glow);
}

.tech-current {
  background: var(--card);
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  border-left: 3px solid var(--sci);
  line-height: 1.4;
}

/* ====================================================================
   HELP
   ==================================================================== */
.help-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  overflow-y: auto;
  max-height: 440px;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,212,255,0.3) transparent;
}
.help-body::-webkit-scrollbar { width: 4px; }
.help-body::-webkit-scrollbar-track { background: transparent; }
.help-body::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.3); border-radius: 2px; }
.help-section {
  font-size: 11px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #ffd34d;
  text-transform: uppercase;
  padding: 8px 0 2px;
  border-bottom: 1px solid rgba(255,211,77,0.15);
}
.help-body p { padding: 4px 0; }
.help-body b { color: var(--text); }
.help-body kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--cyan);
}

/* ====================================================================
   END SCREEN
   ==================================================================== */
.end-detail {
  font-size: 14px;
  color: var(--text-2);
  text-align: center;
  margin: 8px 0;
  line-height: 1.5;
}
.end-stats {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--card);
  border-radius: var(--r-sm);
  text-align: left;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: var(--muted); }
.stat-row span:last-child { color: var(--text); font-family: var(--font-num); }

/* ====================================================================
   PROGRESS BAR
   ==================================================================== */
.bar {
  flex: 1;
  height: 6px;
  background: var(--panel);
  border-radius: 3px;
  overflow: hidden;
  max-width: 140px;
  border: 1px solid var(--line);
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), #66e8ff);
  border-radius: 3px;
}
.bar.s > i { background: linear-gradient(90deg, var(--sci), #d4b8ff); }
.bar.f > i { background: linear-gradient(90deg, var(--green), #66ffaa); }

.hidden { display: none !important; }

/* Glasses edition: static ink, ivory and brass surfaces. Keep the fixed
   600px interaction coordinates and spend no frames animating decoration. */
#title { background: #000; border: 1px solid #273021; }
#title::before { inset: 10px; border: 1px solid #273021; background: none; }
.title-bg-hex { display: none; animation: none; }
.title-wrap { justify-content: flex-start; gap: 0; padding: 22px 30px; }
.title-kicker { color: var(--cyan); text-transform: uppercase; letter-spacing: 3px; font-size: 11px; }
.title-name { font-family: Georgia, 'Times New Roman', serif; font-size: 50px; letter-spacing: -2px; font-weight: 600; color: var(--text); background: none; text-shadow: none; margin: 2px 0 4px; }
.title-sub { font-size: 16px; letter-spacing: 0; text-transform: none; opacity: 1; margin: 0; }
.title-settlement { width: 100%; height: 164px; object-fit: contain; margin: 8px 0; }
.title-actions { width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.title-actions > .nav-item { grid-column: span 3; }
.title-actions-row { display: contents; }
.title-actions-row .nav-item, .title-actions > [data-action="cloud-sync"] { grid-column: span 2; margin: 0; }
.title-actions .nav-item { min-height: 52px; padding: 10px 8px; font-size: 18px; letter-spacing: 0; }
.title-actions .small { min-height: 44px; font-size: 14px; }
.title-audio { width: 100%; gap: 8px; margin-top: 8px; }
.title-audio .audio-toggle { flex: 1; padding: 8px; font-size: 12px; }
.title-controls { margin-top: auto; padding-top: 18px; color: var(--cyan); font-size: 13px; }
.nav-item, .audio-toggle, .back-btn { background: var(--panel); border-color: var(--line); border-radius: 4px; box-shadow: none; }
.nav-item.primary { background: var(--card); color: var(--text); border-color: var(--line-2); }
.focusable:focus, .nav-item:focus, .action-row:focus, .civ-card:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--card-2); box-shadow: none; transform: none; }
.nav-item.primary:focus { background: #354530; color: var(--text); }
.audio-toggle[aria-pressed="true"] { background: var(--panel-2); border-color: var(--line-2); box-shadow: none; }
.header { display: flex; align-items: center; gap: 14px; padding: 14px 18px; flex-shrink: 0; background: var(--panel); border-color: var(--line); }
.header h1 { font-family: Georgia, 'Times New Roman', serif; font-size: 28px; letter-spacing: 0; }
.back-btn { width: 44px; height: 44px; flex-shrink: 0; color: var(--text); font-size: 20px; }
.civ-cards { min-height: 0; }
.civ-card { border-radius: 5px; background: var(--panel-2); box-shadow: none; }
.civ-name { font-size: 19px; }
.civ-desc, .civ-bonus { font-size: 13px; line-height: 1.4; }
#map { image-rendering: auto; }
.hud-top { height: 40px; gap: 4px; padding: 4px 7px; background: #080d09; border-bottom: 1px solid var(--line); font-size: 13px; }
.hud-cell { border-radius: 3px; padding: 4px; background: var(--panel-2); border-color: var(--line); }
.hud-cell.turn { background: var(--card); border-color: var(--line-2); }
.hud-cell.age-cell { letter-spacing: .5px; font-size: 10px; }
.hud-lbl { font-size: 10px; }
.hud-bottom { background: #080d09; height: 76px; padding: 7px 8px; border-color: var(--line); }
.hud-chip { background: var(--panel-2); border-color: var(--line); border-radius: 4px; padding: 7px 6px; letter-spacing: .4px; transition: none; }
.mode-pill, .mode-pill.scroll { box-shadow: none; background: var(--card); border-color: var(--line-2); }
.chip-lbl { letter-spacing: .5px; }
.hud-row-2 { gap: 8px; }
.hud-hint { font-size: 11px; letter-spacing: 0; }
.units-pill { cursor: pointer; }
.end-turn-chip { border-radius: 4px; box-shadow: none; }
.era-pill.golden::after, .era-pill.near::after { animation: none; }
.screen.modal { background: rgba(0, 0, 0, .88); backdrop-filter: none; padding: 18px 24px; }
.modal-card { background: #0e150f; border-color: var(--line-2); border-radius: 5px; box-shadow: none; max-height: 564px; min-height: 0; padding: 16px 18px; overflow: hidden; }
.modal-card::before, .modal-card::after { display: none; }
.modal-header { flex-shrink: 0; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.modal-card h2 { font-family: Georgia, 'Times New Roman', serif; font-size: 27px; letter-spacing: 0; text-transform: none; }
.action-list, .help-body, .log-body, .standings-body { min-height: 0; overscroll-behavior: contain; }
.action-row { flex-shrink: 0; border: 1px solid var(--line); border-radius: 4px; padding: 11px; min-height: 56px; transition: none; }
.action-title { font-size: 16px; }
.action-sub { font-size: 13px; line-height: 1.4; }
.action-icon { background: #0d150e; border: 0; border-radius: 0; }
.tech-node { border-radius: 4px; transition: none; }
.tech-node .tn-name { font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.tech-node.locked { opacity: .72; }
.tech-node:focus, .tech-node.locked:focus, .tech-node.avail:focus { outline: 2px solid var(--focus); outline-offset: -2px; opacity: 1; background: var(--card-2); box-shadow: none; transform: none; }
#c-scene { display: block; width: 80px; height: 64px; flex-shrink: 0; margin: -4px 0; }
.city-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; flex-shrink: 0; }
.city-stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 3px; padding: 6px 10px; }
.city-stats .lbl { color: var(--cyan); font-size: 12px; }
.city-stats > div > span:last-child { font-size: 17px; }
.city-build-label { color: var(--cyan); font-size: 13px; font-weight: 700; text-transform: uppercase; flex-shrink: 0; }
.city-queue-hint { text-transform: none; font-size: 12px; font-weight: 400; }
#c-current, #c-queue-section { flex-shrink: 0; }
.city-current { font-size: 16px; border-radius: 3px; }
.city-current small { font-size: 13px; }
.queue-chip { font-size: 13px; border-radius: 3px; }
.city-stats > div { text-align: left; }
#c-options { flex: 1 1 auto; min-height: 90px; }
.help-body { font-size: 14px; line-height: 1.5; }
.help-section { color: var(--cyan); }
.bar > i { background: #acbe8b; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
