/* ==========================================================================
   Pinsheet — interface

   Design notes worth keeping in mind before editing:

   - No web fonts. Zero external requests is the product's offline guarantee,
     so the type is a tuned system stack. Numerals are monospace everywhere,
     because in this app the numbers are the content.
   - Density is a first-class control, not a preference buried in settings.
     Comfortable honours a 44px touch target; Compact drops to the density a
     daily user wants. Everything sizes off --row / --tap / --fs.
   - Light palette lives on bare :root. Dark redefines tokens only, once under
     prefers-color-scheme (guarded so an explicit light choice wins) and again
     under [data-theme="dark"]. Never declare a colour only inside one of those
     blocks — it will be missing in the un-stamped default state.
   ========================================================================== */

:root {
  /* --- surfaces --------------------------------------------------------- */
  --ground:     #fbfaf9;
  --surface:    #ffffff;
  --raised:     #f5f4f2;
  --sunken:     #f0eeec;
  --line:       #e7e4e1;
  --line-soft:  #f1efed;

  /* --- ink -------------------------------------------------------------- */
  --ink:        #17191c;
  --ink-2:      #52565c;
  --ink-3:      #83888e;

  /* --- accent and semantics --------------------------------------------- */
  --accent:     #cf4526;
  --accent-ink: #ffffff;
  --accent-wk:  #fdeee9;
  --good:       #157f4a;
  --good-wk:    #e8f4ed;
  --warn:       #8f5f0a;
  --warn-wk:    #fbf1dc;
  --bad:        #b02a1f;
  --bad-wk:     #fbe9e7;
  --live:       #2563c9;
  --live-wk:    #e9f0fd;
  --focus:      #2563c9;

  --shadow-sm:  0 1px 2px rgba(20, 18, 16, .05);
  --shadow:     0 4px 14px rgba(20, 18, 16, .08), 0 1px 3px rgba(20, 18, 16, .05);
  --shadow-lg:  0 24px 60px rgba(20, 18, 16, .22);

  --r:    7px;
  --r-lg: 11px;

  --ui:   "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
          system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, SFMono-Regular, "SF Mono",
          Menlo, "Liberation Mono", monospace;

  /* --- density: Comfortable (default) ----------------------------------- */
  --row:    46px;
  --tap:    44px;
  --cell-w: 62px;
  --fs:     15px;
  --fs-num: 15.5px;
  --pad:    22px;
  --gap:    14px;

  --rail:   238px;
  --top-h:  54px;
}

:root[data-density="compact"] {
  --row: 32px; --tap: 30px; --cell-w: 52px;
  --fs: 13.5px; --fs-num: 13.5px; --pad: 15px; --gap: 11px;
  --top-h: 48px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:     #0b0c0e;
    --surface:    #141618;
    --raised:     #1a1d20;
    --sunken:     #101214;
    --line:       #24282c;
    --line-soft:  #1a1e21;
    --ink:        #edeef0;
    --ink-2:      #a6abb2;
    --ink-3:      #757b82;
    --accent:     #ff7a55;
    --accent-ink: #1c0a04;
    --accent-wk:  #2a1410;
    --good:       #45d67f;
    --good-wk:    #0f2419;
    --warn:       #f0b429;
    --warn-wk:    #2a2110;
    --bad:        #ff6b6b;
    --bad-wk:     #2b1414;
    --live:       #6ea8ff;
    --live-wk:    #101c2e;
    --focus:      #6ea8ff;
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, .5);
    --shadow:     0 6px 22px rgba(0, 0, 0, .45);
    --shadow-lg:  0 28px 64px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  --ground:     #0b0c0e;
  --surface:    #141618;
  --raised:     #1a1d20;
  --sunken:     #101214;
  --line:       #24282c;
  --line-soft:  #1a1e21;
  --ink:        #edeef0;
  --ink-2:      #a6abb2;
  --ink-3:      #757b82;
  --accent:     #ff7a55;
  --accent-ink: #1c0a04;
  --accent-wk:  #2a1410;
  --good:       #45d67f;
  --good-wk:    #0f2419;
  --warn:       #f0b429;
  --warn-wk:    #2a2110;
  --bad:        #ff6b6b;
  --bad-wk:     #2b1414;
  --live:       #6ea8ff;
  --live-wk:    #101c2e;
  --focus:      #6ea8ff;
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, .5);
  --shadow:     0 6px 22px rgba(0, 0, 0, .45);
  --shadow-lg:  0 28px 64px rgba(0, 0, 0, .6);
}

