/*
 * Hockey Pool: rink palette and scoreboard type.
 * Ice-white surfaces, blue-line blue for picks and actions, goal-light red used sparingly
 * (the header's red line, the leader's rank). Big Shoulders Display carries jersey numbers
 * and point totals; Source Sans 3 does everything else.
 */
:root {
  --ice: #f4f7fa;
  --surface: #ffffff;
  --ink: #13233f;
  --muted: #5a6b84;
  --rule: #d5dee8;
  --blue: #1d4e89;
  --blue-tint: #e8eff8;
  --red: #c8102e;
  --gain: #1e7a46;

  --font-ui: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-score: 'Big Shoulders Display', 'Arial Narrow', 'Roboto Condensed', sans-serif;

  --radius: 10px;
  --header-h: 64px;
  --gutter: clamp(16px, 3vw, 32px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--ice);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
}

body.sheet-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; line-height: 1.15; }

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

button { cursor: pointer; }

[hidden] { display: none !important; }

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

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

.skip-link {
  position: absolute;
  left: 8px; top: -48px;
  z-index: 100;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 6px;
}
.skip-link:focus { top: 8px; }

code {
  font-size: 0.9em;
  background: var(--blue-tint);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- Header: the board with the red line ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 4px solid var(--red);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 8px var(--gutter);
  display: flex;
  align-items: center;
  gap: 8px 28px;
  flex-wrap: wrap;
}

.app-title {
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: 0.01em;
  color: var(--blue);
}

.tabs { display: flex; gap: 4px; }

.tab {
  border: 0;
  background: none;
  padding: 10px 12px 8px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); border-bottom-color: var(--blue); }

.tab-count {
  display: inline-block;
  min-width: 1.4em;
  margin-left: 2px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--blue-tint);
  color: var(--blue);
  font-size: 0.8em;
  text-align: center;
}
.tab-count:empty { display: none; }

