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

body {
  font-family: 'DM Sans', sans-serif;
  background: #0d0d14;
  color: #e0ddd5;
  overflow-x: hidden;
}

/* Cinematic background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 0%, rgba(240, 165, 0, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(240, 165, 0, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(26, 26, 46, 0.8) 0%, #0d0d14 70%);
  pointer-events: none;
  z-index: 0;
}

#root {
  position: relative;
  z-index: 1;
}

/* Screenplay formatting */
.screenplay {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #2a2a2a;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.screenplay .scene-heading {
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.screenplay .character {
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 1em;
  margin-bottom: 0.2em;
}

.screenplay .dialogue {
  margin-left: 15%;
  margin-right: 15%;
  margin-bottom: 0.5em;
}

.screenplay .parenthetical {
  margin-left: 20%;
  margin-right: 20%;
  font-style: italic;
  color: #555;
}

.screenplay .action {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.screenplay .transition {
  text-align: right;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 1em;
}

/* Typewriter cursor */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: #f0a500;
  animation: blink-cursor 0.8s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}

@keyframes blink-cursor {
  50% { opacity: 0; }
}

/* Generate button glow */
.btn-generate {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-generate::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, #f0a500, #ffd866, #c48800, #f0a500);
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn-generate:hover::before {
  opacity: 1;
}

.btn-generate.generating {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(240, 165, 0, 0.3); }
  50% { box-shadow: 0 0 40px rgba(240, 165, 0, 0.6), 0 0 80px rgba(240, 165, 0, 0.2); }
}

/* Pill toggle buttons */
.pill-btn {
  transition: all 0.25s ease;
  border: 1px solid rgba(240, 165, 0, 0.2);
}

.pill-btn:hover {
  border-color: rgba(240, 165, 0, 0.5);
  background: rgba(240, 165, 0, 0.08);
}

.pill-btn.active {
  background: rgba(240, 165, 0, 0.15);
  border-color: #f0a500;
  color: #f0a500;
  box-shadow: 0 0 15px rgba(240, 165, 0, 0.15);
}

/* Toast notification */
.toast {
  animation: toast-in 0.4s ease, toast-out 0.4s ease 2.2s forwards;
}

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

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

/* Loading animation */
.loading-clapperboard {
  animation: clap 0.6s ease-in-out infinite;
}

@keyframes clap {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-15deg); }
  75% { transform: rotate(5deg); }
}

/* Script paper effect */
.script-paper {
  background: linear-gradient(180deg, #f5f0e8 0%, #ede8dc 100%);
  box-shadow: 
    0 2px 30px rgba(0,0,0,0.3),
    inset 0 0 60px rgba(0,0,0,0.03);
  position: relative;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(20, 20, 31, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(240, 165, 0, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(240, 165, 0, 0.5);
}

/* Saved script cards */
.saved-card {
  transition: all 0.25s ease;
  border: 1px solid rgba(240, 165, 0, 0.1);
}

.saved-card:hover {
  border-color: rgba(240, 165, 0, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* Textarea focus */
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(240, 165, 0, 0.3), 0 0 30px rgba(240, 165, 0, 0.08);
}

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

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

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 20px rgba(240, 165, 0, 0.6);
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f0a500' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Fade in animation for sections */
.fade-in {
  animation: fadeIn 0.6s ease forwards;
}

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

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

@media (max-width: 640px) {
  .screenplay {
    font-size: 11px;
  }
  .screenplay .dialogue {
    margin-left: 8%;
    margin-right: 8%;
  }
  .screenplay .parenthetical {
    margin-left: 12%;
    margin-right: 12%;
  }
  .script-paper::before {
    left: 30px;
  }
}