@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@400;500;600;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
  --bg: #0e0c14;
  --bg-alt: #161220;
  --surface: #1c1728;
  --surface-2: #251e33;
  --silver: #c7cbd8;
  --silver-bright: #f1f2f7;
  --violet: #8c6fe0;
  --violet-bright: #b79bff;
  --violet-deep: #5b3fa8;
  --ink: #eae7f2;
  --muted: #a49ebb;
  --line: rgba(199, 203, 216, 0.14);
  --line-strong: rgba(199, 203, 216, 0.28);
  --glow: rgba(140, 111, 224, 0.4);
  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-hero: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 28px; }
section { position: relative; }

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vw 60vw at 15% -5%, rgba(140, 111, 224, 0.16), transparent 60%),
    radial-gradient(50vw 50vw at 100% 20%, rgba(140, 111, 224, 0.1), transparent 55%),
    var(--bg);
}

/* ---------- Ambient dice rain (fixed, spans the whole page) ---------- */
.dice-rain { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.dice-rain__item {
  position: absolute; top: -18vh; color: var(--silver); opacity: 0;
  animation-name: dice-fall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes dice-fall {
  0% { transform: translateY(-18vh) rotate(0deg); opacity: 0; }
  8% { opacity: 0.15; }
  92% { opacity: 0.15; }
  100% { transform: translateY(118vh) rotate(320deg); opacity: 0; }
}

/* ---------- Reveal on scroll ---------- */
[data-reveal] { opacity: 0; transform: translateY(22px); transition: opacity 0.7s ease, transform 0.7s ease; }
[data-reveal].is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background 0.3s ease, border-color 0.3s ease, padding 0.3s ease;
}
.nav.is-scrolled {
  background: rgba(14, 12, 20, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
}
.nav__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.15rem; letter-spacing: 0.03em; color: var(--silver-bright); }
.nav__brand-icon { width: 26px; height: 26px; color: var(--violet-bright); }
.nav__links { display: flex; gap: 30px; list-style: none; margin: 0; padding: 0; }
.nav__links a { font-size: 0.95rem; color: var(--muted); letter-spacing: 0.02em; transition: color 0.2s ease; }
.nav__links a:hover { color: var(--silver-bright); }
.nav__right { display: flex; align-items: center; gap: 18px; }
.lang-switch { display: flex; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang-switch button { background: none; border: none; color: var(--muted); font-size: 0.78rem; padding: 5px 10px; border-radius: 999px; letter-spacing: 0.05em; text-transform: uppercase; }
.lang-switch button.is-active { background: var(--violet-deep); color: var(--silver-bright); }
.nav__burger { display: none; flex-direction: column; gap: 5px; background: none; border: none; padding: 6px; }
.nav__burger span { width: 22px; height: 2px; background: var(--silver-bright); transition: transform 0.25s ease, opacity 0.25s ease; }
.nav__burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger.is-open span:nth-child(2) { opacity: 0; }
.nav__burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-mobile { display: none; }
.nav-mobile.is-open {
  display: flex; flex-direction: column; gap: 4px;
  position: fixed; top: 62px; left: 14px; right: 14px; z-index: 99;
  background: rgba(20, 16, 30, 0.97); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; backdrop-filter: blur(10px);
}
.nav-mobile a, .nav-mobile button { padding: 12px 10px; color: var(--silver); font-size: 1rem; text-align: left; background: none; border: none; border-radius: var(--radius-sm); }
.nav-mobile a:hover, .nav-mobile button:hover { background: var(--surface); }
.nav-mobile__langs { display: flex; gap: 8px; padding: 8px 10px; }
.nav-mobile__langs button { flex: 1; border: 1px solid var(--line); text-align: center; }
.nav-mobile__langs button.is-active { background: var(--violet-deep); color: var(--silver-bright); }

/* ---------- Hero ---------- */
.hero {
  min-height: 92vh; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 140px 28px 80px; position: relative; overflow: hidden;
}
.hero__ornament { font-family: var(--font-display); color: var(--violet-bright); font-size: 0.85rem; letter-spacing: 0.28em; text-transform: uppercase; margin-bottom: 22px; opacity: 0.85; }
.hero__title { font-family: var(--font-hero); font-size: clamp(2.4rem, 5.4vw, 4.4rem); line-height: 1.08; color: var(--silver-bright); text-shadow: 0 0 40px var(--glow); max-width: 920px; margin: 0 auto; }
.hero__lead { margin: 26px auto 0; max-width: 620px; color: var(--muted); font-size: 1.2rem; line-height: 1.65; }
.hero__actions { display: flex; gap: 16px; justify-content: center; margin-top: 38px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 14px 30px; border-radius: 999px; font-family: var(--font-display); font-size: 0.95rem; letter-spacing: 0.04em; border: 1px solid var(--line-strong); transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease; }
.btn:hover { transform: translateY(-2px); }
.btn--primary { background: linear-gradient(135deg, var(--violet), var(--violet-deep)); color: var(--silver-bright); border-color: transparent; box-shadow: 0 10px 30px -10px var(--glow); }
.btn--primary:hover { box-shadow: 0 14px 34px -8px var(--glow); }
.btn--ghost { background: rgba(255,255,255,0.02); color: var(--silver); }
.btn--ghost:hover { border-color: var(--violet-bright); color: var(--silver-bright); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ---------- Section shell ---------- */
.section { padding: 100px 0; }
.section__head { text-align: center; max-width: 640px; margin: 0 auto 52px; }
.section__kicker { font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--violet-bright); margin-bottom: 12px; }
.section__title { font-size: clamp(1.8rem, 3.4vw, 2.6rem); color: var(--silver-bright); }
.section__lead { margin-top: 14px; color: var(--muted); font-size: 1.1rem; }
.section--alt { background: linear-gradient(180deg, transparent, rgba(140,111,224,0.05), transparent); }

/* ---------- Classes grid ---------- */
.classes-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.class-chip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 18px; text-align: center; transition: border-color 0.25s ease, transform 0.25s ease, background 0.25s ease; }
.class-chip:hover { border-color: var(--violet-bright); transform: translateY(-4px); background: var(--surface-2); }
.class-chip__icon { display: inline-flex; width: 40px; height: 40px; color: var(--violet-bright); margin-bottom: 12px; }
.class-chip__icon svg { width: 100%; height: 100%; }
.class-chip__name { display: block; font-family: var(--font-display); font-size: 1.05rem; color: var(--silver-bright); margin-bottom: 4px; }
.class-chip__tagline { display: block; font-size: 0.9rem; color: var(--muted); font-style: italic; }

/* ---------- Quiz ---------- */
.quiz-panel { max-width: 680px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 48px; text-align: center; }
.quiz-panel__intro-icon { width: 64px; height: 64px; margin: 0 auto 20px; color: var(--violet-bright); }
.quiz-progress-track { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.quiz-progress-track__bar { height: 100%; background: linear-gradient(90deg, var(--violet), var(--violet-bright)); transition: width 0.35s ease; }
.quiz-progress-label { font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 26px; text-align: left; }
.quiz-question { font-family: var(--font-display); font-size: 1.4rem; color: var(--silver-bright); margin-bottom: 28px; text-align: left; line-height: 1.4; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.quiz-option { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--silver); font-size: 1rem; font-family: var(--font-body); transition: border-color 0.2s ease, background 0.2s ease; }
.quiz-option:hover { border-color: var(--violet-bright); }
.quiz-option__dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--line-strong); flex-shrink: 0; transition: background 0.2s ease, border-color 0.2s ease; }
.quiz-option.is-selected { border-color: var(--violet-bright); background: rgba(140, 111, 224, 0.12); }
.quiz-option.is-selected .quiz-option__dot { background: var(--violet-bright); border-color: var(--violet-bright); }
.quiz-nav { display: flex; justify-content: space-between; gap: 12px; }

