/* ============================================================ tokens */
:root {
  color-scheme: dark;
  --bg: #07080c;
  --bg-2: #0b0e15;
  --card: #10141d;
  --card-2: #141a26;
  --card-3: #182031;
  --line: #1e2534;
  --line-2: #2a3346;
  --text: #e8ecf4;
  --muted: #8d99b0;
  --dim: #5b6579;
  --accent: #e06552;
  --accent-2: #ff8a75;
  --accent-soft: rgba(224, 101, 82, .14);
  --ok: #35c46a;
  --warn: #e0a23a;
  --bad: #ef5b5b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

body[data-game="40k"] { --accent: #e06552; --accent-2: #ff8a75; --accent-soft: rgba(224, 101, 82, .14); }
body[data-game="kt"] { --accent: #e0a23a; --accent-2: #f5c76a; --accent-soft: rgba(224, 162, 58, .14); }
body[data-game="sc"] { --accent: #35c46a; --accent-2: #6fe095; --accent-soft: rgba(53, 196, 106, .14); }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 560px at 12% -8%, rgba(30, 44, 78, .55) 0%, transparent 62%),
    radial-gradient(800px 460px at 92% 0%, rgba(70, 36, 64, .35) 0%, transparent 58%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { max-width: 1480px; margin: 0 auto; padding: 0 22px 40px; }

/* ============================================================ top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 0 20px;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex: none; }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center;
  font: 800 22px/1 var(--mono);
  color: #fff;
  background: linear-gradient(145deg, var(--accent), #7b2c25);
  box-shadow: 0 8px 24px var(--accent-soft), inset 0 1px 0 rgba(255, 255, 255, .22);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.08; }
.brand-text strong { font-size: 19px; letter-spacing: .16em; }
.brand-text small { font-size: 11.5px; color: var(--dim); letter-spacing: .04em; }

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .025);
  margin-left: auto;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.tab.active { color: var(--text); background: var(--card-2); border-color: var(--line-2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05); }

.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.dot-40k { background: #e06552; }
.dot-kt { background: #e0a23a; }
.dot-sc { background: #35c46a; }
.tab.active .tab-dot { box-shadow: 0 0 0 4px rgba(255, 255, 255, .07); }

.info-btn { flex: none; }

.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.icon-btn:hover { background: var(--card-3); color: var(--text); border-color: var(--line-2); }

/* ============================================================ game layout */
.game { display: none; }
.game.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.game-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin: 6px 0 24px;
}

.kicker {
  margin: 0 0 8px;
  font: 600 11.5px/1.2 var(--mono);
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.game-title h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.05;
  letter-spacing: -.035em;
  font-weight: 720;
}

.lead { margin: 0; max-width: 680px; color: var(--muted); font-size: 14.5px; }

.head-fields { display: flex; gap: 12px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font: 600 10.5px/1 var(--mono); letter-spacing: .11em; text-transform: uppercase; color: var(--dim); }

select, .select-btn {
  min-height: 42px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .16s ease, background .16s ease;
}
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%238d99b0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
select:hover, .select-btn:hover { border-color: var(--line-2); background-color: var(--card-2); }
select:focus-visible, .select-btn:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.select-btn { text-align: left; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  align-items: start;
}

/* ============================================================ catalog */
.catalog { min-width: 0; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 14px;
  background: linear-gradient(var(--bg) 68%, transparent);
  backdrop-filter: blur(6px);
}

.search {
  display: flex; align-items: center; gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  transition: border-color .16s ease;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--dim); stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 14.5px; }
.search input::placeholder { color: var(--dim); }
.search input:focus-visible { outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.chip .chip-n { color: var(--dim); font-family: var(--mono); font-size: 10.5px; margin-left: 3px; }

.catalog-note { margin: 0 0 12px; color: var(--dim); font-size: 12px; }
.catalog-note strong { color: var(--muted); font-weight: 600; }

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 12px;
  padding-bottom: 90px;
}

.unit-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 42%), var(--card);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.unit-card:hover { border-color: var(--line-2); background-color: var(--card-2); }
.unit-card.in-roster { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

.unit-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.unit-name { margin: 0; font-size: 15.5px; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
.unit-name button { border: 0; background: none; padding: 0; text-align: left; color: inherit; font: inherit; }
.unit-name button:hover { color: var(--accent-2); }

.points {
  flex: none;
  padding: 4px 8px;
  border-radius: 8px;
  font: 700 12.5px/1 var(--mono);
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  white-space: nowrap;
}
.points small { color: var(--muted); font-weight: 500; font-size: 10px; }

.unit-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; color: var(--dim); font-size: 11.5px; }
.unit-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--dim); }
.unit-role { color: var(--muted); }

.stat-line {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font: 600 11px/1.35 var(--mono);
  color: var(--muted);
}
.stat-line b { color: var(--text); font-weight: 700; }
.stat-line span { white-space: nowrap; }

.keywords { display: flex; flex-wrap: wrap; gap: 4px; }
.kw {
  padding: 3px 6px;
  border-radius: 5px;
  font: 500 10px/1.2 var(--mono);
  color: #9fabc1;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .045);
  white-space: nowrap;
}
.kw.more { color: var(--dim); background: none; border-color: transparent; }

.unit-actions { display: flex; gap: 7px; margin-top: auto; padding-top: 5px; }
.unit-actions select { flex: 1; min-height: 36px; font-size: 12px; padding: 0 28px 0 9px; border-radius: 9px; }
.unit-actions .add-btn { flex: none; }

.add-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease;
}
.add-btn:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); border-color: var(--accent); }
.add-btn:active { transform: translateY(1px); }

