/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */

/* ─── me[tt] Custom Styles ───────────────────────────────────────────────── */
/* Built on top of Pico CSS dark theme */

:root {
  /* Dark charcoal + antique gold — inspired by the ancient world theme of Mega Empires */
  --mett-bg: #0e0f0f;
  --mett-surface: #181c1c;
  --mett-surface2: #212727;
  --mett-border: #2e3636;
  --mett-text: #e8e3d8;
  --mett-muted: #7a7568;
  --mett-accent: #c4933f;   /* antique gold */
  --mett-logo-bracket: var(--mett-accent); /* gold bracket in wordmark */
  --mett-danger: #cc3333;
  --mett-success: #2ea84a;
  --mett-warning: #cc8800;

  /* Pico overrides */
  --pico-background-color: var(--mett-bg);
  --pico-card-background-color: var(--mett-surface);
  --pico-border-color: var(--mett-border);

  /* Status-grid table column widths. Each `.status-grid .X` block applies
     `width: var(--col-X); min-width: var(--col-X)`. Per-breakpoint blocks
     below only override the variables, not the rules. */
  --col-mil: 2.2rem;
  --col-city: 2.2rem;
  --col-census-pop: 2.1rem;
  --col-rank: 1.2rem;
  --col-adv-pts: 1.9rem;
  --col-ast-pts: 1.9rem;
  --col-total-vp: 2.4rem;

  /* AST progress strip on the civ page. Phone breakpoint below
     overrides these. Declared up here (not next to .ast-progress-grid)
     so a later unconditional :root block can't accidentally beat the
     media-query override on source order. */
  --ast-node-size: 2rem;
  --ast-node-gap: 0.1875rem;
}

body {
  background: var(--mett-bg);
  color: var(--mett-text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ─── Site header / logo ──────────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem 0.3rem;
}

/* Tiny build-version stamp pinned to the bottom-left of the viewport. A faint
   pill background keeps it legible on the body backdrop where no card sits. */
.version-footer {
  position: fixed;
  left: 0.4rem;
  bottom: 0.3rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--mett-muted);
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.mett-wordmark {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--mett-text);
  text-decoration: none;
  flex-shrink: 0;
}

.mw-bracket {
  color: var(--mett-logo-bracket);
}

.mett-tagline {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--mett-muted);
  white-space: nowrap;
}

.admin-gear {
  margin-left: auto;
  font-size: 1rem;
  color: var(--mett-muted);
  text-decoration: none;
  padding: 0.1rem 0.25rem;
  flex-shrink: 0;
}

.admin-gear:hover { color: var(--mett-text); }

/* ─── Header ──────────────────────────────────────────────────────────────── */

.mett-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 0.3rem;
}

.mett-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.game-status {
  color: var(--mett-muted);
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ─── Badges ──────────────────────────────────────────────────────────────── */

.mode-badge,
.revealed-badge,
.final-round-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 624.9375rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mode-badge {
  background: var(--mett-accent);
  color: #fff;
}

.final-round-badge {
  background: var(--mett-danger);
  color: #fff;
  animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.revealed-badge {
  background: var(--mett-success);
  color: #fff;
}

/* ─── Civilization badges ─────────────────────────────────────────────────── */

.civ-badge {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  border-radius: 0.1875rem;
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  border: 0.0625rem solid rgba(0,0,0,0.15);
}

.civ-badge-sm {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.125rem;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  border: 0.0625rem solid rgba(0,0,0,0.15);
}

.region-west .civ-badge { border-left: 0.1875rem solid rgba(0,0,0,0.3); }
.region-east .civ-badge { border-right: 0.1875rem solid rgba(255,255,255,0.3); }

.civ-badge-with-num {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding-left: 0.25rem;
  width: 7.1875rem;
  box-sizing: border-box;
}
.civ-badge-label { min-width: 0; }
.civ-num-in-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.22);
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.mil-badge {
  font-size: 0.75rem;
  margin-left: 0.3rem;
  opacity: 0.9;
}

/* Census table column sizing */
.census-table { table-layout: fixed; width: 100%; }
.census-table .empire-col { width: 100%; }
.empire-col-inner { display: flex; align-items: center; overflow: hidden; min-width: 0; }
.empire-col-inner .civ-badge { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.census-table .city-col {
  width: 2.125rem;
  text-align: center;
  font-size: 0.85rem;
  white-space: nowrap;
}
.census-table .mil-col {
  width: 2.125rem;
  text-align: center;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  white-space: nowrap;
}
.census-table thead .mil-col { color: #cc4444; }
.census-pop { width: 3.25rem; }

/* Red military dot */
.mil-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--mett-danger);
  box-shadow: 0 0 0.25rem var(--mett-danger);
  vertical-align: middle;
}

.census-pop { font-weight: 700; text-align: right; font-size: 1rem; white-space: nowrap; }
.pending-pop { color: var(--mett-warning); font-size: 0.85rem; }
.submitted-hidden { color: #4a8a5a; font-size: 0.85rem; }   /* muted green ✓ */
.not-submitted    { color: var(--mett-warning); font-size: 0.85rem; }

/* Military icon — red dot in census table, ⚔ on header/buttons */

/* Military & Wonder toggles on civ page */
.mil-won-row { display: flex; flex-direction: column; gap: 0.5rem; }
.mil-toggle-civ, .won-toggle-civ {
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  border: 0.0625rem solid var(--mett-border);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
}
.mil-toggle-civ.mil-on  { background: #3a2020; border-color: #cc5555; color: #ff8888; }
.mil-toggle-civ.mil-off { background: var(--mett-surface2); color: var(--mett-muted); }
.won-toggle-civ.won-on  { background: #2a2a10; border-color: #aaaa22; color: #dddd44; }
.won-toggle-civ.won-off { background: var(--mett-surface2); color: var(--mett-muted); }

/* Requirement label in AST table */
.req-label { text-align: center; color: var(--mett-muted); font-size: 0.85rem; width: 2.5rem; }

/* Requirement legend below AST table */
.req-legend {
  margin: 0.6rem 0 0;
  padding: 0.5rem 0.75rem;
  list-style: none;
  font-size: 0.75rem;
  color: var(--mett-muted);
  border-top: 0.0625rem solid var(--mett-border);
  line-height: 1.7;
}
.req-legend li strong { color: var(--mett-text); margin-right: 0.3rem; }

.move-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--mett-accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.4rem;
}

.civ-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  background: var(--mett-surface2);
  color: var(--mett-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  margin-right: 0.4rem;
  flex-shrink: 0;
}

.total-vp { font-weight: 700; text-align: right; }

/* Leaderboard ties */
.rank-tie { color: var(--mett-warning); font-weight: 900; font-size: 1rem; }
.lb-tied td { background: rgba(204,136,0,0.06); }
.lb-group-start td { border-top: 0.125rem solid var(--mett-border); }

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.mett-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.mett-table th {
  background: var(--mett-surface2);
  color: var(--mett-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.6rem;
  border-bottom: 0.0625rem solid var(--mett-border);
  white-space: nowrap;
}

.mett-table td {
  padding: 0.3rem 0.55rem;
  border-bottom: 0.0625rem solid var(--mett-border);
  vertical-align: middle;
  height: 2rem;  /* fixed row height so tables align across columns */
  overflow: hidden;
  white-space: nowrap;
}

.mett-table tr:hover td {
  background: var(--mett-surface2);
}

.rank { color: var(--mett-muted); font-size: 0.85rem; width: 2rem; text-align: center; }
.player-name { font-weight: 500; }
.lb-emp-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.0625rem;
  padding: 0.1875rem 0.5rem 0.25rem 0.25rem;
  width: 7.1875rem;
  box-sizing: border-box;
}
.lb-emp-top {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
}
.lb-badge-name { display: none; font-size: 0.625rem; opacity: 0.8; padding-left: 0.125rem; white-space: nowrap; }
/* Player name in go-empire — visible by default, block on mobile for card layout */
.go-player-name { display: none; font-size: 0.78rem; color: var(--mett-muted); margin-top: 0.1rem; }
.adv-pts { text-align: right; }
.ast-pts { text-align: right; font-weight: 600; }
.ast-req { color: var(--mett-muted); font-size: 0.82rem; }
.status-col { text-align: center; width: 2.5rem; }
.status-icon { font-size: 1rem; }
.status-icon.submitted { color: var(--mett-success); }
.status-icon.pending { color: var(--mett-warning); }

.table-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--mett-muted);
}

.census-hint {
  display: block;
  font-size: 0.75rem;
  opacity: 0.5;
  margin-top: 0.25rem;
}

.table-scroll { overflow-x: auto; }

/* ─── S2 status page layout ──────────────────────────────────────────────── */

.s2-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
  min-width: 0;
}
.s2-grid > * { min-width: 0; }

