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

:root {
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;

  --color-gold: #f3d081;
  --color-gold-glow: rgba(243, 208, 129, 0.4);
  --color-teal-glow: rgba(64, 224, 208, 0.35);
  --color-purple-glow: rgba(147, 112, 219, 0.4);

  --bg-dark: #080a10;
  --text-main: #f0f4f8;
  --text-muted: #a0aec0;

  --glass-bg: rgba(13, 17, 28, 0.65);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: blur(16px);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

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

html, body, #root {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-body);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   BUTTONS & GENERAL UI COMPONENTS
   ========================================================================== */

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 40px;
  background: linear-gradient(135deg, #d4af37 0%, #f3d081 50%, #b8860b 100%);
  color: #0b0f19;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 20px var(--color-gold-glow);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 28px rgba(243, 208, 129, 0.6);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.9rem;
  backdrop-filter: var(--glass-blur);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-secondary.sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 20px;
}

.btn-secondary.danger {
  color: #feb2b2;
  border-color: rgba(245, 101, 101, 0.3);
}

.btn-secondary.danger:hover {
  background: rgba(245, 101, 101, 0.2);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  color: var(--text-main);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.icon-btn.sm {
  width: 28px;
  height: 28px;
}

.icon-btn.danger:hover {
  background: rgba(245, 101, 101, 0.3);
  color: #feb2b2;
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.icon-btn:disabled:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: none;
}

/* ==========================================================================
   SPLASH SCREEN
   ========================================================================== */

.splash-screen {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  transition: opacity 0.8s ease-in-out;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Dual-layer splash background — same approach as scene screen */
.splash-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.65);
  transform: scale(1.15);
  animation: slowZoom 30s infinite alternate ease-in-out;
  will-change: transform;
}

.splash-main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes slowZoom {
  0% { transform: scale(1.08); }
  100% { transform: scale(1.18); }
}

/* Disable zoom animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .splash-backdrop {
    animation: none !important;
    will-change: auto;
  }
}

.splash-content {
  position: relative;
  z-index: 10;
  width: 90%;
  max-width: 580px;
  padding: 44px 36px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  text-align: center;
  animation: floatUp 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatUp {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

.splash-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  border-radius: 20px;
  background: rgba(243, 208, 129, 0.12);
  border: 1px solid rgba(243, 208, 129, 0.3);
  color: var(--color-gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.story-title {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.15;
  background: linear-gradient(180deg, #ffffff 0%, #d8e2ed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.story-subtitle {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--color-gold);
  font-style: italic;
  margin-bottom: 8px;
}

.story-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.story-intro-teaser {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.5;
  color: #e2e8f0;
  font-style: italic;
  margin-bottom: 28px;
  padding: 0 10px;
}

.splash-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.traveler-input {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: all 0.3s ease;
}

.traveler-input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 15px var(--color-gold-glow);
  background: rgba(0, 0, 0, 0.6);
}

/* Pronoun selector chips */
.pronoun-group {
  margin-top: 4px;
}

.pronoun-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pronoun-chip {
  flex: 1;
  min-width: 100px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.3s ease;
}

.pronoun-chip:hover {
  border-color: var(--color-gold);
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.55);
}

.pronoun-chip.active {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--color-gold);
  color: var(--color-gold);
  box-shadow: 0 0 12px var(--color-gold-glow);
}

.pronoun-chip:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.action-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.splash-footer {
  margin-top: 24px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

/* ==========================================================================
   SCENE SCREEN & PARALLAX CANVAS
   ========================================================================== */

/* --------------------------------------------------------------------------
   DUAL-LAYER SCENE BACKGROUND
   Backdrop: same image, blurred + scaled to fill screen (cover — allowed to crop).
   Main:    same image, object-fit:contain — always shows the full 1024×1024 art.
   -------------------------------------------------------------------------- */
.scene-screen {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

.scene-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(24px) brightness(0.7);
  transform: scale(1.15);
  will-change: transform;
  transition: opacity 1.2s ease-in-out;
}

.scene-main {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 1.2s ease-in-out;
}

/* Disable parallax animation for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .scene-backdrop {
    /* keep the scale + blur so the fill still works, but no transform animation */
    animation: none !important;
    will-change: auto;
  }
}

/* ────────────────────────────────────────────────────────────────
   PARALLAX WALKING SCENE
   ──────────────────────────────────────────────────────────────── */

/* Container fills the viewport; overflow hidden so we scroll within */
.parallax-container {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

/* Each parallax image layer fills the FULL viewport height and scales its
   width proportionally to the image's intrinsic aspect ratio. This keeps the
   whole image visible (no vertical crop/zoom) while leaving the extra width
   available to pan into.
   NOTE: min-width is deliberately omitted — forcing the width to fill the
   viewport upscales the image on wide screens, cropping the top/bottom and
   "zooming in" on the art. object-fit is also omitted because with
   height:100% and width:auto the element already matches the image's aspect
   ratio, and object-fit can interfere with translateX. */
.parallax-layer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  will-change: transform;
}

/* Symbol overlay layer — moves in lockstep with the near (foreground) layer.
   Symbols are positioned with absolute left/top values relative to the near
   layer's pan distance, computed at runtime from the image widths. */
.parallax-symbol-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* Each symbol is positioned by left/top percentages within the
   symbol layer. The wrapper handles visibility and interactivity
   while FloatingSymbol provides the icon + animation. */
