/* ---------------- Stage ---------------- */
.stage {
  position: relative;
  /* The pile sizes itself to this box (container units), whatever the window. */
  container-type: size;
  perspective: 1100px; /* so the pile can lean in 3D as you tilt the phone */
  margin: 8px 12px 0;
  border-radius: 34px;
  background: var(--stage);
  color: var(--stage-ink);
  overflow: hidden;
  isolation: isolate;
  min-height: 0;
}
.stage::after {
  /* grainy light, like a printed poster */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 20% 0%, rgba(255, 255, 255, 0.22), transparent 55%), radial-gradient(90% 70% at 100% 100%, rgba(0, 0, 0, 0.28), transparent 60%);
  z-index: -1;
}
.stage-bg {
  position: absolute;
  inset: -20% -40%;
  z-index: -1;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: rotate(-8deg);
}
.stage-word {
  font: 900 120px/0.85 var(--display);
  font-stretch: 62%;
  color: transparent;
  -webkit-text-stroke: 2px color-mix(in srgb, var(--stage-ink) 18%, transparent);
  white-space: normal;
  word-spacing: 30px;
  text-align: center;
  width: 160%;
  /* Its own GPU layer, drawn once: the drift only moves it. */
  will-change: transform;
  animation: marquee 40s linear infinite;
}
@keyframes marquee {
  to { transform: translateX(-25%); }
}
/* Lifting a book: the stage dims to a spotlight around it and the colour deepens. Drawn once as a
   gradient that only fades (a filter here would re-filter the whole stage every frame of the drag). */
.stage-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 55% at 50% 55%, transparent 35%, rgba(0, 0, 0, 0.45));
  display: none; /* only exists while you hold a book */
  animation: spot-in 0.3s ease-out both;
}
body.lifting .stage-bg::after { display: block; }
@keyframes spot-in {
  from { opacity: 0; }
}

.deck {
  position: absolute;
  /* The bottom band is kept free for the hint chip, so it never covers a book. */
  inset: 22px 0 58px;
  /* Passes are book-shaped: at least 1.5 × as tall as wide (narrower if the height is short). */
  --sw: clamp(88px, min(62cqw, 250px, calc((100cqh - 100px) / 1.5)), 250px);
  touch-action: none;
  outline: none;
  transform: translateX(calc(var(--sw) * -0.08));
}
.deck .stamp {
  --sh: max(calc(var(--sw) * 1.5), min(calc(var(--sw) * 1.62), calc(100cqh - 120px)));
}
.deck:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: -6px;
  border-radius: 34px;
}
.counter {
  position: absolute;
  top: 16px;
  right: 20px;
  text-align: right;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.14em;
  opacity: 0.8;
  pointer-events: none;
}

/* Drop zones appear while a book is lifted */
.zones {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: none; /* only while you hold a book */
}
body.lifting .zones { display: block; }
.zone {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  border-radius: 18px;
  opacity: 0;
  transition: transform 0.45s var(--spring), opacity 0.25s, background 0.2s, color 0.2s;
}
.zone b {
  font: 900 22px/1 var(--display);
  font-stretch: 70%;
  letter-spacing: 0.02em;
}
.zone small {
  font: 700 9px/1 var(--mono);
  letter-spacing: 0.12em;
}
.z-left,
.z-right {
  top: 18%;
  bottom: 18%;
  width: 58px;
  flex-direction: column;
  writing-mode: vertical-rl;
}
.z-left {
  left: 10px;
  transform: translateX(-140%) rotate(180deg);
}
.z-left b,
.z-left small {
  transform: none;
}
.z-right {
  right: 10px;
  transform: translateX(140%);
}
.z-top {
  top: 10px;
  left: 22%;
  right: 22%;
  height: 50px;
  transform: translateY(-160%);
  background: var(--yellow);
}
.z-bottom {
  bottom: 10px;
  left: 30%;
  right: 30%;
  height: 46px;
  transform: translateY(160%);
  background: #d91d16;
  color: var(--white);
}
.zone.on {
  opacity: 1;
}
.z-left.on { transform: rotate(180deg); }
.z-right.on,
.z-top.on,
.z-bottom.on { transform: none; }
.zone.hot {
  background: var(--lime);
  color: var(--ink);
}
.z-left.hot { transform: rotate(180deg) scale(1.12); }
.z-right.hot,
.z-top.hot,
.z-bottom.hot { transform: scale(1.12); }

/* Gesture hint chip with a ghost finger */
.hint-slot {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--lime);
  font: 11px/1 var(--pixel);
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.3s, transform 0.5s var(--spring);
}
.hint.on {
  opacity: 1;
  transform: none;
}
.ghost {
  position: relative;
  width: 18px;
  height: 18px;
  flex: none;
}
.ghost::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime);
}
.hint[data-anim="swipe"] .ghost::before { animation: g-swipe 1.4s ease-in-out 4; }
.hint[data-anim="up"] .ghost::before { animation: g-up 1.3s ease-in-out 4; }
.hint[data-anim="hold"] .ghost::before { animation: g-hold 1.4s ease-in-out 4; }
.hint[data-anim="tap"] .ghost::before { animation: g-tap 1.2s ease-in-out 4; }
@keyframes g-swipe {
  0%, 100% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
}
@keyframes g-up {
  0% { transform: translateY(6px); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-6px); opacity: 0; }
}
@keyframes g-hold {
  0%, 100% { transform: scale(0.6); }
  50% { transform: scale(1.3); box-shadow: 0 0 0 6px rgba(231, 255, 61, 0.25); }
}
@keyframes g-tap {
  0%, 30%, 60%, 100% { transform: scale(1); }
  15%, 45% { transform: scale(0.55); }
}
