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

:root {
  --bg-dark: #1a1a4e;
  --bg-light: #2d1b69;
  --card-bg: rgba(100, 80, 180, 0.35);
  --card-border: rgba(180, 160, 240, 0.3);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --accent-pink: #ff6b9d;
  --accent-orange: #ffa94d;
  --accent-yellow: #ffe066;
  --accent-teal: #4dd4ac;
  --accent-purple: #9d6bff;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-light) 50%, #3d2080 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Stars background */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 215, 0, 0.6) 50%, transparent 100%);
  border-radius: 50%;
  animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

/* Floating book */
.floating-book {
  text-align: center;
  margin-bottom: 1rem;
  animation: float 3s ease-in-out infinite;
}

.book-emoji {
  font-size: 4rem;
  display: inline-block;
  filter: drop-shadow(0 0 20px rgba(255, 200, 100, 0.5));
}

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

/* Gradient title */
.gradient-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-pink), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 0.5rem;
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

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

/* Home screen */
.home-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.home-title {
  font-size: 3rem;
}

.home-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

/* Action buttons */
.action-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 0.875rem 1.5rem;
  border-radius: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.action-btn:hover {
  transform: translateY(-2px);
  background: rgba(120, 100, 200, 0.5);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.action-btn.primary {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  border: none;
}

.action-btn.primary:hover {
  background: linear-gradient(135deg, #ff7daa, #ab7dff);
}

.action-btn.large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Back button */
.back-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.back-btn:hover {
  background: rgba(120, 100, 200, 0.5);
}

.back-btn.top-left {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 10;
}

/* Selection container */
.select-container {
  flex: 1;
  padding: 2rem;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Selection screen */
.selection-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2rem;
}

.screen-title {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.5rem;
}

.screen-subtitle {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 2rem;
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns), 1fr);
  gap: 1rem;
  width: 100%;
  max-width: 900px;
  padding: 0 1rem;
}

@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Selection card */
.selection-card {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
  position: relative;
}

.selection-card:hover {
  transform: scale(1.03);
  background: rgba(120, 100, 200, 0.45);
  box-shadow: 0 8px 30px rgba(100, 50, 200, 0.3);
}

.selection-card.selected {
  border-color: var(--accent-pink);
  box-shadow: 0 0 20px rgba(255, 107, 157, 0.4);
  background: rgba(140, 100, 200, 0.5);
}

.card-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.check-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
}

/* Progress indicator */
.progress-indicator {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 2rem 0;
  margin-top: auto;
}

.progress-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(100, 80, 180, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.progress-dot.active {
  background: var(--card-bg);
  border-color: var(--accent-pink);
  transform: scale(1.15);
}

.progress-dot.completed {
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-purple));
}

/* Loading screen */
.loading-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
  text-align: center;
}

.loading-messages {
  margin: 1.5rem 0;
  min-height: 60px;
}

.primary-message {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.secondary-message {
  font-size: 1rem;
  color: var(--text-secondary);
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  max-width: 400px;
  height: 12px;
  background: rgba(100, 80, 180, 0.3);
  border-radius: 6px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-pink), var(--accent-orange), var(--accent-yellow), var(--accent-teal), var(--accent-purple));
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  border-radius: 6px;
  transition: width 0.3s ease;
}

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

.progress-text {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.helper-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Selections summary */
.selections-summary {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  margin-top: 2rem;
  backdrop-filter: blur(10px);
  max-width: 500px;
  width: 100%;
}

.summary-title {
  font-weight: 700;
  margin-bottom: 1rem;
}

.summary-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.tag {
  background: rgba(150, 120, 220, 0.4);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Story reader */
.story-reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}

.story-cover {
  text-align: center;
  max-width: 500px;
}

.cover-image {
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  margin-bottom: 1.5rem;
  border: 4px solid rgba(180, 160, 240, 0.3);
}

.story-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.story-meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.story-page {
  max-width: 600px;
  padding: 2rem;
  background: var(--card-bg);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.story-text {
  font-size: 1.1rem;
  line-height: 1.8;
  text-align: center;
}

.nav-hint {
  position: absolute;
  bottom: 5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.page-dots {
  position: absolute;
  bottom: 2rem;
  display: flex;
  gap: 0.5rem;
}

.page-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.page-dot.active {
  background: var(--accent-pink);
  transform: scale(1.3);
}

.page-dot:hover {
  background: rgba(255, 255, 255, 0.6);
}

/* Story end */
.story-end {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.end-card {
  text-align: center;
  max-width: 400px;
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.end-title {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(90deg, var(--accent-orange), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.end-decoration {
  font-size: 2rem;
  margin-bottom: 2rem;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Story library */
.story-library {
  flex: 1;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.library-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.library-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.library-card {
  background: var(--card-bg);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
  border: 2px solid var(--card-border);
}

.library-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(100, 50, 200, 0.3);
}

.library-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.library-card h3 {
  padding: 1rem 1rem 0.25rem;
  font-weight: 700;
}

.library-card p {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.library-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
  text-align: center;
}

.library-empty h2 {
  margin-bottom: 0.5rem;
}

.library-empty p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1rem;
  position: relative;
  z-index: 1;
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s ease;
}

.app-footer a:hover {
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 640px) {
  .gradient-title {
    font-size: 2rem;
  }
  
  .home-title {
    font-size: 2.25rem;
  }
  
  .screen-title {
    font-size: 1.5rem;
  }
  
  .card-emoji {
    font-size: 2rem;
  }
  
  .card-title {
    font-size: 0.9rem;
  }
  
  .card-desc {
    font-size: 0.75rem;
  }
  
  .selection-card {
    padding: 1rem;
  }
  
  .book-emoji {
    font-size: 3rem;
  }
  
  .story-text {
    font-size: 1rem;
    line-height: 1.7;
  }
}