:root {
  --green-dark: #157623;
  --green: #9bca3e;
  --olive: #83a83d;
  --yellow: #ffb920;
  --rust: #de6739;
  --teal: #3abbc0;
  --bg: #dde5ed;
  --ink: #2f2c28;
  --ink-soft: #5e5c5e;
  --card: #ffffff;
  --line-track: #e7ecf2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Arimo", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

/* ---------- Header bar (per HEADER_SPECS) ---------- */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 14px;
}
.game-title-wrap { position: relative; }
.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.game-title-heading {
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  margin: 0;
  color: var(--green-dark);
}
.game-title-chevron { color: var(--ink-soft); font-size: 13px; }
.game-title-dropdown {
  position: absolute;
  top: 110%;
  left: 0;
  background: var(--card);
  border: 1px solid #d4dbe3;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 180px;
  z-index: 40;
}
.game-title-dropdown[aria-hidden="true"] { display: none; }
.game-nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}
.game-nav-link:hover { background: #f0f4f8; }
.header-right { display: flex; align-items: center; }

/* ---------- Mode pills (game modes only) ---------- */
.mode-row {
  display: flex;
  gap: 8px;
  margin: 0 0 18px;
}
.mode-pill {
  flex: 1 1 0;
  border: 2px solid #d4dbe3;
  background: #fff;
  border-radius: 999px;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  padding: 9px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.mode-pill:hover { border-color: var(--green); }
.mode-pill.is-active {
  background: var(--green);
  border-color: var(--green);
  color: var(--green-dark);
}

/* ---------- Buttons ---------- */
.primary-btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: var(--green);
  color: var(--green-dark);
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.3px;
  padding: 15px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--olive);
  transition: transform 80ms ease, box-shadow 80ms ease, background 120ms ease;
}
.primary-btn:hover { background: #acd457; }
.primary-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--olive); }
.primary-btn:disabled {
  background: #c8d2da;
  color: #8a939c;
  box-shadow: 0 4px 0 #b3bdc6;
  cursor: default;
}
.guess-row + .primary-btn { margin-top: 12px; }

/* ---------- Setup screen ---------- */
.setup { text-align: center; }
.setup-tagline {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 4px 0 22px;
}
.setup-tagline strong { color: var(--green-dark); }

.secret-pick {
  background: var(--card);
  border-radius: 16px;
  padding: 20px 18px;
  box-shadow: 0 6px 18px rgba(47,44,40,0.08);
  margin-bottom: 22px;
}
.secret-label {
  display: block;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 12px;
  color: var(--ink);
}
/* Editable player-name chip (Pass & Play) — tap the pencil to rename */
.pass-name-field { margin-bottom: 16px; text-align: center; }
.pass-name-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--green-dark);
  background: #eef6e6;
  border: 2px solid #cfe6b3;
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  user-select: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.pass-name-edit:hover { border-color: var(--green); background: #e6f3d6; }
.pass-name-edit .edit-icon { font-size: 0.78em; opacity: 0.7; }
.pass-name-edit:hover .edit-icon { opacity: 1; }
.pass-name-input {
  width: 220px;
  text-align: center;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: var(--green-dark);
  border: 2px solid var(--green);
  border-radius: 999px;
  padding: 8px 16px;
  background: #fff;
}
.pass-name-input:focus { outline: none; }

.secret-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}
.secret-input {
  width: 120px;
  text-align: center;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 36px;
  color: var(--green-dark);
  border: 2px solid #d4dbe3;
  border-radius: 12px;
  padding: 8px 6px;
  background: #fafcff;
}
.secret-input:focus { outline: none; border-color: var(--green); }
/* hide number spinners for a cleaner look */
.secret-input::-webkit-outer-spin-button,
.secret-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.secret-input { -moz-appearance: textfield; }

