:root,
[data-theme="default"] {
  color-scheme: dark;
  --theme-bg: #10151d;
  --theme-bg-deep: #0b0f15;
  --theme-surface: #18212c;
  --theme-surface-raised: #202b38;
  --theme-surface-soft: rgb(32 43 56 / 72%);
  --theme-text: #f1eee8;
  --theme-muted: #a7b0bb;
  --theme-border: rgb(171 184 198 / 20%);
  --theme-border-strong: rgb(171 184 198 / 36%);
  --theme-accent: #67b8b0;
  --theme-accent-soft: rgb(103 184 176 / 15%);
  --theme-secondary: #c49b65;
  --theme-danger: #d96b72;
  --theme-success: #75b98b;
  --theme-radius: 12px;
  --theme-shadow: 0 24px 70px rgb(0 0 0 / 32%);
  --theme-font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --theme-font-display: Georgia, "Times New Roman", serif;
}

[data-theme="cyber-noir"] {
  color-scheme: dark;
  --theme-bg: #07111f;
  --theme-bg-deep: #020812;
  --theme-surface: #0b1928;
  --theme-surface-raised: #11283d;
  --theme-surface-soft: rgb(8 28 45 / 82%);
  --theme-text: #edf7ff;
  --theme-muted: #91a4b8;
  --theme-border: rgb(81 193 225 / 24%);
  --theme-border-strong: rgb(67 210 246 / 58%);
  --theme-accent: #16d7f4;
  --theme-accent-soft: rgb(22 215 244 / 18%);
  --theme-secondary: #f0ad60;
  --theme-danger: #ff6572;
  --theme-success: #61d798;
  --theme-radius: 5px;
  --theme-shadow:
    0 28px 90px rgb(0 0 0 / 58%),
    inset 0 1px rgb(255 255 255 / 4%);
  --theme-font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --theme-font-display: "Arial Narrow", "Roboto Condensed", Inter, sans-serif;
}

.app-body {
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--theme-accent) 10%, transparent), transparent 28rem),
    linear-gradient(145deg, var(--theme-bg), var(--theme-bg-deep));
  color: var(--theme-text);
  font-family: var(--theme-font-ui);
}

.app-nav {
  border-color: var(--theme-border);
  background: color-mix(in srgb, var(--theme-surface) 92%, transparent);
  box-shadow: 0 1px rgb(255 255 255 / 3%);
  backdrop-filter: blur(14px);
}

.app-brand {
  color: var(--theme-accent);
  letter-spacing: .01em;
}

/* Bridge the existing Tailwind-heavy platform to scenario theme tokens.
   New narrative components should use semantic classes directly. */
.app-body .bg-gray-900 {
  background-color: var(--theme-bg);
}

.app-body .bg-gray-800 {
  background-color: var(--theme-surface);
}

.app-body .bg-gray-700 {
  background-color: var(--theme-surface-raised);
}

.app-body .border-gray-700,
.app-body .border-gray-600 {
  border-color: var(--theme-border);
}

.app-body .text-gray-100,
.app-body .text-white {
  color: var(--theme-text);
}

.app-body .text-gray-300,
.app-body .text-gray-400,
.app-body .text-gray-500 {
  color: var(--theme-muted);
}

.app-body .text-cyan-300,
.app-body .text-cyan-400,
.app-body .text-cyan-500 {
  color: var(--theme-accent);
}

.app-body .bg-cyan-500,
.app-body .bg-cyan-600,
.app-body .bg-cyan-700 {
  background-color: var(--theme-accent);
}

.app-body .border-cyan-500 {
  border-color: var(--theme-accent);
}

.narrative-page {
  position: relative;
  left: 50%;
  width: 100vw;
  min-height: calc(100dvh - 53px);
  margin-top: -2rem;
  margin-left: -50vw;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 12%, var(--theme-accent-soft), transparent 30rem),
    linear-gradient(145deg, var(--theme-bg), var(--theme-bg-deep));
}

