/* ============================================================================
 * Star Trek TNG — Choose Your Own Adventure: Stylesheet
 * ----------------------------------------------------------------------------
 * LCARS-inspired dark Trek shell. Colour tokens, layout primitives, and
 * component styles are all defined here. Edit the :root variables to retheme.
 * ==========================================================================*/

:root {
  /* Base dark palette (kept close to the original to preserve the existing
   * feel; LCARS accent bars sit on top of these surfaces.) */
  --color-bg:           #05060f;
  --color-bg-deep:      #02030a;
  --color-surface:      #0f1428;
  --color-surface-2:    #161d36;
  --color-surface-3:    #1f2849;
  --color-text:         #e7ecf6;
  --color-text-dim:     #9aa6c4;
  --color-text-faint:   #5a6585;
  --color-divider:      rgba(255, 255, 255, 0.06);

  /* Classic LCARS accent palette (toned slightly for AA on dark surfaces) */
  --lcars-orange:       #ff9c5b;
  --lcars-peach:        #ffcc99;
  --lcars-blue:         #7aa7e0;
  --lcars-violet:       #c89cd6;
  --lcars-red:          #e07a7a;
  --lcars-yellow:       #ffcc66;
  --lcars-gold:         #f5c465;

  /* Ending colour cues */
  --ending-good:        #6be0a3;
  --ending-bad:         #e07a7a;
  --ending-neutral:     #7aa7e0;
  --ending-secret:      #c89cd6;

  /* Typography */
  --font-display:       'Antonio', 'Helvetica Neue', 'Arial Narrow', sans-serif;
  --font-body:          'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Motion */
  --transition-speed:   0.25s;
  --ease:               cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Layout */
  --sidebar-w:          280px;
  --header-h:           72px;
  --rail-w:             14px;

  /* Effects */
  --shadow-panel:       0 18px 48px rgba(0, 0, 0, 0.55);
  --glow-primary:       0 0 0 2px rgba(255, 156, 91, 0.35);
}

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

html, body {
  height: 100%;
  background:
    radial-gradient(ellipse at top, rgba(122, 167, 224, 0.07), transparent 55%),
    radial-gradient(ellipse at 30% 100%, rgba(255, 156, 91, 0.05), transparent 55%),
    var(--color-bg-deep);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: calc(var(--header-h) + env(safe-area-inset-top));
  padding-bottom: env(safe-area-inset-bottom);
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.35em;
  border-radius: 4px;
  background: var(--color-surface-3);
  color: var(--lcars-peach);
  font: 600 0.78em var(--font-body);
  text-align: center;
}

/* ───────── LCARS HEADER ───────── */
.lcars-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.55rem 1rem 0.55rem 0;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
  border-bottom: 1px solid var(--color-divider);
  z-index: 200;
  padding-top: max(0.55rem, env(safe-area-inset-top));
  height: calc(var(--header-h) + env(safe-area-inset-top));
}

/* Iconic LCARS curved end-cap on the left */
.lcars-endcap {
  flex: 0 0 auto;
  width: 96px;
  background: var(--lcars-orange);
  border-radius: 0 9999px 9999px 0;
  position: relative;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.15);
}
.lcars-endcap::after {
  content: "";
  position: absolute;
  right: -1px; top: 50%;
  width: 28px; height: 14px;
  background: var(--lcars-peach);
  border-radius: 0 9999px 9999px 0;
  transform: translateY(-50%);
}

.lcars-title-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  flex: 1 1 auto;
}
.app-title {
  font: 700 1.4rem/1 var(--font-display);
  letter-spacing: 0.16em;
  color: var(--lcars-orange);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-title-accent { color: var(--lcars-blue); }
.app-subtitle {
  font: 500 0.72rem/1 var(--font-body);
  color: var(--color-text-dim);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lcars-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  overflow: hidden;
}
.status-pill {
  font: 700 0.7rem/1 var(--font-display);
  letter-spacing: 0.18em;
  padding: 0.4rem 0.7rem;
  border-radius: 9999px;
  background: var(--color-surface-3);
  color: var(--lcars-peach);
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.act-pill   { color: var(--lcars-blue);   }
.ending-pill { color: var(--lcars-gold);  }

@media (max-width: 720px) {
  .lcars-status .act-pill { display: none; }
  .app-subtitle { display: none; }
  .lcars-endcap { width: 56px; }
}
@media (max-width: 460px) {
  .lcars-status .ending-pill { display: none; }
  :root { --header-h: 60px; }
  .app-title { font-size: 1.15rem; letter-spacing: 0.12em; }
  .status-pill { padding: 0.32rem 0.55rem; font-size: 0.62rem; }
}

.menu-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 64px;
  padding: 0.4rem 0.75rem;
  background: var(--lcars-blue);
  color: var(--color-bg-deep);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background var(--transition-speed) var(--ease), transform var(--transition-speed) var(--ease);
}
.menu-toggle:hover,
.menu-toggle:focus-visible { background: var(--lcars-peach); outline: none; transform: translateY(-1px); }
.menu-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-bg-deep);
  border-radius: 2px;
}
.menu-toggle-label {
  font: 700 0.6rem/1 var(--font-display);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ───────── SIDEBAR ───────── */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) var(--ease);
  z-index: 250;
}
.sidebar-backdrop.active { opacity: 1; pointer-events: auto; }

