/* Shared spacing rhythm. Loaded on first paint; the body scope deliberately
   outranks the older stylesheets appended by the experience scripts. */
:root {
  --anomalie-space-1: 0.25rem;
  --anomalie-space-2: 0.5rem;
  --anomalie-space-3: 0.75rem;
  --anomalie-space-4: 1rem;
  --anomalie-space-5: 1.25rem;
  --anomalie-space-6: 1.5rem;
  --anomalie-space-8: 2rem;
  --anomalie-space-10: 2.5rem;
  --anomalie-space-12: 3rem;
  --anomalie-space-16: 4rem;
  --anomalie-space-24: 6rem;
  --anomalie-page-gutter: clamp(1.25rem, 6vw, 6rem);
  --anomalie-section-space: clamp(4rem, 8vw, 7rem);
  --anomalie-panel-padding: clamp(1.5rem, 3vw, 2.5rem);
  --anomalie-label-gap: clamp(1.5rem, 3vw, 2rem);
}

/* Page rhythm and first-screen breathing room. The hero must accommodate
   long rotating messages and returning-visitor text without clipping. */
body.anomalie-site header {
  padding-inline: var(--anomalie-page-gutter);
  gap: var(--anomalie-space-6);
}
body.anomalie-site header .logo.logo-anomalie {
  gap: var(--anomalie-space-3);
}
body.anomalie-site header nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-block: var(--anomalie-space-2);
}
body.anomalie-site .hero.hero-anomaly {
  height: auto;
  min-height: 100svh;
  max-height: none;
}
body.anomalie-site .hero.hero-anomaly .hero-inner {
  padding: clamp(8rem, 16vh, 12rem) var(--anomalie-space-6) var(--anomalie-space-24);
}
body.anomalie-site .hero.hero-anomaly .eyebrow {
  margin: 0 0 var(--anomalie-space-6);
  line-height: 1.65;
}
body.anomalie-site .hero.hero-anomaly h1 {
  margin: 0 0 var(--anomalie-space-8);
}
body.anomalie-site .hero.hero-anomaly .hero-inner > p:not(.hero-thought) {
  margin: 0 auto var(--anomalie-space-8);
}
body.anomalie-site .hero.hero-anomaly .primary {
  min-height: 52px;
  max-width: 100%;
  padding: var(--anomalie-space-4) var(--anomalie-space-6);
  line-height: 1.5;
}
body.anomalie-site .hero.hero-anomaly p.hero-thought {
  margin: var(--anomalie-space-6) auto 0;
}
body.anomalie-site .hero.hero-anomaly .footnote {
  margin-top: var(--anomalie-space-6);
}
body.anomalie-site .hero.hero-anomaly .hero-variation {
  margin-top: var(--anomalie-space-4);
}
body.anomalie-site .return-signal {
  padding: var(--anomalie-space-3) var(--anomalie-space-4);
  line-height: 1.65;
}
body.anomalie-site .hero.hero-anomaly .corner {
  bottom: var(--anomalie-space-6);
  line-height: 1.6;
}
body.anomalie-site .intro,
body.anomalie-site .worlds,
body.anomalie-site .quote,
body.anomalie-site .architect,
body.anomalie-site .anomaly-banner {
  padding: var(--anomalie-section-space) var(--anomalie-page-gutter);
}
body.anomalie-site .meta,
body.anomalie-site .anomaly-banner .tiny {
  line-height: 1.7;
}
body.anomalie-site .intro-grid {
  margin-top: var(--anomalie-space-12);
  gap: var(--anomalie-space-12);
}
body.anomalie-site .intro-grid p {
  margin: 0;
}
body.anomalie-site .intro-grid p + p {
  margin-top: var(--anomalie-space-6);
}
body.anomalie-site .intro small {
  margin-top: var(--anomalie-space-8);
  padding-top: var(--anomalie-space-6);
  line-height: 1.7;
}
body.anomalie-site .anomaly-banner > strong {
  margin: var(--anomalie-space-6) auto;
}