/* Force uniform row height across all three tables */
.s2-grid .mett-table td { height: 2.2rem; }

@media (max-width: 87.5em) {
  .s2-grid { gap: 1rem; }
  .s2-grid .mett-table td { height: 1.9rem; }
}
@media (max-width: 68.75em) {
  .s2-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .s2-grid .mett-table td { height: 1.75rem; }
}
@media (max-width: 43.75em) {
  .s2-grid { grid-template-columns: 1fr; }
}

/* S2 AST board — match table row heights */
.s2-ast .ab-cell        { height: 2.2rem; }
.s2-ast .ab-magnet      { width: 1.6rem; height: 1.6rem; }

@media (max-width: 87.5em) {
  .s2-ast .ab-cell   { height: 1.9rem; }
  .s2-ast .ab-magnet { width: 1.4rem; height: 1.4rem; }
}
@media (max-width: 68.75em) {
  .s2-ast .ab-cell   { height: 1.75rem; }
  .s2-ast .ab-magnet { width: 1.3rem; height: 1.3rem; }
}

/* ─── S3 status page layout (4-column, TV-optimised) ─────────────────────── */

.status-grid {
  display: grid;
  /* leaderboard | census | trade | AST board | AST order */
  grid-template-columns: 2.3fr auto auto 3.2fr auto;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
  /* Fill the viewport vertically on desktop sizes — cards stretch to match
     each other (align-items: stretch), but tables INSIDE cards stay
     natural-sized (no flex-grow on tables) so rows don't float. Content
     packs at the top of each card; empty space sits below each table as
     consistent padding, not as stretched rows. */
  min-height: calc(100vh - 5rem);
}
.status-grid > * { min-width: 0; }
.status-grid .mett-table { width: 100%; }

/* Compact game status bar on s3 */
.status-header { margin: 0 0 0.2rem; }
.status-header .game-status { font-size: 0.75rem; }

/* Trim Pico's vertical padding on the home page so 18 empires + the AST
   legend fit a 1080p viewport without scrolling. Other pages keep Pico's
   default vertical rhythm (this :has rule only matches when status-grid
   is present, which is the main display). */
main.container-fluid:has(.status-grid) { padding-block: 0.25rem; }

/* Compact table density — tuned so 18 empires fit in a 1080p viewport
   without scrolling. Row height computes to ~36 px at Pico's fluid root. */
.status-grid .table-section   { padding: 0.25rem 0.4rem; display: flex; flex-direction: column; }
.status-grid .table-section h3 { font-size: 0.65rem; margin-bottom: 0.15rem; }
.status-grid .table-hint       { font-size: 0.58rem; margin-top: auto; margin-bottom: 0; padding-top: 0.15rem; }
.status-grid .ab-legend        { margin-top: auto; font-size: 0.46rem; line-height: 1.2; padding: 0.1rem 0 0; gap: 0.05rem 0.6rem; }
.status-grid .ab-legend li     { gap: 0.2rem; }
.status-grid .ab-legend-dot    { width: 0.5rem; height: 0.5rem; }
/* Row height + font scale with viewport HEIGHT (not width) so the table
   uses available vertical space without overflowing — works regardless of
   aspect ratio (1920×1200, 3440×1440 ultrawide, 4K, etc). Floor matches
   the previous fixed sizing (1080p stays as before); ceiling caps growth
   on very tall displays. ~4 vh × 18 rows + thead + padding stays under
   100vh on every realistic monitor. */
.status-grid .mett-table       { font-size: clamp(0.72rem, 1.1vh, 1.3rem); border-collapse: separate; border-spacing: 0 clamp(2px, 0.3vh, 5px); }
.status-grid .mett-table th    { font-size: clamp(0.55rem, 0.85vh, 1rem); padding: clamp(0.08rem, 0.25vh, 0.22rem) 0.4rem; }
.status-grid .mett-table td    { height: clamp(1.55rem, 3.3vh, 3.6rem); padding: clamp(0.05rem, 0.18vh, 0.18rem) 0.4rem; font-size: inherit; border-bottom: none; }
.status-grid .trade-table      { table-layout: fixed; width: calc(7.5rem + 8.2rem); }
.status-grid .trade-empire-col { width: 7.5rem; }
/* 9 chips × 0.8rem + 8 gaps × 0.05rem + 2 × 0.3rem cell padding */
.status-grid .trade-chip-col   { width: 8.2rem; }
.status-grid .trade-card-col   { padding-bottom: 0.08rem; }
.status-grid .trade-chips      { gap: 0.05rem; }
.status-grid .trade-chip       { width: 0.8rem; height: 1.25rem; font-size: 0.5rem; }

/* Fixed layout with explicit width (= sum of column widths) so empire column respects stated 5.5rem.
   table-layout:fixed + width:auto causes Chrome to use fill-available, ignoring max-width on cells. */
.status-grid .census-table { table-layout: fixed; width: 16.2rem; }
.status-grid .census-table thead th:first-child { width: 7.5rem; }

/* Narrow columns — widths come from --col-* on :root, overridden per breakpoint. */
.status-grid .mil-col    { width: var(--col-mil);        min-width: var(--col-mil); }
.status-grid .city-col   { width: var(--col-city);       min-width: var(--col-city); }
.status-grid .census-pop { width: var(--col-census-pop); min-width: var(--col-census-pop); }
.status-grid .rank       { width: var(--col-rank);       min-width: var(--col-rank); }
.status-grid .adv-pts    { width: var(--col-adv-pts);    min-width: var(--col-adv-pts); }
.status-grid .ast-pts    { width: var(--col-ast-pts);    min-width: var(--col-ast-pts); }
.status-grid .total-vp   { width: var(--col-total-vp);   min-width: var(--col-total-vp); }

/* Full-width colored empire cells — fixed width so all tables align.
   Font scales with viewport height to match the row heights above. */
.empire-cell {
  font-weight: 600;
  font-size: clamp(0.72rem, 1.2vh, 1.4rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 7.5rem;
  min-width: 7.5rem;
  max-width: 7.5rem;
  border-radius: 0.2rem;
}

/* Leaderboard at the default breakpoint (700px–2560px): the 6-column table
   needs to fit a ~340px grid cell at 1920×1080, so shrink the empire-cell
   here without affecting the other tables. WQHD/4K override below. */
@media (min-width: 43.75em) and (max-width: 159.99rem) {
  .lb-table .empire-cell { width: 5rem; min-width: 5rem; max-width: 5rem; }
}
.civ-num {
  display: inline-block;
  background: rgba(0,0,0,0.3);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  min-width: 0.9rem;
  text-align: center;
  border-radius: 0.125rem;
  padding: 0.02rem 0.15rem;
  margin-right: 0.3rem;
  vertical-align: middle;
}

/* Trade group separator — pseudo-element centered in the 4px border-spacing gap.
   border-top alone lands at the bottom of the gap; top:-2px centers a 1px line in it. */
.status-grid .trade-table .trade-group-start td {
  border-top: none;
  overflow: visible;
  position: relative;
}
.status-grid .trade-table .trade-group-start td::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--mett-accent);
  pointer-events: none;
}