/* -------------------------------------------------------------------- base */

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0 0 .3em; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
h4 { font-size: .85rem; }
p { margin: 0 0 .7em; }
a { color: var(--live); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-3); }
.small { font-size: .84rem; }
.strong { font-weight: 650; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad  { color: var(--bad); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mt { margin-top: .8rem; }
.spacer { flex: 1 1 auto; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 5px; }

/* -------------------------------------------------------------------- boot */

.boot {
  position: fixed; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: .5rem; background: var(--ground); color: var(--ink-3); text-align: center;
}
.boot-mark { font-size: 1.4rem; font-weight: 700; letter-spacing: -.025em; color: var(--ink); }
.boot-error { max-width: 40rem; padding: 2rem; text-align: left; }
.boot-error pre { white-space: pre-wrap; font-size: .78rem; color: var(--bad); }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--top-h);
  display: flex; align-items: center; gap: .6rem;
  padding: 0 var(--pad);
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-weight: 700; letter-spacing: -.025em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 50%; position: relative; flex: none;
  background: radial-gradient(circle at 34% 28%, #fff 0 14%, var(--accent) 15% 100%);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 62% 34%, rgba(0,0,0,.6) 0 1.4px, transparent 1.5px),
    radial-gradient(circle at 73% 53%, rgba(0,0,0,.6) 0 1.4px, transparent 1.5px),
    radial-gradient(circle at 58% 59%, rgba(0,0,0,.6) 0 1.4px, transparent 1.5px);
}
.brand-text { font-size: .98rem; }

#event-switch {
  max-width: 20rem; min-width: 8rem;
  padding: .3rem .5rem; min-height: calc(var(--tap) - 10px);
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: .86rem; font-weight: 550;
}

/* the command launcher — label adapts to the platform in app.js */
.cmd-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: calc(var(--tap) - 10px);
  padding: .3rem .6rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink-3);
  font: inherit; font-size: .82rem; cursor: pointer;
}
.cmd-btn:hover { color: var(--ink); border-color: var(--ink-3); }

kbd {
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: .05rem .3rem; background: var(--raised); color: var(--ink-2);
  white-space: nowrap;
}

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .18rem .5rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: .73rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-online  { color: var(--good); background: var(--good-wk); border-color: transparent; }
.pill-offline { color: var(--warn); background: var(--warn-wk); border-color: transparent; }
.pill-save { color: var(--ink-3); }
.pill-good { color: var(--good); }
.pill-bad  { color: var(--bad); background: var(--bad-wk); border-color: transparent; }

.menu-toggle { display: none; }

/* ------------------------------------------------------------------ layout */

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--top-h)); }

.sidenav {
  position: sticky; top: var(--top-h);
  width: var(--rail); flex: 0 0 var(--rail);
  height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: .6rem .55rem 1rem;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.sidenav a {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); padding: .4rem .55rem;
  border-radius: var(--r);
  color: var(--ink-2); font-size: .88rem; font-weight: 550;
}
.sidenav a:hover { background: var(--raised); color: var(--ink); text-decoration: none; }
.sidenav a.is-active { background: var(--accent-wk); color: var(--accent); font-weight: 650; }
.sidenav .ico { width: 1.05rem; text-align: center; font-size: .92rem; opacity: .85; flex: none; }

.nav-group {
  margin: .7rem .55rem .2rem;
  font-size: .66rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
}
.nav-badge {
  margin-left: auto; min-width: 1.2rem; padding: 0 .32rem;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--mono); font-size: .68rem; font-weight: 700;
  text-align: center; line-height: 1.2rem;
}
.nav-foot { margin-top: auto; padding: .7rem .55rem 0; border-top: 1px solid var(--line-soft); }
.nav-foot p { font-size: .72rem; color: var(--ink-3); margin: 0; line-height: 1.45; }