/* Worlds, route navigation, and the progress panel. */
body.anomalie-site .world-heading {
  position: relative;
  gap: var(--anomalie-space-8);
  margin-bottom: var(--anomalie-space-8);
}
body.anomalie-site .world-heading:after {
  top: 0;
  right: 0;
  margin: 0;
}
body.anomalie-site .worlds h2 {
  margin-top: var(--anomalie-space-6);
}
body.anomalie-site .world-heading .count {
  flex-shrink: 0;
  line-height: 1.6;
}
body.anomalie-site .signal-route {
  gap: var(--anomalie-space-3);
  margin: 0 0 var(--anomalie-space-8);
}
body.anomalie-site .signal-route .route-label {
  margin: 0;
  line-height: 1.7;
}
body.anomalie-site .signal-route a {
  min-height: 44px;
  padding: var(--anomalie-space-3) var(--anomalie-space-4);
  line-height: 1.5;
}
body.anomalie-site .consequence-route {
  margin: 0 0 var(--anomalie-space-8);
  padding: var(--anomalie-panel-padding);
}
body.anomalie-site .consequence-route .route-heading h3 {
  margin: var(--anomalie-space-3) 0 var(--anomalie-space-6);
}
body.anomalie-site .science-route-row {
  grid-template-columns: 100px minmax(0, 1fr) auto;
  gap: var(--anomalie-space-3) var(--anomalie-space-4);
  padding: var(--anomalie-space-4) 0;
}
body.anomalie-site .science-route-row > * {
  min-width: 0;
  line-height: 1.6;
}
body.anomalie-site .science-route-row a {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  padding-block: var(--anomalie-space-2);
}
body.anomalie-site .consequence-route .science-method {
  margin: var(--anomalie-space-6) 0 0;
}
body.anomalie-site .cards {
  gap: var(--anomalie-space-6);
}
body.anomalie-site .world {
  height: auto;
  min-height: clamp(28rem, 42vw, 34rem);
  padding: var(--anomalie-panel-padding);
  gap: var(--anomalie-space-24);
}
body.anomalie-site .world .card-top {
  gap: var(--anomalie-space-3);
  flex-wrap: wrap;
  align-items: flex-start;
  line-height: 1.6;
}
body.anomalie-site .world .card-top .status {
  margin-inline-start: auto;
  text-align: right;
}
body.anomalie-site .world .card-bottom {
  max-width: 100%;
  min-width: 0;
}
body.anomalie-site .world .card-bottom small {
  margin-bottom: var(--anomalie-space-4);
  line-height: 1.6;
}
body.anomalie-site .world .card-bottom > span {
  margin-top: var(--anomalie-space-6);
  line-height: 1.6;
}
body.anomalie-site .world .card-bottom .echo-note {
  margin-top: var(--anomalie-space-3);
}
body.anomalie-site .cards-footer {
  margin-top: var(--anomalie-space-6);
  gap: var(--anomalie-space-4);
  line-height: 1.7;
}
body.anomalie-site .route-toast {
  bottom: max(var(--anomalie-space-6), env(safe-area-inset-bottom));
  max-width: calc(100% - 2rem);
  padding: var(--anomalie-space-4) var(--anomalie-space-6);
  line-height: 1.6;
}

/* Fifth signal: a real gap BEFORE the border, then a deliberate inner rhythm. */
body.anomalie-site #fifth > .tiny {
  margin: 0 0 var(--anomalie-label-gap);
}
body.anomalie-site #fifth .hidden-signal {
  margin: 0 auto;
  padding: clamp(2.5rem, 5vw, 3.5rem) var(--anomalie-panel-padding);
}
body.anomalie-site #fifth .fifth-sigil {
  margin: 0 auto var(--anomalie-space-8);
}
body.anomalie-site #fifth .hidden-signal > .tiny {
  margin: 0;
  line-height: 1.7;
}
body.anomalie-site #fifth .hidden-signal h3 {
  margin: var(--anomalie-space-6) 0;
}
body.anomalie-site #fifth .hidden-signal p {
  margin: 0 auto var(--anomalie-space-8);
}
body.anomalie-site #fifth .hidden-signal button {
  min-height: 52px;
  max-width: 100%;
  padding: var(--anomalie-space-4) var(--anomalie-space-6);
  line-height: 1.6;
}

