:root {
  --ink: #1b2a3a;
  --navy: #10283d;
  --navy-2: #1b4564;
  --gold: #f0b429;
  --gold-deep: #a56b10;
  --paper: #fffaf2;
  --bg: #d5e4f2;
  --line: #d7cbb8;
  --field: #0f7a45;
  --field-deep: #0b5c34;
  --miss: #8d341f;
  --miss-bg: #fde8df;
  --chip: #e7f0f8;
  --chip-life: #fff1d2;
  --muted: #5c6b7a;
  --shadow: 0 10px 28px rgba(16, 40, 61, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at top left, #f7fbff 0, transparent 36%),
    linear-gradient(180deg, #e7f1fa 0%, var(--bg) 220px);
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.top {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 16px 8px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ball { width: 64px; height: 40px; flex: none; }

.brand-kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--navy-2);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
  color: var(--navy);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.scoreboard {
  margin-top: 14px;
  background: var(--navy);
  color: #f7fbff;
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "cat switch"
    "score switch"
    "guesses switch";
  align-items: center;
  column-gap: 16px;
}

.category {
  grid-area: cat;
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}

.scoreline {
  grid-area: score;
  margin: 2px 0 0;
  font-size: 3rem;
  line-height: 0.95;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scoreword {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c5d5e4;
  margin-left: 4px;
}

.guessline {
  grid-area: guesses;
  margin: 6px 0 0;
  color: #d5e2ee;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.switch {
  grid-area: switch;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 2px solid #3d6484;
  background: #17364e;
  color: white;
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.switch .knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #8aa4ba;
  display: inline-block;
}

.switch[aria-checked="true"] {
  background: #145c38;
  border-color: #8ee0b4;
}

.switch[aria-checked="true"] .knob { background: #b6f3d2; }

.btn {
  font: inherit;
  font-weight: 800;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
}

.btn:focus-visible,
.switch:focus-visible,
.player-search:focus-visible,
.season-select:focus-visible,
.suggestion:focus-visible,
.result-toggle:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #ffc94a; }
.btn-ghost {
  background: white;
  color: var(--navy);
  border-color: #c5d3e0;
}
.btn-ghost:hover { border-color: var(--navy); }
.btn-add { background: var(--field); color: white; }
.btn-add:hover { background: var(--field-deep); }
.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding-inline: 8px;
}
.btn-quiet:hover { color: var(--ink); }

.banner {
  max-width: 980px;
  margin: 12px auto 0;
  padding: 14px 16px;
  background: #e8f8ee;
  color: #0d4b2c;
  border: 2px solid #9ad7b4;
  border-radius: 14px;
  font-weight: 800;
}

.banner-lead { margin: 0 0 8px; }

.recap {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  font-weight: 700;
  color: var(--navy);
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
}

.recap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.copy-note { margin: 0; min-height: 1.2em; }

#board {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.row {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
  border: 2px solid transparent;
}

.row.is-filled { border-color: #b7e4cb; }
.row.is-given { border-color: #ead9b0; background: #fff7e8; }

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

.row-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex: none;
}

.years {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--navy);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px 38px; }

.chip {
  background: var(--chip);
  color: var(--navy);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.86rem;
  font-weight: 800;
}

.chip.life { background: var(--chip-life); }

.pick-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 280px) auto auto;
  gap: 8px;
  align-items: start;
  margin-left: 38px;
}

.search-wrap { position: relative; }

.season-wrap { display: flex; flex-direction: column; gap: 6px; }

.player-search,
.season-select {
  width: 100%;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: white;
  border: 2px solid #cfc3b1;
  border-radius: 12px;
  padding: 10px 12px;
}

.season-select.is-locked,
.season-select:disabled {
  background: #f3efe6;
  color: var(--navy);
  cursor: not-allowed;
}

.season-lock {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--navy-2);
}

.give-confirm {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #fff4e0;
  border: 2px solid #e2c48a;
  border-radius: 12px;
  padding: 8px 10px;
}

.give-confirm[hidden] { display: none; }

.give-confirm p {
  margin: 0;
  flex: 1 1 180px;
  font-weight: 800;
  color: var(--ink);
}

.suggestions {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: white;
  border: 2px solid var(--navy);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
  padding: 4px;
}

.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 700;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--ink);
}

.suggestion.is-active,
.suggestion:hover { background: #e7f0f8; }

.empty-suggest {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 700;
}

.easy-hint {
  display: none;
  margin: 8px 0 0 38px;
  color: var(--field-deep);
  font-weight: 800;
}

body.easy-mode .season-wrap { display: none; }
body.easy-mode .easy-hint { display: block; }
body.easy-mode .pick-controls { grid-template-columns: minmax(0, 1fr) auto auto; }

.message {
  margin: 8px 0 0 38px;
  min-height: 0;
  font-weight: 800;
}

.message.miss {
  background: var(--miss-bg);
  color: var(--miss);
  border-radius: 12px;
  padding: 8px 10px;
}

.message.ok { color: var(--field-deep); }

.result { margin-left: 38px; }

.result-name {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy);
}

