/*
 * Warhost design system — "painted tabletop at night".
 * Dark ink backgrounds, parchment cards, gilded accents, and four heraldic player colours.
 */
:root {
  --ink-950: #0b0c12;
  --ink-900: #12141d;
  --ink-800: #1a1d29;
  --ink-700: #252a3a;
  --ink-600: #343a4f;
  --ink-400: #6b7390;
  --ink-300: #9aa1b9;
  --ink-200: #c9cddb;
  --parchment: #efe4c9;
  --parchment-2: #e4d5b1;
  --parchment-ink: #2b2116;
  --parchment-muted: #6d5b42;
  --gold: #d9a441;
  --gold-bright: #f3c868;
  --gold-deep: #9a6c1c;
  --blood: #8b1e2d;
  --blood-bright: #c8102e;
  --moss: #4d6b3a;
  --steel: #9aa6b2;

  --p0: #c8102e; /* Crimson */
  --p1: #1f5fbf; /* Azure */
  --p2: #e0a100; /* Gold */
  --p3: #2e9e4f; /* Verdant */

  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --radius: 10px;
  --radius-lg: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 3px 10px rgba(0, 0, 0, 0.35);
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-200);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(217, 164, 65, 0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(139, 30, 45, 0.16), transparent 60%),
    linear-gradient(180deg, var(--ink-900), var(--ink-950));
  background-attachment: fixed;
}
a { color: var(--gold-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--parchment); letter-spacing: 0.02em; line-height: 1.15; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 4vw, 3rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--ink-700); margin: 2rem 0; }