.view { flex: 1 1 auto; min-width: 0; padding: var(--pad) var(--pad) 4rem; max-width: 1560px; }
.view:focus { outline: none; }

/* --------------------------------------------------------------- page head */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: var(--gap);
}
.page-head p { margin: 0; color: var(--ink-3); font-size: .87rem; }
.page-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.section-title { margin: 1.4rem 0 .6rem; font-size: .9rem; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1rem 1.05rem;
  margin-bottom: var(--gap);
}
.card > h3 { margin-bottom: .55rem; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.card-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.card-grid.two { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }
.card-grid.three { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.card-grid .card { margin-bottom: 0; }
.card:has(> table.table), .card:has(> .table) { overflow-x: auto; }

.welcome { max-width: 46rem; }
.welcome h2 { font-size: 1.25rem; }

.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: .45rem; }
.row.wrap { flex-wrap: wrap; }

/* ------------------------------------------------------------------- stats */

.stat-row {
  display: grid; gap: var(--gap); margin-bottom: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: .8rem .9rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.stat-label { font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.stat-value { font-family: var(--mono); font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .76rem; color: var(--ink-3); }

.squad-card .bar { height: 5px; border-radius: 999px; background: var(--sunken); overflow: hidden; margin: .45rem 0 .55rem; }
.squad-card .bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.mini-list { margin: .25rem 0 0; padding-left: 1.05rem; font-size: .82rem; color: var(--ink-2); }
.mini-list li { margin-bottom: .1rem; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .4rem .8rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: .86rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--raised); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--raised); }
.btn.small { min-height: calc(var(--tap) - 10px); padding: .25rem .55rem; font-size: .79rem; }
.btn.danger, .btn.ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.btn.danger:hover { background: var(--bad-wk); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: calc(var(--tap) - 10px); min-height: calc(var(--tap) - 10px);
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  font-size: 1rem; line-height: 1; border-radius: var(--r); cursor: pointer;
}
.icon-btn:hover { background: var(--raised); color: var(--ink); }

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-block; padding: .08rem .42rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  background: var(--raised); color: var(--ink-2); white-space: nowrap;
}
.badge-good  { background: var(--good-wk); color: var(--good); }
.badge-bad   { background: var(--bad-wk);  color: var(--bad); }
.badge-warn  { background: var(--warn-wk); color: var(--warn); }
.badge-live  { background: var(--live-wk); color: var(--live); }
.badge-muted { background: transparent; color: var(--ink-3); }

/* ----------------------------------------------------------------- notices */

.notice {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .7rem .9rem; margin-bottom: var(--gap);
  background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--live);
  border-radius: var(--r-lg);
  color: var(--ink-2); font-size: .88rem;
}
.notice.good { background: var(--good-wk); border-left-color: var(--good); color: var(--ink); }
.notice.warn { background: var(--warn-wk); border-left-color: var(--warn); color: var(--ink); }
.notice.bad  { background: var(--bad-wk);  border-left-color: var(--bad);  color: var(--ink); }

.blockers { margin: 0; padding-left: 1.1rem; color: var(--warn); }
.blockers li { margin-bottom: .2rem; }

/* ------------------------------------------------------------------ tables */

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  text-align: left; font-size: .68rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
  padding: .5rem .55rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td {
  padding: .45rem .55rem; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle; height: var(--row);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--raised); }
.table .pos { font-family: var(--mono); font-weight: 600; color: var(--ink-3); width: 3rem; }
.table .row-top .pos { color: var(--accent); }
.table .row-inactive { opacity: .55; }
.table .pending { color: var(--ink-3); }
.table.audit code { font-family: var(--mono); font-size: .78rem; color: var(--live); }
.row-error { background: var(--bad-wk); }
.row-warn  { background: var(--warn-wk); }

.scroll-x { overflow-x: auto; }
.scroll-y { max-height: 52vh; overflow-y: auto; }