/* Closing sections and footer. */
body.anomalie-site .quote .meta {
  margin-bottom: var(--anomalie-space-8);
}
body.anomalie-site .quote blockquote {
  margin: 0 auto var(--anomalie-space-12);
}
body.anomalie-site .quote-credit {
  gap: var(--anomalie-space-4) var(--anomalie-space-8);
  padding-top: var(--anomalie-space-6);
  line-height: 1.7;
}
body.anomalie-site .architect-box {
  margin-top: var(--anomalie-space-8);
  padding: var(--anomalie-panel-padding);
  gap: var(--anomalie-space-12);
}
body.anomalie-site footer {
  padding: var(--anomalie-space-8) var(--anomalie-page-gutter);
  padding-bottom: max(var(--anomalie-space-8), env(safe-area-inset-bottom));
  align-items: center;
  flex-wrap: wrap;
  gap: var(--anomalie-space-4) var(--anomalie-space-8);
  line-height: 1.7;
}
body.anomalie-site footer .anomalie-reset-link {
  min-height: 44px;
  padding: var(--anomalie-space-3) 0;
}

/* Dialog shell: maintain edge space, allow long labels to wrap, and separate
   headers/footers from the scene rather than accumulating arbitrary margins. */
body.anomalie-site #dialog {
  width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.anomalie-site #dialog .modal {
  padding: var(--anomalie-panel-padding);
}
body.anomalie-site #dialog .modal-head,
body.anomalie-site #dialog .modal-foot {
  flex-wrap: wrap;
  align-items: center;
  gap: var(--anomalie-space-3) var(--anomalie-space-6);
  line-height: 1.6;
}
body.anomalie-site #dialog .modal-head {
  padding-bottom: var(--anomalie-space-6);
}
body.anomalie-site #dialog .modal-head > span {
  min-width: 0;
  flex: 1 1 160px;
  overflow-wrap: anywhere;
}
body.anomalie-site #dialog .modal-head button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: center;
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: normal;
}
body.anomalie-site #dialog .modal-foot {
  margin-top: var(--anomalie-space-8);
  padding-top: var(--anomalie-space-6);
}
body.anomalie-site #modal-content {
  display: flow-root;
  padding-top: var(--anomalie-space-8);
}
body.anomalie-site #modal-content :is(h1, h2, h3, h4, h5, h6) {
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: anywhere;
}
body.anomalie-site #modal-content > * {
  margin-block: 0;
}
body.anomalie-site #modal-content > * + * {
  margin-block-start: var(--anomalie-space-6);
}
body.anomalie-site #modal-content > .experience-track + .experience-scene {
  margin-block-start: var(--anomalie-space-4);
}
body.anomalie-site #modal-content > :is(.science-phase, .experience-step) + h2 {
  margin-block-start: var(--anomalie-space-3);
}
body.anomalie-site #modal-content > .dialog-kicker + :is(h2, .experience-dialog-title) {
  margin-block-start: var(--anomalie-space-4);
}
body.anomalie-site #modal-content > h2 + .dialog-copy,
body.anomalie-site #modal-content > .dialog-copy + .dialog-copy {
  margin-block-start: var(--anomalie-space-4);
}
body.anomalie-site #modal-content > .experience-foot {
  margin-block-start: var(--anomalie-space-8);
  line-height: 1.7;
}
body.anomalie-site #modal-content .dialog-kicker,
body.anomalie-site #modal-content .science-phase,
body.anomalie-site #modal-content .experience-step {
  line-height: 1.7;
}
body.anomalie-site #modal-content .experience-track {
  gap: var(--anomalie-space-3);
}
body.anomalie-site #modal-content .experience-scene .scene-code {
  bottom: var(--anomalie-space-4);
  left: var(--anomalie-space-4);
  right: var(--anomalie-space-4);
  line-height: 1.6;
}
body.anomalie-site #modal-content .experience-stat {
  gap: var(--anomalie-space-4);
}

