/* FFTM design system. Dark is the spec's primary style (esports teams play at night, on phones).
   Red is the single accent: primary actions, the active nav item, urgent states. Everything else is neutral. */
@font-face { font-family: 'Bricolage'; font-weight: 600 800; font-display: swap; src: url('../font/bricolage-grotesque-600.woff2') format('woff2'); }
@font-face { font-family: 'Jakarta'; font-weight: 400 700; font-display: swap; src: url('../font/plus-jakarta-sans-400.woff2') format('woff2'); }

:root {
  --bg: #0a0a0c;
  --surface: #131317;
  --surface-2: #1b1b21;
  --surface-3: #24242c;
  --line: #2c2c35;
  --line-strong: #3d3d48;
  --text: #f3f3f5;
  --muted: #a3a3ae;
  --faint: #7c7c88;
  --red: #e5112b;          /* button fill, white text 4.9:1 */
  --red-hover: #ff2a42;
  --red-text: #ff5468;     /* red text on dark surfaces, 5.3:1 on --surface */
  --red-soft: #2a0d12;
  --ok: #38c97a; --ok-soft: #0f2a1c;
  --warn: #f2b33d; --warn-soft: #2d2311;
  --info: #7fb2ff; --info-soft: #132036;
  --r-sm: 6px; --r: 10px; --r-lg: 14px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --font: 'Jakarta', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Bricolage', 'Jakarta', system-ui, sans-serif;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* word-spacing: this Jakarta build has a very narrow space glyph (~0.14em); widen it so words do not run together */
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.55 var(--font); word-spacing: .1em; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, .figure, .bigbal, .price { word-spacing: normal; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 var(--s3); letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 5vw, 34px); }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 var(--s3); }
a { color: var(--text); text-decoration-color: var(--red-text); text-underline-offset: 3px; }
a:hover { color: #fff; }
img { max-width: 100%; display: block; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--red-text); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: 600 14px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-3); border-color: #50505c; color: var(--text); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { background: transparent; border-color: #5c1a24; color: var(--red-text); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { min-height: 36px; padding: 0 var(--s3); font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); min-width: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 13px; color: var(--text); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 13px; color: var(--red-text); }
.req::after { content: ' *'; color: var(--red-text); }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font: 400 15px/1.4 var(--font); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red-text); box-shadow: 0 0 0 3px rgba(229, 17, 43, .22); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--red-text); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--red); flex: none; margin: 0; }
.check { display: flex; gap: var(--s3); align-items: flex-start; font-size: 14px; cursor: pointer; margin-bottom: var(--s4); }
.check input { margin-top: 1px; }
input[type="file"] { padding: 8px; }
input::file-selector-button { background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px 10px; margin-right: 10px; font: 600 13px var(--font); cursor: pointer; }
.grid2 { display: grid; gap: 0 var(--s4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 .full { grid-column: 1 / -1; } }
.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; margin-top: var(--s2); }
.form-error { background: var(--red-soft); border: 1px solid #5c1a24; color: #ffd0d6; padding: var(--s3) var(--s4); border-radius: var(--r-sm); margin-bottom: var(--s4); font-size: 14px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); min-width: 0; }
.card + .card { margin-top: var(--s4); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.card-head h2, .card-head h3 { margin: 0; }
.card-head a { font-size: 13px; color: var(--muted); }
.stack > * + * { margin-top: var(--s4); }
.cols { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .cols.two { grid-template-columns: 1fr 1fr; } .cols.main-side { grid-template-columns: 1.6fr 1fr; } .cols.three { grid-template-columns: repeat(3, 1fr); } }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-top: 1px solid var(--line); min-width: 0; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.list .sub { font-size: 13px; color: var(--muted); }
a.rowlink { text-decoration: none; color: inherit; display: flex; gap: var(--s3); align-items: center; width: 100%; min-height: 44px; }
a.rowlink:hover .title { color: #fff; text-decoration: underline; text-decoration-color: var(--red-text); }

/* key numbers on the dashboard: one big figure, not a row of equal cards */
.figure { font: 700 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.figure-label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s4); }
.kv .v { font: 700 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.kv .k { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--red-soft); color: var(--red-text); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.solid { background: var(--red); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  table.t.stack-sm thead { display: none; }
  table.t.stack-sm tr { display: block; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  table.t.stack-sm td { display: flex; justify-content: space-between; gap: var(--s3); border: 0; padding: 3px 0; text-align: right; }
  table.t.stack-sm td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; text-align: left; }
  table.t.stack-sm td.n { text-align: right; }
}

/* ---------- avatars ---------- */
.av { width: 40px; height: 40px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font: 700 15px var(--display); color: var(--muted); flex: none; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.lg { width: 72px; height: 72px; font-size: 26px; border-radius: 12px; }
.av.sm { width: 30px; height: 30px; font-size: 12px; border-radius: 6px; }

/* ---------- states ---------- */
.empty { text-align: left; padding: var(--s5) var(--s4); border: 1px dashed var(--line-strong); border-radius: var(--r); color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: var(--s3); }
.loading { color: var(--muted); padding: var(--s5) 0; display: flex; gap: var(--s3); align-items: center; }
.loading::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--red-text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: var(--s3) var(--s4); border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 14px; margin-bottom: var(--s4); }
.notice.warn { border-color: #5a4515; background: var(--warn-soft); color: #ffe1a3; }
.notice.bad { border-color: #5c1a24; background: var(--red-soft); color: #ffd0d6; }
.notice.ok { border-color: #1c5236; background: var(--ok-soft); color: #c4f1d8; }

/* ---------- toast & modal ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--s2); width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 960px) { #toasts { bottom: var(--s5); } }
.toast { background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: var(--s3) var(--s4); box-shadow: var(--shadow-pop); font-size: 14px; animation: rise .18s ease-out; pointer-events: auto; }
.toast.bad { border-color: #7a2230; }
.toast.ok { border-color: #1f6b44; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--r-lg); padding: 0; width: min(94vw, 560px); max-height: 90vh; box-shadow: var(--shadow-pop); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s4) 0; }
dialog .dlg-head h2 { margin: 0; font-size: 19px; }
dialog .dlg-body { padding: var(--s4); overflow-y: auto; max-height: calc(90vh - 70px); }
@media (max-width: 639px) { dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; } }

/* ---------- tabs / segmented ---------- */
.tabs { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; overflow-x: auto; margin-bottom: var(--s4); }
.tabs button, .tabs a { flex: 1 0 auto; min-height: 38px; padding: 0 var(--s3); border: 0; border-radius: 4px; background: transparent; color: var(--muted); font: 600 13.5px var(--font); cursor: pointer; text-decoration: none; display: grid; place-items: center; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { background: var(--surface-3); color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-end; margin-bottom: var(--s4); }
.toolbar .field { margin: 0; flex: 1 1 150px; }
.toolbar .btn { flex: none; }

/* ---------- app shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); height: 58px; background: rgba(10, 10, 12, .96); border-bottom: 1px solid var(--line); }
.topbar .team-switch { display: flex; align-items: center; gap: var(--s2); min-width: 0; text-decoration: none; color: var(--text); font-weight: 700; min-height: 44px; }
.topbar .team-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r-sm); background: transparent; border: 0; color: var(--text); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .count { position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.logo { font: 800 19px/1 var(--display); letter-spacing: .02em; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; word-spacing: normal; }
.logo b { color: var(--red-text); }
.logo-mark { width: 26px; height: 26px; margin-right: 8px; }
.body { display: flex; flex: 1; min-height: 0; }
.sidenav { display: none; }
main.content { flex: 1; min-width: 0; padding: var(--s4) var(--s4) calc(96px + env(safe-area-inset-bottom)); max-width: 1180px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin: var(--s2) 0 var(--s4); }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 13px; color: var(--muted); text-decoration: none; display: inline-flex; min-height: 32px; align-items: center; }
.crumb:hover { color: var(--text); }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(19, 19, 23, .98); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 60px; color: var(--muted); text-decoration: none; font: 600 11px var(--font); background: none; border: 0; cursor: pointer; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar [aria-current="page"] { color: var(--text); }
.tabbar [aria-current="page"] svg { color: var(--red-text); }

.navlist { list-style: none; padding: 0; margin: 0; }
.navgroup { font-size: 11.5px; font-weight: 700; color: var(--faint); padding: var(--s4) var(--s3) 6px; letter-spacing: .04em; }
.navlist a { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3); min-height: 40px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px; }
.navlist a:hover { background: var(--surface-2); color: var(--text); }
.navlist a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--red); }
.navlist svg { width: 18px; height: 18px; flex: none; }
.navlist .pill { margin-left: auto; }
.sheet-nav { columns: 2; column-gap: var(--s3); }
.sheet-nav .navgroup { break-after: avoid; }
.sheet-nav li { break-inside: avoid; }

@media (min-width: 960px) {
  .tabbar { display: none; }
  .sidenav { display: block; width: 236px; flex: none; border-right: 1px solid var(--line); padding: var(--s2) var(--s3) var(--s6); position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto; }
  main.content { padding: var(--s5) var(--s6) var(--s7); }
}

/* ---------- auth / centered pages ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.auth { width: min(100%, 420px); }
.auth .logo { margin-bottom: var(--s5); }
.auth h1 { font-size: 26px; }
.auth .switch { margin-top: var(--s4); font-size: 14px; color: var(--muted); }

/* ---------- lineup board ---------- */
.lineup { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
@media (min-width: 640px) { .lineup { grid-template-columns: repeat(4, 1fr); } }
.slot { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3); text-align: center; min-height: 140px; display: flex; flex-direction: column; align-items: center; gap: var(--s2); justify-content: center; }
.slot .no { font: 700 12px var(--display); color: var(--red-text); }
.slot .ign { font-weight: 700; overflow-wrap: anywhere; }
.slot.empty-slot { border-style: dashed; color: var(--faint); }

/* ---------- charts ---------- */
.chart { width: 100%; max-width: 720px; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font); }
.chart .grid { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--red-text); stroke-width: 2.5; }
.chart .line.alt { stroke: #d9d9e0; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--red-text); }
.chart .bar { fill: #5a5a68; }
.chart .bar.hi { fill: var(--red); }
.legend { display: flex; gap: var(--s4); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--red-text); }
.legend i.alt { background: repeating-linear-gradient(90deg, #d9d9e0 0 4px, transparent 4px 8px); }
.meter { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--red); }

/* ---------- tactic board ---------- */
.board { position: relative; width: 100%; aspect-ratio: 1; background: #101014; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; touch-action: manipulation; user-select: none; }
.board .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.board .gridlines { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 12.5% 12.5%; opacity: .55; }
.board.has-image .gridlines { background-image: linear-gradient(rgba(255,255,255,.28) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px); opacity: 1; }
.board.has-image .mapname, .board.has-image .coord { color: #fff; text-shadow: 0 1px 2px #000; }
.board .coord { position: absolute; font-size: 10px; color: var(--faint); }
.board .mapname { position: absolute; left: 10px; top: 8px; font: 700 13px var(--display); color: var(--muted); }
.mk { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px; pointer-events: auto; }
.mk i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center; font: 700 11px var(--font); color: #fff; font-style: normal; }
.mk span { font-size: 11px; background: rgba(0, 0, 0, .75); padding: 1px 5px; border-radius: 3px; white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.mk.drop i { background: var(--red); } .mk.rotate i { background: #3b6fd8; } .mk.hold i { background: #2f9d62; }
.mk.danger i { background: #c98a12; } .mk.loot i { background: #7a5bd1; } .mk.note i { background: #555; }
.markers-key { display: flex; flex-wrap: wrap; gap: var(--s2); }
.markers-key button { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- misc ---------- */
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.divider { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3); border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 13.5px; cursor: pointer; color: var(--text); }
.chip[aria-pressed="true"] { border-color: var(--red); background: var(--red-soft); }
.code { font: 600 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; background: var(--surface-3); padding: 6px 10px; border-radius: var(--r-sm); }
.qr { width: 220px; max-width: 100%; border-radius: var(--r); background: #fff; padding: 8px; }
.money-in { color: var(--ok); } .money-out { color: var(--red-text); }
.bigbal { font: 800 clamp(34px, 8vw, 46px)/1 var(--display); font-variant-numeric: tabular-nums; }
.steps { list-style: none; padding: 0; margin: 0 0 var(--s4); display: grid; gap: var(--s2); }
.steps li { display: flex; gap: var(--s3); align-items: center; font-size: 14px; color: var(--muted); }
.steps li b { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; flex: none; }
.steps li.done { color: var(--text); } .steps li.done b { background: var(--ok-soft); border-color: #1f6b44; color: var(--ok); }
.steps li.now { color: var(--text); font-weight: 600; } .steps li.now b { background: var(--red); border-color: var(--red); color: #fff; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.menu-btn { display: grid; }
@media (min-width: 960px) { .menu-btn { display: none; } }
button, input, select, textarea { word-spacing: inherit; }
.card + .tabs { margin-top: var(--s4); }
