:root {
  --demo-bg: #05070f;
  --demo-panel: rgba(12, 18, 32, 0.78);
  --demo-gold: #d4af37;
  --demo-gold-soft: rgba(212, 175, 55, 0.55);
  --demo-text: #f4f6fb;
  --demo-muted: rgba(244, 246, 251, 0.72);
  --demo-line: rgba(212, 175, 55, 0.28);
  --theme-blue: #2f7cff;
  --theme-green: #2ecc71;
  --theme-purple: #9b59ff;
  --theme-teal: #1abc9c;
  --theme-gold: #e0a800;
  --theme-cyan: #22d3ee;
  --font-display: "Segoe UI", "Trebuchet MS", sans-serif;
  --font-body: "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.demo-body {
  font-family: var(--font-body);
  color: var(--demo-text);
  /* Single full-viewport mountain — no second layer on .demo-page (avoids scroll seam) */
  background-color: var(--demo-bg);
  background-image:
    radial-gradient(1200px 500px at 50% -10%, rgba(80, 110, 180, 0.22), transparent 60%),
    linear-gradient(180deg, rgba(10, 16, 32, 0.22) 0%, rgba(5, 7, 15, 0.4) 45%, rgba(4, 6, 12, 0.72) 100%),
    url("../images/demo/hero-mountain.png");
  background-position: center top;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
}

.demo-page {
  position: relative;
  min-height: 100vh;
  padding: 28px clamp(16px, 4vw, 48px) 40px;
  isolation: isolate;
}

/* Soft veil only — mountain lives on body so it never tiles/seams with page height */
.demo-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -2;
  background: linear-gradient(
    180deg,
    rgba(5, 7, 15, 0.08) 0%,
    rgba(5, 7, 15, 0.28) 55%,
    rgba(5, 7, 15, 0.55) 100%
  );
  opacity: 1;
}

.demo-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(circle at 8% 88%, rgba(212, 175, 55, 0.12), transparent 22%),
    radial-gradient(circle at 92% 90%, rgba(47, 124, 255, 0.1), transparent 20%),
    linear-gradient(rgba(212, 175, 55, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 175, 55, 0.05) 1px, transparent 1px);
  background-size: auto, auto, 42px 42px, 42px 42px;
  /* Soft fade — no hard horizontal cut */
  mask-image: linear-gradient(180deg, transparent 0%, #000 40%, #000 100%);
}

.demo-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.demo-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--demo-text);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
}

.demo-brand .site-brand-logo,
.site-brand-logo {
  height: clamp(40px, 6vw, 56px);
  width: auto;
  max-width: min(260px, 52vw);
  display: block;
  object-fit: contain;
  object-position: left center;
}

.demo-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f0d278, #b8891d);
  color: #1a1405;
  font-weight: 900;
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.35);
}

.demo-topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.demo-tagline {
  color: var(--demo-gold);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  font-weight: 700;
  text-align: right;
}

.demo-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 12px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: var(--demo-text);
  font-size: 0.82rem;
}

.demo-player-chip.is-empty,
.demo-welcome-note.is-empty { display: none !important; }

.demo-player-chip strong { color: var(--demo-gold); }

.demo-change-player {
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--demo-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.demo-change-player:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.demo-welcome-note {
  margin: 14px auto 0;
  max-width: 560px;
  color: rgba(244, 246, 251, 0.86);
  font-size: 0.9rem;
  line-height: 1.45;
}

.demo-welcome-note strong { color: var(--demo-gold); }

.demo-hero {
  text-align: center;
  max-width: 820px;
  margin: 0 auto 16px;
}

.demo-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.demo-hero h1 span { color: var(--demo-gold); }

.demo-hero-line {
  width: min(220px, 40%);
  height: 2px;
  margin: 14px auto 16px;
  background: linear-gradient(90deg, transparent, var(--demo-gold), transparent);
}

.demo-hero p {
  margin: 0 auto;
  max-width: 560px;
  color: var(--demo-muted);
  line-height: 1.55;
  font-size: clamp(0.95rem, 2vw, 1.08rem);
}

.demo-stage {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.demo-quiz-panel {
  position: sticky;
  top: 18px;
  padding: 18px 16px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(18, 26, 44, 0.92), rgba(8, 12, 22, 0.96));
  border: 1px solid rgba(212, 175, 55, 0.28);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.demo-quiz-panel-head {
  margin-bottom: 14px;
}

.demo-quiz-panel-head h2,
.demo-games-panel-head h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--demo-gold);
}

.demo-quiz-panel-head p,
.demo-games-panel-head p {
  margin: 0;
  color: var(--demo-muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.demo-games-panel-head {
  margin-bottom: 14px;
}

.demo-quiz-panel .competency-list {
  max-height: min(58vh, 520px);
}

.demo-quiz-panel .demo-hint {
  margin-top: 12px;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: none;
  margin: 0;
}

.demo-card.is-waiting {
  opacity: 0.72;
}

.demo-card.is-ready {
  opacity: 1;
}

.demo-card.is-recommended {
  border-color: color-mix(in srgb, var(--accent) 80%, white 12%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 22px 48px rgba(0, 0, 0, 0.42),
    0 0 36px color-mix(in srgb, var(--accent) 34%, transparent);
}

.demo-card.is-disabled {
  opacity: 0.42;
  filter: grayscale(0.25);
}

.demo-card.is-disabled .demo-card-cta,
.demo-card-cta:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.demo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 160px;
  padding: 22px 20px 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 45%),
    linear-gradient(160deg, rgba(18, 26, 44, 0.92), rgba(8, 12, 22, 0.96));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, rgba(255, 255, 255, 0.08));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 18px 40px rgba(0, 0, 0, 0.35),
    0 0 28px color-mix(in srgb, var(--accent) 18%, transparent);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.demo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 30%),
    radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: auto, 18px 18px;
  opacity: 0.35;
  pointer-events: none;
}