.toolbar { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; padding: .55rem .65rem; }
.toolbar select, .toolbar input {
  min-height: calc(var(--tap) - 10px);
  padding: .3rem .45rem; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem;
}
.toolbar .search { flex: 1 1 16rem; min-width: 10rem; }

/* -------------------------------------------------------------- score grid */

.score-grid th.game-col { text-align: center; min-width: var(--cell-w); }
.score-grid th.published { color: var(--ink-2); }
.score-grid th .lock { font-size: .62em; margin-left: .15rem; opacity: .7; }
.score-grid td.game-col { padding: 0 .2rem; text-align: center; }
.score-grid .sticky-l {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface); border-right: 1px solid var(--line); min-width: 12rem;
}
.score-grid tbody tr:hover .sticky-l { background: var(--raised); }

.score-input {
  width: calc(var(--cell-w) - 8px); height: var(--tap);
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--sunken); color: var(--ink);
  font-family: var(--mono); font-size: var(--fs-num); font-weight: 600;
  font-variant-numeric: tabular-nums; text-align: center;
  -moz-appearance: textfield;
}
.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.score-input:hover { border-color: var(--ink-3); }
.score-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; background: var(--surface); }
/* a published game reads as inked onto a paper scoresheet */
.score-input.is-locked { background: transparent; border-color: transparent; color: var(--ink-2); }
.score-input.is-locked:hover { border-color: var(--line); }
.score-input.is-revised { box-shadow: inset 0 -2px 0 var(--warn); }
.score-input[disabled] { opacity: .45; }

.lane-input {
  width: 3rem; height: calc(var(--tap) - 8px);
  text-align: center; border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--ink-2);
  font-family: var(--mono); font-size: .84rem;
}
.lane-input:hover, .lane-input:focus { border-color: var(--line); background: var(--sunken); }

/* games-complete pips: status by shape as well as colour */
.pips { display: flex; gap: 3px; margin-top: 3px; }
.pip { width: 14px; height: 3px; border-radius: 2px; background: var(--line); }
.pip.on  { background: var(--good); }
.pip.now { background: var(--warn); }

/* ------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: var(--gap); }
.tab {
  display: inline-flex; align-items: center;
  min-height: calc(var(--tap) - 8px); padding: .3rem .75rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font-size: .84rem; font-weight: 600;
}
.tab:hover { background: var(--raised); text-decoration: none; }
.tab.is-active { background: var(--ink); border-color: var(--ink); color: var(--ground); }

.segmented { display: inline-flex; background: var(--raised); border-radius: var(--r); padding: 2px; gap: 2px; }
.seg {
  display: inline-flex; align-items: center;
  min-height: calc(var(--tap) - 12px); padding: .25rem .7rem;
  border: 0; border-radius: 5px; background: transparent; color: var(--ink-2);
  font: inherit; font-size: .81rem; font-weight: 600; cursor: pointer;
}
.seg:hover { text-decoration: none; color: var(--ink); }
.seg.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* -------------------------------------------------------------- definitions */

.defs { margin: 0; display: grid; gap: 0; }
.def { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--line-soft); }
.def:last-child { border-bottom: none; }
.def dt { color: var(--ink-3); font-size: .82rem; }
.def dd { margin: 0; font-size: .85rem; font-weight: 600; text-align: right; }

/* ---------------------------------------------------------------- brackets */

.bracket-board { display: flex; gap: 1rem; align-items: stretch; padding-bottom: .4rem; }
.bracket-board > h4 { flex: 0 0 100%; }
.round { min-width: 15rem; display: flex; flex-direction: column; gap: .5rem; justify-content: space-around; }
.round > h4 { color: var(--ink-3); font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; margin-bottom: .1rem; }

