:root {
  --story-bg: #f5f7fb;
  --story-primary: #0062ff;
  --story-accent: #ff8c42;
  --story-text: #1a1a1a;
  --story-muted: #6b7280;
  --story-card-bg: #ffffff;
  --story-card-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --story-progress-bg: #e5e7eb;
  --story-progress-fill: linear-gradient(135deg, #0062ff, #5c6cff);
  --story-badge-bg: #ffffff;
  --story-badge-border: #d4d8ff;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--story-text);
  background: var(--story-bg);
}

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

a:hover,
a:focus {
  text-decoration: underline;
}

.story-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.story-header {
  background: var(--story-card-bg);
  box-shadow: var(--story-card-shadow);
  border-radius: 0 0 24px 24px;
  padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 3rem;
  position: relative;
  overflow: hidden;
}

.story-header::after {
  content: "";
  position: absolute;
  inset: -40% -40% auto auto;
  width: clamp(180px, 35vw, 280px);
  aspect-ratio: 1;
  background: radial-gradient(circle at center, rgba(92, 108, 255, 0.18), transparent 70%);
  transform: rotate(12deg);
  pointer-events: none;
}

.story-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.story-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.story-brand img {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  border: 3px solid rgba(0, 98, 255, 0.1);
  box-shadow: 0 10px 24px rgba(0, 98, 255, 0.16);
}

.story-brand h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin: 0;
  font-weight: 700;
}

.story-language {
  position: relative;
}

.story-language button {
  border: none;
  border-radius: 999px;
  background: rgba(0, 98, 255, 0.08);
  color: var(--story-primary);
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.story-language button:focus-visible {
  outline: 3px solid rgba(0, 98, 255, 0.3);
  outline-offset: 3px;
}

.story-language-menu {
  position: absolute;
  top: 110%;
  right: 0;
  width: max-content;
  min-width: 220px;
  background: var(--story-card-bg);
  border-radius: 16px;
  box-shadow: var(--story-card-shadow);
  padding: 0.5rem;
  display: none;
  z-index: 100;
}

.story-language-menu[aria-expanded="true"] {
  display: block;
}

.story-language-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-weight: 500;
  color: var(--story-muted);
  transition: background 0.2s ease, color 0.2s ease;
}

.story-language-menu a[data-active="true"] {
  background: rgba(0, 98, 255, 0.12);
  color: var(--story-primary);
}

.story-language-menu a:hover,
.story-language-menu a:focus-visible {
  background: rgba(0, 98, 255, 0.08);
}

.story-hero {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(1.5rem, 3vw, 2.5rem);
  align-items: start;
  position: relative;
  z-index: 1;
}

.story-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.story-hero-copy h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.2;
}

.story-hero-copy p {
  margin: 0;
  color: var(--story-muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.story-hero-personas {
  display: grid;
  gap: 1rem;
}

.story-persona-card {
  border-radius: 20px;
  background: var(--story-card-bg);
  box-shadow: var(--story-card-shadow);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.story-persona-card:hover,
.story-persona-card:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(0, 98, 255, 0.28);
  outline: none;
}

.story-persona-card[data-active="true"] {
  border-color: rgba(0, 98, 255, 0.45);
  background: rgba(0, 98, 255, 0.06);
  box-shadow: 0 14px 32px rgba(0, 98, 255, 0.18);
}

.story-persona-card h3 {
  margin: 0;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.story-persona-card span {
  color: var(--story-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.story-content {
  flex: 1;
  padding: clamp(1.5rem, 5vw, 4rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.story-progress {
  background: var(--story-card-bg);
  border-radius: 24px;
  box-shadow: var(--story-card-shadow);
  padding: 1.5rem clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.story-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.story-progress-meter {
  height: 12px;
  border-radius: 999px;
  background: var(--story-progress-bg);
  overflow: hidden;
}

.story-progress-meter span {
  display: block;
  height: 100%;
  background: var(--story-progress-fill);
  border-radius: inherit;
  width: 0;
  transition: width 0.4s ease;
}

.story-node {
  background: var(--story-card-bg);
  border-radius: 26px;
  box-shadow: var(--story-card-shadow);
  padding: clamp(1.75rem, 3vw, 2.75rem);
  display: grid;
  gap: 1.5rem;
}

.story-scene {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: #0f172a;
  color: #ffffff;
  min-height: 240px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.story-scene-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.15), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.28), transparent 65%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.95));
  transition: background 0.6s ease;
}

.story-scene-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: clamp(1rem, 2.5vw, 2.25rem);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  z-index: 1;
}

.story-scene-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-scene-avatar img {
  width: clamp(120px, 28vw, 180px);
  height: clamp(120px, 28vw, 180px);
  object-fit: contain;
  border-radius: 36px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
  border: 3px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.28);
}

.story-dialog {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.story-dialog-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.92);
  color: #1f2937;
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  font-size: 1.1rem;
  line-height: 1.6;
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.2);
}