#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: min(86%, var(--sidebar-w));
  height: 100%;
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg-deep) 100%);
  border-right: 1px solid var(--color-divider);
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.5);
  transform: translateX(-105%);
  transition: transform var(--transition-speed) var(--ease);
  z-index: 300;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
#sidebar.active { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem 0;
  border-bottom: 1px solid var(--color-divider);
}
.sidebar-endcap {
  width: 56px;
  height: 28px;
  background: var(--lcars-orange);
  border-radius: 0 9999px 9999px 0;
  flex: 0 0 auto;
}
.sidebar-title {
  font: 700 0.95rem/1 var(--font-display);
  letter-spacing: 0.22em;
  color: var(--lcars-peach);
  text-transform: uppercase;
}

.chapter-list {
  list-style: none;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 0.85rem 1rem;
}

.chapter-group { margin-bottom: 1.1rem; }
.chapter-group-heading {
  font: 700 0.7rem/1 var(--font-display);
  letter-spacing: 0.22em;
  color: var(--lcars-blue);
  text-transform: uppercase;
  margin: 0 0.25rem 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed rgba(122, 167, 224, 0.25);
}
.chapter-sublist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.chapter-sublist a {
  display: grid;
  grid-template-columns: 34px 18px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--color-text-faint);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background var(--transition-speed) var(--ease), color var(--transition-speed) var(--ease);
  cursor: pointer;
}
.chapter-sublist a.visited { color: var(--color-text); }
.chapter-sublist a.visited:hover,
.chapter-sublist a.visited:focus-visible {
  background: var(--color-surface-3);
  outline: none;
}
.chapter-sublist a.current {
  background: linear-gradient(90deg, rgba(255, 156, 91, 0.18), transparent);
  color: var(--lcars-peach);
  border-left-color: var(--lcars-orange);
}
.chapter-sublist a.locked { cursor: not-allowed; opacity: 0.55; }
.chapter-sublist a.locked .chapter-label { font-style: italic; }

.chapter-marker {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--lcars-blue);
  text-align: center;
}
.chapter-sublist a.current .chapter-marker { color: var(--lcars-orange); }
.chapter-sublist a.visited .chapter-marker { color: var(--ending-good); }
.chapter-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.chapter-nav-thumb {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.chapter-ending-tag {
  font: 700 0.6rem/1 var(--font-display);
  letter-spacing: 0.18em;
  padding: 0.18rem 0.4rem;
  border-radius: 9999px;
  background: var(--color-surface-3);
  color: var(--ending-neutral);
}
.chapter-ending-tag.ending-good    { color: var(--ending-good);    background: rgba(107, 224, 163, 0.10); }
.chapter-ending-tag.ending-bad     { color: var(--ending-bad);     background: rgba(224, 122, 122, 0.10); }
.chapter-ending-tag.ending-neutral { color: var(--ending-neutral); background: rgba(122, 167, 224, 0.10); }
.chapter-ending-tag.ending-secret  { color: var(--ending-secret);  background: rgba(200, 156, 214, 0.10); }

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.6rem 0.85rem 0.3rem;
  border-top: 1px solid var(--color-divider);
}
.sidebar-actions .close { grid-column: 1 / -1; }
.menu-button {
  display: block;
  padding: 0.55rem 0.6rem;
  border: none;
  border-radius: 9999px;
  font: 700 0.72rem/1 var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--color-surface-3);
  color: var(--color-text);
  transition: background var(--transition-speed) var(--ease), color var(--transition-speed) var(--ease), transform var(--transition-speed) var(--ease);
}
.menu-button.save  { background: var(--lcars-blue);   color: var(--color-bg-deep); }
.menu-button.reset { background: var(--lcars-red);    color: var(--color-bg-deep); }
.menu-button.close { background: var(--lcars-peach);  color: var(--color-bg-deep); }
.menu-button:hover,
.menu-button:focus-visible { transform: translateY(-1px); filter: brightness(1.08); outline: none; }

.sidebar-footer {
  padding: 0.5rem 0.95rem 1rem;
  color: var(--color-text-faint);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ───────── STORY FRAME ───────── */
.lcars-frame {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  gap: 1rem;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* Decorative vertical rail of LCARS blocks */
.lcars-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: stretch;
}
.rail-block {
  display: block;
  width: var(--rail-w);
  border-radius: 4px;
  flex: 1 1 auto;
  min-height: 36px;
}
.rail-block.short { flex: 0 0 28px; }
.rail-orange { background: var(--lcars-orange); }
.rail-peach  { background: var(--lcars-peach); }
.rail-blue   { background: var(--lcars-blue); }
.rail-violet { background: var(--lcars-violet); }

.story-panel {
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-2) 100%);
  border: 1px solid var(--color-divider);
  border-radius: 12px;
  padding: 1.6rem 1.4rem;
  box-shadow: var(--shadow-panel);
  position: relative;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.story-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--lcars-orange), var(--lcars-blue));
  border-radius: 12px 0 0 12px;
}

