:root {
  --void: #05060a;
  --ink: #e8e6f2;
  --mute: rgba(232, 230, 242, 0.7);
  --line: rgba(232, 230, 242, 0.14);
  --serif: "Cormorant Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: Manrope, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #05060a;
  color: var(--ink);
  font-family: var(--sans);
  touch-action: none;
}

#app {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060a;
}

#depth-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

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

body.title-mode #hud-right,
body.title-mode #brand,
body.title-mode #season {
  opacity: 0;
  pointer-events: none;
}

#grain {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.07;
  mix-blend-mode: overlay;
  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='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  background: radial-gradient(ellipse at 50% 42%, rgba(20, 24, 40, 0.15), rgba(5, 6, 10, 0.55) 55%, rgba(5, 6, 10, 0.78));
  transition: opacity 1.1s ease;
}

#title-screen.out {
  opacity: 0;
  pointer-events: none;
}

#word {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(64px, 16vw, 128px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  line-height: 1;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.6s ease, transform 1.6s ease;
  text-shadow: 0 0 40px rgba(160, 190, 255, 0.25);
}

#word.on {
  opacity: 1;
  transform: none;
}

#tag {
  margin-top: 18px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(16px, 3.6vw, 22px);
  letter-spacing: 0.18em;
  color: var(--mute);
  opacity: 0;
  transition: opacity 1.8s ease;
}

#tag.on {
  opacity: 1;
}

#whisper {
  position: absolute;
  bottom: 11vh;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--mute);
  opacity: 0;
  transition: opacity 2s ease;
}

#whisper.on {
  opacity: 0.95;
}

#title-actions {
  margin-top: 40px;
  display: flex;
  gap: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s ease, transform 1s ease;
  pointer-events: auto;
}

#btn-born {
  padding: 16px 36px;
  font-size: 13px;
  letter-spacing: 0.28em;
  border-color: rgba(232, 230, 242, 0.35);
  min-width: 180px;
}

#title-actions.on {
  opacity: 1;
  transform: none;
}

button {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  padding: 12px 22px;
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 0.3s, background 0.3s, color 0.3s;
}

button:hover,
button:active {
  border-color: rgba(232, 230, 242, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

#btn-continue {
  display: none;
}
#btn-continue.show {
  display: inline-flex;
}

#veil {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9vh;
  display: flex;
  justify-content: center;
  padding: 0 28px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

#veil.on {
  opacity: 1;
  transform: none;
}

#igra-line {
  max-width: 720px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 5.4vw, 32px);
  line-height: 1.35;
  text-align: center;
  color: rgba(243, 240, 250, 0.98);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.85);
}

#hint {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(232, 230, 242, 0.62);
  opacity: 0;
  transition: opacity 0.8s ease;
}

#fit-debug {
  position: fixed;
  left: 8px;
  top: 8px;
  bottom: auto;
  z-index: 50;
  max-width: calc(100vw - 16px);
  padding: 3px 5px;
  font-size: 10px;
  line-height: 1.25;
  letter-spacing: 0.04em;
  color: rgba(232, 230, 242, 0.6);
  background: rgba(0, 0, 0, 0.38);
  pointer-events: none;
  white-space: pre-line;
  display: none;
}
body.debug #fit-debug {
  display: block;
}

#hud-right {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

#hud-right button {
  padding: 8px 12px;
  letter-spacing: 0.14em;
  font-size: 11px;
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(238, 236, 246, 0.82);
}

#fate-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 9, 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
  padding: 32px;
  text-align: center;
}
#fate-screen.on {
  opacity: 1;
  pointer-events: auto;
}
#fate-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(20px, 5vw, 30px);
  max-width: 520px;
  margin-bottom: 28px;
}
#fate-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

#sky-btn {
  display: none;
}
#sky-btn.show {
  display: inline-flex;
}
#sky-btn.lit {
  border-color: rgba(78, 224, 255, 0.45);
  color: #9be7ff;
}

#law {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0.08em;
  color: rgba(198, 255, 58, 0.92);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
#law.on {
  opacity: 1;
}

#sigil-verses {
  margin-top: 16px;
  max-width: 360px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.45;
  color: rgba(222, 214, 255, 0.9);
  text-align: center;
}

#sigil-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 9, 0.78);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 32px 20px 40px;
}

#sigil-screen.on {
  opacity: 1;
  pointer-events: auto;
}

#sigil-canvas {
  display: block;
  margin: 0 auto;
}

#sigil-name {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: center;
}

#sigil-sub {
  margin-top: 6px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--mute);
  text-align: center;
  max-width: 320px;
}

#sigil-stats {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: rgba(232, 230, 242, 0.72);
}

#sigil-actions {
  margin-top: 28px;
  display: flex;
  gap: 10px;
}

#btn-forget {
  border-color: rgba(255, 80, 90, 0.25);
  color: rgba(255, 170, 170, 0.7);
}

#brand {
  position: absolute;
  top: 20px;
  left: 20px;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.38em;
  color: rgba(232, 230, 242, 0.45);
  pointer-events: none;
}

#season {
  position: absolute;
  top: 38px;
  left: 20px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: rgba(232, 230, 242, 0.55);
  pointer-events: none;
}

#sigil-season {
  margin-top: 10px;
  font-family: var(--serif);
  font-style: italic;
  color: rgba(232, 230, 242, 0.78);
  text-align: center;
  max-width: 340px;
}

#mouth-wrap {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: rgba(232, 230, 242, 0.35);
  width: min(320px, 86vw);
}

#mouth-url {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-radius: 999px;
  outline: none;
}

.android-compact #word {
  font-size: 42px;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
}

.android-compact #tag {
  font-size: 14px;
  letter-spacing: 0.05em;
}

.android-compact #title-actions {
  width: 100%;
  max-width: 360px;
  padding: 0 4px;
  gap: 6px;
  justify-content: center;
}

.android-compact #title-actions button {
  min-width: 0;
  padding: 12px 16px;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.android-compact #hud-right {
  left: 8px;
  right: 8px;
  gap: 3px;
}

.android-compact #hud-right button {
  padding: 7px 8px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
}

@media (max-width: 420px) {
  #word {
    font-size: 56px;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
  }

  #tag {
    font-size: 16px;
    letter-spacing: 0.08em;
  }

  #title-actions {
    width: 100%;
    max-width: 380px;
    padding: 0 8px;
    gap: 8px;
    justify-content: center;
  }

  #title-actions button {
    min-width: 0;
    padding-left: 20px;
    padding-right: 20px;
  }

  #hud-right {
    left: 10px;
    right: 10px;
    gap: 4px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  #hud-right button {
    padding: 7px 8px;
    font-size: 10px;
  }
}

@media (max-height: 560px) {
  #word {
    font-size: 56px;
  }
  #title-actions {
    margin-top: 24px;
  }
}
