/* L.I.F.E.AI - Main Styles
   Mobile-first design with 3 themes: Photographic Dark, Paper Light, Sepia
   Designed for literary readers who appreciate sophisticated aesthetics
*/

/* ===== CSS VARIABLES ===== */
:root {
  /* Font sizes */
  --base-font-size: 18px;
  --min-font-size: 14px;
  --max-font-size: 32px;

  /* Theme: Paper Light (clean, bookish) */
  --light-bg: #faf9f7;
  --light-text: #2c2c2c;
  --light-accent: #8b7355;
  --light-muted: #6b6b6b;
  --light-border: #e8e4de;
  --light-card-bg: rgba(0, 0, 0, 0.02);

  /* Theme: Photographic Dark (cinematic, sophisticated) */
  --dark-bg: #141414;
  --dark-text: #e8e8e8;
  --dark-accent: #c9a962;
  --dark-muted: #8a8a8a;
  --dark-border: rgba(255, 255, 255, 0.08);
  --dark-card-bg: rgba(255, 255, 255, 0.03);

  /* Theme: Sepia (warm, nostalgic) */
  --sepia-bg: #f5ebe0;
  --sepia-text: #4a3728;
  --sepia-accent: #a67c52;
  --sepia-muted: #7a6a5a;
  --sepia-border: #d9cdbf;
  --sepia-card-bg: rgba(166, 124, 82, 0.06);
}

/* ===== BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--base-font-size);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Landing page uses sans-serif */
#landing-page {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Story page can use custom fonts */
#story-page {
  font-family: inherit;
}

/* ===== THEME CLASSES ===== */

/* Paper Light Theme (bookish, clean) */
.theme-light {
  background-color: var(--light-bg);
  color: var(--light-text);
  --current-accent: var(--light-accent);
  --current-muted: var(--light-muted);
  --current-border: var(--light-border);
  --current-card-bg: var(--light-card-bg);
}

/* Photographic Dark Theme (Default - cinematic) */
.theme-dark {
  background-color: var(--dark-bg);
  color: var(--dark-text);
  --current-accent: var(--dark-accent);
  --current-muted: var(--dark-muted);
  --current-border: var(--dark-border);
  --current-card-bg: var(--dark-card-bg);
}

/* Sepia Theme (warm, nostalgic) */
.theme-sepia {
  background-color: var(--sepia-bg);
  color: var(--sepia-text);
  --current-accent: var(--sepia-accent);
  --current-muted: var(--sepia-muted);
  --current-border: var(--sepia-border);
  --current-card-bg: var(--sepia-card-bg);
}

/* Smooth theme transitions */
body {
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 26px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hidden {
  display: none !important;
}

/* ===== LANGUAGE SWITCHER ===== */
.language-switcher {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.lang-btn {
  padding: 8px 16px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 20px;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  background: var(--current-accent);
  color: white;
  border-color: var(--current-accent);
}

.lang-btn.active {
  background: var(--current-accent);
  color: white;
  border-color: var(--current-accent);
}

/* ===== LANDING PAGE ===== */
#landing-page {
  min-height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Subtle vignette effect for photographic feel */
#landing-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.25) 100%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.theme-dark #landing-page::before {
  opacity: 1;
}

/* Subtle grain texture for film-like quality */
#landing-page::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: overlay;
  transition: opacity 0.5s ease;
}

.theme-dark #landing-page::after {
  opacity: 0.03;
}

#landing-page > * {
  position: relative;
  z-index: 1;
}

#landing-page h1 {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: 4px;
  animation: fadeInUp 0.8s ease-out;
}

.theme-dark #landing-page h1 {
  text-shadow: 0 2px 20px rgba(201, 169, 98, 0.15);
}

#landing-page h2 {
  font-size: 1.1rem;
  font-weight: 400;
  text-align: center;
  color: var(--current-muted);
  margin-bottom: 16px;
  letter-spacing: 1px;
  animation: fadeInUp 0.8s ease-out 0.1s backwards;
}

.promo-text {
  text-align: center;
  font-size: 1rem;
  color: var(--current-muted);
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.8;
  animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

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

/* ===== SETUP SECTIONS ===== */
.setup-section {
  width: 100%;
  max-width: 600px;
  margin: 0 auto 24px;
}

.setup-section h3 {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--current-muted);
}