/* Questions, answers, feedback, and puzzle controls. */
body.anomalie-site #modal-content #science-options {
  display: grid;
  gap: var(--anomalie-space-4);
}
body.anomalie-site #modal-content #science-options > * {
  margin: 0;
}
body.anomalie-site #modal-content #science-options > .science-continue {
  margin-top: var(--anomalie-space-2);
  justify-self: start;
}
body.anomalie-site #modal-content .options {
  gap: var(--anomalie-space-3);
}
body.anomalie-site #modal-content .science-option,
body.anomalie-site #modal-content .option {
  min-height: 48px;
  padding: var(--anomalie-space-4) var(--anomalie-space-5);
  line-height: 1.55;
}
body.anomalie-site #modal-content .science-reaction,
body.anomalie-site #modal-content .experience-response,
body.anomalie-site #modal-content .reflection,
body.anomalie-site #modal-content .science-branch {
  padding: var(--anomalie-space-6);
}
body.anomalie-site #modal-content .experience-response {
  margin: 0;
}
body.anomalie-site #modal-content .experience-response + .experience-next {
  margin-top: var(--anomalie-space-6);
}
body.anomalie-site #modal-content .science-reaction b,
body.anomalie-site #modal-content .experience-response strong,
body.anomalie-site #modal-content .science-branch b {
  margin-bottom: var(--anomalie-space-3);
  line-height: 1.7;
}
body.anomalie-site #modal-content .science-continue,
body.anomalie-site #modal-content .experience-next,
body.anomalie-site #modal-content .finish,
body.anomalie-site #modal-content .science-replay {
  min-height: 48px;
  max-width: 100%;
  padding: var(--anomalie-space-4) var(--anomalie-space-6);
  line-height: 1.6;
}
body.anomalie-site #modal-content .fragment-puzzle {
  gap: var(--anomalie-space-4);
}
body.anomalie-site #modal-content .fragment-puzzle button {
  padding: var(--anomalie-space-5);
  line-height: 1.6;
  min-height: 64px;
}
body.anomalie-site #modal-content .assembled {
  padding: var(--anomalie-space-5);
  line-height: 1.6;
}
body.anomalie-site #modal-content .assembled:empty:before {
  line-height: 1.7;
}
body.anomalie-site #modal-content .puzzle-actions {
  gap: var(--anomalie-space-3);
}
body.anomalie-site #modal-content .puzzle-actions button,
body.anomalie-site #modal-content .code-input button,
body.anomalie-site #modal-content .puzzle-form button {
  min-height: 48px;
  padding: var(--anomalie-space-4) var(--anomalie-space-5);
  line-height: 1.6;
}
body.anomalie-site #modal-content .code-input,
body.anomalie-site #modal-content .puzzle-form {
  gap: var(--anomalie-space-3);
}
body.anomalie-site #modal-content .code-input input,
body.anomalie-site #modal-content .puzzle-form input {
  padding: var(--anomalie-space-4);
  min-height: 48px;
}