/* +/- stepper buttons (tap, or hold to accelerate) */
.step-btn {
  flex: 0 0 auto;
  width: 56px;
  border: 2px solid #d4dbe3;
  background: #fff;
  border-radius: 12px;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
  color: var(--green-dark);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 100ms ease, border-color 100ms ease, transform 60ms ease;
}
.step-btn:hover { border-color: var(--green); background: #f4faec; }
.step-btn:active { transform: scale(0.94); background: #e8f4d6; }
.step-btn:disabled {
  opacity: 0.45;
  cursor: default;
  background: #fff;
  border-color: #d4dbe3;
  transform: none;
}

.shuffle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 14px auto 0;
  border: 2px solid #d4dbe3;
  background: #fff;
  border-radius: 12px;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  padding: 9px 18px;
  cursor: pointer;
}
.shuffle-btn:hover { border-color: var(--yellow); background: #fffdf5; }
.secret-hint { font-size: 13px; color: var(--ink-soft); margin: 16px 0 0; line-height: 1.5; }

/* ---------- Turn banner ---------- */
.turn-banner {
  text-align: center;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 18px;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  background: #fff6df;
  color: #8a6400;
  border: 1px solid #ffe6a8;
}
.turn-banner.is-cpu {
  background: #eaf6ec;
  color: var(--green-dark);
  border-color: #bfe3c5;
}

/* ---------- Boards ---------- */
.board {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(47,44,40,0.07);
}
.board--cpu { opacity: 0.97; }
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.board-title {
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
}
.board-range {
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 14px;
  color: var(--green-dark);
  background: #eaf6ec;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ---------- Number line ---------- */
.numberline {
  position: relative;
  height: 26px;
  background: var(--line-track);
  border-radius: 0;
  margin-bottom: 4px;
  overflow: visible;
  border: 1px solid #d4dbe3;
}
.numberline-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--green) 0%, var(--olive) 100%);
  border-radius: 0;
  transition: left 280ms ease, right 280ms ease;
  left: 0;
  right: 0;
}
.board--cpu .numberline-band {
  background: linear-gradient(90deg, var(--teal) 0%, #2f9aa0 100%);
}
.numberline-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 34px;
  background: var(--ink);
  transform: translateX(-1px);
  opacity: 0.35;
}
.numberline-marker.is-latest {
  background: var(--rust);
  opacity: 1;
  width: 3px;
}
.numberline-labels {
  position: relative;
  height: 16px;
  margin-bottom: 2px;
}
.numberline-labels span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--green-dark);
}
.board--cpu .numberline-labels span { color: #2f9aa0; }

/* ---------- Guess history ---------- */
.guess-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.guess-list:empty { display: none; }
.guess-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 9px;
  border-radius: 14px;
  background: #eef2f6;
  color: var(--ink);
  border: 1px solid transparent;
}
.guess-chip .dir { font-size: 11px; line-height: 1; }
.guess-chip.is-higher .dir { color: var(--green-dark); }
.guess-chip.is-lower .dir { color: var(--rust); }
.guess-chip.is-correct { background: var(--green); color: var(--green-dark); }
.guess-chip.is-latest { border-color: var(--yellow); }

/* ---------- Guess row ---------- */
.guess-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  align-items: stretch;
}
.guess-input {
  flex: 1 1 auto;
  width: 100%;
  text-align: center;
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: var(--green-dark);
  border: 2px solid #d4dbe3;
  border-radius: 12px;
  padding: 8px;
  background: #fafcff;
}
.guess-input:focus { outline: none; border-color: var(--green); }
.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.guess-input { -moz-appearance: textfield; }

/* ---------- Feedback line ---------- */
.feedback {
  text-align: center;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 16px;
  margin-top: 12px;
  min-height: 22px;
  color: var(--ink-soft);
}
.feedback.is-higher { color: var(--green-dark); }
.feedback.is-lower { color: var(--rust); }
.feedback--cpu { font-size: 15px; }

/* ---------- Result overlay ---------- */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(47,44,40,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}
.result-card {
  background: var(--card);
  border-radius: 20px;
  padding: 30px 24px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.result-emoji { font-size: 54px; line-height: 1; }
.result-title {
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 30px;
  margin: 10px 0 6px;
  color: var(--green-dark);
}
.result-card.is-loss .result-title { color: var(--rust); }
.result-detail {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 22px;
}

/* ---------- Handoff overlay (Pass & Play) ---------- */
.handoff-overlay {
  position: fixed;
  inset: 0;
  background: rgba(47,44,40,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 70;
}
.handoff-card {
  background: var(--card);
  border-radius: 20px;
  padding: 30px 24px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.handoff-emoji { font-size: 54px; line-height: 1; }
.handoff-title {
  font-family: "League Spartan", sans-serif;
  font-weight: 800;
  font-size: 26px;
  margin: 10px 0 6px;
  color: var(--green-dark);
}
.handoff-detail {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 22px;
}

/* ---------- About ---------- */
.about {
  margin-top: 22px;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(47,44,40,0.06);
}
.about-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 15px 16px;
  font-family: "League Spartan", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
}
.about-chevron { transition: transform 200ms ease; color: var(--ink-soft); }
.about-toggle[aria-expanded="true"] .about-chevron { transform: rotate(180deg); }
.about-content {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 260ms ease, padding 260ms ease;
}
.about-content.is-open { padding: 0 16px 16px; max-height: 600px; }
.about-content p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

/* ---------- Footer ---------- */
.footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  text-align: center;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}
.footer-links a {
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.footer-links a:hover { text-decoration: underline; }

@media (min-width: 480px) {
  .game-title-heading { font-size: 30px; }
}
