:root {
  --primary: #2d1b4e;
  --secondary: #5c4b8a;
  --accent: #a67c52;
  --text: #333;
  --text-light: #666;
  --bg: #faf8f5;
  --bg-card: #fff;
  --border: #e0d8c8;
  --shadow: rgba(45, 27, 78, 0.08);
  --radius: 12px;
  --transition: 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px var(--shadow);
}

header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  text-decoration: none;
  color: white;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition);
  padding: 0.5rem 0;
}

nav a:hover {
  opacity: 0.8;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 4rem 0;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 1rem;
  font-weight: 700;
}

.hero p {
  font-size: 1.25rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.875rem 2rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

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

.btn-primary:hover {
  background: #8b6542;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(166, 124, 82, 0.3);
}

.btn-secondary {
  background: transparent;
  color: white;
  border: 2px solid white;
}

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

/* Main Content */
main {
  padding: 3rem 0;
}

section {
  margin-bottom: 4rem;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}

h3 {
  font-size: 1.5rem;
  color: var(--secondary);
  margin-bottom: 1rem;
}

/* Generator */
.generator-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 20px var(--shadow);
  max-width: 800px;
  margin: 0 auto;
}

.generator-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}

select, input[type="number"] {
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color var(--transition);
  background: white;
}

select:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--secondary);
}

.generate-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.results {
  min-height: 100px;
}

.name-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-left: 4px solid var(--accent);
}

.name-text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.name-meaning {
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: italic;
}

.name-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  padding: 0.5rem;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--primary);
  transform: scale(1.1);
}

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

.feature-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 2px solid var(--border);
  box-shadow: 0 4px 20px var(--shadow);
  transition: all var(--transition);
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 30px var(--shadow);
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

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

.race-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 20px var(--shadow);
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.race-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--shadow);
}

.race-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.race-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.race-content {
  padding: 1.5rem;
}

.race-content h3 {
  margin-bottom: 0.5rem;
}

.race-content p {
  color: var(--text-light);
  font-size: 0.95rem;
}

/* Guide Cards */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.guide-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 20px var(--shadow);
  transition: all var(--transition);
  text-decoration: none;
  color: inherit;
  display: block;
}

.guide-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--shadow);
}

.guide-card h3 {
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.guide-card p {
  color: var(--text-light);
}

/* Tips Section */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.tip-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow);
  border-top: 4px solid var(--accent);
}

.tip-card h4 {
  color: var(--primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* FAQ */
.faq-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 2px solid var(--border);
}

.faq-item h3 {
  color: var(--primary);
  margin-bottom: 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item h3::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--accent);
  transition: transform var(--transition);
}

.faq-item.active h3::after {
  transform: rotate(45deg);
}

.faq-item h4 {
  color: var(--primary);
  margin-bottom: 0.75rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item h4::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--accent);
  transition: transform var(--transition);
}

.faq-item.active h4::after {
  transform: rotate(45deg);
}

.faq-answer {
  color: var(--text-light);
  display: none;
}

.faq-item.active .faq-answer {
  display: block;
}

/* Footer */
footer {
  background: var(--primary);
  color: white;
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-section h4 {
  margin-bottom: 1rem;
  color: var(--accent);
}

.footer-section ul {
  list-style: none;
}

.footer-section a {
  color: white;
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition);
  display: block;
  padding: 0.25rem 0;
}

.footer-section a:hover {
  opacity: 1;
}

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  opacity: 0.7;
  font-size: 0.9rem;
}

/* Article Content */
.article-content {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 20px var(--shadow);
}

.article-content h2 {
  text-align: left;
  margin-top: 2rem;
}

.article-content p {
  margin-bottom: 1rem;
}

.article-content ul, .article-content ol {
  margin: 1rem 0 1rem 2rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

/* Breadcrumb */
.breadcrumb {
  padding: 1rem 0;
  font-size: 0.9rem;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--secondary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  margin: 0 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  header .container {
    flex-direction: column;
    text-align: center;
  }
  
  nav ul {
    justify-content: center;
  }
  
  .hero {
    padding: 2rem 0;
  }
  
  .generator-controls {
    grid-template-columns: 1fr;
  }
  
  .name-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }

/* Internal links */
.internal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 2rem 0;
}

