/* ==========================================================================
   Survivor pool — one stylesheet, no build step.

   Designed at 375px first. Every interactive target is at least 44px tall.
   Everything scales with rem so 200% text zoom stays usable, and nothing
   depends on hover.
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #eef0f4;
  --border: #d6dae1;
  --border-strong: #adb4bf;

  --text: #14181f;
  --text-muted: #5a6472;
  --text-inverse: #ffffff;

  --accent: #1c5dd8;
  --accent-hover: #164ab0;
  --accent-soft: #e7efff;

  --alive: #0f7a44;
  --alive-soft: #e2f4ea;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --warning: #8a5a00;
  --warning-soft: #fff4dc;

  --radius: 12px;
  --radius-lg: 16px;
  --tap: 44px;

  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --shadow-lg: 0 4px 6px -2px rgb(16 24 40 / 6%), 0 12px 16px -4px rgb(16 24 40 / 10%);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --surface: #1b1f26;
    --surface-sunken: #23282f;
    --border: #333a44;
    --border-strong: #4d5663;

    --text: #f0f2f5;
    --text-muted: #a3adba;

    --accent: #7ba7f5;
    --accent-hover: #9dbdf8;
    --accent-soft: #1e2a3f;

    --alive: #6fd39b;
    --alive-soft: #12301f;
    --danger: #f2938c;
    --danger-soft: #331815;
    --warning: #e5b667;
    --warning-soft: #302411;

    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 45%);
  }
}

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

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  /* Never allow a sideways scroll on a phone. */
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   Focus — always visible, never removed.
   -------------------------------------------------------------------------- */

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

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

.page {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

.page--wide {
  max-width: 60rem;
}

@media (min-width: 40rem) {
  .page {
    padding: 2rem 1.5rem 5rem;
  }
}

.stack > * + * {
  margin-top: 1rem;
}

.stack-sm > * + * {
  margin-top: 0.5rem;
}

.stack-lg > * + * {
  margin-top: 1.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.row--between {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.175rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0;
}

.lede {
  font-size: 1.0625rem;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.875rem;
}

.tiny {
  font-size: 0.8125rem;
}

.numeric {
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.625rem 1rem;
  min-height: var(--tap);
}

.masthead--wide .masthead__inner {
  max-width: 60rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.875rem;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Buttons — minimum 44px, full width on phones.
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.6875rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: var(--surface-sunken);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--border-strong);
}

.btn--primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--block {
  width: 100%;
}

.btn--large {
  min-height: 3.25rem;
  font-size: 1.0625rem;
}

.btn--quiet {
  background: none;
  border-color: var(--border);
}

.btn--link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  min-height: var(--tap);
  padding: 0.5rem;
  font-weight: 500;
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn[disabled]:hover {
  border-color: transparent;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field {
  display: block;
}

.field__label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.field__hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.6875rem 0.875rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.input:focus-visible {
  border-color: var(--accent);
}

.input--xl {
  min-height: 3.5rem;
  font-size: 1.375rem;
  font-weight: 600;
}

/* The 6-digit code box: big, spaced, tabular. */
.input--code {
  min-height: 3.75rem;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  font-variant-numeric: tabular-nums;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
  border-width: 2px;
}

.field__error {
  display: block;
  margin-top: 0.375rem;
  color: var(--danger);
  font-weight: 550;
  font-size: 0.9375rem;
}

/* Checkbox row: box and label side by side, whole row a 44px tap target. */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.5rem 0;
  cursor: pointer;
}

.checkbox > input[type='checkbox'] {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.125rem 0 0;
  accent-color: var(--accent);
}

.checkbox__text {
  flex: 1 1 auto;
  min-width: 0;
}

.checkbox__text > strong {
  display: block;
}

.checkbox__text > .field__hint {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Notices — never colour alone; each carries a text label.
   -------------------------------------------------------------------------- */

.notice {
  display: flex;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  font-size: 0.9375rem;
}

.notice__label {
  font-weight: 700;
  white-space: nowrap;
}

.notice--error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--text);
}

.notice--warning {
  background: var(--warning-soft);
  border-color: var(--warning);
}

.notice--success {
  background: var(--alive-soft);
  border-color: var(--alive);
}

.notice--info {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Status pills — text + shape, so colour is never the only signal.
   -------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-sunken);
  font-size: 0.8125rem;
  font-weight: 650;
  white-space: nowrap;
}

.pill--alive {
  background: var(--alive-soft);
  border-color: var(--alive);
  color: var(--alive);
}

