/* Pass the Sphinx — tokens first. Lapis and ochre: the night sky over Thebes and the sand at the gate. */
:root {
  --lapis: #1E2A5E;
  --lapis-deep: #141C42;
  --ochre: #B5841F;
  --ochre-bright: #D9A93F;
  --marble: #F3F3F0;
  --stone: #D7D8DE;

  --bg: var(--marble);
  --surface: #FFFFFF;
  --ink: var(--lapis);
  --ink-soft: #4A5480;
  --line: var(--stone);
  --accent: var(--ochre);
  --accent-ink: #FFFFFF;
  --right: #2F6E4C;
  --wrong: #9C3324;
  --focus: #D9A93F;

  --serif: "Gloock", "Georgia", serif;
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.25rem;
  --step-4: 3.5rem;
  --step-5: 5.5rem;

  --radius-s: 6px;
  --radius-m: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--lapis-deep);
    --surface: #1B2452;
    --ink: #ECEDF3;
    --ink-soft: #A7AECB;
    --line: #2F3A6E;
    --accent: var(--ochre-bright);
    --accent-ink: var(--lapis-deep);
    --right: #6FC093;
    --wrong: #E5866F;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--lapis-deep);
  --surface: #1B2452;
  --ink: #ECEDF3;
  --ink-soft: #A7AECB;
  --line: #2F3A6E;
  --accent: var(--ochre-bright);
  --accent-ink: var(--lapis-deep);
  --right: #6FC093;
  --wrong: #E5866F;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.5;
  min-height: 100dvh;
}
.shell {
  max-width: 36rem;
  margin: 0 auto;
  padding: 3.5rem 1rem 4rem;
  outline: none;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.1; margin: 0; }
p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- Shared pieces ---------- */
.stack > * + * { margin-top: var(--gap, 1.25rem); }
.muted { color: var(--ink-soft); }
.small { font-size: var(--step--1); }

