/* ==========================================================================
   theredwizard.net — design tokens + system
   Rules of the house (docs/dopamine-design-bible.md):
   dark ground + ONE glow + ONE accent per surface; feedback < 100ms;
   no dead frame; nothing changes silently; boldness lives in the wand cursor.
   ========================================================================== */

@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/cinzel-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122, U+FEFF;
}
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/cinzel-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2020, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/orbitron.woff2') format('woff2');
}

:root {
  /* ground */
  --void: #0b0709;
  --bg1: #120b0e;
  --panel: #1a1014;
  --panel2: #221419;
  --line: #3a2129;
  /* accents — one per surface, never mixed */
  --ember: #ff5a36;
  --ember-dim: #8a3420;
  --crimson: #d92b45;
  --gold: #f5c451;
  --aether: #67e8f9;   /* Aether Vanguard card only */
  --torch: #f0a84b;    /* Grimlight card only */
  /* text */
  --text-hi: #f5ecdf;
  --text-mid: #b3989a;
  --text-low: #97747a; /* nudged up from #79595f — WCAG AA needs 4.5:1 on --void at these sizes (was 3.25:1) */
  --ink: #0b0709;
  /* type */
  --display: 'Cinzel', 'Iowan Old Style', Georgia, serif;
  --game: 'Orbitron', 'Arial Narrow', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  /* motion */
  --settle: cubic-bezier(0.215, 0.61, 0.355, 1);        /* Cubic.easeOut */
  --pop: cubic-bezier(0.175, 0.885, 0.32, 1.4);         /* Back.easeOut */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--void);
  color: var(--text-hi);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

::selection { background: var(--ember); color: var(--ink); }

/* ---------- cinematic grade: vignette + living film grain ---------- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1500;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(7, 3, 5, 0.5) 100%);
}
body::before {
  content: '';
  position: fixed;
  inset: -60%;
  z-index: 2500;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.038;
  animation: grain 9s steps(10) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-3%, -2%); }
  20% { transform: translate(2%, -4%); }
  30% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, 2%); }
  50% { transform: translate(-2%, -3%); }
  60% { transform: translate(4%, 1%); }
  70% { transform: translate(-1%, 4%); }
  80% { transform: translate(2%, -2%); }
  90% { transform: translate(-3%, 1%); }
}

/* ---------- scrollbar belongs to the world, not the OS ---------- */
html { scrollbar-width: thin; scrollbar-color: #3a2129 #0b0709; }
::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: #0b0709; }
::-webkit-scrollbar-thumb { background: #3a2129; border-radius: 6px; border: 2px solid #0b0709; }
::-webkit-scrollbar-thumb:hover { background: #8a3420; }

/* On fine pointers the wand IS the cursor (drawn on canvas by wand.js). */
body.wand-active, body.wand-active a, body.wand-active button { cursor: none; }
/* while a spellcast is held, dragging must not select the page */
body.casting { user-select: none; -webkit-user-select: none; }

canvas.fx {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}
#embers { z-index: 0; }
#wand { z-index: 1000; }

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 2; }

/* ---------------- nav ---------------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(to bottom, rgba(11, 7, 9, 0.92), rgba(11, 7, 9, 0));
}
.nav.scrolled {
  background: color-mix(in srgb, var(--void) 78%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  transition: background 300ms var(--settle);
}
.nav .mark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.22em;
  color: var(--text-hi);
}
.nav .mark em { color: var(--ember); font-style: normal; }
.nav ul { display: flex; gap: 26px; list-style: none; align-items: center; }
.nav ul a {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mid);
  transition: color 120ms var(--settle);
}
.nav ul a:hover, .nav ul a:focus-visible { color: var(--text-hi); }
@media (max-width: 640px) {
  .nav { padding: 12px 16px; }
  .nav ul { gap: 14px; }
  .nav .mark { font-size: 13px; letter-spacing: 0.14em; }
  .nav ul a { font-size: 11px; letter-spacing: 0.08em; }
  .sound-toggle { font-size: 10px; padding: 4px 8px; }
}

.sound-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-mid);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 5px 12px;
  transition: transform 120ms var(--settle), color 120ms, border-color 120ms;
}
.sound-toggle:hover { transform: scale(1.03); color: var(--text-hi); border-color: var(--ember-dim); }
.sound-toggle[aria-pressed='true'] { color: var(--ember); border-color: var(--ember-dim); }

/* ---------------- hero ---------------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
}
.hero::before {
  /* warm light pool holding the wordmark — the key light of the scene */
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: min(95vmin, 940px);
  height: min(62vmin, 620px);
  translate: -50% -50%;
  background: radial-gradient(ellipse, rgba(255, 90, 54, 0.1), rgba(217, 43, 69, 0.04) 45%, transparent 68%);
  animation: breathe 6.5s ease-in-out infinite;
  pointer-events: none;
}

.sigil {
  position: absolute;
  top: 50%; left: 50%;
  width: min(78vmin, 720px);
  height: min(78vmin, 720px);
  translate: -50% -50%;
  opacity: 0.5;
  will-change: transform;
}
.sigil svg { width: 100%; height: 100%; overflow: visible; }
.ring-outer { animation: spin 90s linear infinite; transform-origin: 50% 50%; }
.ring-inner { animation: spin 60s linear infinite reverse; transform-origin: 50% 50%; }
.sigil .core { animation: breathe 5.2s ease-in-out infinite; transform-origin: 50% 50%; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}

.hero-inner { position: relative; padding: 0 20px; max-width: min(94vw, 980px); }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ember);
  margin-bottom: 22px;
}

