/* Svidbear — Fat Bear Week 2026
   Palette: river silt + spruce + sockeye. Type: Bricolage Grotesque / Newsreader / DM Mono. */

:root {
  --ground: #dbe2da;
  --surface: #f1f4ef;
  --surface-2: #e6ebe4;
  --ink: #14211b;
  --ink-soft: #4d5c54;
  --ink-faint: #7b897f;
  --rule: #b7c2b6;
  --rule-soft: #cbd4c9;
  --accent: #b8402a;
  --accent-ink: #8f2f1d;
  --accent-wash: rgba(184, 64, 42, 0.1);
  --spruce: #2f5e4a;
  --spruce-wash: rgba(47, 94, 74, 0.12);
  --gold: #9a6f16;
  --gold-wash: rgba(154, 111, 22, 0.12);
  --shadow: 0 1px 0 rgba(20, 33, 27, 0.06), 0 8px 24px -16px rgba(20, 33, 27, 0.4);

  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  --gap: 30px;
  --radius: 4px;
  --tray-h: 112px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ground: #0d1411;
    --surface: #161f1a;
    --surface-2: #1e2823;
    --ink: #dfe7df;
    --ink-soft: #9aa99f;
    --ink-faint: #74837a;
    --rule: #2c3a33;
    --rule-soft: #24302a;
    --accent: #e0573c;
    --accent-ink: #f0836d;
    --accent-wash: rgba(224, 87, 60, 0.14);
    --spruce: #6fa189;
    --spruce-wash: rgba(111, 161, 137, 0.16);
    --gold: #d0a24a;
    --gold-wash: rgba(208, 162, 74, 0.14);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 10px 28px -18px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --ground: #0d1411;
  --surface: #161f1a;
  --surface-2: #1e2823;
  --ink: #dfe7df;
  --ink-soft: #9aa99f;
  --ink-faint: #74837a;
  --rule: #2c3a33;
  --rule-soft: #24302a;
  --accent: #e0573c;
  --accent-ink: #f0836d;
  --accent-wash: rgba(224, 87, 60, 0.14);
  --spruce: #6fa189;
  --spruce-wash: rgba(111, 161, 137, 0.16);
  --gold: #d0a24a;
  --gold-wash: rgba(208, 162, 74, 0.14);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 10px 28px -18px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* Class-based display rules outrank the UA sheet, so make [hidden] win outright. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0 0 calc(var(--tray-h) + 24px);
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px;
  top: 16px;
  z-index: 50;
  background: var(--surface);
  padding: 10px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Masthead ───────────────────────────────────────────── */

.masthead {
  position: relative;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
  padding: clamp(28px, 6vw, 64px) clamp(20px, 5vw, 56px) clamp(24px, 4vw, 40px);
}

.masthead__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.masthead h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 6.5rem);
  line-height: 0.86;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.masthead__year {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.3em;
  letter-spacing: 0.04em;
  color: var(--accent);
  vertical-align: super;
}

.masthead__lede {
  margin: 0;
  max-width: 62ch;
  font-size: 1.12rem;
  color: var(--ink-soft);
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 8px 0 0;
  border-top: 1px solid var(--rule-soft);
  padding-top: 14px;
}

.facts > div {
  padding-right: clamp(20px, 4vw, 44px);
  margin-right: clamp(20px, 4vw, 44px);
  border-right: 1px solid var(--rule-soft);
}
.facts > div:last-child {
  border-right: 0;
  margin-right: 0;
  padding-right: 0;
}

.facts dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.facts dd {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.28rem;
  font-variant-numeric: tabular-nums;
}

.theme-toggle {
  position: absolute;
  top: clamp(16px, 3vw, 28px);
  right: clamp(16px, 4vw, 40px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
}
.theme-toggle__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Section furniture ──────────────────────────────────── */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(16px, 5vw, 56px);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 20px;
  padding: clamp(36px, 5vw, 56px) 0 20px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
}

.section-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.95rem;
  max-width: 56ch;
}

/* ── Bracket board ──────────────────────────────────────── */

.board-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  margin: 0 calc(clamp(16px, 5vw, 56px) * -1);
  padding-left: clamp(16px, 5vw, 56px);
  padding-right: clamp(16px, 5vw, 56px);
}

