:root {
  --bone: #e9e1cf;
  --bone-muted: rgba(233, 225, 207, 0.66);
  --bone-faint: rgba(233, 225, 207, 0.36);
  --ember: #c78b52;
  --ember-bright: #e0ab72;
  --moss: #22271f;
  --night: #0d0f0c;
  --glass: rgba(16, 18, 14, 0.78);
  --hairline: rgba(233, 225, 207, 0.18);
  --display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@font-face {
  font-family: "Noto Runic";
  src: url("Noto_Sans_Runic/NotoSansRunic-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--bone);
}

html {
  color-scheme: dark;
}

body {
  min-height: 100svh;
  overflow: hidden;
  overflow-x: clip;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: 3px;
  background: var(--bone);
  color: var(--night);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

#experience,
#scene-container,
.atmosphere {
  position: fixed;
  inset: 0;
}

#experience {
  min-height: 100svh;
  isolation: isolate;
  overflow: hidden;
}

#scene-container {
  z-index: -3;
  background:
    radial-gradient(circle at 50% 40%, rgba(57, 62, 48, 0.36), transparent 44%),
    var(--night);
}

#scene-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.atmosphere {
  z-index: -2;
  pointer-events: none;
}

.atmosphere-vignette {
  background:
    radial-gradient(ellipse at 50% 44%, transparent 34%, rgba(6, 7, 5, 0.35) 68%, rgba(5, 6, 4, 0.84) 100%),
    linear-gradient(180deg, rgba(5, 6, 4, 0.5), transparent 25%, transparent 74%, rgba(5, 6, 4, 0.7));
}

.atmosphere-grain {
  z-index: 9;
  opacity: 0.065;
  mix-blend-mode: soft-light;
  background-repeat: repeat;
  background-size: 128px 128px;
}

.site-header {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) clamp(20px, 4vw, 64px) 0;
  pointer-events: none;
}

.brand,
.sound-button {
  pointer-events: auto;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand-mark {
  margin-right: 11px;
  color: var(--ember-bright);
  font-family: "Noto Runic", sans-serif;
  font-size: 22px;
  line-height: 1;
}

.brand-name {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.32em;
}

.brand-domain {
  margin-left: 2px;
  color: var(--bone-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.sound-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--bone-muted);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: color 180ms ease;
}

.sound-button:hover {
  color: var(--bone);
}

.sound-icon {
  position: relative;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  color: var(--ember-bright);
  font-size: 14px;
}

.sound-button[aria-pressed="true"] .sound-icon::after {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(224, 171, 114, 0.28);
  border-radius: inherit;
  content: "";
}

.ritual-panel {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: clamp(24px, 8vw, 130px);
  width: min(510px, calc(100vw - 48px));
  transform: translateY(-49%);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--ember-bright);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.ritual-panel h1 {
  max-width: 530px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(44px, 5.5vw, 82px);
  font-weight: 400;
  letter-spacing: -0.045em;
  line-height: 0.94;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.38);
}

.ritual-panel h1 em {
  color: var(--bone-muted);
  font-weight: 400;
}

.intro-copy {
  max-width: 440px;
  margin: 26px 0 28px;
  color: var(--bone-muted);
  font-family: var(--display);
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.55;
}

