:root {
  --void: #0b0f1a;
  --hull: #121828;
  --hull-2: #1a2236;
  --line: #2a3450;
  --ink: #e6e9f2;
  --ink-dim: #9aa3bd;
  --signal: #f2b84b;
  --xenium: #6fc3df;
  --nova: #f28a4b;
  --nebulite: #b48cff;
  --ok: #6fd3a4;
  --tabs-h: 56px;
  --enemy: #ef6b6b;
  --danger: #ef8a6b;
  --f-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#map.dragging { cursor: grabbing; }

.series {
  font-family: var(--f-display);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--signal);
}

.muted { color: var(--ink-dim); }
.error { color: var(--danger); }

/* --- Top bar --- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: linear-gradient(var(--void), transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title .name { font-family: var(--f-display); font-weight: 700; font-size: 18px; }

button {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
  background: var(--hull-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
}
button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* --- Loading screen --- */
.loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: var(--void);
  text-align: center;
}
.loading h1 {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  font-family: var(--f-display);
  font-size: clamp(32px, 10vw, 44px);
  line-height: 1.05;
}

/* --- Planet info sheet --- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--hull);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}
.sheet-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 32px; height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.sheet h2 { margin: 0 32px 4px 0; font-family: var(--f-display); font-size: 22px; }
.sheet .coords { font-family: var(--f-display); color: var(--ink-dim); font-size: 13px; }
.sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 0; }
.sheet dt { color: var(--ink-dim); }
.sheet dd { margin: 0; }

.tag {
  display: inline-block;
  margin-top: 10px;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid currentColor;
  font-family: var(--f-display);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tag.you { color: var(--signal); }
.tag.rich { color: var(--nebulite); }
.tag.enemy { color: var(--enemy); }

/* The map sheet sits above the tab bar. */
.sheet { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: 20px; }

/* --- "Open in Telegram" link --- */
.open-tg {
  font-family: var(--f-display);
  font-weight: 700;
  color: #1a1306;
  background: var(--signal);
  border-radius: 4px;
  padding: 12px 20px;
  text-decoration: none;
}

/* --- Tab bar --- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding: 0 max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  background: var(--hull);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.tab {
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ink-dim);
  font-size: 15px;
  letter-spacing: 0.05em;
}
.tab.active { color: var(--signal); box-shadow: inset 0 2px 0 var(--signal); }

/* --- Planet screen --- */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--void);
  padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
  -webkit-user-select: none;
}
.screen > * { max-width: 560px; margin-left: auto; margin-right: auto; }