h1.wordmark {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(44px, 9.5vw, 118px);
  line-height: 1.02;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-hi);
  text-shadow: 0 0 60px rgba(255, 90, 54, 0.35), 0 0 140px rgba(217, 43, 69, 0.2);
}
h1.wordmark .red { color: var(--ember); }

.tagline {
  margin-top: 20px;
  font-size: clamp(15px, 2vw, 19px);
  color: var(--text-mid);
  letter-spacing: 0.04em;
}

.hero-ctas { margin-top: 40px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

.btn {
  position: relative;
  display: inline-block;
  overflow: hidden;
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.08em;
  padding: 14px 32px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: transform 120ms var(--settle), box-shadow 120ms var(--settle),
              background-color 120ms, border-color 120ms;
  will-change: transform;
}
.btn:hover, .btn:focus-visible { transform: scale(1.03); }
.btn:active { transform: scale(0.97); transition-duration: 80ms; }
.btn-primary {
  background: linear-gradient(180deg, #ff8058 0%, #ff5a36 55%, #ec4a29 100%);
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 4px 30px rgba(255, 90, 54, 0.35);
}
.btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 6px 44px rgba(255, 90, 54, 0.55); }
.btn-primary::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -70%;
  width: 50%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg);
  opacity: 0;
  pointer-events: none;
}
.btn-primary:hover::after { animation: sheen 600ms var(--settle) 1; }
.btn-ghost {
  border-color: var(--line);
  color: var(--text-mid);
}
.btn-ghost:hover { color: var(--text-hi); border-color: var(--ember-dim); }

/* click ripple (spawned by main.js) */
.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: 0.35;
  transform: scale(0);
  animation: ripple 360ms var(--settle) forwards;
}
@keyframes ripple { to { transform: scale(3.2); opacity: 0; } }

.scroll-cue {
  position: absolute;
  bottom: 26px; left: 50%;
  translate: -50%;
  color: var(--text-low);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(8px); opacity: 1; }
}

/* ---------------- sections ---------------- */

section { padding: 110px 0; position: relative; }

.section-head { display: flex; align-items: baseline; gap: 20px; margin-bottom: 54px; }
.section-head h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.section-head .rule { flex: 1; height: 1px; background: linear-gradient(to right, var(--ember-dim), transparent); }
/* the rule draws itself in as part of the section's arrival choreography */
html.js .section-head .rule { transform: scaleX(0); transform-origin: left; transition: transform 900ms var(--settle) 200ms; }
html.js .section-head.arrived .rule { transform: scaleX(1); }