/* Gap between the West and East trade tables */
.trade-east { margin-top: 0.5rem; }

/* Player name column in s3 leaderboard */
.player-name-col {
  max-width: 5.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

/* AST order table — single empire-cell column, group separators between levels */
.ast-order-table { table-layout: fixed; }
.status-grid .ast-order-table { width: auto; }
.ast-order-table td { width: 7.5rem; min-width: 7.5rem; }
.ast-order-table .ast-order-group-start td {
  border-top: none;
  overflow: visible;
  position: relative;
}
.ast-order-table .ast-order-group-start td::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--mett-accent);
  pointer-events: none;
}

/* AST board compact sizing for s3 — !important beats the wide media-query rule.
   Row pitch matches other status-grid tables (height + border-spacing) so all
   18 empires line up across columns within a 1080p viewport. */
.ab-table.status-ast {
  width: auto !important;
  font-size: 0.65rem !important;
  border-collapse: separate !important;
  border-spacing: 0 2px !important;
}
.status-ast thead th { font-size: clamp(0.55rem, 0.85vh, 1rem); padding: clamp(0.08rem, 0.25vh, 0.22rem) 0.4rem; }
.status-ast thead tr { height: clamp(1rem, 2vh, 1.8rem); }
.status-ast .ab-civ-label { width: 7.5rem; min-width: 7.5rem; }
.status-ast td.empire-cell { padding: clamp(0.05rem, 0.18vh, 0.18rem) 0.4rem; font-size: clamp(0.72rem, 1.2vh, 1.4rem); }
.status-ast .ab-cell      { width: clamp(1.9rem, 2.4vw, 3rem); height: clamp(1.55rem, 3.3vh, 3.6rem); }
.status-ast .ab-level-num { width: clamp(1.9rem, 2.4vw, 3rem); font-size: clamp(0.52rem, 0.78vh, 0.95rem) !important; }
.status-ast .ab-round-num { width: clamp(1.9rem, 2.4vw, 3rem); font-size: clamp(0.52rem, 0.78vh, 0.95rem) !important; }
.status-ast .ab-name      { font-size: clamp(0.55rem, 0.85vh, 1rem) !important; }
.status-ast .ab-magnet {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ─── S3 phone layout — single column, normal density ────────────────────── */

@media (max-width: 43.75em) {
  .status-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Undo TV-compact sizing */
  .status-header { margin: 0.5rem 0 0.75rem; }
  .status-header .game-status { font-size: 0.9rem; }
  .status-grid .table-section   { padding: 0.6rem 0.8rem; }
  .status-grid .table-section h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
  .status-grid .table-hint       { font-size: 0.78rem; margin-top: 0.35rem; }
  .status-grid .mett-table       { font-size: 0.84rem; }
  .status-grid .mett-table th    { font-size: 0.72rem; padding: 0.35rem 0.5rem; }
  .status-grid .mett-table td    { height: 2rem; padding: 0.15rem 0.5rem; }

  /* Census: back to normal auto layout filling full width */
  .status-grid .census-table { table-layout: auto; width: 100%; }
  .status-grid .census-table thead th:first-child { width: auto; }
  :root {
    --col-mil: 3.0rem;
    --col-city: 3.0rem;
    --col-census-pop: 3.5rem;
    --col-rank: 1.8rem;
    --col-adv-pts: 2.5rem;
    --col-ast-pts: 2.5rem;
    --col-total-vp: 3rem;
  }

  .census-table th.mil-col,
  .census-table th.city-col,
  .census-table th.census-pop { padding-left: 0.25rem; padding-right: 0.25rem; }

  /* Empire cells: unconstrained, fill remaining space */
  .empire-cell { width: auto; min-width: 5rem; max-width: none; font-size: 0.84rem; }
  .player-name-col    { max-width: 6rem; }

  /* Trade table: full-width, empire col % so it stays proportional at any font size */
  .status-grid .trade-table      { table-layout: fixed; width: 100%; }
  .status-grid .trade-empire-col { width: 40%; }
  .status-grid .trade-chip-col   { width: auto; }
  /* Chips in px — must not scale with user font size; 9×16+8×2+10 = 170px needed */
  .status-grid .trade-chip       { width: 16px; height: 24px; font-size: 10px; }
  .status-grid .trade-chips      { gap: 2px; }
  .status-grid .trade-table td   { padding-left: 5px; padding-right: 5px; }
  .trade-east { margin-top: 0.75rem; }
}

/* ─── S3 WQHD layout — 2560px CSS px (native 2560p, or 4K @ 1.5×) ─────────── */

@media (min-width: 160rem) {
  .status-grid .table-section   { padding: 0.45rem 0.55rem; }
  .status-grid .table-section h3 { font-size: 0.82rem; margin-bottom: 0.35rem; }
  .status-grid .table-hint       { font-size: 0.72rem; }
  .status-grid .ab-legend        { font-size: 0.62rem; gap: 0.15rem; }

  /* font/row sizing now handled by viewport-height-relative clamp() at the
     base level — see .status-grid .mett-table above. WQHD-specific tweaks
     stay below for column proportions and chip widths. */
  .status-grid .trade-chip       { width: 0.95rem; height: 1.5rem; font-size: 0.6rem; }
  /* 9 × 0.95rem + 8 × 0.05rem + 2 × 0.4rem padding = 10.25rem; empire = 7.5rem */
  .status-grid .trade-chip-col   { width: 10.25rem; }
  .status-grid .trade-table      { width: calc(7.5rem + 10.25rem); }

  /* Census: keep auto column with a fixed table (empire 7.5rem + 2×2.2rem + 2.5rem = 14.4rem) */
  .status-grid .census-table { width: 14.4rem; }
  .status-grid .census-table thead th:first-child { width: 7.5rem; }
  :root {
    --col-mil: 2.2rem;
    --col-city: 2.2rem;
    --col-census-pop: 2.5rem;
    --col-rank: 1.5rem;
    --col-adv-pts: 2.2rem;
    --col-ast-pts: 2.2rem;
    --col-total-vp: 2.8rem;
  }

  .empire-cell { width: 7.5rem; min-width: 7.5rem; max-width: 7.5rem; }
  .status-grid .trade-empire-col { width: 7.5rem; }
  .civ-num { font-size: 0.7rem; min-width: 1.15rem; }
  .player-name-col { max-width: 7rem; }
  .ast-order-table td { width: 7.5rem; min-width: 7.5rem; }

  /* Trade separator: re-center 1px line in the now-5px gap */
  .status-grid .trade-table .trade-group-start td::before { top: -2.5px; }

  /* AST board: row heights + fonts handled by viewport-height clamp() above. */
  .status-ast .ab-civ-label { width: 7.5rem; min-width: 7.5rem; }
  .status-ast .ab-magnet    { width: 1.5rem; height: 1.5rem; font-size: clamp(0.62rem, 1vh, 1.05rem); }
}

/* ─── S3 4K layout — 3072px CSS px (4K @ 1.25×) ───────────────────────────── */

@media (min-width: 192rem) {
  .status-grid {
    grid-template-columns: 2.0fr auto auto 3.5fr auto;
    gap: 0.75rem;
  }

  .status-header .game-status { font-size: 1rem; }

  .status-grid .table-section   { padding: 0.55rem 0.65rem; }
  .status-grid .table-section h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
  .status-grid .table-hint       { font-size: 0.82rem; }
  .status-grid .ab-legend        { font-size: 0.72rem; gap: 0.2rem; }

  /* Font/row sizing comes from viewport-height clamp() at the base level. */
  .status-grid .trade-chip       { width: 1.1rem; height: 1.75rem; font-size: 0.7rem; }
  /* 9 × 1.1rem + 8 × 0.05rem + 2 × 0.45rem padding = 11.8rem; empire = 7.5rem */
  .status-grid .trade-chip-col   { width: 11.8rem; }
  .status-grid .trade-table      { width: calc(9rem + 11.8rem); }

  /* Census: explicit width so empire col gets a full 9rem (longest civ name = 8 chars @ 1.15rem) */
  .status-grid .census-table { width: calc(9rem + 2 * 2.5rem + 3rem); }
  .status-grid .census-table thead th:first-child { width: 9rem; }
  :root {
    --col-mil: 2.5rem;
    --col-city: 2.5rem;
    --col-census-pop: 3rem;
    --col-rank: 1.7rem;
    --col-adv-pts: 2.6rem;
    --col-ast-pts: 2.6rem;
    --col-total-vp: 3.3rem;
  }

  .empire-cell { width: 9rem; min-width: 9rem; max-width: 9rem; }
  .status-grid .trade-empire-col { width: 9rem; }
  .ast-order-table td { width: 9rem; min-width: 9rem; }
  .civ-num { font-size: 0.75rem; min-width: 1.25rem; }
  .player-name-col { max-width: 10rem; }

  /* Trade separator: re-center in 6px gap */
  .status-grid .trade-table .trade-group-start td::before { top: -3px; }

  /* AST board: row heights + fonts handled by viewport-height clamp() above. */
  .status-ast .ab-civ-label { width: 9rem; min-width: 9rem; }
  .status-ast .ab-magnet    { width: 1.8rem; height: 1.8rem; font-size: clamp(0.72rem, 1vh, 1.05rem); }
}

/* ─── Main 3-column layout ────────────────────────────────────────────────── */

.main-grid {
  display: grid;
  /* census | leaderboard | ast — leaderboard gets more room for 16:9 TV */
  grid-template-columns: 5fr 8fr 5fr;
  gap: 1.5rem;
  align-items: stretch;
  min-width: 0;
}
.main-grid > * { min-width: 0; }

@media (max-width: 68.75em) {
  .main-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 43.75em) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ─── Status page responsive font scaling ─────────────────────────────────── */
@media (max-width: 87.5em) {
  .mett-table { font-size: 0.84rem; }
  .mett-table th { font-size: 0.7rem; padding: 0.4rem 0.5rem; }
  .mett-table td { height: 1.9rem; padding: 0.25rem 0.5rem; }
  .table-section { padding: 0.6rem; }
  .main-grid { gap: 1rem; }
}
@media (max-width: 68.75em) {
  .mett-table { font-size: 0.8rem; }
  .mett-table td { height: 1.75rem; }
  .table-section { padding: 0.5rem; }
  .main-grid { gap: 0.6rem; }
}
@media (max-width: 43.75em) {
  .mett-table { font-size: 0.78rem; }
  main.container-fluid { padding-left: 0.3rem !important; padding-right: 0.3rem !important; }
  .player-name-col { display: none; }
  .lb-badge-name { display: block; }
  .lb-table .adv-pts, .lb-table .ast-pts, .lb-table .total-vp, .lb-table .rank { padding-left: 0.2rem; padding-right: 0.2rem; }
}

/* ─── Admin page responsive font scaling ──────────────────────────────────── */

@media (max-width: 75em) {
  .admin-table { font-size: 0.82rem; }
  .admin-table td { height: 1.9rem; }
  .admin-table .player-name-input { width: 6.875rem; font-size: 0.82rem; }
  .admin-table .adv-input { width: 4.25rem; }
  .mett-header h2 { font-size: 1.2rem; }
  .admin-header h2 { font-size: 1.2rem; }
}
@media (max-width: 56.25em) {
  .admin-table { font-size: 0.76rem; }
  .admin-table .player-name-input { width: 5.625rem; font-size: 0.76rem; }
  .admin-table .adv-input { width: 3.625rem; }
  .ast-btn { width: 1.4rem; height: 1.4rem; font-size: 0.85rem; }
  .ast-select { font-size: 0.76rem; }
  .mil-toggle:not(.icon-toggle), .won-toggle:not(.icon-toggle) { font-size: 0.72rem; padding: 0.15rem 0.35rem; }
  .setup-section, .admin-section { padding: 0.4rem 0.6rem; }
}
@media (max-width: 43.75em) {
  /* Admin — ultra compact for phone */
  .admin-table { font-size: 0.68rem; }
  .admin-table td, .admin-table th { padding: 0.15rem 0.2rem; height: 1.6rem; }
  .admin-table .player-name-input { width: 4.5rem; font-size: 0.68rem; }
  .admin-table .adv-input { width: 2.875rem; font-size: 0.68rem; }
  .census-admin-input { width: 2.625rem !important; font-size: 0.68rem; padding: 0.12rem 0.15rem; }
  .admin-table .rank-input { width: 2.125rem; font-size: 0.65rem; }
  .ast-btn { width: 1.2rem; height: 1.2rem; font-size: 0.75rem; }
  .ast-select { font-size: 0.66rem; padding: 0.1rem 0.15rem; }
  .ast-ctrl { gap: 0.15rem; }
  .mil-toggle:not(.icon-toggle), .won-toggle:not(.icon-toggle) { font-size: 0.62rem; padding: 0.1rem 0.2rem; }
  .admin-section { padding: 0.3rem 0.4rem; }

  /* All tables on phone — minimal column gaps */
  .mett-table td, .mett-table th { padding-left: 0.2rem; padding-right: 0.2rem; }
}

.table-section {
  background: var(--mett-surface);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.3125rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  min-width: 0;
}

.table-spacer { flex: 1; }

.table-section h3 {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mett-muted);
  font-weight: 700;
}

