:root {
  color-scheme: dark;
  --bg: #12140e;
  --panel: #1c2116;
  --panel-2: #242b1c;
  --ink: #f3ead8;
  --muted: #b7ad96;
  --line: #3c4430;
  --green: #b5c86a;
  --green-dim: #2c3820;
  --danger: #e08b72;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", Candara, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a331c 0%, transparent 55%),
    radial-gradient(900px 400px at 90% 0%, #1a2214 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  padding: 1.5rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(28, 33, 22, 0.85) 0%, rgba(18, 20, 14, 0.35) 100%);
}

.hero[hidden],
.army-picker[hidden],
#builder[hidden] {
  display: none !important;
}

.logo {
  display: block;
  width: min(420px, 88vw);
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}

.tagline {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: clamp(0.68rem, 2.2vw, 0.82rem);
  line-height: 1.45;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.15rem, 3.5vw, 1.65rem);
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.discord {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid #5865f2;
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.discord:hover,
.discord:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

.discord-compact {
  margin-top: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  background: transparent;
  color: #c5cafe;
  border-color: #5865f2;
}

.discord-compact:hover,
.discord-compact:focus-visible {
  background: #5865f2;
  color: #fff;
  filter: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.army-picker {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

.army-picker h2 {
  margin: 0 0 0.35rem;
  text-align: center;
  font-size: 1.2rem;
}

.picker-hint {
  margin: 0 0 1.25rem;
  text-align: center;
  color: var(--muted);
}

.army-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.army-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem 0.95rem;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.army-card:hover,
.army-card:focus-visible {
  border-color: var(--green);
  background: var(--panel-2);
  transform: translateY(-2px);
  outline: none;
}

.army-card-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.army-card-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 20, 14, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

h2, p { margin: 0; }

.brand {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.change-army {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}

.change-army:hover,
.change-army:focus-visible {
  color: var(--ink);
  border-color: var(--green);
  outline: none;
}

.army-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.army-label > span {
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.brand select {
  max-width: 100%;
  min-width: 12rem;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.55rem;
}

.brand select:hover,
.brand select:focus { border-color: var(--green); }

h2 { font-size: 1.05rem; }

.points {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 700;
}

.points.over { color: var(--danger); }

.slash, .pts-label { color: var(--muted); font-weight: 500; }

.pts-label { font-size: 0.95rem; }

select, input[type="search"], input[type="number"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

.points select {
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.2rem 0.35rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(200px, 260px);
  gap: 1rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  align-items: start;
}

.catalogue,
.editor-panel,
.muster-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  box-shadow: var(--shadow);
}

.panel-label {
  margin: 0 0 0.55rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 650;
}

.muster-count {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.muster-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: min(70vh, 42rem);
  overflow: auto;
}

.muster-empty { padding: 0.85rem 0.25rem; }

.muster-row {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
}

.muster-select {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "role cost"
    "name name"
    "meta meta";
  gap: 0.1rem 0.5rem;
  padding: 0.55rem 0.65rem;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.muster-row.selected .muster-select {
  border-color: var(--green);
  background: var(--green-dim);
}

.muster-role {
  grid-area: role;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.muster-name { grid-area: name; font-size: 0.95rem; }

.muster-meta {
  grid-area: meta;
  color: var(--muted);
  font-size: 0.78rem;
}

.muster-cost {
  grid-area: cost;
  color: var(--green);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.muster-remove {
  flex: 0 0 auto;
  align-self: center;
}

.search input { width: 100%; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.chips button, .roster-actions button, .add, .icon-btn {
  border: 1px solid var(--line);
  background: var(--green-dim);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}

.chips button[aria-pressed="true"], .add {
  background: var(--green);
  color: #1a1d12;
  border-color: transparent;
  font-weight: 650;
}

.roster-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.roster-actions button {
  border-radius: 10px;
  background: var(--green);
  color: #1a1d12;
  font-weight: 650;
}

.ghost {
  background: transparent !important;
  color: var(--ink) !important;
}

#catalogue, #roster { list-style: none; padding: 0; margin: 0; }

.unit-row, .card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.unit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.unit-row p, .meta, .hint, .summary, .status { color: var(--muted); }

.unit-name { font-weight: 650; }

.card { padding: 0.85rem; margin-bottom: 0.7rem; }

.card-head, .model-row, .opt, .roster-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.card-head { align-items: flex-start; }

.cost { color: var(--green); font-variant-numeric: tabular-nums; font-weight: 700; }

.model-row, .group { margin-top: 0.75rem; }

.group { padding-top: 0.7rem; border-top: 1px solid var(--line); }

.prompt { font-size: 0.92rem; margin-bottom: 0.4rem; }

.opt { padding: 0.25rem 0; }

.opt select { max-width: 100%; }

.stepper { display: flex; align-items: center; gap: 0.35rem; }

.icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  padding: 0;
  background: #31382a;
}

.icon-btn:disabled { opacity: 0.35; cursor: default; }

input[type="number"] {
  width: 4.2rem;
  text-align: center;
}

.summary {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--line);
  font-size: 0.92rem;
  line-height: 1.45;
}

.summary div { color: var(--ink); }

.profile {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.profile th, .profile td {
  padding: 0.28rem 0.15rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.profile th[scope="row"] { text-align: left; font-weight: 650; }
.profile .changed { color: var(--green); font-weight: 750; }
.profile-note { color: var(--muted); font-size: 0.72rem; font-weight: 500; }

.opt, .group { position: relative; }
.opt-line { display: flex; align-items: center; gap: 0.4rem; }
.opt-line .check { flex: 1; }
.opt-line > span:first-child { flex: 1; }

.info {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 99px;
  padding: 0;
  font-size: 0.75rem;
  font-style: italic;
  background: #31382a;
}

.gear-note {
  display: none;
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0.15rem 0 0;
  padding: 0.45rem 0.6rem;
  background: #1c2218;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  font-size: 0.84rem;
  line-height: 1.4;
  white-space: pre-line;
  max-height: 8rem;
  overflow: auto;
  pointer-events: none;
}

.opt.open > .gear-note,
.opt:hover > .gear-note,
.opt:has(.info:hover) > .gear-note,
.group:hover > .gear-note,
.group:focus-within > .gear-note { display: block; }

.abilities { margin-top: 0.8rem; }
.abilities summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.abilities ul { margin: 0.45rem 0 0; padding-left: 1.1rem; }
.abilities li { margin: 0.45rem 0; }
.abilities p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.88rem; }
.abilities .tag { color: var(--muted); font-weight: 500; }

.empty {
  padding: 1.5rem 0.5rem;
  color: var(--muted);
}

.status { min-height: 1.2rem; margin: 0.4rem 0; }

.export-box {
  width: 100%;
  min-height: 12rem;
  margin-top: 0.5rem;
  background: #10140c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
}

.check { display: flex; align-items: center; gap: 0.5rem; }

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  }
  .muster-panel {
    grid-column: 1 / -1;
    max-height: none;
  }
  .muster-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-height: none;
  }
}

@media (max-width: 800px) {
  .hero { padding: 1.15rem 0.9rem 0.9rem; }
  .army-picker { padding: 1.1rem 0.9rem 2rem; }
  .army-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .layout { grid-template-columns: 1fr; padding: 0.7rem; }
  .topbar { padding: 0.75rem; flex-wrap: wrap; }
  .brand select { font-size: 1.05rem; min-width: 0; width: 100%; }
  .points { font-size: 1.35rem; }
  .unit-row, .card-head { align-items: flex-start; }
  .muster-panel { grid-column: auto; }
}