.parallax-symbol-wrapper {
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* Completed (past) symbols are dimmed and non-interactive */
.parallax-symbol-wrapper.past .floating-symbol-container {
  pointer-events: none;
}

.parallax-symbol-wrapper.past .symbol-core {
  opacity: 0.5;
  filter: grayscale(0.4);
}

.parallax-symbol-wrapper.past .symbol-aura,
.parallax-symbol-wrapper.past .symbol-pulse-ring,
.parallax-symbol-wrapper.past .symbol-mote {
  display: none;
}

/* Current symbol is fully visible and pulsing */
.parallax-symbol-wrapper.current .floating-symbol-container {
  pointer-events: auto;
}

/* Right-anchor the symbol on the wrapper position: the inline left/top
   percentages FloatingSymbol sets resolve to 0 inside the zero-sized
   wrapper, so cancel `left` and pin `right: 0` — this puts the whole
   symbol (core + label) on the RIGHT side, ahead of the reader as they
   walk right, and the label never clips the screen's right edge. */
.parallax-symbol-wrapper .floating-symbol-container {
  transform: none !important;
  left: auto !important;
  right: 0 !important;
}

/* ==========================================================================
   KEN BURNS SCENE (internal scenes — single hero image + zoom/pan camera)
   ========================================================================== */
.kenburns-container {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

.kenburns-hero {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  will-change: transform;
}

/* Wrapper only controls visibility/interactivity; the FloatingSymbol inside
   positions itself via the screenPosition prop. */
.kenburns-symbol-wrapper {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Only current + past symbols capture clicks; future symbols are hidden and
   must never intercept a pointer. */
.kenburns-symbol-wrapper .floating-symbol-container {
  pointer-events: none;
}
.kenburns-symbol-wrapper.current .floating-symbol-container,
.kenburns-symbol-wrapper.past .floating-symbol-container {
  pointer-events: auto;
}

/* Past (already read) symbols are dimmed and non-interactive */
.kenburns-symbol-wrapper.past .symbol-core {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.kenburns-symbol-wrapper.past .symbol-aura,
.kenburns-symbol-wrapper.past .symbol-pulse-ring,
.kenburns-symbol-wrapper.past .symbol-mote {
  display: none;
}

/* ==========================================================================
   EDITOR — SCENE TYPE TOGGLE + FOCUS PICKER
   ========================================================================== */
.scene-type-toggle {
  display: flex;
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}
.scene-type-toggle .type-opt {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.scene-type-toggle .type-opt.active {
  background: var(--color-gold);
  color: #1a1208;
  font-weight: 600;
}

.focus-picker {
  position: relative;
  margin: 10px 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: crosshair;
  border: 1px solid var(--glass-border);
  max-width: 320px;
}
.focus-picker img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.focus-picker .focus-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-gold);
  background: rgba(243, 208, 129, 0.35);
  box-shadow: 0 0 10px var(--color-gold-glow);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Walking guard — disable all interaction during pan */
.parallax-symbol-wrapper.walking .floating-symbol-container {
  pointer-events: none !important;
}


.scene-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(180deg, rgba(8, 10, 16, 0.85) 0%, rgba(8, 10, 16, 0) 100%);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.story-branding {
  display: flex;
  flex-direction: column;
}

.story-title-mini {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-gold);
}

.reader-greeting {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Progress Indicator */
.progress-indicator-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  border-radius: 30px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

.scene-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-main);
}

.compass-icon {
  color: var(--color-gold);
}

.scene-title {
  font-family: var(--font-serif);
  font-style: italic;
}

.node-trail {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trail-dot {
  color: rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.trail-dot.done {
  color: var(--color-gold);
}

.progress-percent {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Audio Widget */
.audio-controller-widget {
  position: relative;
}

.audio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
}

.audio-btn.active {
  color: var(--color-gold);
  border-color: rgba(243, 208, 129, 0.4);
}

.volume-slider-popup {
  position: absolute;
  top: 50px;
  right: 0;
  padding: 12px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 160px;
}

.volume-slider {
  width: 100%;
  accent-color: var(--color-gold);
}

.volume-val {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   FLOATING SYMBOLS & DRIFT ANIMATION
   ========================================================================== */

.symbols-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.floating-symbol-container {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
  animation: floatBob 5s ease-in-out infinite alternate;
}

@keyframes floatBob {
  0% { transform: translate(-50%, -50%) translateY(0px) rotate(-1deg); }
  50% { transform: translate(-50%, -50%) translateY(-12px) rotate(1deg); }
  100% { transform: translate(-50%, -50%) translateY(0px) rotate(-1deg); }
}

.symbol-core {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(13, 17, 28, 0.7);
  backdrop-filter: var(--glass-blur);
  border: 1.5px solid var(--color-gold);
  color: var(--color-gold);
  box-shadow: 0 0 20px var(--color-gold-glow), inset 0 0 10px var(--color-gold-glow);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floating-symbol-container:hover .symbol-core {
  transform: scale(1.25);
  box-shadow: 0 0 35px rgba(243, 208, 129, 0.9), inset 0 0 20px rgba(243, 208, 129, 0.6);
  background: rgba(243, 208, 129, 0.2);
}

.floating-symbol-container.completed .symbol-core {
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.6);
  box-shadow: none;
  opacity: 0.65;
}

.symbol-aura {
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-gold-glow) 0%, transparent 70%);
  animation: auraPulse 3s ease-in-out infinite alternate;
}

@keyframes auraPulse {
  0% { opacity: 0.3; transform: scale(0.9); }
  100% { opacity: 0.8; transform: scale(1.2); }
}

.symbol-tooltip {
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(8, 10, 16, 0.85);
  border: 1px solid var(--glass-border);
  font-size: 0.8rem;
  color: var(--text-main);
  white-space: nowrap;
  opacity: 0.8;
  transition: all 0.3s ease;
}

.floating-symbol-container:hover .symbol-tooltip {
  opacity: 1;
  transform: translateY(2px);
  border-color: var(--color-gold);
}

/* Direction arrow — sits immediately to the right of the symbol core and
   nudges rightward to indicate the reader's walking direction. Only rendered
   in parallax scenes, on the current symbol (see FloatingSymbol.jsx). */
.direction-arrow {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(13, 17, 28, 0.75);
  border: 1.5px solid var(--color-gold);
  color: var(--color-gold);
  box-shadow: 0 0 14px var(--color-gold-glow);
  pointer-events: none;
  animation: directionNudge 1.5s ease-in-out infinite;
}

@keyframes directionNudge {
  0%, 100% { transform: translateY(-50%) translateX(0); opacity: 0.7; }
  50% { transform: translateY(-50%) translateX(6px); opacity: 1; }
}

/* ==========================================================================
   STORY PANEL READING OVERLAY
   ========================================================================== */

.story-panel-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.7);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.story-panel-card {
  position: relative;
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 40px 44px;
  background: rgba(12, 16, 26, 0.88);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(243, 208, 129, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(243, 208, 129, 0.15);
  animation: panelSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* The passage body scrolls independently so long (200+ word) passages stay
   readable on small screens without pushing the footer off-screen. */
.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
}

@keyframes panelSlideUp {
  0% { opacity: 0; transform: translateY(40px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-header {
  flex: 0 0 auto;
}

.panel-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.panel-symbol-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 20px;
  background: rgba(243, 208, 129, 0.12);
  color: var(--color-gold);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 24px;
}

.passage-text {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.7;
  color: #f7fafc;
  letter-spacing: 0.2px;
  margin-bottom: 32px;
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
  padding-top: 16px;
}

/* ==========================================================================
   SCENE COMPLETE & EDITOR MODAL
   ========================================================================== */

.scene-complete-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 12, 0.8);
  backdrop-filter: blur(10px);
}

.scene-complete-card {
  width: 90%;
  max-width: 520px;
  padding: 40px;
  text-align: center;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

.sparkle-badge {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(243, 208, 129, 0.15);
  color: var(--color-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.scene-complete-text {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 16px 0 28px;
}

/* Access Notice Modal Overrides */
.access-notice-modal {
  height: auto;
  width: auto;
  max-width: 520px;
  min-width: 320px;
}

.access-notice-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  text-align: center;
}

.access-notice-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.access-notice-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.editor-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 200;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-modal-card {
  width: 92%;
  max-width: 1000px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  background: #0f1422;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 25px 70px rgba(0,0,0,0.9);
}

/* Synopsis modal — compact, auto-height popup (not a full editor). */
.synopsis-modal {
  width: 92%;
  max-width: 560px;
  height: auto;
  max-height: 80vh;
}

.synopsis-body {
  padding: 24px;
}

.synopsis-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-main);
  white-space: pre-wrap;
}

.synopsis-empty {
  color: var(--text-muted);
  font-style: italic;
}

.editor-header {
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  position: relative;
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-gold);
  flex: 0 1 auto;
  min-width: 0;
}

.header-title-group h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.editor-tab-switcher {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 20px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.json-textarea {
  width: 100%;
  height: 100%;
  min-height: 450px;
  background: #090c14;
  color: #a6accd;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  padding: 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  resize: none;
}

.json-error-banner {
  padding: 10px 16px;
  background: rgba(245, 101, 101, 0.2);
  border: 1px solid rgba(245, 101, 101, 0.4);
  color: #feb2b2;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.editor-section {
  margin-bottom: 28px;
}

.editor-section h3 {
  font-size: 1.1rem;
  color: var(--color-gold);
  margin-bottom: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.audio-options {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group.full {
  grid-column: 1 / -1;
}

.field-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.field-group input, .field-group select, .field-group textarea {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

/* Inline "upload image" button beside a URL field. */
.input-with-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-with-action input {
  flex: 1;
  min-width: 0;
}
.upload-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 0 !important;
  cursor: pointer;
}
.field-error {
  display: block;
  font-size: 0.75rem;
  color: #ffc9c9;
  margin-top: 4px;
}

.pos-inputs {
  display: flex;
  gap: 8px;
}

/* The X/Y number inputs must be allowed to shrink (min-width: 0) and share
   the cell evenly, otherwise their intrinsic width overflows the grid cell
   and the Y input spills over the neighboring field (e.g. the zoom slider). */
.pos-inputs input {
  flex: 1 1 0%;
  min-width: 0;
}

.scene-tabs-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.scene-tab-item {
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  white-space: nowrap;
}

.scene-tab-item.active {
  background: var(--color-gold);
  color: #0b0f19;
  font-weight: 600;
}

.node-editor-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.node-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.node-idx {
  font-weight: 700;
  color: var(--color-gold);
}

.node-id-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.editor-footer {
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES & MOBILE OPTIMIZATIONS
   ========================================================================== */

/*
 * All scene + splash images are now rendered via <img> with object-fit,
 * so the browser handles responsive sizing natively — no aspect-ratio
 * media queries needed.
 */

/* Tablet & Mobile devices */
@media (max-width: 768px) {
  .splash-content {
    width: 92%;
    padding: 28px 20px;
  }

  .story-title {
    font-size: 2.1rem;
  }

  .story-subtitle {
    font-size: 1.05rem;
  }

  .story-intro-teaser {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .scene-header {
    height: 60px;
    padding: 0 12px;
  }

  .reader-greeting {
    display: none;
  }

  .progress-indicator-bar {
    padding: 6px 12px;
    gap: 8px;
  }

  .scene-title {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .symbol-core {
    width: 48px;
    height: 48px;
  }

  .floating-symbol-container:hover .symbol-core {
    transform: scale(1.15);
  }

  .symbol-tooltip {
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  .story-panel-card {
    padding: 24px 20px;
    width: 94%;
  }

  .passage-text {
    font-size: 1.15rem;
    line-height: 1.55;
    margin-bottom: 20px;
  }

  .action-buttons {
    gap: 8px;
  }

  .btn-primary, .btn-secondary {
    font-size: 0.85rem;
    padding: 10px 16px;
  }

  .editor-modal-card {
    width: 98%;
    height: 96vh;
  }

  .editor-header {
    padding: 12px 16px;
  }

  .editor-body {
    padding: 14px;
  }

  .editor-footer {
    padding: 12px 16px;
  }

  .footer-left, .footer-right {
    gap: 8px;
  }

  .footer-right .btn-primary {
    padding: 10px 18px;
    gap: 6px;
  }

  .footer-right .btn-primary span {
    display: inline;
  }
}

/* 500px — wrap right-side header controls so the Story Name stays fully visible */
@media (max-width: 500px) {
  .scene-header {
    height: auto;
    min-height: 60px;
    padding: 8px 12px;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

}

/* Compact screens — wrap header items so right-side controls never overflow */
@media (max-width: 680px) {
  .scene-header {
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    row-gap: 8px;
    column-gap: 12px;
    padding: 8px 12px;
    justify-content: flex-start;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-center {
    flex: 1 1 100%;
    order: 3;
    display: flex;
    justify-content: center;
  }

  .header-right {
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }

  /* Editor: stack header title + tabs vertically on compact screens */
  .editor-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .editor-header .icon-btn.close-editor {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
  }

  .header-title-group h2 {
    font-size: 0.9rem;
  }

  .editor-tab-switcher {
    align-self: center;
  }

  .tab-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  /* Editor footer: stack buttons full-width */
  .editor-footer {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
  }

  .footer-left, .footer-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Small smartphone portrait screens */
@media (max-width: 480px) {
  .story-title {
    font-size: 1.75rem;
  }

  .action-buttons {
    flex-direction: column;
    width: 100%;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
  }

  /* Prevent small inline upload and reorder buttons from stretching to full width */
  .input-with-action .upload-action,
  .reorder-btn {
    width: 40px;
    min-width: 40px;
  }

  /* Editor footer: keep buttons inline rather than full-width */
  .editor-footer .btn-secondary,
  .editor-footer .btn-primary {
    width: auto;
  }

  .symbol-core {
    width: 44px;
    height: 44px;
  }
}

/* ==========================================================================
   END STORY / STOP AUDIO BUTTON
   Distinctive destructive action separated from primary navigation.
   Base class: .btn-secondary.danger (red-tinted text + border).
   Extra treatment: subtle red glow, lift on hover, red focus ring,
   and a hairline separator above to keep it out of the main action group.
   ========================================================================== */

.action-separator {
  width: 100%;
  height: 1px;
  background: rgba(245, 101, 101, 0.15);
  margin: 4px 0;
  border: 0;
  flex: 0 0 100%;
}

.stop-story-btn {
  margin-top: 4px;
  box-shadow: 0 0 12px rgba(245, 101, 101, 0.15);
}

.stop-story-btn:hover {
  background: rgba(245, 101, 101, 0.25);
  border-color: rgba(245, 101, 101, 0.6);
  box-shadow: 0 0 20px rgba(245, 101, 101, 0.25);
  transform: translateY(-1px);
}

.stop-story-btn:active {
  transform: translateY(0);
}

.stop-story-btn:focus-visible {
  outline: 2px solid rgba(245, 101, 101, 0.7);
  outline-offset: 2px;
}

/* Mobile: keep label readable on very small screens */
@media (max-width: 400px) {
  .stop-story-btn {
    font-size: 0.82rem;
    padding: 8px 16px;
  }
}

/* ==========================================================================
   SIGIL TEXT ELEMENTS
   Reader-facing sigil copy. New selectors only — no existing rule is
   modified or overridden, so surrounding layout keeps its current values.
   ========================================================================== */

/* Story cover line — sits directly under .story-title inside .splash-content.
   Kept to one short line so the cover action buttons stay in view. */
.sigil-cover-line {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--color-gold);
  opacity: 0.85;
  text-shadow: 0 0 18px var(--color-gold-glow);
}

/* First-scene status pill — fixed above the scene layer, below the passage
   panel (.story-panel-backdrop, z-index 100). pointer-events: none keeps it
   from intercepting clicks on floating sigils or scene controls. */
.sigil-hint {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 15;
  max-width: min(90vw, 28rem);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: rgba(10, 10, 20, 0.72);
  border: 1px solid var(--color-gold);
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 16px var(--color-gold-glow);
  animation: sigil-hint-in 0.6s ease-out;
  transition: opacity 0.45s ease;
}

@keyframes sigil-hint-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Leaving state — cancels the entrance keyframe so the opacity transition
   (declared on .sigil-hint) can run to completion. */
.sigil-hint.is-leaving {
  opacity: 0;
  animation: none;
  transition: opacity 0.45s ease;
}

@media (prefers-reduced-motion: reduce) {
  .sigil-hint {
    animation: none;
  }
}

/* End-of-story card — serif gold line between the card h2 and
   .scene-complete-text. */
.sigil-end-heading {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--color-gold);
  margin: 0 0 0.75rem;
}

/* Narrow screens: trim the cover line so it stays on one line and the
   .splash-form .action-buttons group below it remains fully visible. */
@media (max-width: 480px) {
  .sigil-cover-line {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
  }
}

/* ==========================================================================
   Sigil Tales — application shell (auth gate, header, library, roles)
   Complements index.css. Uses the same tokens (--color-gold, --glass-*).
   ========================================================================== */

/* Inputs must stay selectable even though the app disables selection globally. */
input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
  font-family: var(--font-body);
}

/* App root: fills the viewport and lets the active screen own its scroll. */
.book-cloud-app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Shared frosted panel. */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.spin { animation: bcSpin 0.9s linear infinite; }
@keyframes bcSpin { to { transform: rotate(360deg); } }

/* ---- Boot splash ---- */
.app-boot {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.app-boot svg { color: var(--color-gold); }

/* ---- Role pills ---- */
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}
.role-pill.admin {
  color: #ffd9a0;
  background: rgba(243, 208, 129, 0.14);
  border-color: rgba(243, 208, 129, 0.45);
}
.role-pill.creator {
  color: #b6ecff;
  background: rgba(64, 224, 208, 0.13);
  border-color: rgba(64, 224, 208, 0.4);
}
.role-pill.reader {
  color: #d6c8ff;
  background: rgba(147, 112, 219, 0.16);
  border-color: rgba(147, 112, 219, 0.42);
}

/* ==========================================================================
   AUTH SCREEN
   ========================================================================== */

.auth-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

@media (max-width: 600px) {
  .auth-screen {
    overflow-y: auto;
    align-items: flex-start;
  }
}

.auth-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 520px;
  padding: 34px 32px 26px;
  margin: auto;
  animation: fadeIn 0.5s ease both;
}

/* Scrollbar styling for auth-card */
.auth-card::-webkit-scrollbar {
  width: 6px;
}
.auth-card::-webkit-scrollbar-track {
  background: transparent;
}
.auth-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.auth-card:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.auth-brand-icon {
  color: var(--color-gold);
  filter: drop-shadow(0 0 12px var(--color-gold-glow));
}
.auth-brand-title {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
}
.auth-brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  margin-bottom: 20px;
}
.auth-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.auth-tab:hover { color: var(--text-main); }
.auth-tab.active {
  color: #1a1408;
  background: linear-gradient(135deg, var(--color-gold), #e8b95f);
  box-shadow: 0 6px 20px var(--color-gold-glow);
}

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 16px;
}
.auth-alert svg { flex-shrink: 0; margin-top: 1px; }
.auth-alert.error {
  color: #ffc9c9;
  background: rgba(245, 101, 101, 0.14);
  border: 1px solid rgba(245, 101, 101, 0.4);
}
.auth-alert.success {
  color: #c4f5d4;
  background: rgba(72, 199, 116, 0.14);
  border: 1px solid rgba(72, 199, 116, 0.4);
}

.auth-form { display: flex; flex-direction: column; gap: 15px; }

.auth-field { display: flex; flex-direction: column; gap: 7px; flex: 1; }
.auth-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.auth-label svg { color: var(--color-gold); opacity: 0.85; }

.auth-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.98rem;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input::placeholder { color: rgba(160, 174, 192, 0.55); }
.auth-input:focus {
  border-color: rgba(243, 208, 129, 0.65);
  box-shadow: 0 0 0 3px rgba(243, 208, 129, 0.14);
}

.auth-row { display: flex; gap: 12px; }

.auth-submit { width: 100%; margin-top: 4px; }

.auth-link {
  align-self: center;
  font-size: 0.83rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-link:hover { color: var(--color-gold); }

.auth-hint {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}
.auth-hint strong { color: var(--color-gold); font-weight: 600; }

.auth-verify-btn { width: 100%; margin-bottom: 16px; }

.auth-roles {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}

@media (max-width: 520px) {
  .auth-row { flex-direction: column; }
  .auth-card { padding: 26px 20px 20px; }
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */

.app-header {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(8, 10, 16, 0.82);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  flex-shrink: 0;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.app-brand-icon { color: var(--color-gold); filter: drop-shadow(0 0 10px var(--color-gold-glow)); }
.app-brand-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.app-brand-text strong { font-family: var(--font-serif); font-size: 1.16rem; letter-spacing: 0.01em; }
.app-brand-text small { font-size: 0.64rem; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }

.app-nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.app-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.app-nav-btn:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.07); }
.app-nav-btn.active {
  color: var(--color-gold);
  background: rgba(243, 208, 129, 0.12);
  border-color: rgba(243, 208, 129, 0.35);
}

.app-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.app-username {
  font-size: 0.88rem;
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}
.app-logout:hover { color: #ffc9c9; border-color: rgba(245, 101, 101, 0.5); background: rgba(245, 101, 101, 0.1); }

/* Narration Toggle */
.narration-toggle {
  transition: all 0.2s ease;
}
.narration-toggle.narration-on {
  color: #48bb78;
  border-color: rgba(72, 187, 120, 0.4);
  background: rgba(72, 187, 120, 0.05);
}
.narration-toggle.narration-on:hover {
  background: rgba(72, 187, 120, 0.1);
  border-color: rgba(72, 187, 120, 0.6);
}
.narration-toggle.narration-off {
  color: #f56565;
  border-color: rgba(245, 101, 101, 0.4);
  background: rgba(245, 101, 101, 0.05);
}
.narration-toggle.narration-off:hover {
  background: rgba(245, 101, 101, 0.1);
  border-color: rgba(245, 101, 101, 0.6);
}

/* Hamburger menu toggle — hidden on desktop, shown under 912px. */
.app-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
}
.app-menu-toggle:hover { background: rgba(255, 255, 255, 0.09); }

/* Dropdown menu (mobile) — anchored under the header, right-aligned. */
.app-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 14px;
  z-index: 40;
  min-width: 230px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(10, 13, 20, 0.96);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.18s ease both;
}
.app-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
}
.app-menu-item:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.07); }
.app-menu-item.active { color: var(--color-gold); background: rgba(243, 208, 129, 0.12); }
.app-menu-divider { height: 1px; margin: 6px 8px; background: var(--glass-border); }
.app-menu-logout { color: #ffc9c9; }
.app-menu-logout:hover { color: #ffc9c9; background: rgba(245, 101, 101, 0.12); }

/* ==========================================================================
   LIBRARY / STUDIO / ADMIN SHELLS
   ========================================================================== */

.home-screen,
.studio-screen,
.admin-screen {
  position: relative;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 34px clamp(18px, 4vw, 52px) 64px;
}

.home-screen::before,
.studio-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(147, 112, 219, 0.13), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

.home-hero { position: relative; z-index: 2; margin-bottom: 24px; }
.home-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.home-subtitle { margin-top: 6px; font-size: 0.96rem; color: var(--text-muted); max-width: 62ch; }

.home-alert { position: relative; z-index: 2; max-width: 720px; }

.home-toolbar { position: relative; z-index: 2; display: flex; gap: 12px; margin-bottom: 22px; }

.new-story-form {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  padding: 20px;
  margin-bottom: 26px;
  max-width: 780px;
  animation: fadeIn 0.3s ease both;
}
.new-story-form .auth-field { min-width: 220px; }
.new-story-form button { align-self: flex-end; }

.home-loading {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 70px 0;
  color: var(--color-gold);
}
.home-loading.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 0;
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(4px);
}

.home-empty {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 70px 20px;
  text-align: center;
  color: var(--text-muted);
}
.home-empty svg { color: rgba(243, 208, 129, 0.5); }

/* ---- Story grid ---- */
.story-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 22px;
}

.story-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.story-card:hover {
  transform: translateY(-4px);
  border-color: rgba(243, 208, 129, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.story-card.draft { opacity: 0.92; }

/* Cards you can click to open the story get a pointer + a focus ring. */
.story-card-openable { cursor: pointer; }
.story-card-openable:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

.story-cover {
  position: relative;
  height: 158px;
  background-color: #0d111c;
  background-size: cover;
  background-position: center;
}
.story-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(13, 17, 28, 0.96));
}
.story-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(6px);
}
.story-badge.published { color: #c4f5d4; background: rgba(72, 199, 116, 0.24); border: 1px solid rgba(72, 199, 116, 0.5); }
.story-badge.draft { color: #ffe3b0; background: rgba(243, 208, 129, 0.2); border: 1px solid rgba(243, 208, 129, 0.5); }

.story-body { display: flex; flex-direction: column; flex: 1; gap: 8px; padding: 16px 18px 18px; }
.story-card-title {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.25;
}
.story-card-desc {
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-card-meta { font-size: 0.76rem; color: rgba(160, 174, 192, 0.8); letter-spacing: 0.03em; }

.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}
.story-actions .btn-primary,
.story-actions .btn-secondary { flex: 1 1 auto; padding: 9px 13px; font-size: 0.83rem; }
.story-actions .btn-secondary span { white-space: nowrap; }

.admin-reorder-group {
  display: flex;
  gap: 4px;
  flex: 0 0 auto;
}

.reorder-btn {
  flex: 0 0 auto !important;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reorder-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ==========================================================================
   ADMIN — user management
   ========================================================================== */

.user-table { position: relative; z-index: 2; overflow: hidden; max-width: 900px; }

.user-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.4fr) minmax(210px, 1fr) 90px 130px 44px;
  align-items: center;
  gap: 16px;
  padding: 15px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.user-row:last-child { border-bottom: none; }
.user-head {
  padding: 12px 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}

.user-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  font-weight: 700;
  color: #1a1408;
  background: linear-gradient(135deg, var(--color-gold), #c9a24f);
}
.user-id strong { display: block; font-size: 0.94rem; font-weight: 600; }
.user-self { font-style: normal; font-size: 0.78rem; color: var(--text-muted); }
.user-email {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-control { display: flex; align-items: center; gap: 10px; }
.role-select {
  padding: 7px 11px;
  font-size: 0.84rem;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}
.role-select:focus { border-color: rgba(243, 208, 129, 0.6); }
.role-select:disabled { opacity: 0.55; cursor: wait; }

.user-status { display: flex; align-items: center; gap: 8px; font-size: 0.83rem; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.verified { background: #48c774; box-shadow: 0 0 9px rgba(72, 199, 116, 0.8); }
.status-dot.unverified { background: #f6ad55; box-shadow: 0 0 9px rgba(246, 173, 85, 0.7); }

.user-stories {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.user-actions { display: flex; justify-content: flex-end; }
.user-delete { padding: 7px 9px; line-height: 1; }
.user-delete:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 944px) {
  .app-header { gap: 12px; padding: 10px 14px; }
  .app-nav { display: none; }
  .app-logout { display: none; }
  .app-menu-toggle { display: inline-flex; }
  .app-brand-text small { display: none; }
  .app-username { display: inline-block; }
  .user-row { grid-template-columns: 1fr; gap: 10px; }
  .user-head { display: none; }
}

@media (max-width: 560px) {
  .app-logout span { display: none; }
  .home-screen, .studio-screen, .admin-screen { padding: 22px 14px 48px; }
  .story-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   SW Update Toast
   Fixed bottom-centre banner that slides up when a new service worker has
   activated. Tap "Refresh" to reload with the new version immediately.
   ========================================================================== */

@keyframes swToastSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(100%); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sw-update-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;

  display: flex;
  align-items: center;
  gap: 14px;

  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: rgba(13, 17, 28, 0.88);
  border: 1px solid rgba(134, 59, 255, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(134, 59, 255, 0.2);

  white-space: nowrap;
  animation: swToastSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.sw-update-toast__text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  letter-spacing: 0.01em;
}

.sw-update-toast__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #863bff 0%, #6020cc 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.sw-update-toast__btn:hover,
.sw-update-toast__btn:focus-visible {
  opacity: 0.85;
}

@media (max-width: 499px) {
  .app-user {
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
  }
  .app-username {
    font-size: 0.75rem;
    line-height: 1;
    margin: 0;
  }
}

@media (max-width: 420px) {
  .sw-update-toast {
    bottom: 16px;
    left: 16px;
    right: 16px;
    transform: none;
    white-space: normal;
  }
  @keyframes swToastSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
/* 
  Sigil Tales Library Lobby Styles
  Extends the futuristic dark sci-fi language of index.css/app-shell.css
*/

.lobby-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: var(--bg-dark);
  color: var(--text-main);
  position: relative;
  overflow: hidden;
}

.lobby-header {
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  z-index: 100;
}

.lobby-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: none;
  border: none;
  color: var(--color-gold);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.lobby-brand:hover {
  background: rgba(255,255,255,0.05);
}

.lobby-brand-icon {
  filter: drop-shadow(0 0 8px var(--color-gold-glow));
}

.lobby-brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.lobby-brand-text strong {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.lobby-brand-text small {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

.lobby-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lobby-nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lobby-nav-btn:hover {
  color: var(--text-main);
  background: rgba(255,255,255,0.08);
}

.lobby-nav-btn.active {
  color: var(--color-gold);
  background: rgba(243, 208, 129, 0.12);
}

.lobby-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  padding: 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-md);
}

.lobby-mobile-menu {
  position: absolute;
  top: 72px;
  right: 1rem;
  min-width: 230px;
  z-index: 110;
  background: rgba(8, 10, 16, 0.98);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: slideInDown 0.2s ease-out;
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}


.lobby-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lobby-enter-btn {
  height: 36px;
  padding: 0 1.25rem;
  font-size: 0.85rem;
}

.lobby-signout-btn {
  height: 36px;
  padding: 0 1rem;
  font-size: 0.85rem;
}

.lobby-view-wrapper {
  flex: 1;
  position: relative;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* --- Entrance Hall --- */
.entrance-hall {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  position: relative;
}

.entrance-hero-slides {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

.entrance-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2s ease-in-out, transform 8s linear;
  transform: scale(1.05);
}

.entrance-slide.active {
  opacity: 0.8;
  transform: scale(1.15);
}

.entrance-hero-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(0,0,0,0), var(--bg-dark) 90%);
  pointer-events: none;
  z-index: 1;
}

.entrance-content {
  max-width: 800px;
  text-align: center;
  z-index: 10;
  animation: entrance-fade-in 1s ease-out;
}

@keyframes entrance-fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.entrance-title {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 300;
  color: var(--color-gold);
  margin-bottom: 1rem;
  text-shadow: 0 0 30px var(--color-gold-glow);
  letter-spacing: -0.01em;
}

.entrance-tagline {
  font-size: 1.25rem;
  color: var(--text-main);
  max-width: 600px;
  margin: 0 auto 3rem;
  line-height: 1.6;
  opacity: 0.9;
}

.entrance-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.entrance-btn {
  min-width: 200px;
  height: 52px;
  font-size: 1rem;
}

/* --- Shelves --- */
.shelves-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.shelves-header {
  margin-bottom: 4rem;
  border-left: 3px solid var(--color-gold);
  padding-left: 1.5rem;
}

.shelves-header h2 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  color: var(--color-gold);
}

.shelves-header p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.shelf-section {
  margin-bottom: 5rem;
}

.shelf-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-main);
  opacity: 0.8;
}

.shelf-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--glass-border), transparent);
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2.5rem;
  padding: 0.5rem;
}

.shelf-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.shelf-item:hover {
  transform: translateY(-8px);
  border-color: var(--color-gold);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 15px rgba(243, 208, 129, 0.1);
}

.shelf-item-cover {
  width: 100%;
  aspect-ratio: 2/3;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

.shelf-item-shimmer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.08) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.shelf-item:hover .shelf-item-shimmer {
  transform: translateX(100%);
}

.shelf-item-info {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.shelf-item-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.shelf-item-part {
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--color-gold);
  margin: 0 0 0.5rem;
}

.shelf-item-author {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Book Detail --- */
.book-detail-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 4rem;
}

.book-detail-aside {
  position: sticky;
  top: 4rem;
}

.book-detail-cover {
  width: 100%;
  aspect-ratio: 2/3;
  border-radius: var(--radius-lg);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  margin-bottom: 2rem;
}

.book-detail-cta {
  width: 100%;
  height: 56px;
  font-size: 1.1rem;
}

.book-detail-genre {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.book-detail-main h1 {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  color: var(--color-gold);
  margin-bottom: 0.5rem;
  line-height: 1;
}

.book-detail-author {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.author-link {
  color: var(--color-gold);
  text-decoration: none;
  cursor: pointer;
}

.author-link:hover {
  text-decoration: underline;
}

.book-detail-synopsis {
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-main);
  opacity: 0.9;
  margin-bottom: 4rem;
  white-space: pre-wrap;
}

/* --- Reviews --- */
.reviews-section {
  border-top: 1px solid var(--glass-border);
  padding-top: 4rem;
}

.reviews-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  gap: 2rem;
}

.reviews-summary {
  display: flex;
  align-items: center;
  gap: 3rem;
}

.overall-score {
  text-align: center;
}

.overall-score-num {
  display: block;
  font-size: 4rem;
  font-weight: 300;
  color: var(--color-gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.overall-score-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.category-scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem 2.5rem;
}

.cat-score {
  min-width: 140px;
}

.cat-score-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.cat-score-header span:last-child {
  color: var(--color-gold);
  font-variant-numeric: tabular-nums;
}

.cat-score-bar {
  height: 4px;
  background: rgba(243, 208, 129, 0.22);
  border-radius: 2px;
  overflow: hidden;
}

.cat-score-fill {
  height: 100%;
  background: var(--color-gold);
  box-shadow: 0 0 8px var(--color-gold-glow);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 4rem;
}

.review-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.review-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.review-card-user {
  font-weight: 600;
  color: var(--color-gold);
}

.review-card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.review-card-comment {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
  opacity: 0.85;
}

.review-editor {
  background: var(--glass-bg);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-top: 4rem;
}

.review-editor-title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: 2rem;
  color: var(--color-gold);
}

.review-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem 3rem;
  margin-bottom: 2.5rem;
}

.review-slider-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.review-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 500;
}

.review-slider-val {
  color: var(--color-gold);
}

.review-input-range {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(243, 208, 129, 0.28);
  border-radius: 2px;
  outline: none;
}

.review-input-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--color-gold);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.review-comment-field {
  margin-bottom: 2.5rem;
}

