:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --panel: #fffaf1;
  --ink: #24211c;
  --muted: #70695d;
  --line: #ded3bf;
  --accent: #176b5c;
  --accent-dark: #0f4e43;
  --gold: #c88924;
  --danger: #b73e3e;
  --shadow: 0 18px 45px rgba(48, 39, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 107, 92, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(200, 137, 36, 0.16), transparent 35%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary {
  background: var(--accent);
  color: white;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary {
  background: #eee3d0;
  color: var(--ink);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero {
  min-height: 220px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 20px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 4.6rem);
  line-height: 1.05;
}

.hero-copy {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 900;
  text-transform: uppercase;
}

.today-pill,
.score-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.8);
  padding: 12px 16px;
  font-weight: 900;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.92);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.55rem;
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
}

.join-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 16px;
  font-size: 1.1rem;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 14px 16px;
  font: inherit;
  font-size: 1.1rem;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.player-card,
.challenge-head,
.section-head,
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.player-card h2 {
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.stat {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.status-text {
  min-height: 32px;
}

.quiz-card {
  border-color: rgba(23, 107, 92, 0.35);
}

.quiz-top {
  color: var(--muted);
  font-weight: 900;
}

#questionPrompt {
  margin: 18px 0;
  font-size: clamp(1.55rem, 5vw, 2.2rem);
  line-height: 1.35;
}

.lifeline-row,
.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.lifeline-row span {
  color: var(--muted);
  font-weight: 800;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.option-button {
  min-height: 76px;
  border: 2px solid #d9c8a9;
  background: white;
  color: var(--ink);
  text-align: left;
  white-space: normal;
  line-height: 1.35;
}

.option-button:hover:not(:disabled) {
  border-color: var(--accent);
}

.option-button.selected {
  border-color: var(--accent);
  background: #e7f1eb;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.option-letter {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: 10px;
  border-radius: 8px;
  background: #eee3d0;
  color: var(--accent-dark);
}

.confirm-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.message {
  min-height: 36px;
  margin-top: 16px;
  color: var(--accent-dark);
  font-weight: 900;
  line-height: 1.5;
}

.message.error {
  color: var(--danger);
}

.leaderboards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.leaderboard {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.leaderboard li:last-child {
  border-bottom: 0;
}

.rank {
  color: var(--gold);
  font-weight: 950;
}

.points {
  color: var(--accent-dark);
}

.family-panel {
  display: grid;
  gap: 18px;
}

.family-form {
  display: grid;
  gap: 14px;
}

.family-form label,
.answer-picker legend {
  color: var(--muted);
  font-weight: 900;
}

.family-form label input {
  margin-top: 8px;
}

.family-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.answer-picker {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.answer-picker label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.answer-picker input {
  width: 20px;
  min-height: 20px;
}

.question-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.question-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.question-list strong {
  display: block;
  margin-bottom: 8px;
}

.question-list span {
  color: var(--accent-dark);
  font-weight: 900;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 12px;
  }

  .hero {
    min-height: 190px;
    align-items: start;
    flex-direction: column;
  }

  .join-row,
  .stats-grid,
  .options-grid,
  .family-options,
  .leaderboards {
    grid-template-columns: 1fr;
  }

  .player-card,
  .challenge-head,
  .section-head,
  .quiz-top {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-picker {
    align-items: flex-start;
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
