/* ============================================================
   Ezoterium — Wróżba z run
   Wspólne style wszystkich etapów wróżby (/wrozba/runy/).
   Ten sam kosmos, co w numerologii, ale w barwie systemu
   (#45C9B0) — chłodny, zorzowy, z kamieniem zamiast szkła
   tam, gdzie pojawiają się runy.
   ============================================================ */

:root {
  --bg: #030a0b;
  --ink: #ecfbf7;
  --ink-soft: rgba(230, 248, 243, .93);
  --ink-mute: rgba(212, 236, 229, .78);
  --ink-faint: rgba(200, 226, 218, .58);
  --accent: #45c9b0;
  --accent-rgb: 69, 201, 176;
  --accent-light: #aef0e4;
  --light-rgb: 174, 240, 228;
  --hot: #eafff9;
  --bad-rgb: 236, 120, 146;
  --serif-display: 'Cormorant Garamond', Georgia, serif;
  --serif-text: 'Manrope', 'Segoe UI', system-ui, sans-serif;

  /* kamień */
  --stone-w: 64px;
  --stone-h: 88px;
  --stone-d: 16px;
  --stone-step: 88px;          /* odstęp kamieni w trójce */
  --stone-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .86 0 0 0 0 .93 0 0 0 0 .9 0 0 0 .42 -.08'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-text);
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

h1, h2 { font-family: var(--serif-display); font-weight: 500; margin: 0; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- animacje ---------- */
@keyframes tw        { 0%, 100% { opacity: .22; } 50% { opacity: 1; } }
@keyframes driftBg   { 0%, 100% { transform: translate(0, 0); }
                       50%      { transform: translate(1.2%, -1.2%); } }
@keyframes riseIn    { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulseGlow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ============================================================
   SCENA
   ============================================================ */

.scene {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  background: radial-gradient(130% 100% at 50% 46%,
    #0b2426 0%, #07181a 42%, #030a0b 78%, #010404 100%);
}

.scene--tall {
  height: auto;
  min-height: 100vh;
  min-height: 100svh;
}
.scene--tall .scene__nebula,
.scene--tall .scene__sky,
.scene--tall .scene__flight,
.scene--tall .scene__vignette { position: fixed; }

/* mgławica jak zorza — zieleń, turkus i odrobina fioletu */
.scene__nebula {
  position: absolute;
  inset: -4%;
  pointer-events: none;
  filter: blur(16px);
  animation: driftBg 44s ease-in-out infinite;
  background:
    radial-gradient(ellipse 200px 70px at 20% 24%, rgba(69, 201, 176, .14), transparent 70%),
    radial-gradient(ellipse 160px 60px at 78% 20%, rgba(110, 120, 220, .1), transparent 70%),
    radial-gradient(ellipse 240px 90px at 60% 82%, rgba(90, 220, 150, .07), transparent 70%),
    radial-gradient(ellipse 280px 110px at 40% 50%, rgba(50, 160, 170, .08), transparent 70%);
}

.scene__sky { position: absolute; inset: 0; pointer-events: none; }

.star {
  position: absolute;
  left: var(--l); top: var(--t);
  width: var(--s); height: var(--s);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px #fff;
  animation: tw var(--du) ease-in-out var(--d) infinite;
}

.scene__flight {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scene__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background: radial-gradient(120% 120% at 50% 50%, transparent 46%, rgba(1, 4, 4, .72) 100%);
}

/* ============================================================
   GÓRNA BELKA
   ============================================================ */

.topbar {
  position: relative;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: clamp(12px, 2.4vh, 24px) clamp(16px, 4vw, 44px);
}

.topbar__back {
  font-size: 13px;
  letter-spacing: .2em;
  color: var(--ink-mute);
  text-transform: uppercase;
  text-decoration: none;
  transition: color .3s ease;
}
.topbar__back:hover { color: var(--ink); }

.topbar__mark {
  font-family: var(--serif-display);
  font-size: clamp(15px, 2vw, 19px);
  letter-spacing: .42em;
  text-indent: .42em;
  color: #e6fbf6;
}

.topbar__reset {
  border: 1px solid rgba(var(--accent-rgb), .6);
  background: rgba(var(--accent-rgb), .08);
  color: var(--accent-light);
  font-family: var(--serif-text);
  font-size: 12.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 22px;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: background .3s ease, color .3s ease;
}
.topbar__reset:hover { background: rgba(var(--accent-rgb), .2); color: #fff; }
.topbar__reset--off { opacity: 0; pointer-events: none; }

/* ============================================================
   SCENA ETAPU
   ============================================================ */

.stage {
  position: relative;
  z-index: 70;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(14px, 4vw, 40px) clamp(14px, 3vh, 30px);
}

.stage__sub {
  margin: 0 auto;
  max-width: 46ch;
  flex-shrink: 0;
  text-align: center;
  font-size: clamp(13px, 1.7vw, 16px);
  line-height: 1.55;
  letter-spacing: .1em;
  color: rgba(200, 232, 224, .62);
  animation: riseIn .6s ease both;
}

.eyebrow {
  margin: 0;
  color: rgba(var(--light-rgb), .72);
  font-size: 12.5px;
  letter-spacing: .42em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ============================================================
   ETAP 1 — PYTANIE W SZKLE
   (ten sam odłamek, co w numerologii — warstwy:
   .shard lot z JS, .shard__body szkło i nadlot z CSS)
   ============================================================ */

@keyframes shardIn {
  from { opacity: 0; transform: scale(.06); filter: blur(6px); }
  60%  { opacity: 1; filter: blur(0); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes sheen {
  0%        { transform: translateX(-70%) rotate(0.001deg); }
  24%, 100% { transform: translateX(70%) rotate(0.001deg); }
}

@keyframes glint {
  0%, 84%, 100% { opacity: 0; transform: scale(.2) rotate(0deg); }
  90%           { opacity: 1; transform: scale(1) rotate(45deg); }
  96%           { opacity: 0; transform: scale(.4) rotate(90deg); }
}

.fields {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fields__space {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 5vh, 56px) 0;
  perspective: 900px;
}

.shard {
  position: relative;
  flex: none;
  will-change: transform, opacity;
  transform-style: preserve-3d;
}
.shard.is-focus { z-index: 5; }

.shard__body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(640px, 88vw);
  padding: 16px clamp(18px, 3vw, 32px) 12px;
  overflow: hidden;
  border: 1px solid rgba(var(--light-rgb), .26);
  border-radius: 28px 20px 30px 18px;
  background:
    linear-gradient(155deg,
      rgba(var(--light-rgb), .14) 0%,
      rgba(var(--accent-rgb), .05) 42%,
      rgba(8, 40, 40, .18) 100%);
  -webkit-backdrop-filter: blur(9px) saturate(140%);
  backdrop-filter: blur(9px) saturate(140%);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, .38),
    0 0 30px rgba(var(--accent-rgb), .12),
    inset 0 1px 0 rgba(255, 255, 255, .2),
    inset 0 0 26px rgba(var(--accent-rgb), .08);
  animation: shardIn 1.25s cubic-bezier(.18, .7, .25, 1) calc(.2s + var(--i) * .24s) both;
  transition: border-color .4s ease, box-shadow .4s ease, background .4s ease;
}

.shard__body::before {
  content: '';
  position: absolute;
  inset: -40%;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 40%,
    rgba(255, 255, 255, .14) 47%,
    rgba(var(--light-rgb), .3) 50%,
    rgba(255, 255, 255, .12) 53%,
    transparent 60%);
  mix-blend-mode: screen;
  transform: translateX(-70%);
  animation: sheen 8s ease-in-out 1.8s infinite;
}

.shard__glint {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 14px;
  height: 14px;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent 44%, #fff 50%, transparent 56%),
    linear-gradient(0deg,  transparent 44%, #fff 50%, transparent 56%);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 70%);
  mask-image: radial-gradient(circle, #000 18%, transparent 70%);
  filter: drop-shadow(0 0 4px rgba(var(--light-rgb), .9));
  animation: glint 5.5s ease-in-out 2.6s infinite;
}

.shard__label {
  font-size: 11px;
  letter-spacing: .42em;
  text-indent: .42em;
  text-transform: uppercase;
  color: rgba(var(--light-rgb), .72);
  cursor: text;
}

.shard__input {
  display: block;
  width: 100%;
  min-height: 3.9em;
  padding: 4px 2px;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--hot);
  caret-color: var(--accent-light);
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(21px, 2.7vw, 29px);
  line-height: 1.3;
  letter-spacing: .01em;
  text-align: center;
  text-shadow: 0 0 20px rgba(var(--accent-rgb), .5);
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--light-rgb), .3) transparent;
}
.shard__input::placeholder { color: rgba(var(--light-rgb), .24); text-shadow: none; font-style: italic; }
.shard__input:focus-visible { outline: none; }

.shard__hint {
  min-height: 1.3em;
  font-size: 12.5px;
  letter-spacing: .08em;
  color: var(--ink-faint);
  text-align: center;
  transition: color .3s ease;
}

.shard.is-focus .shard__body {
  border-color: rgba(var(--light-rgb), .6);
  background:
    linear-gradient(155deg,
      rgba(var(--light-rgb), .19) 0%,
      rgba(var(--accent-rgb), .08) 42%,
      rgba(8, 40, 40, .22) 100%);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, .42),
    0 0 44px rgba(var(--accent-rgb), .3),
    inset 0 1px 0 rgba(255, 255, 255, .28),
    inset 0 0 30px rgba(var(--accent-rgb), .14);
}

.shard__halo {
  position: absolute;
  inset: -22px;
  border-radius: 44px;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), .3), rgba(var(--accent-rgb), .07) 60%, transparent);
  filter: blur(8px);
  transition: opacity .8s ease;
}
.fields.is-aligned .shard__halo {
  opacity: 1;
  animation: pulseGlow 2.6s ease-in-out infinite;
}
.fields.is-aligned .shard__body { border-color: rgba(var(--light-rgb), .55); }
.fields.is-aligned .shard__hint { color: var(--accent-light); }