.review-textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 1rem;
  font-family: inherit;
  resize: vertical;
}

.review-textarea:focus {
  border-color: var(--color-gold);
  outline: none;
}

.review-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* --- Author Profile --- */
.author-profile-view {
  max-width: 1000px;
  margin: 0 auto;
  padding: 6rem 2rem;
}

.author-header {
  display: flex;
  align-items: center;
  gap: 3rem;
  margin-bottom: 5rem;
}

.author-photo {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid var(--color-gold);
  padding: 5px;
  box-shadow: 0 0 20px var(--color-gold-glow);
  background: var(--bg-dark);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.author-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.author-photo-placeholder {
  font-family: var(--font-serif);
  font-size: 4rem;
  color: var(--color-gold);
}

.author-info h1 {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  margin-bottom: 1rem;
  color: var(--color-gold);
}

.author-bio {
  font-size: 1.1rem;
  line-height: 1.6;
  opacity: 0.8;
  white-space: pre-wrap;
}

/* --- Misc Screens --- */
.lobby-static-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 8rem 2rem;
}

.lobby-static-view h2 {
  font-family: var(--font-serif);
  font-size: 3rem;
  color: var(--color-gold);
  margin-bottom: 2rem;
}

.lobby-static-view p {
  font-size: 1.2rem;
  line-height: 1.8;
  margin-bottom: 2rem;
  opacity: 0.9;
}