.match { border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); overflow: hidden; }
.match.is-resolved { background: var(--surface); }
.slot {
  display: grid; grid-template-columns: 1.5rem 1fr 2.6rem;
  align-items: center; gap: .4rem; padding: .35rem .5rem; font-size: .85rem;
  min-height: calc(var(--tap) - 10px);
}
.slot + .slot { border-top: 1px solid var(--line-soft); }
.slot .seed { font-family: var(--mono); color: var(--ink-3); font-size: .72rem; font-weight: 700; text-align: center; }
.slot .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .sc { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.slot.is-winner { background: var(--good-wk); }
.slot.is-winner .nm { font-weight: 700; }
.slot.is-out { opacity: .5; }
.slot.empty { opacity: .5; }
.match-note { padding: .15rem .5rem .3rem; }

/* ------------------------------------------------------------------- empty */

.empty {
  border: 1px dashed var(--line); border-radius: var(--r-lg);
  padding: 2rem 1.5rem; text-align: center; color: var(--ink-3);
  background: var(--surface);
}
.empty h3 { color: var(--ink); }

/* ------------------------------------------------------------------- forms */

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: .7rem; }
.field { display: flex; flex-direction: column; gap: .2rem; grid-column: span 12; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
.form-section {
  grid-column: span 12; margin: .3rem 0 -.2rem; padding-top: .6rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); border-top: 1px solid var(--line-soft);
}
.label { font-size: .78rem; font-weight: 650; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: .4rem .55rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sunken); color: var(--ink);
  font: inherit; font-size: .9rem;
}
.field textarea { min-height: 4.5rem; }
.field input:focus, .field select:focus, .field textarea:focus { background: var(--surface); border-color: var(--focus); }
.hint { font-size: .76rem; color: var(--ink-3); }

.check {
  display: flex; align-items: center; gap: .45rem;
  min-height: var(--tap); font-size: .87rem; cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.checklist { display: flex; flex-direction: column; gap: 0; }
.checklist.wide { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 .8rem; }

.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  text-align: left; min-height: var(--tap); padding: .45rem .6rem;
  border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--ink);
  font: inherit; font-size: .88rem; cursor: pointer;
}
.menu-item:hover { background: var(--raised); }
.menu-item.danger { color: var(--bad); }

.code {
  font-family: var(--mono); font-size: .76rem;
  background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r);
  padding: .55rem .65rem; white-space: pre-wrap; word-break: break-all; margin: 0 0 .55rem;
}

/* ------------------------------------------------------------------ modals */

#modal-host { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.modal {
  position: relative; margin: 4vh auto; max-width: 34rem; width: calc(100% - 2rem);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: var(--shadow-lg);
  max-height: 92vh; display: flex; flex-direction: column;
}
.modal-wide { max-width: 56rem; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.05rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1rem; }
.modal-body { padding: 1rem 1.05rem; overflow-y: auto; }
.modal-body .intro { margin-top: -.15rem; margin-bottom: .85rem; font-size: .86rem; color: var(--ink-2); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: .45rem;
  padding-top: .9rem; margin-top: .5rem; border-top: 1px solid var(--line-soft);
  position: sticky; bottom: -1rem; background: var(--surface);
}

/* -------------------------------------------------------- command palette */

