:root {
  --void: #07040d;
  --ink: #0a0612;
  --plum: #1a0b28;
  --grape: #2a1240;
  --gold: #d4af37;
  --gold-soft: #f4e4a6;
  --gold-dim: #8a6a1a;
  --cream: #f5e6c8;
  --muted: #b9a88a;
  --rose: #c41e3a;
  --violet: #7c3aed;
  --emerald: #3d9b6e;
  --line: rgba(212, 175, 55, 0.28);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font-display: "Cinzel", serif;
  --font-body: "Cormorant Garamond", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--void);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--gold-soft);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 1rem;
  background: var(--gold);
  color: var(--ink);
}

.skip-link:focus {
  top: 1rem;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(ellipse 40% 30% at 80% 20%, rgba(212, 175, 55, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(7, 4, 13, 0.2), rgba(7, 4, 13, 0.75));
}

.site-header,
main,
.site-footer,
.modal {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 6vw;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, rgba(7, 4, 13, 0.92), rgba(7, 4, 13, 0.55) 70%, transparent);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--gold-soft);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.brand-mark {
  color: var(--gold);
  animation: twinkle 2.8s ease-in-out infinite;
}

.site-nav {
  display: flex;
  gap: 1.6rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--muted);
  position: relative;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35rem;
  width: 0;
  height: 1px;
  background: var(--gold);
  transition: width 0.35s var(--ease);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--gold-soft);
}

.site-nav a:hover::after,
.site-nav a:focus-visible::after {
  width: 100%;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--gold-dim);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.lang-btn {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 0.2rem 0.15rem;
}

.lang-btn.is-active,
.lang-btn[aria-pressed="true"] {
  color: var(--gold-soft);
}

.hero {
  min-height: calc(100svh - 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.2rem 6vw 4.5rem;
  position: relative;
}

.hero-orbit {
  position: absolute;
  inset: 8% 10%;
  pointer-events: none;
  overflow: hidden;
}

.float-card,
.float-hat {
  position: absolute;
  font-size: 1.4rem;
  opacity: 0.55;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.4));
  animation: floaty 9s ease-in-out infinite;
}

.float-card {
  padding: 0.55rem 0.45rem;
  border-radius: 0.35rem;
  background: linear-gradient(180deg, #f7efe0, #e7d7b1);
  color: #1a0b12;
  font-family: var(--font-display);
  font-size: 0.85rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.c1 { top: 8%; left: 8%; animation-delay: 0s; transform: rotate(-12deg); color: #111; }
.c2 { top: 18%; right: 12%; animation-delay: -2s; transform: rotate(8deg); color: var(--rose); }
.c3 { bottom: 22%; left: 14%; animation-delay: -4s; transform: rotate(14deg); color: var(--rose); }
.c4 { bottom: 16%; right: 10%; animation-delay: -6s; transform: rotate(-6deg); color: #111; }
.float-hat { top: 12%; left: 2%; font-size: 2rem; animation-delay: -3s; opacity: 0.4; }

.eyebrow {
  font-family: var(--font-display);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--gold);
  margin: 0 0 1rem;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 8.5vw, 6.2rem);
  letter-spacing: 0.08em;
  line-height: 0.95;
}

.gold-foil {
  background: linear-gradient(105deg, #8a6a1a 0%, #f4e4a6 22%, #d4af37 48%, #fff6d2 52%, #d4af37 62%, #8a6a1a 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: foil 8s linear infinite;
  filter: drop-shadow(0 0 18px rgba(212, 175, 55, 0.28));
}

.hero-slogan {
  margin: 1.2rem 0 0;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  font-style: italic;
  color: var(--gold-soft);
}

.hero-lead {
  max-width: 38rem;
  margin: 1rem auto 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 0.3s var(--ease), box-shadow 0.3s, background 0.3s, color 0.3s;
}

.btn-gold {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--ink);
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.25);
}

.btn-gold:hover,
.btn-gold:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(212, 175, 55, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--gold-soft);
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: rgba(212, 175, 55, 0.08);
  transform: translateY(-2px);
}

.scroll-hint {
  position: absolute;
  bottom: 1.5rem;
  height: 3.2rem;
}

.scroll-wand {
  display: block;
  width: 1px;
  height: 100%;
  margin: 0 auto;
  background: linear-gradient(180deg, transparent, var(--gold), transparent);
  animation: wand 2.2s ease-in-out infinite;
}

.levels,
.trick-section {
  padding: 5rem 6vw;
  scroll-margin-top: 4.5rem;
}