/* ---------- dół: błąd i przycisk ---------- */

.fields__foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: riseIn .8s ease .9s backwards;   /* bez „forwards" — inaczej nie zgaśnie przy odlocie */
  transition: opacity .6s ease;
}
.fields.is-leaving .fields__foot { opacity: 0; }

.fields__error {
  margin: 0;
  padding: 8px 18px;
  border: 1px solid rgba(var(--bad-rgb), .5);
  border-radius: 18px;
  background: rgba(90, 30, 50, .3);
  font-size: 13.5px;
  color: #f8dbe2;
  text-align: center;
}
.fields__error[hidden] { display: none; }

.cta {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 26px;
  padding: 12px 34px;
  background: rgba(var(--accent-rgb), .14);
  color: var(--accent-light);
  font-family: var(--serif-text);
  font-size: 14px;
  letter-spacing: .22em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(var(--accent-rgb), .2);
  transition: background .3s ease, color .3s ease, box-shadow .3s ease,
              opacity .5s ease, transform .5s cubic-bezier(.2, .8, .2, 1), visibility .5s;
}
.cta:hover, .cta:focus-visible {
  background: rgba(var(--accent-rgb), .28);
  color: #fff;
  box-shadow: 0 0 34px rgba(var(--accent-rgb), .45);
}