.empty-state {
  padding: 38px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  color: var(--dim);
  font-size: 13.5px;
  grid-column: 1 / -1;
}
.empty-state strong { display: block; color: var(--muted); font-size: 15px; margin-bottom: 6px; }

/* ============================================================ roster */
.roster {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent 34%), var(--card);
  box-shadow: var(--shadow);
  overflow: auto;
  overscroll-behavior: contain;
}

.roster-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
  background: var(--card);
}
.roster-head-main { flex: 1; min-width: 0; }
.roster-kicker { margin: 0 0 4px; font: 600 10px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; color: var(--dim); }
.roster-name {
  width: 100%;
  border: 0; border-bottom: 1px dashed transparent;
  background: transparent;
  padding: 1px 0 2px;
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  outline: none;
}
.roster-name:hover { border-bottom-color: var(--line-2); }
.roster-name:focus { border-bottom-color: var(--accent); }
.roster-close { display: none; flex: none; }

.roster-body { padding: 16px; }

.total-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.total-big { font: 800 32px/1 var(--mono); letter-spacing: -.04em; }
.total-big small { font-size: 14px; color: var(--dim); font-weight: 500; letter-spacing: 0; }
.total-label { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 5px; }
.total-side { text-align: right; color: var(--muted); font-size: 12px; }
.total-side b { display: block; font: 700 14px/1.2 var(--mono); color: var(--text); }

