:root {
  color-scheme: dark;
  --bg: #0f1116;
  --surface: #181b23;
  --surface-2: #20242e;
  --border: #2d323e;
  --text: #eceef4;
  --muted: #9aa2b4;
  --accent: #6f5ce8;
  --accent-hover: #7f6df0;
  --accent-soft: rgba(111, 92, 232, 0.2);
  --link: #b3a8ff;
  --good: #4fd093;
  --good-soft: rgba(79, 208, 147, 0.13);
  --bad: #f38a8a;
  --bad-soft: rgba(243, 138, 138, 0.12);
  --warn: #f0be5a;
  --warn-soft: rgba(240, 190, 90, 0.13);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.18);
  --radius: 14px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f2f1ed;
  --border: #e1dfd8;
  --text: #1d1f26;
  --muted: #646b7a;
  --accent: #5b48d6;
  --accent-hover: #4d3bc4;
  --accent-soft: rgba(91, 72, 214, 0.1);
  --link: #4f3dc9;
  --good: #1b8a56;
  --good-soft: rgba(27, 138, 86, 0.1);
  --bad: #c43c3c;
  --bad-soft: rgba(196, 60, 60, 0.08);
  --warn: #946500;
  --warn-soft: rgba(200, 150, 20, 0.14);
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.05), 0 6px 20px rgba(20, 20, 40, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1,
.h1 {
  font-size: 1.55rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

main.container {
  padding-top: 24px;
  padding-bottom: 64px;
}

/* header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1;
}

.brand-mark sup {
  position: relative;
  top: -0.4em;
  margin-left: 1px;
  font-size: 0.6em;
  font-style: normal;
  line-height: 0;
  vertical-align: baseline;
}

.brand-name {
  display: none;
}

@media (min-width: 420px) {
  .brand-name {
    display: inline;
  }
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav form {
  display: flex;
  margin: 0;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* layout helpers */

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack > .btn:not(.btn-block) {
  align-self: flex-start;
}

.section {
  margin-top: 32px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.lead {
  color: var(--muted);
  font-size: 1.02rem;
}

.centered-text {
  text-align: center;
}

.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* cards */

.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card.has-error {
  border-color: var(--bad);
}

.narrow {
  max-width: 440px;
  margin: 24px auto 0;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
}

.empty h1 {
  color: var(--text);
}

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

.quiz-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiz-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.quiz-card h2 a {
  color: var(--text);
}

@media (min-width: 640px) {
  .quiz-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .quiz-card .actions {
    flex: none;
  }
}

/* buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--muted);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-danger {
  border-color: var(--bad);
  background: transparent;
  color: var(--bad);
}

.btn-danger:hover {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.btn-danger-solid,
.btn-danger-solid:hover {
  border-color: #c43c3c;
  background: #c43c3c;
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 52px;
  font-size: 1.05rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.actions.centered {
  justify-content: center;
}

.tool-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
}

.tool-link:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.tool-link.danger {
  color: var(--bad);
}

/* forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label:not(.check),
.field > .label {
  font-size: 0.92rem;
  font-weight: 600;
}

.hint ul {
  margin: 0;
  padding-left: 18px;
}

.radio-group .check {
  display: flex;
}

.group > .field {
  gap: 0;
}

/* optional parts of a form that stay folded until needed */
details.more {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

details.more > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 14px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

details.more > summary::-webkit-details-marker {
  display: none;
}

details.more > summary::after {
  content: "+";
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 400;
}

details.more[open] > summary::after {
  content: "\2212";
}

details.more > .stack {
  padding: 0 14px 14px;
}

.people {
  margin: 0 0 0 9px;
  padding-left: 20px;
  border-left: 2px solid var(--border);
}

/* the list only matters for the two "people I pick" choices */
.audience:has(input[value="everyone"]:checked) .people,
.audience:has(input[value="nobody"]:checked) .people {
  display: none;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.error {
  color: var(--bad);
  font-size: 0.9rem;
  font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="datetime-local"] {
  max-width: 280px;
  min-height: 46px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="number"] {
  max-width: 140px;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
}

input[type="file"]::file-selector-button {
  min-height: 40px;
  margin-right: 12px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 500;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.image-input {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.image-input img {
  width: auto;
  max-width: 100%;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

/* messages and badges */

.flash {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.messages .flash {
  margin-bottom: 16px;
}

.flash + .stack {
  margin-top: 16px;
}

.flash-success {
  border-color: var(--good);
  background: var(--good-soft);
}

.flash-error {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.flash-warning {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--link);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-good {
  background: var(--good-soft);
  color: var(--good);
}

.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* quiz builder */

.q-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.q-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.q-item:last-child {
  padding-bottom: 0;
}

.q-num,
.rank {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.q-body {
  flex: 1;
  min-width: 0;
}

.q-text {
  font-weight: 600;
}

.q-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin-top: 6px;
  margin-left: -10px;
}

.q-tools form {
  display: inline-flex;
  margin: 0;
}

.q-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--surface-2);
  object-fit: cover;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-edit {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.option-edit-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 16px;
}

.check.remove {
  color: var(--muted);
}

.option-edit:has(.correct input:checked) {
  border-color: var(--good);
}

.option-edit:has(.remove input:checked) {
  border-style: dashed;
  border-color: var(--border);
}

.option-edit:has(.remove input:checked) > .field {
  opacity: 0.35;
}

/* taking a quiz */

.quiz-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.question {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.q-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.question-text {
  font-size: 1.12rem;
  font-weight: 600;
}

.question-image {
  display: block;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.question-image img {
  width: auto;
  max-width: 100%;
  max-height: min(60vh, 420px);
  margin: 0 auto;
  border-radius: 8px;
}

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

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

@media (min-width: 640px) {
  .choices-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

.choice {
  position: relative;
  display: block;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.choice-body {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  transition: background-color 0.15s, border-color 0.15s;
}

.choice-body::before {
  content: "";
  flex: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: var(--surface);
}

.choice input[type="checkbox"] + .choice-body::before {
  border-radius: 6px;
}

.choice:hover .choice-body {
  border-color: var(--muted);
}

.choice input:checked + .choice-body {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice input:checked + .choice-body::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.choice input:focus-visible + .choice-body {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.choice-text {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.choice-image {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg);
}

.choice-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.choices-grid .choice-body,
.choices-grid .answer {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  padding: 8px;
}

.choices-grid .choice-body::before {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 1;
}

.choices-grid .choice-text {
  flex: none;
  padding: 0 4px 4px;
  text-align: center;
}

.choices-grid .choice-body > .choice-text:first-child {
  padding: 30px 8px 12px;
}

/* results */

.result-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 18px;
  text-align: center;
}

.score {
  font-size: 3.4rem;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.score small {
  color: var(--muted);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0;
}

progress.meter {
  width: 100%;
  max-width: 320px;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  -webkit-appearance: none;
  appearance: none;
}

progress.meter::-webkit-progress-bar {
  background: var(--surface-2);
}

progress.meter::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent);
}

progress.meter::-moz-progress-bar {
  background: var(--accent);
}

.answer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}

.answer.is-correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.answer.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.choices-grid .tags {
  justify-content: center;
  margin: 0 0 4px;
}

.tag {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-good {
  border-color: var(--good);
  color: var(--good);
}

/* attempt lists and leaderboard */

.rows {
  margin: 0;
  padding: 4px 18px;
  list-style: none;
}

.rows li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.rows li:first-child {
  border-top: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.who {
  font-weight: 600;
}

.pts {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.row-tools {
  display: flex;
  flex-basis: 100%;
  margin-left: -10px;
}

@media (min-width: 640px) {
  .row-tools {
    flex-basis: auto;
    margin-left: 0;
  }
}

.board li:first-child .rank {
  background: var(--accent);
  color: #fff;
}

.quote {
  margin-top: 4px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  font-size: 0.92rem;
}

/* one question at a time */

.play-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

progress.meter-wide {
  max-width: none;
  height: 8px;
}

/* the main button is first in the markup, Back still sits on the left */
.play-actions {
  flex-direction: row-reverse;
  justify-content: space-between;
}

.play-actions .btn-primary {
  flex: 1;
  max-width: 320px;
}

.answer.is-picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* notes, comments and ending messages */

.note,
.bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
}

.note {
  border: 1px dashed var(--border);
  background: var(--bg);
}

.bubble {
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  background: var(--accent-soft);
}

.note-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ending {
  width: 100%;
  max-width: 460px;
  margin: 6px 0;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: var(--accent-soft);
  font-size: 1.05rem;
  font-weight: 500;
}

.ending footer {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.ending footer::before {
  content: "\2013\00a0";
}

.below {
  margin-bottom: 16px;
}

.below-list {
  margin-top: 10px;
}

/* locked quiz and countdown */

.locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 36px 18px;
  text-align: center;
}

.lock-mark {
  color: var(--link);
}

.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 400px;
  margin: 10px 0 4px;
}

.tick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.tick-num {
  font-size: clamp(1.6rem, 8vw, 2.3rem);
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tick-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tick:last-child .tick-num {
  color: var(--link);
}

/* scoreboard */

.versus {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.versus .section-head {
  margin-bottom: 0;
}

.versus-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
}

.versus-name {
  grid-column: 1 / -1;
  font-size: 0.92rem;
  font-weight: 600;
}

.versus-side progress.meter {
  max-width: none;
}

.versus-side .meta {
  grid-column: 1 / -1;
}
