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

body {
  background-color: #0a0a14;
  background-image: 
    radial-gradient(ellipse at 20% 50%, rgba(212, 165, 55, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(212, 165, 55, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(42, 42, 69, 0.3) 0%, transparent 50%);
}

/* Film grain overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #12121f; }
::-webkit-scrollbar-thumb { background: #2a2a45; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #d4a537; }

/* Typewriter animation */
@keyframes typeReveal {
  from { max-height: 0; opacity: 0; }
  to { max-height: 2000px; opacity: 1; }
}

.typewriter-line {
  overflow: hidden;
  animation: typeReveal 0.15s ease-out forwards;
  opacity: 0;
}

/* Glow effect for generate button */
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(212, 165, 55, 0.3), 0 0 40px rgba(212, 165, 55, 0.1); }
  50% { box-shadow: 0 0 30px rgba(212, 165, 55, 0.5), 0 0 60px rgba(212, 165, 55, 0.2); }
}

.btn-generate:hover {
  animation: goldPulse 2s ease-in-out infinite;
}

/* Script page styling */
.script-page {
  background: #faf8f2;
  color: #1a1a1a;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.65;
  padding: 48px 60px;
  box-shadow: 
    0 4px 6px rgba(0,0,0,0.4),
    0 20px 40px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  min-height: 400px;
  position: relative;
}

.script-page::before {
  content: '';
  position: absolute;
  left: 48px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(200, 50, 50, 0.15);
}

@media (max-width: 640px) {
  .script-page {
    padding: 24px 20px;
    font-size: 11px;
  }
  .script-page::before {
    left: 16px;
  }
}

/* Scene heading */
.scene-heading {
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 24px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

/* Character name */
.character-name {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 16px;
  margin-bottom: 2px;
  letter-spacing: 1px;
}

/* Dialogue */
.dialogue {
  text-align: center;
  max-width: 65%;
  margin: 0 auto 8px;
}

/* Parenthetical */
.parenthetical {
  text-align: center;
  font-style: italic;
  color: #555;
  margin: 0 auto 2px;
}

/* Action line */
.action-line {
  margin: 8px 0;
}

/* Act break */
.act-break {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  margin: 32px 0 24px;
  letter-spacing: 3px;
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  padding: 12px 0;
}

/* Transition */
.transition-line {
  text-align: right;
  text-transform: uppercase;
  font-weight: 700;
  margin: 16px 0;
  letter-spacing: 1px;
}

/* Title page */
.title-page {
  text-align: center;
  padding: 60px 0;
  margin-bottom: 24px;
  border-bottom: 2px solid #ddd;
}

/* Loading spinner */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeSlide {
  0% { opacity: 0; transform: translateY(8px); }
  15% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

.loading-message {
  animation: fadeSlide 3s ease-in-out infinite;
}

/* Sidebar transitions */
.sidebar-overlay {
  transition: opacity 0.3s ease;
}

.sidebar-panel {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus glow */
input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(212, 165, 55, 0.4), 0 0 20px rgba(212, 165, 55, 0.1);
  border-color: #d4a537 !important;
}

/* Genre pill */
.genre-pill {
  transition: all 0.2s ease;
  cursor: pointer;
}

.genre-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(212, 165, 55, 0.2);
}

.genre-pill.active {
  background: linear-gradient(135deg, #d4a537, #8b6914);
  color: #0a0a14;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(212, 165, 55, 0.3);
}

/* Tone slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(to right, #f0d78c, #2a2a45, #8b6914);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #d4a537;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(212, 165, 55, 0.4);
  transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Clapper animation */
@keyframes clap {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-20deg); }
  50% { transform: rotate(0deg); }
  75% { transform: rotate(-10deg); }
}

.clapper-anim {
  display: inline-block;
  animation: clap 1.5s ease-in-out infinite;
  transform-origin: bottom left;
}