/* Fat Bear Pool — Alliance IP palette, sampled from the logo:
   #3d9be8 (the "IP" blue) and #585450 (the wordmark charcoal). */

:root {
  --brand-blue: #3d9be8;
  --brand-blue-600: #2b7fc7;
  --brand-blue-700: #1f65a3;
  --brand-blue-50: #eaf4fd;
  --brand-blue-100: #d2e8fa;

  --charcoal-900: #2f2d2b;
  --charcoal-800: #3f3c39;
  --charcoal-700: #4c4945;
  --charcoal-600: #585450;
  --charcoal-400: #8b8781;

  --slate-50: #f6f7f8;
  --slate-100: #eceef0;
  --slate-200: #dde0e3;

  --amber-400: #e0a33e;

  /* Semantic, deliberately not brand blue — an error must not read as a link. */
  --danger-600: #c0392b;
  --danger-bg: #fdecea;
  --danger-text: #7d2118;
  --success-600: #2f7a52;
  --success-bg: #e8f3ec;
  --success-text: #1a4c33;

  --bg: var(--slate-50);
  --surface: #ffffff;
  --text: var(--charcoal-900);
  --text-muted: var(--charcoal-600);
  --border: var(--slate-200);
  --accent: var(--brand-blue-600);
  --header-bg: #ffffff;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgb(47 45 43 / 8%), 0 2px 8px rgb(47 45 43 / 6%);
  --shadow-md: 0 4px 16px rgb(47 45 43 / 14%);
  --focus: 0 0 0 3px #fff, 0 0 0 6px var(--brand-blue-600);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1e22;
    --surface: #23282d;
    --text: #eceef0;
    --text-muted: #a8aeb5;
    --border: #363c43;
    --accent: var(--brand-blue);
    --header-bg: #14181b;
    --brand-blue-50: #17303f;
    --brand-blue-100: #1d4055;
    --danger-bg: #3a1a16; --danger-text: #ffb3a7;
    --success-bg: #14311f; --success-text: #a8e0c0;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 4px 16px rgb(0 0 0 / 45%);
    --focus: 0 0 0 3px #1a1e22, 0 0 0 6px var(--brand-blue);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  font-size: 17px;
  line-height: 1.55;
}

h1, h2, h3, .ui {
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

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

/* ------------------------------------------------------------- structure */

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

.masthead {
  background: var(--header-bg);
  color: var(--text);
  padding: 0.9rem 0;
  border-bottom: 4px solid var(--brand-blue);
  box-shadow: var(--shadow-sm);
}
.masthead .wrap {
  display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
}

/* The logo is dark artwork on transparency, so in dark mode it sits on a
   white chip rather than being recolored. */
.brand-logo {
  display: block; height: 30px; width: auto; flex: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .brand-logo {
    background: #fff; padding: 5px 8px; border-radius: 6px; height: 40px;
    box-sizing: content-box;
  }
}

.masthead .divider {
  width: 1px; align-self: stretch; background: var(--border); flex: none;
}
.masthead h1 {
  margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em;
}
.masthead .year {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--brand-blue-600); font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .masthead .year { color: var(--brand-blue); }
}
.masthead .mark { font-size: 1.5rem; line-height: 1; }

@media (max-width: 520px) {
  .masthead .wrap { gap: 0.6rem; }
  .masthead .divider { display: none; }
  .brand-logo { height: 24px; }
  .masthead h1 { font-size: 1rem; }
}

main { padding: 1.5rem 0 5rem; }

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.panel h2 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.panel .hint { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.92rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; max-width: 26rem; }
.field label { font-weight: 600; font-size: 0.92rem; font-family: ui-sans-serif, system-ui, sans-serif; }
.field .help { color: var(--text-muted); font-size: 0.85rem; }

input[type='text'], input[type='password'], select {
  font: inherit; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
  min-height: 44px; width: 100%;
}
input[aria-invalid='true'] { border-color: var(--danger-600); }

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

.btn {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.95rem; font-weight: 600;
  padding: 0.65rem 1.1rem; min-height: 44px;
  border-radius: 8px; border: 1.5px solid transparent;
  cursor: pointer; background: var(--charcoal-700); color: #fff;
}
.btn:hover:not(:disabled) { background: var(--charcoal-800); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand-blue-600); }
.btn-primary:hover:not(:disabled) { background: var(--brand-blue); }
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--slate-100); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .btn-ghost:hover:not(:disabled) { background: #2d333a; }
}
.btn-sm { font-size: 0.85rem; padding: 0.4rem 0.7rem; min-height: 36px; }

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