.narrative-page__scene {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.narrative-page__scene-shade {
  position: absolute;
  inset: 0;
  display: none;
  background: linear-gradient(to bottom, rgb(7 11 16 / 24%), rgb(7 11 16 / 88%));
}

.narrative-page--landscape .narrative-page__scene,
.narrative-page--landscape .narrative-page__scene-shade {
  display: block;
}

.narrative-stage {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  width: min(1380px, calc(100% - 3rem));
  min-height: min(760px, calc(100dvh - 101px));
  margin-inline: auto;
  padding-block: 1.5rem;
}

.narrative-character {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--theme-border);
  border-right: 0;
  border-radius: var(--theme-radius) 0 0 var(--theme-radius);
  background: color-mix(in srgb, var(--theme-surface) 94%, transparent);
  box-shadow: var(--theme-shadow);
}

.narrative-character__image {
  display: block;
  width: 100%;
  border: 1px solid var(--theme-border-strong);
  border-radius: calc(var(--theme-radius) - 4px);
  background: var(--theme-bg-deep);
  object-fit: cover;
  object-position: center top;
}

.narrative-page--thumbnail .narrative-character__image {
  aspect-ratio: 16 / 10;
}

.narrative-page--portrait .narrative-stage {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}

.narrative-page--portrait .narrative-character__image {
  aspect-ratio: 2 / 3;
}

.narrative-dialogue {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--theme-border);
  border-radius: 0 var(--theme-radius) var(--theme-radius) 0;
  background: color-mix(in srgb, var(--theme-bg) 91%, transparent);
  box-shadow: var(--theme-shadow);
  backdrop-filter: blur(18px);
}

.narrative-speaker {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  margin: 0;
  padding: .4rem 1.4rem;
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  background: var(--theme-surface);
  color: var(--theme-text);
  font-family: var(--theme-font-display);
  font-size: 1rem;
  line-height: 1.2;
  transform: translate(-50%, -50%);
}

.narrative-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding-inline: clamp(1.25rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--theme-border);
  color: var(--theme-muted);
  font-size: .8rem;
}

.narrative-toolbar a,
.narrative-toolbar button {
  color: inherit;
}

.narrative-toolbar a:hover,
.narrative-toolbar button:hover {
  color: var(--theme-text);
}

.narrative-content {
  flex: 1;
  overflow-y: auto;
  padding: clamp(1.5rem, 4vw, 4rem);
}

.narrative-copy {
  max-width: 900px;
  min-height: 10rem;
  color: var(--theme-text);
  font-size: clamp(1.05rem, 1.5vw, 1.28rem);
  line-height: 1.8;
}

.narrative-copy p {
  margin: 0 0 1rem;
}

.narrative-copy em {
  color: var(--theme-muted);
}

.narrative-choices {
  display: flex;
  max-width: 980px;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1.75rem;
}

.narrative-choice {
  width: 100%;
  min-height: 58px;
  padding: .9rem 1.1rem;
  border: 1px solid var(--theme-border);
  border-left: 3px solid transparent;
  border-radius: 8px;
  background: var(--theme-surface-soft);
  color: var(--theme-text);
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.narrative-choice:hover,
.narrative-choice:focus-visible {
  border-color: var(--theme-border-strong);
  border-left-color: var(--theme-accent);
  background: var(--theme-surface-raised);
  outline: none;
  transform: translateX(3px);
}

.narrative-page--landscape .narrative-stage {
  grid-template-columns: 1fr;
  align-content: end;
}

.narrative-page--landscape .narrative-character {
  display: none;
}

.narrative-page--landscape .narrative-dialogue {
  max-height: 68dvh;
  margin-top: 18dvh;
  border-radius: var(--theme-radius);
  background: rgb(10 15 21 / 88%);
}

.narrative-page--landscape .narrative-content {
  display: flex;
  flex-direction: column;
}

.narrative-page--landscape .narrative-copy {
  width: 100%;
  max-width: none;
}

.narrative-page--landscape .narrative-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: none;
}

.narrative-input {
  display: flex;
  gap: .65rem;
  margin-top: .75rem;
}

.narrative-input input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--theme-border);
  border-radius: 8px;
  background: var(--theme-bg-deep);
  color: var(--theme-text);
  padding: .75rem .9rem;
}

.narrative-action {
  border-radius: 8px;
  background: var(--theme-accent);
  color: #091311;
  padding: .75rem 1rem;
  font-weight: 700;
}