.result-panel {
  --result-bg: none;
  max-width: 780px; margin: 0 auto; border-radius: 20px; overflow: hidden; position: relative;
  border: 1px solid var(--line-strong);
}
.result-panel__bg { position: absolute; inset: 0; background: var(--result-bg) center/cover no-repeat; }
.result-panel__scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,12,20,0.55), rgba(14,12,20,0.94) 78%); }
.result-panel__content { position: relative; padding: 64px 44px 48px; text-align: center; }
.result-panel__icon { width: 54px; height: 54px; margin: 0 auto 16px; color: var(--violet-bright); filter: drop-shadow(0 0 12px var(--glow)); }
.result-panel__kicker { font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--violet-bright); margin-bottom: 10px; }
.result-panel__name { font-family: var(--font-hero); font-size: clamp(2rem, 4vw, 2.9rem); color: var(--silver-bright); }
.result-panel__tagline { font-style: italic; color: var(--muted); margin-top: 10px; font-size: 1.15rem; }
.result-panel__desc { max-width: 520px; margin: 22px auto 0; color: var(--silver); font-size: 1.08rem; line-height: 1.7; }
.result-panel__traits-label { font-family: var(--font-display); font-size: 0.75rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); margin: 30px 0 12px; }
.result-panel__traits { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 34px; }
.trait-chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 16px; font-size: 0.88rem; color: var(--silver-bright); background: rgba(255,255,255,0.03); }