.board-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.board-head h2 { margin: 0; font-size: 1.05rem; }
.tally { color: var(--text-muted); font-size: 0.9rem; font-family: ui-sans-serif, system-ui, sans-serif; }

.bear-grid {
  display: grid; gap: 0.9rem; list-style: none; margin: 0; padding: 0;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.bear-card { position: relative; }

.bear-card input[type='radio'] {
  position: absolute; opacity: 0; width: 1px; height: 1px;
}

.bear-card label {
  display: block; cursor: pointer;
  background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius);
  overflow: hidden; height: 100%;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.bear-card label:hover { border-color: var(--brand-blue); box-shadow: var(--shadow-md); }
.bear-card input:focus-visible + label { box-shadow: var(--focus); }
.bear-card input:checked + label {
  border-color: var(--brand-blue-600);
  box-shadow: var(--shadow-md), inset 0 0 0 2px var(--brand-blue-600);
}

/* The official Fat Bear Week photos are wide June/September comparisons. */
.bear-photo {
  aspect-ratio: 2.4 / 1; width: 100%; display: block; object-fit: cover;
  background: var(--charcoal-800);
}
.bear-photo-fallback {
  aspect-ratio: 2.4 / 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--charcoal-700), var(--charcoal-900));
  color: var(--slate-100);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em;
}

.bear-body { padding: 0.7rem 0.8rem 0.85rem; }
.bear-name {
  margin: 0; font-size: 1.05rem; font-weight: 700;
  font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.25;
}
.bear-num { color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.bear-blurb {
  margin: 0.35rem 0 0; font-size: 0.88rem; color: var(--text-muted); line-height: 1.45;
}
.bear-credit {
  margin: 0.4rem 0 0; font-size: 0.7rem; color: var(--text-muted); opacity: 0.85;
}

.badge {
  display: inline-block; font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; padding: 0.2rem 0.5rem; border-radius: 999px;
  margin-bottom: 0.4rem;
}
.badge-open { background: var(--success-bg); color: var(--success-text); }
.badge-taken { background: var(--slate-200); color: var(--charcoal-600); }
.badge-elim { background: #ede8e2; color: #7a6a5c; }
.badge-winner { background: var(--amber-400); color: #3a2a08; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .badge-open { background: #1f4633; color: #a8e0c0; }
  :root:not([data-theme='light']) .badge-taken { background: #2b4034; color: #cdd6cf; }
  :root:not([data-theme='light']) .badge-elim { background: #2a2622; color: #9c9186; }
}

/* A taken or eliminated bear is visibly out of play but still readable. */
.bear-card.is-unavailable label { cursor: not-allowed; opacity: 0.72; }
.bear-card.is-unavailable label:hover { border-color: var(--border); box-shadow: none; }
.bear-card.is-unavailable .bear-photo,
.bear-card.is-unavailable .bear-photo-fallback { filter: grayscale(0.75); }
.taken-by {
  margin: 0.4rem 0 0; font-size: 0.88rem; font-weight: 600;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

/* ------------------------------------------------------------ confirm bar */

.confirm-bar {
  position: sticky; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 2px solid var(--brand-blue-600);
  box-shadow: 0 -4px 16px rgb(26 23 19 / 12%);
  padding: 0.85rem 0; margin-top: 1.25rem;
}
.confirm-bar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.confirm-bar p { margin: 0; font-size: 0.95rem; }
.confirm-bar[hidden] { display: none; }

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

.notice {
  padding: 0.85rem 1rem; border-radius: var(--radius);
  border: 1.5px solid; margin-bottom: 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.95rem;
}
.notice-error { background: var(--danger-bg); border-color: var(--danger-600); color: var(--danger-text); }
.notice-success { background: var(--success-bg); border-color: var(--success-600); color: var(--success-text); }
.notice-info { background: var(--slate-100); border-color: var(--border); color: var(--text); }

.success-card { text-align: center; padding: 2rem 1.25rem; }
.success-card .big { font-size: 2.5rem; margin: 0 0 0.5rem; }
.success-card h2 { font-size: 1.5rem; margin: 0 0 0.4rem; }

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

.assignments { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.assignments caption { text-align: left; color: var(--text-muted); font-size: 0.9rem; padding-bottom: 0.5rem; }
.assignments th, .assignments td {
  text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border);
}
.assignments th {
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted);
}
.assignments tbody tr:last-child td { border-bottom: none; }

.empty {
  text-align: center; padding: 2rem 1rem; color: var(--text-muted);
  font-size: 0.95rem;
}

.skeleton {
  background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 50%, var(--slate-100) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius); height: 280px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition: none !important; }
}

footer {
  border-top: 1px solid var(--border); margin-top: 2rem; padding: 1.25rem 0 2rem;
  color: var(--text-muted); font-size: 0.85rem;
}
footer a { color: inherit; }
.footer-brand { margin: 0 0 0.9rem; }
.footer-brand .brand-logo { height: 26px; opacity: 0.85; }

.bear-group {
  display: block; font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.2rem;
}

.photo-caption {
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.66rem;
  color: var(--text-muted); text-align: center;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.3rem 0 0; margin: 0;
}

/* ------------------------------------------------------------- vote bar */

.vote-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: var(--brand-blue-50);
  border: 1px solid var(--brand-blue-100);
  border-left: 5px solid var(--brand-blue);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem; margin-bottom: 1.5rem;
}
.vote-bar h2 {
  margin: 0; font-size: 1rem; line-height: 1.3;
}
.vote-bar p {
  margin: 0.2rem 0 0; font-size: 0.88rem; color: var(--text-muted);
}
.vote-bar .btn { flex: none; }
@media (max-width: 520px) {
  .vote-bar { flex-direction: column; align-items: stretch; }
  .vote-bar .btn { width: 100%; text-align: center; }
}

/* -------------------------------------------------------------- bracket */

.bracket-scroll { overflow-x: auto; padding-bottom: 0.5rem; }

.bracket-grid {
  display: flex; gap: 1.1rem; align-items: stretch; min-width: max-content;
}

.bracket-col { display: flex; flex-direction: column; min-width: 190px; flex: 1; }

.bracket-col-head {
  margin: 0 0 0.6rem; font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); font-weight: 700;
}
.bracket-col-head span {
  display: block; font-size: 0.72rem; letter-spacing: 0.03em;
  text-transform: none; font-weight: 500; color: var(--charcoal-400);
}