#palette-host { position: fixed; inset: 0; z-index: 110; }
.pal-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 12, .42); backdrop-filter: blur(3px); }
.pal {
  position: relative; margin: 12vh auto 0; width: min(580px, calc(100% - 2rem));
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 13px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.pal input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--ink);
  font: inherit; font-size: 1rem; padding: .9rem 1.05rem;
}
.pal input:focus { outline: none; }
.pal ul { list-style: none; margin: 0; padding: .35rem; max-height: 46vh; overflow-y: auto; }
.pal li {
  display: flex; align-items: center; gap: .65rem;
  min-height: var(--tap); padding: .45rem .65rem;
  border-radius: var(--r); cursor: pointer; font-size: .89rem;
}
.pal li[aria-selected="true"] { background: var(--accent-wk); color: var(--accent); }
.pal li .ico { width: 1.05rem; text-align: center; opacity: .8; flex: none; }
.pal li .grp-tag { margin-left: auto; font-size: .72rem; color: var(--ink-3); }
.pal li[aria-selected="true"] .grp-tag { color: var(--accent); }
.pal-empty { padding: 1.2rem; text-align: center; color: var(--ink-3); font-size: .88rem; }
.pal-foot {
  display: flex; gap: 1rem; padding: .5rem .9rem;
  border-top: 1px solid var(--line); font-size: .72rem; color: var(--ink-3);
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed; z-index: 120; bottom: 1rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--ground);
  border-radius: 9px; box-shadow: var(--shadow);
  padding: .55rem .9rem; font-size: .86rem; font-weight: 550; max-width: 26rem;
  animation: toast-in .16s ease-out;
}
.toast-success { background: var(--good); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- public page */

.public-page { background: var(--ground); }
.public-view { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.public-head { margin-bottom: var(--gap); }
.public-head h2 { font-size: 1.35rem; }
.public-head p { margin: 0 0 .2rem; color: var(--ink-3); }
.pub-stamp {
  display: inline-block; margin-top: .4rem !important;
  padding: .2rem .6rem; border-radius: 999px;
  background: var(--accent-wk); color: var(--accent);
  font-size: .78rem; font-weight: 650;
}
.public-foot {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.5rem; padding-top: .8rem; border-top: 1px solid var(--line);
  font-size: .76rem; color: var(--ink-3);
}
.squad-tabs { margin-top: 1rem; }

/* ------------------------------------------------ registration (bowler side) */

.lobby-card h3 { margin-bottom: .1rem; }
.lobby-card .btn { margin-top: .6rem; width: 100%; }

.fee-summary { margin-top: 1rem; padding: .7rem .85rem; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); }
.fee-line { display: flex; justify-content: space-between; gap: 1rem; padding: .16rem 0; font-size: .88rem; }
.fee-line span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.fee-line.total { margin-top: .3rem; padding-top: .4rem; border-top: 1px solid var(--line); font-weight: 700; font-size: 1rem; }

.confirm-card { text-align: center; max-width: 34rem; margin-inline: auto; }
.confirm-mark {
  width: 52px; height: 52px; margin: .2rem auto .7rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--good-wk); color: var(--good);
  font-size: 1.6rem; font-weight: 700;
}
.confirm-card .defs { text-align: left; margin-top: 1rem; }
.confirm-card .def.total dd { color: var(--accent); font-size: 1.05rem; }
.ref-code {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700; letter-spacing: .06em;
  color: var(--accent); background: var(--accent-wk);
  border-radius: var(--r); padding: .5rem; margin: .8rem 0;
}