.board {
  display: grid;
  grid-template-columns:
    minmax(230px, 1fr) minmax(230px, 1fr) minmax(230px, 1fr)
    minmax(190px, 0.8fr)
    minmax(230px, 1fr) minmax(230px, 1fr) minmax(230px, 1fr);
  column-gap: var(--gap);
  min-width: 1750px;
  min-height: 780px;
  align-items: stretch;
}

.column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.col__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
  text-align: center;
}

.col__head strong {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.col__head span {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.col__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pair {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  position: relative;
}

.pair--single {
  justify-content: center;
}

/* Vertical joiner: sibling match centres always sit at 25% / 75% of a pair. */
.pair--join::after {
  content: '';
  position: absolute;
  top: 25%;
  height: 50%;
  width: 1px;
  background: var(--rule);
}
.column[data-side='L'] .pair--join::after {
  left: calc(100% + var(--gap) / 2);
}
.column[data-side='R'] .pair--join::after {
  right: calc(100% + var(--gap) / 2);
}

/* ── Match cards ────────────────────────────────────────── */

.match {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.match__date {
  position: absolute;
  top: -9px;
  left: 10px;
  padding: 0 6px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.match--final {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px var(--gold-wash), var(--shadow);
}

/* Horizontal stubs out to the joiner line. */
.match::after,
.match::before {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(var(--gap) / 2);
  height: 1px;
  background: var(--rule);
}
.match:not(.has-out)::after,
.match:not(.has-in)::before {
  display: none;
}
.column[data-side='L'] .match::after {
  left: 100%;
}
.column[data-side='L'] .match::before {
  right: 100%;
}
.column[data-side='R'] .match::after {
  right: 100%;
}
.column[data-side='R'] .match::before {
  left: 100%;
}
.column[data-side='F'] .match::after {
  right: 100%;
}
.column[data-side='F'] .match::before {
  left: 100%;
}

.slot {
  display: flex;
  align-items: stretch;
  width: 100%;
  transition: background 0.14s ease;
}
.slot + .slot {
  border-top: 1px solid var(--rule-soft);
}
.match .slot:first-of-type {
  border-radius: var(--radius) var(--radius) 0 0;
}
.match .slot:last-of-type {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* The wide half reads the dossier; the narrow half advances the bear. */
.slot__main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 6px 10px 10px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}
.slot__main:hover {
  background: var(--surface-2);
}
.slot--empty .slot__main {
  cursor: default;
}
.slot--empty .slot__main:hover {
  background: transparent;
}

.slot__pick {
  flex: none;
  width: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--rule-soft);
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}
.slot__pick:hover .slot__check {
  border-color: var(--accent);
  color: var(--accent);
}

.slot__check {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: transparent;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.slot__id {
  flex: none;
  min-width: 34px;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.slot__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.slot__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot__meta {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot--picked {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}
.column[data-side='R'] .slot--picked {
  box-shadow: inset -3px 0 0 var(--accent);
}
.slot--picked .slot__id,
.slot--picked .slot__name {
  color: var(--accent-ink);
}
.slot--picked .slot__name {
  font-weight: 800;
}
.slot--picked .slot__check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fdf7f4;
}
.slot--picked .slot__pick:hover .slot__check {
  background: transparent;
  color: var(--accent);
}

.slot--empty .slot__name {
  font-family: var(--body);
  font-weight: 400;
  font-style: italic;
  color: var(--ink-faint);
}

.slot--out {
  opacity: 0.45;
}

/* ── Bear dossier modal ─────────────────────────────────── */

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(8, 14, 11, 0.55);
  backdrop-filter: blur(3px);
}

.modal[open] {
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.modal__form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  margin: 0;
}

.modal__head {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--rule);
}

.modal__id {
  font-family: var(--mono);
  font-size: 2.1rem;
  font-weight: 500;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.modal__titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.modal__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-wrap: balance;
}

.modal__tagline {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
}

.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.modal__close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 26px 24px;
  overflow-y: auto;
}

.modal__matchup {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.modal__matchup strong {
  color: var(--ink);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.02em;
}

.modal__vitals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 0;
}

.modal__vitals div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 11px;
  border-left: 2px solid var(--rule);
}

.modal__vitals dt {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.modal__vitals dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.92rem;
}

.modal__marks,
.modal__bio {
  margin: 0;
}

.modal__marks {
  font-size: 0.94rem;
  font-style: italic;
  color: var(--ink-soft);
}

.modal__edge {
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--gold-wash);
  border: 1px solid var(--gold);
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.94rem;
  color: var(--ink);
}
.modal__edge::before {
  content: 'Why they win';
  display: block;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 5px;
}