/* ─── Banners ─────────────────────────────────────────────────────────────── */

.no-game-banner,
.census-ready-banner,
.final-round-banner {
  padding: 1rem 1.5rem;
  border-radius: 0.3125rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.final-round-banner {
  background: #3a1010;
  border: 0.0625rem solid var(--mett-danger);
  color: #ff9999;
}

.final-scores-section {
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
}

/* Score breakdown shown only on mobile inside player name cell */
.go-score-detail { display: none; }

/* Game-over empire badge: let it size to content so long names like "Carthage"
   never clip regardless of font rendering or monitor DPI. */
.game-over-table .civ-badge-with-num { width: auto; min-width: 8rem; }

/* ─── Game-over table: card layout on narrow/large-text screens ───────────── */
@media (max-width: 43.75em) {
  .game-over-table thead { display: none; }
  .game-over-table,
  .game-over-table tbody { display: block; }
  .game-over-table tr {
    display: grid;
    /* empire: fit-content caps at 55% so total always gets meaningful space */
    grid-template-columns: 1.8rem fit-content(55%) 1fr;
    align-items: stretch;  /* all three cells same height as empire badge */
    gap: 0.5rem;
    padding: 0.45rem 0.1rem;
    border-bottom: 0.0625rem solid var(--mett-border);
  }
  .game-over-table tr.lb-tied { background: rgba(204,136,0,0.06); }
  .game-over-table td { height: auto; overflow: visible; }
  /* Rank: vertically centred */
  .game-over-table .go-rank   { padding: 0; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
  /* Empire: flex container so badge stretches to fill full cell height */
  .game-over-table .go-empire { padding: 0; overflow: visible; white-space: normal; display: flex; align-items: stretch; }
  /* Total: vertically centred, right-aligned — 1fr gives it all remaining space */
  .game-over-table .go-total  { padding: 0; display: flex; align-items: center; justify-content: flex-end; white-space: nowrap; font-size: 1rem; overflow: visible; }
  .game-over-table .go-ast,
  .game-over-table .go-adv   { display: none; }
  .game-over-table .go-tie   { grid-column: 1 / 4; padding: 0.25rem 0 0; }
  .game-over-table .go-tie:empty { display: none; }
  /* Badge fills empire cell: flex:1 for full width, align-self:stretch for full height */
  .game-over-table .civ-badge-with-num { flex: 1 1 100%; display: flex; white-space: normal; align-items: flex-start; }
  .game-over-table .civ-badge-label   { display: flex; flex-direction: column; line-height: 1.25; }
  .game-over-table .go-player-name    { display: block !important; font-size: 0.72rem; opacity: 0.82; margin-top: 0.15rem; }
  /* strip padding from the game-over section so table sits flush */
  .go-section { padding: 0.15rem 0.05rem; }
  main.container-fluid { padding-left: 0.15rem !important; padding-right: 0.15rem !important; }
}

/* Medal flags (⚑) in gold/silver/bronze */
.medal {
  font-size: 1rem;
  vertical-align: middle;
}
.medal-gold   { color: #f5c518; }
.medal-silver { color: #adb5bd; }
.medal-bronze { color: #cd7f32; }

/* Late Iron Age star — shown next to empire name */
.lia-star {
  color: var(--mett-accent);
  font-size: 0.9rem;
  vertical-align: middle;
}

/* Late Iron Age star toggle button (admin game-over) */
.lia-star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0.2rem;
  vertical-align: middle;
  transition: color 0.15s;
}
.lia-star-on  { color: var(--mett-accent); }
.lia-star-off { color: var(--mett-border); }
.lia-star-off:hover { color: var(--mett-muted); }
.lia-star-ineligible { color: var(--mett-border); opacity: 0.3; cursor: default; }

/* LIA bonus chip (leaderboard + player page) */
.lia-bonus-chip { color: var(--mett-accent); font-size: 0.85rem; }
.lia-bonus-row  { margin-top: 0.25rem; }

/* Tie-break rank dropdown */
.rank-select {
  --pico-form-element-spacing-vertical: 0.15rem;
  --pico-form-element-spacing-horizontal: 0.35rem;
  font-size: 0.8rem;
  width: auto;
}
.rank-select-resolved {
  opacity: 0.55;
  cursor: default;
}

.no-game-banner {
  background: var(--mett-surface);
  border: 0.0625rem solid var(--mett-border);
  color: var(--mett-muted);
}

.census-ready-banner {
  background: #1a3a1a;
  border: 0.0625rem solid var(--mett-success);
  color: var(--mett-success);
}

/* ─── Civ Page ────────────────────────────────────────────────────────────── */

.civ-hero {
  background: var(--civ-color, #333);
  color: var(--civ-text, #fff);
  border-radius: 0.375rem;
  padding: 0.45rem 0.85rem;
  margin-bottom: 0.4rem;
  position: relative;
}

.civ-hero-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.civ-hero h2 {
  font-size: 1.7rem;
  font-weight: 900;
  margin: 0;
  color: inherit;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.civ-player-name {
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.8;
}

.civ-region-tag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: rgba(0,0,0,0.2);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  align-self: flex-start;
  text-transform: uppercase;
}

.civ-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.civ-body > * { min-width: 0; } /* prevent grid items from expanding beyond their track */

.civ-section.ast-section {
  grid-column: 1 / -1;
}

@media (max-width: 43.75em) {
  /* Container gutters */
  main.container-fluid { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }

  /* Hero */
  .civ-hero { padding: 0.35rem 0.5rem; margin-bottom: 0.2rem; }
  .civ-hero-content { gap: 0.02rem; }
  .civ-hero h2 { font-size: 1.0rem; gap: 0.3rem; }
  .civ-player-name { font-size: 0.72rem; }
  .civ-region-tag { font-size: 0.58rem; padding: 0.08rem 0.25rem; }

  /* Body layout */
  .civ-body { grid-template-columns: 1fr; gap: 0.2rem; }
  .civ-section { padding: 0.3rem 0.4rem; }
  .civ-section h3 { font-size: 0.68rem; margin-bottom: 0.15rem; letter-spacing: 0.04em; }

  /* Census — status line very tight, input row compact */
  .census-submitted, .census-pending { font-size: 0.7rem; margin-bottom: 0.08rem; }
  .census-input-row, .adv-input-row { gap: 0.2rem; }
  .census-input, .adv-input { -webkit-appearance: none; appearance: none; font-size: 0.82rem; padding: 0 0 0 0.4rem; height: 1.65rem; min-height: 0; line-height: 1.65rem; box-sizing: border-box; border-radius: 0.1875rem; }
  .btn-submit { font-size: 0.74rem; padding: 0 0.5rem; height: 1.65rem; min-height: 0; box-sizing: border-box; }
  .move-order { font-size: 0.68rem; margin-top: 0.1rem; }

  /* Advances — stacked rows, very tight */
  .adv-cards { gap: 0.1rem; }
  .adv-card-row { gap: 0.18rem; margin: 0; }
  .adv-card-label { font-size: 0.66rem; }
  .adv-card-input { -webkit-appearance: none; appearance: none; font-size: 0.76rem; padding: 0 0.3rem 0 0; width: 3rem; height: 1.5rem; min-height: 0; line-height: 1.5rem; text-align: right; box-sizing: border-box; border-radius: 0.1875rem; margin: 0 !important; }
  .adv-btn { width: 1.5rem; height: 1.5rem; min-height: 0; font-size: 0.85rem; }
  .adv-total-row { margin-top: 0.1rem; padding-top: 0.15rem; gap: 0.2rem; }
  .adv-total-label { font-size: 0.68rem; }
  .adv-total-value { font-size: 0.9rem; min-width: 2rem; }

  /* Military */
  .mil-toggle-civ, .won-toggle-civ { padding: 0.28rem 0.5rem; font-size: 0.78rem; }

  /* AST section */
  .ast-current { margin-bottom: 0.18rem; gap: 0.3rem; }
  .ast-level-label { font-size: 0.75rem; }
  .ast-level-value { font-size: 1.05rem; }
  .ast-era { font-size: 0.7rem; }
  .ast-next { padding: 0.28rem 0.4rem; margin-bottom: 0.2rem; }
  .ast-next h4 { font-size: 0.7rem; margin-bottom: 0.12rem; }
  .ast-req-text { font-size: 0.78rem; }
  .ast-mode-note { font-size: 0.64rem; margin-top: 0.1rem; }
  /* AST strip: 17 nodes (expert mode) must fit in a 412 CSS-px phone
     viewport without horizontal scroll. */
  :root { --ast-node-size: 1.3rem; --ast-node-gap: 0.0625rem; }
  .ast-node { font-size: 0.55rem; }
  .ast-age-label { font-size: 0.36rem; padding: 0.0625rem 0; margin-bottom: 0.0625rem; }
}

.civ-section {
  background: var(--mett-surface);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.3125rem;
  padding: 0.4rem 0.6rem;
}

.civ-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--mett-muted);
  font-weight: 700;
}

.census-submitted { color: var(--mett-success); font-weight: 600; margin: 0 0 0.35rem; font-size: 0.9rem; }
.census-pending { color: var(--mett-warning); margin: 0 0 0.35rem; font-size: 0.9rem; }
.status-icon-fixed { display: inline-block; width: 1em; text-align: center; flex-shrink: 0; }

.census-input-row,
.adv-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.census-input, .adv-input {
  --pico-form-element-spacing-vertical: 0.25rem;
  --pico-form-element-spacing-horizontal: 0.5rem;
  flex: 1;
  max-width: 10rem;
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  color: var(--mett-text);
  font-size: 0.95rem;
  margin: 0 !important;
}

/* Advance card inputs */
.adv-cards { display: flex; flex-direction: column; gap: 0.25rem; }
.adv-card-row { display: flex; align-items: center; gap: 0.3rem; }
.adv-card-label { flex: 1; font-size: 0.82rem; color: var(--mett-muted); white-space: nowrap; }
.adv-btn {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.1875rem;
  background: var(--mett-surface2);
  color: var(--mett-text);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.adv-btn:hover { background: var(--mett-border); }
.adv-card-input {
  --pico-form-element-spacing-vertical: 0.18rem;
  --pico-form-element-spacing-horizontal: 0.35rem;
  width: 4rem;
  text-align: right;
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.1875rem;
  color: var(--mett-text);
  font-size: 0.88rem;
  margin: 0 !important;
}
/* Hide number input spinners globally for compact layout */
.adv-card-input::-webkit-outer-spin-button,
.adv-card-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.adv-card-input[type=number] { -moz-appearance: textfield; }
.adv-total-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding-top: 0.3rem;
  border-top: 0.0625rem solid var(--mett-border);
}
.adv-total-label { flex: 1; font-size: 0.85rem; color: var(--mett-muted); }
.adv-total-value { font-weight: 800; font-size: 1rem; min-width: 2.5rem; text-align: right; }

.btn-submit {
  background: var(--mett-accent);
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-submit:hover { filter: brightness(1.15); }

.move-order {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--mett-muted);
}

/* ─── AST Section on civ page ─────────────────────────────────────────────── */

.ast-current {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.ast-level-label { color: var(--mett-muted); }
.ast-level-value { font-size: 1.8rem; font-weight: 900; }
.ast-era { color: var(--mett-muted); font-size: 0.85rem; }

.ast-next {
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-accent);
  border-radius: 0.25rem;
  padding: 0.35rem 0.55rem;
  margin-bottom: 0.35rem;
}

.ast-next h4 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--mett-accent); }
.ast-req-text { margin: 0; font-weight: 600; font-size: 1rem; }
.ast-mode-note { margin: 0.25rem 0 0; font-size: 0.75rem; color: var(--mett-muted); }

.ast-warn-regress {
  margin: 0;
  font-weight: 700;
  color: var(--mett-danger);
  font-size: 1rem;
}
.ast-req-status {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.req-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.req-ok { color: var(--mett-success); }
.req-fail { color: var(--mett-danger); }
.req-unknown { color: var(--mett-muted); }
.req-have { font-weight: 400; font-size: 0.8rem; color: var(--mett-muted); }
.ast-next.req-all-ok { border-color: var(--mett-success); }
.ast-next.req-not-met { border-color: var(--mett-danger); }

.ast-bar-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
  scrollbar-width: none; /* Firefox */
}
.ast-bar-wrap::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.ast-progress-grid {
  display: grid;
  gap: var(--ast-node-gap);
  width: max-content;
}

.ast-age-label {
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  border-radius: 0.1875rem 0.1875rem 0 0;
  padding: 0.125rem 0;
  margin-bottom: 0.125rem;
}

.ast-node {
  width: var(--ast-node-size);
  height: var(--ast-node-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.1875rem;
  font-size: 0.65rem;
  font-weight: 700;
  cursor: default;
}

.ast-node.past { background: var(--mett-surface2); color: var(--mett-muted); }
.ast-node.active {
  background: var(--mett-accent);
  color: #fff;
  box-shadow: 0 0 0.5rem var(--mett-accent);
  transform: scale(1.1);
}
.ast-node.future { background: var(--mett-surface); border: 0.0625rem solid var(--mett-border); color: var(--mett-muted); }

/* ─── AST Full Table ──────────────────────────────────────────────────────── */

.ast-full-table td { vertical-align: top; padding-top: 0.3rem; padding-bottom: 0.3rem; }

.ast-full-table .ast-level-cell {
  font-weight: 800;
  font-size: 1rem;
  text-align: right;
  width: 4rem;
}

.ast-full-table .ast-era-cell {
  color: var(--mett-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.ast-full-table tr.ast-row-occupied td {
  background: rgba(108, 110, 255, 0.08);
}

/* ast-civs-cell is now an inner div (not td) to avoid display:flex on td causing row jump */
.ast-civs-cell { display: flex; flex-direction: column; gap: 0.125rem; min-width: 6.25rem; align-items: flex-start; }

.ast-table-wrap { overflow-x: auto; }

.ast-mode-toggle {
  margin-bottom: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--mett-surface);
  border-radius: 0.25rem;
  border: 0.0625rem solid var(--mett-border);
  font-size: 0.82rem;
}
.ast-mode-toggle p { margin: 0; }

/* ─── AST View Toggle ────────────────────────────────────────────────────── */

.ast-view-toggle {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.ast-toggle-btn {
  padding: 0.25rem 0.9rem;
  font-size: 0.85rem;
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  background: var(--mett-surface);
  color: var(--mett-muted);
  cursor: pointer;
}

.ast-toggle-btn.active-toggle {
  background: var(--mett-accent);
  color: #fff;
  border-color: var(--mett-accent);
}

/* ─── AST Board View ─────────────────────────────────────────────────────── */

/* Shrink-wrap the table so it doesn't stretch to fill the page */
.ab-scroll {
  overflow-x: auto;
  display: inline-block;   /* key: shrinks to table width */
  max-width: 100%;
}

.ab-table {
  border-collapse: collapse;
  table-layout: fixed;
  /* width is sum of columns: 6.25rem label + 17 × 1.875rem = 38.125rem */
  width: 38.125rem;
  font-size: 0.72rem;
}

/* Scale up on wider screens: 68.75rem → 10rem label + 17×3rem = 61rem */
@media (min-width: 68.75em) {
  .ab-scroll { display: block; }
  .ab-table { width: 61rem; font-size: 0.82rem; }
  .ab-civ-label { width: 8.125rem; }
  .ab-level-num { width: 3rem; font-size: 0.72rem; }
  .ab-cell { width: 3rem; height: 2.125rem; }
  .ab-magnet { width: 1.625rem; height: 1.625rem; }
  .ab-name { font-size: 0.72rem; }
  .ab-round-num { font-size: 0.72rem; }
}

/* Even wider: 87.5rem → 11.25rem label + 17×3.625rem = 72.875rem */
@media (min-width: 87.5em) {
  .ab-table { width: 72.875rem; font-size: 0.88rem; }
  .ab-civ-label { width: 8.4375rem; }
  .ab-level-num { width: 3.625rem; font-size: 0.76rem; }
  .ab-cell { width: 3.625rem; height: 2.5rem; }
  .ab-magnet { width: 1.875rem; height: 1.875rem; }
  .ab-name { font-size: 0.76rem; }
  .ab-round-num { font-size: 0.76rem; }
}

.ab-table th, .ab-table td {
  padding: 0;
  border: 0.0625rem solid rgba(255,255,255,0.08);
}

/* Civ label column — sticky so it stays visible when scrolling */
.ab-civ-label {
  width: 7.8125rem;
  padding: 0.2rem 0.4rem;
  background: var(--mett-bg);
  position: sticky;
  left: 0;
  z-index: 2;
  border-right: 0.125rem solid rgba(0,0,0,0.5) !important;
}

.ab-corner { background: var(--mett-bg) !important; z-index: 3; }
.status-ast .ab-corner { background: transparent !important; border: none !important; }

.ab-player-col {
  position: sticky;
  left: 10rem;
  background: inherit;
  z-index: 2;
  width: 10rem;
  min-width: 10rem;
  max-width: 10rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 0.0625rem solid var(--mett-border);
}
th.ab-player-col {
  font-size: 0.65rem;
  color: var(--mett-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ab-vp-label {
  font-size: 0.6rem;
  color: var(--mett-muted);
  font-weight: 400;
  text-align: right;
  padding-right: 0.3rem;
}

.ab-civ-num {
  display: inline-block;
  width: 1.1em;
  opacity: 0.65;
  font-size: 0.65em;
  vertical-align: middle;
}

/* Age band header row */
.ab-header {
  text-align: center;
  padding: 0.2rem 0.1rem;
  vertical-align: middle;
  overflow: hidden;
  border-bottom: 0.125rem solid rgba(0,0,0,0.4) !important;
}

.ab-name {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.15;
  word-break: break-word;
  hyphens: auto;
}

/* Level number row */
.ab-level-num {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.15rem 0;
  width: 1.875rem;
  border-bottom: 0.125rem solid rgba(0,0,0,0.4) !important;
}

/* Age band colours — headers */
.age-start   { background: #1a1a1a; color: #666; }
.age-stone   { background: #3a3028; color: #c8b89a; }
.age-ebronze { background: #352818; color: #d4a870; }
.age-mbronze { background: #2e1e0e; color: #c09050; }
.age-lbronze { background: #221408; color: #a07840; }
.age-eiron   { background: #2a2000; color: #c8a020; }
.age-liron   { background: #1e1004; color: #b06828; }

/* Cell tints for the body rows */
.ab-cell {
  width: 1.875rem;
  height: 1.5rem;
  text-align: center;
  vertical-align: middle;
}

.ab-cell.age-start   { background: rgba(30,30,30,0.30); }
.ab-cell.age-stone   { background: rgba(90,76,52,0.35); }
.ab-cell.age-ebronze { background: rgba(110,72,20,0.35); }
.ab-cell.age-mbronze { background: rgba(80,48,10,0.40); }
.ab-cell.age-lbronze { background: rgba(56,32,6,0.45); }
.ab-cell.age-eiron   { background: rgba(72,56,0,0.40); }
.ab-cell.age-liron   { background: rgba(90,36,4,0.40); }

/* Thick right border marks the end of each age band per empire row */
.ab-age-end {
  border-right: 0.125rem solid rgba(255,255,255,0.22) !important;
}

/* Start column — level 0, where all empires sit at game start */
.ab-start-col {
  border-right: 0.125rem solid rgba(255,255,255,0.22) !important;
  opacity: 0.6;
}
.ab-level-num.ab-start-col {
  font-style: italic;
  letter-spacing: 0;
}

/* Magnet dot */
.ab-magnet {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 0.0938rem solid rgba(0,0,0,0.4);
  box-shadow: 0 0.0625rem 0.1875rem rgba(0,0,0,0.6), inset 0 0.0625rem 0.125rem rgba(255,255,255,0.25);
  vertical-align: middle;
}

/* Requirements legend below the board */
.ab-legend {
  list-style: none;
  padding: 0.5rem 0 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  font-size: 0.72rem;
  color: var(--mett-muted);
}

.ab-legend li { display: flex; align-items: center; gap: 0.35rem; }

.ab-legend-dot {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 0.125rem;
  flex-shrink: 0;
}

.ab-slowstart-note {
  font-size: 0.68rem;
  color: var(--mett-muted);
  margin: 0.25rem 0 0;
}

/* Round track footer row */
.ab-round-label {
  font-size: 0.6rem;
  color: var(--mett-muted);
  font-weight: 400;
  text-align: right;
  padding-right: 0.3rem;
}

.ab-round-num {
  text-align: center;
  font-size: 0.6rem;
  color: var(--mett-muted);
  padding: 0.12rem 0;
  border-top: 0.0625rem solid rgba(255,255,255,0.08);
}

.ab-round-current {
  color: var(--mett-accent);
  font-weight: 700;
  background: rgba(196,147,63,0.12) !important;
}

/* ─── Admin Page ──────────────────────────────────────────────────────────── */

.admin-page h2 { margin-bottom: 1.5rem; }

.setup-section,
.admin-section {
  background: var(--mett-surface);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.3rem;
}

.setup-section h3,
.admin-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mett-muted);
  font-weight: 700;
}

.mode-toggle-row {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.mode-toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.player-count-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.player-count-select {
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.3rem 0.5rem;
  color: var(--mett-text);
  font-size: 1rem;
  cursor: pointer;
}

.setup-hint {
  font-size: 0.8rem;
  color: var(--mett-muted);
  margin: 0;
}

.civ-num { font-size: 0.7rem; }

/* ─── Name inputs ─────────────────────────────────────────────────────────── */

.name-inputs-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1.25rem;
}

@media (max-width: 37.5em) {
  .name-inputs-grid2 { grid-template-columns: 1fr; }
}

.name-input-row {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.name-civ-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  border-radius: 0.125rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 5.5rem;
}

.name-text-input {
  flex: 1;
  min-width: 0;
  margin: 0 !important;
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.3rem 0.5rem;
  color: var(--mett-text);
  font-size: 0.85rem;
  height: auto;
  line-height: 1.4;
}

/* ─── Admin active controls ───────────────────────────────────────────────── */

.admin-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.admin-header h2 { margin: 0; }
.admin-badges { display: flex; gap: 0.5rem; }

.round-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.debug-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 0.0625rem solid var(--mett-border);
}
.round-hint {
  font-size: 0.8rem;
  color: var(--mett-warning);
  opacity: 0.85;
}

/* Login page */
.login-page {
  max-width: 20rem;
  margin: 4rem auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  background: var(--mett-bg-alt);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.35rem;
  color: var(--mett-text);
}
.login-error {
  color: #e05555;
  font-size: 0.9rem;
}
.pwd-ok {
  color: #4caf50;
  font-size: 0.9rem;
}
.change-pwd-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}
.change-pwd-form .login-input {
  width: auto;
  flex: 1 1 10rem;
}

/* Submission progress counters */
.submission-progress {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.sub-prog-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.35rem;
  background: var(--mett-bg-alt);
  border: 0.0625rem solid var(--mett-border);
  font-size: 0.8rem;
}
.sub-prog-item.sub-prog-done {
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.15);
}
.sub-prog-label { opacity: 0.8; }
.sub-prog-count { font-weight: 600; }
.sub-prog-item.sub-prog-done .sub-prog-label { opacity: 1; }

/* Section hint text (civ page) */
.section-hint {
  font-size: 0.8rem;
  opacity: 0.7;
  margin: -0.25rem 0 0.5rem;
}

/* Reset Pico CSS margin AND padding on all form elements inside admin table */
.admin-table input,
.admin-table select,
.admin-table button {
  margin: 0 !important;
}
.admin-table input[type=text],
.admin-table input[type=number],
.admin-table select {
  --pico-form-element-spacing-vertical: 0.12rem;
  --pico-form-element-spacing-horizontal: 0.35rem;
}

.admin-table { font-size: 0.84rem; }
.admin-table td { height: 1.75rem; padding: 0.15rem 0.4rem; }
.admin-table th { padding: 0.25rem 0.4rem; font-size: 0.68rem; }

/* 1080p laptop-on-the-table — primary target is WQHD/4K, but the 18-row
   Players table runs ~300 px past the fold at FHD with the default
   density. Tighten rows, form-element padding, and icon buttons so all
   18 players fit (Danger Zone may still need a small scroll). Capped
   below the WQHD breakpoint (160em) so TV-display density at 2560px+
   is untouched. */
@media (min-width: 75em) and (max-width: 159.99em) {
  .admin-table td { height: 1.2rem; padding: 0.04rem 0.4rem; }
  .admin-table th { padding: 0.1rem 0.4rem; }
  .admin-table input[type=text],
  .admin-table input[type=number],
  .admin-table select {
    --pico-form-element-spacing-vertical: 0.04rem;
    line-height: 1.1;
  }
  .admin-table .icon-toggle { width: 1.3rem; height: 1.3rem; font-size: 0.8rem; }
  .admin-table .lia-star-btn { font-size: 0.85rem; padding: 0; }
  .ast-ctrl { gap: 0.2rem; }
  .admin-section { padding: 0.35rem 0.55rem; }
  .submission-progress { gap: 0.5rem; }
  .round-controls { margin-top: 0.35rem; }
  .admin-header { margin-bottom: 0.4rem; }
  .admin-header h2 { margin: 0; }
}
.admin-table th { width: 14.28%; }

.admin-table .player-name-input {
  background: transparent;
  border: 0.0625rem solid transparent;
  color: var(--mett-text);
  font-size: 0.84rem;
  padding: 0.15rem 0.35rem;
  border-radius: 0.1875rem;
  width: 7.5rem;
}
.admin-table .player-name-input:focus {
  border-color: var(--mett-accent);
  background: var(--mett-surface2);
  outline: none;
}

.mil-won-cell { display: flex; flex-direction: row; gap: 0.25rem; align-items: center; }
.mil-toggle, .won-toggle {
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.1875rem;
  padding: 0.12rem 0.35rem;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}
/* Icon-only compact variant used in admin table */
.icon-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  border-radius: 0.1875rem;
  flex-shrink: 0;
}
.mil-toggle.mil-on { background: #3a2020; border-color: #cc5555; color: #ff8888; }
.mil-toggle.mil-off { background: var(--mett-surface2); color: var(--mett-muted); }
.won-toggle.won-on  { background: #2a2a10; border-color: #aaaa22; color: #dddd44; }
.won-toggle.won-off { background: var(--mett-surface2); color: var(--mett-muted); }

.ast-ctrl {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.ast-status-dots {
  display: flex;
  align-items: center;
  gap: 0.1875rem;
  width: 1.1875rem;
  flex-shrink: 0;
}
.ast-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.ast-status-advance  { background: var(--mett-success); }
.ast-status-stay     { background: var(--mett-warning); }
.ast-status-regress  { background: var(--mett-danger); }
.ast-status-unknown  { background: var(--mett-border); }
.ast-status-hidden   { background: transparent; }

.ast-btn {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.1875rem;
  background: var(--mett-surface2);
  color: var(--mett-text);
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1;
  padding: 0;
}

.ast-select {
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  color: var(--mett-text);
  padding: 0.1rem 0.25rem;
  font-size: 0.82rem;
  width: 4.25rem;
}

.admin-table .rank-input {
  width: 2.75rem;
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.15rem 0.3rem;
  color: var(--mett-muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
}

.admin-table .adv-input {
  width: 4.25rem;
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.15rem 0.3rem;
  color: var(--mett-text);
  font-size: 0.82rem;
  text-align: right;
  margin: 0;
}

.city-admin-select {
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  color: var(--mett-text);
  padding: 0.1rem 0.25rem;
  font-size: 0.82rem;
  width: 4.25rem;
}

.census-admin-input { width: 5.875rem !important; flex: none; }
.census-admin-input::-webkit-inner-spin-button,
.census-admin-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; display: none; }
.census-admin-input { -moz-appearance: textfield; }
.census-admin-input,
.city-admin-input {
  background: var(--mett-surface2);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.1875rem;
  padding: 0.15rem 0.3rem;
  color: var(--mett-text);
  font-size: 0.82rem;
  text-align: right;
  margin: 0 !important;
}
.census-admin-input:focus,
.city-admin-input:focus {
  border-color: var(--mett-accent);
  outline: none;
}
.census-admin-input::placeholder,
.city-admin-input::placeholder { color: var(--mett-muted); }

.danger-section { border-color: #442222; }
.btn-outline-danger {
  background: transparent;
  border: 0.0625rem solid var(--mett-danger);
  color: var(--mett-danger);
  padding: 0.3rem 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.danger-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
#sim-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }

/* Informational nag shown below the Danger Zone when the admin password is still the seeded default. */
.default-pwd-nag {
  margin: 1.25rem 0 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--mett-muted);
  border-left: 0.125rem solid #6a5a22;
  background: rgba(106, 90, 34, 0.08);
  border-radius: 0 0.25rem 0.25rem 0;
}
.default-pwd-nag strong { color: var(--mett-fg); }

.ast-req-table { font-size: 0.8rem; }
.ast-req-table .ast-req-vp { font-weight: 700; width: 2.5rem; color: var(--mett-accent); }
.ast-req-table .ast-req-era { color: var(--mett-muted); white-space: nowrap; width: 8rem; }

/* ─── AST Turn Tracker ────────────────────────────────────────────────────── */

.ast-tracker-count {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--mett-muted);
  margin-left: 0.4rem;
}

.ast-tracker-table { width: auto; min-width: 0; }
/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--mett-accent);
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  padding: 0.5rem 1.2rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  background: var(--mett-danger);
  color: #fff;
  border: none;
  border-radius: 0.25rem;
  padding: 0.45rem 1rem;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: var(--mett-surface2);
  color: var(--mett-text);
  border: 0.0625rem solid var(--mett-border);
  border-radius: 0.25rem;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.error-msg {
  color: #ff6666;
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
  min-height: 1.2em;
}

.not-in-game {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--mett-muted);
}

/* ── Trade card layout (still used in main view) ──────────────────────────── */
.trade-table { width: 100%; }
.trade-table .trade-card-col {
  width: 10rem;
  vertical-align: middle;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}
.trade-table .trade-card-col.submitted-hidden { color: #4a8a5a; font-size: 1rem; font-weight: 700; }
.trade-table .trade-card-col.not-submitted    { color: #8a3a3a; font-size: 1rem; font-weight: 700; }
.trade-no-cards { color: var(--mett-muted); }
.trade-locked-msg { color: var(--mett-muted); font-size: 0.75rem; padding: 0.5rem 0; margin: 0; }
.phase-hint { color: var(--mett-muted); font-size: 0.78rem; margin: 0 0 0.4rem; }

/* Trade card chips */
.trade-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.125rem;
}
.trade-chip {
  width: 1rem;
  height: 1.5rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.125rem;
  border: 0.0625rem solid var(--mett-border);
  background: var(--mett-surface2);
  color: var(--mett-text);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1;
}
.trade-chip-wonder {
  background: #2a2a10;
  border-color: #aaaa22;
  color: #dddd44;
}
.trade-table .trade-group-start td {
  border-top: 0.125rem solid var(--mett-accent);
}

/* ── Error toast ─────────────────────────────────────────────────────────── */
#mett-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #7a1a1a;
  color: #fff;
  padding: 0.55rem 1.1rem;
  border-radius: 0.35rem;
  border: 1px solid #cc3333;
  font-size: 0.875rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 9999;
  white-space: nowrap;
}
#mett-toast.visible { opacity: 1; }