.cta.is-waiting {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(.94);
  pointer-events: none;
}

/* ============================================================
   ETAP 2 — KAMIENIE Z KOSMOSU

   .cast         — przycisk rozkładu (tekst i kamienie),
   .cast__float  — dryf zestawu (transform liczy numero-float.js),
   .stone        — miejsce kamienia, perspektywa i zanikanie,
   .stone__fly   — prostopadłościan: nadlot z koziołkowaniem (CSS),
   .stone__f     — sześć ścian bryły.
   Przezroczystość spłaszcza bryłę 3D, więc gra tylko na .stone,
   który sam nie przekazuje 3D dalej.
   ============================================================ */

@keyframes stoneFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* z głębi, koziołkując, aż do spoczynku — z drobnym przechyłem przy lądowaniu */
@keyframes stoneIn {
  0% {
    transform: translate3d(var(--fx), var(--fy), -2300px)
               rotateX(calc(var(--rx) + var(--sx)))
               rotateY(calc(var(--ry) + var(--sy)))
               rotateZ(calc(var(--rz) + var(--sz)));
  }
  86% {
    transform: translate3d(0, 0, 14px)
               rotateX(calc(var(--rx) - 7deg))
               rotateY(calc(var(--ry) + 5deg))
               rotateZ(var(--rz));
  }
  100% {
    transform: translate3d(0, 0, 0)
               rotateX(var(--rx))
               rotateY(var(--ry))
               rotateZ(var(--rz));
  }
}