.modal__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 26px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}

.modal__hint {
  margin: 0;
  margin-right: auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
}

/* Champion plate in the middle column */
.champion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 16px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-wash);
  text-align: center;
}

.champion__label {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.champion__id {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.champion__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

.champion--empty .champion__id {
  color: var(--ink-faint);
}
.champion--empty .champion__name {
  font-family: var(--body);
  font-weight: 400;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-faint);
}

.voting-note {
  margin: 20px 0 0;
  font-size: 0.92rem;
  color: var(--ink-faint);
  max-width: 68ch;
}

/* ── The pool ───────────────────────────────────────────── */

.pool__body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.pool__empty,
.pool__error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  color: var(--ink-faint);
  font-style: italic;
}

.entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.entry:hover {
  border-color: var(--accent);
}
.entry--mine {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.entry__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
}

.entry__pick {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.entry__code {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

/* ── Roster ─────────────────────────────────────────────── */

.roster__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.dossier {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 24px 26px;
  background: var(--surface);
  scroll-margin-top: 24px;
}

.dossier__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.dossier__id {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1;
}

.dossier__name {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.chip {
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.dossier__vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.dossier__marks {
  margin: 0;
  padding-left: 13px;
  border-left: 2px solid var(--rule);
  font-size: 0.92rem;
  font-style: italic;
  color: var(--ink-soft);
}

.dossier__bio {
  margin: 0;
  font-size: 1rem;
}

.dossier__edge {
  margin: 4px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--spruce);
}

.dossier__edge::before {
  content: 'Why they win';
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

/* ── Colophon ───────────────────────────────────────────── */

.colophon {
  padding: 48px 0 8px;
  border-top: 1px solid var(--rule-soft);
  margin-top: 56px;
  color: var(--ink-faint);
  font-size: 0.88rem;
  max-width: 72ch;
}
.colophon p {
  margin: 0;
}

/* ── Sticky tray ────────────────────────────────────────── */

.tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -10px 30px -22px rgba(0, 0, 0, 0.7);
}

.tray__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px clamp(16px, 5vw, 56px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.tray__progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  flex: 1 1 200px;
}

.meter {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.tray__count {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.tray__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field {
  padding: 9px 12px;
  width: 170px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.92rem;
}
.field::placeholder {
  color: var(--ink-faint);
  font-family: var(--body);
  font-style: italic;
}

.btn {
  padding: 9px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.btn:hover:not(:disabled) {
  border-color: var(--ink-faint);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fdf7f4;
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}
.btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--quiet {
  background: transparent;
  color: var(--ink-faint);
  font-weight: 500;
}

.tray__status {
  margin: 0;
  padding: 0 clamp(16px, 5vw, 56px) 10px;
  max-width: 1400px;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--spruce);
  min-height: 1em;
}
.tray__status[data-tone='error'] {
  color: var(--accent);
}

/* ── Stacked layout for narrow screens ──────────────────── */

/* Phone layout lives in the mobile section at the end of this file. */

/* Centre column: the final match must stay at the board's midline, so the
   champion plate hangs below it without pushing the match off centre. */
.col__body--final {
  position: relative;
  justify-content: center;
}

.column[data-side='F'] .champion {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}



/* ── Account controls ───────────────────────────────────── */

.tray__auth {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 12px;
  margin-right: 4px;
  border-right: 1px solid var(--rule);
}

.tray__who {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.modal--narrow {
  width: min(420px, calc(100vw - 32px));
}

.field--wide {
  width: 100%;
  font-size: 1rem;
  padding: 11px 13px;
}

.modal__note {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-faint);
}
.modal__note[data-tone='ok'] {
  color: var(--spruce);
}
.modal__note[data-tone='error'] {
  color: var(--accent);
}



/* ── Bear photographs ───────────────────────────────────── */

.slot__face {
  flex: none;
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
}
.slot--out .slot__face {
  filter: grayscale(0.75);
}
.slot--picked .slot__face {
  box-shadow: 0 0 0 2px var(--accent);
}

.modal__figure {
  flex: none;
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.modal__photo {
  display: block;
  width: 100%;
  aspect-ratio: 1036 / 633;
  max-height: 34vh;
  object-fit: cover;
  background: var(--surface-2);
}

.modal__credit {
  padding: 7px 26px 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.dossier__photo {
  width: 100%;
  aspect-ratio: 1036 / 633;
  object-fit: cover;
  border-radius: 3px;
  background: var(--surface-2);
}

/* The bracket row is narrow: the bear's number is its name, so it shares the
   name line rather than taking a column of its own. */
.slot__name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.slot__num {
  flex: none;
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.slot__nick {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot__face--blank {
  background: var(--surface-2);
  border: 1px dashed var(--rule);
}

/* ═══ Touch and iOS behaviour ═══════════════════════════════════════════════ */

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

* {
  -webkit-tap-highlight-color: transparent;
}

/* The pick button carries a word on a phone and only the tick on a desktop. */
.slot__picklabel {
  display: none;
}

.modal__body {
  overscroll-behavior: contain;
}

/* Dynamic viewport units keep the sheet clear of Safari's collapsing toolbars. */
.modal {
  max-height: min(86dvh, 760px);
}

/* A finger has no hover, so the pointer states must not stick after a tap. */
@media (hover: none) {
  .slot__main:hover {
    background: transparent;
  }
  .slot__pick:hover .slot__check {
    border-color: var(--rule);
    color: transparent;
  }
  .slot--picked .slot__pick:hover .slot__check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fdf7f4;
  }
  .entry:hover,
  .btn:hover:not(:disabled),
  .theme-toggle:hover {
    border-color: var(--rule);
  }
}

.slot__main:active {
  background: var(--surface-2);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* ═══ Phones and small tablets ══════════════════════════════════════════════ */

@media (max-width: 1000px) {
  :root {
    --tray-h: 160px;
  }

  body {
    font-size: 16px;
    padding-bottom: calc(var(--tray-h) + env(safe-area-inset-bottom, 0px) + 20px);
  }

  /* Both axes, or a hidden overflow-y silently forces overflow-x to scroll
     and breaks the sticky round headers. */
  .board-scroll {
    overflow: visible;
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .board {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
    min-height: 0;
  }

  .column {
    order: var(--order, 0);
  }

  .col__head {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 10px;
    text-align: left;
    margin-bottom: 12px;
    padding: 10px 0 8px;
    background: var(--ground);
  }

  .col__body {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .pair {
    display: contents;
  }

  .pair--join::after,
  .match::after,
  .match::before {
    display: none;
  }

  /* Two bears side by side, the way the official poll presents a matchup. */
  .match {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 10px;
  }

  .match__date {
    position: static;
    grid-column: 1 / -1;
    padding: 0 2px;
    background: transparent;
  }

  .slot {
    flex-direction: column;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
  }
  .slot + .slot {
    border-top: 1px solid var(--rule);
  }
  .match .slot:first-of-type,
  .match .slot:last-of-type {
    border-radius: var(--radius);
  }

  .slot__main {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
  }

  .slot__face {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 0;
  }

  .slot__body {
    padding: 8px 10px 10px;
  }
  .slot__name {
    font-size: 1rem;
  }
  .slot__meta {
    font-size: 0.6rem;
  }

  .slot__pick {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    border-left: 0;
    border-top: 1px solid var(--rule-soft);
    background: var(--surface-2);
  }

  .slot__picklabel {
    display: inline;
    font-family: var(--display);
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--ink-soft);
  }

  .slot--picked {
    box-shadow: none;
    border-color: var(--accent);
  }
  .column[data-side='R'] .slot--picked {
    box-shadow: none;
  }
  .slot--picked .slot__pick {
    background: var(--accent);
  }
  .slot--picked .slot__picklabel {
    color: #fdf7f4;
  }
  .slot--picked .slot__check {
    background: transparent;
    border-color: rgba(253, 247, 244, 0.55);
    color: #fdf7f4;
  }

  /* A matchup still waiting on a feeder stays a compact row. */
  .match--pending {
    grid-template-columns: 1fr;
  }
  .match--pending .slot {
    flex-direction: row;
    align-items: stretch;
  }
  .match--pending .slot__main {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
  }
  .match--pending .slot__face {
    width: 40px;
    height: 40px;
    aspect-ratio: auto;
    border-radius: 3px;
  }
  .match--pending .slot__face--blank {
    display: none;
  }
  .match--pending .slot__pick {
    width: 54px;
    min-height: 0;
    border-top: 0;
    border-left: 1px solid var(--rule-soft);
    background: transparent;
  }
  .match--pending .slot__picklabel {
    display: none;
  }

  .col__body--final {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .column[data-side='F'] .champion {
    position: static;
    padding: 18px;
  }

  /* Keep the eyebrow clear of the theme pill in the corner. */
  .eyebrow {
    padding-right: 92px;
  }

  .facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 0;
  }
  .facts > div {
    padding-right: 14px;
    margin-right: 14px;
  }
  .facts > div:nth-child(2n) {
    border-right: 0;
    margin-right: 0;
    padding-right: 0;
  }

  .roster__grid {
    grid-template-columns: 1fr;
  }

  /* ── Tray: progress, then name and submit, then everything else ── */

  .tray {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .tray__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 16px 8px;
  }

  .tray__progress {
    /* The base rule's flex-basis is a width when the tray is a row and a
       height once it stacks, which stretched the tray to 200px tall. */
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .tray__actions {
    display: grid;
    /* minmax(0,...) or the text input's min-content width pushes the row
       wider than the tray and the buttons run off the right edge. */
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      'name submit submit'
      'auth share reset';
    gap: 8px;
    align-items: center;
    width: 100%;
  }

  #trayAuth {
    grid-area: auth;
    min-width: 0;
    padding-right: 0;
    margin-right: 0;
    border-right: 0;
  }
  #trayAuth .btn {
    min-height: 40px;
    font-size: 0.82rem;
  }
  #entryName {
    grid-area: name;
    width: auto;
    min-width: 0;
    font-size: 16px; /* anything smaller and iOS zooms the page on focus */
    min-height: 44px;
  }
  #submitBtn {
    grid-area: submit;
    min-height: 44px;
    padding-inline: 16px;
    font-size: 0.86rem;
    white-space: nowrap;
  }
  #shareBtn {
    grid-area: share;
  }
  #resetBtn {
    grid-area: reset;
  }
  #shareBtn,
  #resetBtn {
    background: transparent;
    border-color: transparent;
    color: var(--ink-faint);
    font-weight: 500;
    font-size: 0.82rem;
    padding: 8px;
    white-space: nowrap;
    min-height: 40px;
  }

  .tray__status {
    padding: 0 16px 8px;
  }
}

/* ═══ The dossier becomes a bottom sheet ════════════════════════════════════ */

@media (max-width: 700px) {
  .modal,
  .modal--narrow {
    /* Pinned rather than auto-margined: a centred dialog drifts a few pixels
       below the fold once Safari's toolbars are in play. */
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    margin: 0;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
  }

  .modal__head {
    padding: 18px 18px 14px;
  }
  .modal__body {
    padding: 16px 18px 20px;
  }
  .modal__credit {
    padding-left: 18px;
    padding-right: 18px;
  }
  .modal__photo {
    max-height: 30dvh;
  }

  .modal__foot {
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .modal__hint {
    display: none;
  }
  .modal__foot .btn {
    flex: 1;
    min-height: 46px;
  }

  .modal__name {
    font-size: 1.35rem;
  }
  .modal__id {
    font-size: 1.8rem;
  }
}

/* Tablets have room for more than one matchup across. */
@media (min-width: 620px) and (max-width: 1000px) {
  .col__body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
  }
  .col__head {
    padding-top: 14px;
  }
}

/* ═══ The two views ═════════════════════════════════════════════════════════ */

.viewnav {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  align-self: flex-start;
  background: var(--surface-2);
}

.viewnav__tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}
.viewnav__tab--active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.viewnav__count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--spruce-wash);
  color: var(--spruce);
  font-family: var(--mono);
  font-size: 0.68rem;
  text-align: center;
}
.viewnav__count:empty {
  display: none;
}

/* Someone else's bracket is deliberately a different colour from your own, so
   the two can never be mistaken for each other at a glance. */
body[data-view='guest'] {
  --accent: var(--spruce);
  --accent-ink: var(--spruce);
  --accent-wash: var(--spruce-wash);
}

.guest {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 20px;
  padding: 12px 18px;
  border: 1px solid var(--spruce);
  border-radius: var(--radius);
  background: var(--spruce-wash);
  backdrop-filter: blur(8px);
}

.guest__who {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.guest__label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--spruce);
}

