:root {
  --void: #060304;
  --ink: #12080c;
  --clay: #2a1418;
  --stone: #4a3036;
  --bone: #e8d4c4;
  --dust: #b89888;
  --gold: #c4a15a;
  --ember: #c43a28;
  --blood: #6e1020;
  --ash: #8a6860;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--bone);
  background:
    radial-gradient(ellipse at 50% -10%, #3a1214 0%, transparent 42%),
    radial-gradient(ellipse at 78% 110%, #1a0608 0%, transparent 40%),
    var(--void);
  font-family: "IM Fell English", "Times New Roman", serif;
  letter-spacing: 0.01em;
}

.grain,
.vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
}

.grain {
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  box-shadow: inset 0 0 180px 40px #000;
}

.site-nav,
.masthead,
main,
.journal {
  position: relative;
  z-index: 1;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.4rem;
  padding: 1.1rem 1rem 0;
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.langs {
  flex-basis: 100%;
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-top: -0.35rem;
}

.langs button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--dust);
  font-family: Cinzel, serif;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  cursor: pointer;
  padding: 0.1rem 0.05rem;
  border-bottom: 1px solid transparent;
}

.langs button[aria-pressed="true"],
.langs button:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.site-nav a {
  color: var(--dust);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 0.15rem;
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.masthead {
  text-align: center;
  padding: 1.6rem 1.2rem 0.4rem;
}

.sigil {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.55em;
  font-family: Cinzel, serif;
  font-size: 0.95rem;
  opacity: 0.85;
}

h1 {
  margin: 0.35rem 0 0;
  font-family: Cinzel, serif;
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0.4rem 0 0;
  color: var(--dust);
  font-style: italic;
}

.altar {
  width: min(760px, calc(100% - 2rem));
  margin: 1.6rem auto 0;
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field span {
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.field textarea {
  width: 100%;
  min-height: 6.2rem;
  resize: vertical;
  border: 1px solid #5a3030;
  background: rgba(12, 6, 8, 0.72);
  color: var(--bone);
  padding: 0.85rem 1rem;
  font: inherit;
  font-size: 1.15rem;
  outline: none;
}

.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(196, 161, 90, 0.25);
}

.reduction {
  margin: 0;
  min-height: 2.6rem;
  text-align: center;
  color: var(--ash);
  line-height: 1.7;
}

.reduction .keep {
  color: var(--gold);
  letter-spacing: 0.12em;
}

.reduction .fall {
  color: #6a4040;
  text-decoration: line-through;
  text-decoration-color: #8a3030;
}

.reduction .ashes {
  display: block;
  margin-top: 0.35rem;
  font-family: Cinzel, serif;
  font-size: 1.05rem;
  letter-spacing: 0.34em;
  color: var(--bone);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  justify-content: center;
}

.modes {
  display: flex;
  gap: 0.45rem;
}

.mode {
  appearance: none;
  border: 1px solid #5a3030;
  background: transparent;
  color: var(--dust);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
}

.mode.is-active {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}

.cast,
.rite-btn,
.cease {
  appearance: none;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #3a1616, #14080a);
  color: var(--bone);
  font-family: Cinzel, serif;
  font-size: 1.05rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  padding: 1rem 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: inset 0 0 24px rgba(196, 58, 40, 0.18);
}

.cast:hover:not(:disabled),
.rite-btn:hover,
.cease:hover {
  background: linear-gradient(180deg, #4a1c1c, #1c0a0c);
}

.cast:disabled {
  opacity: 0.55;
  cursor: wait;
}

.cast-rune {
  color: var(--gold);
  letter-spacing: 0;
}

.entropy {
  margin: 0;
  text-align: center;
  color: #8a6860;
  font-size: 0.92rem;
}

.cloth {
  width: min(640px, calc(100% - 2rem));
  margin: 1.6rem auto 0;
  padding: 1.6rem 1.2rem 1.4rem;
  display: grid;
  justify-items: center;
  gap: 1rem;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(110, 16, 32, 0.22), transparent 46%),
    linear-gradient(180deg, rgba(32, 12, 14, 0.78), rgba(10, 6, 7, 0.92));
  border: 1px solid #3a2020;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.45);
}

.seal {
  position: relative;
  width: min(480px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(196, 161, 90, 0.08), transparent 42%),
    radial-gradient(circle at 50% 50%, #1a0c0e, #070304 72%);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.55),
    0 0 0 1px #4a2828;
}

.seal.is-charged {
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.4),
    0 0 28px rgba(196, 58, 40, 0.28),
    0 0 0 1px var(--gold);
}

.glyph,
.veil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.glyph {
  overflow: visible;
}

.glyph .ring,
.glyph .tick,
.glyph .mark,
.glyph .stroke {
  fill: none;
  stroke: var(--bone);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.glyph .ring,
.glyph .tick {
  stroke: #8a6860;
}

.glyph .stroke {
  stroke: var(--gold);
  filter: drop-shadow(0 0 3px rgba(196, 161, 90, 0.35));
}

.glyph .mark {
  stroke: var(--ember);
}

.glyph .is-drawing {
  animation: draw 1.15s ease forwards;
}

.veil {
  cursor: crosshair;
  touch-action: none;
}

.cloth-hint {
  margin: 0;
  color: #8a6860;
  font-style: italic;
  text-align: center;
}

.rite {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.rite[hidden],
.controls[hidden],
.cease[hidden] {
  display: none;
}

.rite-btn {
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  padding: 0.7rem 1rem;
  min-width: 9.5rem;
}

.rite-ember {
  border-color: var(--ember);
  color: #f0c8b8;
}

.cease {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  min-width: 10rem;
}

.reading {
  width: min(640px, calc(100% - 2rem));
  margin: 1.4rem auto 2rem;
}

.asked,
.weave,
.seed {
  text-align: center;
}

.asked {
  color: var(--gold);
  font-style: italic;
  font-size: 1.2rem;
}

.weave {
  color: var(--dust);
  letter-spacing: 0.28em;
  font-family: Cinzel, serif;
}

.seed {
  color: #7a5854;
  font-size: 0.9rem;
}

.note {
  margin: 0.8rem 0 0;
  text-align: center;
  color: var(--ash);
  line-height: 1.45;
}

.oracle {
  margin: 1.2rem 0 0.4rem;
  padding: 1.1rem 1.05rem 1.15rem;
  border: 1px solid #5a3a32;
  background:
    radial-gradient(ellipse at 10% 0%, rgba(196, 161, 90, 0.08), transparent 46%),
    rgba(12, 8, 7, 0.82);
}

.oracle h2 {
  margin: 0 0 0.45rem;
  font-family: Cinzel, serif;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.oracle .note {
  margin-top: 0.35rem;
}

.journal {
  width: min(640px, calc(100% - 2rem));
  margin: 0 auto 3.5rem;
}

.journal h2 {
  margin: 0;
  font-family: Cinzel, serif;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.journal ol {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.journal li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2b1818;
  padding-bottom: 0.45rem;
}

.hist-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #12080c;
}

.hist-mark .stroke {
  stroke: var(--gold);
  fill: none;
}

.hist-mark .ring,
.hist-mark .tick,
.hist-mark .mark {
  fill: none;
  stroke: #6a4040;
}

.hist-meta {
  margin: 0;
  color: #8d6860;
  font-size: 0.92rem;
}

.hist-hash {
  font-family: Cinzel, serif;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.empty {
  color: #7a5854;
  font-style: italic;
}

body.is-charging .site-nav,
body.is-charging .masthead,
body.is-charging .altar,
body.is-charging .reading,
body.is-charging .journal,
body.is-charging .rite,
body.is-charging .cloth-hint {
  opacity: 0;
  pointer-events: none;
}

body.is-charging {
  background: #050203;
}

body.is-charging .cloth {
  width: min(92vw, 720px);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  margin-top: 8vh;
}

body.is-charging .seal {
  animation: gnosis 2.8s ease-in-out infinite;
}

body.is-forgetting .rite-btn:first-child {
  visibility: hidden;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes gnosis {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1) saturate(1);
  }
  50% {
    transform: scale(1.045);
    filter: brightness(1.22) saturate(1.35);
  }
}

@media (max-width: 520px) {
  .rite-btn {
    min-width: 8rem;
  }
}