.progress { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s ease, background .2s ease; }
.progress.warn > i { background: var(--warn); }
.progress.bad > i { background: var(--bad); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.summary-cell { padding: 8px 9px; border-radius: 9px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .04); }
.summary-cell span { display: block; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
.summary-cell b { display: block; margin-top: 3px; font: 700 14px/1 var(--mono); }

.warn-list { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 2px; }
.warn {
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  border: 1px solid rgba(239, 91, 91, .25);
  background: rgba(239, 91, 91, .08);
  color: #f3a3a3;
}
.warn.soft { border-color: rgba(224, 162, 58, .25); background: rgba(224, 162, 58, .08); color: #ecc47e; }

.section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.section-head h3 { margin: 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.section-head .count { font: 600 10.5px/1 var(--mono); color: var(--dim); padding: 3px 6px; border-radius: 5px; background: rgba(255, 255, 255, .04); }
.section-head .grow { flex: 1; }
.section-action {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--muted);
  border-radius: 7px; padding: 4px 8px; font-size: 11px; font-weight: 600;
}
.section-action:hover { color: var(--text); border-color: var(--line-2); background: var(--card-3); }

.list { display: flex; flex-direction: column; gap: 6px; }
.list-empty { padding: 12px 10px; border: 1px dashed var(--line); border-radius: 9px; color: var(--dim); font-size: 12px; text-align: center; }

.list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .018);
}
.list-item:hover { border-color: var(--line-2); background: rgba(255, 255, 255, .03); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.list-sub { margin-top: 2px; font-size: 10.5px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px 8px; }
.list-sub .pts { color: var(--muted); font-family: var(--mono); }
.list-right { display: flex; align-items: center; gap: 6px; flex: none; }
.list-points { font: 700 12px/1 var(--mono); color: var(--text); min-width: 34px; text-align: right; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 26px; height: 27px; border: 0; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; }
.qty button:hover { background: var(--card-3); color: var(--text); }
.qty b { min-width: 24px; text-align: center; font: 700 12px/1 var(--mono); }

.mini-btn {
  width: 27px; height: 27px; flex: none;
  border: 1px solid var(--line); border-radius: 7px;
  background: transparent; color: var(--dim);
  font-size: 13px; line-height: 1;
}
.mini-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--card-3); }
.mini-btn.danger:hover { color: #f3a3a3; border-color: rgba(239, 91, 91, .4); background: rgba(239, 91, 91, .08); }

.enh { color: #c9b3ff; }
.dp { color: #7fc8ff; }

.field-inline { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; }
.field-inline label { flex: 1; font-size: 12px; color: var(--muted); }
.field-inline input {
  width: 74px; min-height: 34px; padding: 0 8px; text-align: center;
  border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); outline: none;
  font-family: var(--mono); font-size: 13px;
}
.field-inline input:focus { border-color: var(--accent); }

.roster-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 18px; }
.btn-row { display: flex; gap: 7px; }
.btn {
  min-height: 38px; padding: 0 13px;
  border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03); color: var(--text);
  font-size: 12.5px; font-weight: 600;
  transition: background .14s ease, border-color .14s ease;
}
.btn:hover { background: var(--card-3); border-color: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #140d0b; font-weight: 750; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: #f3a3a3; }
.btn.danger:hover { background: rgba(239, 91, 91, .08); border-color: rgba(239, 91, 91, .35); }
.btn-row .btn { flex: 1; }

.team-info { padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .018); }
.team-info h4 { margin: 0 0 3px; font-size: 13px; }
.team-info p { margin: 0; color: var(--muted); font-size: 11.5px; }
.team-info details { margin-top: 8px; }
.team-info summary { cursor: pointer; color: var(--dim); font-size: 11px; }
.team-info pre { white-space: pre-wrap; word-break: break-word; font: 11px/1.5 var(--sans); color: var(--muted); margin: 7px 0 0; max-height: 220px; overflow: auto; }

/* ============================================================ mobile bar */
.mobile-bar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 13, 20, .92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.mb-total { display: flex; flex-direction: column; line-height: 1.1; }
.mb-total span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.mb-total strong { font: 800 18px/1.2 var(--mono); }
.mobile-bar .primary { min-height: 42px; padding: 0 20px; }

.scrim { display: none; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px); }
body.roster-open .scrim { display: block; }

