/* 20 Number Challenge — visual language matches the Game On Family brand. */

:root {
  --gof-primary-dark: #157623;
  --gof-primary: #9bca3e;
  --gof-bg-light: #dde5ed;
  --gof-bg-mint: #defff0;
  --gof-accent: #ffb920;
  --gof-warm: #de6739;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --card-bg: #ffffff;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --slot-border: #d1d5db;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Arimo', sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--gof-bg-light) 0%, var(--gof-bg-mint) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}

.header-left { flex: 1; min-width: 0; max-width: 85%; }
.header-right { flex-shrink: 0; min-width: 52px; }

.game-title-wrap { position: relative; display: inline-block; }

.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

.game-title-heading {
  margin: 0;
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.game-title-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.game-title-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 160px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
}

.game-title-dropdown[aria-hidden="false"] { display: block; }

.game-nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
}

.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-bg-mint); }

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.mode-row .mode-btn {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 3px 10px;
  min-height: 26px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-row .mode-btn:hover {
  border-color: var(--gof-primary);
  background: var(--gof-bg-mint);
}

.mode-row .mode-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
  padding: 2px 9px;
}

/* ===== App container ===== */
#app {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.screen[hidden] { display: none; }

/* ===== Setup screen ===== */
.game-header {
  text-align: center;
  margin-bottom: 0.25rem;
}

.game-title {
  font-family: 'League Spartan', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
  line-height: 1.05;
}

.game-tagline {
  font-family: 'Trocchi', Georgia, serif;
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 0.4rem;
}

