:root {
  color-scheme: dark;

  --ink: #f4f1ea;
  --dim: #9aa0ad;
  --faint: #5b616e;

  --felt-0: #05070a;
  --felt-1: #0b0f15;
  --felt-2: #11161f;

  --gold: #d9b676;
  --gold-deep: #9c7b3f;
  --red: #c8302b;       /* hearts / diamonds */
  --black: #14171d;     /* spades / clubs ink on the card */

  --card-paper: #f7f3e9;
  --card-paper-2: #efe7d4;
  --card-line: #d8cdb4;
  --card-ink: #1c1f25;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* one card unit; everything scales off this */
  --cw: clamp(264px, 24vw, 348px);
  --ch: calc(var(--cw) * 1.4);
  --radius: clamp(12px, 1.4vw, 20px);

  --card-shadow: 0 26px 40px -10px rgba(0, 0, 0, 0.62);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 18%, var(--felt-2) 0%, var(--felt-1) 42%, var(--felt-0) 100%),
    var(--felt-0);
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ============================================================= STAGE ===== */
.stage {
  position: relative;
  height: 100svh;
  width: 100%;
  overflow: hidden;
  perspective: 1600px;
  perspective-origin: 50% 42%;
}

.stage__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 55% at 50% 44%, rgba(217, 182, 118, 0.05), transparent 70%),
    radial-gradient(130% 120% at 50% 50%, transparent 48%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 2;
}

/* The intro copy lives over the resting deck */
.intro {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: clamp(40px, 9vh, 96px);
  text-align: center;
  pointer-events: none;
  will-change: opacity, transform;
}

.intro__kicker {
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
}

.intro__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.9rem, 5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
}

.intro__sub {
  margin: 18px 0 0;
  color: var(--dim);
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
}

.intro__hint {
  margin: 26px 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}

.intro__arrow {
  display: inline-block;
  margin-left: 4px;
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(5px); opacity: 1; }
}

/* HUD: which card you're on */
.hud {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 4vh, 40px);
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hud.is-on { opacity: 1; }

.hud__count { font-size: 0.82rem; letter-spacing: 0.1em; color: var(--dim); }
.hud__count b { color: var(--gold); }
.hud__name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
}
.hud__bar {
  width: min(260px, 60vw);
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.hud__bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}

/* The deck holds every card, absolutely centred; JS drives the transforms */
.deck {
  position: absolute;
  inset: 0;
  z-index: 10;
  transform-style: preserve-3d;
}

/* ===================================================== PLAYING CARD ====== */
.pc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cw);
  height: var(--ch);
  margin-left: calc(var(--cw) / -2);
  margin-top: calc(var(--ch) / -2);
  transform-style: preserve-3d;
  will-change: transform;
}

.pc__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}

.pc__face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

/* ---- the back of every card (ornate) ---- */
.pc__back {
  background-color: #0d1530;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(217, 182, 118, 0.14), transparent 58%),
    repeating-linear-gradient(45deg, rgba(217, 182, 118, 0.10) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(217, 182, 118, 0.10) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #11203f, #0a1124 60%, #070b18);
  background-size: cover;
  border: 1px solid rgba(217, 182, 118, 0.35);
  /* inset bevel + a real cast shadow (shadow on the face, NOT the 3D-preserving .pc) */
  box-shadow: inset 0 0 0 6px rgba(7, 11, 24, 0.9), inset 0 0 0 7px rgba(217, 182, 118, 0.28), var(--card-shadow);
}

/* when the generated art is available, JS sets --back-img and adds .has-art */
.pc__back.has-art {
  background-image: var(--back-img);
  background-size: cover;
  background-position: center;
}

.pc__back::after {
  content: "H";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 800;
  font-size: calc(var(--cw) * 0.34);
  color: rgba(217, 182, 118, 0.5);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.pc__back.has-art::after { content: none; }

/* ---- the face of every card ---- */
.pc__front {
  transform: rotateY(180deg);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--card-paper), var(--card-paper-2) 70%, #e7ddc7 100%);
  color: var(--card-ink);
  border: 1px solid var(--card-line);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6), inset 0 0 0 3px var(--card-line), var(--card-shadow);
  padding: clamp(12px, 1.4vw, 18px);
  display: flex;
  flex-direction: column;
}

.pc[data-color="red"] { --pip: var(--red); }
.pc[data-color="black"] { --pip: var(--black); }
.pc[data-color="gold"] { --pip: var(--gold-deep); }