/* rozgrzany lotem kamień stygnie */
@keyframes stoneHeat {
  0%, 55% { opacity: .9; }
  100%    { opacity: 0; }
}

@keyframes stoneImpact {
  0%   { opacity: 0; transform: scale(.3); }
  15%  { opacity: .9; }
  100% { opacity: 0; transform: scale(2.6); }
}

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

.spreadhead {
  flex-shrink: 0;
  max-width: 640px;
  text-align: center;
  animation: riseIn .6s ease both;
}

.spreadhead__title {
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: .02em;
  color: var(--ink);
  text-shadow: 0 0 30px rgba(var(--accent-rgb), .35);
}

.spreadhead__question {
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.spreadhead__label {
  font-size: 10.5px;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: rgba(var(--light-rgb), .6);
}

.spreadhead__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.4;
  color: var(--accent-light);
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.spreadhead__edit {
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-decoration: none;
  transition: color .3s ease;
}
.spreadhead__edit:hover { color: var(--accent-light); }

.casting {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vh, 20px);
}

.casting__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 8vw, 120px);
  padding: clamp(10px, 3vh, 30px) 0;
}

.casting__note {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: .12em;
  text-align: center;
  color: var(--ink-faint);
  animation: riseIn .8s ease 1.4s backwards;
  transition: opacity .5s ease;
}
.casting.is-leaving .casting__note { opacity: 0; }

/* ---------- przycisk rozkładu ---------- */

.cast {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 10px 12px;
  border: 0;
  border-radius: 26px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .5s ease;
}
.cast:focus-visible { outline: none; }

/* nierówno w przestrzeni — jak rzucone */
.cast--jedna { margin-top: -5vh; }
.cast--trzy  { margin-top: 6vh; }

.cast__float {
  display: block;
  will-change: transform, opacity;
}

.cast__stones {
  position: relative;
  display: block;
  height: calc(var(--stone-h) * 1.9);
}
.cast--jedna .cast__stones { width: calc(var(--stone-w) * 2.2); }
.cast--trzy  .cast__stones { width: calc(var(--stone-step) * 2 + var(--stone-w) * 2.2); }

/* poświata pod zestawem — zapala się pod kursorem */
.cast__stones::before {
  content: '';
  position: absolute;
  inset: 4% -10%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), .26), rgba(var(--accent-rgb), .06) 60%, transparent);
  filter: blur(10px);
  opacity: 0;
  transition: opacity .5s ease;
}
.cast:hover .cast__stones::before,
.cast:focus-visible .cast__stones::before { opacity: 1; }

.cast__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 250px;
  text-align: center;
  animation: riseIn .8s ease backwards;
  animation-delay: calc(.9s + var(--i) * .15s);
}

.cast__name {
  font-family: var(--serif-display);
  font-size: clamp(22px, 2.8vw, 28px);
  letter-spacing: .03em;
  color: var(--ink);
  transition: color .3s ease, text-shadow .3s ease;
}

.cast__sub {
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: .04em;
  color: var(--ink-mute);
  text-wrap: balance;
}