/* ============================================================ modal */
.modal {
  position: relative;
  width: min(760px, calc(100vw - 28px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65);
  overflow: hidden;
}
.modal::backdrop { background: rgba(4, 6, 10, .72); backdrop-filter: blur(4px); }
.modal-inner { padding: 24px; overflow: auto; max-height: min(86vh, 900px); }
.modal-close { position: absolute; top: 14px; right: 14px; z-index: 3; }

.modal h2 { margin: 0 0 4px; padding-right: 42px; font-size: 24px; letter-spacing: -.025em; }
.modal .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal h3 { margin: 20px 0 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.modal p { color: var(--muted); font-size: 13.5px; }
.modal p strong { color: var(--text); }

.picker-search { margin-bottom: 12px; }

.pick-list { display: flex; flex-direction: column; gap: 5px; }
.pick-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .018);
  transition: background .14s ease, border-color .14s ease;
}
.pick-row:hover { background: var(--card-2); border-color: var(--line-2); }
.pick-row .pick-main { flex: 1; min-width: 0; }
.pick-row .pick-title { font-size: 13.5px; font-weight: 600; }
.pick-row .pick-sub { margin-top: 2px; color: var(--dim); font-size: 11px; }
.pick-row .pick-val { flex: none; font: 700 12px/1 var(--mono); color: var(--muted); }
.pick-group { margin: 12px 0 5px; font: 600 10.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }

.stats-table { width: 100%; border-collapse: collapse; margin: 4px 0 2px; }
.stats-table th, .stats-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: center; font: 600 12px/1.2 var(--mono); }
.stats-table th { color: var(--dim); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.stats-table td:first-child, .stats-table th:first-child { text-align: left; color: var(--muted); }

.rule-box { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .018); margin-bottom: 7px; }
.rule-box h4 { margin: 0 0 4px; font-size: 13px; }
.rule-box p { margin: 0; font-size: 12.5px; white-space: pre-wrap; }

.export-box {
  width: 100%; min-height: 300px;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: 12px/1.55 var(--mono);
  resize: vertical;
  outline: none;
}
.export-box:focus { border-color: var(--accent); }

.disclaimer { font-size: 11.5px; color: var(--dim); line-height: 1.5; }

/* ============================================================ toast */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  z-index: 100;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: #171d29;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .5);
  transition: opacity .2s ease, transform .2s ease;
  max-width: min(92vw, 520px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(239, 91, 91, .4); color: #f3a3a3; }

/* ============================================================ footer */
.footer {
  display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: space-between;
  margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line);
  color: var(--dim); font-size: 11.5px;
}
.footer a { color: var(--muted); }

/* ============================================================ responsive */
@media (min-width: 1024px) {
  .roster { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 348px; }
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
}

@media (max-width: 1023px) {
  .app { padding: 0 16px 110px; }
  .topbar { padding: 16px 0 14px; flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .tab { flex: 1; justify-content: center; padding: 9px 8px; font-size: 12.5px; }
  .info-btn { margin-left: auto; }

  .game-head { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 18px; }
  .head-fields { flex-wrap: wrap; }
  .head-fields .field { flex: 1 1 160px; }
  .select-btn { max-width: none; width: 100%; }

  .workspace { display: block; }
  .catalog { display: block; }
  .unit-grid { padding-bottom: 24px; }

  .roster {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform: translateY(105%);
    transition: transform .24s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.roster-open .roster { transform: none; }
  .roster-close { display: inline-grid; }
  .roster-head { border-radius: 20px 20px 0 0; }
  .roster-body { padding-bottom: 26px; }
  .mobile-bar { display: flex; }
  .footer { display: none; }
}

@media (max-width: 560px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .brand-text small { display: none; }
  .brand-mark { width: 40px; height: 40px; }
  .game-title h1 { font-size: 28px; }
  .lead { font-size: 13.5px; }
  .unit-grid { grid-template-columns: 1fr; }
  .unit-card { padding: 13px; }
  .toolbar { padding-top: 8px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .modal { width: 100vw; max-height: 92vh; border-radius: 18px 18px 0 0; margin: auto 0 0; }
  .modal-inner { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; }
  .total-big { font-size: 28px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .tb-summary { grid-template-columns: repeat(3, 1fr); }
  .modal h2 { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