/* --- Teleport --- */
.teleport-transition {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow: hidden;
}

.teleport-transition.active {
  opacity: 1;
  pointer-events: all;
}

.teleport-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(8, 10, 16, 0.72) 0%, rgba(5, 6, 10, 0.97) 60%, #05060a 100%);
  backdrop-filter: blur(10px);
}

.teleport-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--color-gold);
  border-radius: 50%;
  opacity: 0;
}

.teleport-transition.active .teleport-ring {
  animation: teleport-ring 1.35s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.teleport-ring.ring-1 { width: 90px; height: 90px; animation-delay: 0s; }
.teleport-ring.ring-2 { width: 190px; height: 190px; animation-delay: 0.08s; }
.teleport-ring.ring-3 { width: 340px; height: 340px; animation-delay: 0.16s; }

.teleport-sweep {
  position: absolute;
  left: -50%;
  width: 200%;
  height: 110px;
  background: linear-gradient(to bottom, transparent, var(--color-gold-glow), transparent);
  transform: rotate(35deg) translateY(120vh);
  opacity: 0;
}

.teleport-transition.active .teleport-sweep {
  animation: teleport-sweep 1.15s ease-in-out forwards;
}

.teleport-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
}

.teleport-transition.active .teleport-flash {
  animation: teleport-flash 1.45s ease-out forwards;
}