.story-dialog-bubble::after {
  content: '';
  position: absolute;
  left: -16px;
  top: 40%;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-right: 16px solid rgba(255, 255, 255, 0.92);
}

.story-dialog-sub {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.01em;
}

.story-scene-feedback {
  background: rgba(0, 98, 255, 0.08);
  border-left: 4px solid rgba(0, 98, 255, 0.6);
  padding: 1rem 1.25rem;
  border-radius: 14px;
  color: var(--story-primary);
  font-weight: 500;
  display: none;
}

.story-scene-feedback[data-visible='true'] {
  display: block;
}

.story-node [hidden] {
  display: none !important;
}

.story-node h2,
.story-node h3 {
  margin: 0;
}

.story-node p {
  margin: 0;
  color: var(--story-muted);
  line-height: 1.7;
  font-size: 1rem;
}

.story-node-choices {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.story-choice-button {
  border: 2px solid rgba(0, 98, 255, 0.12);
  border-radius: 18px;
  padding: 1.15rem 1.25rem;
  background: #f8f9ff;
  color: var(--story-primary);
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.story-choice-button:hover,
.story-choice-button:focus-visible {
  transform: translateY(-4px);
  background: #eef2ff;
  outline: none;
}

.story-rewards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.story-badge {
  background: var(--story-badge-bg);
  border: 1px solid var(--story-badge-border);
  border-radius: 20px;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  text-align: center;
}

.story-badge img {
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 12px 24px rgba(92, 108, 255, 0.18));
}

.story-badge strong {
  font-size: 1.05rem;
}

.story-cta-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.story-cta-rail a {
  flex: 1 1 200px;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: transform 0.2s ease;
}

.story-cta-primary {
  background: var(--story-primary);
  color: #ffffff;
}

.story-cta-secondary {
  background: rgba(0, 98, 255, 0.12);
  color: var(--story-primary);
}

.story-cta-rail a:hover,
.story-cta-rail a:focus-visible {
  transform: translateY(-4px);
}

.story-footer {
  padding: 2rem 1.5rem 3rem;
  text-align: center;
  color: var(--story-muted);
  font-size: 0.95rem;
}

.story-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--story-card-bg);
  color: var(--story-text);
  border-radius: 18px;
  box-shadow: var(--story-card-shadow);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 120;
}

.story-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 768px) {
  .story-header {
    border-radius: 0 0 20px 20px;
    padding: 2rem 1.35rem 2.5rem;
  }

  .story-brand img {
    width: 48px;
    height: 48px;
  }

  .story-language button {
    width: 100%;
    justify-content: center;
  }

  .story-language-menu {
    left: 0;
    right: auto;
  }

  .story-content {
    padding: 1.5rem;
  }

  .story-node {
    padding: 1.5rem;
  }

  .story-scene-stage {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .story-dialog-bubble::after {
    left: calc(50% - 8px);
    top: 100%;
    border-right: 12px solid transparent;
    border-left: 12px solid transparent;
    border-top: 14px solid rgba(255, 255, 255, 0.92);
    border-bottom: none;
  }

  .story-cta-rail a {
    flex: 1 1 100%;
  }

  .story-toast {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}