/* space-around is what produces the stepped bracket alignment. */
.bracket-col-body {
  display: flex; flex-direction: column; justify-content: space-around;
  gap: 0.5rem; flex: 1;
}

.matchup {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); overflow: hidden;
}
.matchup-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
  padding: 0.3rem 0.55rem; background: var(--slate-100);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .matchup-head { background: #2d333a; }
}
.clash-badge {
  background: var(--brand-blue); color: #fff; border-radius: 999px;
  padding: 0.05rem 0.4rem; font-size: 0.62rem; letter-spacing: 0.04em;
}

.slot {
  display: flex; align-items: center; gap: 0.4rem; width: 100%;
  padding: 0.45rem 0.55rem; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--text); text-align: left;
  font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.82rem;
  cursor: pointer; min-height: 40px;
}
.slot:first-of-type { border-top: 0; }
.slot:hover { background: var(--brand-blue-50); }
.slot-bear { font-weight: 600; flex: 1; line-height: 1.25; }
.slot-num { color: var(--text-muted); font-weight: 700; }
.slot-owner {
  font-size: 0.72rem; color: var(--brand-blue-700); font-weight: 700;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .slot-owner { color: var(--brand-blue); }
}
.slot-unclaimed { color: var(--charcoal-400); font-weight: 500; font-style: italic; }
.slot-check { color: var(--success-600); font-weight: 700; }
.slot-won { background: var(--success-bg); }
.slot-lost { opacity: 0.5; text-decoration: line-through; }
.slot-empty {
  color: var(--charcoal-400); font-style: italic; cursor: default;
  font-size: 0.75rem;
}
.slot.is-traced {
  background: var(--brand-blue); color: #fff;
}
.slot.is-traced .slot-num,
.slot.is-traced .slot-owner { color: #fff; }

tr.is-out td { opacity: 0.55; }

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

@media (max-width: 480px) {
  body { font-size: 16px; }
  .bear-grid { grid-template-columns: 1fr; gap: 0.7rem; }
  .confirm-bar .wrap { flex-direction: column; align-items: stretch; }
  .confirm-bar .btn { width: 100%; }
}
