:root {
  --navy: #1b2a4a;
  --navy-dark: #101a30;
  --blue: #2f6feb;
  --blue-light: #eaf1ff;
  --gold: #f5b942;
  --green: #2fa860;
  --red: #e05a5a;
  --grey: #6b7280;
  --bg: #f4f6fb;
  --card: #ffffff;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--navy-dark);
  min-height: 100vh;
}

.screen { display: none; padding: 20px 16px 60px; max-width: 900px; margin: 0 auto; }
.screen.active { display: block; }

h1, h2, h3 { margin-top: 0; }

.muted { color: var(--grey); }

/* ---- Header / brand ---- */
.brand {
  text-align: center;
  padding: 32px 16px 8px;
}
.brand h1 { font-size: 1.6rem; color: var(--navy); margin-bottom: 4px; }
.brand p { color: var(--grey); margin-top: 0; }

/* ---- Buttons ---- */
button { font-family: inherit; cursor: pointer; }

.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  margin-top: 10px;
}
.btn-primary:active { background: #2559c2; }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--card);
  color: var(--navy);
  border: 2px solid var(--blue-light);
  border-radius: var(--radius);
  margin-top: 10px;
}

.btn-tiny {
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--blue-light);
  color: var(--navy);
  border: none;
  border-radius: 8px;
  margin-left: 4px;
}
.btn-tiny.danger { background: #fde3e3; color: var(--red); }

.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 0.9rem;
  text-decoration: underline;
  padding: 4px;
}

.btn-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-top: 10px;
  font-size: 1rem;
  background: var(--card);
  border: 2px solid #e2e8f5;
  border-radius: 12px;
  color: var(--navy-dark);
}
.btn-option:disabled { opacity: 0.85; }
.btn-option.correct { border-color: var(--green); background: #e9f9ef; font-weight: 600; }
.btn-option.incorrect { border-color: var(--red); background: #fdecec; }

/* ---- Mode grid on home screen ---- */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.mode-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  border: none;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.08);
}
.mode-card .icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.mode-card .label { font-weight: 600; font-size: 0.95rem; color: var(--navy); }
@media (max-width: 420px) {
  .mode-grid { grid-template-columns: 1fr; }
}

/* ---- Cards / panels ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.08);
  margin-top: 16px;
}

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  border: 2px solid #e2e8f5;
  border-radius: 10px;
  margin-top: 6px;
}

label { font-weight: 600; font-size: 0.9rem; color: var(--navy); }

.error-text { color: var(--red); font-size: 0.9rem; min-height: 1.2em; margin-top: 8px; }

/* ---- Jeopardy select ---- */
.tier-block { margin-top: 18px; }
.tier-block h3 { color: var(--navy); border-bottom: 2px solid var(--blue-light); padding-bottom: 6px; }
.game-btn-row { display: flex; gap: 10px; }
.game-btn-row .btn-secondary { margin-top: 0; }

.team-manager { margin-top: 24px; }
.team-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #eef1f8;
}
.team-row-name { flex: 1; font-weight: 600; }
.team-row-score { color: var(--grey); font-size: 0.9rem; margin-right: 8px; }
.add-team-row { display: flex; gap: 8px; margin-top: 12px; }
.add-team-row input { flex: 1; }

/* ---- Jeopardy board ---- */
.jeo-scoreboard-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.score-chip {
  background: var(--navy);
  color: white;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  gap: 8px;
  align-items: center;
}
.score-chip strong { color: var(--gold); }

#jeopardy-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.jeo-cat-head {
  background: var(--navy);
  color: white;
  padding: 10px 4px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.jeo-cell {
  background: var(--blue);
  color: var(--gold);
  border: none;
  border-radius: 6px;
  padding: 16px 4px;
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 48px;
}
.jeo-cell.used { background: #dde3ef; color: transparent; }
.jeo-cell:disabled { cursor: default; }

/* ---- Modal ---- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.85);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--navy);
  color: white;
  border-radius: var(--radius);
  padding: 26px 20px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content .clue-meta { color: var(--gold); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; font-size: 0.85rem; }
.modal-content .clue-body { font-size: 1.4rem; margin: 16px 0; line-height: 1.35; }
.modal-content .clue-answer { font-size: 1.15rem; color: var(--green); font-weight: 700; margin-top: 10px; }
.hidden { display: none !important; }
#clue-award-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn-award {
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: var(--blue);
  color: white;
  font-weight: 600;
}
.btn-award.none { background: #5a6478; }

/* ---- Quiz progress ---- */
.progress-label { color: var(--grey); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.question-text { font-size: 1.2rem; margin: 10px 0 4px; line-height: 1.4; }
.explain-box {
  background: var(--blue-light);
  border-radius: 10px;
  padding: 14px;
  margin-top: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* ---- Ranking ---- */
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--blue-light);
  padding: 10px 12px;
  border-radius: 10px;
  margin-top: 8px;
}
.rank-pos {
  background: var(--navy);
  color: white;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}
.rank-item { flex: 1; font-size: 0.95rem; }
.rank-controls .btn-tiny { margin-left: 4px; }
#rank-expert-list { padding-left: 20px; line-height: 1.7; }

/* ---- Sprint timer ---- */
.sprint-timer { font-size: 2.4rem; font-weight: 800; color: var(--blue); text-align: center; margin: 8px 0; }
textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  font-size: 1rem;
  border-radius: 10px;
  border: 2px solid #e2e8f5;
  font-family: inherit;
  margin-top: 8px;
}

/* ---- Spectrum ---- */
.spectrum-labels { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--grey); margin-top: 6px; }
input[type="range"] { width: 100%; margin-top: 14px; }
.spectrum-value { text-align: center; font-size: 2rem; font-weight: 800; color: var(--blue); margin-top: 4px; }

/* ---- Leaderboard ---- */
.lb-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.85rem; }
.lb-table th, .lb-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid #eef1f8; }
.lb-table th { background: var(--navy); color: white; font-size: 0.75rem; }
.lb-name { text-align: left; font-weight: 700; }
.lb-manual-entry { display: grid; gap: 8px; margin-top: 16px; }
.lb-manual-entry select { padding: 12px; border-radius: 10px; border: 2px solid #e2e8f5; font-size: 1rem; }

/* ---- Top nav bar (in-game) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.topbar h2 { font-size: 1.15rem; margin: 0; }

footer.small-print {
  text-align: center;
  color: var(--grey);
  font-size: 0.75rem;
  padding: 24px 16px 40px;
}