/* ---------------- game cards ---------------- */

.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
@media (max-width: 800px) { .games-grid { grid-template-columns: 1fr; } }

.game-card {
  --accent: var(--ember);
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--panel2), var(--panel) 55%, var(--bg1));
  padding: 40px 36px 36px;
  overflow: hidden;
  transition: transform 120ms var(--settle), border-color 120ms, box-shadow 160ms var(--settle);
  will-change: transform;
}
.game-card:hover, .game-card:focus-visible {
  transform: scale(1.03);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 10px 60px color-mix(in srgb, var(--accent) 22%, transparent);
}
.game-card:active { transform: scale(0.97); transition-duration: 80ms; }
.game-card::after {
  /* one-shot aether sheen sweep on hover — thematic light, not generic sparkle */
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -60%;
  width: 45%;
  background: linear-gradient(105deg, transparent, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
  transform: skewX(-18deg);
  opacity: 0;
  pointer-events: none;
}
.game-card:hover::after { animation: sheen 700ms var(--settle) 60ms 1; }
@keyframes sheen {
  from { transform: translateX(0) skewX(-18deg); opacity: 1; }
  to { transform: translateX(400%) skewX(-18deg); opacity: 0; }
}
.game-card::before {
  /* single glow per surface */
  content: '';
  position: absolute;
  top: -40%; right: -25%;
  width: 70%; height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%);
  opacity: 0.55;
  transition: opacity 160ms;
}
.game-card:hover::before { opacity: 1; }

@media (max-width: 560px) { .game-card { padding-top: 64px; } }
.game-card.av { --accent: var(--aether); }
.game-card.vtt { --accent: var(--torch); }
/* ambient life per world: aether lanes breathe on AV, torchlight flickers on Grimlight */
.game-card.av {
  background-image:
    repeating-linear-gradient(90deg, transparent 0 33%, rgba(103, 232, 249, 0.045) 33%, rgba(103, 232, 249, 0.045) calc(33% + 2px), transparent calc(33% + 2px) 66%, rgba(103, 232, 249, 0.045) 66%, rgba(103, 232, 249, 0.045) calc(66% + 2px), transparent calc(66% + 2px)),
    linear-gradient(160deg, var(--panel2), var(--panel) 55%, var(--bg1));
}
.game-card.av::before { animation: breathe 5.5s ease-in-out infinite; }
.game-card.vtt::before { animation: torch 4.6s ease-in-out infinite; }
@keyframes torch {
  0%, 100% { opacity: 0.55; }
  11% { opacity: 0.85; } 17% { opacity: 0.6; } 33% { opacity: 0.92; }
  40% { opacity: 0.68; } 58% { opacity: 1; } 70% { opacity: 0.62; } 85% { opacity: 0.88; }
}
.game-card h3 { text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 30%, transparent); }