.story-panel.fade-in {
  animation: chapterFadeIn 0.45s var(--ease);
}
@keyframes chapterFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .story-panel.fade-in { animation: none; }
}

.chapter-title {
  font: 700 2rem/1.1 var(--font-display);
  letter-spacing: 0.04em;
  color: var(--lcars-peach);
  margin-bottom: 1rem;
  text-transform: uppercase;
}
.chapter-paragraph {
  font-size: 1.02rem;
  color: var(--color-text);
  margin-bottom: 1rem;
}
.chapter-paragraph:last-of-type { margin-bottom: 0; }

/* Ending screen styling */
.ending-badge {
  display: inline-block;
  font: 700 0.7rem/1 var(--font-display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  margin-bottom: 0.85rem;
  background: var(--color-surface-3);
}
.ending-badge.ending-good    { background: rgba(107, 224, 163, 0.16); color: var(--ending-good); box-shadow: 0 0 0 1px rgba(107, 224, 163, 0.35); }
.ending-badge.ending-bad     { background: rgba(224, 122, 122, 0.16); color: var(--ending-bad);  box-shadow: 0 0 0 1px rgba(224, 122, 122, 0.35); }
.ending-badge.ending-neutral { background: rgba(122, 167, 224, 0.16); color: var(--ending-neutral); box-shadow: 0 0 0 1px rgba(122, 167, 224, 0.35); }
.ending-badge.ending-secret  { background: rgba(200, 156, 214, 0.16); color: var(--ending-secret);  box-shadow: 0 0 0 1px rgba(200, 156, 214, 0.35); }

.ending-summary {
  margin-top: 1.25rem;
  padding: 0.8rem 0.95rem;
  background: var(--color-surface);
  border-left: 3px solid var(--lcars-blue);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--color-text-dim);
}

/* ───────── CHOICE BUTTONS ───────── */
.choices {
  max-width: 920px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.choice-button {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.95rem 1.1rem;
  background: linear-gradient(180deg, var(--color-surface-2) 0%, var(--color-surface) 100%);
  color: var(--color-text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 4px solid var(--lcars-blue);
  border-radius: 8px;
  font: 500 1rem/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-speed) var(--ease),
              border-color var(--transition-speed) var(--ease),
              background var(--transition-speed) var(--ease),
              box-shadow var(--transition-speed) var(--ease);
}
.choice-button:hover:not(:disabled),
.choice-button:focus-visible:not(:disabled) {
  border-left-color: var(--lcars-orange);
  background: linear-gradient(180deg, var(--color-surface-3) 0%, var(--color-surface-2) 100%);
  transform: translateX(2px);
  box-shadow: var(--glow-primary);
  outline: none;
}
.choice-button:active:not(:disabled) { transform: translateX(2px) scale(0.995); }

.choice-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  background: var(--color-surface-3);
  color: var(--lcars-peach);
  font: 700 0.85rem/1 var(--font-display);
  letter-spacing: 0.1em;
}
.choice-button:hover:not(:disabled) .choice-index,
.choice-button:focus-visible:not(:disabled) .choice-index {
  background: var(--lcars-orange);
  color: var(--color-bg-deep);
}
.choice-text { display: block; }

.choice-button.locked {
  cursor: not-allowed;
  border-left-color: var(--color-text-faint);
  background: repeating-linear-gradient(
    135deg,
    var(--color-surface) 0 10px,
    var(--color-surface-2) 10px 20px
  );
  color: var(--color-text-dim);
  opacity: 0.85;
}
.choice-button.locked .choice-index {
  background: var(--color-bg);
  color: var(--color-text-faint);
}
.choice-button.locked .choice-index { font-size: 0; }
.choice-button.locked .choice-index::after {
  content: "🔒";
  font-size: 1rem;
  line-height: 1;
}
.choice-hint {
  grid-column: 2 / -1;
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--lcars-gold);
}

/* ───────── TOAST ───────── */
.toast {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 16px);
  background: var(--color-surface-3);
  color: var(--color-text);
  padding: 0.65rem 1rem;
  border-radius: 9999px;
  font: 600 0.85rem/1 var(--font-body);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 400;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ───────── INSTALL GUIDE ───────── */
body.install-guide-open {
  overflow: hidden;
}

.install-guide-backdrop {
  position: fixed;
  inset: 0;
  z-index: 480;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
}

.install-guide {
  position: fixed;
  inset: 0;
  z-index: 490;
  display: grid;
  place-items: end center;
  padding: 1rem clamp(1rem, 4vw, 1.5rem) calc(var(--nav-h) + max(1rem, env(safe-area-inset-bottom)));
  pointer-events: none;
}