.icon { width: 1.15em; height: 1.15em; fill: currentColor; vertical-align: -0.2em; flex: none; }
.icon-lg { width: 2rem; height: 2rem; }
.icon-xl { width: 3rem; height: 3rem; }
.muted { color: var(--ink-300); }
.small { font-size: 0.88rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.container { width: min(1200px, 100%); margin: 0 auto; padding: 0 var(--gutter); }
.page { padding: 2rem 0 4rem; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 12, 18, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(217, 164, 65, 0.18);
}
.topbar .container { display: flex; align-items: center; gap: 1.5rem; height: 64px; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; color: var(--parchment); letter-spacing: 0.08em; }
.brand:hover { text-decoration: none; color: var(--gold-bright); }
.brand .icon { color: var(--gold); width: 1.6rem; height: 1.6rem; }
.nav { display: flex; gap: 0.25rem; flex: 1; flex-wrap: nowrap; overflow-x: auto; }
.nav a { color: var(--ink-200); padding: 0.4rem 0.8rem; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.nav a:hover, .nav a.active { background: var(--ink-700); color: var(--parchment); text-decoration: none; }
.nav-user { display: flex; gap: 0.75rem; align-items: center; white-space: nowrap; }
.nav-user form { margin: 0; }
@media (max-width: 760px) {
  .topbar .container { height: auto; padding-top: 0.6rem; padding-bottom: 0.6rem; flex-wrap: wrap; gap: 0.6rem; }
  .nav { order: 3; width: 100%; }
}

.footer { border-top: 1px solid var(--ink-800); padding: 2rem 0; color: var(--ink-400); font-size: 0.9rem; }

/* ---------- Flash ---------- */
.flash { margin: 1rem 0 0; padding: 0.8rem 1.1rem; border-radius: var(--radius); border: 1px solid; display: flex; gap: 0.6rem; align-items: center; }
.flash-notice { background: rgba(46, 158, 79, 0.12); border-color: rgba(46, 158, 79, 0.4); color: #bfe8c9; }
.flash-alert { background: rgba(200, 16, 46, 0.12); border-color: rgba(200, 16, 46, 0.45); color: #f6c1c9; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; font-size: 0.92rem;
  padding: 0.7rem 1.25rem; border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  color: var(--ink-950); background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  box-shadow: 0 2px 0 var(--gold-deep), var(--shadow-sm);
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--gold-deep); }
.btn[disabled], .btn.disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.5); }
.btn-ghost { background: transparent; color: var(--parchment); border-color: var(--ink-600); box-shadow: none; }
.btn-ghost:hover { background: var(--ink-700); }
.btn-danger { background: linear-gradient(180deg, #d23a4f, var(--blood)); color: #fff; box-shadow: 0 2px 0 #5a0f1b, var(--shadow-sm); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.95rem 1.7rem; font-size: 1.05rem; }
.btn-icon { padding: 0.45rem; border-radius: 8px; }
.button_to { display: inline; }

/* ---------- Cards & panels ---------- */
.panel {
  background: linear-gradient(180deg, rgba(37, 42, 58, 0.85), rgba(26, 29, 41, 0.92));
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.panel-title { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.panel-title h2, .panel-title h3 { margin: 0; }
.parchment {
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.35), transparent 40%),
    linear-gradient(180deg, var(--parchment), var(--parchment-2));
  color: var(--parchment-ink);
  border: 1px solid #c9b48a;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow), inset 0 0 40px rgba(120, 90, 40, 0.18);
}
.parchment h1, .parchment h2, .parchment h3, .parchment h4 { color: var(--parchment-ink); }
.parchment .muted { color: var(--parchment-muted); }
.parchment a { color: var(--blood); }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.layout-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 980px) { .layout-sidebar { grid-template-columns: 1fr; } }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.page-header h1 { margin: 0; }
.eyebrow { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.75rem; color: var(--gold); margin-bottom: 0.4rem; display: block; }

.empty { text-align: center; padding: 3rem 1rem; border: 1px dashed var(--ink-600); border-radius: var(--radius-lg); color: var(--ink-300); }
.empty .icon { width: 3rem; height: 3rem; color: var(--ink-600); margin-bottom: 0.5rem; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field label, .label { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-300); }
.parchment .field label { color: var(--parchment-muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  font: inherit; color: var(--parchment); background: var(--ink-950); border: 1px solid var(--ink-600);
  border-radius: 8px; padding: 0.65rem 0.8rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.form-errors { background: rgba(200, 16, 46, 0.12); border: 1px solid rgba(200, 16, 46, 0.45); color: #f6c1c9; border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1rem; }
.form-errors ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.auth-card { width: min(460px, 100%); margin: 3rem auto; }

.choice-group { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem; padding: 0.8rem 1.1rem; min-width: 96px;
  border: 1px solid var(--ink-600); border-radius: var(--radius); cursor: pointer; background: var(--ink-900);
  font-family: var(--font-display); color: var(--parchment);
}
.choice span small { font-family: var(--font-body); color: var(--ink-300); }
.choice input:checked + span { border-color: var(--gold); background: rgba(217, 164, 65, 0.12); box-shadow: 0 0 0 1px var(--gold) inset; }
.choice input:focus-visible + span { outline: 2px solid var(--gold); }
.pips { display: flex; gap: 4px; }
.pip { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--ink-600)); box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }

/* ---------- Badges ---------- */
.phase-badge, .badge {
  display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.65rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; border: 1px solid var(--ink-600); background: var(--ink-800); color: var(--ink-200);
  white-space: nowrap;
}
.phase-waiting-for-players { border-color: #6b7390; }
.phase-agent-connection { border-color: #7c5cc4; color: #cfc0f5; background: rgba(124, 92, 196, 0.14); }
.phase-deployment { border-color: var(--gold); color: var(--gold-bright); background: rgba(217, 164, 65, 0.12); }
.phase-battle { border-color: var(--blood-bright); color: #ffd0d6; background: rgba(200, 16, 46, 0.2); animation: pulse 1.6s infinite; }
.phase-finished { border-color: var(--moss); color: #cfe6c0; background: rgba(77, 107, 58, 0.2); }
.phase-cancelled { opacity: 0.6; }
.badge-ok { border-color: rgba(46, 158, 79, 0.6); color: #bfe8c9; background: rgba(46, 158, 79, 0.14); }
.badge-warn { border-color: rgba(217, 164, 65, 0.6); color: var(--gold-bright); background: rgba(217, 164, 65, 0.1); }
.badge-locked { border-color: var(--ink-400); color: var(--ink-300); }
.agent-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
.agent-status > .muted { white-space: nowrap; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.5); } 50% { box-shadow: 0 0 0 6px rgba(200, 16, 46, 0); } }

.swatch { display: inline-block; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px rgba(0,0,0,0.35), 0 0 12px color-mix(in srgb, var(--swatch) 60%, transparent); flex: none; }
.swatch-sm { width: 10px; height: 10px; }
.swatch-md { width: 14px; height: 14px; }
.swatch-lg { width: 22px; height: 22px; }

/* ---------- Landing ---------- */
.hero { position: relative; padding: clamp(3rem, 8vw, 6rem) 0 3rem; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 3rem; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.6rem); margin-bottom: 0.3em; }
.hero h1 em { font-style: normal; color: var(--gold-bright); }
.hero .lede { font-size: 1.25rem; color: var(--ink-200); max-width: 38ch; }
.hero-art { position: relative; aspect-ratio: 1; border-radius: 50%; background:
  radial-gradient(circle at 50% 50%, #4e6b37 0%, #3b5429 45%, #2b3d1f 70%, #1a2213 100%);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 0 60px rgba(0,0,0,0.5), 0 0 0 14px #3b2a18, 0 0 0 16px #5a4026;
}
.hero-art .army { position: absolute; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 6px; transform-origin: center; }
.hero-art .army i { width: 13px; height: 13px; border-radius: 50%; background: var(--c); box-shadow: 0 2px 0 rgba(0,0,0,0.5), 0 0 0 2px rgba(0,0,0,0.25); }
.hero-art .army.a0 { left: 38%; top: 74%; --c: var(--p0); }
.hero-art .army.a1 { left: 74%; top: 42%; --c: var(--p1); transform: rotate(90deg); }
.hero-art .army.a2 { left: 38%; top: 10%; --c: var(--p2); }
.hero-art .army.a3 { left: 4%; top: 42%; --c: var(--p3); transform: rotate(90deg); }
.hero-art .army { animation: march 6s ease-in-out infinite alternate; }
.hero-art .army.a1, .hero-art .army.a3 { animation-name: march-side; }
@keyframes march { to { translate: 0 calc(var(--d, 1) * 18px); } }
@keyframes march-side { to { translate: calc(var(--d, 1) * 18px) 0; } }
.hero-art .army.a0, .hero-art .army.a1 { --d: -1; }

.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1.25rem; margin: 2rem 0 3rem; }
.pillar { padding: 1.5rem; border-radius: var(--radius-lg); background: rgba(26, 29, 41, 0.7); border: 1px solid var(--ink-700); }
.pillar .num { font-family: var(--font-display); color: var(--gold); font-size: 2.2rem; line-height: 1; }
.pillar h3 { margin-top: 0.5rem; }

.unit-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 1rem; }
.unit-card { padding: 1.1rem; border-radius: var(--radius); background: rgba(239, 228, 201, 0.06); border: 1px solid rgba(239, 228, 201, 0.12); }
.unit-card .icon { color: var(--gold); width: 2rem; height: 2rem; }
.unit-card h4 { margin: 0.4rem 0 0.2rem; }
.unit-card .cost { font-family: var(--font-display); color: var(--gold-bright); }

/* ---------- Army builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .builder { grid-template-columns: 1fr; } }
.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 1rem; }
.roster-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem; border-radius: var(--radius); background: rgba(255, 255, 255, 0.35); border: 1px solid #cdb98f; }
.roster-card header { display: flex; align-items: center; gap: 0.6rem; }
.roster-card header .icon { width: 2rem; height: 2rem; color: var(--blood); }
.roster-card h3 { margin: 0; font-size: 1.05rem; }
.roster-card .cost { margin-left: auto; font-family: var(--font-display); font-weight: 700; color: var(--blood); white-space: nowrap; }
.roster-card p { font-size: 0.92rem; margin: 0; }
.stat-line { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; font-size: 0.78rem; text-align: center; }
.stat-line div { background: rgba(43, 33, 22, 0.08); border-radius: 6px; padding: 0.25rem 0.1rem; }
.stat-line b { display: block; font-size: 0.95rem; font-family: var(--font-display); }
.roster-card .btn { margin-top: auto; }

.muster { position: sticky; top: 84px; }
.points-meter { position: relative; height: 14px; border-radius: 999px; background: var(--ink-950); overflow: hidden; border: 1px solid var(--ink-600); }
.points-meter span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); transition: width 0.25s ease; }
.points-meter.over span { background: linear-gradient(90deg, #7a1020, var(--blood-bright)); }
.points-total { font-family: var(--font-display); font-size: 2.2rem; color: var(--parchment); line-height: 1; }
.points-total small { font-size: 1rem; color: var(--ink-300); }
.regiment-list { list-style: none; margin: 1rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.regiment-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.6rem; align-items: center; padding: 0.6rem 0.7rem; border-radius: var(--radius); background: var(--ink-900); border: 1px solid var(--ink-700); }
.regiment-row .icon { color: var(--gold); width: 1.5rem; height: 1.5rem; }
.regiment-row .name { font-weight: 700; color: var(--parchment); line-height: 1.2; }
.regiment-row .meta { font-size: 0.8rem; color: var(--ink-300); }
.regiment-row .cost { font-family: var(--font-display); color: var(--gold-bright); min-width: 3.2em; text-align: right; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--ink-600); border-radius: 8px; overflow: hidden; }
.stepper button { background: var(--ink-800); color: var(--parchment); border: 0; width: 28px; height: 30px; cursor: pointer; font-size: 1rem; }
.stepper button:hover { background: var(--ink-700); }
.stepper input { width: 42px; text-align: center; border: 0; border-radius: 0; padding: 0.3rem 0; background: var(--ink-950); -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.rule-list { list-style: none; padding: 0; margin: 0.5rem 0 1rem; font-size: 0.88rem; }
.rule-list li { display: flex; gap: 0.5rem; align-items: center; padding: 0.15rem 0; color: var(--ink-300); }
.rule-list li.ok { color: #bfe8c9; }
.rule-list li.bad { color: #f6a5b1; }

.army-card { display: flex; flex-direction: column; gap: 0.8rem; }
.army-card header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.army-card h3 { margin: 0; }
.army-composition { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-flex; gap: 0.35rem; align-items: center; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--ink-900); border: 1px solid var(--ink-700); font-size: 0.85rem; }
.chip .icon { color: var(--gold); }

/* ---------- Matches ---------- */
.match-card { display: flex; flex-direction: column; gap: 0.9rem; }
.match-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.match-card h3 { margin: 0; }
.seat-strip { display: flex; gap: 0.4rem; }
.seat-dot { flex: 1; height: 8px; border-radius: 999px; background: var(--ink-700); }
.seat-dot.filled { background: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent); }
.roll { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.92rem; }
.roll div { display: flex; align-items: center; gap: 0.5rem; }

.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 1rem; }
.slot {
  position: relative; border-radius: var(--radius-lg); padding: 1.2rem; min-height: 190px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 22%, var(--ink-800)), var(--ink-900) 70%);
  border: 1px solid color-mix(in srgb, var(--c) 55%, var(--ink-700));
  display: flex; flex-direction: column; gap: 0.6rem; overflow: hidden;
}
.slot::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 40%, transparent), transparent 70%); pointer-events: none; }
.slot.empty-slot { background: repeating-linear-gradient(135deg, var(--ink-900), var(--ink-900) 10px, var(--ink-800) 10px, var(--ink-800) 20px); border-style: dashed; border-color: var(--ink-600); align-items: center; justify-content: center; text-align: center; color: var(--ink-400); }
.slot .slot-head { display: flex; align-items: center; gap: 0.6rem; }
.slot .slot-name { font-family: var(--font-display); font-size: 1.15rem; color: var(--parchment); }
.slot .slot-meta { font-size: 0.85rem; color: var(--ink-300); }
.slot .slot-status { margin-top: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.slot.you { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
.you-tag { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-bright); font-family: var(--font-display); }

.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; margin: 1.5rem 0; }
.steps li { list-style: none; text-align: center; font-size: 0.78rem; color: var(--ink-400); position: relative; padding-top: 1.6rem; }
.steps li::before { content: ""; position: absolute; top: 0.45rem; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--ink-700); }
.steps li::after { content: ""; position: absolute; top: 0; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--ink-700); border: 2px solid var(--ink-900); }
.steps li.done, .steps li.current { color: var(--parchment); }
.steps li.done::before, .steps li.current::before { background: var(--gold-deep); }
.steps li.done::after { background: var(--gold); }
.steps li.current::after { background: var(--gold-bright); box-shadow: 0 0 12px var(--gold); }
@media (max-width: 640px) { .steps li { font-size: 0.64rem; } }