.game-card .status {
  position: absolute;
  top: 20px; right: 20px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-low);
  transition: color 300ms, border-color 300ms;
}
.game-card .status.live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.game-card .status.live::before { content: '● '; }
/* a state change is PRESENTED, never silent: reward pop when a badge resolves */
.game-card .status.pop { animation: pop 300ms var(--pop); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* wordmark ignition letters (split by main.js; glow applied inline by proximity) */
.ww { white-space: nowrap; }
.wl { display: inline-block; transition: transform 120ms var(--settle), text-shadow 600ms var(--settle); }
/* title-card entrance: each letter condenses out of the dark */
@keyframes letter-in {
  from { opacity: 0; transform: translateY(0.32em); filter: blur(7px); }
  to { opacity: 1; transform: none; filter: none; }
}

.game-card .kind {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.game-card h3 {
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.game-card.av h3 { font-family: var(--game); font-weight: 700; }
.game-card.vtt h3 { font-family: var(--display); font-weight: 700; }
.game-card .hook {
  color: var(--text-hi);
  font-size: 16px;
  font-style: italic;
  margin-bottom: 14px;
  opacity: 0.9;
}
.game-card p.desc { color: var(--text-mid); font-size: 14.5px; margin-bottom: 26px; }
.game-card .enter {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.game-card .enter::after { content: ' →'; transition: none; }
.game-card:hover .enter::after { content: ' ⟶'; }

/* ---------------- craft ---------------- */

.craft-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 900px) { .craft-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .craft-grid { grid-template-columns: 1fr; } }

.craft-tile {
  --accent: var(--ember);
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg1);
  padding: 26px 22px;
  transition: transform 120ms var(--settle), border-color 120ms, box-shadow 160ms var(--settle);
}
.craft-tile[data-accent='#67e8f9'] { --accent: var(--aether); }
.craft-tile[data-accent='#f0a84b'] { --accent: var(--torch); }
.craft-tile[data-accent='#f5c451'] { --accent: var(--gold); }
.craft-tile:hover {
  transform: scale(1.03);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 8px 40px color-mix(in srgb, var(--accent) 16%, transparent);
}
.craft-tile:active { transform: scale(0.97); transition-duration: 80ms; }
.tile-enter {
  display: block;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--accent);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms var(--settle), transform 120ms var(--settle);
}
.craft-tile:hover .tile-enter, .craft-tile:focus-visible .tile-enter { opacity: 1; transform: none; }
.craft-tile .glyph { font-size: 22px; color: var(--accent); margin-bottom: 14px; }
.craft-tile h4 {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.craft-tile p { color: var(--text-mid); font-size: 13.5px; line-height: 1.55; }

/* ---------------- resume band ---------------- */

.resume-band {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(120deg, var(--panel), var(--bg1));
  padding: 44px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.resume-band::after {
  /* a slow gold glint crossing the scroll of record — treasure, not neon */
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -40%;
  width: 28%;
  background: linear-gradient(105deg, transparent, rgba(245, 196, 81, 0.09), transparent);
  transform: skewX(-18deg);
  animation: bandglint 9s linear infinite;
  pointer-events: none;
}
@keyframes bandglint {
  0% { transform: translateX(0) skewX(-18deg); }
  22% { transform: translateX(600%) skewX(-18deg); }
  100% { transform: translateX(600%) skewX(-18deg); }
}
.resume-band h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.resume-band p { color: var(--text-mid); margin-top: 6px; max-width: 52ch; }
.resume-band .btn-ghost:hover { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); color: var(--gold); }

/* ---------------- footer ---------------- */

footer {
  border-top: 1px solid var(--line);
  padding: 60px 0 80px;
  position: relative;
  z-index: 2;
}
.open-loop {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--text-hi);
  margin-bottom: 18px;
}
.open-loop em { color: var(--ember); font-style: normal; }
.open-loop a { color: var(--ember); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--ember) 45%, transparent); transition: text-decoration-color 120ms; }
.open-loop a:hover, .open-loop a:focus-visible { text-decoration-color: var(--ember); }
.foot-links { display: flex; gap: 24px; flex-wrap: wrap; }
.foot-links a {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mid);
  transition: color 120ms;
}
.foot-links a:hover { color: var(--ember); }
.colophon { margin-top: 26px; color: var(--text-low); font-size: 12px; font-family: var(--mono); }

/* the trial gate: hidden until three imps fall in one visit */
.trial-gate[hidden] { display: none; }
.trial-gate {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  padding: 14px 18px;
  border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--line));
  border-radius: 10px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--ember) 7%, var(--bg1)), var(--bg1));
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  transition: transform 120ms var(--settle), box-shadow 160ms;
}
.trial-gate.open { animation: summoned 600ms var(--pop); }
.trial-gate:hover { transform: scale(1.02); box-shadow: 0 6px 40px rgba(255, 90, 54, 0.25); color: var(--text-hi); }
.trial-gate em { color: var(--ember); font-style: normal; }
.tg-ring {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--ember);
  box-shadow: 0 0 16px rgba(255, 90, 54, 0.5), inset 0 0 10px rgba(255, 90, 54, 0.4);
  animation: breathe 3.2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ---------------- arrival choreography ---------------- */

