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

:root {
  --primary-color: #6366f1;
  --secondary-color: #8b5cf6;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --bg-color: #f9fafb;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-color);
  line-height: 1.6;
}

.header {
  text-align: center;
  padding: 2rem 1rem;
  color: white;
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.95;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: white;
}

.spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top: 4px solid white;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Start Screen */
.start-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.welcome-card {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 3rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 800px;
  width: 100%;
}

.welcome-card h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.welcome-card p {
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

/* Genre Grid */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.genre-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.genre-button:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.genre-button:active {
  transform: translateY(-2px);
}

.genre-icon {
  font-size: 3rem;
  line-height: 1;
}

.genre-name {
  font-size: 1.3rem;
  font-weight: 600;
}

.genre-desc {
  font-size: 0.9rem;
  opacity: 0.9;
}

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

  .genre-button {
    padding: 1.5rem 1rem;
  }

  .genre-icon {
    font-size: 2.5rem;
  }

  .genre-name {
    font-size: 1.1rem;
  }

  .genre-desc {
    font-size: 0.8rem;
  }
}

/* Story Screen */
.story-screen {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .story-screen {
    grid-template-columns: 2fr 1fr;
  }
}

.story-card {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.page-number {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.story-content {
  margin-bottom: 2rem;
}

.story-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.story-text {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-color);
  white-space: pre-wrap;
  margin-bottom: 2rem;
}

/* Choices */
.choices-container {
  margin: 2rem 0;
}

.choice-button {
  display: block;
  width: 100%;
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
  box-shadow: var(--shadow);
}

.choice-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.choice-button:active {
  transform: translateY(0);
}

.choice-number {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  margin-right: 0.75rem;
  font-weight: 600;
}

/* Story Actions */
.story-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

/* History Panel */
.history-panel {
  background: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-height: 600px;
  overflow-y: auto;
}

.history-panel h3 {
  margin-bottom: 1rem;
  color: var(--text-color);
  font-size: 1.2rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  padding: 0.75rem;
  background: var(--bg-color);
  border-radius: 0.5rem;
  border-left: 3px solid var(--primary-color);
  font-size: 0.9rem;
  color: var(--text-light);
}

.history-item.current {
  background: #eef2ff;
  border-left-color: var(--secondary-color);
  font-weight: 600;
  color: var(--text-color);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-color);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

.btn-outline {
  background: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-outline:hover {
  background: var(--primary-color);
  color: white;
}

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

/* Utility */
.hidden {
  display: none !important;
}

/* Scrollbar */
.history-panel::-webkit-scrollbar {
  width: 8px;
}

.history-panel::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb:hover {
  background: #d1d5db;
}
