:root {
  --bg: #120e0c;
  --bg-2: #1a1512;
  --panel: #211a16;
  --line: #3a2d25;
  --text: #f6efe9;
  --muted: #ae9a8c;
  --chalk: #fbf3ea;
  --ball: #f58426;
  --accent: var(--ball);  /* replaced with team color during a game */
  --team: #3a2418;        /* team primary */
  --hit: #5fd38d;
  --miss: #ff7a6b;
  --radius: 10px;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    /* hardwood planks */
    repeating-linear-gradient(90deg, transparent 0 63px, rgba(255,255,255,.022) 63px 64px),
    /* center-court circle glow */
    radial-gradient(circle at 50% -120px, transparent 0 239px, rgba(245,132,38,.10) 240px 242px, transparent 243px),
    radial-gradient(1100px 560px at 50% -200px, #3a2216 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.screen { max-width: 1240px; margin: 0 auto; padding: 32px 24px 48px; }

.kicker {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Home ---------- */
.hero { padding: 24px 0 8px; }
.hero h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(48px, 9vw, 96px);
  line-height: .9;
  margin: 6px 0 12px;
  text-transform: uppercase;
  letter-spacing: -.01em;
}
.hero h1 span { color: var(--accent); }
.lede { max-width: 58ch; color: var(--muted); margin: 0; font-size: 18px; }

.options {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center;
  margin: 28px 0 8px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.opt { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; }
.opt > span:first-child { color: var(--muted); }
.opt select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
}
.all-btn { margin-left: auto; background: var(--ball); color: #1a0d04; display: inline-flex; gap: 10px; align-items: baseline; }
.all-btn .best { color: rgba(26,13,4,.7); font-size: 14px; }
.all-btn .best b { color: #1a0d04; }

.conferences { display: grid; gap: 28px; margin-top: 24px; }
.conference h2 {
  font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: .04em;
  margin: 0 0 12px; text-transform: uppercase;
}
.divisions { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.division { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.division h3 { margin: 0 0 8px 4px; }
.team-list { display: grid; gap: 6px; }

.team-card {
  --c: #333;
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 8px 12px 8px 8px; text-align: left;
  background: var(--bg-2); border: 1px solid transparent; border-left: 4px solid var(--c);
  border-radius: 8px; cursor: pointer; text-transform: none; letter-spacing: 0; color: var(--text);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.team-card:hover, .team-card:focus-visible {
  background: #261e19; border-color: var(--line); border-left-color: var(--c); transform: translateX(2px); outline: none;
}
.team-card img { width: 40px; height: 40px; object-fit: contain; }
.team-card .tname { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.05; text-transform: uppercase; }
.team-card .tloc { display: block; font-family: var(--body); font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.best { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.best b { color: var(--hit); font-weight: 700; }

.status { color: var(--muted); margin: 16px 0; }
.status.error { color: var(--miss); }
.status button { margin-left: 8px; }
.foot { color: var(--muted); font-size: 13px; margin-top: 36px; max-width: 90ch; }

/* ---------- Buttons ---------- */
button {
  border: 0; border-radius: 8px; padding: 10px 16px; cursor: pointer;
  font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: .05em; text-transform: uppercase;
  background: var(--chalk); color: #140c07;
}
button:disabled { opacity: .4; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,.25); }
button.ghost:hover { border-color: rgba(255,255,255,.6); }
button.danger { background: transparent; color: var(--miss); border: 1px solid rgba(255,122,107,.5); }
button.danger:hover:not(:disabled) { background: rgba(255,122,107,.12); }

/* ---------- Game header ---------- */
.team-band {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px;
  padding: 16px 20px; border-radius: 14px;
  background:
    linear-gradient(100deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.45)),
    var(--team);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.team-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.team-id img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.team-id img:not([src]), .team-id img[src=""] { display: none; }
.team-id .kicker { color: rgba(255,255,255,.75); }
.team-id h2 {
  margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(28px, 4vw, 44px);
  line-height: 1; text-transform: uppercase; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.scoreboard { display: flex; gap: 8px; }
.sb-cell {
  display: grid; justify-items: center; min-width: 96px; padding: 6px 14px;
  background: rgba(0,0,0,.55); border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
}
.sb-label { font-family: var(--display); font-weight: 600; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.65); }
.sb-value { font-family: var(--display); font-weight: 800; font-size: 32px; line-height: 1.05; font-variant-numeric: tabular-nums; color: #fff; }
.sb-value.low { color: var(--miss); }

/* ---------- Input ---------- */
.play-bar { display: flex; gap: 12px; align-items: flex-start; margin: 20px 0 8px; position: sticky; top: 0; z-index: 5; padding: 10px 0; background: linear-gradient(var(--bg) 75%, transparent); }
.input-wrap { flex: 1; }
#guess {
  width: 100%; padding: 14px 18px; font-size: 22px; font-weight: 500;
  background: var(--panel); border: 2px solid var(--line); border-radius: 10px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#guess:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
#guess.shake { animation: shake .3s ease; border-color: var(--miss); }
.play-bar > button { height: 58px; }
.feedback { margin: 6px 4px 0; min-height: 1.45em; font-size: 15px; color: var(--muted); }
.feedback.good { color: var(--hit); }
.feedback.bad { color: var(--miss); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- Result banner ---------- */
.result {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px;
  margin: 8px 0 16px; padding: 16px 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--accent);
}
.result-line { margin: 2px 0 0; font-family: var(--display); font-weight: 700; font-size: 28px; }
.result-actions { display: flex; gap: 10px; }

/* ---------- Single-team board: five jerseys ---------- */
.lineup { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-top: 8px; }
.jersey {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 6px;
  padding: 18px 12px 16px; min-height: 210px; text-align: center;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--team) 70%, transparent), transparent 75%),
    var(--panel);
  border: 1px solid var(--line); border-radius: 14px;
  /* tank-top neckline and arm holes */
  clip-path: polygon(0 0, 22% 0, 32% 9%, 68% 9%, 78% 0, 100% 0, 100% 100%, 0 100%);
}
.jersey .pos {
  margin-top: 10px; font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .14em;
  color: rgba(255,255,255,.8);
}
.jersey .num {
  font-family: var(--display); font-weight: 800; font-size: clamp(56px, 8vw, 92px); line-height: .9;
  color: var(--chalk); font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 2px color-mix(in srgb, var(--accent) 80%, transparent);
  paint-order: stroke fill;
}
.jersey .num.none { color: var(--muted); -webkit-text-stroke: 0; }
.jersey .name {
  min-height: 2.5em; display: grid; place-items: center; width: 100%;
  font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.1; text-transform: uppercase;
}
.jersey .name:empty::before { content: ""; width: 70%; height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; }
.jersey.got { border-color: color-mix(in srgb, var(--hit) 60%, transparent); }
.jersey.got .name { color: var(--hit); }
.jersey.missed .name { color: var(--miss); }
.jersey.flash { animation: pop .7s ease; }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.05); background-color: color-mix(in srgb, var(--hit) 30%, var(--panel)); } 100% { transform: none; } }

/* ---------- All-teams board ---------- */
.league { display: grid; gap: 24px; margin-top: 8px; }
.league h3.conf { margin: 0 0 10px; font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: .04em; text-transform: uppercase; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: start; }
/* Wide screens: five across, so each division (five teams) gets its own row. */
@media (min-width: 1180px) {
  .groups { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .groups .slot { grid-template-columns: 24px 26px 1fr; gap: 6px; padding: 3px 6px; }
  .groups .slot .num { font-size: 18px; }
  .groups .slot .name { font-size: 14px; }
}
.group { --c: #555; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--c); border-radius: var(--radius); overflow: hidden; }
.group-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.group-head img { width: 26px; height: 26px; object-fit: contain; }
.group-head h4 { flex: 1; margin: 0; font-family: var(--display); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .04em; }
.group-head .count { font-family: var(--display); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.group.done .count { color: var(--hit); }
.group .err { margin: 0; padding: 10px 12px; color: var(--miss); font-size: 14px; }
.slots { list-style: none; margin: 0; padding: 6px; display: grid; gap: 3px; }
.slot {
  display: grid; grid-template-columns: 34px 38px 1fr; align-items: center; gap: 8px;
  min-height: 32px; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.02);
}
.slot .pos {
  justify-self: start; font-family: var(--display); font-weight: 700; font-size: 13px; letter-spacing: .06em;
  padding: 1px 6px; border-radius: 4px; background: rgba(255,255,255,.08); color: var(--muted);
}
.slot .num { font-family: var(--display); font-weight: 800; font-size: 20px; text-align: right; color: var(--chalk); font-variant-numeric: tabular-nums; }
.slot .num.none { color: var(--muted); font-weight: 600; }
.slot .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.slot .name:empty::before { content: ""; display: block; height: 2px; margin-top: 12px; background: rgba(255,255,255,.08); border-radius: 2px; }
.slot.got { background: color-mix(in srgb, var(--hit) 12%, transparent); }
.slot.got .name { color: var(--hit); }
.slot.got .pos { background: color-mix(in srgb, var(--hit) 22%, transparent); color: var(--text); }
.slot.missed .name { color: var(--miss); font-weight: 500; }
.slot.flash { animation: flash .9s ease; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--hit) 55%, transparent); transform: scale(1.02); } 100% { transform: none; } }

@media (max-width: 860px) {
  .lineup { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .jersey { min-height: 180px; }
}
@media (max-width: 720px) {
  .screen { padding: 20px 14px 40px; }
  .all-btn { margin-left: 0; }
  .team-band { grid-template-columns: 1fr; gap: 12px; }
  .team-band #btn-back { justify-self: start; }
  .scoreboard { justify-content: stretch; }
  .sb-cell { flex: 1; }
  .team-id img { width: 48px; height: 48px; }
  #guess { font-size: 18px; }
  .play-bar > button { height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