/* hidden-until-arrival only when JS is running (html.js set inline in <head>) */
html.js [data-arrive] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 600ms var(--settle), transform 600ms var(--settle);
  transition-delay: var(--arrive-delay, 0ms);
}
html.js [data-arrive].arrived { opacity: 1; transform: none; }

/* ---------- summoning reveal (cards are conjured, not loaded) ---------- */
html.js [data-summon] { opacity: 0; }
html.js [data-summon].summoned {
  opacity: 1;
  animation: summoned 520ms var(--pop);
}
@keyframes summoned {
  0% { transform: scale(0.94); box-shadow: 0 0 70px color-mix(in srgb, var(--accent, #ff5a36) 45%, transparent); }
  100% { transform: scale(1); }
}

/* ---------- a fireball hit lands: the surface takes it ---------- */
.fb-hit { animation: fb-hit 400ms var(--settle) !important; }
@keyframes fb-hit {
  0% { transform: translate(0, 0); }
  18% { transform: translate(7px, -5px) rotate(0.6deg); }
  42% { transform: translate(-6px, 4px) rotate(-0.5deg); }
  68% { transform: translate(3px, -2px); }
  100% { transform: translate(0, 0); }
}

/* ---------- the sigil answers a serious spell ---------- */
.sigil { transition: opacity 500ms var(--settle); }
.sigil.answer { opacity: 0.95; }
.sigil.answer .ring-inner { animation-duration: 9s; }
.sigil.answer .core { animation-duration: 1.2s; }

/* ---------- familiar-binding toast (presented, then gone) ---------- */
.trw-toast {
  position: fixed;
  bottom: 34px; left: 50%;
  translate: -50%;
  z-index: 2000;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.18em;
  color: var(--gold);
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line));
  border-radius: 999px;
  padding: 10px 22px;
  animation: node-toast-in 450ms var(--pop);
  transition: opacity 700ms var(--settle), transform 700ms var(--settle);
  pointer-events: none;
}
.trw-toast.gone { opacity: 0; transform: translateY(10px); }
@keyframes node-toast-in { from { opacity: 0; transform: translateY(14px) scale(0.9); } }

/* ---------- the Descend drop + the Undercroft ---------- */
/* falling THROUGH the interface: the world scales past the viewer and blurs */
body.descending .nav,
body.descending main,
body.descending footer {
  transition: transform 1050ms cubic-bezier(0.5, 0, 0.85, 0.4), opacity 1050ms ease-in, filter 1050ms ease-in;
  transform-origin: 50% 30%;
  transform: scale(3.2) translateY(-16%);
  opacity: 0;
  filter: blur(9px);
  pointer-events: none;
}
body.ascending .nav,
body.ascending main,
body.ascending footer {
  transition: transform 700ms var(--settle), opacity 700ms var(--settle), filter 700ms var(--settle);
  transform: none;
  opacity: 1;
  filter: none;
}
body.in-undercroft { overflow: hidden; }
body.in-undercroft .nav, body.in-undercroft main, body.in-undercroft footer { visibility: hidden; }

/* CRITICAL: our display:grid would override the hidden attribute's UA
   display:none — without this rule the "hidden" chamber invisibly covers
   the whole page (z 60) and buries everything beneath it. */
.undercroft[hidden] { display: none; }
.undercroft {
  position: fixed;
  inset: 0;
  z-index: 60;
  transition: transform 700ms cubic-bezier(0.5, 0, 0.85, 0.4), opacity 700ms ease-in;
  overflow-y: auto;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(217, 43, 69, 0.12), transparent 55%),
    radial-gradient(ellipse at 50% 115%, rgba(255, 90, 54, 0.08), transparent 55%),
    linear-gradient(#050304, #0b0608 40%, #0a0507);
}
.undercroft.uc-close { transform: translateY(16%) scale(0.93); opacity: 0; pointer-events: none; }
.uc-inner { padding: 70px 24px; max-width: 900px; }
.uc-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(34px, 6.5vw, 60px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-hi);
  text-shadow: 0 0 50px rgba(217, 43, 69, 0.4);
}
.uc-lede { color: var(--text-mid); margin: 14px auto 42px; max-width: 52ch; }
.uc-cells { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.uc-cell {
  --accent: var(--ember);
  display: block;
  width: 218px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(170deg, #150a0f, #0d0609 70%);
  padding: 26px 18px;
  transition: transform 120ms var(--settle), border-color 120ms, box-shadow 160ms;
}
.uc-cell[data-accent='#f5c451'] { --accent: var(--gold); }
.uc-cell[data-accent='#67e8f9'] { --accent: var(--aether); }
.uc-cell:hover {
  transform: scale(1.05);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 8px 44px color-mix(in srgb, var(--accent) 20%, transparent);
}
.uc-cell:active { transform: scale(0.97); }
.uc-glyph { display: block; font-size: 30px; color: var(--accent); margin-bottom: 12px; }
.uc-name { display: block; font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-hi); margin-bottom: 6px; }
.uc-sub { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--text-mid); }
.uc-whisper { margin: 36px 0 26px; color: var(--text-low); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.16em; }
.uc-ascend { font-family: var(--mono); letter-spacing: 0.18em; }