.internal-links a {
  background: var(--bg-card);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  text-decoration: none;
  color: var(--secondary);
  font-weight: 500;
  border: 2px solid var(--border);
  transition: all var(--transition);
}

.internal-links a:hover {
  border-color: var(--secondary);
  background: var(--secondary);
  color: white;
}

/* Race Hero Section */
.race-hero {
  position: relative;
  height: 280px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 2rem;
}
.race-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.race-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(45, 27, 78, 0.3), rgba(45, 27, 78, 0.8));
  display: flex;
  align-items: flex-end;
  padding: 2rem;
}
.race-hero-text {
  color: white;
  max-width: 700px;
}
.race-hero-text h1 {
  font-size: 2.5rem;
  margin: 0 0 0.5rem 0;
  color: white;
}
.race-hero-text p {
  font-size: 1.1rem;
  margin: 0;
  opacity: 0.9;
}

/* Tab Switcher */
.tab-switcher {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-size: 0.95rem;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
}
.tab-btn:hover:not(.active) {
  color: var(--secondary);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Character Card */
.char-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  border: 2px solid var(--border);
  box-shadow: 0 4px 20px var(--shadow);
  margin-bottom: 1.5rem;
}
.char-card h3 {
  margin-top: 0;
  color: var(--primary);
  font-size: 1.5rem;
}
.char-card-section {
  margin-bottom: 1rem;
}
.char-card-section h4 {
  margin: 0.5rem 0 0.25rem;
  color: var(--secondary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.char-card h4 {
  color: var(--secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.5rem 0 0.75rem;
  font-weight: 700;
}

/* Character Card Grid */
.char-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
}
.char-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.char-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  font-weight: 600;
}
.char-stat-value {
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}

/* Character Sections */
.char-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.char-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.char-section p {
  margin: 0.5rem 0;
  line-height: 1.7;
  color: var(--text);
}
.char-section p strong {
  color: var(--secondary);
  font-weight: 600;
}

/* Personality Grid */
.personality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.personality-item {
  background: var(--bg);
  padding: 1rem;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}
.personality-item strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  margin-bottom: 0.5rem;
}
.personality-item p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