.setup-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.game-blurb p {
  font-size: 0.98rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.game-blurb p:last-child { margin-bottom: 0; }

.goal-line {
  color: var(--gof-primary-dark);
  font-weight: 700;
}

.settings-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-heading {
  font-family: 'League Spartan', sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.setup-section { display: flex; flex-direction: column; gap: 0.5rem; }
.setup-section[hidden] { display: none; }

.setup-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.player-count-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.count-btn {
  flex: 1;
  min-width: 48px;
  min-height: 48px;
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  background: white;
  color: var(--text-primary);
  border: 2px solid var(--gof-primary);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.count-btn:hover { background: var(--gof-bg-mint); }

.count-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
}

.count-btn:active { transform: scale(0.96); }

.player-name-inputs { display: flex; flex-direction: column; gap: 0.5rem; }

.player-name-input {
  font-family: 'Arimo', sans-serif;
  font-size: 1rem;
  padding: 0.75rem 0.875rem;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background: white;
  color: var(--text-primary);
  min-height: 44px;
}

/* ===== Primary / secondary buttons ===== */
.primary-btn {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.9rem 1.25rem;
  background: var(--gof-primary-dark);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s, transform 0.1s;
}

.primary-btn:hover { background: #1a8a2a; }
.primary-btn:active { transform: scale(0.98); }
.primary-btn[disabled] { background: #c9d0c1; cursor: not-allowed; }

.secondary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.75rem 1.1rem;
  background: white;
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, transform 0.1s;
}

.secondary-btn:hover { background: var(--gof-bg-mint); }
.secondary-btn:active { transform: scale(0.98); }

/* ===== Play screen ===== */
/* Fixed-column grid: each element has a permanent x-position so visibility
   changes never shift anything left or right. */
.draw-area {
  display: grid;
  grid-template-columns: 4.75rem 3.5rem 6rem;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 0.55rem 0.9rem;
  box-shadow: var(--card-shadow);
}

.draw-number {
  font-family: 'League Spartan', sans-serif;
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: left;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
  grid-column: 1;
}

.draw-number.is-empty { color: var(--text-secondary); opacity: 0.4; }

.draw-number.is-spinning {
  color: var(--gof-accent);
  opacity: 0.9;
}

.draw-number.is-revealing {
  animation: drawReveal 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  transform-origin: left center;
}

@keyframes drawReveal {
  0%   { transform: scale(1.35); color: var(--gof-accent); }
  60%  { transform: scale(0.95); color: var(--gof-primary-dark); }
  100% { transform: scale(1);    color: var(--gof-primary-dark); }
}

.draws-remaining {
  grid-column: 2;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Draw button and placement prompt share grid column 3 so neither shifts
   the rest of the row when toggled. */
.draw-btn {
  grid-column: 3;
  grid-row: 1;
  margin-top: 0;
  min-height: 40px;
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.95rem;
}

.place-prompt {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  font-style: italic;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.15;
}

.place-prompt[hidden] { display: none; }
.place-prompt.is-cpu { opacity: 0.75; }

.play-tagline {
  font-family: 'Trocchi', Georgia, serif;
  color: var(--text-secondary);
  font-size: 1rem;
  text-align: center;
  margin-top: -0.25rem;
}

.players-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.players-toggle[hidden] { display: none; }

.players-toggle-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.count-btn-inline {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  padding: 4px 10px;
  font-size: 0.95rem;
}

.hint-line {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.2rem;
}

/* ===== Boards ===== */
.boards-area {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  width: 100%;
  flex-wrap: nowrap;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
  max-width: 280px;
}

.board-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding: 4px 6px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  min-height: 28px;
}

.board-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.board-name-edit {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.45;
  transition: opacity 0.15s;
  flex: 0 0 auto;
}

.board-name-edit:hover,
.board-name-edit:focus { opacity: 1; outline: none; }

.board-name-input {
  width: 100%;
  font-family: 'Arimo', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  border: 1.5px solid var(--gof-primary);
  border-radius: 4px;
  padding: 1px 4px;
  background: white;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.board.is-eliminated .board-name {
  background: #fce8e1;
  color: var(--gof-warm);
}

.board.is-active .board-name {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
}

.slot {
  height: 28px;
  border: 1.5px solid var(--slot-border);
  border-radius: 6px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Arimo', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: default;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  user-select: none;
}

.slot.is-empty { color: var(--text-secondary); opacity: 0.5; font-weight: 500; }

.slot.is-filled {
  background: var(--gof-bg-mint);
  border-color: var(--gof-primary);
  color: var(--gof-primary-dark);
  font-weight: 800;
}

.slot.is-valid {
  cursor: pointer;
  border-color: var(--gof-accent);
  background: #fffaef;
}

.slot.is-valid:hover {
  background: var(--gof-accent);
  color: white;
  transform: scale(1.02);
}

.slot.is-invalid {
  background: #fafafa;
  color: var(--text-secondary);
  opacity: 0.4;
}

.slot.is-bad {
  background: #fce8e1;
  border-color: var(--gof-warm);
  color: var(--gof-warm);
}

/* ===== Pass screen overlay ===== */
.pass-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
}

.pass-card {
  background: white;
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pass-emoji { font-size: 3rem; }
.pass-title { font-family: 'League Spartan', sans-serif; font-size: 1.5rem; color: var(--gof-primary-dark); }
.pass-text { color: var(--text-secondary); font-size: 0.95rem; }

/* ===== End screen ===== */
.result-icon { font-size: 4rem; }

.result-title {
  font-family: 'League Spartan', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--gof-primary-dark);
  text-align: center;
}

.result-summary {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}

.result-line .result-name { font-weight: 700; }
.result-line .result-score {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  color: var(--gof-primary-dark);
}

.result-line.is-winner { color: var(--gof-primary-dark); }
.result-line.is-winner .result-name::after { content: ' 🏆'; }

.result-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== Tutorial / about expandable ===== */
.tutorial-section {
  width: 100%;
  max-width: 480px;
  margin: 1.25rem auto 0;
}

.tutorial-section details {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.tutorial-section summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.tutorial-section summary::-webkit-details-marker { display: none; }

.tutorial-section summary::after {
  content: '▾';
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.tutorial-section details[open] summary::after { transform: rotate(180deg); }

.tutorial-body {
  padding: 0 1rem 1rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
  border-top: 1px solid #eef0ee;
  padding-top: 0.75rem;
}

.tutorial-body h3 {
  font-family: 'League Spartan', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-top: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--gof-primary-dark);
}

.tutorial-body h3:first-child { margin-top: 0; }

.tutorial-body p { margin-bottom: 0.5rem; }
.tutorial-body p:last-child { margin-bottom: 0; }

.tutorial-body ul {
  margin: 0.2rem 0 0.5rem 1.1rem;
  padding: 0;
}

.tutorial-body li { margin-bottom: 0.25rem; }
.tutorial-body strong { color: var(--gof-primary-dark); }

/* ===== Footer ===== */
.footer {
  width: 100%;
  padding: 1rem;
  border-top: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.5);
  text-align: center;
  margin-top: auto;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.footer-links a:hover { color: var(--gof-primary-dark); }

/* ===== Small-screen tweaks ===== */
@media (max-width: 480px) {
  .game-title { font-size: 1.9rem; }
  .draw-area { grid-template-columns: 4rem 3rem 5.5rem; gap: 0.75rem; }
  .draw-number { font-size: 2rem; }
  .draws-remaining { font-size: 0.8rem; }
  .draw-btn { padding: 0.4rem 0.5rem; font-size: 0.9rem; }
  .place-prompt { font-size: 0.8rem; }
  .boards-area { gap: 0.4rem; }
  .slot { height: 26px; font-size: 0.88rem; }
  .board-name { font-size: 0.78rem; padding: 3px 4px; }
}

@media (max-width: 360px) {
  .draw-area { grid-template-columns: 3.5rem 2.5rem 5rem; gap: 0.5rem; }
  .draw-number { font-size: 1.8rem; }
  .draws-remaining { font-size: 0.75rem; }
  .place-prompt { font-size: 0.75rem; }
  .slot { height: 24px; font-size: 0.82rem; }
}