.cast:hover .cast__name,
.cast:focus-visible .cast__name {
  color: var(--hot);
  text-shadow: 0 0 22px rgba(var(--accent-rgb), .6);
}
.cast:focus-visible .cast__name { text-decoration: underline 1px rgba(var(--accent-rgb), .7); text-underline-offset: 6px; }

/* wybór: drugi zestaw gaśnie, wybrany rozbłyska */
.casting.is-leaving .cast:not(.is-chosen) { opacity: 0; pointer-events: none; }
.casting.is-leaving .cast { pointer-events: none; }
.cast.is-chosen .cast__stones::before { opacity: 1; animation: pulseGlow .9s ease-in-out infinite; }
.cast.is-chosen .cast__text { opacity: 0; transition: opacity .4s ease; }

/* ---------- kamień ---------- */

.stone {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--stone-w);
  height: var(--stone-h);
  margin-left: calc(var(--stone-w) / -2 + var(--k) * var(--stone-step));
  margin-top: calc(var(--stone-h) / -2 + var(--y));
  perspective: 700px;
  animation:
    stoneFade .5s ease-out var(--delay) both,
    stoneBob var(--bob) ease-in-out calc(var(--delay) + var(--dur)) infinite;
}

.stone__fly {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: stoneIn var(--dur) cubic-bezier(.16, .62, .3, 1) var(--delay) both;
}

.stone__f {
  position: absolute;
  overflow: hidden;
  backface-visibility: hidden;
  background-color: #2b3332;
  background-image:
    var(--stone-noise),
    linear-gradient(160deg, #3c4645 0%, #2a3231 55%, #1f2625 100%);
  background-size: 140px 140px, 100% 100%;
}

/* żar po locie z kosmosu (etap 2) — każda ściana stygnie razem z bryłą */
.stone__f::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 40%, rgba(214, 255, 246, .7), rgba(var(--accent-rgb), .35) 55%, rgba(var(--accent-rgb), .12));
  mix-blend-mode: screen;
}
.stone .stone__f::after { animation: stoneHeat var(--dur) ease-in var(--delay) both; }

/* wierzch widoczny dla pytającego to plecy runy — gładki kamień z wyrytym kółkiem */
.stone__f--front,
.stone__f--back {
  inset: 0;
  border-radius: 5px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .14),
    inset -1px -1px 0 rgba(0, 0, 0, .35),
    inset 0 0 14px rgba(0, 0, 0, .45);
  transition: box-shadow .4s ease;
}
.stone__f--front {
  transform: translateZ(calc(var(--stone-d) / 2));
  background-image:
    var(--stone-noise),
    radial-gradient(120% 90% at 28% 18%, rgba(255, 255, 255, .12), transparent 55%),
    linear-gradient(160deg, #46514f 0%, #313a39 55%, #232a29 100%);
  background-size: 140px 140px, 100% 100%, 100% 100%;
}
.stone__f--back  { transform: rotateY(180deg) translateZ(calc(var(--stone-d) / 2)); }

.stone__f--left,
.stone__f--right {
  top: 0;
  left: calc(50% - var(--stone-d) / 2);
  width: var(--stone-d);
  height: 100%;
  background-image:
    var(--stone-noise),
    linear-gradient(90deg, #262d2c, #1b2120);
}
.stone__f--right { transform: rotateY(90deg)  translateZ(calc(var(--stone-w) / 2)); }
.stone__f--left  { transform: rotateY(-90deg) translateZ(calc(var(--stone-w) / 2)); }

.stone__f--top,
.stone__f--bottom {
  left: 0;
  top: calc(50% - var(--stone-d) / 2);
  width: 100%;
  height: var(--stone-d);
  background-image:
    var(--stone-noise),
    linear-gradient(180deg, #353e3d, #232a29);
}
.stone__f--top    { transform: rotateX(90deg)  translateZ(calc(var(--stone-h) / 2)); }
.stone__f--bottom { transform: rotateX(-90deg) translateZ(calc(var(--stone-h) / 2)); }

.stone__mark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--light-rgb), .16);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .06);
  transition: border-color .4s ease, box-shadow .4s ease;
}
.stone__mark::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: rgba(var(--light-rgb), .18);
  transition: background .4s ease, box-shadow .4s ease;
}