/* Voice & Backstory Text */
.voice-text, .backstory-text {
  background: var(--bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-top: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.8;
  border-left: 3px solid var(--accent);
}

/* Trait Tags */
.trait-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: white;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0.25rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Etymology Box */
.etymology-box {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.6;
}
.etymology-box code {
  background: var(--bg-card);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  color: var(--accent);
}

/* Portrait Prompt Box */
.portrait-prompt-box {
  background: var(--bg);
  border: 2px dashed var(--accent);
  padding: 1.25rem;
  border-radius: var(--radius);
  margin-top: 0.75rem;
  position: relative;
}
.portrait-prompt-box pre {
  margin: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Character Actions */
.char-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}
.char-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.char-actions button:hover {
  background: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* IP Badge */
.ip-badge {
  display: inline-block;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

/* Etymology Box */
.etymology-box {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  font-family: monospace;
  font-size: 0.9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* Portrait Prompt */
.portrait-prompt {
  background: var(--bg);
  border: 1px dashed var(--accent);
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Phonetic Tag */
.phonetic-tag {
  display: inline-block;
  background: var(--bg);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  margin-right: 0.3rem;
  border: 1px solid var(--border);
}

/* Name Example */
.name-example {
  background: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  margin: 0.5rem 0;
  border-left: 3px solid var(--accent);
}

/* Scenario Grid */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

/* Batch Results */
.batch-results {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* Export Buttons */
.export-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(400px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Character Generator Controls */
#char-generator {
  background: transparent;
}
.char-gen-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 768px) {
  .char-gen-controls {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .char-gen-controls {
    grid-template-columns: 1fr;
  }
}

/* Hidden utility */
.hidden {
  display: none;
}

/* Subrace Comparison Grid */
.subrace-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}
.subrace-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 2px solid var(--border);
  box-shadow: 0 2px 10px var(--shadow);
}
.subrace-card h3 {
  color: var(--primary);
  margin-top: 0;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.5rem;
}
.subrace-card ul {
  list-style: none;
  padding: 0;
}
.subrace-card li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.subrace-card li:last-child {
  border-bottom: none;
}

/* Nav without ul - fallback for pages using plain links */
nav:not(:has(ul)) {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
nav:not(:has(ul)) a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition);
  padding: 0.5rem 0;
}
nav:not(:has(ul)) a:hover {
  opacity: 0.8;
}

/* ── Backstory Generator Page Styles ── */
.backstory-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 3rem 0;
  text-align: center;
  margin-bottom: 2rem;
}
.backstory-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: white;
}
.backstory-hero p {
  font-size: 1.2rem;
  opacity: 0.9;
  max-width: 700px;
  margin: 0 auto;
}
.generator-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 20px var(--shadow);
  margin-bottom: 2rem;
}
.input-section {
  margin-bottom: 2rem;
}
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.input-section .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text);
}
.input-section .form-group select,
.input-section .form-group input[type="text"],
.input-section .form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color var(--transition);
}
.input-section .form-group select:focus,
.input-section .form-group input[type="text"]:focus,
.input-section .form-group textarea:focus {
  outline: none;
  border-color: var(--secondary);
}
.options-section {
  background: var(--bg);
  padding: 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.options-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--primary);
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.checkbox-item:hover {
  background: white;
  box-shadow: 0 2px 8px var(--shadow);
}
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.input-section .generate-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.input-section .generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(45, 27, 78, 0.3);
}
.input-section .generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.result-section {
  margin-top: 2rem;
  display: none;
}
.result-section.active {
  display: block;
}
.backstory-output {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  padding: 2rem;
  border-radius: var(--radius);
  line-height: 1.8;
  font-size: 1.05rem;
  white-space: pre-wrap;
  min-height: 200px;
}
.result-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.action-btn {
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}
.action-btn:hover {
  border-color: var(--secondary);
  background: var(--secondary);
  color: white;
}
.loading {
  display: none;
  text-align: center;
  padding: 2rem;
}
.loading.active {
  display: block;
}
.spinner {
  border: 4px solid var(--border);
  border-top: 4px solid var(--secondary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── About Page Styles ── */
.about-hero {
  background: linear-gradient(135deg, rgba(45, 27, 78, 0.95) 0%, rgba(92, 75, 138, 0.95) 100%);
  color: white;
  padding: 3rem 0;
  text-align: center;
}
.about-hero h2 {
  color: white;
  font-size: 2rem;
  margin-bottom: 1rem;
}
.about-hero p {
  max-width: 700px;
  margin: 0 auto;
  font-size: 1.1rem;
  line-height: 1.8;
  opacity: 0.95;
}
.about-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: 0 4px 20px var(--shadow);
  margin-bottom: 2rem;
}
.about-section h3 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1rem;
}
.about-section h4 {
  color: var(--secondary);
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.about-section p {
  line-height: 1.8;
  margin-bottom: 1rem;
}
.about-section ul {
  margin: 0.5rem 0 1rem 1.5rem;
  line-height: 1.8;
}
.limitation-box {
  background: var(--bg);
  border-left: 4px solid var(--accent);
  padding: 1.5rem;
  margin: 1.5rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.limitation-box h4 {
  margin-top: 0;
  color: var(--primary);
}
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: monospace;
  font-size: 0.9rem;
  overflow-x: auto;
  margin: 1rem 0;
}

/* ── Races Page FAQ Styles ── */
.faq-section details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.75rem;
}
.faq-section summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.faq-section summary::-webkit-details-marker {
  display: none;
}
.faq-section summary::before {
  content: "+";
  display: inline-block;
  width: 1.2em;
  font-weight: 700;
}
.faq-section details[open] summary::before {
  content: "\2212";
}

/* ── Comparison Table Styles (Races Page) ── */
.comparison-table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
}
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.comparison-table th,
.comparison-table td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.comparison-table thead th {
  background: var(--card-bg);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.comparison-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.comparison-table a {
  color: var(--accent);
  text-decoration: none;
}
.comparison-table a:hover {
  text-decoration: underline;
}

/* ── 404 Error Page Styles ── */
.error-page {
  text-align: center;
  padding: 4rem 2rem;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.error-code {
  font-size: 8rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 1rem;
}
.error-message {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 2rem;
}
.error-description {
  color: var(--text-light);
  margin-bottom: 2rem;
  max-width: 600px;
}