@keyframes teleport-ring {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; border-width: 9px; }
  45% { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(4.2); opacity: 0; border-width: 1px; }
}

@keyframes teleport-sweep {
  0% { transform: rotate(35deg) translateY(120vh); opacity: 0; }
  30% { opacity: 0.55; }
  60% { opacity: 0.55; }
  100% { transform: rotate(35deg) translateY(-120vh); opacity: 0; }
}

@keyframes teleport-flash {
  0% { opacity: 0; }
  86% { opacity: 0; }
  91% { opacity: 0.95; }
  100% { opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 944px) {
  .lobby-header { padding: 0 1rem; }
  .lobby-nav { display: none; }
  .lobby-mobile-toggle { display: flex; }
  .lobby-enter-btn { display: none; }
  .lobby-signout-btn { display: none; }
  .book-detail-view { grid-template-columns: 1fr; gap: 3rem; }
  .book-detail-aside { position: static; max-width: 350px; margin: 0 auto; }
  .author-header { flex-direction: column; text-align: center; gap: 2rem; }
  .category-scores { grid-template-columns: 1fr; }
}

@media (max-width: 499px) {
  .app-user {
    flex-direction: column;
    align-items: flex-end !important;
    gap: 4px !important;
  }
  .app-username {
    font-size: 0.75rem;
    line-height: 1;
    margin: 0;
  }
  .entrance-title { font-size: 3rem; }
  .entrance-actions { flex-direction: column; width: 100%; }
  .entrance-btn { width: 100%; }
  .shelf-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   ENTRANCE HALL — SIGIL EXPLAINER
   Sits between .entrance-tagline and .entrance-actions. The negative top
   margin absorbs the tagline's existing 3rem gap (adjacent sibling margins
   collapse), so the three action buttons keep their vertical position on
   narrow screens. New selector only — .entrance-tagline is untouched.
   ========================================================================== */

.entrance-sigil-explainer {
  max-width: 34rem;
  margin: -1.5rem auto 1.75rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-main);
  opacity: 0.9;
  text-align: center;
}

.entrance-sigil-explainer strong {
  color: var(--color-gold);
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 499px) {
  .entrance-sigil-explainer {
    margin: -1rem auto 1.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
  }
}

/* Short viewports (small phones, landscape): compress the explainer so the
   three entrance buttons stay on screen without scrolling. */
@media (max-height: 700px) {
  .entrance-sigil-explainer {
    margin: -1.25rem auto 0.75rem;
    font-size: 0.85rem;
    line-height: 1.45;
  }
}
