:root {
  --night: #1a1030;
  --night-2: #3b1f5c;
  --ink: #fff7ea;
  --muted: #d8c9f0;
  --gold: #ffd23f;
  --pink: #ff5d8f;
  --blue: #4cc9f0;
  --shadow: #2b1240;
  --mx: 0; /* pointer position, -1..1, set by home.js */
  --my: 0;
}

* { box-sizing: border-box; }

html { background: var(--night); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(255, 140, 60, 0.35), transparent 70%),
    linear-gradient(180deg, var(--night) 0%, var(--night-2) 70%, #6b2d5c 100%);
  overflow-x: hidden;
}

#sky {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}

/* A glowing grid floor that rolls toward you. */
.floor {
  position: fixed; left: -50%; right: -50%; bottom: -10vh; height: 55vh;
  z-index: 0; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255, 180, 90, 0.5) 0 2px, transparent 2px 80px),
    repeating-linear-gradient(0deg, rgba(255, 180, 90, 0.5) 0 2px, transparent 2px 80px);
  transform: perspective(500px) rotateX(70deg);
  transform-origin: 50% 0;
  mask-image: linear-gradient(transparent, #000 40%);
  -webkit-mask-image: linear-gradient(transparent, #000 40%);
  animation: roll 2.5s linear infinite;
}

@keyframes roll { to { background-position: 0 80px, 0 80px; } }

.stage {
  position: relative; z-index: 1;
  max-width: 1080px; margin: 0 auto; padding: 0 16px 48px;
  perspective: 1200px;
}

/* ---------- hero ---------- */
.hero {
  text-align: center;
  padding: clamp(40px, 9vh, 96px) 0 32px;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--my) * -8deg)) rotateY(calc(var(--mx) * 12deg));
  transition: transform 0.2s ease-out;
}

.wordmark {
  margin: 0;
  font-size: clamp(3.6rem, 15vw, 9rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  transform-style: preserve-3d;
}

.wordmark span {
  display: inline-block;
  color: var(--c);
  /* Stacked shadows make chunky extruded letters. */
  text-shadow:
    1px 1px 0 var(--d), 2px 2px 0 var(--d), 3px 3px 0 var(--d), 4px 4px 0 var(--d),
    5px 5px 0 var(--d), 6px 6px 0 var(--d), 7px 7px 0 var(--d), 8px 8px 0 var(--d),
    9px 9px 0 var(--shadow), 10px 10px 0 var(--shadow),
    14px 18px 24px rgba(0, 0, 0, 0.5);
  animation: dropIn 0.9s cubic-bezier(0.2, 1.6, 0.4, 1) backwards, bob 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 90ms), calc(0.9s + var(--i) * 150ms);
}

