:root {
  color-scheme: dark;
  --background: #171527;
  --panel: #222038;
  --surface: #2d2944;
  --border: #4b4564;
  --text: #fbf8ff;
  --muted: #c4bed6;
  --accent: #d8ff7d;
  --accent-ink: #222a11;
  --error: #ffb4c8;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 82% 0%, #30264e 0, transparent 52%), var(--background);
  color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.shell {
  width: min(100% - 3rem, 66rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  min-height: 4.75rem;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -.015em;
}

.spark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: .6rem;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 1.2rem;
}

.text-button {
  padding: .5rem .65rem;
  min-height: 2.75rem;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: .5rem;
  font-size: .9rem;
  font-weight: 700;
}
.text-button:hover { color: var(--text); background: var(--surface); }

main { padding-bottom: 2rem; }

.intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1.25rem;
  margin-block: 2.35rem 1.65rem;
}

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

h1 {
  font-size: clamp(3rem, 7vw, 5.75rem);
  letter-spacing: -.065em;
  line-height: .98;
  font-weight: 850;
}
h1 span { color: var(--accent); }
.intro p { margin-top: .85rem; color: var(--muted); }

.difficulty {
  margin: 0;
  min-width: 0;
  padding: 0;
  border: 0;
}
.difficulty legend {
  padding: 0;
  margin-bottom: .35rem;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}

.segmented {
  display: flex;
  gap: .2rem;
  padding: .2rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: .75rem;
}
.segmented label { position: relative; cursor: pointer; }
.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segmented span {
  display: grid;
  min-height: 2.75rem;
  min-width: 4.25rem;
  place-items: center;
  border-radius: .5rem;
  padding: .35rem .8rem;
  color: var(--muted);
  font-weight: 750;
}
.segmented input:checked + span { color: var(--accent-ink); background: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 2px; }

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  overflow: hidden;
  background: var(--panel);
}

.portrait {
  position: relative;
  isolation: isolate;
  min-height: 31rem;
  background: radial-gradient(ellipse at 40% 30%, #6c527d, #362849 65%, #231e35);
}
.portrait img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
}
.portrait figcaption {
  position: absolute;
  bottom: 1.125rem;
  left: 1.125rem;
  padding: .4rem .7rem;
  background: #171527e8;
  color: var(--text);
  border-radius: .45rem;
  font-size: .9rem;
  font-weight: 700;
}

.answer-panel {
  min-width: 0;
  padding: clamp(1.25rem, 4vw, 2.8rem);
}

.game-status {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  font-size: .9rem;
  font-weight: 750;
  color: var(--muted);
}
#score { color: var(--accent); }

progress {
  display: block;
  width: 100%;
  height: .4rem;
  margin: .65rem 0 1.65rem;
  border: 0;
  border-radius: 1rem;
  overflow: hidden;
  appearance: none;
  background: var(--surface);
  color: var(--accent);
}
progress::-webkit-progress-bar { background: var(--surface); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 1rem; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 1rem; }

h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -.035em;
  line-height: 1.12;
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
  margin-top: 1rem;
}

.option, .primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.15rem;
  padding: .6rem .85rem;
  border: 1px solid transparent;
  border-radius: .7rem;
  font-weight: 750;
  line-height: 1.25;
}

.option { color: var(--text); background: var(--surface); border-color: var(--border); }
.option:hover:enabled { border-color: var(--accent); }
.option[data-result="correct"] { background: #344329; border-color: var(--accent); color: var(--accent); }
.option[data-result="incorrect"] { background: #472c42; border-color: var(--error); color: var(--error); }

.primary {
  color: var(--accent-ink);
  background: var(--accent);
}
.primary:hover:enabled { background: #e5ffa6; }

.typed-answer {
  display: grid;
  gap: .6rem;
  margin-top: 1rem;
}
.typed-answer label { font-weight: 700; color: var(--muted); }

.typed-answer input {
  width: 100%;
  min-height: 3.15rem;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  color: var(--text);
  background: var(--background);
}
.typed-answer input::placeholder { color: #a59eba; }

.feedback {
  margin-top: 1rem;
  min-height: 1.45rem;
  line-height: 1.45;
  font-weight: 700;
}
.feedback[data-result="correct"] { color: var(--accent); }
.feedback[data-result="incorrect"] { color: var(--error); }
.question-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .35rem; }
#give-up { margin-left: -.5rem; }

.results {
  text-align: center;
  padding: 3.5rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--panel);
}
.results p { margin-block: .85rem 1.5rem; color: var(--muted); }
.results .primary { margin-inline: auto; }
.result-spark { margin-bottom: 1rem; color: var(--accent); font-size: 2.5rem; }

dialog {
  width: min(100% - 2rem, 36rem);
  max-height: 82dvh;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: #0d0b18bd; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.credit-note { margin-top: .7rem; color: var(--muted); }
.credit-list { padding-left: 1.3rem; color: var(--muted); }
.credit-list li { margin-top: .7rem; }
.credit-note a, .credit-list a { color: var(--accent); text-underline-offset: .17em; }

@media (max-width: 46rem) {
  .shell { width: calc(100% - 2rem); }
  .site-header { min-height: 3.6rem; }
  .intro { margin-block: 1.25rem 1rem; align-items: start; flex-direction: column; gap: .8rem; }
  .intro p { margin-top: .45rem; }
  .game { grid-template-columns: minmax(0, 1fr); }
  .portrait { min-height: 0; height: clamp(12rem, 32vh, 23rem); }
  .portrait figcaption { bottom: .65rem; left: .65rem; }
  .answer-panel { padding: 1rem; }
  progress { margin-bottom: 1rem; }
  .feedback:empty { min-height: 0; margin-top: .3rem; }
}

@media (max-width: 23rem) {
  .option { padding-inline: .45rem; }
}
