/* Nuffy — dusk-stadium scoreboard design system.
   Palette: Turf #16241C, Panel #1E2F24, Chalk #F5F3EA, Floodlight #FFB648,
   Ochre #C1542C, Mist #8FA396. Display face Big Shoulders Display (stadium
   signage), body Inter, data/mono IBM Plex Mono for stats and game IDs. */

:root {
  --turf: #16241c;
  --turf-deep: #0e1712;
  --panel: #1e2f24;
  --panel-hi: #26392c;
  --chalk: #f5f3ea;
  --chalk-dim: #cdd2c6;
  --floodlight: #ffb648;
  --floodlight-dim: #7a5a28;
  --ochre: #c1542c;
  --mist: #8fa396;
  --line: #33453a;

  --font-display: "Big Shoulders Display", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--turf-deep);
}

body {
  font-family: var(--font-body);
  color: var(--chalk);
  padding: 0 20px 80px;
  position: relative;
  overflow-x: hidden;
}

/* Ambient floodlight glow, fixed behind content — signature atmosphere,
   evokes stadium lights at dusk without being a literal illustration. */
.glow {
  position: fixed;
  top: -30vh;
  left: 50%;
  width: 140vw;
  height: 70vh;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(255, 182, 72, 0.16) 0%, rgba(255, 182, 72, 0.05) 35%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.topbar {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.brand { display: flex; align-items: baseline; gap: 8px; }

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--turf-deep);
  background: var(--floodlight);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.06em;
}

.coverage-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mist);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
  transition: color 0.4s ease;
}

main {
  max-width: 880px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.tagline {
  color: var(--chalk-dim);
  font-size: 15px;
  line-height: 1.55;
  max-width: 620px;
  margin: 10px 0 32px;
}

/* --- Scoreboard: the sentence being built ------------------------------ */
.scoreboard {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  min-height: 72px;
}

.sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: 0.01em;
}

.sentence .placeholder {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  font-style: italic;
  color: var(--mist);
}

.chip {
  color: var(--chalk);
  animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.chip--num {
  font-family: var(--font-mono);
  color: var(--floodlight);
  font-weight: 600;
}

.chip--connector {
  color: var(--mist);
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 500;
  text-transform: lowercase;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.85) translateY(2px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Builder: next-token options ---------------------------------------- */
.builder { margin-top: 18px; }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.opt-btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--chalk);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  animation: fade-in 0.28s ease both;
}

.opt-btn:hover {
  border-color: var(--floodlight-dim);
  background: var(--panel-hi);
  transform: translateY(-1px);
}

.opt-btn:active { transform: translateY(0); }

.opt-btn:focus-visible {
  outline: 2px solid var(--floodlight);
  outline-offset: 2px;
}

.opt-btn--run {
  background: var(--floodlight);
  color: var(--turf-deep);
  border-color: var(--floodlight);
  font-weight: 700;
}

.opt-btn--run:hover { background: #ffc670; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.text-input {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--chalk);
  background: var(--turf);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  min-width: 220px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: var(--floodlight);
  box-shadow: 0 0 0 3px rgba(255, 182, 72, 0.18);
}

.text-input::placeholder { color: var(--mist); }

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.filter-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.more-note {
  color: var(--mist);
  font-size: 13px;
  align-self: center;
  font-style: italic;
}

.open-input-group {
  display: inline-flex;
  gap: 8px;
}

.empty-note {
  color: var(--mist);
  font-style: italic;
  font-size: 14px;
}

/* --- Player browser: 2 sidebars + a grid -------------------------------- */
.browser {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fade-in 0.2s ease both;
}

.browser-search { width: 100%; max-width: 360px; }

.browser-panes {
  display: grid;
  grid-template-columns: 176px 96px 1fr;
  /* A definite (not min/max) row height is required for the grid items'
     overflow-y:auto to actually enable scrolling — with only a max-height
     on the container, the row track sizes to its content and never
     triggers overflow at all. */
  height: 420px;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.browser-pane {
  background: var(--panel);
  height: 100%;
  min-height: 0; /* grid items default to min-height:auto, which fights overflow-y */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.browser-pane::-webkit-scrollbar { width: 8px; }
.browser-pane::-webkit-scrollbar-track { background: transparent; }
.browser-pane::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.browser-pane::-webkit-scrollbar-thumb:hover { background: var(--mist); }

.browser-pane--players {
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 12px;
}

.team-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--chalk-dim);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.team-btn:hover { background: var(--panel-hi); color: var(--chalk); }

.team-btn--active {
  background: var(--panel-hi);
  color: var(--floodlight);
  border-color: var(--floodlight-dim);
}

.team-badge {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.team-badge--initials {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--mist);
}

.decade-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--chalk-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.decade-btn:hover { background: var(--panel-hi); color: var(--chalk); }

.decade-btn--active {
  background: var(--panel-hi);
  color: var(--floodlight);
  border-color: var(--floodlight-dim);
}

.player-btn { display: inline-flex; align-items: baseline; gap: 6px; }

.player-btn-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mist);
}