.data-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--rule);
  flex-shrink: 0;
}
.data-status[data-state='live'] .status-dot { background: var(--gain); }
.data-status[data-state='snapshot'] .status-dot { background: #c98a00; }
.data-status[data-state='none'] .status-dot { background: var(--red); }

.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button:disabled { color: var(--muted); cursor: wait; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
}
.button:hover { border-color: var(--blue); }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover { background: #163e6e; }
.button.quiet { border-color: transparent; background: none; color: var(--muted); }
.button.quiet:hover { color: var(--red); border-color: transparent; }
.button.small { min-height: 32px; padding: 4px 10px; font-size: 0.875rem; }

.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-button {
  width: 32px; height: 32px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.icon-button:hover { color: var(--blue); border-color: var(--blue); }

/* ---------- Layout ---------- */

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px var(--gutter) 64px;
}

.view-intro { margin-bottom: 16px; max-width: 72ch; }
.view-intro h2 { font-size: 1.5rem; }
.view-intro-row {
  max-width: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.rules, .hint { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }

.picks-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 18px;
}

.search-field { flex: 1 1 260px; max-width: 420px; }

input[type='search'], input[type='text'] {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
input[type='search']:focus, input[type='text']:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-tint); }

.segmented {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  padding: 3px;
  gap: 2px;
}
.segment {
  border: 0;
  background: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}
.segment:hover { color: var(--ink); }
.segment[aria-pressed='true'] { background: var(--blue); color: #fff; }

.empty-filter { color: var(--muted); }

/* ---------- Boxes ---------- */

.box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.box {
  margin: 0;
  min-width: 0;
  padding: 0 0 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.box.is-picked { border-left: 5px solid var(--blue); }
.box.is-flash { animation: flash 1.1s ease-out; }

@keyframes flash {
  0% { box-shadow: 0 0 0 4px var(--blue-tint), 0 0 0 6px var(--blue); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.box-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 8px;
  float: left; /* lets the legend sit inside the fieldset's border box */
}
.box-head + * { clear: both; }

.box-number {
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--blue);
  min-width: 1.4ch;
}
.box-knights .box-number { color: var(--red); }

.box-head-text {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.box-kind { font-weight: 700; }
.box-status {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.box.is-picked .box-status { color: var(--blue); font-weight: 600; }

.pick-row {
  clear: both;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin: 0 6px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.pick-row:hover { background: var(--ice); }
.pick-row.is-match { background: #fff6d6; }

.pick-input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.pick-row:has(.pick-input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 1px; }

/* Jersey number: a small extra beside the name, never the focus */
.jersey {
  margin-left: 6px;
  font-size: 0.8em;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}

.who { min-width: 0; display: flex; flex-direction: column; padding-left: 4px; }
.who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-meta { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }

.row-score { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.row-points { font-family: var(--font-score); font-weight: 800; font-size: 1.5rem; }
.row-week { font-size: 0.75rem; font-weight: 700; color: var(--gain); }

.info-button { width: 28px; height: 28px; font-size: 0.85rem; font-style: italic; font-family: Georgia, serif; }

.pick-row:has(.pick-input:checked) { background: var(--blue); color: #fff; }
.pick-row:has(.pick-input:checked) .jersey,
.pick-row:has(.pick-input:checked) .who-meta,
.pick-row:has(.pick-input:checked) .row-week { color: #dbe6f5; }
.pick-row:has(.pick-input:checked) .pp-pp1 { background: #fff; }
.pick-row:has(.pick-input:checked) .pp-pp2 { color: #dbe6f5; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45); }
.pick-row:has(.pick-input:checked) .info-button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.5); }

/* Injury badges: red when out, amber day-to-day, grey suspended */
.inj {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
  font-style: normal;
}
.inj-out { background: var(--red); color: #fff; }
.inj-dtd { background: #f2b705; color: #3d2b00; }
.inj-susp { background: #6b778a; color: #fff; }
.who-meta .inj { margin-left: 0; }
.pick-row:has(.pick-input:checked) .inj-out { box-shadow: 0 0 0 1px #fff; }

.injury-note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fde8eb;
  color: #8a0d20;
  font-size: 0.875rem;
  font-weight: 600;
}

.drawer-injury {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fde8eb;
  border-left: 4px solid var(--red);
}
.drawer-injury.inj-box-dtd { background: #fff6d6; border-left-color: #f2b705; }
.drawer-injury.inj-box-susp { background: var(--ice); border-left-color: #6b778a; }
.drawer-injury p { margin: 0; }
.drawer-injury-head { display: flex; align-items: center; gap: 8px; }
.drawer-injury-head .inj { margin-left: 0; }
.drawer-injury-facts { margin-top: 6px !important; font-weight: 600; }
.drawer-injury-comment { margin-top: 6px !important; font-size: 0.9rem; }
.drawer-injury-date { margin-top: 6px !important; font-size: 0.8rem; color: var(--muted); }

.drawer-links { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer-links .button { flex: 1 1 140px; text-decoration: none; color: var(--ink); }

.ext-link { color: var(--blue); font-weight: 600; white-space: nowrap; }
.ext-link::after { content: ' ↗'; font-size: 0.85em; }

.pp {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.5;
  vertical-align: middle;
}
.pp-pp1 { background: var(--blue-tint); color: var(--blue); }
.pp-pp2 { box-shadow: inset 0 0 0 1px var(--rule); color: var(--muted); }

/* ---------- Team panel ---------- */

.team-panel {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}

.team-bar { display: none; }

.team-sheet {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - var(--header-h) - 40px);
}

.team-sheet-head { display: flex; justify-content: space-between; align-items: center; }
.team-sheet-head h2 { font-size: 1.15rem; }
.sheet-close { display: none; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.875rem; font-weight: 600; color: var(--muted); }

.editing-note {
  margin: -6px 0 0;
  font-size: 0.85rem;
  color: var(--blue);
}

.scoreboard, .drawer-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.score { display: flex; flex-direction: column; padding: 8px 0; }
.score + .score { padding-left: 16px; border-left: 1px solid var(--rule); }
.score-value {
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 3.25rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-week { color: var(--gain); }
.drawer-scores { grid-template-columns: repeat(3, 1fr); }
.drawer-scores .score-value { font-size: 2.75rem; }
.score-proj { color: var(--blue); }
.drawer-projection-note { margin: -8px 0 0; font-size: 0.85rem; color: var(--muted); }
td.proj { color: var(--blue); font-weight: 600; }
.score-label { font-size: 0.85rem; color: var(--muted); }

.progress-text {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  font-weight: 600;
}
.progress-track {
  margin-top: 6px;
  height: 6px;
  border-radius: 3px;
  background: var(--blue-tint);
  overflow: hidden;
}
.progress-fill { height: 100%; width: 0; background: var(--blue); transition: width 0.25s ease; }
.team-panel.is-complete .progress-fill { background: var(--gain); }

.pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 120px;
  flex: 1;
  border-top: 1px solid var(--rule);
}

.pick-item-button {
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid var(--ice);
  background: none;
  text-align: left;
  font-size: 0.9rem;
}
.pick-item-button:hover { background: var(--ice); }
.pick-item.is-open .pick-item-button { color: var(--muted); font-style: italic; }
.pick-item.is-open .pick-item-name { grid-column: 2 / -1; }

.pick-item-box {
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--blue);
  text-align: right;
  font-style: normal;
}
.pick-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-item-team { font-size: 0.8rem; color: var(--muted); }
.pick-item-points { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.team-actions { display: flex; flex-direction: column; gap: 8px; }
.team-actions .primary { width: 100%; min-height: 46px; font-size: 1.05rem; }
.secondary-actions { display: flex; gap: 8px; }
.secondary-actions .button { flex: 1; }

/* ---------- Tables (Standings, Players, Knights) ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; }

th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--ice); }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; background: var(--surface); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
td.up { color: var(--gain); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }

.empty-row td { color: var(--muted); padding: 24px 14px; }

.standings-table .rank {
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 1.4rem;
  width: 64px;
}
.team-row.is-leader .rank { color: var(--red); }
.team-points { font-family: var(--font-score); font-weight: 800; font-size: 1.5rem; }
.team-week { color: var(--gain); font-weight: 700; }

.team-toggle {
  border: 0;
  background: none;
  padding: 4px 0;
  font-weight: 700;
  text-align: left;
}
.team-toggle::after { content: ' +'; color: var(--muted); font-weight: 400; }
.team-toggle[aria-expanded='true']::after { content: ' −'; }
.team-toggle:hover { color: var(--blue); }

.row-actions { text-align: right; white-space: nowrap; }
.row-actions .button + .button { margin-left: 4px; }

.team-detail td { background: var(--ice); padding: 12px 14px 16px; }
.team-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2 300px;
  column-gap: 32px;
}
.team-detail-list li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto 64px;
  gap: 8px;
  padding: 3px 0;
  break-inside: avoid;
  font-size: 0.9rem;
}

.players-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}

.players-table thead th { position: sticky; top: 0; }
.players-table tr.is-mine td { background: var(--blue-tint); }

.sort {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  color: inherit;
}
.sort:hover { color: var(--ink); }
th[aria-sort] .sort { color: var(--ink); }
th[aria-sort='descending'] .sort::after { content: ' ↓'; }
th[aria-sort='ascending'] .sort::after { content: ' ↑'; }

.player-link {
  border: 0;
  background: none;
  padding: 2px 0;
  font-weight: 600;
  display: inline-flex;
  align-items: baseline;
  text-align: left;
}
.player-link:hover .player-link-name { color: var(--blue); text-decoration: underline; }
.players-table .pp { margin-left: 8px; }
.mine-tag {
  margin-left: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue);
}

.players-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: calc(var(--header-h) + 20px); }

.side-section {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px;
}
.side-section h3 { font-size: 1.1rem; }

.hot-list { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: hot; }
.hot-list li { counter-increment: hot; }
.hot-item {
  width: 100%;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  grid-template-areas: 'rank name pts' 'rank meta pts';
  column-gap: 8px;
  align-items: center;
  padding: 6px 4px;
  border: 0;
  border-bottom: 1px solid var(--ice);
  background: none;
  text-align: left;
}
.hot-item::before {
  content: counter(hot);
  grid-area: rank;
  font-family: var(--font-score);
  font-weight: 800;
  color: var(--muted);
}
.hot-item:hover { background: var(--ice); }
.hot-name { grid-area: name; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hot-meta { grid-area: meta; font-size: 0.8rem; color: var(--muted); }
.hot-points { grid-area: pts; font-family: var(--font-score); font-weight: 800; font-size: 1.4rem; color: var(--gain); }
.hot-empty { color: var(--muted); font-style: italic; padding: 6px 0; }
.hot-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff6d6;
  color: #6b4a00;
  font-size: 0.875rem;
}

.knights-panel summary { cursor: pointer; list-style-position: outside; }
.knights-panel summary h3 { display: inline; }
.knights-panel .table-wrap { margin: 12px 0; border-radius: 8px; }
.knights-table th, .knights-table td { padding: 6px 8px; }
.knights-input {
  width: 52px;
  min-height: 36px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-align: right;
}

/* ---------- Player drawer ---------- */

.drawer {
  margin: 0 0 0 auto;
  height: 100vh;
  max-height: 100vh;
  width: min(400px, 100vw);
  border: 0;
  border-left: 4px solid var(--blue);
  padding: 24px;
  background: var(--surface);
  color: var(--ink);
}
.drawer::backdrop { background: rgba(19, 35, 63, 0.4); }
.drawer[open] { display: flex; flex-direction: column; gap: 18px; }

.drawer-head { display: grid; grid-template-columns: 72px minmax(0, 1fr) 32px; gap: 14px; align-items: center; }
.drawer-headshot, .drawer-initials {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--blue-tint);
  object-fit: cover;
}
.drawer-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-score);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--blue);
}
.drawer-number { margin: 0; font-family: var(--font-score); font-weight: 800; font-size: 1.1rem; color: var(--muted); }
.drawer-head h2 { font-size: 1.4rem; }
.drawer-meta { margin: 2px 0 0; font-size: 0.9rem; color: var(--muted); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  margin: 0;
}
.stat { display: flex; justify-content: space-between; border-bottom: 1px solid var(--ice); padding-bottom: 6px; }
.stat dt { color: var(--muted); }
.stat dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.drawer-note { margin: 0; color: #8a5a00; font-size: 0.9rem; }
.drawer-pick { margin-top: auto; min-height: 46px; }

/* ---------- Loading and toasts ---------- */

.loading-overlay {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.loading-overlay.visible { opacity: 1; transform: translate(-50%, 0); }
.loading-overlay p { margin: 0; }
.loading-spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: min(340px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface);
  border-left: 4px solid var(--blue);
  box-shadow: 0 8px 24px rgba(19, 35, 63, 0.18);
  pointer-events: auto;
  transition: opacity 0.2s, transform 0.2s;
}
.toast-success { border-left-color: var(--gain); }
.toast-warning { border-left-color: #c98a00; }
.toast-error { border-left-color: var(--red); }
.toast-hide { opacity: 0; transform: translateY(6px); }
.toast-content { flex: 1; font-size: 0.95rem; }
.toast-close { border: 0; background: none; font-size: 1.2rem; line-height: 1; color: var(--muted); }

/* ---------- Tablet and phone ---------- */

@media (max-width: 1100px) {
  .players-layout { grid-template-columns: 1fr; }
  .players-side { position: static; }
}

@media (max-width: 900px) {
  :root { --header-h: 92px; }
  .header-inner { gap: 0 12px; padding-top: 6px; padding-bottom: 0; min-height: 0; }
  .app-title { font-size: 1.45rem; }
  /* Phone: status shrinks to its dot plus Refresh; tabs get their own full-width row */
  .data-status { margin-left: auto; }
  .data-status #data-status-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; padding: 10px 4px 8px; }

  main { padding-top: 18px; padding-bottom: 96px; }
  .picks-layout { grid-template-columns: 1fr; }

  /* Team panel becomes a bar fixed to the bottom that opens into a sheet */
  .team-panel { position: static; }
  .team-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 4px solid var(--blue);
    background: var(--surface);
    text-align: left;
    box-shadow: 0 -6px 20px rgba(19, 35, 63, 0.12);
  }
  .team-bar-progress { font-weight: 600; }
  .team-bar-points { font-family: var(--font-score); font-weight: 800; font-size: 1.4rem; }
  .team-bar-action { color: var(--blue); font-weight: 700; }
  .team-panel.is-complete .team-bar { border-top-color: var(--gain); }

  .team-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 35;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    border: 0;
    box-shadow: 0 -12px 40px rgba(19, 35, 63, 0.3);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s 0.25s;
  }
  .team-panel.sheet-open .team-sheet {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease;
  }
  .sheet-close { display: inline-block; }

  .standings-table th:nth-child(4), .standings-table td.team-week { display: none; }
  .row-actions .button.quiet { display: none; }

  .drawer {
    margin: auto 0 0;
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: 90vh;
    border-left: 0;
    border-top: 4px solid var(--blue);
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .toast-container { top: auto; bottom: 84px; right: 50%; transform: translateX(50%); }
}

@media (max-width: 520px) {
  .segmented { width: 100%; }
  .segment { flex: 1; padding: 7px 6px; font-size: 0.85rem; }
  .search-field { max-width: none; }
  .players-table th:nth-child(3), .players-table td:nth-child(3),
  .players-table th:nth-child(4), .players-table td:nth-child(4) { display: none; }
  th, td { padding: 8px 10px; }
}

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

@media print {
  .app-header, .team-bar, .toolbar { display: none; }
}