.demo-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 70%, white 10%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 22px 48px rgba(0, 0, 0, 0.42),
    0 0 36px color-mix(in srgb, var(--accent) 28%, transparent);
}

.demo-card[data-theme="blue"] { --accent: var(--theme-blue); }
.demo-card[data-theme="green"] { --accent: var(--theme-green); }
.demo-card[data-theme="purple"] { --accent: var(--theme-purple); }
.demo-card[data-theme="teal"] { --accent: var(--theme-teal); }
.demo-card[data-theme="gold"] { --accent: var(--theme-gold); }
.demo-card[data-theme="cyan"] { --accent: var(--theme-cyan); }

.demo-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--accent) 22%, #0b1220);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: #fff;
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent);
  position: relative;
  z-index: 1;
}

.demo-card-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.demo-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 75%, white 40%);
  position: relative;
  z-index: 1;
}

.demo-card .card-desc {
  margin: 0 0 16px;
  color: var(--demo-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  position: relative;
  z-index: 1;
}

.demo-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  flex: 1;
  position: relative;
  z-index: 1;
}

.demo-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(244, 246, 251, 0.88);
  font-size: 0.88rem;
}

.demo-features li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--demo-gold);
  box-shadow: 0 0 8px var(--demo-gold-soft);
  flex: 0 0 auto;
}

.demo-card-cta {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 70%, white 40%);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.demo-card-cta .cta-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: transform 0.2s ease;
}

.demo-card:hover .cta-arrow { transform: translateX(3px); }

.demo-footer {
  max-width: 1180px;
  margin: 36px auto 0;
  text-align: center;
}

.demo-journey {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(10px, 3vw, 28px);
  margin-bottom: 16px;
  color: var(--demo-gold);
}

.demo-journey span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--demo-gold-soft);
  display: grid;
  place-items: center;
  background: rgba(10, 14, 24, 0.75);
  font-size: 0.85rem;
}

.demo-journey i {
  width: 28px;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--demo-gold) 0 4px, transparent 4px 8px);
  opacity: 0.7;
}

.demo-footer p {
  margin: 0;
  color: var(--demo-gold);
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Modals */
.demo-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 6, 14, 0.78);
  backdrop-filter: blur(4px);
}

.demo-modal[hidden] { display: none !important; }

.demo-modal-card {
  width: min(480px, 100%);
  background: linear-gradient(165deg, #121a2c, #0a101c);
  border: 1px solid var(--demo-line);
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 30px rgba(47, 124, 255, 0.12);
  position: relative;
}

.demo-modal-card.wide { width: min(560px, 100%); }

.demo-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: var(--demo-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.demo-modal-card h3 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: 0.03em;
}

.demo-modal-card .modal-sub {
  margin: 0 0 18px;
  color: var(--demo-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.demo-field label {
  display: block;
  margin-bottom: 8px;
  color: var(--demo-gold);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.demo-field input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--demo-text);
  padding: 13px 14px;
  font-size: 1rem;
  outline: none;
}

.demo-field input:focus {
  border-color: color-mix(in srgb, var(--theme-blue) 70%, white 10%);
  box-shadow: 0 0 0 3px rgba(47, 124, 255, 0.18);
}

.demo-error {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: #ff8d85;
  font-size: 0.88rem;
}

.demo-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.demo-btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.92rem;
}

.demo-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.demo-btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.35);
}

.demo-btn-ghost {
  background: transparent;
  color: var(--demo-muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.competency-list {
  display: grid;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
  padding-right: 4px;
}

.competency-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: var(--demo-text);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.competency-option:hover,
.competency-option.is-selected {
  border-color: rgba(47, 124, 255, 0.65);
  background: rgba(47, 124, 255, 0.12);
  transform: translateY(-1px);
}

.competency-option strong {
  display: block;
  font-size: 0.98rem;
  margin-bottom: 4px;
}

.competency-option span {
  color: var(--demo-muted);
  font-size: 0.82rem;
}

.competency-option .pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--demo-gold-soft);
  color: var(--demo-gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.demo-hint {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.22);
  color: rgba(244, 246, 251, 0.82);
  font-size: 0.84rem;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .demo-stage { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); }
  .demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .demo-stage {
    grid-template-columns: 1fr;
  }

  .demo-quiz-panel {
    position: static;
  }

  .demo-quiz-panel .competency-list {
    max-height: min(42vh, 320px);
  }
}

@media (max-width: 640px) {
  .demo-page { padding: 18px 14px 28px; }
  .demo-topbar { align-items: flex-start; }
  .demo-topbar-right { max-width: 58%; }
  .demo-tagline { font-size: 0.62rem; }
  .demo-player-chip { font-size: 0.74rem; }
  .demo-grid { grid-template-columns: 1fr; }
  .demo-card { min-height: 0; }
  .demo-journey { gap: 8px; }
  .demo-journey span { width: 30px; height: 30px; font-size: 0.75rem; }
  .demo-journey i { width: 16px; }
}