.browser-empty, .browser-loading {
  color: var(--mist);
  font-size: 13px;
  font-style: italic;
  padding: 10px 4px;
  max-width: 320px;
}

.builder-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.ctrl-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--mist);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ctrl-btn:hover { color: var(--chalk); border-color: var(--mist); }
.ctrl-btn--danger:hover { color: var(--ochre); border-color: var(--ochre); }

/* --- Result ticket: signature element ----------------------------------- */
.result-wrap { margin-top: 36px; }

.ticket {
  position: relative;
  background: var(--chalk);
  color: var(--turf-deep);
  border-radius: 4px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.ticket-notch {
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 14px;
  background:
    radial-gradient(circle at 16px 0, transparent 8px, var(--chalk) 8.5px) top left / 32px 14px repeat-x;
  transform: translateY(-50%);
}

.ticket-notch--bottom {
  top: auto;
  bottom: -1px;
  transform: translateY(50%) rotate(180deg);
}

.ticket-body {
  padding: 34px 30px 26px;
}

.ticket-question {
  font-family: var(--font-body);
  font-size: 14px;
  color: #566056;
  line-height: 1.5;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px dashed #c7c3b3;
}

.ticket-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 56px;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.ticket-value--records {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  font-size: 34px;
}

.ticket-record-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.ticket-record-entity {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 22px;
  color: var(--turf-deep);
}

.ticket-record-amount {
  font-family: var(--font-display);
  font-weight: 800;
  white-space: nowrap;
}

.ticket-value--h2h {
  font-size: 40px;
  gap: 14px;
}

.ticket-value--empty {
  font-size: 24px;
  color: #8b8c7d;
  font-family: var(--font-body);
  font-weight: 500;
}

.ticket-value .unit {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 18px;
  color: #566056;
}

.ticket-gap-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ochre);
  font-family: var(--font-mono);
}

.ticket-trunc-note {
  margin-top: 10px;
  font-size: 11.5px;
  font-style: italic;
  color: #8b8c7d;
  text-align: center;
}

.ticket-games {
  margin-top: 22px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #3a4239;
}

.ticket-games-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: #8b8c7d;
  margin-bottom: 8px;
}

.ticket-game-row {
  display: flex;
  gap: 14px;
  padding: 3px 0;
  border-bottom: 1px solid #e6e3d4;
}

.ticket-game-row:last-child { border-bottom: none; }

.ticket-game-row--rich {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
}

.game-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.game-entity {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13.5px;
  color: #22301f;
}

.game-stat {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
  color: #2f6b45;
  background: #e3ecdd;
  border-radius: 4px;
  padding: 1px 6px;
}

.game-row-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: #6b7263;
  font-size: 12px;
}

.game-when { white-space: nowrap; }

.game-score {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #4c5546;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.game-score-sep { opacity: 0.5; }

.game-team-won { color: #22301f; font-weight: 700; }

.game-link {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #2f6b45;
  text-decoration: none;
  border-bottom: 1px dotted #2f6b45;
  white-space: nowrap;
}

.game-link:hover { color: #1c4a30; }

.games-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed #c7c3b3;
}

.pager-btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: #2f6b45;
  background: transparent;
  border: 1px solid #b9c7b0;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.pager-btn:hover:not(:disabled) { background: #e3ecdd; }

.pager-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.pager-label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #8b8c7d;
}

.ticket-error {
  font-family: var(--font-body);
  color: var(--ochre);
}

.ticket-loading {
  font-family: var(--font-mono);
  color: #8b8c7d;
  font-size: 13px;
}

@media (max-width: 620px) {
  .sentence { font-size: 18px; }
  .ticket-value { font-size: 42px; }
  .coverage-pill { max-width: 100%; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .chip, .opt-btn, .ticket { animation: none; }
}