@media (max-width: 760px) {
  .narrative-page {
    margin-top: -2rem;
  }

  .narrative-stage,
  .narrative-page--portrait .narrative-stage {
    grid-template-columns: 1fr;
    width: min(100% - 1rem, 680px);
  }

  .narrative-character {
    display: block;
    border-right: 1px solid var(--theme-border);
    border-bottom: 0;
    border-radius: var(--theme-radius) var(--theme-radius) 0 0;
  }

  .narrative-character__image,
  .narrative-page--portrait .narrative-character__image {
    aspect-ratio: 1;
  }

  .narrative-dialogue {
    border-radius: 0 0 var(--theme-radius) var(--theme-radius);
  }

  .narrative-page--landscape .narrative-character {
    position: static;
    width: auto;
  }

  .narrative-page--landscape .narrative-dialogue {
    max-height: none;
    margin-top: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .narrative-choice {
    transition: none;
  }
}

/* -------------------------------------------------------------------------
   Cyber Noir
   Cinematic landscape scenes; portrait/thumbnail art becomes an atmospheric
   blurred backdrop while the source image stays sharp inside its card.
   ------------------------------------------------------------------------- */

[data-theme="cyber-noir"].app-body {
  background:
    radial-gradient(circle at 18% 0%, rgb(22 215 244 / 10%), transparent 30rem),
    linear-gradient(145deg, #07111f, #020812);
}

[data-theme="cyber-noir"] .app-nav {
  border-color: rgb(74 142 170 / 26%);
  background: rgb(4 13 24 / 88%);
  box-shadow:
    0 1px rgb(74 211 242 / 8%),
    0 12px 40px rgb(0 0 0 / 24%);
  backdrop-filter: none;
}

[data-theme="cyber-noir"] .app-brand {
  color: #28dcf7;
  font-family: var(--theme-font-display);
  letter-spacing: .035em;
  text-shadow: 0 0 22px rgb(22 215 244 / 24%);
}

[data-theme="cyber-noir"] .narrative-page {
  background:
    radial-gradient(circle at 78% 15%, rgb(240 173 96 / 8%), transparent 24rem),
    linear-gradient(145deg, #07111f, #020812);
}

[data-theme="cyber-noir"] .narrative-page__scene,
[data-theme="cyber-noir"] .narrative-page__scene-shade {
  display: block;
}

[data-theme="cyber-noir"] .narrative-page--thumbnail .narrative-page__scene,
[data-theme="cyber-noir"] .narrative-page--portrait .narrative-page__scene {
  inset: -3rem;
  width: calc(100% + 6rem);
  height: calc(100% + 6rem);
  opacity: .68;
  filter: blur(24px) saturate(.9) brightness(.78);
  transform: scale(1.05);
}

[data-theme="cyber-noir"] .narrative-page--thumbnail .narrative-page__scene-shade,
[data-theme="cyber-noir"] .narrative-page--portrait .narrative-page__scene-shade {
  background:
    linear-gradient(90deg, rgb(2 8 18 / 44%), rgb(3 11 20 / 72%)),
    radial-gradient(circle at 18% 42%, transparent, rgb(2 7 14 / 48%) 65%),
    linear-gradient(to bottom, rgb(4 11 20 / 28%), rgb(3 8 16 / 82%));
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-page__scene {
  object-position: center;
  filter: saturate(.96) brightness(.92);
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-page__scene-shade {
  background:
    linear-gradient(90deg, rgb(2 8 17 / 5%), rgb(2 8 17 / 24%)),
    linear-gradient(to bottom, transparent 35%, rgb(2 8 17 / 48%) 94%);
}

[data-theme="cyber-noir"] .narrative-stage {
  width: min(1540px, calc(100% - 3rem));
  padding-block: clamp(1rem, 2.5vh, 2rem);
}

[data-theme="cyber-noir"] .narrative-character,
[data-theme="cyber-noir"] .narrative-dialogue {
  border-color: rgb(73 184 218 / 34%);
  background:
    linear-gradient(145deg, rgb(8 25 41 / 94%), rgb(3 13 25 / 91%));
  box-shadow:
    0 30px 90px rgb(0 0 0 / 55%),
    inset 0 1px rgb(255 255 255 / 5%);
  backdrop-filter: none;
}

[data-theme="cyber-noir"] .narrative-character {
  position: relative;
}

[data-theme="cyber-noir"] .narrative-dialogue {
  border-color: rgb(73 184 218 / 24%);
  background:
    linear-gradient(145deg, rgb(8 25 41 / 76%), rgb(3 13 25 / 68%));
  box-shadow:
    0 24px 70px rgb(0 0 0 / 38%),
    inset 0 1px rgb(255 255 255 / 4%);
  backdrop-filter: none;
}

[data-theme="cyber-noir"] .narrative-character::before {
  position: absolute;
  top: 0;
  left: 1.5rem;
  width: 4.5rem;
  height: 2px;
  background: var(--theme-accent);
  box-shadow: 0 0 18px rgb(22 215 244 / 55%);
  content: "";
}

[data-theme="cyber-noir"] .narrative-character__image {
  border-color: rgb(22 215 244 / 62%);
  border-radius: 3px;
  box-shadow:
    0 18px 50px rgb(0 0 0 / 38%),
    0 0 0 1px rgb(22 215 244 / 8%);
}

[data-theme="cyber-noir"] .narrative-toolbar {
  border-color: rgb(66 139 167 / 22%);
  background: rgb(3 13 25 / 28%);
  letter-spacing: .04em;
  text-transform: uppercase;
}

[data-theme="cyber-noir"] .narrative-speaker {
  padding: .42rem 1.8rem;
  border-color: rgb(22 215 244 / 42%);
  border-radius: 3px;
  background: rgb(5 25 39 / 88%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 28%);
  color: #dff9ff;
  font-family: var(--theme-font-display);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

[data-theme="cyber-noir"] .narrative-copy {
  max-width: 1040px;
  color: #eaf5fc;
}

[data-theme="cyber-noir"] .narrative-choice {
  border-color: rgb(76 147 174 / 30%);
  border-left-color: rgb(76 147 174 / 30%);
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgb(13 39 58 / 64%), rgb(5 21 36 / 56%));
  box-shadow: inset 0 1px rgb(255 255 255 / 3%);
  transition: none;
}

[data-theme="cyber-noir"] .narrative-choice:hover,
[data-theme="cyber-noir"] .narrative-choice:focus-visible {
  border-color: var(--theme-accent);
  border-left-color: var(--theme-accent);
  background:
    linear-gradient(90deg, rgb(8 67 87 / 92%), rgb(6 30 47 / 92%));
  box-shadow:
    0 0 28px rgb(22 215 244 / 12%),
    inset 4px 0 var(--theme-accent);
  transform: none;
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-stage {
  min-height: calc(100dvh - 53px);
  padding-bottom: 2.25rem;
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-dialogue {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: none;
  width: min(1240px, 88%);
  min-height: 230px;
  margin-top: auto;
  margin-inline: auto;
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgb(4 18 31 / 72%), rgb(4 15 28 / 62%));
  box-shadow:
    0 20px 60px rgb(0 0 0 / 34%),
    inset 0 1px rgb(255 255 255 / 4%);
  backdrop-filter: none;
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-content {
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 2vw, 1.75rem);
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-copy {
  width: 100%;
  min-height: 4.5rem;
  font-size: clamp(1rem, 1.25vw, 1.16rem);
  line-height: 1.6;
}

[data-theme="cyber-noir"] .narrative-page--landscape .narrative-choices {
  margin-top: .9rem;
}

[data-theme="cyber-noir"] .narrative-page--landscape #dialogue-choices-wrapper {
  width: 100%;
}

@media (max-width: 900px) {
  .narrative-page--landscape .narrative-choices {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 760px) {
  [data-theme="cyber-noir"] .narrative-stage {
    width: min(100% - 1rem, 680px);
  }

  [data-theme="cyber-noir"] .narrative-page--landscape .narrative-stage {
    min-height: calc(100dvh - 53px);
  }

  [data-theme="cyber-noir"] .narrative-page--landscape .narrative-dialogue {
    width: 100%;
  }
}
