@font-face {
  font-family: "Bodoni Moda";
  src: url("bodoni-moda.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Sora";
  src: url("sora-grotesk.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0A0A0A;
  --ember: #FF6F00;
  --gold: #FFD700;
  --cream: #FFF6DE;
  --line: rgba(255, 215, 0, 0.42);
  --panel: rgba(10, 10, 10, 0.82);
  --display: "Bodoni Moda", "Palatino Linotype", Palatino, serif;
  --sans: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  text-decoration: none !important;
  text-decoration-color: transparent !important;
  -webkit-text-decoration-color: transparent !important;
  -webkit-tap-highlight-color: transparent;
}

::spelling-error,
::grammar-error {
  background: transparent;
  color: inherit;
  text-decoration: none !important;
}

::selection {
  background: #FF6F00;
  color: #0A0A0A;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

html,
body {
  background: var(--ink);
  color: var(--cream);
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  overflow: hidden;
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
  background:
    linear-gradient(180deg, rgba(10, 10, 10, 0.28), rgba(10, 10, 10, 0.78)),
    url("canopy-reverie.jpg") center / cover no-repeat;
}

button,
img {
  -webkit-user-drag: none;
  user-select: none;
}

button {
  font-family: inherit;
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  color: var(--cream);
  background: rgba(10, 10, 10, 0.62);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 54px;
  padding: 0 16px;
  cursor: pointer;
  width: 100%;
}

button.solid {
  background: var(--ember);
  color: var(--ink);
  border-color: transparent;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--gold);
}

[hidden] {
  display: none !important;
}

#stage {
  container-type: inline-size;
  width: min(560px, 100%);
  height: 100%;
  max-height: 100svh;
  position: relative;
  overflow: hidden;
  background: var(--ink);
}

.veil {
  display: none;
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  padding:
    max(14px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.veil.live {
  display: flex;
  flex-direction: column;
}

#rite[data-scene="summon"] {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.18), rgba(10, 10, 10, 0.84)),
    url("canopy-reverie.jpg");
}

#rite[data-scene="coins"] {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.28), rgba(10, 10, 10, 0.86)),
    url("aureate-veil.jpg");
}

#rite[data-scene="win"] {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.34), rgba(10, 10, 10, 0.88)),
    url("lantern-procession.jpg");
}

#grove {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.12) 0%, rgba(10, 10, 10, 0.72) 46%, #0A0A0A 100%),
    url("canopy-reverie.jpg");
}

#atelier {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.55), rgba(10, 10, 10, 0.92)),
    url("aureate-veil.jpg");
}

#ledger {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.62), rgba(10, 10, 10, 0.92)),
    url("lantern-procession.jpg");
}

#chamber {
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.7), #0A0A0A 78%),
    url("aureate-veil.jpg");
}

#run.veil {
  padding: 0;
  background: #0A0A0A;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ember);
  font-weight: 600;
}

h1,
h2,
.card h2,
.skin h3 {
  font-family: var(--display);
  font-weight: 700;
  font-variation-settings: "opsz" 72, "wght" 700;
  color: var(--gold);
  line-height: 0.9;
  text-wrap: balance;
}

.rite-page {
  display: none;
  min-height: 0;
}

.rite-page.live {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.rite-page h1 {
  margin-top: 8px;
  font-size: clamp(2.3rem, 13cqw, 4.4rem);
}

.lede,
.card p,
.empty,
.wearing,
.bestline,
.hint p,
.record div span,
.skin p {
  color: rgba(255, 246, 222, 0.84);
  overflow-wrap: anywhere;
}

.lede {
  margin-top: 10px;
  max-width: 34ch;
  font-size: clamp(0.92rem, 3.6cqw, 1.05rem);
}

.seal-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seal {
  width: min(230px, 62cqw);
  aspect-ratio: 1;
  border-radius: 50%;
  position: relative;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 111, 0, 0.38), rgba(10, 10, 10, 0.15) 58%, rgba(10, 10, 10, 0.72));
}

.seal img {
  width: 88%;
  height: 52%;
  object-fit: contain;
  opacity: 0.22;
  filter: grayscale(1) brightness(0.6);
  pointer-events: none;
}

.seal.awake img {
  opacity: 1;
  filter: none;
}

.ring {
  position: absolute;
  inset: 7px;
  width: calc(100% - 14px);
  height: calc(100% - 14px);
  transform: rotate(-90deg);
  pointer-events: none;
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 2.5;
}

.ring-track {
  stroke: rgba(255, 215, 0, 0.28);
}

.ring-fill {
  stroke: var(--ember);
  stroke-linecap: round;
  stroke-dasharray: 289;
  stroke-dashoffset: 289;
}

.onward {
  margin-top: 12px;
  flex: 0 0 auto;
}

.coin-field {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 8px 0;
  overflow: hidden;
}

.drift {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  min-height: 0;
  animation: float 3.2s ease-in-out var(--d) infinite;
}

.drift img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.drift.caught {
  visibility: hidden;
}

.trayline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.trayline span {
  color: var(--gold);
  font-weight: 600;
  min-width: 3.2rem;
}