.install-guide[hidden],
.install-guide-backdrop[hidden] {
  display: none;
}

.install-guide-card {
  width: min(100%, 430px);
  position: relative;
  padding: 1.25rem;
  border: 1px solid rgba(141, 195, 235, 0.26);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(8, 28, 48, 0.98), rgba(2, 8, 15, 0.98)),
    radial-gradient(ellipse at top left, rgba(140, 201, 255, 0.18), transparent 48%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  pointer-events: auto;
}

.install-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(245, 248, 252, 0.82);
  font: 700 1.4rem/1 var(--font-body);
  cursor: pointer;
}

.install-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 0.85rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 216, 130, 0.38);
  background: rgba(230, 182, 86, 0.12);
  color: var(--gold-bright);
  font-size: 1.65rem;
}

.install-guide h2 {
  margin: 0.35rem 2.25rem 0 0;
  color: #ffffff;
  font: 700 clamp(1.85rem, 8vw, 2.55rem)/0.98 var(--font-display);
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.install-lede {
  margin-top: 0.75rem;
  color: rgba(245, 248, 252, 0.8);
  font-size: 0.98rem;
  line-height: 1.55;
}

.install-steps {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.install-step {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.78rem;
  border: 1px solid rgba(141, 195, 235, 0.16);
  border-radius: 16px;
  background: rgba(2, 8, 15, 0.34);
}

.install-step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(140, 201, 255, 0.14);
  color: var(--blue-soft);
  font: 800 0.9rem/1 var(--font-body);
}

.install-step strong {
  display: block;
  color: #f6f9fc;
  font-size: 0.96rem;
}

.install-step span:last-child {
  display: block;
  margin-top: 0.2rem;
  color: rgba(229, 238, 248, 0.72);
  font-size: 0.88rem;
  line-height: 1.4;
}

.install-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-top: 1rem;
}

.primary-install,
.secondary-install,
.outline-action.install-action {
  min-height: 48px;
  border-radius: 15px;
  cursor: pointer;
  font: 800 0.92rem/1 var(--font-body);
}

.primary-install {
  border: 1px solid rgba(255, 216, 130, 0.68);
  background: linear-gradient(180deg, rgba(230, 182, 86, 0.95), rgba(181, 126, 42, 0.95));
  color: #160f05;
}

.secondary-install {
  border: 1px solid rgba(141, 195, 235, 0.24);
  background: rgba(8, 28, 48, 0.48);
  color: rgba(245, 248, 252, 0.86);
}

/* ───────── DESKTOP LAYOUT ───────── */
@media (min-width: 960px) {
  body { padding-left: var(--sidebar-w); }
  #sidebar {
    transform: translateX(0);
    box-shadow: none;
    border-right: 1px solid var(--color-divider);
  }
  .menu-toggle { display: none; }
  .sidebar-backdrop { display: none; }
  .lcars-header { left: var(--sidebar-w); }
  .lcars-frame { padding: 2rem 1.5rem 5rem; }
  .chapter-title { font-size: 2.4rem; }
}

/* ============================================================================
 * Cinematic mobile app redesign
 * ==========================================================================*/
:root {
  --space-black: #02060d;
  --space-navy: #07101d;
  --glass: rgba(5, 16, 29, 0.78);
  --glass-strong: rgba(7, 22, 38, 0.92);
  --glass-border: rgba(137, 182, 219, 0.24);
  --blue-rim: #3d89bf;
  --blue-soft: #8cc9ff;
  --gold: #e6b656;
  --gold-bright: #ffd882;
  --danger: #ff6e72;
  --success: #88d78d;
  --nav-h: 82px;
  --topbar-h: 74px;
}