.wordmark {
  font-family: var(--serif);
  font-size: var(--step-1);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 2.5rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 var(--step-0)/1 var(--sans);
  padding: 1.05rem 1.5rem;
  min-height: 3.25rem;
  cursor: pointer;
  width: 100%;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn--quiet {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.field { display: block; }
.field label { display: block; font-weight: 700; margin-bottom: .4rem; }
.field .hint { display: block; font-size: var(--step--1); color: var(--ink-soft); margin-top: .35rem; }
.field input {
  width: 100%;
  font: var(--step-1) var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: .8rem .9rem;
}
.field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.error { color: var(--wrong); font-weight: 700; }

/* ---------- Home ---------- */
.hero-title {
  font-size: clamp(var(--step-4), 15vw, var(--step-5));
  letter-spacing: -0.02em;
}
.hero-title span { display: block; }
.hero-lede { font-size: var(--step-1); max-width: 30rem; }
.rules {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1.5px solid var(--line);
}
.rules li {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: .85rem 0;
  border-bottom: 1.5px solid var(--line);
}
.rules b { font-family: var(--serif); font-weight: 400; font-size: var(--step-2); color: var(--accent); }

/* ---------- Share ---------- */
.linkbox {
  display: flex;
  gap: .5rem;
  align-items: stretch;
}
.linkbox input {
  flex: 1;
  min-width: 0;
  font: var(--step-0) var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: .75rem;
}
.linkbox .btn { width: auto; flex: none; }
.message {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 1rem 1.1rem;
  font-size: var(--step-1);
}
.private {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-m);
  padding: 1rem 1.1rem;
}

/* ---------- Timer: the one loud thing ---------- */
.timer {
  position: fixed;
  inset: 0 0 auto 0;
  height: 10px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  z-index: 10;
  opacity: 0;
  transition: opacity .2s;
}
.timer.is-on { opacity: 1; }
.timer__sand {
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(1);
}
.timer.is-low .timer__sand { background: var(--wrong); }

/* ---------- Question ---------- */
.qhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
  margin-bottom: 1.75rem;
}
.qhead .secs { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); font-size: var(--step-1); }
.qhead .secs.is-low { color: var(--wrong); }
.question {
  font-size: clamp(var(--step-2), 6.5vw, var(--step-3));
  margin-bottom: 2rem;
  min-height: 3em;
}
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.option {
  appearance: none;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: .75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  font: var(--step-1)/1.3 var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: .9rem 1rem;
  min-height: 3.5rem;
  cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option kbd {
  font: 700 var(--step--1) var(--sans);
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
  border-radius: 4px;
  text-align: center;
  padding: .1rem 0;
}
.option.is-picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.options.is-locked .option { pointer-events: none; }
.options.is-locked .option:not(.is-picked) { opacity: .45; }

/* ---------- Section intro ---------- */
.section-count { color: var(--accent); font-family: var(--serif); font-size: var(--step-2); }
.section-title { font-size: clamp(var(--step-4), 13vw, var(--step-5)); letter-spacing: -0.02em; }

/* ---------- Results ---------- */
.score {
  font-family: var(--serif);
  font-size: clamp(6rem, 30vw, 9rem);
  line-height: .9;
  letter-spacing: -0.03em;
}
.score small { font-size: .35em; color: var(--ink-soft); letter-spacing: 0; }
.verdict { font-size: var(--step-3); }
.sections { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--line); }
.sections li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem 1rem;
  padding: .9rem 0;
  border-bottom: 1.5px solid var(--line);
}
.sections .pips { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.pip { height: 8px; border-radius: 2px; background: var(--line); }
.pip.is-right { background: var(--accent); }
.sections .n { font-variant-numeric: tabular-nums; font-weight: 700; }
.flag { padding: .9rem 1rem; border-radius: var(--radius-s); background: var(--surface); }
.flag--warn { border-left: 4px solid var(--wrong); }

details.missed summary { cursor: pointer; font-weight: 700; padding: .5rem 0; }
.missed ol { margin: .5rem 0 0; padding-left: 1.25rem; }
.missed li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.missed .their { color: var(--wrong); }
.missed .right { color: var(--right); font-weight: 700; }

.attempts { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.attempts a {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1rem; background: var(--surface); border-radius: var(--radius-s);
  text-decoration: none; border: 1.5px solid var(--line);
}

@media (min-width: 640px) {
  .shell { padding-top: 5rem; }
  .options { grid-template-columns: 1fr 1fr; }
  .option { min-height: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .timer { transition: none; }
}
.question:focus { outline: none; }

/* ---------- Maps ---------- */
:root {
  --map-water: #E3E8F0;
  --map-land: #FBFBF9;
  --map-border: #B9BDCB;
  --map-target: var(--lapis);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --map-water: #0E1534;
    --map-land: #2A3470;
    --map-border: #44508C;
    --map-target: var(--ochre-bright);
  }
}
:root[data-theme="dark"] {
  --map-water: #0E1534;
  --map-land: #2A3470;
  --map-border: #44508C;
  --map-target: var(--ochre-bright);
}
.map-frame { margin: -0.75rem 0 1.25rem; }
.map {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-m);
  border: 1.5px solid var(--line);
}
.map__water { fill: var(--map-water); }
.map__land { fill: var(--map-land); }
.map__borders { fill: none; stroke: var(--map-border); stroke-width: 1.4; stroke-linejoin: round; }
.map__target { fill: var(--map-target); stroke: var(--map-target); stroke-width: 1; stroke-linejoin: round; }
.question--map { min-height: 0; font-size: var(--step-2); }
.map--thumb { width: 9rem; margin: .4rem 0; border-radius: var(--radius-s); }
@media (min-width: 640px) {
  .map-frame { max-width: 30rem; }
}

/* Map questions: keep the map and all four answers on one phone screen. */
.options--map { grid-template-columns: 1fr 1fr; gap: .5rem; }
.options--map .option { min-height: 3.25rem; padding: .65rem .75rem; font-size: var(--step-0); grid-template-columns: 1.6rem 1fr; gap: .5rem; }
.question--map { margin-bottom: 1rem; }
.map-frame { margin: 0 0 1rem; }
@media (max-width: 639px) {
  .qhead { margin-bottom: 1rem; }
  .shell:has(.map-frame) { padding-top: 1.75rem; }
}

/* ---------- The Sphinx ---------- */
.sphinx {
  display: block;
  height: auto;
  --s-body: var(--lapis);
  --s-wing: var(--ochre);
  --s-feather: var(--lapis);
  --s-detail: var(--ochre);
  --s-crown: var(--ochre);
  --s-cut: var(--bg);
}
.sphinx .ink { fill: var(--s-body); }
.sphinx .wing { fill: var(--s-wing); }
.sphinx .ink-stroke { fill: none; stroke: var(--s-body); stroke-width: 7; stroke-linecap: round; }
.sphinx .line { fill: none; stroke: var(--s-detail); stroke-width: 3; stroke-linecap: round; }
.sphinx .feather { stroke: var(--s-feather); }
.sphinx .thin { stroke-width: 2; }
.sphinx .crown { fill: var(--s-crown); }
.sphinx .eye { fill: var(--s-cut); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sphinx {
    --s-body: var(--marble); --s-wing: var(--ochre-bright); --s-feather: var(--lapis-deep);
    --s-detail: var(--ochre-bright); --s-crown: var(--ochre-bright);
  }
}
:root[data-theme="dark"] .sphinx {
  --s-body: var(--marble); --s-wing: var(--ochre-bright); --s-feather: var(--lapis-deep);
  --s-detail: var(--ochre-bright); --s-crown: var(--ochre-bright);
}

/* Home: three-line title, the Sphinx seated to the right of "Pass" and "the". */
.hero-title--home { position: relative; }
.sphinx--hero {
  position: absolute;
  right: 0;
  bottom: 1.15em;
  width: min(40vw, 12rem);
}
.sphinx--intro { width: 6.5rem; margin: 0 0 -.5rem auto; }
@media (min-width: 640px) {
  .sphinx--hero { width: 14rem; bottom: 0.35em; right: -1rem; }
}
/* The page container takes focus on screen changes for screen readers; it never needs a visible ring. */
.shell:focus, .shell:focus-visible { outline: none; }
.attempt-pending {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 1rem; border-radius: var(--radius-s); border: 1.5px dashed var(--line);
}
