:root {
  color-scheme: dark;
  --ink: #080507;
  --bone: #f0e6d2;
  --muted: #b8a9aa;
  --blood: #a52b34;
  --ember: #e98545;
  --line: rgba(229, 205, 185, 0.16);
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--ink); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 17%, rgba(119, 29, 42, 0.24), transparent 32%),
    radial-gradient(circle at 12% 90%, rgba(103, 40, 28, 0.16), transparent 38%),
    linear-gradient(168deg, #050304 0%, #0d080b 56%, #12090b 100%);
  color: var(--bone);
  font-family: Georgia, "Times New Roman", serif;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.atmosphere {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background-image:
    repeating-linear-gradient(94deg, transparent 0 7px, rgba(255,255,255,.025) 8px, transparent 9px),
    repeating-linear-gradient(3deg, transparent 0 11px, rgba(255,255,255,.018) 12px, transparent 13px);
  mix-blend-mode: screen;
}

.fog {
  position: absolute;
  width: 170vw;
  height: 28vh;
  left: -35vw;
  border-radius: 50%;
  filter: blur(34px);
  opacity: 0.12;
  background: linear-gradient(90deg, transparent, #d8c9c5, transparent 72%);
  animation: drift 15s ease-in-out infinite alternate;
}

.fog-one { bottom: 12%; }
.fog-two { bottom: 38%; opacity: .07; animation-duration: 22s; animation-direction: alternate-reverse; }

.ember {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 9px var(--ember);
  animation: rise 7s linear infinite;
}

.ember-one { left: 18%; bottom: -4%; animation-delay: -1s; }
.ember-two { left: 72%; bottom: -7%; animation-delay: -4s; }
.ember-three { left: 47%; bottom: -10%; animation-delay: -6s; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 20px var(--safe-bottom);
}

.intro-card {
  width: 100%;
  text-align: center;
  animation: reveal .9s cubic-bezier(.2,.8,.2,1) both;
}

.eyebrow,
.chapter-label,
.microcopy {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.eyebrow {
  margin: 0 0 20px;
  color: #9f8c8e;
  font-size: .69rem;
  font-weight: 750;
  letter-spacing: .25em;
  text-transform: uppercase;
}

.eclipse {
  position: relative;
  display: grid;
  place-items: center;
  width: 118px;
  height: 118px;
  margin: 0 auto 24px;
  border: 1px solid rgba(236, 126, 75, .35);
  border-radius: 50%;
  background:
    radial-gradient(circle at 47% 45%, #13090c 0 43%, transparent 45%),
    radial-gradient(circle, #d65b3a 0 53%, #7f1e2c 56%, transparent 59%);
  box-shadow: 0 0 52px rgba(177, 42, 46, .27), inset 0 0 26px rgba(0,0,0,.75);
  animation: breathe 4.8s ease-in-out infinite;
}

.eclipse::before,
.eclipse::after {
  content: "";
  position: absolute;
  inset: -11px;
  border: 1px solid rgba(206, 177, 150, .14);
  border-radius: 50%;
  border-left-color: transparent;
  animation: turn 20s linear infinite;
}

.eclipse::after { inset: -19px; animation-direction: reverse; animation-duration: 27s; }

.eclipse-mark {
  position: relative;
  color: rgba(242, 222, 201, .82);
  font-size: .72rem;
  letter-spacing: .22em;
  text-indent: .22em;
}

.chapter-label {
  margin: 0 0 11px;
  color: var(--ember);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 11.5vw, 4.75rem);
  font-weight: 400;
  line-height: .84;
  letter-spacing: -.045em;
  text-transform: uppercase;
  text-shadow: 0 8px 34px #000;
}

h1 span {
  color: #c23a40;
  font-style: italic;
  letter-spacing: .015em;
}

.intro-copy {
  max-width: 32ch;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 4.5vw, 1.12rem);
  line-height: 1.62;
}

.seal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 23px;
  margin: 27px 0;
}

.seal {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #6f6163;
  font-size: .66rem;
}

.seal:not(:last-child)::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 1px;
  margin-left: 57px;
  background: var(--line);
}

.seal.is-active {
  border-color: rgba(214, 91, 58, .72);
  color: #ffb17e;
  box-shadow: 0 0 18px rgba(192, 50, 54, .2);
}

.primary-button {
  position: relative;
  width: 100%;
  min-height: 70px;
  padding: 14px 22px;
  border: 1px solid #c94a45;
  border-radius: 4px;
  background: linear-gradient(180deg, #a52b34, #701923);
  color: #fff4e5;
  box-shadow: 0 12px 35px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.16);
  cursor: pointer;
  touch-action: manipulation;
}

.primary-button::before,
.primary-button::after {
  content: "✦";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 220, 184, .6);
  font-size: .68rem;
}

