:root {
  --bg: #140f0c;
  --ink: #1c140f;
  --cream: #f6f0e4;
  --cream-ink: #f3eadc;
  --muted: #c8bbae;
  --quiet: #8d7f72;
  --line: rgba(28, 20, 15, 0.18);
  --daub: rgba(196, 42, 36, 0.58);
  --card-shadow: 0 18px 40px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 480px at 50% -12%, #3c2c24 0%, transparent 55%),
    var(--bg);
  color: var(--cream-ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

button, input { font: inherit; }

.wrap {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 14px 16px 24px;
}

.eyebrow {
  margin: 0;
  color: var(--quiet);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pattern {
  margin: 2px 0 0;
  font-size: 1.75rem;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f0b429;
  color: var(--ink);
  font-weight: 700;
}

.call-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 8px;
}

.ball {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 -8px 12px rgba(0, 0, 0, 0.25), 0 8px 18px rgba(0, 0, 0, 0.35);
  background: #2a241f;
  color: var(--cream);
}

.ball[data-letter="B"] { background: #1d4e89; color: #fff; }
.ball[data-letter="I"] { background: #b4332a; color: #fff; }
.ball[data-letter="N"] { background: #2c333a; color: #fff; }
.ball[data-letter="G"] { background: #1c7a43; color: #fff; }
.ball[data-letter="O"] { background: #f0b429; color: var(--ink); }

.ball .face {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 0.9;
}

.ball small {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
}

.call-meta { margin: 0; color: var(--muted); }
.call-meta strong {
  display: block;
  color: var(--cream);
  font-size: 1.05rem;
  font-weight: 650;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 0 10px;
  padding-bottom: 2px;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: #2a221c;
  color: var(--cream-ink);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.chip:first-child { outline: 1px solid #e0a106; }

.card {
  background-color: var(--cream);
  background-image: radial-gradient(rgba(80, 50, 20, 0.045) 0.7px, transparent 0.7px);
  background-size: 7px 7px;
  color: var(--ink);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--card-shadow);
}

.heads, .grid-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.heads span {
  display: grid;
  place-items: center;
  height: 28px;
  margin: 0 3px 6px;
  border-radius: 7px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.heads span:nth-child(1) { background: #1d4e89; color: #fff; }
.heads span:nth-child(2) { background: #b4332a; color: #fff; }
.heads span:nth-child(3) { background: #2c333a; color: #fff; }
.heads span:nth-child(4) { background: #1c7a43; color: #fff; }
.heads span:nth-child(5) { background: #f0b429; color: var(--ink); }

.grid {
  border: 2px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
  background: var(--cream);
}

.square {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: clamp(1rem, 4.6vw, 1.45rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.grid-row .square:last-child { border-right: 0; }
.grid-row:last-child .square { border-bottom: 0; }

.square:focus-visible {
  outline: 3px solid #1d4e89;
  outline-offset: -3px;
  z-index: 1;
}

.square.free {
  cursor: default;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

.square.free .num {
  width: 70%;
  height: 70%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(240, 180, 41, 0.45);
}

.num { position: relative; z-index: 1; }

.square.marked::before {
  content: "";
  position: absolute;
  width: 76%;
  height: 70%;
  border-radius: 50%;
  background: var(--daub);
  transform: rotate(-14deg);
}

.square.called:not(.marked) {
  box-shadow: inset 0 0 0 2px #c42824;
}

.square.needed::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.4;
}

.switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #241c17;
}

.switch-title {
  display: block;
  font-weight: 700;
}

.switch-help {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.track {
  position: relative;
  width: 52px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #3d342c;
  transition: background 0.15s linear;
}

.track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cream);
  transition: transform 0.15s linear;
}

.switch input:checked + .track { background: #1c7a43; }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid #f0b429; outline-offset: 2px; }
.switch input:disabled + .track { opacity: 0.45; }

.bingo {
  width: 100%;
  height: 56px;
  margin-top: 10px;
  border: 0;
  border-radius: 999px;
  background: #3a322c;
  color: #efe6da;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  touch-action: manipulation;
}

.bingo.lit {
  background: #ff4d3a;
  color: #1c140f;
}

.bingo:focus-visible { outline: 3px solid #f0b429; outline-offset: 3px; }
.bingo:disabled { cursor: default; opacity: 0.7; }

@media (prefers-reduced-motion: no-preference) {
  .bingo.lit { animation: glow 1.5s ease-in-out infinite; }
  @keyframes glow {
    50% { box-shadow: 0 0 0 6px rgba(255, 77, 58, 0.28); }
  }
}

.status {
  min-height: 1.3em;
  margin: 6px 0 0;
  color: var(--muted);
  text-align: center;
}

.fixture {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(243, 234, 220, 0.14);
  color: var(--quiet);
  font-size: 0.85rem;
}

.fixture p { margin: 0 0 8px; }

.fixture-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.scripted,
.fixture-actions button {
  border: 1px solid rgba(243, 234, 220, 0.28);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  cursor: pointer;
}

.scripted { margin-left: auto; flex: 0 0 auto; }

#fixture-rulings { justify-content: center; margin-top: 4px; }

.sample-note {
  align-self: center;
  color: var(--quiet);
  font-size: 0.85rem;
}

.scripted:disabled,
.fixture-actions button:disabled { opacity: 0.4; cursor: default; }

.scripted:focus-visible,
.fixture-actions button:focus-visible { outline: 2px solid #f0b429; outline-offset: 2px; }

.waiting {
  margin: 28px 0;
  color: var(--muted);
  font-size: 1.15rem;
}

@media (max-width: 360px) {
  .ball { width: 72px; height: 72px; }
  .pattern { font-size: 1.7rem; }
}