/* arrival choreography inside the undercroft */
.undercroft .uc-item { opacity: 0; transform: translateY(-26px) scale(0.96); }
.undercroft.uc-open .uc-item {
  opacity: 1;
  transform: none;
  transition: opacity 550ms var(--settle), transform 550ms var(--pop);
}
.undercroft.uc-open .uc-item:nth-child(1) { transition-delay: 60ms; }
.undercroft.uc-open .uc-item:nth-child(2) { transition-delay: 140ms; }
.undercroft.uc-open .uc-item:nth-child(3) { transition-delay: 230ms; }
.undercroft.uc-open .uc-cells .uc-cell:nth-child(1) { transition-delay: 330ms; }
.undercroft.uc-open .uc-cells .uc-cell:nth-child(2) { transition-delay: 410ms; }
.undercroft.uc-open .uc-cells .uc-cell:nth-child(3) { transition-delay: 490ms; }
.undercroft.uc-open .uc-whisper { transition-delay: 620ms; }
.undercroft.uc-open .uc-ascend { transition-delay: 700ms; }

/* ---------- deeper delights ---------- */
.sigil.crimson {
  opacity: 0.95 !important;
  filter: hue-rotate(-14deg) saturate(1.8) brightness(1.35);
  transition: filter 800ms var(--settle), opacity 800ms var(--settle);
}
.sigil.crimson .ring-inner { animation-duration: 14s; }
.sigil.crimson .core { animation-duration: 1s; }

.colophon-door { cursor: pointer; transition: color 120ms var(--settle); }
.colophon-door:hover { color: var(--gold); }

.game-card .status { cursor: pointer; }

.secret-ledger {
  position: fixed;
  bottom: 30px; left: 50%;
  translate: -50%;
  z-index: 2000;
  width: min(340px, 92vw);
  background: color-mix(in srgb, var(--bg1) 94%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
  border-radius: 12px;
  padding: 18px 22px;
  animation: node-toast-in 350ms var(--pop);
  box-shadow: 0 16px 70px rgba(0, 0, 0, 0.7);
}
.secret-ledger .sl-head {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.secret-ledger .sl-row {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 5px 0;
  color: var(--text-low);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
}
.secret-ledger .sl-row:last-child { border-bottom: none; }
.secret-ledger .sl-row.found { color: var(--gold); }
.secret-ledger .sl-rune { display: inline-block; width: 22px; }
.secret-ledger em { font-style: italic; opacity: 0.8; }

/* keyboard focus is always visible */
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 4px; }

/* ---------- skip link: invisible until a keyboard user tabs to it ---------- */
.skip-link {
  position: fixed;
  top: -60px; left: 12px;
  z-index: 3000;
  background: var(--void);
  color: var(--text-hi);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 12px 18px;
  border: 1px solid var(--ember-dim);
  border-radius: 6px;
  transition: top 160ms var(--settle);
}
.skip-link:focus-visible, .skip-link:focus {
  top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
  html.js [data-arrive] { opacity: 1; transform: none; transition-delay: 0ms; }
}