.pill--out {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.pill--review {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--warning);
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */

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

.center {
  text-align: center;
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 1.5rem 0;
}

.footer-note {
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* Anything wide (tables, code) scrolls inside itself, never the page. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

/* ==========================================================================
   Pool screens
   ========================================================================== */

/* --- Deadline countdown: the unmissable thing at the top of the home screen. */

.countdown {
  display: block;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.countdown__label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.countdown__value {
  display: block;
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.countdown__absolute {
  display: block;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.countdown--urgent {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.countdown--passed {
  border-color: var(--border-strong);
  background: var(--surface-sunken);
}

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

.entry-card__name {
  font-size: 1.125rem;
  font-weight: 650;
}

.entry-card__pick {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.entry-card__pick-team {
  font-size: 1.0625rem;
  font-weight: 700;
}

/* --- Used teams -------------------------------------------------------- */

.used-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.used-teams li {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1875rem 0.4375rem;
  border-radius: 6px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.used-teams b {
  font-weight: 650;
}

.used-teams span {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* --- Matchup rows: the two-tap pick flow -------------------------------- */

.matchup {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 0.75rem;
}

.matchup + .matchup {
  margin-top: 0.75rem;
}

.matchup--locked {
  background: var(--surface-sunken);
  opacity: 0.75;
}

.matchup__when {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.625rem;
  align-items: baseline;
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.matchup__when strong {
  color: var(--text);
  font-weight: 650;
}

.matchup__teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

/* A team button. Big, thumb-reachable, and legible at 200% zoom. */
.team {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  min-height: 3.75rem;
  padding: 0.625rem 0.75rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}

.team:hover {
  border-color: var(--accent);
}

.team__abbr {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.team__meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.team--chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.team--chosen .team__abbr::after {
  content: " ✓";
}

.team[disabled] {
  cursor: not-allowed;
  background: var(--surface-sunken);
  border-color: var(--border);
  border-style: dashed;
  color: var(--text-muted);
}

.team[disabled] .team__abbr {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

/* --- Picks visibility table -------------------------------------------- */

.picks-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.picks-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  /* Wraps rather than squeezing: a row with several pills would otherwise crush
     the name column to nothing, and `overflow-wrap: anywhere` then breaks it one
     character per line. */
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  padding: 0.6875rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.picks-list li:last-child {
  border-bottom: 0;
}

.picks-list__name {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.picks-list__pick {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.375rem;
  font-weight: 650;
}

.picks-list__hidden {
  color: var(--text-muted);
  font-weight: 500;
}

.result--win {
  color: var(--alive);
}

.result--loss,
.result--tie {
  color: var(--danger);
}

/* --- Week navigation ---------------------------------------------------- */

.week-nav {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.week-nav a {
  flex: 0 0 auto;
  min-width: 2.75rem;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.week-nav a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

/* --- Group nav --------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.tabs a {
  flex: 0 0 auto;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* --- Definition-style rule list ---------------------------------------- */

.rules-list {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.rules-list > div {
  display: grid;
  gap: 0.125rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.rules-list dt {
  font-weight: 650;
}

.rules-list dd {
  margin: 0;
  color: var(--text-muted);
}

/* --- Copy-to-clipboard block ------------------------------------------- */

.copy-block {
  width: 100%;
  min-height: 9rem;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
  white-space: pre;
}

/* --- Pool switcher -------------------------------------------------------
   The pool name in the masthead doubles as the switcher when someone is in
   more than one pool. A <details> disclosure, so it needs no JavaScript and
   the entries stay real links.
   ------------------------------------------------------------------------- */

.pool-switch {
  position: relative;
  min-width: 0;
}

/* `display: flex` rather than inline-flex: as a list-item the summary reserves a
   line box for its disclosure marker, which pushed the label onto a second row. */
.pool-switch > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.25rem 0.375rem 0.25rem 0;
  font-weight: 650;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

/* Kept as separate rules on purpose. An unrecognised vendor pseudo-element in a
   selector *list* invalidates the entire rule, so combining these two would mean
   neither applies and the default triangle shows through. */
.pool-switch > summary::-webkit-details-marker {
  display: none;
}

.pool-switch > summary::marker {
  content: '';
}

.pool-switch__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Leaves room for "Sign out" at 375px. */
  max-width: 10.5rem;
}

@media (min-width: 30rem) {
  .pool-switch__name {
    max-width: 20rem;
  }
}

.pool-switch__caret {
  flex: 0 0 auto;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.pool-switch[open] .pool-switch__caret {
  transform: rotate(180deg);
}

.pool-switch__panel {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 60;
  min-width: 15rem;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.pool-switch__label {
  padding: 0.375rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pool-switch__panel a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.pool-switch__panel a[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent);
}