/* World endings and the final reveal follow the same rhythm as the questions. */
body.anomalie-site #modal-content .science-ending {
  padding: var(--anomalie-space-8) var(--anomalie-space-6);
}
body.anomalie-site #modal-content .science-ending .ending-symbol {
  margin-bottom: var(--anomalie-space-4);
  line-height: 1.15;
}
body.anomalie-site #modal-content .science-ending .science-outcome {
  line-height: 1.7;
}
body.anomalie-site #modal-content .science-ending h2 {
  margin: var(--anomalie-space-4) 0;
}
body.anomalie-site #modal-content .science-ending p {
  margin: 0 auto;
}
body.anomalie-site #modal-content > .epilogue {
  padding: 0;
}
body.anomalie-site #modal-content .epilogue > * {
  margin-block: 0;
}
body.anomalie-site #modal-content .epilogue > * + * {
  margin-block-start: var(--anomalie-space-6);
}
body.anomalie-site #modal-content .epilogue > .dialog-kicker + h2 {
  margin-block-start: var(--anomalie-space-4);
}
body.anomalie-site #modal-content .epilogue > blockquote {
  padding: var(--anomalie-space-6);
  margin-inline: 0;
}
body.anomalie-site #modal-content .epilogue > p + p {
  margin-block-start: var(--anomalie-space-4);
}
body.anomalie-site #modal-content .epilogue > .architect-reveal,
body.anomalie-site #modal-content .epilogue > .science-final-variant {
  margin-block-start: var(--anomalie-space-8);
  padding: var(--anomalie-panel-padding);
}
body.anomalie-site #modal-content .architect-reveal small,
body.anomalie-site #modal-content .science-final-variant > b {
  display: block;
  line-height: 1.7;
}
body.anomalie-site #modal-content .architect-reveal h3,
body.anomalie-site #modal-content .science-final-variant h3 {
  margin: var(--anomalie-space-4) 0;
}
body.anomalie-site #modal-content .architect-reveal p,
body.anomalie-site #modal-content .science-final-variant p {
  margin: var(--anomalie-space-4) 0 0;
}
body.anomalie-site #modal-content .architect-reveal a {
  margin-top: var(--anomalie-space-6);
  padding-block: var(--anomalie-space-3);
  line-height: 1.7;
}

/* Intro and reset dialogs must also fit a short or narrow viewport. */
body.anomalie-site #intro-signal {
  overflow-y: auto;
  padding: var(--anomalie-space-6) var(--anomalie-space-4);
  place-items: safe center;
}
body.anomalie-site #intro-signal .terminal-box {
  max-width: 100%;
  padding: var(--anomalie-panel-padding);
}
body.anomalie-site #intro-signal .terminal-label {
  line-height: 1.7;
}
body.anomalie-site #intro-signal .terminal-title {
  margin: var(--anomalie-space-6) 0;
}
body.anomalie-site #intro-signal .terminal-text {
  min-height: 0;
}
body.anomalie-site #intro-signal .terminal-button {
  margin-top: var(--anomalie-space-6);
  padding: var(--anomalie-space-4) var(--anomalie-space-5);
  min-height: 48px;
  max-width: 100%;
  line-height: 1.5;
}
body.anomalie-site #intro-signal .terminal-skip {
  margin-top: var(--anomalie-space-4);
  line-height: 1.7;
}
body.anomalie-site dialog.anomalie-reset-dialog {
  width: min(470px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: var(--anomalie-panel-padding);
  overflow-y: auto;
}
body.anomalie-site .anomalie-reset-dialog h2 {
  margin: var(--anomalie-space-4) 0 var(--anomalie-space-6);
}
body.anomalie-site .anomalie-reset-dialog p {
  margin: var(--anomalie-space-4) 0 0;
}
body.anomalie-site .anomalie-reset-dialog .reset-actions {
  margin-top: var(--anomalie-space-8);
  gap: var(--anomalie-space-3);
}
body.anomalie-site .anomalie-reset-dialog .reset-actions button {
  padding: var(--anomalie-space-4);
  line-height: 1.5;
}

@media (max-width: 760px) {
  body.anomalie-site .intro-grid {
    margin-top: var(--anomalie-space-8);
    gap: var(--anomalie-space-8);
  }
  body.anomalie-site .world-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--anomalie-space-6);
  }
  body.anomalie-site .world-heading:after {
    display: none;
  }
  body.anomalie-site .world-heading .count {
    flex-direction: row;
    align-items: baseline;
    gap: var(--anomalie-space-3);
  }
  body.anomalie-site .signal-route .route-label {
    width: 100%;
  }
  body.anomalie-site .architect-box {
    gap: var(--anomalie-space-8);
  }
}
@media (max-width: 600px) {
  body.anomalie-site .science-route-row {
    grid-template-columns: minmax(72px, 82px) minmax(0, 1fr);
    align-items: start;
  }
  body.anomalie-site .science-route-row a {
    grid-column: 2;
  }
  body.anomalie-site footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
@media (max-width: 400px) {
  body.anomalie-site .hero.hero-anomaly .hero-inner {
    padding-inline: var(--anomalie-space-4);
  }
  body.anomalie-site header {
    gap: var(--anomalie-space-4);
  }
  body.anomalie-site #dialog .modal,
  body.anomalie-site #intro-signal .terminal-box,
  body.anomalie-site dialog.anomalie-reset-dialog {
    padding: var(--anomalie-space-5);
  }
  body.anomalie-site #modal-content .puzzle-actions {
    flex-direction: column;
  }
  body.anomalie-site #modal-content .puzzle-actions button {
    width: 100%;
  }
  body.anomalie-site #modal-content .science-reaction,
  body.anomalie-site #modal-content .science-ending,
  body.anomalie-site #modal-content .epilogue > .architect-reveal,
  body.anomalie-site #modal-content .epilogue > .science-final-variant {
    padding: var(--anomalie-space-5);
  }
}

