:root {
  --bg: #0d0c0a;
  --panel: #181613;
  --panel-2: #211e1a;
  --line: #312c25;
  --line-2: #4a4237;
  --text: #ece5d6;
  --muted: #a39a88;
  --gold: #d6aa52;
  --gold-hi: #f1cf80;
  --gold-ink: #1d1607;
  --red: #d8664f;
  --green: #8fbb7f;
  --imperium: #d6aa52;
  --chaos: #d8664f;
  --xenos: #62b8a4;
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  /* Column layout so the footer sits at the bottom of short pages. */
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 90% 420px at 50% -120px, rgba(214, 170, 82, 0.13), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}

a { color: var(--gold-hi); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); letter-spacing: 0.01em; }
h2 { font-size: 1.25rem; margin-bottom: 0.35rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 0.875rem; }

/* ---------- Layout ---------- */

.site-header {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.wrap {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.site-footer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.loading { color: var(--muted); text-align: center; padding: 48px 0; }

.stack { display: flex; flex-direction: column; gap: 20px; }
.notice a { white-space: nowrap; }
.stack > :not(.reveal) { width: 100%; max-width: 720px; margin-inline: auto; }


.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card.center { align-items: center; padding: 40px 22px; }

@media (max-width: 520px) {
  .card { padding: 18px 16px; }
}

/* ---------- Event header & status ---------- */

.event-head { display: flex; flex-direction: column; gap: 8px; }
.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.event-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 0.9rem; }

.icon { display: inline-flex; width: 1.05em; height: 1.05em; flex: none; }
.icon svg { width: 100%; height: 100%; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-sealed { background: rgba(216, 102, 79, 0.14); color: #f0a08f; border: 1px solid rgba(216, 102, 79, 0.35); }
.badge-open { background: rgba(143, 187, 127, 0.14); color: #b4dca5; border: 1px solid rgba(143, 187, 127, 0.35); }

.progress-wrap { display: flex; flex-direction: column; gap: 8px; }
.progress-label { font-size: 0.95rem; color: var(--muted); }
.progress-label strong { color: var(--text); }
.progress { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #a87d2e, var(--gold-hi)); transition: width 0.4s ease; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field legend {
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0;
}
.field legend { margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.counter { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--red); font-weight: 600; }

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zooming on focus */
  color: var(--text);
  background: #100f0d;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .check-chip:has(input:focus-visible) {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
input::placeholder, textarea::placeholder { color: #6f675a; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select:invalid { color: #8c8372; }
optgroup { color: var(--gold); font-style: normal; }
option { color: var(--text); }
textarea { font-family: var(--mono); font-size: 14px; line-height: 1.5; resize: vertical; min-height: 220px; }
@media (max-width: 520px) { textarea { font-size: 16px; } }

.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  cursor: pointer;
}
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.check-chip span {
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #100f0d;
  font-size: 0.92rem;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.check-chip input:checked + span {
  background: rgba(214, 170, 82, 0.16);
  border-color: var(--gold);
  color: var(--gold-hi);
}
.check-chip input:checked + span::before { content: "✓ "; }

.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.toggle input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--gold); flex: none; }

.form-error { color: var(--red); font-weight: 500; }
.form-error:empty { display: none; }

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .btn { flex: none; padding-inline: 22px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; padding: 13px 16px; font-size: 1rem; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(216, 102, 79, 0.5); color: var(--red); }
.btn-danger:hover { background: rgba(216, 102, 79, 0.1); border-color: var(--red); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: var(--gold);
  color: var(--gold-ink);
}
.btn-primary:hover { background: linear-gradient(180deg, #f8dc98, #e0b75e); }
.card > .btn:not(.btn-block), .field > .btn { align-self: flex-start; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-row .btn-block { flex: 1; width: auto; }

.btn-icon {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.btn-icon:hover { color: var(--red); border-color: var(--line-2); }

.copy-field { display: flex; gap: 8px; }
.copy-input { flex: 1; min-width: 0; font-family: var(--mono) !important; font-size: 14px !important; color: var(--gold-hi) !important; }
@media (max-width: 520px) { .copy-input { font-size: 16px !important; } }

.notice {
  background: rgba(214, 170, 82, 0.08);
  border: 1px solid rgba(214, 170, 82, 0.3);
  border-radius: 8px;
  padding: 12px 14px;
}
.notice-warn { background: rgba(216, 102, 79, 0.09); border-color: rgba(216, 102, 79, 0.35); }

.host-key { display: flex; gap: 10px; color: var(--muted); font-size: 0.875rem; }
.host-key .icon { color: var(--gold); margin-top: 3px; }

/* ---------- Host player list ---------- */

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.player-row:first-child { padding-top: 0; }
.player-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-name { font-weight: 600; overflow-wrap: anywhere; }
.player-actions { display: flex; align-items: center; gap: 4px; flex: none; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.status-done { color: var(--green); }
.status-wait { color: var(--muted); }

/* ---------- Shared event link ---------- */

.stack-tight { display: flex; flex-direction: column; gap: 12px; }
.roster { display: flex; flex-wrap: wrap; gap: 6px; }
.roster-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 0.88rem;
}
.roster-chip.is-done { border-style: solid; border-color: rgba(143, 187, 127, 0.4); color: #b4dca5; }

/* ---------- Sealed confirmation ---------- */

.sealed-card { align-items: center; text-align: center; padding-top: 30px; }
.sealed-card > .btn:not(.btn-block) { align-self: center; }
.sealed-card .progress-wrap { width: 100%; max-width: 360px; }
.seal {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold-hi);
  background: radial-gradient(circle at 35% 30%, #b13a2a, #6f1d14 70%);
  box-shadow: 0 0 0 4px rgba(177, 58, 42, 0.25), 0 10px 30px rgba(0, 0, 0, 0.5);
}
.seal .icon { width: 34px; height: 34px; }
.personal-link { width: 100%; display: flex; flex-direction: column; gap: 8px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--line); text-align: left; }

/* ---------- Reveal ---------- */

.reveal { display: flex; flex-direction: column; gap: 14px; }
.reveal-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.reveal-head h2 { font-size: 1.5rem; margin: 0; }

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
  gap: 16px;
  align-items: start;
}

.list-card {
  --accent: var(--gold);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.faction-imperium { --accent: var(--imperium); }
.faction-chaos { --accent: var(--chaos); }
.faction-xenos { --accent: var(--xenos); }

.list-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.list-card-head h3 { font-size: 1.4rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; overflow-wrap: anywhere; }
.faction { color: var(--accent); font-weight: 600; margin-top: 2px; }
.you-tag {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(214, 170, 82, 0.16);
  color: var(--gold-hi);
}

.list-meta { margin: 0; display: grid; gap: 10px; }
.list-meta div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: baseline; }
.list-meta dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.list-meta dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .list-meta div { grid-template-columns: 1fr; gap: 2px; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: #100f0d;
}

.army-list {
  margin: 0;
  padding: 14px;
  background: #0b0a09;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 13px/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #ddd5c4;
}

/* ---------- Home ---------- */

.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.link-list li:last-child { border-bottom: 0; }
.row-end { display: flex; align-items: center; gap: 4px; flex: none; }
.link-list a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.link-list a:hover { text-decoration: underline; }