.planet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.planet-head h1 { margin: 0; font-family: var(--f-display); font-size: 26px; line-height: 1.1; }
.coords { font-family: var(--f-display); color: var(--ink-dim); font-size: 13px; margin-top: 2px; }
.allegiance {
  flex: none;
  text-align: right;
  font-family: var(--f-display);
  font-size: 12px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.allegiance b { display: block; font-size: 20px; color: var(--ink); letter-spacing: 0; }

.resources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.res {
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-width: 0;
}
.res-name {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--f-display); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-dim);
}
.res-name i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.res-amount { font-family: var(--f-display); font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.res-amount.full { color: var(--danger); }
.res-meta { font-size: 11.5px; line-height: 1.35; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.res-bar { height: 3px; background: var(--hull-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.res-bar > span { display: block; height: 100%; background: var(--c); }

.section-title {
  font-family: var(--f-display); font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-dim); margin: 24px auto 10px;
}

/* Build queue */
.queue { margin-top: 18px; display: grid; gap: 8px; }
.queue-item {
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}
.queue-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.queue-row .time { font-family: var(--f-display); font-variant-numeric: tabular-nums; color: var(--signal); }
.queue-item.waiting .time { color: var(--ink-dim); }
.progress { height: 4px; background: var(--hull-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--signal); transition: width 1s linear; }

/* Buildings */
.buildings { display: grid; gap: 8px; }
.building {
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.building-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.building-head h3 { margin: 0; font-family: var(--f-display); font-size: 17px; }
.level { font-family: var(--f-display); font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.building p { margin: 0; font-size: 13px; color: var(--ink-dim); }
.building-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.costs { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.cost { display: inline-flex; align-items: center; gap: 4px; }
.cost i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.cost.short { color: var(--danger); }
.cost.time { color: var(--ink-dim); }
.build-btn { min-width: 96px; }
.build-btn.primary { background: var(--signal); border-color: var(--signal); color: #1a1306; font-weight: 700; }
.build-btn:disabled { opacity: 0.45; cursor: default; }
.locked { font-size: 13px; color: var(--ink-dim); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  background: var(--hull-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  z-index: 10;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); color: var(--ok); }

/* --- Screens shared by tabs --- */
.screen-title { margin: 0; font-family: var(--f-display); font-size: 26px; line-height: 1.15; text-wrap: balance; }
.screen.overlay { z-index: 8; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.screen.overlay .sheet-close { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.screen.overlay .screen-title { margin-right: 40px; }
.section-title.danger { color: var(--enemy); }
.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--ok) 50%, transparent);
  border-radius: 6px;
  color: var(--ok);
  font-size: 13px;
}
.tag { color: var(--ink-dim); }
.planet-switch {
  margin-top: 8px;
  max-width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--hull-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
}

/* Troops */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--hull); font-size: 13px; }
.chip b { font-family: var(--f-display); font-variant-numeric: tabular-nums; }
#training .queue { margin-top: 10px; }
.building .stats { font-size: 12px; font-variant-numeric: tabular-nums; }
.train-row { display: flex; gap: 6px; align-items: center; }
input.count {
  width: 72px;
  font: inherit;
  font-family: var(--f-display);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--void);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 8px;
  -webkit-user-select: text;
  user-select: text;
}
input.count:focus { outline: none; border-color: var(--signal); }

/* Tab badges */
.badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--signal);
  color: #1a1306;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.badge.danger { background: var(--enemy); color: #fff; }
.tabs { grid-template-columns: repeat(4, 1fr); }
.tab { font-size: 14px; padding: 0 4px; }

/* Planet sheet buttons */
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sheet-actions .build-btn { flex: 1 1 0; }

/* Fleets */
.fleet { background: var(--hull); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: grid; gap: 4px; font-size: 14px; }
.fleet.incoming { border-color: color-mix(in srgb, var(--enemy) 60%, var(--line)); }
.fleet.incoming .time { color: var(--enemy); }
.fleet.returning .time { color: var(--ink-dim); }
.fleet .muted { font-size: 13px; }
.fleet-units { font-size: 13px; }

/* Send screen */
.send-units { display: grid; gap: 8px; margin-top: 16px; }
.send-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.send-preview dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0; }
.send-preview dt { color: var(--ink-dim); }
.send-preview dd { margin: 0; font-variant-numeric: tabular-nums; }
.build-btn.wide { width: 100%; padding: 12px; font-size: 16px; margin-top: 8px; }

/* Reports */
.report-list { display: grid; gap: 6px; margin-top: 16px; }
.report-row {
  display: grid;
  gap: 2px;
  text-align: left;
  font-family: var(--f-body);
  background: var(--hull);
  padding: 10px 12px;
  border-radius: 6px;
}
.report-row .muted { font-size: 12px; }
.report-row.unread { border-color: var(--signal); }
.report-row.unread .report-title { font-weight: 500; }
.report-title { font-size: 14px; }
#report-body h3 { font-family: var(--f-display); font-size: 16px; margin: 20px 0 2px; }
#report-body p { margin: 4px 0; }
.report-outcome { font-family: var(--f-display); font-size: 18px; margin-top: 12px !important; }
.report-outcome.attacker { color: var(--signal); }
.report-outcome.defender { color: var(--enemy); }
.report-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.report-table th { font-family: var(--f-display); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); font-weight: 500; }
.report-table td.lost { color: var(--danger); }

/* --- Fixes after the first screenshot pass --- */
.report-table { table-layout: fixed; }
.report-table th:first-child { width: 50%; }
.tab { white-space: nowrap; position: relative; }
.tab .badge { position: absolute; top: 8px; right: 6px; margin: 0; }
/* Toasts sit at the top so they never cover buttons near the bottom. */
.toast { bottom: auto; top: calc(12px + env(safe-area-inset-top)); z-index: 20; }

