:root {
  --bg: #f4f2ec;
  --paper: #fffdf8;
  --ink: #121212;
  --ink-soft: #4a4a4a;
  --line: #d5d0c3;
  --line-strong: #111111;
  --accent: #f7da21;
  --accent-deep: #d8ba00;
  --ok: #2e7d32;
  --bad: #b00020;
  --muted: #f0ede3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 10% -5%, #fff 0%, var(--bg) 55%, #ece8dc 100%);
  color: var(--ink);
  font-family: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
}

.hidden {
  display: none !important;
}

.masthead {
  border-bottom: 1px solid #222;
  background: #111;
  color: #fff;
}

.masthead-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-kicker {
  margin: 0;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  opacity: 0.84;
}

.brand-title {
  margin: 2px 0 0;
  line-height: 1;
  font-size: clamp(1.65rem, 2.2vw, 2rem);
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.reset-pill {
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

.page-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 16px 38px;
  display: grid;
  gap: 20px;
}

.game-card,
.results-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  padding: 18px;
  animation: rise-in 220ms ease;
}

.puzzle-header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.puzzle-label {
  margin: 0;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.quiz-title {
  margin: 6px 0 3px;
  line-height: 1.05;
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

.topic-line {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.status-line {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: 0.92rem;
  color: #2a2a2a;
}

.status-line.error {
  color: var(--bad);
}

.progress-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.progress-cell {
  border: 1px solid var(--line);
  background: #f7f3e8;
  min-height: 34px;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
}

.progress-cell.current {
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.progress-cell.answered {
  background: #ece8dc;
}

.progress-cell.correct {
  background: rgba(46, 125, 50, 0.2);
  border-color: rgba(46, 125, 50, 0.5);
}

.progress-cell.wrong {
  background: rgba(176, 0, 32, 0.12);
  border-color: rgba(176, 0, 32, 0.36);
}

.question-panel {
  margin-top: 14px;
}

.question-number {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.question-text {
  margin: 7px 0 12px;
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
  line-height: 1.34;
  font-size: clamp(1.05rem, 1.75vw, 1.25rem);
}

.choices {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: #252525;
}

.choice-btn {
  width: 100%;
  text-align: left;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  font-size: 0.97rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.choice-btn:hover {
  transform: translateY(-1px);
  border-color: #888;
}

.choice-btn.selected {
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  background: #f8f4e7;
}

.choice-btn.is-correct {
  border-color: rgba(46, 125, 50, 0.65);
  background: rgba(46, 125, 50, 0.14);
}

.choice-btn.is-wrong {
  border-color: rgba(176, 0, 32, 0.52);
  background: rgba(176, 0, 32, 0.08);
}

.answer-note {
  margin: 10px 0 0;
  color: #373737;
  font-size: 0.94rem;
  line-height: 1.35;
}

.nav-row {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-main {
  border-color: #151515;
  background: var(--accent);
  color: #111;
}

.btn-main:hover:not(:disabled) {
  background: var(--accent-deep);
}

.btn-muted {
  border-color: var(--line);
  background: var(--muted);
  color: #202020;
}

.btn-muted:hover:not(:disabled) {
  background: #e8e2d2;
}

.btn-link {
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: #111;
  text-decoration: underline;
}

.admin-input,
.admin-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font-size: 0.96rem;
  font-family: inherit;
}

.admin-textarea {
  min-height: 320px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.score-line {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif;
}

.result-note {
  margin: 6px 0 12px;
  color: var(--ink-soft);
}

.share-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px;
}

.share-preview {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.98rem;
  line-height: 1.35;
}

.share-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats-line {
  margin: 12px 0 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .masthead-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .reset-pill {
    width: 100%;
    text-align: center;
  }

  .progress-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-row {
    justify-content: stretch;
  }

  .nav-row .btn {
    flex: 1;
  }
}