.result-meta { margin: 2px 0 0; color: var(--muted); font-weight: 700; }

.result-stat {
  margin: 6px 0 0;
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--field-deep);
}

.row.is-given .result-stat { color: var(--gold-deep); font-size: 1.25rem; }

.meter {
  margin-top: 8px;
  height: 12px;
  background: #e4e0d8;
  border-radius: 999px;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1f7a4d, #f0b429);
  border-radius: inherit;
}

.pct { margin: 6px 0 0; font-weight: 800; color: var(--navy); }

.result-toggle {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.more-cue {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--navy-2);
}

.better {
  margin-top: 10px;
  background: white;
  border: 2px solid #d7e6f2;
  border-radius: 12px;
  padding: 8px;
}

.better-title {
  margin: 0 4px 6px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.better-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1.4fr) auto auto;
  gap: 6px 10px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 8px;
  font-weight: 700;
}

.better-row.is-yours {
  background: #e5f6ec;
  outline: 2px solid #9ad7b4;
}

.better-rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.better-who { display: flex; flex-direction: column; min-width: 0; }
.better-name { color: var(--navy); font-weight: 800; }
.better-meta { color: var(--muted); font-size: 0.88rem; }
.better-value { font-variant-numeric: tabular-nums; color: var(--field-deep); font-weight: 800; }
.better-pct { color: var(--navy); }
.yours-tag {
  grid-column: 2 / -1;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--field-deep);
}

.reveal-label {
  margin: 8px 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 800;
}

.foot {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: 0.92rem;
}

.foot p { margin: 0 0 6px; }

dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  max-width: min(640px, calc(100vw - 24px));
  box-shadow: var(--shadow);
  color: var(--ink);
}

dialog::backdrop { background: rgba(16, 40, 61, 0.55); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 16px 0;
}

.dialog-head h2 { margin: 0; color: var(--navy); }

.steps { margin: 8px 0 0; padding: 0 18px 0 36px; }
.steps li { margin: 0 0 10px; font-weight: 700; }
.dialog-note { margin: 0; padding: 0 16px 16px; color: var(--muted); font-weight: 700; }

.empty-board, .error-board {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

html.skip-intro #intro,
html.intro-done #intro { display: none; }

html:not(.skip-intro):not(.intro-done) .skip,
html:not(.skip-intro):not(.intro-done) .top,
html:not(.skip-intro):not(.intro-done) #complete,
html:not(.skip-intro):not(.intro-done) #board,
html:not(.skip-intro):not(.intro-done) .foot {
  display: none;
}

.intro {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.intro-card h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  margin: 4px 0 10px;
}

.intro-lead {
  margin: 0 0 18px;
  font-weight: 700;
  color: var(--navy-2);
}

.walk {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.walk-step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.walk-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.walk-step h2 {
  margin: 4px 0 6px;
  font-size: 1.2rem;
  color: var(--navy);
}

.walk-step p { margin: 0 0 10px; font-weight: 700; }

.mock {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.intro .chips,
.intro .pick-controls,
.intro .result,
.intro .mock-score { margin-left: 0; }

.mock-field {
  border: 2px solid #cfc3b1;
  border-radius: 12px;
  background: white;
  padding: 10px 12px;
  font-weight: 800;
}

.mock-add {
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--field);
  color: white;
  padding: 10px 14px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.intro .pick-controls {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
}

.mock-score .result-name { font-size: 1.15rem; }
.mock-score .result-stat { font-size: 1.35rem; }

.mock-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
}

.mock-choice {
  background: white;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mock-choice strong { color: var(--navy); }
.mock-choice span { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.intro-skip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  font-weight: 800;
  color: var(--navy);
}

.intro-skip input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--field);
}

.intro-start {
  width: 100%;
  font-size: 1.3rem;
  padding: 16px 24px;
}

@media (max-width: 760px) {
  h1 { font-size: 1.6rem; }
  .scoreboard {
    grid-template-columns: 1fr;
    grid-template-areas: "cat" "score" "guesses" "switch";
  }
  .scoreline { font-size: 2.5rem; }
  .switch { justify-self: start; }
  .pick-controls,
  body.easy-mode .pick-controls {
    grid-template-columns: 1fr;
    margin-left: 0;
  }
  .chips, .message, .result, .easy-hint { margin-left: 0; }
  .top-row { flex-direction: column; }
  .better-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }
  .better-value, .better-pct { grid-column: 2; }
  .intro .pick-controls,
  .mock-pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