.cast:hover .stone__f--front,
.cast:focus-visible .stone__f--front,
.cast.is-chosen .stone__f--front,
.pstone:hover .stone__f--front,
.pstone:focus-visible .stone__f--front {
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .18),
    inset -1px -1px 0 rgba(0, 0, 0, .35),
    inset 0 0 14px rgba(0, 0, 0, .35),
    inset 0 0 0 1px rgba(var(--accent-rgb), .45);
}
.cast:hover .stone__mark,
.cast:focus-visible .stone__mark,
.cast.is-chosen .stone__mark,
.pstone:hover .stone__mark,
.pstone:focus-visible .stone__mark {
  border-color: rgba(var(--light-rgb), .85);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .5), 0 0 10px rgba(var(--accent-rgb), .8), inset 0 0 6px rgba(var(--accent-rgb), .6);
}
.cast:hover .stone__mark::after,
.cast:focus-visible .stone__mark::after,
.cast.is-chosen .stone__mark::after,
.pstone:hover .stone__mark::after,
.pstone:focus-visible .stone__mark::after {
  background: var(--accent-light);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), .9);
}

/* fala pyłu w chwili lądowania */
.stone__impact {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120%;
  aspect-ratio: 1;
  margin: -60% 0 0 -60%;
  border-radius: 50%;
  pointer-events: none;
  border: 1px solid rgba(var(--light-rgb), .5);
  background: radial-gradient(closest-side, transparent 55%, rgba(var(--accent-rgb), .25) 85%, transparent);
  opacity: 0;
  animation: stoneImpact 1s ease-out calc(var(--delay) + var(--dur) * .8) both;
}

/* ============================================================
   ETAP 3 — PIERŚCIEŃ RUN I ODSŁANIANIE

   .belt         — scena z perspektywą, przeciąganie obraca pierścień,
   .belt__ring   — pierścień (obrót liczy runy-draw.js, promień --R),
   .pstone       — kamień na obwodzie, przygaszany z tyłu (--dim),
   .slot         — miejsce w rozkładzie; .sstone przylatuje tu z pierścienia,
   .sstone__turn — odwrócenie kamienia znakiem do góry.
   ============================================================ */

@keyframes beltIn {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: none; }
}

/* odwrócenie z uniesieniem — kamień podskakuje i przewraca się na plecy */
@keyframes stoneFlip {
  0%   { transform: none; }
  45%  { transform: translateZ(60px) rotateY(95deg); }
  100% { transform: rotateY(180deg); }
}

@keyframes runeGlow {
  from { opacity: 0; filter: blur(6px); }
  to   { opacity: 1; filter: none; }
}

