:root {
  --bg: #0A0C10;
  --ink: #F0F6FC;
  --muted: #8B949E;
  --line: #30363D;
  --zzz: #38BDF8;
  --sp: #A855F7;
  --ap: #2DD4BF;
  --out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* sized from the window: the cards sit in the middle of the screen at about
     60% of its height, never larger than 640 px tall, with the title above */
  --pad: 24px;
  --F: clamp(32px, 5.2svh, 60px);                   /* title size */
  --gap: clamp(20px, 3.6svh, 44px);                 /* title to cards */
  --cgap: clamp(16px, 2vw, 32px);                   /* between cards */
  --card-h: min(60svh, 640px, calc((100vw - 48px - 2 * var(--cgap)) / 3 * 462 / 260));
  --card-w: calc(var(--card-h) * 260 / 462);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(56, 189, 248, 0.05), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.defs { position: absolute; width: 0; height: 0; }

/* ---------- layout ---------- */
/* three rows: the cards own the middle row, so they are centred in the window,
   and the title sits at the bottom of the top row, just above them */
.hub {
  min-height: 100svh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  padding: var(--pad) 24px;
}
.hub > .hero { align-self: end; margin-bottom: var(--gap); }
.hub > .cards { grid-row: 2; }
.hub > .foot { grid-row: 3; align-self: end; }

/* ---------- footer: legal links and fan-site notice ---------- */
.foot {
  width: 100%;
  max-width: 760px;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(48, 54, 61, 0.7);       /* the hairline divider above the links */
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: #6E7681;
}
.foot-links {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.foot-links a { color: #C9D1D9; text-decoration: none; transition: color 150ms ease; }
.foot-links a:hover, .foot-links a:focus-visible { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.foot-note { margin: 0; text-wrap: balance; }
/* wide screens: the notice runs on one line, shrinking a touch to fit (about 1300 px at 11 px) */
@media (min-width: 1100px) {
  .foot { max-width: none; width: 95%; }
  .foot-note { white-space: nowrap; font-size: min(11px, calc((100vw - 56px) * 11 / 1300)); }
}

/* ---------- hero: word + three game dots ---------- */
.hero { display: flex; align-items: center; gap: calc(var(--F) * 0.28); }
.word {
  margin: 0;
  font-size: var(--F);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(12px);
  animation: word-in 500ms var(--out-expo) forwards;
}
.dots { display: flex; gap: calc(var(--F) * 0.16); padding-top: 0.12em; font-size: var(--F); }
.dot {
  width: 0.21em; height: 0.21em; border-radius: 50%;
  opacity: 0;
  transform: translateY(-40px);
  animation: dot-in 420ms var(--spring) forwards;
  transition: transform 260ms var(--spring), opacity 260ms ease, box-shadow 260ms ease;
}
.dot[data-game="zzz"] { background: var(--zzz); color: var(--zzz); animation-delay: 240ms; }
.dot[data-game="sp"]  { background: var(--sp);  color: var(--sp);  animation-delay: 320ms; }
.dot[data-game="ap"]  { background: var(--ap);  color: var(--ap);  animation-delay: 400ms; }
@keyframes word-in { to { opacity: 1; transform: none; } }
@keyframes dot-in  { to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.cards { display: flex; gap: var(--cgap); justify-content: center; }
.card {
  --accent: var(--zzz);
  --focus: 50%;                                     /* vertical crop focus of the art */
  position: relative;
  display: block;
  width: var(--card-w);
  aspect-ratio: 260 / 462;
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
  color: inherit;
  text-decoration: none;
  outline: none;
  cursor: pointer;
  background: #11141a;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.7);
  opacity: 0;
  animation: card-in 600ms var(--out-expo) forwards;
  transition:
    transform 320ms var(--out-expo),
    opacity 320ms ease,
    border-radius 320ms var(--out-expo),
    box-shadow 320ms ease;
  -webkit-tap-highlight-color: transparent;
}
.card-zzz { --accent: var(--zzz); animation-delay: 300ms; }
.card-sp  { --accent: var(--sp);  animation-delay: 380ms; }
.card-ap  { --accent: var(--ap);  animation-delay: 460ms; }
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
/* after the entrance, transitions take over */
.ready .card { animation: none; opacity: 1; }
.ready .dot { animation: none; opacity: 1; transform: none; }

/* the frame line, drawn above everything inside the card */
.card::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--line);
  pointer-events: none;
  z-index: 20;
  transition: box-shadow 220ms ease;
}

.card.is-active {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.7), 0 0 28px color-mix(in srgb, var(--accent) 45%, transparent);
  transition:
    transform 220ms var(--out-expo),
    opacity 220ms ease,
    border-radius 220ms var(--out-expo),
    box-shadow 220ms ease;
}
.card.is-active::after { box-shadow: inset 0 0 0 2px var(--accent); }
.hub[data-active] .card:not(.is-active) { opacity: 0.55; }
.card:focus-visible::after { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }

/* hovered card's dot grows, the others dim */
.hub[data-active] .dot { opacity: 0.45; }
.hub[data-active="zzz"] .dot[data-game="zzz"],
.hub[data-active="sp"]  .dot[data-game="sp"],
.hub[data-active="ap"]  .dot[data-game="ap"] {
  opacity: 1;
  transform: scale(1.6);
  box-shadow: 0 0 16px currentColor;
}

.art-wrap { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% var(--focus);
  display: block;
  transform-origin: 50% 50%;
  will-change: transform;
}
.shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(10, 12, 16, 0.2) 0%, rgba(10, 12, 16, 0) 60%, rgba(10, 12, 16, 0.75) 100%);
}
.glow {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(100% 35% at 50% 95%, color-mix(in srgb, var(--accent) 45%, transparent), transparent);
  opacity: 0;
  transition: opacity 320ms ease;
}
.card.is-active .glow { opacity: 1; transition-duration: 220ms; }
/* the PSD's per-card gradient fill (game colour to black at 50%), cropped with the art */
.tint {
  position: absolute; inset: 0; pointer-events: none;
  background-size: cover;
  background-position: 50% var(--focus);
}
/* logos are their own layer, placed where the PSD comp has them */
.logo {
  position: absolute;
  z-index: 4;
  height: auto;
  pointer-events: none;
  user-select: none;
}
.card-zzz .logo { left: 18.5%; top: 46.0%; width: 64.0%; }
.card-sp  .logo { left: 6.7%;  top: 44.2%; width: 86.6%; }
.card-ap  .logo { left: 13.6%; top: 40.6%; width: 75.8%; }
.fx {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- coming soon: the card greys out on click ---------- */
.soon {
  position: absolute; inset: 0;
  z-index: 15;
  display: grid; place-items: center;
  pointer-events: none;
  background: rgba(10, 12, 16, 0.35);
  backdrop-filter: grayscale(1) brightness(0.55);
  -webkit-backdrop-filter: grayscale(1) brightness(0.55);
  opacity: 0;
  transition: opacity 260ms ease;
}
.soon span {
  font-size: clamp(14px, calc(var(--card-w) * 0.075), 28px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  transform: translateY(6px);
  transition: transform 260ms var(--out-expo);
}
.card.is-soon .soon { opacity: 1; }
.card.is-soon .soon span { transform: none; }
.card.is-soon { --accent: #6E7681; }

/* ---------- ZZZ: glitchy CRT ---------- */
.card-zzz.is-active { border-radius: 22px; }
.card-zzz .split,
.card-zzz .slice {
  position: absolute; inset: 0;
  background-image: url(/img/art-zzz.webp);
  background-size: cover;
  background-position: 50% var(--focus);
  pointer-events: none;
  opacity: 0;
}
.card-zzz .split { mix-blend-mode: screen; }
.card-zzz .split-r { filter: url(#duo-red); }
.card-zzz .split-b { filter: url(#duo-cyan); }
.card-zzz .slice { clip-path: inset(var(--top) 0 calc(100% - var(--top) - var(--h)) 0); }
.card-zzz.is-active .split { opacity: var(--split-o, 0.35); }
.card-zzz.is-active .split-r { transform: translate(var(--rx, -3px), var(--ry, 0)); }
.card-zzz.is-active .split-b { transform: translate(var(--bx, 3px), var(--by, 0)); }
.card-zzz .crt {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0, rgba(0, 0, 0, 0) 3.5px, rgba(0, 0, 0, 0.5) 7px);
  opacity: 0;
  transition: opacity 220ms ease;
}
.card-zzz.is-active .crt { opacity: 1; }
.card-zzz .roll {
  position: absolute; left: 0; right: 0; top: 0;
  height: 12.6%;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(125, 211, 252, 0), rgba(186, 230, 253, 0.28), rgba(125, 211, 252, 0));
  opacity: 0;
  transform: translateY(-120%);
}
.card-zzz.is-active .roll { opacity: 1; animation: roll 2.6s linear infinite; }
.card-zzz.is-active .roll.jump { animation: none; transform: translateY(var(--roll-y)); }
@keyframes roll { from { transform: translateY(-120%); } to { transform: translateY(800%); } }
.card-zzz .scan {
  position: absolute; left: 0; right: 0; top: -2%;
  height: 4px;
  background: #BAE6FD;
  box-shadow: 0 0 10px 1px rgba(56, 189, 248, 0.9);
  pointer-events: none;
  opacity: 0;
}
.card-zzz.is-active .scan { animation: scan 300ms ease-in-out forwards; }
@keyframes scan { 0% { top: -2%; opacity: 1; } 99% { opacity: 1; } 100% { top: 101%; opacity: 0; } }

/* ---------- Silver Palace: strike flash ---------- */
.card-sp .flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(90% 90% at 50% 40%, rgba(245, 235, 255, 0.7), rgba(168, 85, 247, 0.35) 60%, rgba(168, 85, 247, 0) 100%);
  mix-blend-mode: screen;
  opacity: 0;
}

/* ---------- Azur Promilia: core glow (placed by main.js on the art) ---------- */
.card-ap .core {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(204, 251, 241, 0.75), rgba(45, 212, 191, 0.38) 35%, rgba(13, 148, 136, 0.12) 70%, rgba(13, 148, 136, 0));
  filter: blur(14px);
  mix-blend-mode: screen;
  opacity: 0;
}

/* ---------- phones: three cropped bands that fit one screen ---------- */
@media (max-width: 720px) {
  :root {
    --pad: 16px;
    --F: clamp(30px, 9vw, 40px);
    --gap: 16px;
    --cgap: 12px;
    --band: calc((100svh - 2 * var(--pad) - env(safe-area-inset-top) - env(safe-area-inset-bottom)
                  - 1.3 * var(--F) - var(--gap) - 2 * var(--cgap) - 8px) / 3);
  }
  .hub {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--gap);
    padding: calc(var(--pad) + env(safe-area-inset-top)) 16px calc(var(--pad) + env(safe-area-inset-bottom));
  }
  .hub > .hero { margin: 0; align-self: center; }
  /* the cards fill the first screen; the footer sits just below them */
  .hub > .foot { align-self: center; margin-top: 8px; padding-bottom: 8px; font-size: 11px; }
  .foot-links { font-size: 12px; }
  .cards { flex-direction: column; align-items: center; width: 100%; }
  .card {
    width: min(100%, 520px);
    height: max(120px, var(--band));
    aspect-ratio: auto;
  }
  /* the crop keeps each face in the upper part of the band ... */
  .card-zzz { --focus: 44%; }
  .card-sp  { --focus: 18%; }
  .card-ap  { --focus: 30%; }
  /* ... and the logo sits along the bottom, over a soft dark fade */
  .shade { background: linear-gradient(to bottom, rgba(10, 12, 16, 0) 40%, rgba(10, 12, 16, 0.65) 100%); }
  .card .logo {
    left: 50%; top: auto; bottom: 8%;
    translate: -50% 0;
    width: auto;
    max-width: 70%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
  }
  .card-zzz .logo { height: 34%; }
  .card-sp  .logo { height: 23%; }
  .card-ap  .logo { height: 44%; }
  .card.is-active { transform: scale(1.015); }
  .card-zzz.is-active { border-radius: 16px; }
}

/* ---------- reduced motion: colour and glow only ---------- */
@media (prefers-reduced-motion: reduce) {
  .word, .dot, .card { animation: none !important; opacity: 1; transform: none; }
  .card, .card.is-active, .dot { transition-duration: 150ms !important; }
  .card.is-active { transform: none; }
  .hub[data-active] .dot { transform: none; }
  .card-zzz .roll, .card-zzz .scan, .card-zzz .split, .card-zzz .slice { display: none; }
}