/* --- Welcome screen and rename --- */
.setup {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background: var(--void);
  padding: calc(32px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.setup-inner { max-width: 420px; margin: 0 auto; display: grid; gap: 12px; }
.setup h1 { margin: 0; font-family: var(--f-display); font-size: clamp(30px, 9vw, 40px); line-height: 1.05; text-wrap: balance; }
.setup p { margin: 0; }
.setup-form { display: grid; gap: 8px; margin-top: 12px; }
.setup-form label {
  margin-top: 8px;
  font-family: var(--f-display); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-dim);
}
.text-input {
  width: 100%;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  -webkit-user-select: text;
  user-select: text;
}
.text-input:focus { outline: none; border-color: var(--signal); }
.small { font-size: 13px; }
.planet-title { display: flex; align-items: center; gap: 8px; }
.icon-btn { padding: 2px 8px; font-size: 16px; line-height: 1.4; color: var(--ink-dim); background: none; }

/* --- Map legend --- */
.legend {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 6px 10px;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11.5px;
  color: var(--ink-dim);
  background: color-mix(in srgb, var(--hull) 85%, transparent);
  border: 1px solid var(--line);
  border-radius: 6px;
  pointer-events: none;
}
.legend li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.legend i.double { box-shadow: 0 0 0 2px var(--hull), 0 0 0 3px var(--c); }
.legend i.glow { box-shadow: 0 0 6px 2px color-mix(in srgb, var(--c) 70%, transparent); }
/* The planet sheet covers the legend while open. */
.sheet { z-index: 6; }
.tag.mine { color: var(--ok); }
.tag.visited { color: #7aa7d9; }

/* --- Chat --- */
.tabs { grid-template-columns: repeat(6, minmax(0, 1fr)); padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
.tab { font-size: 12px; letter-spacing: 0.02em; padding: 0 2px; }
.chat-screen { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 76px); }
.chat-log { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.chat-day { align-self: center; font-size: 12px; color: var(--ink-dim); margin: 8px 0 2px; }
.msg { max-width: 82%; align-self: flex-start; display: grid; gap: 2px; }
.msg.mine { align-self: flex-end; text-align: right; }
.msg-meta { font-size: 12px; color: var(--ink-dim); }
.msg-meta b { color: var(--signal); font-weight: 500; }
.msg-text {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--hull);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}
.msg.mine .msg-text { background: color-mix(in srgb, var(--signal) 16%, var(--hull)); border-color: color-mix(in srgb, var(--signal) 40%, var(--line)); }
.chat-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--void);
  border-top: 1px solid var(--line);
}
.chat-bar .text-input { padding: 10px 12px; font-size: 16px; }
.chat-bar .build-btn { flex: none; }

/* --- Social tab: sections and alliance --- */
.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.segment {
  position: relative;
  border: 0;
  background: none;
  color: var(--ink-dim);
  font-size: 13px;
  padding: 8px 4px;
  white-space: nowrap;
}
.segment.active { background: var(--hull-2); color: var(--signal); }
.segment .badge { position: absolute; top: -6px; right: -2px; margin: 0; }
.tag-inline { color: var(--ink-dim); font-weight: 500; }
.tag.ally { color: #4fc3c9; }
#alliance-panel { margin-top: 8px; }
.alliance-name { margin: 20px 0 2px; font-family: var(--f-display); font-size: 22px; }
.member {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  background: var(--hull);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
}
.member .build-btn { padding: 6px 10px; font-size: 13px; }
.invite-row { display: flex; gap: 8px; }
.invite-row .text-input { padding: 10px 12px; font-size: 16px; }
#leave-area { margin-top: 28px; }
.danger-btn { color: var(--enemy); border-color: color-mix(in srgb, var(--enemy) 50%, var(--line)); background: none; }

/* Toasts are only messages: taps go through to whatever is underneath. */
.toast { pointer-events: none; }

/* --- Events --- */
.head-right { display: flex; align-items: flex-start; gap: 8px; }
.admin-btn { font-size: 18px; }
.events { display: grid; gap: 8px; margin-top: 14px; }
.events:empty { display: none; }
.event-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  text-align: left;
  font-family: var(--f-body);
  padding: 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--signal) 10%, var(--hull));
  border: 1px solid color-mix(in srgb, var(--signal) 55%, var(--line));
}
.event-card.arena {
  background: color-mix(in srgb, var(--enemy) 14%, var(--hull));
  border-color: var(--enemy);
}
.event-card.titan {
  background: color-mix(in srgb, #e2574c 10%, var(--hull));
  border-color: color-mix(in srgb, #e2574c 55%, var(--line));
}
.event-icon { font-size: 26px; line-height: 1; }
.event-body { display: grid; gap: 4px; min-width: 0; }
.event-title { font-family: var(--f-display); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.event-time { font-weight: 500; color: var(--signal); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-text { font-size: 13.5px; color: var(--ink-dim); }
.event-text b { color: var(--ink); font-weight: 500; }
#event-body p { margin: 10px 0; }
.ranking td:first-child { width: 2.5em; color: var(--ink-dim); }
.ranking tr.you td { color: var(--signal); }
select.text-input { appearance: auto; }
.legend i.titan { box-shadow: 0 0 0 2px var(--hull), 0 0 0 3px var(--signal); }

/* --- Daily reward and invites --- */
.rewards { display: grid; gap: 8px; margin-top: 8px; }
.reward-card { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--hull); }
.reward-card.ready { border-color: color-mix(in srgb, var(--ok) 60%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--hull)); }
.reward-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; }
.reward-head .build-btn { padding: 6px 14px; }
.reward-card p { margin: 0; }
.reward-card .costs { align-items: center; color: var(--ink-dim); }
#report-share { margin-top: 24px; }

/* Shown when an upgrade costs more than the planet can store. */
.building .storage-hint { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--danger); }