.tray {
  display: flex;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.tray img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.ascent {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 8px 0 4px;
}

.rail {
  position: absolute;
  left: 50%;
  top: 28px;
  bottom: 16px;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(var(--gold), var(--ember));
}

.crest {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

#trophy-drag {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(132px, 34cqw);
  height: auto;
  transform: translateX(-50%);
  touch-action: none;
  cursor: grab;
}

.purse {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 36px;
}

.purse img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.purse strong {
  font-family: var(--display);
  font-variation-settings: "opsz" 48, "wght" 700;
  color: var(--gold);
  font-size: 1.7rem;
  line-height: 1;
}

.purse span,
.bar-marks {
  color: rgba(255, 246, 222, 0.78);
  font-size: 0.82rem;
}

.hero {
  min-height: 0;
  overflow: auto;
  padding-top: 8px;
}

.hero h1 {
  margin-top: 8px;
  font-size: clamp(3.1rem, 18cqw, 5.4rem);
}

.hero h1 span {
  display: block;
}

.rule {
  width: 84px;
  height: 3px;
  margin: 14px 0 4px;
  background: linear-gradient(90deg, var(--ember), var(--gold));
}

.wearing,
.bestline {
  margin-top: 8px;
  font-size: 0.92rem;
}

.bestline {
  color: var(--gold);
  font-weight: 600;
}

.menu {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  flex: 0 0 auto;
}

.bar {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  flex: 0 0 auto;
}

.bar h2 {
  text-align: center;
  font-size: clamp(1.7rem, 8cqw, 2.4rem);
}

.back {
  min-height: 44px;
  width: auto;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 0.92rem;
}

.bar-marks {
  font-family: var(--display);
  font-variation-settings: "opsz" 36, "wght" 700;
  color: var(--gold);
  font-size: 1.35rem;
  white-space: nowrap;
  min-width: 1.5rem;
  text-align: right;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 8px;
  -webkit-overflow-scrolling: touch;
}

.skin {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.66);
}

.skin.worn {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 215, 0, 0.4);
}

.skin img {
  width: 92px;
  height: 62px;
  object-fit: contain;
}

.skin h3 {
  font-size: clamp(1.35rem, 6cqw, 1.8rem);
}

.skin p {
  margin: 4px 0 8px;
  font-size: 0.86rem;
}

.skin button {
  min-height: 42px;
  width: auto;
  min-width: 112px;
}

.record {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.18);
}

.rank {
  color: var(--ember);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.record b {
  display: block;
  color: var(--gold);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.record div span {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.empty {
  margin: auto;
  text-align: center;
  max-width: 24ch;
  padding: 24px 8px;
}

.settings {
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  min-height: 60px;
  padding: 0 16px;
}

.row.danger {
  color: var(--ember);
  border-color: rgba(255, 111, 0, 0.7);
}

.switch {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #171717;
  position: relative;
  flex: 0 0 auto;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cream);
  transition: transform 0.18s ease;
}

.row[aria-pressed="true"] .switch {
  background: var(--ember);
  border-color: transparent;
}

.row[aria-pressed="true"] .switch::after {
  transform: translateX(22px);
  background: var(--ink);
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 10, 0.72);
}

.card {
  width: min(100%, 380px);
  max-height: calc(100% - 8px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h2 {
  font-size: clamp(2.2rem, 12cqw, 3.5rem);
  text-align: center;
}

.card .eyebrow,
.card p {
  text-align: center;
}

#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 0.7fr) auto;
  gap: 6px;
  align-items: start;
  padding:
    max(10px, env(safe-area-inset-top))
    12px
    0
    12px;
  pointer-events: none;
}

.hud-k {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 246, 222, 0.72);
}

.hud strong {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-weight: 600;
  font-size: clamp(1rem, 5.4cqw, 1.55rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#pause {
  pointer-events: auto;
  width: auto;
  min-width: 72px;
  min-height: 44px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(10, 10, 10, 0.72);
  font-size: 0.92rem;
}

.hint {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(max(68px, env(safe-area-inset-top) + 58px));
  z-index: 2;
  text-align: center;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-shadow: 0 2px 12px #0A0A0A;
}

.hint-title {
  font-family: var(--display);
  font-variation-settings: "opsz" 60, "wght" 700;
  color: var(--gold);
  font-size: clamp(1.8rem, 8cqw, 2.6rem);
  line-height: 0.95;
}

.hint p {
  font-size: clamp(0.84rem, 3.4cqw, 0.98rem);
}

#ready-best {
  color: var(--gold);
  font-weight: 600;
}

.scrim {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 10, 10, 0.5);
}

#upright {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(10, 10, 10, 0.45), rgba(10, 10, 10, 0.82)),
    url("lantern-procession.jpg") center / cover no-repeat;
}

#upright p {
  max-width: 16ch;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.82);
  color: var(--gold);
  font-family: var(--display);
  font-variation-settings: "opsz" 72, "wght" 700;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  line-height: 0.95;
}

@keyframes float {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@media (min-width: 640px) {
  #stage {
    box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.28);
  }
}

@media (max-height: 700px) {
  button {
    min-height: 48px;
  }

  .menu {
    gap: 8px;
    padding-top: 10px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 14cqw, 3.6rem);
  }

  .rite-page h1 {
    font-size: clamp(2rem, 11cqw, 3rem);
  }

  .seal {
    width: min(168px, 46cqw);
  }

  .drift {
    width: 52px;
    height: 52px;
  }

  .lede {
    margin-top: 6px;
  }
}

@media (max-height: 560px) {
  .eyebrow {
    letter-spacing: 0.12em;
  }

  .rule {
    margin: 8px 0 2px;
  }

  .wearing {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #upright {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