@media (max-width: 760px) {
  body.anomalie-site .world .card-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    gap: 0.375rem;
  }
  body.anomalie-site .world .card-top .status {
    margin-inline-start: 0;
    text-align: start;
    letter-spacing: 0.05em;
    line-height: 1.4;
    padding: 0.125em 0.45em;
    background: #071a2ded;
    border-radius: 0.2rem;
  }
}

@media (min-width: 761px) {
  body.anomalie-site #dialog #close {
    border: 1px solid #668ca8;
    background-color: #10283d;
  }
}
@media (min-width: 761px) and (hover: hover) and (pointer: fine) {
  body.anomalie-site #dialog #close:hover {
    border-color: #afd5ec;
    background-color: #19374e;
  }
}

footer:has(.privacy-notice[open]) {
  flex-wrap: wrap;
}
footer .privacy-notice[open] {
  flex-basis: 100%;
}
.privacy-notice summary {
  cursor: pointer;
}
.privacy-notice div {
  max-width: 65ch;
  font:
    1.0625rem/1.6 'Space Grotesk',
    sans-serif;
  color: #c7dbee;
  letter-spacing: normal;
}
.privacy-notice h2 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
}
.privacy-notice a {
  text-decoration: underline;
}

@media (max-width: 760px) {
  body.anomalie-site .signal-route {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
  }
  body.anomalie-site .signal-route a {
    justify-content: flex-start;
  }
}

#privacy-dialog {
  width: min(44rem, calc(100% - 2rem));
  max-height: 80dvh;
  overflow: auto;
  overscroll-behavior: contain;
}
#privacy-dialog article {
  padding: 0 clamp(1rem, 4vw, 2rem) 1rem;
  font-size: 1.1rem;
  line-height: 1.6;
}
#privacy-dialog article h2 {
  font-size: 1.3rem;
  margin: 1.5rem 0 0.5rem;
}
#privacy-dialog #privacy-heading {
  font-size: clamp(1.4rem, 6vw, 2rem);
  margin-top: 0.5rem;
}
#privacy-dialog article a,
footer a,
#intro-signal a {
  text-decoration: underline;
}
#privacy-dialog form {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0.6rem 1rem;
  background: #071a30;
}
#privacy-dialog form button {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  background: #10283d;
  color: #c6e9ff;
  border: 1px solid #668ca8;
  border-radius: 0.25rem;
}

body.anomalie-site #fifth .hidden-signal.solved #secret-button {
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: 1px solid #719ab5;
  background: #10283d;
  color: #c4e8ff;
  letter-spacing: 0.02em;
  line-height: 1.35;
}