.draw {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.draw__note {
  margin: 14px 0 0;
  min-height: 1.5em;
  font-size: 13.5px;
  letter-spacing: .12em;
  text-align: center;
  color: var(--ink-mute);
  animation: riseIn .6s ease .2s backwards;
  transition: opacity .5s ease;
}
.draw.is-done .draw__note { opacity: 0; }

.draw__plain { display: none; margin: 18px 0 0; }
.no-js .draw__plain { display: block; }
.no-js .belt, .no-js .draw__note { display: none; }

/* ---------- pierścień ---------- */

.belt {
  --stone-w: 48px;
  --stone-h: 66px;
  --stone-d: 12px;
  position: relative;
  width: 100%;
  height: clamp(240px, 46vh, 420px);
  perspective: 1200px;
  perspective-origin: 50% 38%;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  animation: beltIn .7s cubic-bezier(.2, .8, .2, 1) backwards;
  transition: opacity .6s ease, height .8s cubic-bezier(.4, 0, .2, 1);
}
.belt.is-dragging { cursor: grabbing; }
.draw.is-done .belt { opacity: 0; height: 0; pointer-events: none; }

.belt__ring {
  --R: 300px;
  position: absolute;
  left: 50%;
  top: 38%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}

.pstone {
  position: absolute;
  left: calc(var(--stone-w) / -2);
  top: calc(var(--stone-h) / -2);
  width: var(--stone-w);
  height: var(--stone-h);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-style: preserve-3d;
  transform:
    rotateY(var(--a)) translateZ(var(--R))
    translateY(var(--jy)) rotateZ(var(--jz)) rotateX(var(--jx));
}
.pstone:focus-visible { outline: none; }
.pstone.is-taken { visibility: hidden; pointer-events: none; }

.pstone__body {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.pstone:hover .pstone__body,
.pstone:focus-visible .pstone__body { transform: translateZ(18px) scale(1.1); }

/* kamienie z tyłu pierścienia giną w mroku */
.pstone .stone__f::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: rgba(1, 6, 6, var(--dim, 0));
}

/* ---------- miejsca rozkładu ---------- */

.slots {
  --stone-w: 72px;
  --stone-h: 100px;
  --stone-d: 18px;
  list-style: none;
  margin: 0;
  padding: clamp(6px, 2vh, 18px) 0 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(18px, 5vw, 64px);
  animation: riseIn .6s ease .3s both;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 150px;
  text-align: center;
}

.slot__place {
  min-height: 2.6em;
  font-size: 10.5px;
  line-height: 1.3;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: rgba(var(--light-rgb), .62);
  text-wrap: balance;
}
.slots--1 .slot__place { min-height: 0; }

.slot__bed {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--stone-w) + 26px);
  height: calc(var(--stone-h) + 26px);
  border: 1px dashed rgba(var(--light-rgb), .26);
  border-radius: 14px;
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), .08), transparent);
  transition: border-color .6s ease, background .6s ease;
}
.slot.is-in .slot__bed { border-color: transparent; }
.slot.is-revealed .slot__bed {
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), .28), rgba(var(--accent-rgb), .06) 70%, transparent);
}

.sstone {
  position: relative;
  width: var(--stone-w);
  height: var(--stone-h);
  perspective: 700px;
  visibility: hidden;
}
.slot.is-in .sstone { visibility: visible; }

.sstone__body,
.sstone__turn {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.sstone__body { transform: rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz)); }

.slot.is-revealed .sstone__turn { transform: rotateY(180deg); }
.slot.is-flipping .sstone__turn { animation: stoneFlip 1s cubic-bezier(.3, .6, .25, 1) both; }

/* znak wyryty na spodzie kamienia */
.stone__rune {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Sans Runic', 'Segoe UI Historic', 'Segoe UI Symbol', sans-serif;
  font-weight: 400;
  font-size: calc(var(--stone-h) * .56);
  line-height: 1;
  color: var(--accent-light);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), .95), 0 0 24px rgba(var(--accent-rgb), .55), 0 1px 0 rgba(0, 0, 0, .6);
}
.stone__rune--rev { rotate: 180deg; }
.slot.is-flipping .stone__rune { animation: runeGlow .8s ease .55s both; }

.slot.is-revealed .stone__f--back {
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .14),
    inset -1px -1px 0 rgba(0, 0, 0, .35),
    inset 0 0 18px rgba(var(--accent-rgb), .3);
}

.slot__name {
  min-height: 1.4em;
  font-family: var(--serif-display);
  font-size: clamp(19px, 2.2vw, 23px);
  letter-spacing: .04em;
  color: var(--hot);
  text-shadow: 0 0 18px rgba(var(--accent-rgb), .5);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .6s ease .7s, transform .6s ease .7s;
}
.slot__name i {
  display: block;
  font-family: var(--serif-text);
  font-style: normal;
  font-size: 10.5px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(var(--bad-rgb), .9);
}
.slot.is-revealed .slot__name { opacity: 1; transform: none; }

/* ---------- znaczenia run ---------- */