.inbox { border-left: 3px solid var(--accent); }
.inbox h3 { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.inbox-empty { border-left: 3px solid var(--line); }

/* -------------------------------------------------------------- share sign */

.share-sign { background: #fff; color: #111; border-radius: var(--r-lg); border: 1px solid var(--line); padding: 1.5rem 1.2rem; text-align: center; }
.sign-kicker { margin: 0 0 .2rem; font-size: .75rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: #cf4526; }
.sign-title { margin: 0 0 .25rem; font-size: 1.5rem; color: #111; }
.sign-sub { margin: 0 0 1rem; font-size: .85rem; color: #555; }
.sign-qr { display: flex; justify-content: center; }
.sign-qr svg { max-width: 260px; height: auto; }
.sign-url { margin: .8rem 0 .2rem; font-family: var(--mono); font-size: .82rem; color: #333; word-break: break-all; }
.sign-foot { margin: 0; font-size: .82rem; color: #555; }

/* ---------------------------------------------------------------- leagues */

.week-card { padding: .75rem .85rem; }
.week-card h4 { margin: 0; }
.week-card.is-final { border-left: 3px solid var(--good); }
.table.compact td { padding: .22rem .4rem; font-size: .82rem; border-bottom: none; height: auto; }

.match-card { padding: .85rem .95rem; }
.match-card > .row { margin-bottom: .45rem; }
.team-sheet + .team-sheet { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.team-sheet h4 { margin-bottom: .35rem; color: var(--ink-2); }

.kind-select {
  min-height: calc(var(--tap) - 10px); padding: .2rem .3rem; max-width: 8rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--sunken); color: var(--ink-2); font: inherit; font-size: .78rem;
}
tr.team-total td { border-top: 2px solid var(--line); background: var(--sunken); font-size: .85rem; }
.week-nav { align-items: center; gap: .8rem; margin-bottom: .85rem; }

/* ------------------------------------------------------- results packet */

.print-packet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.5rem 1.6rem; }
.pp-head { border-bottom: 2px solid var(--ink); padding-bottom: .7rem; margin-bottom: 1.2rem; }
.pp-h1 { margin: 0 0 .15rem; font-size: 1.5rem; letter-spacing: -.025em; }
.pp-sub { margin: 0; color: var(--ink-3); font-size: .88rem; }
.pp-stamp { margin: .45rem 0 0; font-size: .8rem; font-weight: 650; color: var(--accent); }
.pp-section { margin-bottom: 1.6rem; }
.pp-h2 { font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .5rem; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.pp-h3 { font-size: .95rem; margin: 1rem 0 .35rem; }
.pp-note { font-size: .78rem; color: var(--ink-3); margin: 0 0 .5rem; }
.pp-winner { font-size: .9rem; margin: 0 0 .5rem; }
.pp-pay { font-size: .82rem; color: var(--ink-2); margin: .35rem 0 .8rem; }
.pp-table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-bottom: .6rem; }
.pp-table th { text-align: left; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--ink); padding: .3rem .4rem; }
.pp-table td { padding: .26rem .4rem; border-bottom: 1px solid var(--line-soft); }
.pp-num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-soft { color: var(--ink-3); }
.pp-strong { font-weight: 700; }
.pp-total td { border-top: 1.5px solid var(--ink); font-weight: 700; }
.pp-foot { margin-top: 1.5rem; padding-top: .6rem; border-top: 1px solid var(--line); font-size: .72rem; color: var(--ink-3); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 980px) {
  .menu-toggle { display: inline-flex; }
  .sidenav {
    position: fixed; top: var(--top-h); left: 0; z-index: 45;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidenav.is-open { transform: none; }
  .brand-text { display: none; }
  #save-pill { display: none; }
  .cmd-btn kbd { display: none; }
  .col-3, .col-4, .col-6, .col-8 { grid-column: span 12; }
}

@media (max-width: 620px) {
  .page-head h1 { font-size: 1.2rem; }
  .stat-value { font-size: 1.3rem; }
  #actor-btn { display: none; }
  .modal { margin: 0; width: 100%; max-height: 100vh; height: 100%; border-radius: 0; }
  .pal { margin-top: 0; width: 100%; border-radius: 0; }
}

/* ------------------------------------------------------------------- print */

@media print {
  .topbar, .sidenav, .page-actions, .toolbar, .toasts, .no-print { display: none !important; }
  .view { padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; color: #000; }

  body.printing-sign > *:not(#modal-host) { display: none !important; }
  body.printing-sign .modal-backdrop,
  body.printing-sign .modal-head,
  body.printing-sign .modal-foot,
  body.printing-sign .intro { display: none !important; }
  body.printing-sign #modal-host { position: static; }
  body.printing-sign .modal { margin: 0; max-width: none; width: 100%; height: auto; border: none; box-shadow: none; border-radius: 0; }
  body.printing-sign .modal-body { overflow: visible; padding: 0; }
  body.printing-sign .share-sign { border: none; padding: 2rem 1rem; }
  body.printing-sign .sign-qr svg { max-width: 420px; }

  .print-packet { border: none; box-shadow: none; padding: 0; background: #fff; color: #000; }
  .pp-head { border-bottom: 2px solid #000; }
  .pp-h1 { font-size: 20pt; }
  .pp-sub, .pp-note, .pp-soft, .pp-foot { color: #444; }
  .pp-stamp { color: #000; }
  .pp-h2 { color: #000; border-bottom: 1px solid #000; }
  .pp-table { font-size: 9pt; }
  .pp-table th { border-bottom: 1px solid #000; color: #000; }
  .pp-table td { border-bottom: 1px solid #ccc; }
  .pp-total td { border-top: 1.5px solid #000; }
  .pp-section { break-inside: auto; }
  .pp-break { break-before: page; }
  .pp-section:first-of-type { break-before: auto; }
  .pp-h2, .pp-h3 { break-after: avoid; }
  .pp-table thead { display: table-header-group; }
  .pp-table tr { break-inside: avoid; }
  @page { margin: 14mm; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