.invite-box { display: flex; gap: 0.5rem; align-items: stretch; }
.invite-box input { font-family: ui-monospace, Menlo, monospace; }
.code-display { font-family: ui-monospace, Menlo, monospace; font-size: clamp(1.2rem, 3.4vw, 1.9rem); letter-spacing: 0.08em; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--ink-950); border: 1px dashed var(--gold); color: var(--gold-bright); text-align: center; word-break: break-all; }
pre.prompt { white-space: pre-wrap; background: var(--ink-950); border: 1px solid var(--ink-700); padding: 1rem; border-radius: var(--radius); font-size: 0.86rem; color: var(--ink-200); max-height: 420px; overflow: auto; margin: 0; }
.copy-wrap { position: relative; }
.copy-wrap .btn { position: absolute; top: 0.5rem; right: 0.5rem; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.feed li { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0.5rem; border-radius: 6px; background: rgba(255,255,255,0.025); }
.feed .t { font-family: ui-monospace, Menlo, monospace; color: var(--ink-400); font-size: 0.78rem; min-width: 3.2em; }

/* ---------- Results ---------- */
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem; }
.podium-card { border-radius: var(--radius-lg); padding: 1.3rem; background: linear-gradient(160deg, color-mix(in srgb, var(--c) 25%, var(--ink-800)), var(--ink-900)); border: 1px solid color-mix(in srgb, var(--c) 60%, var(--ink-700)); }
.podium-card.winner { box-shadow: 0 0 0 2px var(--gold), 0 0 40px rgba(217, 164, 65, 0.3); }
.podium-card .place { font-family: var(--font-display); font-size: 2.6rem; color: var(--gold-bright); line-height: 1; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-300); padding: 0.5rem; border-bottom: 1px solid var(--ink-700); }
.table td { padding: 0.5rem; border-bottom: 1px solid var(--ink-800); }
.table-wrap { overflow-x: auto; }
.bar { height: 6px; border-radius: 999px; background: var(--ink-950); overflow: hidden; min-width: 60px; }
.bar span { display: block; height: 100%; background: var(--c, var(--gold)); }