.question-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: min(450px, 100%);
  margin-bottom: 9px;
  color: var(--bone-muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.question-label span {
  color: var(--bone-faint);
  font-weight: 400;
  letter-spacing: 0.12em;
}

.question-field {
  position: relative;
  width: min(450px, 100%);
}

.question-field input {
  width: 100%;
  height: 52px;
  padding: 0 48px 0 15px;
  border: 1px solid var(--hairline);
  border-radius: 2px;
  outline: none;
  background: rgba(10, 12, 9, 0.44);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  color: var(--bone);
  font-family: var(--display);
  font-size: 16px;
  transition: border-color 180ms ease, background 180ms ease;
}

.question-field input::placeholder {
  color: rgba(233, 225, 207, 0.28);
}

.question-field input:focus {
  border-color: rgba(224, 171, 114, 0.56);
  background: rgba(10, 12, 9, 0.68);
}

.question-rune {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: var(--ember);
  font-family: "Noto Runic", sans-serif;
  font-size: 19px;
  pointer-events: none;
}

.cast-button {
  display: inline-flex;
  min-width: 216px;
  height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-top: 16px;
  padding: 0 18px 0 21px;
  border: 1px solid rgba(224, 171, 114, 0.56);
  border-radius: 2px;
  background: rgba(159, 101, 52, 0.16);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
  color: var(--bone);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.cast-button:hover {
  border-color: var(--ember-bright);
  background: rgba(159, 101, 52, 0.3);
  transform: translateY(-2px);
}

.cast-button:active {
  transform: translateY(0);
}

.cast-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.cast-arrow {
  color: var(--ember-bright);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0;
}

.ritual-note {
  margin: 14px 0 0;
  color: var(--bone-faint);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.ritual-note span {
  margin-right: 7px;
  color: var(--ember);
}

.casting-status {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(72px, calc(env(safe-area-inset-bottom) + 50px));
  display: flex;
  visibility: hidden;
  align-items: center;
  gap: 14px;
  transform: translateX(-50%);
  opacity: 0;
  color: var(--bone-muted);
  font-family: var(--display);
  font-size: 14px;
  font-style: italic;
  white-space: nowrap;
}

.status-line {
  width: 38px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ember));
}

.status-line:last-child {
  transform: scaleX(-1);
}

.reading-panel {
  position: fixed;
  z-index: 12;
  right: clamp(22px, 4.5vw, 76px);
  bottom: clamp(54px, 7vh, 96px);
  width: min(760px, calc(100vw - 44px));
  max-height: calc(100svh - 140px);
  padding: clamp(24px, 3vw, 40px);
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.025), transparent 42%),
    var(--glass);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px) saturate(0.8);
  scrollbar-width: thin;
}

.reading-panel[hidden] {
  display: none;
}

.reading-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 21px;
  border-bottom: 1px solid var(--hairline);
}

.reading-heading .eyebrow {
  margin-bottom: 5px;
}

.reading-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(30px, 3vw, 45px);
  font-weight: 400;
  letter-spacing: -0.035em;
}

.asked-question {
  max-width: 330px;
  margin: 0;
  color: var(--bone-muted);
  font-family: var(--display);
  font-size: 14px;
  font-style: italic;
  line-height: 1.45;
  text-align: right;
}

.reading-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

.reading-card {
  min-width: 0;
  padding: 25px 20px 23px;
  border-right: 1px solid var(--hairline);
  cursor: default;
  transition: background 180ms ease;
}

.reading-card:first-child {
  padding-left: 0;
}

.reading-card:last-child {
  padding-right: 0;
  border-right: 0;
}

.reading-card:hover,
.reading-card.is-active {
  background: linear-gradient(180deg, rgba(199, 139, 82, 0.07), transparent);
}

.card-position {
  display: block;
  margin-bottom: 16px;
  color: var(--bone-faint);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.card-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-glyph {
  display: grid;
  flex: 0 0 49px;
  width: 49px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(224, 171, 114, 0.32);
  border-radius: 45% 52% 46% 51%;
  background: rgba(0, 0, 0, 0.2);
  color: var(--ember-bright);
  font-family: "Noto Runic", sans-serif;
  font-size: 29px;
  line-height: 1;
}

.card-glyph.is-reversed {
  transform: rotate(180deg);
}

.card-name {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 400;
}

.card-orientation {
  margin: 3px 0 0;
  color: var(--ember);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.card-meaning-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 17px 0 8px;
}

.card-keyword {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--bone);
  font-family: var(--display);
  font-size: 16px;
  font-style: italic;
}

.card-audio-button {
  position: relative;
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(224, 171, 114, 0.48);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199, 139, 82, 0.12), rgba(8, 10, 7, 0.76));
  box-shadow: inset 0 0 14px rgba(199, 139, 82, 0.08);
  color: var(--ember-bright);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.card-audio-button::before {
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(224, 171, 114, 0.34);
  border-radius: inherit;
  content: "";
  pointer-events: none;
  animation: reading-audio-pulse 2.15s ease-in-out infinite;
}