.primary-button::before { left: 17px; }
.primary-button::after { right: 17px; }

.primary-button span,
.primary-button small { display: block; }
.primary-button span { font-size: 1.03rem; font-weight: 700; letter-spacing: .06em; }
.primary-button small { margin-top: 4px; color: #e6bbb0; font: .72rem/1.2 ui-sans-serif, system-ui, sans-serif; }

.primary-button:focus-visible { outline: 3px solid #f0c18f; outline-offset: 4px; }
.primary-button:active { transform: translateY(1px); }

.microcopy {
  margin: 14px 0 0;
  color: #76696b;
  font-size: .68rem;
  line-height: 1.45;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes breathe {
  0%, 100% { transform: scale(.985); filter: brightness(.87); }
  50% { transform: scale(1.025); filter: brightness(1.08); }
}

@keyframes turn { to { transform: rotate(360deg); } }

@keyframes drift {
  from { transform: translate3d(-9%, 0, 0) scaleY(.8); }
  to { transform: translate3d(9%, -12px, 0) scaleY(1.15); }
}

@keyframes rise {
  0% { transform: translateY(0) scale(.7); opacity: 0; }
  14% { opacity: .7; }
  100% { transform: translateY(-78vh) translateX(24px) scale(0); opacity: 0; }
}

@media (min-width: 480px) {
  .app-shell { padding-inline: 34px; }
}

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

/* Spiloplevelsen */
body {
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding-top: max(16px, env(safe-area-inset-top));
}

.intro-card { margin: auto 0; }
.intro-host-seal {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 3px;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: rgba(156, 75, 76, .34);
  font: 700 .58rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.eclipse-small { width: 98px; height: 98px; }
.resume-title { font-size: clamp(2.6rem, 13vw, 4.25rem); }

.test-banner,
.storage-warning {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(230, 173, 84, .3);
  border-radius: 4px;
  background: rgba(71, 44, 13, .64);
  color: #f4d197;
  text-align: center;
  font: 700 .69rem/1.35 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .04em;
}

.storage-warning {
  border-color: rgba(218, 75, 78, .38);
  background: rgba(78, 20, 26, .72);
  color: #f6b4ae;
}

.game-hud {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  width: 100%;
  min-height: 60px;
  margin-bottom: 7px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8,5,7,.98) 65%, rgba(8,5,7,.78));
  backdrop-filter: blur(10px);
}

.wax-button,
.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(218, 87, 72, .34);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #9f3439, #55131c 68%, #2a0d11);
  color: #edb493;
  box-shadow: inset 0 0 0 3px rgba(29, 6, 10, .25), 0 3px 16px rgba(0,0,0,.25);
  cursor: pointer;
}

.wax-button span { font: 800 .54rem/1 ui-sans-serif, system-ui, sans-serif; }

.icon-button {
  justify-self: end;
  border-color: var(--line);
  background: rgba(24, 14, 18, .86);
  color: #d7c7b8;
  font: 700 1.1rem/1 ui-sans-serif, system-ui, sans-serif;
}

.wax-button:focus-visible,
.icon-button:focus-visible,
.text-button:focus-visible,
.secondary-button:focus-visible,
.hint-button:focus-visible,
.choice-card:focus-visible,
.order-slot:focus-visible,
.relic-palette button:focus-visible,
.altar-slot:focus-visible,
.segmented-control button:focus-visible,
.speed-control button:focus-visible,
.radio-play:focus-visible,
.demo-scan-row button:focus-visible {
  outline: 3px solid #f0c18f;
  outline-offset: 3px;
}

.hud-center { text-align: center; }
.hud-center p {
  margin: 0 0 2px;
  overflow: hidden;
  color: #89797a;
  font: 650 .64rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.hud-center strong {
  display: block;
  color: #f0e4d2;
  font: 650 1.17rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.progress-seals {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 22px;
}

.progress-seal {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #4e4143;
  font: .69rem/1 ui-sans-serif, system-ui, sans-serif;
}

.progress-seal.is-lit {
  border-color: rgba(225, 101, 66, .64);
  color: #ffb37d;
  background: rgba(141, 37, 43, .18);
  box-shadow: 0 0 14px rgba(201, 67, 53, .22);
}

.game-page {
  width: 100%;
  padding-bottom: calc(var(--safe-bottom) + 28px);
}

.page-enter { animation: page-enter .55s cubic-bezier(.2,.8,.2,1) both; }

.page-heading { margin-bottom: 23px; text-align: center; }
.page-heading .chapter-label { margin-bottom: 9px; }
.page-heading h2,
.success-page h2,
.finale-page h2,
.timeout-page h2,
.modal-card h2 {
  margin: 0;
  color: var(--bone);
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 400;
  line-height: .98;
  letter-spacing: -.035em;
}

.page-heading > p:last-child,
.success-page > p,
.finale-copy,
.modal-card > p {
  max-width: 37ch;
  margin: 15px auto 0;
  color: var(--muted);
  font: 1rem/1.57 ui-sans-serif, system-ui, sans-serif;
}

.story-note,
.ritual-text,
.whisper-text,
.final-quote {
  position: relative;
  margin: 0 0 22px;
  padding: 19px 19px 17px;
  border: 1px solid var(--line);
  border-left: 2px solid #8c3038;
  background: linear-gradient(110deg, rgba(38,20,26,.76), rgba(18,11,15,.45));
  color: #d9cab9;
  font-size: 1.02rem;
  font-style: italic;
  line-height: 1.58;
}

.story-note p { margin: 0; }
.story-note cite {
  display: block;
  margin-top: 12px;
  color: #8c7d7b;
  font: .69rem/1.35 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .06em;
}

.scan-counter {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 0 0 14px;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.scan-counter strong { color: #f0d4b6; font-size: 1.45rem; }
.scan-counter span { color: #8d7e7f; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }

.witness-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.witness-card {
  position: relative;
  min-height: 157px;
  padding: 13px 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(18, 11, 15, .7);
  text-align: center;
}

.witness-card::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(232, 214, 191, .06);
  pointer-events: none;
}

.witness-card.is-found { border-color: rgba(177, 67, 60, .38); animation: card-wake .65s ease both; }
.witness-card.is-hidden { display: grid; place-items: center; color: #4f4446; }
.witness-mark { display: block; color: #a94646; font-size: 1.2rem; }
.witness-card p { margin: 6px 0; color: #cdbeb1; font-size: .8rem; text-transform: uppercase; }
.witness-card strong { display: block; color: #f2d5b7; font-size: 2rem; font-weight: 400; }
.witness-card small { display: block; margin-top: 6px; color: #857578; font-size: .64rem; line-height: 1.35; }

.ink-reveal {
  margin: 17px 0;
  padding: 15px;
  border-top: 1px solid rgba(193, 65, 59, .34);
  border-bottom: 1px solid rgba(193, 65, 59, .34);
  color: #e5b087;
  text-align: center;
  font-size: .84rem;
  line-height: 1.5;
  letter-spacing: .075em;
  text-transform: uppercase;
  animation: ink-in .75s ease both;
}

.qr-instruction {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 17px 0;
  padding: 15px;
  border: 1px dashed rgba(221, 194, 170, .2);
  border-radius: 4px;
  background: rgba(10, 7, 9, .42);
}

.qr-instruction > span { color: #c0524b; font-size: 1.35rem; }
.qr-instruction p { margin: 0; color: #9f9090; font: .86rem/1.5 ui-sans-serif, system-ui, sans-serif; }

.demo-panel,
.host-chapters {
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(14, 9, 12, .62);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.demo-panel summary,
.host-chapters summary {
  min-height: 48px;
  padding: 14px;
  color: #a89999;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
}

.demo-panel > p { margin: 0; padding: 0 14px; color: #7f7173; font-size: .75rem; line-height: 1.45; }
.demo-scan-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 12px 14px 14px; }
.demo-scan-row button,
.host-chapters button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #1b1116;
  color: #cfbfb1;
  font: 700 .72rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.demo-scan-row button:disabled { color: #746567; opacity: .6; }

.hint-section {
  margin-top: 28px;
  padding: 17px;
  border: 1px solid rgba(103, 83, 111, .22);
  border-radius: 5px;
  background: linear-gradient(145deg, rgba(25,17,27,.68), rgba(12,8,11,.64));
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.hint-heading { display: flex; align-items: center; justify-content: space-between; }
.hint-heading div { display: flex; align-items: center; gap: 9px; color: #b39ba9; }
.hint-heading span { color: #8d5d80; font-size: 1.1rem; }
.hint-heading strong { font-size: .79rem; letter-spacing: .08em; text-transform: uppercase; }
.hint-heading > small { color: #655968; font-size: .7rem; }
.hint-empty { margin: 12px 0; color: #786a73; font-size: .77rem; line-height: 1.5; }
.hint-list { margin: 12px 0 14px; padding: 0; list-style: none; }
.hint-list li { padding: 12px 0; border-top: 1px solid rgba(213, 192, 207, .08); }
.hint-list small { color: #7d6074; font-size: .65rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.hint-list p { margin: 5px 0 0; color: #bbaeb5; font-size: .82rem; line-height: 1.5; }
.hint-button {
  width: 100%;
  min-height: 48px;
  padding: 11px;
  border: 1px solid rgba(132, 91, 122, .36);
  border-radius: 3px;
  background: rgba(39, 23, 37, .74);
  color: #c8aebe;
  font: 700 .76rem/1.25 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.order-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.order-slot {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 78px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px dashed rgba(226, 205, 185, .22);
  border-radius: 4px;
  background: rgba(12, 8, 10, .45);
  color: #706264;
  text-align: center;
}

button.order-slot { cursor: pointer; }
.order-slot small { position: absolute; top: 6px; left: 8px; color: #5f5052; font: .6rem/1 ui-sans-serif, system-ui, sans-serif; }
.order-slot span { overflow: hidden; font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.order-slot strong { margin-top: 5px; color: #e5c3a1; font-size: 1.3rem; font-weight: 400; }
.order-slot.is-filled { border-style: solid; border-color: rgba(180, 66, 60, .44); background: rgba(83, 24, 30, .18); color: #d6c6b8; }

.choice-stack { display: grid; gap: 9px; }
.choice-card {
  display: grid;
  grid-template-columns: 36px 1fr 30px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 67px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(24, 15, 19, .72);
  color: #d6c7ba;
  text-align: left;
  cursor: pointer;
}

.choice-card:disabled { opacity: .33; cursor: default; }
.choice-mark { color: #ad4447; font-size: 1.2rem; text-align: center; }
.choice-card strong { display: block; font-size: .85rem; }
.choice-card small { display: block; margin-top: 3px; color: #817275; font-size: .67rem; line-height: 1.35; }
.choice-card b { color: #e8c5a3; font-size: 1.35rem; font-weight: 400; text-align: right; }

.feedback {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: 4px;
  font: .81rem/1.45 ui-sans-serif, system-ui, sans-serif;
}

.feedback-error { border-color: rgba(208, 63, 66, .42); background: rgba(92, 21, 28, .28); color: #e9aaa7; }
.feedback-success { border-color: rgba(99, 158, 109, .36); background: rgba(26, 68, 38, .28); color: #b9d5b8; }

.button-row { display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); gap: 9px; margin-top: 14px; }
.primary-button.compact { min-height: 54px; padding-block: 11px; }
.primary-button.compact small { display: none; }

.text-button,
.secondary-button,
.danger-button {
  min-height: 48px;
  padding: 10px 13px;
  border-radius: 3px;
  cursor: pointer;
  font: 700 .76rem/1.25 ui-sans-serif, system-ui, sans-serif;
}

.text-button { border: 0; background: transparent; color: #98898a; }
.secondary-button { border: 1px solid var(--line); background: #1d1317; color: #d3c3b5; }
.danger-button { border: 1px solid #b84045; background: #791f28; color: #fff0e5; }
.danger-text { color: #b65a5d; }
.intro-card > .text-button { display: block; margin: 10px auto 0; }

.success-page,
.finale-page,
.timeout-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100svh - 130px);
  text-align: center;
}

.success-sigil {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin-bottom: 22px;
  border: 1px solid rgba(227, 108, 66, .58);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(143, 38, 42, .33), transparent 68%);
  color: #e78755;
  font-size: 2.2rem;
  box-shadow: 0 0 55px rgba(177, 51, 44, .22);
  animation: success-pulse 2.5s ease-in-out infinite;
}

.code-reveal { display: flex; gap: 9px; margin: 25px 0 8px; }
.code-reveal span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 70px;
  border: 1px solid rgba(230, 179, 129, .34);
  background: rgba(28, 17, 17, .77);
  color: #f0c899;
  font-size: 2.3rem;
  box-shadow: inset 0 0 22px rgba(118, 39, 32, .15);
}

.success-page .ink-reveal { width: 100%; max-width: 320px; }
.success-page .primary-button { margin-top: 7px; }

.radio-device {
  position: relative;
  margin: 4px 0 18px;
  padding: 16px;
  border: 1px solid #4b3534;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.012) 4px),
    linear-gradient(145deg, #251a19, #130e10 65%, #1a1114);
  box-shadow: 0 18px 35px rgba(0,0,0,.3), inset 0 0 0 4px rgba(0,0,0,.18);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.radio-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; color: #695958; font-size: .63rem; font-weight: 750; letter-spacing: .12em; }
.radio-light { width: 8px; height: 8px; border-radius: 50%; background: #301617; box-shadow: inset 0 0 2px #000; }
.radio-light.is-on { background: #e25547; box-shadow: 0 0 10px #e25547; }
.frequency-label { display: block; margin-bottom: 6px; color: #948380; font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.frequency-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #4a3b30;
  border-radius: 3px;
  background: #0e120c;
  box-shadow: inset 0 0 22px rgba(99, 118, 66, .1);
}

.frequency-readout input {
  width: 4.1ch;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #bdc890;
  font: 400 2.35rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .09em;
  text-align: center;
}

.frequency-readout span { color: #68704f; font-size: .72rem; }
.control-group { margin: 16px 0 0; padding: 0; border: 0; }
.control-group legend { margin-bottom: 7px; color: #897a78; font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.segmented-control,
.speed-control { display: grid; gap: 6px; }
.segmented-control { grid-template-columns: 1fr 1fr; }
.speed-control { grid-template-columns: repeat(4, 1fr); }
.segmented-control button,
.speed-control button {
  min-height: 44px;
  border: 1px solid #443332;
  border-radius: 3px;
  background: #171012;
  color: #8b7c79;
  cursor: pointer;
  font: 700 .73rem/1 ui-sans-serif, system-ui, sans-serif;
}

.segmented-control button.is-selected,
.speed-control button.is-selected { border-color: #a04943; background: #542126; color: #edc3a5; box-shadow: inset 0 0 14px rgba(211, 70, 58, .12); }

.radio-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  margin-top: 16px;
  border: 1px solid #755044;
  border-radius: 3px;
  background: linear-gradient(#392421, #241719);
  color: #dfc3aa;
  cursor: pointer;
  font: 750 .77rem/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.radio-play span { color: #c7584e; }
.radio-play:disabled { opacity: .65; }
.waveform { display: flex; align-items: center; justify-content: center; gap: 3px; height: 34px; margin-top: 9px; overflow: hidden; }
.waveform i { width: 2px; height: calc(var(--bar) * 1px); background: #62433f; transform-origin: center; }
.waveform.is-playing i { animation: waveform .38s ease-in-out infinite alternate; animation-delay: calc(var(--bar) * -20ms); }
.radio-status { margin: 0; color: #75686a; text-align: center; font: .78rem/1.4 ui-sans-serif, system-ui, sans-serif; }

.whisper-text { margin-top: 17px; border-left-color: #7f6e8f; color: #d4c5d4; text-align: center; }
.answer-form { margin-top: 17px; font-family: ui-sans-serif, system-ui, sans-serif; }
.answer-form label { display: block; margin-bottom: 8px; color: #c2b3a8; font-size: .85rem; font-weight: 700; }
.answer-row { display: grid; grid-template-columns: 1fr auto; }
.answer-row input,
.host-pin-form input {
  min-width: 0;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #5d4544;
  border-right: 0;
  border-radius: 3px 0 0 3px;
  outline: 0;
  background: #110c0e;
  color: #f0e4d2;
  font: 1rem/1 ui-sans-serif, system-ui, sans-serif;
}

.answer-row input:focus,
.host-pin-form input:focus { border-color: #c76758; box-shadow: inset 0 0 0 1px #c76758; }
.answer-row button {
  min-width: 76px;
  min-height: 50px;
  border: 1px solid #a6373d;
  border-radius: 0 3px 3px 0;
  background: #7f222b;
  color: #fff0e2;
  cursor: pointer;
  font: 750 .78rem/1 ui-sans-serif, system-ui, sans-serif;
}

.ritual-text { padding-block: 13px; }
.ritual-text p { margin: 7px 0; color: #cbbdaf; font-size: .88rem; }
.relic-palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 15px 0; }
.relic-palette button {
  min-height: 64px;
  padding: 7px 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(25, 16, 20, .72);
  color: #a79993;
  cursor: pointer;
}

.relic-palette button span { display: block; color: #c56956; font-size: 1.1rem; }
.relic-palette button small { display: block; margin-top: 5px; overflow: hidden; font: 650 .64rem/1 ui-sans-serif, system-ui, sans-serif; text-overflow: ellipsis; }
.relic-palette button.is-selected { border-color: #d36a55; background: rgba(114, 42, 42, .35); color: #f0d2b5; transform: translateY(-2px); }
.relic-palette button:disabled { opacity: .3; }

.altar-grid {
  display: grid;
  grid-template-columns: 1fr 82px 1fr;
  grid-template-rows: 87px 82px 87px;
  gap: 7px;
  align-items: stretch;
  margin: 17px 0 12px;
}

.altar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 64px;
  padding: 6px;
  border: 1px dashed rgba(224, 197, 175, .25);
  border-radius: 6px;
  background: rgba(17, 11, 14, .72);
  color: #76696a;
  cursor: pointer;
}

.altar-slot small { color: #77686a; font: 650 .58rem/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.altar-slot span { margin: 5px 0 3px; color: #8e4545; font-size: 1.1rem; }
.altar-slot strong { max-width: 100%; overflow: hidden; font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.altar-slot.is-filled { border-style: solid; border-color: rgba(196, 76, 64, .5); background: radial-gradient(circle, rgba(99, 32, 37, .35), rgba(19, 12, 15, .82)); color: #ddc7b5; }
.altar-north { grid-column: 2; grid-row: 1; }
.altar-west { grid-column: 1; grid-row: 2; }
.altar-east { grid-column: 3; grid-row: 2; }
.altar-south { grid-column: 2; grid-row: 3; }
.ash-bowl {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  place-items: center;
  align-content: center;
  border: 1px solid #5b4e4a;
  border-radius: 50%;
  background: radial-gradient(circle, #4b4540 0 24%, #241a1b 28% 54%, #100b0d 58%);
  color: #aaa095;
  box-shadow: 0 0 28px rgba(126, 53, 48, .15);
}

.ash-bowl span { font-size: 1.25rem; }
.ash-bowl small { font: .58rem/1 ui-sans-serif, system-ui, sans-serif; }
.selection-status { min-height: 35px; margin: 0 0 10px; color: #817477; text-align: center; font: .72rem/1.45 ui-sans-serif, system-ui, sans-serif; }

.finale-rings {
  position: relative;
  display: grid;
  place-items: center;
  width: 145px;
  height: 145px;
  margin-bottom: 24px;
  border: 1px solid rgba(223, 115, 69, .55);
  border-radius: 50%;
  box-shadow: 0 0 70px rgba(186, 59, 48, .23);
  animation: breathe 4.8s ease-in-out infinite;
}

.finale-rings::before,
.finale-rings::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(225, 192, 160, .22);
  border-radius: 50%;
  border-top-color: transparent;
  animation: turn 15s linear infinite;
}

.finale-rings::after { inset: 28px; animation-direction: reverse; animation-duration: 10s; }
.finale-rings > span { color: #eda56c; font-size: 2.1rem; text-shadow: 0 0 18px #b8443b; }
.finale-page .eyebrow,
.timeout-page .eyebrow { margin-bottom: 13px; }
.finale-copy { max-width: 34ch; }
.final-quote { width: 100%; margin: 21px 0; color: #dccab8; text-align: center; }
.final-warning { margin: 0 0 20px; color: #b75351; font-size: .82rem; font-style: italic; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; width: 100%; margin-bottom: 18px; }
.result-grid > div,
.host-stats > div { padding: 13px; border: 1px solid var(--line); border-radius: 4px; background: rgba(20,13,16,.65); }
.result-grid small,
.host-stats small { display: block; color: #77696b; font: .62rem/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.result-grid strong,
.host-stats strong { display: block; margin-top: 7px; color: #e4c5a5; font: 1.15rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.final-host-link { min-height: 44px; margin-top: 12px; border: 0; background: transparent; color: #5a494b; cursor: pointer; font: .68rem/1.4 ui-sans-serif, system-ui, sans-serif; }
.cracked-clock { margin-bottom: 27px; color: #a2373d; font: 400 3rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; text-shadow: 2px 2px 0 #381217, -1px 0 #d37b6c; transform: rotate(-3deg); }
.timeout-page .secondary-button { width: 100%; margin-top: 10px; }

.toast {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(calc(100% - 36px), 430px);
  padding: 13px 15px;
  border: 1px solid rgba(218, 190, 168, .22);
  border-radius: 4px;
  background: rgba(28, 18, 22, .96);
  color: #e2d3c4;
  box-shadow: 0 14px 40px rgba(0,0,0,.48);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 18px);
  transition: opacity .22s ease, transform .22s ease;
  font: .8rem/1.45 ui-sans-serif, system-ui, sans-serif;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="danger"] { border-color: rgba(208, 68, 72, .48); color: #f1b6b3; }
.toast[data-tone="success"] { border-color: rgba(101, 164, 111, .42); color: #bdd9bc; }

.modal-backdrop {
  position: fixed;
  z-index: 150;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 16px 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(3, 2, 3, .78);
  backdrop-filter: blur(8px);
  animation: fade-in .2s ease both;
}

.modal-card {
  position: relative;
  width: min(100%, 470px);
  max-height: min(88svh, 760px);
  padding: 27px 20px 21px;
  overflow-y: auto;
  border: 1px solid #533238;
  border-radius: 9px 9px 5px 5px;
  outline: 0;
  background:
    radial-gradient(circle at 50% 0, rgba(125, 39, 43, .2), transparent 38%),
    linear-gradient(155deg, #1b1116, #0f0a0d);
  box-shadow: 0 -14px 60px rgba(0,0,0,.5);
  color: var(--bone);
  text-align: center;
  animation: modal-in .35s cubic-bezier(.2,.8,.2,1) both;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: #8f7d7d;
  cursor: pointer;
  font: 300 1.5rem/1 ui-sans-serif, system-ui, sans-serif;
}

.modal-sigil { margin-bottom: 12px; color: #b74d49; font-size: 2rem; }
.modal-card .chapter-label { margin-bottom: 8px; }
.modal-card blockquote { margin: 16px 0; color: #c7b5aa; font-style: italic; line-height: 1.5; }
.modal-digit { margin: 16px 0 4px; color: #f0c89b; font-size: 3.2rem; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 21px; }

.host-pin-form { margin-top: 19px; text-align: left; font-family: ui-sans-serif, system-ui, sans-serif; }
.host-pin-form label { display: block; margin-bottom: 8px; color: #9d8e8e; font-size: .75rem; font-weight: 700; }
.host-pin-form input { width: 100%; border-right: 1px solid #5d4544; border-radius: 3px; text-align: center; letter-spacing: .35em; }
.host-pin-form .primary-button { margin-top: 10px; }
.host-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 18px 0; }
.host-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.host-action-grid button {
  min-height: 50px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #201419;
  color: #cfbfb1;
  cursor: pointer;
  font: 700 .71rem/1.25 ui-sans-serif, system-ui, sans-serif;
}

.host-action-grid button:disabled { opacity: .35; }
.host-chapters { margin-top: 12px; text-align: left; }
.host-chapters > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 12px 12px; }
.host-footer { display: grid; gap: 5px; margin-top: 13px; }

.noscript {
  position: fixed;
  z-index: 300;
  inset: 20px;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #120b0e;
  color: #f0e4d2;
  text-align: center;
  font: 1rem/1.5 ui-sans-serif, system-ui, sans-serif;
}

.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;
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ink-in { from { opacity: 0; filter: blur(4px); letter-spacing: .14em; } to { opacity: 1; filter: blur(0); letter-spacing: .075em; } }
@keyframes card-wake { from { opacity: .2; transform: rotateY(70deg); } to { opacity: 1; transform: rotateY(0); } }
@keyframes success-pulse { 0%,100% { transform: scale(.98); filter: brightness(.85); } 50% { transform: scale(1.03); filter: brightness(1.12); } }
@keyframes waveform { from { transform: scaleY(.45); } to { transform: scaleY(1.55); } }

@media (max-width: 359px) {
  .app-shell { padding-inline: 14px; }
  .witness-grid { gap: 5px; }
  .witness-card { min-height: 151px; padding-inline: 5px; }
  .relic-palette { gap: 4px; }
  .speed-control { gap: 3px; }
  .host-action-grid { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-shell { width: min(100%, 720px); }
  .intro-card { padding-block: 12px; }
  .eclipse { width: 76px; height: 76px; margin-bottom: 14px; }
  .intro-copy { margin-top: 15px; }
  .seal-row { margin: 17px 0; }
  .success-page, .finale-page, .timeout-page { min-height: auto; }
}