/* ---------- Destiny Dice ---------- */
.dice-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px; align-items: start; }
.dice-picker { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.dice-picker__label { font-family: var(--font-display); font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.dice-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.dice-filter { background: var(--bg-alt); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 15px; font-size: 0.85rem; transition: all 0.2s ease; }
.dice-filter.is-active, .dice-filter:hover { border-color: var(--violet-bright); color: var(--silver-bright); }
.dice-scenario-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 4px; }
.dice-scenario { display: block; width: 100%; text-align: left; background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--silver); font-size: 1.1rem; line-height: 1.4; transition: border-color 0.2s ease; }
.dice-scenario:hover { border-color: var(--violet-bright); }
.dice-custom { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.dice-custom__title { font-size: 0.92rem; color: var(--muted); margin-bottom: 10px; font-style: italic; }
.dice-custom__row { display: flex; gap: 8px; }
.dice-custom input { flex: 1; background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; color: var(--ink); font-family: var(--font-body); font-size: 1rem; }
.dice-custom input:focus { outline: none; border-color: var(--violet-bright); }
.dice-custom__note { margin-top: 10px; font-size: 0.85rem; color: var(--violet-bright); }

.dice-stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 28px; text-align: center; position: sticky; top: 100px; }
.dice-stage__prompt { font-family: var(--font-display); font-size: 1.2rem; color: var(--silver-bright); margin-bottom: 26px; line-height: 1.4; }

.d20 {
  width: 100%; max-width: 340px; aspect-ratio: 1 / 1; margin: 0 auto 30px; position: relative;
}
.d20 canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 32px var(--glow)); transition: filter 0.25s ease; }

/* Landing flourish — a bright pulse the instant the die settles, gold for a natural 20,
   red for a natural 1, echoing BG3's flashy critical/fumble moment on the die itself. */
.d20.is-nat20 canvas { filter: drop-shadow(0 0 46px rgba(255, 208, 110, 0.95)) drop-shadow(0 0 90px rgba(255, 208, 110, 0.5)); animation: d20-flourish-pulse 1.3s ease-out; }
.d20.is-nat1 canvas { filter: drop-shadow(0 0 46px rgba(255, 90, 90, 0.9)) drop-shadow(0 0 90px rgba(255, 90, 90, 0.45)); animation: d20-flourish-pulse 1.3s ease-out; }
@keyframes d20-flourish-pulse {
  0%   { transform: scale(1); }
  12%  { transform: scale(1.08); }
  30%  { transform: scale(0.99); }
  100% { transform: scale(1); }
}
.d20__number {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: none; align-items: center; justify-content: center;
  font-family: var(--font-hero); font-size: 2.3rem; color: var(--silver-bright);
  text-shadow: 0 0 16px var(--glow), 0 2px 10px rgba(0,0,0,0.75);
}