.card-audio-button:hover,
.card-audio-button:focus-visible {
  border-color: rgba(239, 188, 130, 0.82);
  background: radial-gradient(circle, rgba(199, 139, 82, 0.23), rgba(8, 10, 7, 0.82));
  box-shadow: 0 0 20px rgba(199, 139, 82, 0.18), inset 0 0 14px rgba(199, 139, 82, 0.13);
  transform: translateY(-1px);
}

.card-audio-button:focus-visible {
  outline: 1px solid var(--ember-bright);
  outline-offset: 5px;
}

.card-audio-button.is-playing {
  border-color: var(--ember-bright);
  background: radial-gradient(circle, rgba(199, 139, 82, 0.3), rgba(8, 10, 7, 0.84));
  box-shadow: 0 0 22px rgba(199, 139, 82, 0.2), inset 0 0 16px rgba(199, 139, 82, 0.14);
}

.card-audio-button.is-playing::before {
  opacity: 0.5;
  animation: none;
}

.card-audio-icon {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.card-audio-button.is-playing .card-audio-icon {
  width: 9px;
  height: 12px;
  margin-left: 0;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px, currentColor 6px 9px);
}

.card-meaning {
  margin: 0;
  color: var(--bone-muted);
  font-size: 11px;
  line-height: 1.62;
}

.reading-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

.reading-thread {
  max-width: 535px;
  margin: 0;
  color: var(--bone-muted);
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.5;
}

.again-button {
  flex: 0 0 auto;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid var(--ember);
  background: transparent;
  color: var(--bone);
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.again-button span {
  margin-right: 5px;
  color: var(--ember-bright);
  font-size: 14px;
}

.site-footer {
  position: fixed;
  z-index: 8;
  right: clamp(20px, 4vw, 64px);
  bottom: max(20px, env(safe-area-inset-bottom));
  left: clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(233, 225, 207, 0.26);
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  pointer-events: none;
}

.footer-glyphs {
  font-family: "Noto Runic", sans-serif;
  font-size: 12px;
  letter-spacing: 0.5em;
}

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

#loading-screen {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-content: center;
  background: #0b0d0a;
  color: var(--bone-muted);
  text-align: center;
}

.loading-rune {
  color: var(--ember-bright);
  font-family: "Noto Runic", sans-serif;
  font-size: 38px;
  animation: loading-turn 2.2s ease-in-out infinite;
}

#loading-screen p {
  margin: 18px 0 0;
  font-size: 8px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
}

noscript {
  position: fixed;
  z-index: 500;
  right: 20px;
  bottom: 20px;
  left: 20px;
  padding: 18px;
  border: 1px solid var(--hairline);
  background: var(--night);
  color: var(--bone);
  text-align: center;
}

@keyframes loading-turn {
  0%, 100% { transform: rotateY(0deg); opacity: 0.55; }
  50% { transform: rotateY(180deg); opacity: 1; }
}

@keyframes reading-audio-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.18; }
  50% { transform: scale(1.15); opacity: 0.72; }
}

@media (max-width: 980px) {
  .ritual-panel {
    top: auto;
    bottom: 72px;
    right: clamp(20px, 5vw, 48px);
    left: clamp(20px, 5vw, 48px);
    width: auto;
    max-width: 620px;
    margin-inline: auto;
    transform: none;
    text-align: center;
  }

  .ritual-panel h1,
  .intro-copy,
  .question-label,
  .question-field {
    margin-right: auto;
    margin-left: auto;
  }

  .intro-copy {
    margin-top: 18px;
    margin-bottom: 20px;
  }

  .ritual-note {
    display: none;
  }

  .reading-panel {
    right: 17px;
    bottom: 50px;
    left: 17px;
    width: auto;
    max-width: 760px;
    margin-inline: auto;
    max-height: calc(100svh - 126px);
    transform: none;
  }
}