/* --- Settings --- */
.settings { display: grid; gap: 8px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--hull); border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.mini-seg { display: flex; gap: 4px; padding: 3px; background: var(--void); border: 1px solid var(--line); border-radius: 6px; }
.mini-seg button { border: 0; background: none; color: var(--ink-dim); padding: 6px 10px; font-size: 13px; }
.mini-seg button.active { background: var(--hull-2); color: var(--signal); }

/* --- Guide --- */
.guide { display: grid; gap: 8px; margin-top: 16px; }
.guide-section { background: var(--hull); border: 1px solid var(--line); border-radius: 6px; padding: 0 14px; }
.guide-section summary {
  font-family: var(--f-display); font-size: 16px; font-weight: 700; padding: 13px 0; cursor: pointer;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.guide-section summary::-webkit-details-marker { display: none; }
.guide-section summary::after { content: "+"; color: var(--ink-dim); font-size: 20px; line-height: 1; }
.guide-section[open] summary::after { content: "−"; }
.guide-section[open] { padding-bottom: 12px; }
.guide-section p { margin: 0 0 10px; line-height: 1.5; color: var(--ink); }
.guide-section p.muted { color: var(--ink-dim); margin-bottom: 4px; }
.guide-section h3 { font-family: var(--f-display); font-size: 14px; letter-spacing: 0.05em; color: var(--signal); margin: 14px 0 6px; }
.guide-item { border-top: 1px solid var(--line); padding: 10px 0 6px; }
.guide-item h3 { margin-top: 0; }
.guide-colors { list-style: none; margin: 0; padding: 0 0 4px; display: grid; gap: 10px; }
.guide-colors li { display: flex; gap: 10px; align-items: baseline; line-height: 1.45; }
.guide-colors i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); transform: translateY(1px); }
.guide-colors i.double { box-shadow: 0 0 0 2px var(--hull), 0 0 0 3px var(--c); }
.guide-colors i.glow { box-shadow: 0 0 6px 2px color-mix(in srgb, var(--c) 70%, transparent); }
.guide-colors b { font-weight: 500; }

/* --- Waiting room (before the game opens) --- */
.wait-countdown {
  font-family: var(--f-display); font-size: clamp(32px, 11vw, 48px); font-weight: 700; color: var(--signal);
  font-variant-numeric: tabular-nums; margin: 8px 0 4px;
}
.waitroom h1 { margin: 0; font-family: var(--f-display); font-size: clamp(30px, 9vw, 40px); line-height: 1.05; }
.waitroom p { margin: 0; }
.waitroom .setup-inner { padding-top: 16px; }
/* Before the opening only a few tabs show: share the bar between them. */
.tabs.lobby { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }

/* --- Admin statistics --- */
.stat-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat-tile { background: var(--hull); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.stat-num { font-family: var(--f-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--ink); }
.stat-sub { font-size: 11.5px; color: var(--ink-dim); }
.stat-strip { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--ink-dim); }
.stat-strip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart { position: relative; background: var(--hull); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--signal); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .baseline { stroke: var(--ink-dim); stroke-width: 1; }
.chart .axis { fill: var(--ink-dim); font-size: 10px; font-family: var(--f-body); }
.chart-tip {
  position: absolute; top: 6px; width: 150px; padding: 6px 8px; border-radius: 6px; pointer-events: none;
  background: var(--hull-2); border: 1px solid var(--line); color: var(--ink); font-size: 12px; line-height: 1.4;
}
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: 9.5em 1fr 3em; gap: 8px; align-items: center; font-size: 13px; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; background: var(--hull-2); border-radius: 4px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: var(--signal); border-radius: 0 4px 4px 0; }
.pcards { display: grid; gap: 8px; }
.pcard { background: var(--hull); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: grid; gap: 4px; }
.pcard-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.pcard-line { font-size: 12.5px; line-height: 1.45; }
.pcard .build-btn { justify-self: start; margin-top: 4px; padding: 6px 10px; font-size: 13px; }
.online { color: var(--ok); font-size: 12.5px; white-space: nowrap; }
.feed, .pfeed { display: grid; gap: 6px; }
.feed-row { display: grid; grid-template-columns: 6.2em 1fr; gap: 8px; font-size: 12.5px; line-height: 1.4;
  border-top: 1px solid var(--line); padding-top: 6px; }
.pfeed { max-height: 320px; overflow-y: auto; margin-top: 4px; }