/* Army builder: faction picker */
.faction-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; }
.faction-tab { --fc: #888; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.8rem; border-radius: 999px; border: 1px solid rgba(255,255,255,0.12); color: inherit; text-decoration: none; font-size: 0.9rem; }
.faction-tab:hover { border-color: var(--fc); }
.faction-tab.active { border-color: var(--fc); background: color-mix(in srgb, var(--fc) 25%, transparent); }
.faction-swatch { width: 0.75rem; height: 0.75rem; border-radius: 50%; background: var(--fc); }
.faction-blurb { margin: 0 0 1rem; max-width: 70ch; }

/* Results: top moments */
.highlights { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.highlights li { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.highlights .t { font-family: ui-monospace, Menlo, monospace; color: var(--ink-400); font-size: 0.8rem; }
.highlights strong { color: var(--gold); }

/* Live battles */
.live-list { display: grid; gap: 0.75rem; }
.live-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; color: inherit; text-decoration: none; }
.live-row:hover { border-color: var(--gold); }
.live-row h3 { margin: 0; }
.live-main { flex: 1; min-width: 0; display: grid; gap: 0.5rem; }
.live-armies { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.live-meta { text-align: right; display: grid; gap: 0.3rem; }
.live-watchers { font-size: 1.1rem; display: flex; align-items: center; gap: 0.35rem; justify-content: flex-end; }
@media (max-width: 640px) { .live-row { flex-direction: column; align-items: stretch; } .live-meta { text-align: left; } .live-watchers { justify-content: flex-start; } }

/* Rankings and profiles */
.stat-panel { display: grid; gap: 0.25rem; }
.big-number { font-family: var(--font-display); font-size: 2rem; color: var(--parchment, #f3e6c4); line-height: 1.1; }
.delta-up { color: #6fd08c; }
.delta-down { color: #ff8a7a; }

.leaderboard-filters { align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.leaderboard-filters .faction-picker { margin: 0; }

/* Tournaments */
.tournament-card { display: grid; gap: 0.3rem; color: inherit; text-decoration: none; }
.tournament-card:hover { border-color: var(--gold); }
.tournament-card h3 { margin: 0; }
.entry-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.entry-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.champion-banner { display: flex; align-items: center; gap: 0.6rem; font-size: 1.2rem; margin-bottom: 1.5rem; }
.bracket { display: grid; grid-template-columns: repeat(var(--rounds), minmax(220px, 1fr)); gap: 1rem; margin-top: 2rem; overflow-x: auto; padding-bottom: 0.5rem; }
.bracket-round { display: flex; flex-direction: column; justify-content: space-around; gap: 0.75rem; }
.bracket-round h3 { margin: 0 0 0.25rem; text-align: center; }
.bracket-game { padding: 0.5rem 0.6rem; display: grid; gap: 0.25rem; }
.bracket-game.decided { opacity: 0.92; }
.bracket-entry { display: flex; align-items: center; gap: 0.4rem; min-height: 1.8rem; }
.bracket-entry .seed { font-size: 0.7rem; color: var(--ink-400); min-width: 1.2rem; }
.bracket-entry.winner { color: var(--gold); font-weight: 600; }
.bracket-entry.loser { text-decoration: line-through; opacity: 0.6; }
.bracket-entry form.inline { margin-left: auto; }
.bracket-meta { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 0.3rem; }
.tournament-note { margin: 0 0 1rem; }

/* Faction catalogue */
.faction-card { --fc: #888; display: grid; gap: 0.5rem; color: inherit; text-decoration: none; border-top: 3px solid var(--fc); }
.faction-card:hover { border-color: var(--fc); }
.faction-card-head { display: flex; align-items: center; gap: 0.5rem; }
.faction-card h3 { margin: 0; }
.faction-icons { display: flex; flex-wrap: wrap; gap: 0.3rem; color: var(--gold); }
.faction-swatch.big { display: inline-block; width: 1rem; height: 1rem; vertical-align: middle; background: var(--fc); border-radius: 50%; }
.faction-roster { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.unit-detail { display: flex; flex-direction: column; gap: 0.5rem; }
.unit-detail header { display: flex; align-items: center; gap: 0.6rem; }
.unit-detail header .icon { width: 2rem; height: 2rem; color: var(--gold); }
.unit-detail h3 { margin: 0; font-size: 1.05rem; }
.unit-detail .cost { margin-left: auto; font-family: var(--font-display); color: var(--gold-bright); white-space: nowrap; }
.unit-detail p { margin: 0; }
.trait-list { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; color: var(--ink-300); }
.faction-mini { --fc: #888; display: block; color: inherit; text-decoration: none; border-top: 3px solid var(--fc); }
.faction-mini h4 { margin: 0.35rem 0 0.25rem; }