.dice-roll-label {
  font-family: var(--font-hero); font-size: 1.7rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--silver-bright); text-shadow: 0 0 16px var(--glow), 0 2px 10px rgba(0,0,0,0.75);
  margin: -14px 0 22px; animation: dice-roll-label-in 0.3s ease;
}
.dice-roll-label.is-nat20 { color: #ffd06e; text-shadow: 0 0 18px rgba(255,208,110,0.85), 0 2px 10px rgba(0,0,0,0.75); }
.dice-roll-label.is-nat1 { color: #ff6a6a; text-shadow: 0 0 18px rgba(255,90,90,0.75), 0 2px 10px rgba(0,0,0,0.75); }
@keyframes dice-roll-label-in {
  0% { opacity: 0; transform: translateY(-6px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Fallback flat gem shape, used only when WebGL / the 3D module isn't available */
.d20.d20--fallback {
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  background: linear-gradient(155deg, var(--surface-2), var(--bg-alt) 55%, var(--violet-deep));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 0 30px rgba(140,111,224,0.25), 0 0 40px -10px var(--glow);
}
.d20.d20--fallback canvas { display: none; }
.d20.d20--fallback .d20__number { display: flex; font-size: 2.9rem; }
.d20.d20--fallback.is-rolling { animation: d20-tumble 0.85s cubic-bezier(.36,.15,.24,.95) infinite; }
.d20.d20--fallback.is-landed { animation: d20-land 0.55s ease; }
@keyframes d20-tumble {
  0%   { transform: translate(0, 0) rotate(0deg); }
  14%  { transform: translate(-12px, -26px) rotate(80deg); }
  28%  { transform: translate(10px, -40px) rotate(165deg); }
  42%  { transform: translate(-16px, -20px) rotate(245deg); }
  57%  { transform: translate(14px, -6px) rotate(320deg); }
  71%  { transform: translate(-9px, -16px) rotate(400deg); }
  85%  { transform: translate(6px, -4px) rotate(470deg); }
  100% { transform: translate(0, 0) rotate(540deg); }
}
@keyframes d20-land {
  0% { transform: translate(0, -16px) scale(1.16); }
  55% { transform: translate(0, 5px) scale(0.94); }
  100% { transform: translate(0, 0) scale(1); }
}

.dice-result { margin-top: 10px; animation: dice-result-in 0.4s ease; }
.dice-outcome {
  border: 1px solid var(--violet-bright); border-radius: var(--radius-sm); padding: 18px 20px;
  font-size: 1.32rem; line-height: 1.45; color: var(--silver-bright);
  background: rgba(140,111,224,0.14); box-shadow: 0 0 26px -8px var(--glow);
}
@keyframes dice-result-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Footer ---------- */
.footer { padding: 50px 0 36px; text-align: center; border-top: 1px solid var(--line); }
.footer__brand { font-family: var(--font-display); color: var(--silver-bright); font-size: 1.1rem; margin-bottom: 8px; }
.footer__tagline { color: var(--muted); font-size: 0.95rem; margin-bottom: 18px; }
.footer__meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.footer__meta a { color: var(--violet-bright); }
.footer__meta a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .classes-grid { grid-template-columns: repeat(3, 1fr); }
  .dice-layout { grid-template-columns: 1fr; }
  .dice-stage { position: static; }
}
@media (max-width: 860px) {
  .nav__links, .nav__right .lang-switch { display: none; }
  .nav__burger { display: flex; }
  .classes-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-panel { padding: 32px 22px; }
  .result-panel__content { padding: 52px 24px 40px; }
}
@media (max-width: 560px) {
  .hero { padding: 120px 20px 60px; }
  .hero__actions { flex-direction: column; align-items: stretch; }
  .classes-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .class-chip { padding: 18px 12px; }
  .quiz-nav { flex-wrap: wrap; }
  .dice-custom__row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal], .btn, .class-chip, .d20 { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
