:root {
  color-scheme: light;
  --ink: #111111;
  --paper: #f3ead8;
  --paper-light: #fff9ec;
  --paper-muted: #bdb29f;
  --accent: #efb92f;
  --accent-two: #dc5f3d;
  --display: "Archivo Black", "Arial Black", sans-serif;
  --sans: "Source Serif 4", Georgia, serif;
  --ui: "Space Mono", "Courier New", monospace;
  --page-pad: clamp(1rem, 3vw, 3.5rem);
  --rule: 2px solid var(--ink);
  --hard-shadow: clamp(0.35rem, 0.8vw, 0.75rem) clamp(0.35rem, 0.8vw, 0.75rem) 0 var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body[data-result="1"] {
  --accent: #edb832;
  --accent-two: #d95d3b;
}

body[data-result="2"] {
  --accent: #72c2ba;
  --accent-two: #de8daf;
}

body[data-result="3"] {
  --accent: #aa8fc7;
  --accent-two: #e3cf63;
}

body[data-result="4"] {
  --accent: #d95643;
  --accent-two: #dba653;
}

body[data-result="5"] {
  --accent: #7aaa69;
  --accent-two: #4c8fba;
}

body[data-result="6"] {
  --accent: #6e9ecb;
  --accent-two: #bd85c5;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5rem;
  padding: 1rem var(--page-pad);
  border-bottom: var(--rule);
  background: var(--paper-light);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: inherit;
  text-decoration: none;
}

.wordmark > span {
  padding: 0.3rem 0.45rem 0.2rem;
  background: var(--ink);
  color: var(--paper-light);
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.12em;
}

.wordmark small {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.utility-button,
.text-button {
  border: 0;
  background: transparent;
  font: 700 0.67rem/1 var(--sans);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
}

.utility-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.75rem 0.9rem;
  border: var(--rule);
  background: var(--paper-light);
}

.utility-button:hover {
  background: var(--accent);
}

.sound-icon {
  font-size: 1rem;
}

main {
  width: min(100%, 110rem);
  margin-inline: auto;
}

.opening {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(19rem, 0.85fr);
  align-items: center;
  gap: clamp(2rem, 7vw, 8rem);
  min-height: min(78rem, calc(100svh - 5rem));
  padding: clamp(3rem, 7vh, 7rem) var(--page-pad);
}

.opening-copy {
  position: relative;
  container-type: inline-size;
}

.opening-copy::before {
  content: "01—06";
  position: absolute;
  top: -2.2rem;
  right: 0;
  padding-bottom: 0.2rem;
  border-bottom: var(--rule);
  font: 700 0.68rem/1 var(--sans);
  letter-spacing: 0.18em;
}

.eyebrow,
.ritual-label,
.story-label {
  margin: 0;
  font-size: clamp(0.65rem, 0.9vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 1.1rem 0 1.8rem;
  font-family: var(--display);
  font-size: clamp(3.2rem, 8vw, 9.6rem);
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

h1 span {
  display: block;
  max-width: 100%;
  width: fit-content;
  overflow-wrap: normal;
  white-space: nowrap;
}

h1 span:last-child {
  margin-top: 0.12em;
  padding: 0.08em 0.12em 0.03em;
  background: var(--ink);
  color: var(--paper-light);
  transform: rotate(-1deg);
}

@media (min-width: 901px) {
  h1 {
    /* Size against the copy column, not the full two-column viewport. */
    font-size: clamp(3.2rem, 13cqw, 9.6rem);
  }
}

.opening-intro {
  max-width: 43rem;
  margin: 0;
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  line-height: 1.65;
}

.key-hint {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 2rem 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

kbd {
  min-width: 1.6rem;
  padding: 0.3rem 0.45rem;
  border: var(--rule);
  background: var(--paper-light);
  font: inherit;
  text-align: center;
}

.ritual-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(28rem, 49vw, 39rem);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  border: 3px solid var(--ink);
  background: var(--accent);
  box-shadow: var(--hard-shadow);
}

.ritual-panel::before {
  content: "";
  position: absolute;
  inset: 1rem;
  border: 1px dashed var(--ink);
  pointer-events: none;
}

.ritual-label {
  position: absolute;
  top: clamp(1.8rem, 5vw, 3.6rem);
  padding: 0.35rem 0.55rem;
  background: var(--paper-light);
  border: 1px solid var(--ink);
}

.dice-trigger {
  position: relative;
  display: grid;
  place-items: center;
  gap: 1.8rem;
  width: min(100%, 25rem);
  padding: 2rem;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.dice-trigger:disabled {
  cursor: wait;
}

.dice-orbit {
  display: none;
}

.dice-face {
  --die-size: clamp(7.5rem, 14vw, 10.5rem);
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  width: var(--die-size);
  height: var(--die-size);
  aspect-ratio: 1;
  padding: calc(var(--die-size) * 0.14);
  border: 3px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 0.55rem 0.55rem 0 var(--ink);
  transform: rotate(-5deg);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.dice-trigger:hover .dice-face {
  box-shadow: 0.8rem 0.8rem 0 var(--ink);
  transform: rotate(3deg) translate(-0.2rem, -0.2rem);
}

.dice-face i {
  align-self: center;
  justify-self: center;
  width: clamp(0.75rem, 1.5vw, 1.1rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
}

.dice-face[data-face="1"] i:nth-child(5),
.dice-face[data-face="2"] i:nth-child(1),
.dice-face[data-face="2"] i:nth-child(9),
.dice-face[data-face="3"] i:nth-child(1),
.dice-face[data-face="3"] i:nth-child(5),
.dice-face[data-face="3"] i:nth-child(9),
.dice-face[data-face="4"] i:nth-child(1),
.dice-face[data-face="4"] i:nth-child(3),
.dice-face[data-face="4"] i:nth-child(7),
.dice-face[data-face="4"] i:nth-child(9),
.dice-face[data-face="5"] i:nth-child(1),
.dice-face[data-face="5"] i:nth-child(3),
.dice-face[data-face="5"] i:nth-child(5),
.dice-face[data-face="5"] i:nth-child(7),
.dice-face[data-face="5"] i:nth-child(9),
.dice-face[data-face="6"] i:nth-child(1),
.dice-face[data-face="6"] i:nth-child(3),
.dice-face[data-face="6"] i:nth-child(4),
.dice-face[data-face="6"] i:nth-child(6),
.dice-face[data-face="6"] i:nth-child(7),
.dice-face[data-face="6"] i:nth-child(9) {
  opacity: 1;
}

.is-rolling .dice-face {
  animation: dice-roll 170ms steps(2, end) infinite;
}

.dice-cta {
  display: grid;
  gap: 0.4rem;
  text-align: center;
}

.dice-cta strong {
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.4rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dice-cta small,
.roll-status {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.roll-status {
  position: absolute;
  bottom: clamp(1.8rem, 4vw, 3.2rem);
  margin: 0;
}

.journey-progress {
  padding: 2.5rem var(--page-pad) 4rem;
  border-block: var(--rule);
  background: var(--ink);
  color: var(--paper-light);
}

.progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.progress-heading > p:last-child {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.journey-progress ol {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(0.35rem, 1.2vw, 1rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.journey-progress button {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--paper-light);
  cursor: pointer;
}

.journey-progress button:disabled {
  cursor: default;
}

.journey-progress button > span {
  display: grid;
  place-items: center;
  width: 3.2rem;
  aspect-ratio: 1;
  border: 2px solid var(--paper-light);
  background: var(--ink);
  font-family: var(--display);
  font-size: 1.3rem;
  transition: transform 160ms ease, background-color 160ms ease;
}

.journey-progress button small {
  font-size: clamp(0.58rem, 0.8vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.journey-progress button.is-discovered > span {
  border-color: var(--paper-light);
  background: var(--accent);
  color: var(--ink);
}

.journey-progress button.is-discovered:hover > span {
  transform: rotate(-4deg) scale(1.06);
}

.journey-progress button.is-active > span {
  box-shadow: 0.3rem 0.3rem 0 var(--paper-light);
  transform: translate(-0.15rem, -0.15rem);
}

.result-view {
  min-height: 100svh;
  padding: clamp(4rem, 8vw, 9rem) var(--page-pad);
  border-bottom: var(--rule);
  background: var(--paper-light);
  animation: result-enter 450ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.result-heading {
  display: grid;
  grid-template-columns: minmax(12rem, 0.55fr) minmax(0, 1fr);
  align-items: center;
  column-gap: clamp(2rem, 6vw, 8rem);
}

.result-heading > .eyebrow {
  grid-column: 1 / -1;
  margin-bottom: 1rem;
}

.result-number {
  display: grid;
  place-items: center;
  min-height: clamp(12rem, 24vw, 24rem);
  margin: 0;
  border: 3px solid var(--ink);
  background: var(--accent);
  box-shadow: var(--hard-shadow);
  font-family: var(--display);
  font-size: clamp(10rem, 22vw, 23rem);
  font-weight: 400;
  line-height: 0.7;
  text-align: center;
}

.result-heading h2,
.completion h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.5rem, 8vw, 8rem);
  font-weight: 400;
  line-height: 0.86;
  letter-spacing: 0.015em;
  text-transform: uppercase;
}

.result-keywords {
  width: fit-content;
  margin: 1.4rem 0 0;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--ink);
  background: var(--accent);
  font-size: clamp(0.7rem, 1vw, 0.86rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-composition {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.65fr);
  gap: clamp(2rem, 6vw, 7rem);
  align-items: center;
  margin-top: clamp(3rem, 6vw, 7rem);
}

.result-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(25rem, 52vw, 48rem);
  padding: clamp(1rem, 3vw, 3rem);
  overflow: hidden;
  border: 3px solid var(--ink);
  background: var(--accent);
  box-shadow: var(--hard-shadow);
  isolation: isolate;
}

.result-art::before {
  content: attr(data-number);
  position: absolute;
  right: -0.03em;
  bottom: -0.22em;
  z-index: -1;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(20rem, 54vw, 52rem);
  line-height: 1;
  opacity: 0.09;
}

.result-art::after {
  content: "";
  position: absolute;
  inset: 1rem;
  z-index: -1;
  border: 1px dashed var(--ink);
}

.result-art figure {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
}

.result-art img {
  display: block;
  max-width: 100%;
  max-height: min(68vh, 44rem);
  object-fit: contain;
}

.result-art--single figure {
  width: min(84%, 38rem);
}

.result-art--dual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}

.result-art--dual figure:first-child {
  transform: translateX(7%) rotate(-4deg);
}

.result-art--dual figure:last-child {
  transform: translateX(-7%) rotate(4deg);
}

.result-art--procession {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding-inline: 0;
}

.result-art--procession figure:nth-child(even) {
  transform: translateY(8%);
}

.result-art--elements {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding-inline: 0;
}

.result-art--elements figure:nth-child(2),
.result-art--elements figure:nth-child(4) {
  transform: translateY(10%);
}

.result-art--procession img,
.result-art--elements img {
  width: 100%;
  max-height: 38rem;
}

.result-story {
  align-self: center;
  padding-block: 2rem;
}

.story-label {
  width: fit-content;
  margin-bottom: 1.5rem;
  padding-bottom: 0.4rem;
  border-bottom: var(--rule);
}

.result-story [data-result-copy] {
  display: grid;
  gap: 1.25rem;
}

.result-story [data-result-copy] p {
  margin: 0;
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  line-height: 1.7;
}

.result-story [data-result-copy] p:first-child::first-letter {
  float: left;
  margin: 0.05em 0.14em 0 0;
  padding: 0.03em 0.08em 0;
  background: var(--accent);
  font-family: var(--display);
  font-size: 4.5em;
  line-height: 0.75;
}

.result-actions,
.completion-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.2rem;
}

.primary-button {
  min-height: 3.4rem;
  padding: 0.95rem 1.4rem;
  border: var(--rule);
  background: var(--accent);
  color: var(--ink);
  font: 800 0.72rem/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover {
  box-shadow: 0.35rem 0.35rem 0 var(--ink);
  transform: translate(-0.2rem, -0.2rem);
}

.text-button {
  min-height: 3rem;
  padding-inline: 0.5rem;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem var(--page-pad);
  background: var(--paper);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

.completion {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(17, 17, 17, 0.88);
}

.completion-card {
  position: relative;
  width: min(100%, 48rem);
  max-height: calc(100svh - 2rem);
  overflow-y: auto;
  padding: clamp(2rem, 6vw, 5rem);
  border: 3px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 0.8rem 0.8rem 0 var(--accent);
  animation: completion-enter 320ms steps(5, end) both;
}

.completion-card > p:not(.eyebrow) {
  max-width: 38rem;
  font-size: 1.08rem;
  line-height: 1.65;
}

.completion h2 {
  margin-block: 1rem 1.5rem;
  font-size: clamp(3.6rem, 8vw, 6.7rem);
}

.completion-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 2.8rem;
  aspect-ratio: 1;
  border: var(--rule);
  background: var(--paper-light);
  font-size: 1.5rem;
  cursor: pointer;
}

.completion-close:hover {
  background: var(--accent);
}

.path-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}

.path-sequence span {
  display: grid;
  place-items: center;
  width: 3.2rem;
  aspect-ratio: 1;
  border: var(--rule);
  background: var(--accent);
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.4rem;
}

.legacy-redirect {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100svh;
  padding: var(--page-pad);
  text-align: center;
}

.legacy-redirect h1 {
  margin-block: 1rem;
}

.legacy-redirect > p:not(.eyebrow) {
  max-width: 34rem;
  line-height: 1.6;
}

.legacy-redirect .primary-button {
  display: inline-grid;
  place-items: center;
  margin-top: 1rem;
  text-decoration: none;
}

/* Editorial typography system */
.wordmark small,
.utility-button,
.text-button,
.eyebrow,
.ritual-label,
.story-label,
.key-hint,
.dice-cta small,
.roll-status,
.progress-heading > p:last-child,
.journey-progress button small,
.result-keywords,
.primary-button,
footer {
  font-family: var(--ui);
}

.opening-intro,
.result-story [data-result-copy] p,
.completion-card > p:not(.eyebrow),
.legacy-redirect > p:not(.eyebrow) {
  font-family: var(--sans);
}

@keyframes dice-roll {
  0% { transform: rotate(-5deg) translate(0, 0); }
  33% { transform: rotate(13deg) translate(-0.35rem, -0.75rem); }
  66% { transform: rotate(-16deg) translate(0.35rem, 0.15rem); }
  100% { transform: rotate(-5deg) translate(0, 0); }
}

@keyframes result-enter {
  from { opacity: 0; transform: translateY(1.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes completion-enter {
  from { opacity: 0; transform: translate(0.8rem, 0.8rem); }
  to { opacity: 1; transform: translate(0, 0); }
}

@media (max-width: 900px) {
  .opening,
  .result-composition {
    grid-template-columns: 1fr;
  }

  .opening {
    min-height: auto;
  }

  .ritual-panel {
    min-height: min(34rem, 90vw);
  }

  .result-heading {
    grid-template-columns: minmax(8rem, 0.45fr) minmax(0, 1fr);
  }

  .result-art {
    min-height: min(42rem, 85vw);
  }
}

@media (max-width: 650px) {
  .site-header {
    align-items: flex-start;
  }

  .wordmark small,
  .utility-button [data-sound-label] {
    display: none;
  }

  .utility-button {
    padding-inline: 0.7rem;
  }

  .opening {
    padding-top: 3rem;
  }

  .opening-copy::before {
    display: none;
  }

  h1 {
    font-size: clamp(2rem, 11.6vw, 4.7rem);
  }

  h1 span:last-child {
    width: 100%;
  }

  .key-hint {
    display: none;
  }

  .ritual-panel {
    min-height: 29rem;
  }

  .journey-progress {
    overflow: hidden;
  }

  .journey-progress ol {
    grid-template-columns: repeat(6, minmax(3.3rem, 1fr));
    overflow-x: auto;
    padding: 0.3rem 0.3rem 0.8rem;
    scrollbar-width: thin;
  }

  .journey-progress button small {
    display: none;
  }

  .result-heading {
    grid-template-columns: 7rem minmax(0, 1fr);
    align-items: center;
  }

  .result-number {
    min-height: 8rem;
    font-size: 8.5rem;
  }

  .result-heading h2 {
    font-size: clamp(2.6rem, 13vw, 4.5rem);
  }

  .result-keywords {
    line-height: 1.6;
  }

  .result-art {
    min-height: 24rem;
  }

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

  .result-art--elements {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-art--elements figure:last-child {
    grid-column: 2;
  }

  footer {
    display: grid;
  }
}

@media (max-width: 400px) {
  .header-actions {
    gap: 0.25rem;
  }

  .utility-button {
    font-size: 0.57rem;
    letter-spacing: 0.08em;
  }

  .opening {
    padding-inline: 0.8rem;
  }

  .ritual-panel {
    min-height: 26rem;
  }
}

@media (max-width: 360px) {
  .journey-progress {
    overflow: visible;
  }

  .journey-progress ol {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem 0.35rem;
    overflow-x: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 480px) {
  .result-heading h2 { font-size: clamp(1.25rem, 6vw, 1.75rem); line-height: 1.05; }
}