.section-head {
  max-width: 42rem;
  margin: 0 auto 2.8rem;
  text-align: center;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  margin: 0.2rem 0 0.8rem;
  letter-spacing: 0.06em;
}

.section-lead {
  color: var(--muted);
  margin: 0;
}

.level-portals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
}

.portal {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.6rem 1.4rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(42, 18, 64, 0.45), rgba(10, 6, 18, 0.7)),
    radial-gradient(circle at 80% 0%, rgba(212, 175, 55, 0.12), transparent 40%);
  color: inherit;
  transition: transform 0.4s var(--ease), border-color 0.4s, box-shadow 0.4s;
}

.portal:hover,
.portal:focus-visible {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: var(--shadow), 0 0 0 1px rgba(212, 175, 55, 0.2);
}

.portal-count {
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: 0.2em;
  font-size: 0.75rem;
}

.portal-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.trick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}

.trick-card {
  position: relative;
  padding: 1.6rem 1.5rem 1.4rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(165deg, rgba(26, 11, 40, 0.85), rgba(7, 4, 13, 0.92));
  box-shadow: inset 0 1px 0 rgba(244, 228, 166, 0.08);
  transform-style: preserve-3d;
  transition: transform 0.45s var(--ease), border-color 0.45s, box-shadow 0.45s;
  overflow: hidden;
}

.trick-card::before,
.trick-card::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  pointer-events: none;
}

.trick-card::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.trick-card::after { right: 10px; bottom: 10px; border-left: 0; border-top: 0; }

.trick-card:hover {
  transform: translateY(-8px) rotateX(2deg);
  border-color: rgba(212, 175, 55, 0.7);
  box-shadow: var(--shadow), 0 0 40px rgba(124, 58, 237, 0.12);
}