html,
body {
  min-height: 100%;
  background:
    radial-gradient(circle at 82% 13%, rgba(78, 167, 229, 0.3), transparent 2px),
    radial-gradient(circle at 22% 19%, rgba(255, 255, 255, 0.28), transparent 1px),
    radial-gradient(circle at 72% 48%, rgba(255, 255, 255, 0.2), transparent 1px),
    radial-gradient(circle at 38% 74%, rgba(128, 199, 255, 0.22), transparent 1px),
    radial-gradient(ellipse at 68% 12%, rgba(48, 127, 189, 0.22), transparent 34%),
    radial-gradient(ellipse at 20% 100%, rgba(230, 182, 86, 0.09), transparent 38%),
    linear-gradient(180deg, #02050b 0%, #06101d 48%, #010409 100%);
  color: #f4f7fb;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top)) 0
    calc(var(--nav-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -1;
}

body::before {
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0 46%, rgba(90, 181, 255, 0.16) 47%, transparent 49%),
    radial-gradient(ellipse at 72% 90%, rgba(95, 165, 214, 0.26), transparent 19%),
    radial-gradient(ellipse at 76% 98%, rgba(255, 255, 255, 0.28), transparent 20%);
  opacity: 0.84;
}

body::after {
  right: -18vw;
  bottom: -18vw;
  width: 72vw;
  height: 31vw;
  border-radius: 50%;
  border-top: 1px solid rgba(185, 226, 255, 0.5);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(83, 156, 211, 0.34), transparent 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(8, 23, 38, 0));
  filter: blur(0.2px);
}

body[data-view="story"]::before {
  background:
    linear-gradient(90deg, rgba(2, 6, 13, 0.96) 0%, rgba(2, 6, 13, 0.78) 45%, rgba(2, 6, 13, 0.38) 100%),
    linear-gradient(180deg, rgba(2, 6, 13, 0.12), rgba(2, 6, 13, 0.88) 86%),
    var(--chapter-bg-image, none),
    radial-gradient(ellipse at 72% 90%, rgba(95, 165, 214, 0.26), transparent 19%),
    radial-gradient(ellipse at 76% 98%, rgba(255, 255, 255, 0.28), transparent 20%);
  background-position: center, center, center top, center, center;
  background-repeat: no-repeat;
  background-size: cover, cover, cover, cover, cover;
  opacity: 1;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: max(0.85rem, env(safe-area-inset-top)) clamp(1rem, 5vw, 1.5rem) 0.75rem;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 0.75rem;
  z-index: 220;
  background: linear-gradient(180deg, rgba(2, 6, 13, 0.96), rgba(2, 6, 13, 0.72) 80%, transparent);
  backdrop-filter: blur(18px);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(230, 182, 86, 0.2);
  border-radius: 14px;
  background: rgba(5, 17, 30, 0.5);
  color: var(--gold-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.menu-toggle {
  min-width: 42px;
  padding: 0;
  gap: 4px;
  flex-direction: column;
  border-radius: 14px;
  background: rgba(7, 21, 36, 0.55);
  color: var(--gold-bright);
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  background: rgba(230, 182, 86, 0.18);
  filter: none;
  transform: none;
}

.menu-toggle-bar {
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.back-button {
  display: none;
  font: 700 2rem/1 var(--font-display);
}

body[data-view]:not([data-view="story"]) .menu-toggle {
  display: none;
}

body[data-view]:not([data-view="story"]) .back-button {
  display: inline-flex;
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.eyebrow {
  color: var(--gold-bright);
  font: 700 0.73rem/1 var(--font-display);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.app-title {
  margin-top: 0.24rem;
  color: #f6f8fb;
  font: 700 clamp(1rem, 4.4vw, 1.45rem)/1.05 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delta-mark {
  justify-self: end;
  width: 31px;
  height: 42px;
  position: relative;
  filter: drop-shadow(0 0 9px rgba(255, 216, 130, 0.32));
}

.delta-mark::before,
.delta-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 92% 100%, 50% 76%, 8% 100%);
  background: linear-gradient(135deg, #fff2bf, #d19736 48%, #fff5c8);
}

.delta-mark::after {
  inset: 8px 8px 10px;
  clip-path: polygon(50% 0, 100% 100%, 50% 73%, 0 100%);
  background: var(--space-black);
}

.delta-mark.small {
  width: 24px;
  height: 32px;
  justify-self: auto;
}

.delta-mark.large {
  width: 58px;
  height: 78px;
  margin: 0 auto 1rem;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 1.5rem);
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.story-view {
  min-height: calc(100vh - var(--topbar-h) - var(--nav-h));
  min-height: calc(100dvh - var(--topbar-h) - var(--nav-h));
  position: relative;
  isolation: isolate;
}

.story-view::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2, 6, 13, 0.96) 0%, rgba(2, 6, 13, 0.78) 45%, rgba(2, 6, 13, 0.38) 100%),
    linear-gradient(180deg, rgba(2, 6, 13, 0.12), rgba(2, 6, 13, 0.88) 86%),
    var(--chapter-hero-image, var(--chapter-bg-image, none)),
    radial-gradient(ellipse at 72% 90%, rgba(95, 165, 214, 0.26), transparent 19%),
    radial-gradient(ellipse at 76% 98%, rgba(255, 255, 255, 0.28), transparent 20%);
  background-position: center, center, center top, center, center;
  background-repeat: no-repeat;
  background-size: cover, cover, cover, cover, cover;
}

.story-stage {
  position: relative;
  z-index: 1;
  padding: clamp(1rem, 4vh, 2.6rem) 0 1.2rem;
}

.hero-orbit {
  position: fixed;
  right: -6rem;
  top: 26vh;
  width: min(72vw, 420px);
  height: min(40vw, 230px);
  border-radius: 50%;
  transform: rotate(-19deg);
  background:
    radial-gradient(ellipse at 45% 42%, rgba(255, 255, 255, 0.6) 0 1px, transparent 2px),
    radial-gradient(ellipse at 48% 52%, rgba(112, 178, 222, 0.2), transparent 28%),
    linear-gradient(90deg, transparent 0 13%, rgba(174, 215, 242, 0.28) 14% 18%, transparent 20% 100%);
  border-top: 2px solid rgba(166, 207, 234, 0.26);
  border-bottom: 1px solid rgba(166, 207, 234, 0.12);
  opacity: 0.65;
  pointer-events: none;
}

.chapter-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.status-pill {
  background: rgba(4, 14, 27, 0.48);
  color: #d7e7f7;
  border: 1px solid rgba(141, 195, 235, 0.19);
  border-radius: 999px;
  padding: 0.44rem 0.7rem;
  font: 700 0.68rem/1 var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.story-panel {
  min-height: 42vh;
  padding: clamp(1.15rem, 5vw, 2rem);
  border: 1px solid rgba(141, 195, 235, 0.14);
  border-radius: 28px;
  background:
    linear-gradient(110deg, rgba(2, 8, 15, 0.84), rgba(4, 15, 27, 0.58) 66%, rgba(4, 15, 27, 0.18)),
    radial-gradient(ellipse at top left, rgba(140, 201, 255, 0.12), transparent 48%);
  box-shadow: none;
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.story-panel::before {
  display: none;
}

.story-panel.fade-in {
  animation: cinematicFade 0.45s var(--ease);
}

@keyframes cinematicFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapter-title {
  max-width: 12ch;
  margin: 0 0 1.35rem;
  color: #ffffff;
  font: 700 clamp(2.15rem, 11vw, 4.4rem)/0.95 var(--font-display);
  letter-spacing: 0.045em;
  text-transform: uppercase;
  text-shadow: 0 4px 28px rgba(120, 189, 238, 0.35);
}

.chapter-paragraph {
  max-width: 33rem;
  color: rgba(245, 248, 252, 0.92);
  font-size: var(--story-font-size, clamp(1.06rem, 3.9vw, 1.28rem));
  line-height: 1.65;
  margin-bottom: 1.08rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
}

.choices {
  max-width: none;
  margin: 1.35rem 0 0;
  padding: 0;
  gap: 0.85rem;
}

.choice-button {
  grid-template-columns: 46px 52px 1fr 22px;
  min-height: 86px;
  padding: 1rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(90, 163, 216, 0.42);
  border-left: 1px solid rgba(90, 163, 216, 0.42);
  background:
    linear-gradient(180deg, rgba(9, 34, 57, 0.82), rgba(4, 17, 31, 0.9)),
    radial-gradient(ellipse at 0 0, rgba(140, 201, 255, 0.18), transparent 45%);
  box-shadow: inset 0 0 0 1px rgba(122, 186, 236, 0.08), 0 14px 34px rgba(0, 0, 0, 0.32);
  color: #d9ebff;
  backdrop-filter: blur(18px);
}

.choice-button::after {
  content: "›";
  color: var(--blue-soft);
  font: 700 2.25rem/1 var(--font-display);
  justify-self: end;
}

.choice-button:first-child:not(.locked) {
  border-color: rgba(255, 216, 130, 0.68);
  background:
    linear-gradient(180deg, rgba(95, 62, 16, 0.86), rgba(35, 24, 10, 0.94)),
    radial-gradient(ellipse at 0 0, rgba(255, 216, 130, 0.24), transparent 48%);
  box-shadow: inset 0 0 0 1px rgba(255, 232, 170, 0.12), 0 16px 38px rgba(0, 0, 0, 0.4);
  color: #fff7dc;
}

.choice-button:first-child:not(.locked)::after {
  color: var(--gold-bright);
}

.choice-button:hover:not(:disabled),
.choice-button:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--gold-bright);
  background:
    linear-gradient(180deg, rgba(12, 44, 72, 0.9), rgba(5, 20, 36, 0.94)),
    radial-gradient(ellipse at 0 0, rgba(140, 201, 255, 0.22), transparent 45%);
  box-shadow: 0 0 0 2px rgba(255, 216, 130, 0.18), 0 18px 44px rgba(0, 0, 0, 0.48);
}

.choice-button:first-child:hover:not(:disabled),
.choice-button:first-child:focus-visible:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(111, 74, 21, 0.92), rgba(43, 29, 11, 0.96)),
    radial-gradient(ellipse at 0 0, rgba(255, 216, 130, 0.28), transparent 48%);
}

.choice-index {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid currentColor;
  background: rgba(2, 8, 15, 0.22);
  color: var(--blue-soft);
  font-size: 0.78rem;
}

.choice-thumb,
.journey-thumb,
.chapter-nav-thumb {
  display: block;
  overflow: hidden;
  border: 1px solid rgba(141, 195, 235, 0.2);
  background:
    radial-gradient(ellipse at 70% 45%, rgba(171, 219, 255, 0.65) 0 2px, transparent 3px),
    linear-gradient(160deg, transparent 0 45%, rgba(168, 209, 238, 0.42) 46% 48%, transparent 49%),
    #06101d;
}

.choice-thumb.has-image,
.journey-thumb.has-image,
.chapter-nav-thumb.has-image,
.chapter-thumbnail.has-image {
  background-image:
    linear-gradient(180deg, rgba(2, 8, 15, 0.08), rgba(2, 8, 15, 0.36)),
    var(--thumb-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.choice-thumb {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.choice-button:first-child:not(.locked) .choice-index {
  color: var(--gold-bright);
}

.choice-text {
  font-weight: 650;
  letter-spacing: 0.01em;
}

.choice-button.locked {
  opacity: 0.7;
  border-color: rgba(150, 165, 181, 0.22);
  background: rgba(9, 17, 28, 0.76);
}

.choice-button.locked::after {
  content: "⌁";
  color: rgba(213, 223, 235, 0.4);
}

.choice-button.locked .choice-index::after {
  content: "LOCK";
  font-size: 0.56rem;
  letter-spacing: 0.08em;
}

.choice-hint {
  grid-column: 3 / -1;
  color: var(--gold-bright);
}

.story-progress {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin: 1.6rem 0 0.3rem;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}

.progress-dot.active {
  background: var(--gold-bright);
  box-shadow: 0 0 12px rgba(255, 216, 130, 0.72);
}

.panel-view {
  padding: 1.3rem 0 1.5rem;
}

.screen-heading {
  margin: 0.35rem 0 1.4rem;
  text-align: center;
}

.screen-heading h2 {
  margin-top: 0.45rem;
  font: 700 clamp(1.8rem, 8vw, 2.7rem)/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-label,
.settings-group h3 {
  margin: 1.45rem 0 0.7rem;
  color: rgba(218, 228, 239, 0.66);
  font: 700 0.82rem/1 var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.feature-card,
.save-new-card,
.save-slot,
.journey-list li,
.settings-group,
.about-card,
.feature-row {
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(8, 28, 48, 0.72), rgba(3, 12, 22, 0.86)),
    radial-gradient(ellipse at top left, rgba(90, 166, 223, 0.14), transparent 52%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 14px 34px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.current-card {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 1rem;
  align-items: center;
  min-height: 132px;
  padding: 0.8rem;
  cursor: pointer;
}

.chapter-thumbnail {
  min-height: 104px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 70% 45%, rgba(171, 219, 255, 0.65) 0 2px, transparent 3px),
    linear-gradient(160deg, transparent 0 45%, rgba(168, 209, 238, 0.42) 46% 48%, transparent 49%),
    radial-gradient(ellipse at 60% 100%, rgba(77, 152, 209, 0.35), transparent 50%),
    #06101d;
  border: 1px solid rgba(141, 195, 235, 0.18);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.current-card h3,
.save-slot h3,
.feature-row h3 {
  color: #f6f9fc;
  font: 700 1.2rem/1.15 var(--font-body);
}

.current-card p,
.save-slot p,
.feature-row p,
.about-card p {
  color: rgba(229, 238, 248, 0.74);
  margin-top: 0.35rem;
}

.status-text {
  display: inline-block;
  color: var(--gold-bright);
  font-weight: 750;
}

.journey-list {
  list-style: none;
  display: grid;
  gap: 0.65rem;
  counter-reset: chapter;
}

.journey-list li {
  display: grid;
  grid-template-columns: 42px 30px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 62px;
  padding: 0.9rem 1rem;
  color: rgba(229, 238, 248, 0.78);
}

.journey-list button {
  display: contents;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
}

.journey-list .locked {
  opacity: 0.58;
}

.journey-number {
  color: rgba(245, 248, 252, 0.8);
  font-weight: 800;
}

.journey-thumb {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.journey-state {
  color: var(--gold-bright);
  font-size: 0.88rem;
  font-weight: 750;
}

.save-new-card {
  width: 100%;
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 1rem;
  align-items: center;
  min-height: 94px;
  padding: 0.8rem;
  border-color: rgba(141, 195, 235, 0.32);
  color: #f5f8fc;
  font: 700 1.1rem/1 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.save-plus {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 1px solid rgba(140, 201, 255, 0.58);
  border-radius: 14px;
  color: var(--blue-soft);
  font: 300 3rem/1 var(--font-body);
  background: rgba(42, 111, 165, 0.16);
}

.save-slot-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.save-slot {
  display: grid;
  grid-template-columns: 76px 1fr 42px;
  gap: 0.9rem;
  align-items: center;
  min-height: 96px;
  padding: 0.7rem;
}

.save-slot button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.save-delete {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(255, 110, 114, 0.26) !important;
  color: #ffc3c5 !important;
  text-align: center !important;
}

.empty-state {
  padding: 1rem;
  color: rgba(229, 238, 248, 0.7);
  text-align: center;
}

.settings-group {
  padding: 0.35rem 0;
  overflow: hidden;
}

.settings-group + .settings-group {
  margin-top: 1.35rem;
}

.settings-group h3 {
  padding: 0 1rem;
}

.setting-row,
.danger-row {
  width: 100%;
  min-height: 64px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(8, 28, 48, 0.2);
  color: #eef5fc;
  font: 700 1rem/1 var(--font-body);
}

.danger-row {
  justify-content: flex-start;
  color: var(--danger);
  cursor: pointer;
}

.segmented-control {
  display: inline-flex;
  gap: 0.28rem;
  padding: 0.25rem;
  border-radius: 14px;
  background: rgba(2, 8, 15, 0.28);
}

.text-size-option {
  width: 39px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: rgba(232, 240, 249, 0.74);
  cursor: pointer;
}

.text-size-option[data-size="compact"] { font-size: 0.9rem; }
.text-size-option[data-size="standard"] { font-size: 1.15rem; }
.text-size-option[data-size="large"] { font-size: 1.45rem; }
.text-size-option.active {
  color: var(--gold-bright);
  border-color: rgba(255, 216, 130, 0.6);
  box-shadow: 0 0 0 1px rgba(255, 216, 130, 0.12);
}

.switch-row {
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 54px;
  height: 31px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  transition: background var(--transition-speed) var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #d8dde4;
  transition: transform var(--transition-speed) var(--ease);
}

.switch-row input:checked + .switch {
  background: rgba(64, 150, 218, 0.9);
}

.switch-row input:checked + .switch::after {
  transform: translateX(23px);
}

.about-card {
  padding: 2rem 1.25rem;
  text-align: center;
}

.about-card h2 {
  margin-top: 0.6rem;
  font: 700 clamp(1.75rem, 8vw, 2.85rem)/0.95 var(--font-display);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.about-subtitle,
.version {
  color: var(--gold-bright) !important;
  font-weight: 800;
  text-transform: uppercase;
}

.feature-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.feature-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.95rem 1rem;
}

.feature-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 216, 130, 0.45);
  color: var(--gold-bright);
  font-size: 1.45rem;
}

.outline-action {
  width: 100%;
  min-height: 58px;
  margin-top: 1rem;
  border: 1px solid rgba(229, 238, 248, 0.32);
  border-radius: 14px;
  background: rgba(4, 13, 23, 0.62);
  color: #f5f8fc;
  font: 750 1rem/1 var(--font-body);
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 0.5rem clamp(0.5rem, 3vw, 1.4rem) max(0.5rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  background: rgba(2, 8, 15, 0.88);
  border-top: 1px solid rgba(141, 195, 235, 0.2);
  backdrop-filter: blur(20px);
  z-index: 210;
}

.bottom-nav-item {
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: rgba(232, 240, 249, 0.64);
  display: grid;
  place-items: center;
  gap: 0.24rem;
  font: 750 0.72rem/1 var(--font-body);
  cursor: pointer;
}

.bottom-nav-item span:first-child {
  font-size: 1.35rem;
  line-height: 1;
}

.bottom-nav-item.active {
  color: var(--gold-bright);
  background: rgba(230, 182, 86, 0.08);
}

#sidebar {
  width: min(88%, 360px);
  background: linear-gradient(180deg, rgba(7, 18, 33, 0.98), rgba(2, 8, 15, 0.98));
  border-right: 1px solid rgba(141, 195, 235, 0.24);
  box-shadow: 14px 0 42px rgba(0, 0, 0, 0.56);
}

.sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(141, 195, 235, 0.14);
  gap: 0.85rem;
}

.sidebar-title {
  margin-top: 0.25rem;
  color: #f5f8fc;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.chapter-group-heading {
  color: var(--gold-bright);
  border-bottom-color: rgba(230, 182, 86, 0.24);
}

.chapter-sublist a {
  border-radius: 13px;
  border-left: 0;
  background: rgba(8, 28, 48, 0.48);
}

.chapter-sublist a.current {
  color: var(--gold-bright);
  background: rgba(230, 182, 86, 0.12);
}

.toast {
  bottom: calc(var(--nav-h) + max(1rem, env(safe-area-inset-bottom)));
  border-radius: 16px;
  background: rgba(7, 22, 38, 0.95);
  border-color: rgba(141, 195, 235, 0.28);
}

body[data-text-size="compact"] { --story-font-size: 1rem; }
body[data-text-size="large"] { --story-font-size: 1.28rem; }

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding-inline: 1.75rem;
  }

  .story-stage {
    padding-top: 3rem;
  }
}

@media (min-width: 960px) {
  body {
    padding-left: 0;
  }

  #sidebar {
    transform: translateX(-105%);
    box-shadow: 14px 0 42px rgba(0, 0, 0, 0.56);
  }

  #sidebar.active {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
  }

  .lcars-header,
  .app-topbar {
    left: 0;
  }
}

@media (max-width: 440px) {
  :root {
    --topbar-h: 66px;
    --nav-h: 78px;
  }

  .topbar-title .eyebrow {
    display: none;
  }

  .choice-button {
    min-height: 78px;
  }

  .current-card,
  .save-slot {
    grid-template-columns: 86px 1fr;
  }

  .save-slot {
    grid-template-columns: 70px 1fr 36px;
  }
}