/* ===== GENRE GRID ===== */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.genre-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 100px;
  position: relative;
  overflow: hidden;
}

.genre-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--current-accent) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.genre-btn:hover {
  border-color: var(--current-accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.genre-btn:hover::before {
  opacity: 0.08;
}

.genre-btn.active {
  border-color: var(--current-accent);
  background: var(--current-accent);
  color: white;
  box-shadow: 0 4px 20px rgba(201, 169, 98, 0.3);
}

.genre-btn.active::before {
  opacity: 0;
}

.genre-btn .emoji {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.genre-btn .name {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: white;
}

.genre-btn .word-count {
  display: none;
}

/* ===== OPTION BUTTONS ===== */
.option-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.option-btn {
  padding: 10px 20px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.option-btn:hover {
  border-color: var(--current-accent);
}

.option-btn.active {
  background: var(--current-accent);
  border-color: var(--current-accent);
  color: white;
}

/* ===== PRIMARY BUTTON ===== */
.primary-btn {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 32px auto 0;
  padding: 18px 36px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffb3c1 0%, #ff8fa3 50%, #ffc2d1 100%);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(255, 143, 163, 0.3);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.primary-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.primary-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 35px rgba(255, 143, 163, 0.5);
  background: linear-gradient(135deg, #ffc2d1 0%, #ffb3c1 50%, #ff8fa3 100%);
}

.primary-btn:hover::before {
  transform: translateX(100%);
}

.primary-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 15px rgba(255, 143, 163, 0.4);
}

.primary-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
  background: linear-gradient(135deg, #ffb3c1 0%, #ff8fa3 100%);
}

/* Countdown animation for button */
.primary-btn.countdown-active {
  animation: pulseRose 1s ease-in-out infinite;
  background: linear-gradient(135deg, #ff8fa3 0%, #ffb3c1 50%, #ffc2d1 100%);
}

@keyframes pulseRose {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(255, 143, 163, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 8px 40px rgba(255, 143, 163, 0.6);
  }
}

.primary-btn.countdown-go {
  animation: explodeRose 0.8s ease-out forwards;
  background: linear-gradient(135deg, #ffc2d1 0%, #ffb3c1 50%, #ff8fa3 100%);
}

@keyframes explodeRose {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 12px 50px rgba(255, 143, 163, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 6px 30px rgba(255, 143, 163, 0.5);
  }
}

/* ===== TOP BAR ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: inherit;
  border-bottom: 1px solid var(--current-border);
  backdrop-filter: blur(10px);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#scene-counter {
  font-size: 0.85rem;
  color: var(--current-muted);
  margin-right: 8px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--current-accent);
  color: var(--current-accent);
}

.icon-btn .icon {
  font-size: 1rem;
}

/* ===== STORY CONTENT ===== */
.story-content {
  padding: 24px 0;
  animation: fadeIn 0.5s ease;
}

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

.scene-header {
  text-align: center;
  margin-bottom: 24px;
}

.scene-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.scene-details {
  font-size: 0.95rem;
  color: var(--current-accent);
  font-style: italic;
  margin-bottom: 16px;
}

.scene-divider {
  border: none;
  border-top: 2px solid var(--current-border);
  width: 60%;
  margin: 0 auto;
}

.scene-context {
  margin: 20px 0;
  padding: 16px;
  background: var(--current-card-bg);
  border-left: 3px solid var(--current-accent);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

.scene-context em {
  color: var(--current-accent);
}

.story-body p {
  margin-bottom: 1.5em;
  line-height: 1.8;
  text-align: justify;
}

/* ===== OPTIONS CONTAINER ===== */
.options-container {
  margin-top: 32px;
  padding: 20px;
  background: var(--current-card-bg);
  border-radius: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  margin-bottom: 12px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.option-item:last-child {
  margin-bottom: 0;
}

.option-item:hover {
  border-color: var(--current-accent);
  transform: translateX(6px);
  background: var(--current-card-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.option-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  background: var(--current-card-bg);
  border-radius: 50%;
  border: 2px solid var(--current-border);
  transition: all 0.3s ease;
}

.option-item:hover .option-emoji {
  transform: scale(1.1);
  border-color: var(--current-accent);
  box-shadow: 0 0 20px rgba(201, 169, 98, 0.3);
}

.option-text {
  display: block;
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.5;
}

/* ===== COUNTDOWN ===== */
.countdown-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 40px;
}

.better-countdown {
  text-align: center;
}

.countdown-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--current-card-bg);
  border: 3px solid var(--current-accent);
  margin: 0 auto 16px;
  animation: pulse 1s ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.countdown-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--current-accent);
}

.countdown-text {
  font-size: 1rem;
  color: var(--current-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* ===== OPTION COUNTDOWN (Pulsating button style) ===== */
.option-item.option-countdown-active {
  animation: optionPulse 1s ease-in-out infinite;
  background: linear-gradient(135deg,
    rgba(201, 169, 98, 0.2) 0%,
    rgba(201, 169, 98, 0.3) 50%,
    rgba(201, 169, 98, 0.2) 100%);
  border-color: var(--current-accent);
  box-shadow: 0 0 30px rgba(201, 169, 98, 0.4);
  pointer-events: none;
  transform: translateX(0) !important;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

@keyframes optionPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 30px rgba(201, 169, 98, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(201, 169, 98, 0.6);
  }
}

.option-item.option-countdown-active .option-emoji,
.option-item.option-countdown-active .option-text {
  display: none;
}

.option-item .option-countdown-display {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.option-item.option-countdown-active .option-countdown-display {
  display: flex;
}

.option-countdown-number {
  font-size: 4rem;
  font-weight: 700;
  color: var(--current-accent);
  line-height: 1;
  margin-bottom: 12px;
  animation: countdownPop 1s ease-in-out;
}

@keyframes countdownPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.option-countdown-label {
  font-size: 1.1rem;
  color: var(--current-muted);
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 500;
}

.option-item.option-countdown-go {
  animation: optionExplode 0.8s ease-out forwards;
  background: linear-gradient(135deg,
    rgba(201, 169, 98, 0.4) 0%,
    rgba(201, 169, 98, 0.3) 50%,
    rgba(201, 169, 98, 0.2) 100%);
  border-color: var(--current-accent);
}

@keyframes optionExplode {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 50px rgba(201, 169, 98, 0.8);
  }
  100% {
    transform: scale(1.2);
    box-shadow: 0 0 60px rgba(201, 169, 98, 1);
    opacity: 0.8;
  }
}

/* ===== EPILOGUE ===== */
.epilogue-container {
  margin-top: 32px;
  padding: 24px;
  background: var(--current-card-bg);
  border-radius: 12px;
  border-left: 4px solid var(--current-accent);
}

.epilogue-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.epilogue-text {
  margin-bottom: 24px;
  line-height: 1.8;
}

.epilogue-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.epilogue-btn {
  padding: 14px 24px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.epilogue-btn:hover {
  border-color: var(--current-accent);
  background: var(--current-accent);
  color: white;
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  padding: 16px;
  overflow-y: auto;
}

.modal.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  margin-top: 5vh;
  background: var(--dark-bg);
  color: var(--dark-text);
  border-radius: 16px;
  overflow: hidden;
}

.theme-light .modal-content {
  background: var(--light-bg);
  color: var(--light-text);
}

.theme-sepia .modal-content {
  background: var(--sepia-bg);
  color: var(--sepia-text);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--current-border);
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.close {
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.close:hover {
  opacity: 1;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-group h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--current-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.font-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.font-btn {
  padding: 12px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.font-btn:hover {
  border-color: var(--current-accent);
}

.font-btn.active {
  border-color: var(--current-accent);
  background: var(--current-accent);
  color: white;
}

/* Font families */
body.font-system-sans { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
body.font-inter { font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif; }
body.font-roboto { font-family: 'Roboto', 'Helvetica Neue', sans-serif; }
body.font-arial { font-family: Arial, 'Helvetica Neue', sans-serif; }
body.font-georgia { font-family: Georgia, 'Times New Roman', serif; }
body.font-garamond { font-family: 'Garamond', 'Baskerville', serif; }
body.font-merriweather { font-family: 'Merriweather', Georgia, serif; }
body.font-times { font-family: 'Times New Roman', Times, serif; }

/* Landing page always sans-serif */
#landing-page, #landing-page * {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif !important;
}

/* Ensure good text contrast in all themes */
.theme-dark .primary-btn {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-light .primary-btn {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-sepia .primary-btn {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Ensure accent text is readable in all themes */
.theme-dark .scene-details {
  color: var(--dark-accent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.theme-light .scene-details {
  color: var(--light-accent);
}

.theme-sepia .scene-details {
  color: var(--sepia-accent);
}

/* Emoji background adjustments for themes */
.theme-dark .option-emoji {
  background: rgba(255, 255, 255, 0.05);
  filter: brightness(1.1);
}

.theme-light .option-emoji {
  background: rgba(0, 0, 0, 0.03);
}

.theme-sepia .option-emoji {
  background: rgba(166, 124, 82, 0.08);
}

/* Font size adjustments for better readability */
body.font-system-sans,
body.font-inter,
body.font-roboto,
body.font-arial {
  letter-spacing: -0.01em;
}

body.font-georgia,
body.font-garamond,
body.font-merriweather,
body.font-times {
  letter-spacing: 0.01em;
}

.save-load-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.save-load-section input {
  padding: 12px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  font-size: 1rem;
}

.save-load-section input::placeholder {
  color: var(--current-muted);
}

.secondary-btn {
  padding: 12px 20px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  border-color: var(--current-accent);
}

.danger-btn:hover {
  background: #e74c3c;
  border-color: #e74c3c;
  color: white;
}

.warning-text {
  font-size: 0.85rem;
  color: var(--current-muted);
  margin-bottom: 12px;
}

.saved-games-list {
  margin-top: 12px;
}

.saved-game-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.saved-game-info {
  flex: 1;
}

.saved-game-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.saved-game-meta {
  font-size: 0.8rem;
  color: var(--current-muted);
}

.saved-game-actions {
  display: flex;
  gap: 8px;
}

.saved-game-actions .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* ===== NOTIFICATION ===== */
.notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--dark-bg);
  color: var(--dark-text);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.notification-success { border-left: 4px solid #27ae60; }
.notification-error { border-left: 4px solid #e74c3c; }
.notification-warning { border-left: 4px solid #f39c12; }
.notification-info { border-left: 4px solid var(--dark-accent); }

/* ===== TEXT ALIGNMENT ===== */
body.align-left .story-body { text-align: left; }
body.align-center .story-body { text-align: center; }

/* Apply alignment to all story text elements */
body.align-left .scene-title,
body.align-left .scene-details,
body.align-left .story-text,
body.align-left .scene-context {
  text-align: left;
}

body.align-center .scene-title,
body.align-center .scene-details,
body.align-center .story-text,
body.align-center .scene-context {
  text-align: center;
}

/* ===== MARGINS ===== */
body.margins-compact .container { padding-left: 22px; padding-right: 22px; }
body.margins-normal .container { padding-left: 26px; padding-right: 26px; }
body.margins-spacious .container { padding-left: 42px; padding-right: 42px; }

/* ===== TABLET+ STYLES ===== */
@media (min-width: 768px) {
  .container {
    padding: 24px 34px;
  }

  #landing-page h1 {
    font-size: 3.5rem;
  }

  #landing-page h2 {
    font-size: 1.3rem;
  }

  .promo-text {
    font-size: 1.1rem;
  }

  .genre-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }

  .genre-btn {
    min-height: 120px;
  }

  .scene-title {
    font-size: 2.5rem;
  }

  .epilogue-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .epilogue-btn {
    flex: 1;
    min-width: 200px;
  }

  .font-options {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Larger emojis on tablet+ */
  .option-emoji {
    font-size: 3rem;
    width: 64px;
    height: 64px;
  }

  .option-item {
    padding: 24px;
  }
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 480px) {
  .option-emoji {
    font-size: 2rem;
    width: 48px;
    height: 48px;
  }

  .option-item {
    gap: 12px;
    padding: 16px;
  }

  .option-text {
    font-size: 0.95rem;
  }
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 1024px) {
  .genre-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .modal-content {
    max-width: 600px;
  }
}

/* ===== EPUB MODE ===== */
.epub-mode .container {
  max-width: 700px;
}

.epub-mode .story-content {
  padding: 40px 20px;
}

.epub-mode .top-bar {
  display: none;  /* Hide completely in EPUB fullscreen mode */
}

/* ===== LOADING STATE ===== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--current-border);
  border-top-color: var(--current-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus states for keyboard navigation */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--current-accent);
  outline-offset: 2px;
}

/* ===== SKELETON SHIMMER LOADER ===== */
.skeleton-container {
  padding: 1.5rem;
  animation: fadeIn 0.3s ease-in;
}

.skeleton-line {
  height: 1.2em;
  background: linear-gradient(
    90deg,
    var(--current-border) 0%,
    var(--current-muted) 50%,
    var(--current-border) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite ease-in-out;
  border-radius: 4px;
  margin-bottom: 0.8em;
  opacity: 0.3;
}

.skeleton-line:nth-child(1) { width: 45%; height: 1.8em; margin-bottom: 1.2em; }
.skeleton-line:nth-child(2) { width: 30%; height: 1em; margin-bottom: 1.5em; }
.skeleton-line:nth-child(3) { width: 100%; }
.skeleton-line:nth-child(4) { width: 95%; }
.skeleton-line:nth-child(5) { width: 88%; }
.skeleton-line:nth-child(6) { width: 92%; }
.skeleton-line:nth-child(7) { width: 78%; }
.skeleton-line:nth-child(8) { width: 100%; }
.skeleton-line:nth-child(9) { width: 85%; }
.skeleton-line:nth-child(10) { width: 70%; }

.skeleton-title {
  height: 2em;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-subtitle {
  height: 1em;
  width: 40%;
  margin-bottom: 2rem;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Generating message */
.generating-message {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--current-muted);
  font-style: italic;
  animation: pulse 2s infinite ease-in-out;
}

.generating-message .spinner {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  border: 2px solid var(--current-border);
  border-top-color: var(--current-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5em;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== TYPING EFFECT ===== */
.story-text.typing p {
  opacity: 0;
  animation: typeIn 0.3s ease-out forwards;
}

.story-text.typing p:nth-child(1) { animation-delay: 0.1s; }
.story-text.typing p:nth-child(2) { animation-delay: 0.25s; }
.story-text.typing p:nth-child(3) { animation-delay: 0.4s; }
.story-text.typing p:nth-child(4) { animation-delay: 0.55s; }
.story-text.typing p:nth-child(5) { animation-delay: 0.7s; }
.story-text.typing p:nth-child(6) { animation-delay: 0.85s; }
.story-text.typing p:nth-child(7) { animation-delay: 1.0s; }
.story-text.typing p:nth-child(8) { animation-delay: 1.15s; }
.story-text.typing p:nth-child(9) { animation-delay: 1.3s; }
.story-text.typing p:nth-child(10) { animation-delay: 1.45s; }
.story-text.typing p:nth-child(n+11) { animation-delay: 1.6s; }

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

/* Character-by-character typing cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--current-accent);
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Smooth scene transition */
.scene-transition-out {
  animation: sceneOut 0.4s ease-out forwards;
}

.scene-transition-in {
  animation: sceneIn 0.5s ease-out forwards;
}

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

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

/* ===== IMMERSIVE READING MODE ===== */

/* Pull indicator at top of screen */
.pull-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  padding: 8px 20px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.pull-indicator-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--current-card-bg);
  border: 1px solid var(--current-border);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  font-size: 0.75rem;
  color: var(--current-muted);
}

.pull-indicator-arrow {
  font-size: 0.9rem;
  animation: bounceDown 1.5s infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(2px); }
}

.pull-indicator.visible {
  opacity: 1;
}

.pull-indicator.pulling {
  transform: translateX(-50%) translateY(10px);
}

/* Immersive mode - hide toolbar */
.immersive-mode .top-bar {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.immersive-mode .top-bar.revealed {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Smooth transition for top-bar */
.top-bar {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
}

/* Expand content area in immersive mode */
.immersive-mode .container {
  padding-top: 0;
}

.immersive-mode #story-content {
  padding-top: 20px;
}

/* Touch/scroll detection area */
.reveal-trigger {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 99;
  pointer-events: auto;
}

/* Progress indicator during pull */
.pull-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--current-accent) 50%,
    transparent 100%);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
  z-index: 151;
}

.pull-progress.active {
  transform: scaleX(var(--pull-progress, 0));
}

/* Hide pull indicator when toolbar is revealed */
.immersive-mode .top-bar.revealed ~ .pull-indicator {
  opacity: 0 !important;
}