/* corner index (rank + suit), mirrored bottom-right */
.pc__index {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.84;
  color: var(--pip);
  font-family: var(--serif);
  z-index: 3;
}
.pc__index b { font-size: clamp(1rem, 1.7vw, 1.5rem); font-weight: 700; }
.pc__index i { font-style: normal; font-size: clamp(0.85rem, 1.4vw, 1.2rem); margin-top: 2px; }
.pc__index--tl { top: clamp(8px, 1vw, 12px); left: clamp(8px, 1vw, 12px); }
.pc__index--br { bottom: clamp(8px, 1vw, 12px); right: clamp(8px, 1vw, 12px); transform: rotate(180deg); }

/* big faded suit watermark behind the content */
.pc__watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--cw) * 0.62);
  color: var(--pip);
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

.pc__content {
  position: relative;
  z-index: 2;
  margin: auto clamp(6px, 1vw, 12px);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 0.9vw, 10px);
}

.pc__kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.pc__title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.3vw, 1.85rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.pc__status {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a7438;
}
.pc__status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #caa24a;
  box-shadow: 0 0 0 0 rgba(202, 162, 74, 0.6);
  animation: pulse 1.9s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(202, 162, 74, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(202, 162, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(202, 162, 74, 0); }
}

.pc__tagline {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.82rem, 1.15vw, 0.98rem);
  color: #5a4a2c;
}

.pc__desc {
  margin: 2px 0 0;
  font-size: clamp(0.72rem, 0.95vw, 0.82rem);
  line-height: 1.5;
  color: #3c4048;
}

.pc__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 2px;
}
.pc__tags span {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--card-line);
  background: rgba(0, 0, 0, 0.03);
  color: #5d5340;
  white-space: nowrap;
}

.pc__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: clamp(6px, 1vw, 10px);
}
.pc__btn {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--card-ink);
  color: var(--card-ink);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.pc__btn:hover { transform: translateY(-1px); }
.pc__btn--solid { background: var(--card-ink); color: var(--card-paper); }
.pc__btn--solid:hover { background: #000; }

/* the joker is special */
.pc[data-suit="joker"] .pc__front {
  background:
    radial-gradient(120% 100% at 50% 0%, #1a1410, #120d09 70%, #0c0805 100%);
  color: var(--card-paper);
  border-color: var(--gold-deep);
  box-shadow: inset 0 0 0 2px rgba(217, 182, 118, 0.25), inset 0 0 0 3px rgba(217, 182, 118, 0.5), var(--card-shadow);
}
.pc[data-suit="joker"] .pc__index { color: var(--gold); }
.pc[data-suit="joker"] .pc__index b { font-size: clamp(0.62rem, 1vw, 0.78rem); letter-spacing: 0.1em; }
.pc[data-suit="joker"] .pc__index i { display: none; }
.pc[data-suit="joker"] .pc__title { color: var(--gold); }
.pc[data-suit="joker"] .pc__tagline { color: #d9cdb0; }
.pc[data-suit="joker"] .pc__desc { color: #cdc6ba; }
.pc[data-suit="joker"] .pc__tags span { border-color: rgba(217,182,118,0.3); color: #d9cdb0; background: rgba(217,182,118,0.06); }
.pc[data-suit="joker"] .pc__btn { border-color: var(--gold); color: var(--gold); }
.pc[data-suit="joker"] .pc__btn--solid { background: var(--gold); color: #15100a; }
.pc[data-suit="joker"] .pc__watermark { color: var(--gold); opacity: 0.08; }
.pc[data-suit="joker"] .pc__kicker { color: var(--gold); }
/* the joker carries the most content (it has the duel) — tighten it so nothing clips */
.pc[data-suit="joker"] .pc__content { gap: clamp(4px, 0.7vw, 8px); }
.pc[data-suit="joker"] .pc__desc { font-size: clamp(0.68rem, 0.85vw, 0.78rem); }

/* inline typing duel on the joker */
.duel { margin-top: 4px; }
.duel__target {
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1.45;
  color: #d9cdb0;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(217,182,118,0.2);
  border-radius: 8px;
  padding: 6px 8px;
  margin: 0 0 6px;
}
.duel__input {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--gold);
  background: transparent;
  border: 1px dashed rgba(217,182,118,0.4);
  border-radius: 8px;
  padding: 6px 8px;
  outline: none;
}
.duel__input::placeholder { color: rgba(217,182,118,0.5); }
.duel__result { margin: 6px 0 0; font-family: var(--mono); font-size: 0.62rem; min-height: 1em; color: var(--gold); }

/* ===================================================== FALLBACK HAND ===== */
/* By default (no JS, before the mode is chosen) the stage with its real intro
   heading shows — never a blank page. JS picks deck vs static mode. */
.fallback { display: none; }
body.deck-mode .fallback { display: none !important; }
body.deck-mode .pc { cursor: pointer; }
body.static-mode .stage { display: none; }
body.static-mode .fallback { display: block; }

.fallback {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(40px, 8vw, 96px) clamp(18px, 5vw, 48px) 40px;
}

.fallback__hero { text-align: center; margin-bottom: clamp(36px, 7vw, 72px); }
.fallback__kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 14px;
}
.fallback__hero h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.9rem, 6vw, 3.2rem);
  line-height: 1.05;
  margin: 0;
}
.fallback__sub { color: var(--dim); max-width: 640px; margin: 16px auto 0; line-height: 1.6; }

.fallback__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(18px, 3vw, 30px);
  align-items: stretch;
}

/* In the fallback we show only the face; cards GROW to fit content (never clip) */
.fallback .pc {
  position: relative;
  left: auto; top: auto;
  margin: 0;
  width: 100%;
  height: auto;
  min-height: 380px;
  display: flex;
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.fallback .pc.in { opacity: 1; transform: none; }
.fallback .pc__inner { transform: none !important; position: relative; flex: 1; display: flex; }
.fallback .pc__back { display: none; }
.fallback .pc__front { transform: none; position: relative; flex: 1; }

/* ===================================================== FOOTER ============ */
.site-foot {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: clamp(40px, 8vh, 90px) 20px 50px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--dim);
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.4));
}
.site-foot a { color: var(--gold); text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
.site-foot__dim { color: var(--faint); margin-top: 8px; }
.site-foot__old { color: var(--faint) !important; }
.site-foot__old:hover { color: var(--gold) !important; }

/* ===================================================== DEMO VIDEO ======== */
.pc__video {
  position: relative;
  display: block;
  width: 100%;
  margin: 2px 0 0;
  padding: 0;
  border: 1px solid var(--card-line);
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0b0f15;
  cursor: pointer;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
}
.pc__video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pc__video-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(12, 14, 20, 0.62);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}
.pc__video-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 53%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #fff;
}
.pc__video:hover .pc__video-play { transform: scale(1.08); background: var(--red); }
.pc__award {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: clamp(0.56rem, 0.72vw, 0.64rem);
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: #8a7438;
}