.guest__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.btn--guest {
  background: var(--spruce);
  border-color: var(--spruce);
  color: #f4f8f5;
}
.btn--guest:hover:not(:disabled) {
  filter: brightness(1.1);
}

/* ═══ Pool page ═════════════════════════════════════════════════════════════ */

.tally {
  margin-bottom: 40px;
  padding: 22px 24px 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.tally__title {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.tally__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tally__row {
  display: grid;
  grid-template-columns: 40px minmax(120px, 170px) 1fr auto;
  align-items: center;
  gap: 14px;
}

.tally__face {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--surface-2);
}

.tally__label {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.tally__num {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.tally__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tally__bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.tally__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--spruce);
}

.tally__count {
  font-family: var(--mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.pool__subtitle {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.entry {
  flex-direction: row;
  align-items: center;
  gap: 13px;
}

.entry__face {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--surface-2);
}

.entry__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.entry__nameRow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.entry__badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--spruce-wash);
  color: var(--spruce);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.entry--mine {
  border-color: var(--spruce);
  background: var(--spruce-wash);
}
.entry:hover {
  border-color: var(--spruce);
}

.entry__name,
.entry__pick,
.entry__code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1000px) {
  .viewnav {
    width: 100%;
    align-self: stretch;
  }
  .viewnav__tab {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    min-height: 44px;
  }
  .guest {
    margin-top: 14px;
    padding: 10px 14px;
  }
  .btn--guest {
    min-height: 44px;
  }
  .tally {
    padding: 16px;
  }
  .tally__row {
    grid-template-columns: 34px 1fr auto;
    gap: 10px;
  }
  .tally__face {
    width: 34px;
    height: 34px;
  }
  .tally__bar {
    grid-column: 2 / -1;
    grid-row: 2;
  }
}

/* ── Stepping between brackets in the pool ──────────────── */

.guest__pick {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.guest__select {
  min-width: 0;
  max-width: 260px;
  flex: 1;
  padding: 9px 11px;
  border: 1px solid var(--spruce);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.88rem;
}
.guest__select:disabled {
  opacity: 0.5;
}

.btn--step {
  flex: none;
  width: 38px;
  padding: 0;
  min-height: 38px;
  border-color: var(--spruce);
  background: var(--surface);
  color: var(--spruce);
  font-size: 1.15rem;
  line-height: 1;
}
.btn--step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

@media (max-width: 1000px) {
  /* Two rows, not four — this bar is sticky, so every pixel of it is a pixel
     of bracket the reader never sees. */
  .guest {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'who exit'
      'pick pick';
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
  }
  .guest__who {
    grid-area: who;
  }
  .guest__name {
    font-size: 0.95rem;
  }
  .guest__pick {
    grid-area: pick;
    width: 100%;
  }
  #guestExit {
    grid-area: exit;
    padding: 8px 12px;
    min-height: 40px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .guest__select {
    max-width: none;
    font-size: 16px; /* stop iOS zooming when the picker opens */
    min-height: 44px;
  }
  .btn--step {
    width: 44px;
    min-height: 44px;
  }
}

/* ── Google sign-in ─────────────────────────────────────── */

.btn--google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.98rem;
}
.btn--google:hover:not(:disabled) {
  border-color: var(--ink-faint);
}
.btn--google:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn__g {
  flex: none;
  width: 19px;
  height: 19px;
}

/* A rule with the word sitting in the gap. */
.authsplit {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.authsplit::before,
.authsplit::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

@media (max-width: 700px) {
  .btn--google {
    min-height: 52px;
  }
}