.trick-card .spark {
  position: absolute;
  top: -20%;
  left: -30%;
  width: 40%;
  height: 140%;
  background: linear-gradient(90deg, transparent, rgba(244, 228, 166, 0.12), transparent);
  transform: rotate(18deg);
  animation: sheen 5.5s ease-in-out infinite;
  pointer-events: none;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-num {
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

.badge {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.25rem 0.55rem;
  border: 1px solid currentColor;
}

.badge.beginner { color: var(--emerald); }
.badge.intermediate { color: #c4a1ff; }
.badge.expert { color: #f0a0a8; }

.card-icon {
  width: 3.2rem;
  height: 3.2rem;
  margin-bottom: 0.8rem;
  color: var(--gold);
}

.trick-card h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.45rem;
}

.trick-card p {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.reveal {
  opacity: 0;
  transform: translateY(22px);
}

.reveal.visible {
  animation: fade-up 0.9s var(--ease) forwards;
}

.site-footer {
  padding: 3.5rem 6vw 2.5rem;
  text-align: center;
  border-top: 1px solid var(--line);
}

.footer-brand {
  font-family: var(--font-display);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.8rem;
}

.footer-code {
  max-width: 36rem;
  margin: 0 auto 1.2rem;
  color: var(--muted);
  font-style: italic;
}

.footer-copy {
  color: var(--gold-dim);
  font-size: 0.9rem;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 2, 8, 0.78);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  padding: 1.8rem 1.6rem 1.6rem;
  background:
    linear-gradient(180deg, rgba(26, 11, 40, 0.96), rgba(7, 4, 13, 0.98));
  border: 1px solid var(--line);
  box-shadow: var(--shadow), 0 0 80px rgba(124, 58, 237, 0.18);
  animation: curtain 0.55s var(--ease);
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  background: none;
  color: var(--gold-soft);
  font-size: 1.6rem;
  line-height: 1;
}

.modal-kicker {
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.68rem;
  margin: 0 0 0.4rem;
}

.modal-dialog h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}

.modal-tagline {
  margin: 0.35rem 0 1.1rem;
  font-style: italic;
  color: var(--muted);
}

.mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-btn {
  flex: 1;
  padding: 0.65rem 0.6rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-btn.is-active {
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: transparent;
}

.stage-wrap {
  display: grid;
  gap: 0.8rem;
  justify-items: center;
}

.stage {
  width: 100%;
  height: 240px;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 12%, rgba(244, 228, 166, 0.22), transparent 42%),
    radial-gradient(ellipse at 50% 100%, rgba(26, 11, 40, 0.9), #0c0814 70%),
    linear-gradient(180deg, #241433, #0c0814 70%);
  position: relative;
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0 12% 38%;
  background: radial-gradient(ellipse at 50% 0%, rgba(244, 228, 166, 0.18), transparent 70%);
  pointer-events: none;
}

.replay {
  justify-self: center;
}

.secret-panel {
  margin-top: 1.2rem;
  display: grid;
  gap: 1rem;
}

.secret-panel[hidden] {
  display: none;
}

.secret-panel h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.4rem;
}

.secret-panel ul,
.secret-panel ol {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--cream);
}

.secret-panel li + li {
  margin-top: 0.45rem;
}

.tip {
  margin: 0;
  padding: 0.9rem 1rem;
  border-left: 2px solid var(--gold);
  background: rgba(212, 175, 55, 0.06);
  font-style: italic;
  color: var(--gold-soft);
}

/* ---------- demo primitives ---------- */
.demo {
  position: absolute;
  inset: 0;
}

.coin {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff3c4, #d4af37 45%, #8a6a1a);
  box-shadow: inset 0 0 0 2px rgba(255, 246, 210, 0.35), 0 6px 12px rgba(0, 0, 0, 0.4);
  position: absolute;
}

.hand {
  width: 58px;
  height: 70px;
  border-radius: 28px 28px 22px 22px;
  background: linear-gradient(180deg, #e8c2a8, #c48a6a);
  position: absolute;
  bottom: 38px;
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.35);
}

.hand::after {
  content: "";
  position: absolute;
  top: -18px;
  left: 10px;
  width: 38px;
  height: 28px;
  border-radius: 18px;
  background: inherit;
}

.card-face {
  width: 46px;
  height: 66px;
  border-radius: 4px;
  background: #f7efe0;
  color: #1a0b12;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  position: absolute;
}

.felt {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 22px;
  height: 54px;
  border-radius: 4px 4px 10px 10px;
  background:
    linear-gradient(180deg, #3a1d58 0%, #241034 40%, #1a0b28 100%);
  box-shadow:
    inset 0 2px 0 rgba(244, 228, 166, 0.12),
    0 14px 20px rgba(0, 0, 0, 0.35);
}

/* French drop */
.demo-french-drop .hand-left { left: 28%; }
.demo-french-drop .hand-right { right: 28%; }
.demo-french-drop .coin { right: calc(28% + 8px); bottom: 78px; }
.demo-french-drop.is-playing .hand-left { animation: fd-left 3.2s var(--ease) both; }
.demo-french-drop.is-playing .coin { animation: fd-coin 3.2s var(--ease) both; }
.demo-french-drop.is-playing .poof { animation: poof 3.2s ease both; }

.poof {
  position: absolute;
  left: 32%;
  bottom: 90px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), transparent 70%);
  opacity: 0;
}

/* Jumping band */
.fingers {
  position: absolute;
  left: 50%;
  bottom: 40px;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}

.finger {
  display: block;
  width: 14px;
  height: 70px;
  border-radius: 8px;
  background: linear-gradient(180deg, #e8c2a8, #c48a6a);
}

.band {
  position: absolute;
  left: 50%;
  width: 48px;
  height: 10px;
  margin-left: -24px;
  border: 3px solid #c41e3a;
  border-radius: 8px;
  bottom: 88px;
}

.demo-jumping-band.is-playing .band { animation: jump-band 2.4s ease-in-out both; }
.demo-jumping-band.is-playing .fingers { animation: fist 2.4s ease-in-out both; }

/* Rubber pencil */
.pencil {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 180px;
  height: 10px;
  margin-left: -90px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f3c98a, #e2b36a 80%, #c41e3a 80%, #f5e6c8 92%);
  transform-origin: 30% 50%;
}

.demo-rubber-pencil.is-playing .pencil { animation: wobble 1.6s ease-in-out infinite; }

/* Cross cut */
.deck {
  position: absolute;
  width: 70px;
  height: 96px;
  border-radius: 6px;
  background: linear-gradient(160deg, #3b1d5c, #12081c);
  border: 2px solid var(--gold-dim);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.4);
}

.demo-cross-cut .deck-a { left: 28%; top: 28%; }
.demo-cross-cut .deck-b { right: 28%; top: 28%; }
.demo-cross-cut .pred {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: var(--gold-soft);
  opacity: 0;
}
.demo-cross-cut.is-playing .deck-b { animation: cross 2.8s var(--ease) both; }
.demo-cross-cut.is-playing .pred { animation: fade-late 2.8s ease both; }
.demo-cross-cut.is-playing .reveal-card { animation: flip-card 2.8s ease both; }

.reveal-card {
  position: absolute;
  left: 50%;
  top: 34%;
  margin-left: -23px;
  opacity: 0;
  color: var(--rose);
}

/* Coin through table */
.table-top {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 42%;
  height: 18px;
  background: linear-gradient(180deg, #5a3a22, #2a160c);
  border-radius: 4px;
  box-shadow: 0 18px 0 #1a0d08;
}

.demo-coin-table .coin { left: 50%; top: 28%; margin-left: -21px; }
.demo-coin-table .under {
  position: absolute;
  left: 50%;
  bottom: 22px;
  width: 48px;
  height: 28px;
  margin-left: -24px;
  border-radius: 16px 16px 10px 10px;
  background: #c48a6a;
}
.demo-coin-table.is-playing .coin { animation: through 2.6s var(--ease) both; }

/* Ambitious card */
.demo-ambitious .pack { left: 50%; top: 38%; margin-left: -35px; }
.demo-ambitious .amb-card { left: 50%; top: 18%; margin-left: -23px; color: var(--rose); }
.demo-ambitious.is-playing .amb-card { animation: ambitious 3s var(--ease) both; }

/* Enchanted ring */
.ring {
  position: absolute;
  left: 28%;
  top: 38%;
  width: 36px;
  height: 36px;
  border: 5px solid var(--gold);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #8a6a1a;
}

.elastic {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 48%;
  height: 6px;
  border-radius: 4px;
  background: #c41e3a;
}

.demo-enchanted-ring.is-playing .ring { animation: onto-band 2.4s var(--ease) both; }

/* Four aces */
.ace-row {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.ace-row .card-face { position: relative; left: auto; }
.demo-four-aces.is-playing .card-face { animation: ace-flip 2.4s ease both; }
.demo-four-aces.is-playing .card-face:nth-child(2) { animation-delay: 0.15s; }
.demo-four-aces.is-playing .card-face:nth-child(3) { animation-delay: 0.3s; }
.demo-four-aces.is-playing .card-face:nth-child(4) { animation-delay: 0.45s; }

/* Torn restored */
.piece {
  position: absolute;
  width: 28px;
  height: 36px;
  background: #f7efe0;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
}
.demo-torn-restored .p1 { left: 30%; top: 30%; }
.demo-torn-restored .p2 { left: 42%; top: 28%; }
.demo-torn-restored .p3 { left: 36%; top: 48%; }
.demo-torn-restored .p4 { left: 48%; top: 46%; }
.demo-torn-restored .whole {
  left: 50%;
  top: 32%;
  margin-left: -23px;
  opacity: 0;
  color: var(--rose);
}
.demo-torn-restored.is-playing .p1 { animation: gather1 2.8s ease both; }
.demo-torn-restored.is-playing .p2 { animation: gather2 2.8s ease both; }
.demo-torn-restored.is-playing .p3 { animation: gather3 2.8s ease both; }
.demo-torn-restored.is-playing .p4 { animation: gather4 2.8s ease both; }
.demo-torn-restored.is-playing .whole { animation: restore 2.8s ease both; }

/* Matrix */
.mx-coin { width: 28px; height: 28px; }
.demo-matrix .c-tl { left: 18%; top: 22%; }
.demo-matrix .c-tr { left: 72%; top: 22%; }
.demo-matrix .c-bl { left: 18%; top: 64%; }
.demo-matrix .c-br { left: 72%; top: 64%; }
.mini-card {
  width: 38px;
  height: 52px;
  background: #3b1d5c;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  position: absolute;
  opacity: 0.85;
}
.demo-matrix .k-tl { left: 16%; top: 16%; }
.demo-matrix .k-tr { right: 16%; top: 16%; }
.demo-matrix .k-bl { left: 16%; bottom: 22%; }
.demo-matrix .k-br { right: 16%; bottom: 22%; }
.demo-matrix.is-playing .c-tl { animation: mx1 3.4s var(--ease) both; }
.demo-matrix.is-playing .c-tr { animation: mx2 3.4s var(--ease) both; }
.demo-matrix.is-playing .c-bl { animation: mx3 3.4s var(--ease) both; }

.secret .stage::after {
  content: "";
  position: absolute;
  inset: auto 8px 8px auto;
  font-size: 0.7rem;
}

/* icons */
.icon-svg { width: 100%; height: 100%; }

@keyframes foil {
  to { background-position: 220% center; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes floaty {
  50% { transform: translateY(-14px) rotate(8deg); }
}

@keyframes twinkle {
  50% { opacity: 0.35; transform: scale(0.85) rotate(20deg); }
}

@keyframes wand {
  0%, 100% { opacity: 0; transform: scaleY(0.4); }
  50% { opacity: 1; transform: scaleY(1); }
}

@keyframes sheen {
  0% { transform: translateX(0) rotate(18deg); }
  60%, 100% { transform: translateX(420%) rotate(18deg); }
}

@keyframes curtain {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes fd-left {
  0% { transform: translateX(0); }
  30% { transform: translateX(70px); }
  55% { transform: translateX(70px); }
  100% { transform: translateX(0); }
}

@keyframes fd-coin {
  0%, 28% { opacity: 1; transform: translate(0, 0); }
  40% { opacity: 1; transform: translate(-10px, 18px); }
  50%, 100% { opacity: 0; transform: translate(-8px, 28px); }
}

@keyframes poof {
  0%, 55% { opacity: 0; transform: scale(0.4); }
  70% { opacity: 1; transform: scale(2.2); }
  100% { opacity: 0; transform: scale(3); }
}

@keyframes jump-band {
  0%, 35% { bottom: 88px; width: 48px; margin-left: -24px; }
  50% { bottom: 70px; width: 78px; margin-left: -39px; }
  70%, 100% { bottom: 52px; width: 48px; margin-left: -24px; }
}

@keyframes fist {
  40%, 55% { transform: translateX(-50%) scaleY(0.86); }
  70%, 100% { transform: translateX(-50%) scaleY(1); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg) scaleY(1); }
  25% { transform: rotate(9deg) scaleY(0.86); }
  75% { transform: rotate(-9deg) scaleY(0.86); }
}

@keyframes cross {
  0% { transform: translate(0, 0) rotate(0); }
  40% { transform: translate(-18px, 38px) rotate(-8deg); }
  100% { transform: translate(-86px, 18px) rotate(-90deg); }
}

@keyframes fade-late {
  0%, 60% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes flip-card {
  0%, 55% { opacity: 0; transform: rotateY(90deg); }
  100% { opacity: 1; transform: none; }
}

@keyframes through {
  0% { top: 28%; opacity: 1; }
  35% { top: 38%; }
  50% { top: 46%; opacity: 0; }
  70% { top: 70%; opacity: 0; }
  100% { top: 68%; opacity: 1; }
}

@keyframes ambitious {
  0% { top: 18%; opacity: 1; }
  25% { top: 52%; opacity: 0.2; }
  50% { top: 58%; opacity: 0; }
  75% { top: 22%; opacity: 0; }
  100% { top: 18%; opacity: 1; }
}

@keyframes onto-band {
  0% { left: 22%; top: 22%; }
  55% { left: 46%; top: 38%; }
  100% { left: 46%; top: 42%; transform: translateX(-50%); }
}

@keyframes ace-flip {
  0% { transform: rotateY(90deg); filter: brightness(0.4); }
  100% { transform: none; filter: none; }
}

@keyframes gather1 { 70%, 100% { opacity: 0; left: 46%; top: 38%; } }
@keyframes gather2 { 70%, 100% { opacity: 0; left: 46%; top: 38%; } }
@keyframes gather3 { 70%, 100% { opacity: 0; left: 46%; top: 38%; } }
@keyframes gather4 { 70%, 100% { opacity: 0; left: 46%; top: 38%; } }

@keyframes restore {
  0%, 62% { opacity: 0; transform: scale(0.6) rotate(-8deg); }
  100% { opacity: 1; transform: none; }
}

@keyframes mx1 {
  0%, 20% { left: 18%; top: 22%; opacity: 1; }
  38% { opacity: 0; }
  100% { left: 72%; top: 64%; opacity: 1; }
}

@keyframes mx2 {
  0%, 40% { left: 72%; top: 22%; opacity: 1; }
  58% { opacity: 0; }
  100% { left: 72%; top: 64%; opacity: 1; }
}

@keyframes mx3 {
  0%, 62% { left: 18%; top: 64%; opacity: 1; }
  78% { opacity: 0; }
  100% { left: 72%; top: 64%; opacity: 1; }
}

@media (max-width: 860px) {
  .site-header {
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .site-nav {
    display: flex;
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 1.1rem;
    font-size: 0.62rem;
  }

  .level-portals,
  .trick-grid { grid-template-columns: 1fr; }

  .hero { min-height: auto; padding-top: 5rem; }

  .float-hat,
  .c3,
  .c4 { display: none; }

  .hero-title { font-size: clamp(2.4rem, 16vw, 4.2rem); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal { opacity: 1; transform: none; }
  .gold-foil {
    color: var(--gold-soft);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
  }
}