/* ===================================================== LIGHTBOX ========== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  place-items: center;
  padding: clamp(16px, 4vw, 48px);
}
.lightbox.is-open { display: grid; }
.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 8, 0.88);
  backdrop-filter: blur(4px);
}
.lightbox__panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lightbox__title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.lightbox__video {
  width: 100%;
  max-height: 78vh;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8);
}
.lightbox__close {
  position: absolute;
  top: -38px;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 0.9rem;
  cursor: pointer;
}
.lightbox__close:hover { background: var(--red); border-color: var(--red); }

/* ===================================================== FULL HOUSE ======== */
.deck-end {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translate(-50%, 26px);
  width: min(900px, 92vw);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 360;
}
.deck-end__kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(0.62rem, 0.9vw, 0.74rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}
.deck-end__title {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2.6rem, 8vw, 6rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.5);
}
.deck-end__sub {
  margin: 16px auto 0;
  max-width: 48ch;
  font-size: clamp(0.82rem, 1.1vw, 0.98rem);
  line-height: 1.55;
  color: var(--dim);
}
.deck-end.is-on .deck-end__sub::after {
  content: " Tap any card to magnify it.";
  color: var(--gold);
}

/* ============================================== MAGNIFIED PREVIEW ======== */
.preview {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  place-items: center;
  padding: clamp(16px, 4vw, 56px);
}
.preview.is-open { display: grid; }
.preview__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 8, 0.9);
  backdrop-filter: blur(6px);
}
.preview__stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}
.preview__card { position: relative; z-index: 1; }
.pc.pc--preview {
  position: relative;
  left: auto;
  top: auto;
  margin: 0;
  --cw: min(440px, 84vw);
  cursor: default;
}
.preview__close {
  position: fixed;
  top: clamp(14px, 3vw, 28px);
  right: clamp(14px, 3vw, 28px);
  z-index: 3;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.preview__close:hover { background: var(--red); border-color: var(--red); }

/* ===================================================== BOOK FAB ========= */
/* always-visible booking CTA, pinned top-right; sits above the deck/HUD but
   below the preview (1100) and video lightbox (1200) so those cover it. */
.book-fab {
  position: fixed;
  top: clamp(14px, 3vw, 28px);
  right: clamp(14px, 3vw, 28px);
  z-index: 1000;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: #15100a;
  background: var(--gold);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.book-fab:hover {
  background: #e7c98c;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.book-fab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ===================================================== RESPONSIVE ======== */
@media (max-width: 820px) {
  :root { --cw: clamp(240px, 72vw, 320px); }
  .book-fab { font-size: 0.62rem; padding: 8px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .intro__arrow { animation: none; }
  .pc__status i { animation: none; }
  .fallback .pc { transition: none; opacity: 1; transform: none; }
}
