:root {
  color-scheme: light;
  --ink: #203b32;
  --muted: #66766d;
  --paper: #fffef9;
  --canvas: #f4f7ee;
  --line: #c4d0c0;
  --accent: #35552f;
  --accent-soft: #edf3e7;
  --shadow: 0 14px 38px rgb(42 64 43 / 9%);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

html[data-color-mode="dark"] {
  color-scheme: dark;
  --ink: #e8edf7;
  --muted: #aab7ce;
  --paper: #222b3b;
  --canvas: #141a2a;
  --line: #45516d;
  --accent-soft: #29354c;
  --shadow: 0 14px 38px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-image: radial-gradient(#c6d2bf 0.75px, transparent 0.75px);
  background-size: 18px 18px;
}

html[data-color-mode="dark"] body {
  background-image: radial-gradient(#35415b 0.75px, transparent 0.75px);
}

html[data-color-mode="dark"] body[data-theme] { --accent-soft: #29354c; }

body[data-theme="teams"] { --accent: #356843; --accent-soft: #eaf3e8; }
body[data-theme="bingo"] { --accent: #a54232; --accent-soft: #fbede7; }
body[data-theme="bracket"] { --accent: #176f73; --accent-soft: #e6f2f0; }
body[data-theme="challenges"] { --accent: #b44d36; --accent-soft: #fbede7; }
body[data-theme="wheel"] { --accent: #9b7115; --accent-soft: #f8f1dc; }
body[data-theme="scorekeeper"] { --accent: #286f78; --accent-soft: #e7f2f3; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
  padding: 25px 0 56px;
}

.site-header {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 38px;
}

.site-footer {
  display: flex;
  width: min(1240px, calc(100% - 48px));
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin: 24px auto 0;
  border-top: 1px solid var(--line);
  padding: 13px 0 24px;
  color: var(--muted);
  font-size: 11px;
}

.site-footer [data-version] { font-variant-numeric: tabular-nums; }

.theme-toggle {
  position: relative;
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-switch {
  position: relative;
  width: 32px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--line);
  transition: background 120ms ease;
}

.theme-switch::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paper);
  content: "";
  transition: transform 120ms ease;
}

.theme-toggle input:checked + .theme-switch { background: var(--accent); }
.theme-toggle input:checked + .theme-switch::after { transform: translateX(14px); }
.theme-toggle input:focus-visible + .theme-switch { outline: 3px solid var(--accent); outline-offset: 3px; }

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.site-mark {
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: #b9e65b;
  font-size: 14px;
}

html[data-color-mode="dark"] .site-mark {
  border-color: #657895;
  background: #354966;
  color: #e8edf7;
}

.hub-link {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  text-underline-offset: 4px;
}

.hub-link:hover { color: var(--accent); text-decoration: underline; }
.hub-link:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.app-heading { margin-bottom: 25px; }
.app-eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.app-heading h1 { margin: 0; font: 700 42px/1 Georgia, "Times New Roman", serif; }
.app-heading p { max-width: 650px; margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.app-grid {
  display: grid;
  grid-template-columns: minmax(255px, 315px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel h2 { margin: 0 0 16px; font: 700 20px/1.15 Georgia, "Times New Roman", serif; }
.panel h3 { margin: 0; font-size: 13px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 900; }
.input, .textarea, .select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #bdcabc;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

html[data-color-mode="dark"] .input,
html[data-color-mode="dark"] .textarea,
html[data-color-mode="dark"] .select,
html[data-color-mode="dark"] .match-button { background: #1b2435; color: var(--ink); }
.textarea { min-height: 175px; resize: vertical; line-height: 1.55; }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 23%, transparent); outline-offset: 1px; }
.field-hint, .muted { color: var(--muted); font-size: 11px; line-height: 1.45; }

.button-row { display: flex; flex-wrap: wrap; gap: 9px; }
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--paper);
  box-shadow: 0 2px 0 var(--ink);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.button-primary { background: var(--accent-soft); }
.button:disabled { opacity: 0.48; cursor: not-allowed; }
.button-small { min-height: 32px; padding: 0 10px; font-size: 11px; }

.status { min-height: 18px; margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.result-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.result-heading h2 { margin: 0; }
.badge { color: var(--accent); font-size: 10px; font-weight: 900; }
.empty-state { padding: 36px 14px; color: var(--muted); font-size: 13px; text-align: center; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }
.team-card { min-width: 0; border-left: 3px solid var(--accent); padding: 4px 10px 8px; }
.team-card h3 { margin: 0 0 9px; color: var(--accent); }
.team-card ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.team-card li { border-bottom: 1px solid #e2e8df; padding-bottom: 6px; font-size: 12px; overflow-wrap: anywhere; }

html[data-color-mode="dark"] .team-card li,
html[data-color-mode="dark"] .round-list li { border-color: #3c4a63; }

.bracket-board { display: flex; min-height: 250px; align-items: stretch; gap: 16px; overflow-x: auto; padding: 2px 2px 12px; }
.bracket-round { display: flex; min-width: 170px; flex: 1 0 170px; flex-direction: column; justify-content: space-around; gap: 12px; }
.bracket-round h3 { margin-bottom: 4px; color: var(--accent); }
.match { display: grid; gap: 5px; border-left: 2px solid var(--line); padding: 7px 0 7px 9px; }
.match-button { min-height: 32px; border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; background: #fff; font-size: 11px; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.match-button:hover:not(:disabled), .match-button.is-winner { border-color: var(--accent); background: var(--accent-soft); }
.match-button:disabled { color: var(--muted); cursor: default; }
.match-placeholder { color: var(--muted); font-size: 11px; }

.challenge-card { display: grid; min-height: 205px; align-content: center; gap: 16px; border-left: 4px solid var(--accent); padding: 20px; background: var(--accent-soft); }
.challenge-category { color: var(--accent); font-size: 10px; font-weight: 900; text-transform: uppercase; }
.challenge-text { font: 700 27px/1.2 Georgia, "Times New Roman", serif; }
.challenge-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.challenge-controls .field { min-width: 145px; flex: 1; margin: 0; }
.challenge-actions { justify-content: center; margin-top: 14px; }
.timer { color: var(--accent); font: 700 28px/1 Georgia, "Times New Roman", serif; font-variant-numeric: tabular-nums; }

.wheel-layout { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(240px, 0.85fr); align-items: center; gap: 24px; }
.wheel-wrap { position: relative; width: min(100%, 440px); margin: 0 auto; }
.wheel-canvas { display: block; width: 100%; height: auto; }
.wheel-pointer { position: absolute; z-index: 1; top: -9px; left: 50%; width: 0; height: 0; transform: translateX(-50%); border-right: 13px solid transparent; border-left: 13px solid transparent; border-top: 25px solid var(--ink); }
.wheel-result { min-height: 34px; margin-top: 12px; color: var(--accent); font: 700 21px/1.2 Georgia, "Times New Roman", serif; text-align: center; }

.score-table-wrap { overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.score-table th, .score-table td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; }
.score-table th { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.score-table td:last-child, .score-table th:last-child { text-align: right; }
.score-rank { color: var(--accent); font-weight: 900; }
.round-list { display: grid; gap: 8px; margin: 15px 0 0; padding: 0; list-style: none; }
.round-list li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #e2e8df; padding: 8px 0; font-size: 11px; }

.rule-card { display: grid; min-height: 205px; align-content: center; gap: 16px; border-left: 4px solid var(--accent); padding: 20px; background: var(--accent-soft); }
.rule-text { font: 700 25px/1.25 Georgia, "Times New Roman", serif; }

@media (max-width: 800px) {
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .wheel-layout { grid-template-columns: minmax(0, 1fr); }
  .wheel-wrap { width: min(100%, 400px); }
}

@media (max-width: 520px) {
  .page-shell { width: calc(100% - 28px); padding-top: 16px; }
  .site-header { margin-bottom: 28px; }
  .site-footer { width: calc(100% - 28px); font-size: 10px; }
  .app-heading h1 { font-size: 36px; }
  .panel { padding: 16px; }
  .challenge-text, .rule-text { font-size: 23px; }
  .bracket-board { gap: 10px; }
}

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