.wordmark span:nth-child(1) { --i: 0; --c: #ff5d8f; --d: #b8335f; }
.wordmark span:nth-child(2) { --i: 1; --c: #ffd23f; --d: #c99a12; }
.wordmark span:nth-child(3) { --i: 2; --c: #4cc9f0; --d: #2286a8; }
.wordmark span:nth-child(4) { --i: 3; --c: #7bd389; --d: #3f9a4f; }
.wordmark span:nth-child(5) { --i: 4; --c: #b388ff; --d: #7449c4; }
.wordmark span:nth-child(6) { --i: 5; --c: #ff9f1c; --d: #c06c00; }
.wordmark span:nth-child(7) { --i: 6; --c: #ff5d8f; --d: #b8335f; }

@keyframes dropIn {
  from { transform: translate3d(0, -120px, 300px) rotateX(-90deg); opacity: 0; }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-10px) rotate(-3deg); }
}

.tagline {
  margin: 20px 0 28px;
  font-size: clamp(1.15rem, 3.2vw, 1.6rem);
  color: var(--muted);
  transform: translateZ(40px);
}

/* A chunky arcade button that presses down. */
.cta {
  display: inline-block;
  text-decoration: none;
  border-radius: 999px;
  background: #b8335f;
  padding-bottom: 8px;
  transform: translateZ(70px);
  transition: padding 0.08s, transform 0.08s;
}
.cta-face {
  display: block;
  padding: 16px 34px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff86ad, var(--pink));
  color: #fff;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: bold;
  border: 3px solid #fff3;
}
.cta:hover .cta-face, .cta:focus-visible .cta-face { filter: brightness(1.1); }
.cta:active { padding-bottom: 2px; transform: translateZ(70px) translateY(6px); }
.cta:focus-visible { outline: 4px solid var(--gold); outline-offset: 6px; }
.ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; transform-style: preserve-3d; }
.cta.join { background: #2286a8; }
.cta.join .cta-face { background: linear-gradient(180deg, #7fdcff, var(--blue)); }
.cta.keys { background: #c99a12; }
.cta.keys .cta-face { background: linear-gradient(180deg, #ffe68a, var(--gold)); color: #2b1240; }

/* ---------- cards ---------- */
.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
  padding-top: 16px;
}

.card {
  position: relative;
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 28px;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: rise 0.8s cubic-bezier(0.2, 1.2, 0.4, 1) backwards;
}
.card:nth-child(1) { animation-delay: 0.5s; }
.card:nth-child(2) { animation-delay: 0.65s; }
.card:nth-child(3) { animation-delay: 0.8s; }
.card:nth-child(4) { animation-delay: 0.95s; }
.card.tilting { transition: transform 0.08s linear; }

@keyframes rise {
  from { transform: translateY(80px) rotateX(40deg); opacity: 0; }
}

.card-inner {
  position: relative;
  height: 100%;
  padding: 26px 24px 24px;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.2),
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    0 0 50px -10px var(--glow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform-style: preserve-3d;
}

.card h2 { margin: 18px 0 8px; font-size: 1.7rem; transform: translateZ(40px); }
.card p { margin: 0 0 16px; color: var(--muted); line-height: 1.45; transform: translateZ(25px); }

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glow);
  color: var(--glow);
  font-size: 0.85rem;
  font-weight: bold;
  transform: translateZ(30px);
}

.card-art {
  height: 110px;
  display: grid;
  place-items: center;
  font-size: 4.5rem;
  transform: translateZ(80px);
  filter: drop-shadow(0 18px 12px rgba(0, 0, 0, 0.45));
}

.card-art.float { animation: floaty 3s ease-in-out infinite; }
.card-art.spin { animation: turn 6s linear infinite; }

/* A little pan that flips a real, flat pancake in 3D. */
.card-art.flip {
  perspective: 520px;
  filter: none; /* a filter would flatten the 3D scene */
}
.pan3d {
  position: relative;
  width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #5a5a6b 0 55%, #2b2b36 58%);
  border: 9px solid var(--glow);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 26px 22px rgba(0, 0, 0, 0.45);
  transform: rotateX(62deg);
  transform-style: preserve-3d;
}
.cake-shadow {
  position: absolute; inset: 20%; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); filter: blur(5px);
  animation: cakeShadow 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.cake3d {
  position: absolute; inset: 14%;
  transform-style: preserve-3d;
  animation: flip 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.cake3d > div { position: absolute; inset: 0; border-radius: 50%; }
.cake3d .side { backface-visibility: hidden; }
.cake3d .top {
  transform: translateZ(4px);
  background: radial-gradient(circle at 42% 38%, #ffe199 0 12%, #f6c46b 40%, #d9963c 78%, #a8681f 100%);
  box-shadow: inset 0 0 0 2px rgba(120, 70, 20, 0.6);
}
.cake3d .top::after { /* butter pat */
  content: ''; position: absolute; left: 39%; top: 39%; width: 22%; height: 22%;
  border-radius: 4px; background: #fff3a8; box-shadow: 0 0 0 2px rgba(150, 110, 20, 0.5);
  transform: rotate(18deg);
}
.cake3d .bottom {
  transform: rotateX(180deg) translateZ(4px);
  background: radial-gradient(circle at 50% 50%, #c98633 0 30%, #e3a855 60%, #f3cc80 100%);
}
.cake3d .edge { background: #b8762c; }
.cake3d .e1 { transform: translateZ(2px); }
.cake3d .e2 { transform: translateZ(0); }
.cake3d .e3 { transform: translateZ(-2px); background: #9a5f20; }

/* Rest in the pan, leap up while turning over, land flat in the middle. */
@keyframes flip {
  0%, 18% { transform: translateZ(2px) rotateX(0deg); }
  50% { transform: translateZ(90px) rotateX(180deg); }
  80% { transform: translateZ(2px) rotateX(360deg); }
  86% { transform: translateZ(2px) rotateX(360deg) scale(1.06); }
  92%, 100% { transform: translateZ(2px) rotateX(360deg) scale(1); }
}
@keyframes cakeShadow {
  0%, 18%, 80%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(0.55); opacity: 0.18; }
}
@keyframes floaty { 50% { transform: translateZ(80px) translateY(-14px) rotate(6deg); } }
@keyframes turn { to { transform: translateZ(80px) rotateY(360deg); } }

.glare {
  position: absolute; inset: 0; border-radius: 28px; pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, 0.35), transparent 55%);
  opacity: 0; transition: opacity 0.3s;
  transform: translateZ(1px);
}
.card:hover .glare, .card:focus-visible .glare { opacity: 1; }

.card:focus-visible { outline: 4px solid var(--gold); outline-offset: 6px; }
.card.soon { cursor: default; }
.card.soon .card-inner { border-style: dashed; }

footer {
  position: relative; z-index: 1;
  text-align: center; padding: 24px 16px 32px; color: var(--muted); font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .hero, .card { transform: none !important; }
}

@media (max-width: 600px) {
  .wordmark { letter-spacing: 0.06em; }
}

/* ---------- party home ---------- */
.joinbox {
  margin: 8px auto 18px; max-width: 520px; padding: 16px 18px 6px; border-radius: 26px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  border: 2px solid rgba(255, 255, 255, 0.3); box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transform: translateZ(60px);
}
.joinbox label { display: block; font-size: 1.3rem; font-weight: bold; margin-bottom: 10px; }
.joinrow { display: flex; gap: 12px; align-items: flex-start; }
.joinrow input {
  flex: 1; min-width: 0; font: inherit; font-size: clamp(2rem, 7vw, 2.8rem); font-weight: 900; letter-spacing: 0.3em;
  text-align: center; text-transform: uppercase; padding: 6px 0 6px 0.3em; border-radius: 18px;
  border: 4px solid #fff; background: rgba(255, 255, 255, 0.95); color: #2b1240;
}
.joinrow input:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.joinrow .cta { border: 0; padding: 0 0 8px; font: inherit; cursor: pointer; transform: none; }
.joinrow .cta .cta-face { padding: 14px 24px; }
.joinerr { min-height: 1.3em; margin: 6px 0; color: #ffd0dc; font-weight: bold; }
.cta.lead { background: #c99a12; }
.cta.lead .cta-face { background: linear-gradient(180deg, #ffe68a, var(--gold)); color: #2b1240; }
.howto { color: var(--muted); max-width: 520px; margin: 18px auto 0; font-size: 1.05rem; transform: translateZ(30px); }
.section-title { position: relative; z-index: 1; text-align: center; font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 8px 0 4px; }
.hero.small { padding-top: 24px; }
.hero.small .wordmark { font-size: clamp(2.8rem, 10vw, 5.4rem); }
.back { position: absolute; left: 0; top: 18px; color: var(--muted); font-weight: bold; text-decoration: none; }
.back:hover, .back:focus-visible { color: var(--ink); }
/* Hold the hero still while someone types a party code. */
.hero:focus-within { transform: none; }