@media (max-width: 680px) {
  .site-header {
    padding: max(17px, env(safe-area-inset-top)) 18px 0;
  }

  .brand-mark {
    margin-right: 8px;
    font-size: 18px;
  }

  .brand-name {
    font-size: 15px;
  }

  .sound-label,
  .brand-domain {
    display: none;
  }

  .ritual-panel {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
    left: max(18px, env(safe-area-inset-left));
    max-width: none;
    text-align: left;
  }

  .eyebrow {
    margin-bottom: 10px;
  }

  .ritual-panel h1 {
    width: 100%;
    max-width: none;
    font-size: clamp(36px, 10.4vw, 46px);
    line-height: 0.92;
    text-wrap: balance;
  }

  .intro-copy {
    max-width: 420px;
    margin-top: 15px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.42;
  }

  .question-label,
  .question-field {
    width: 100%;
    max-width: none;
    margin-right: 0;
    margin-left: 0;
  }

  .question-field input {
    height: 48px;
    min-width: 0;
    font-size: 15px;
  }

  .cast-button {
    position: relative;
    width: 100%;
    min-width: 0;
    height: 50px;
    gap: 18px;
    justify-content: center;
    margin-top: 12px;
    letter-spacing: 0.17em;
  }

  .cast-arrow {
    position: absolute;
    right: 18px;
  }

  .site-footer {
    display: none;
  }

  .casting-status {
    bottom: max(34px, calc(env(safe-area-inset-bottom) + 22px));
  }

  .reading-panel {
    right: 10px;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-width: none;
    max-height: min(68svh, 660px);
    padding: 22px 20px;
  }

  .reading-heading {
    display: block;
  }

  .asked-question {
    max-width: none;
    margin-top: 10px;
    text-align: left;
  }

  .reading-grid {
    display: block;
  }

  .reading-card,
  .reading-card:first-child,
  .reading-card:last-child {
    display: grid;
    grid-template-columns: 126px 1fr;
    column-gap: 14px;
    padding: 18px 0;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .reading-card:last-child {
    border-bottom: 0;
  }

  .card-position,
  .card-identity {
    grid-column: 1;
  }

  .card-position {
    margin-bottom: 10px;
  }

  .card-identity {
    align-items: flex-start;
  }

  .card-glyph {
    flex-basis: 43px;
    width: 43px;
    height: 51px;
    font-size: 25px;
  }

  .card-name {
    font-size: 19px;
  }

  .card-meaning-heading,
  .card-meaning {
    grid-column: 2;
  }

  .card-meaning-heading {
    margin: 15px 0 6px;
  }

  .reading-footer {
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) and (max-height: 720px) {
  .ritual-panel {
    bottom: max(14px, calc(env(safe-area-inset-bottom) + 10px));
  }

  .ritual-panel h1 {
    font-size: clamp(34px, 9.7vw, 41px);
  }

  .intro-copy {
    margin-top: 11px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.35;
  }

  .question-label {
    margin-bottom: 6px;
  }

  .question-field input {
    height: 44px;
  }

  .cast-button {
    height: 46px;
    margin-top: 10px;
  }
}

@media (max-width: 680px) and (max-height: 590px) {
  .intro-copy {
    display: none;
  }

  .question-label {
    margin-top: 14px;
  }
}

@media (max-width: 430px) {
  .reading-card,
  .reading-card:first-child,
  .reading-card:last-child {
    grid-template-columns: 108px 1fr;
  }

  .reading-thread {
    font-size: 13px;
  }

  .again-button {
    font-size: 8px;
    letter-spacing: 0.13em;
  }

  .reading-thread {
    flex-basis: 100%;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .ritual-panel {
    top: 72px;
    right: auto;
    bottom: 14px;
    left: 7vw;
    width: min(470px, 58vw);
    max-width: none;
    margin: 0;
    overflow-y: auto;
    transform: none;
    text-align: left;
  }

  .ritual-panel h1 {
    font-size: clamp(34px, 7.5vh, 52px);
  }

  .intro-copy {
    display: none;
  }

  .question-label,
  .question-field {
    margin-right: 0;
    margin-left: 0;
  }

  .question-label {
    margin-top: 16px;
  }

  .reading-panel {
    right: 18px;
    bottom: 12px;
    left: auto;
    width: min(720px, 67vw);
    max-height: calc(100svh - 74px);
    margin: 0;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