.reading {
  width: min(680px, 100%);
  margin: clamp(18px, 4vh, 36px) 0 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.reading[hidden] { display: none; }

.rune {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 4px 18px;
  align-items: start;
  padding: 18px clamp(16px, 3vw, 26px) 18px clamp(12px, 2vw, 18px);
  border: 1px solid rgba(var(--light-rgb), .22);
  border-radius: 22px;
  background: linear-gradient(165deg, rgba(20, 60, 58, .5), rgba(5, 18, 20, .72));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .08);
  animation: riseIn .7s ease both;
  animation-delay: calc(var(--i) * .18s);
}

.rune__glyph {
  display: flex;
  justify-content: center;
  padding-top: 4px;
  font-family: 'Noto Sans Runic', 'Segoe UI Historic', 'Segoe UI Symbol', sans-serif;
  font-size: 56px;
  line-height: 1;
  color: var(--accent-light);
  text-shadow: 0 0 16px rgba(var(--accent-rgb), .8), 0 0 36px rgba(var(--accent-rgb), .35);
}
.rune__glyph--rev { rotate: 180deg; }

.rune__place {
  margin: 0 0 2px;
  font-size: 10.5px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(var(--light-rgb), .6);
}

.rune__name {
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.15;
  color: var(--ink);
}
.rune__sense {
  font-size: .62em;
  letter-spacing: .03em;
  color: var(--accent-light);
}
.rune__rev {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  vertical-align: middle;
  border: 1px solid rgba(var(--bad-rgb), .55);
  border-radius: 12px;
  font-family: var(--serif-text);
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #f6cfd9;
}

.rune__keys {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.rune__keys li {
  padding: 3px 11px;
  border: 1px solid rgba(var(--accent-rgb), .35);
  border-radius: 14px;
  background: rgba(var(--accent-rgb), .08);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-light);
}

.rune__text {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.reading__foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  text-align: center;
  animation: riseIn .7s ease .6s both;
}

.reading__note {
  margin: 0;
  font-size: 13.5px;
  letter-spacing: .06em;
  color: var(--ink-faint);
}

.reading__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 22px;
}

.reading__link {
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  text-decoration: none;
  transition: color .3s ease;
}
.reading__link:hover { color: var(--accent-light); }

/* ============================================================
   RESPONSYWNOŚĆ
   ============================================================ */

@media (max-width: 640px) {
  :root {
    --stone-w: 52px;
    --stone-h: 72px;
    --stone-d: 13px;
    --stone-step: 70px;
  }

  .topbar__mark { display: none; }

  .casting__row { flex-direction: column; gap: 10px; }
  .cast--jedna { margin: 0 22vw 0 0; }
  .cast--trzy  { margin: 0 0 0 8vw; }
  .cast { gap: 8px; }

  .belt { --stone-w: 30px; --stone-h: 42px; --stone-d: 8px; height: 250px; }
  .slots { --stone-w: 56px; --stone-h: 78px; --stone-d: 14px; gap: 6px; }
  .slot { width: 104px; }
  .slot__place { letter-spacing: .16em; }
  .rune { grid-template-columns: 50px 1fr; gap: 4px 12px; }
  .rune__glyph { font-size: 42px; }
}

@media (max-height: 640px) and (min-width: 641px) {
  :root {
    --stone-w: 54px;
    --stone-h: 74px;
    --stone-d: 14px;
    --stone-step: 74px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scene__nebula, .star { animation: none; }
  .stage__sub, .fields__foot, .soon, .spreadhead, .cast__text, .casting__note { animation: none; }
  .shard__body { animation: none; }
  .shard__body::before, .shard__glint { animation: none; opacity: 0; }
  .fields.is-aligned .shard__halo { animation: none; }
  .stone, .stone__impact, .stone__f::after { animation: none; }
  .stone__impact, .stone__f::after { opacity: 0; }
  .stone__fly {
    animation: none;
    transform: rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz));
  }
  .belt, .draw__note, .slots, .rune, .reading__foot { animation: none; }
  .slot.is-flipping .sstone__turn, .slot.is-flipping .stone__rune { animation: none; }
  .belt, .pstone__body, .slot__name { transition: none; }
}
