/* =====================================================
   STARBOUND: Rise to Fame — Gritty Street Aesthetic
   ===================================================== */

:root {
  --bg-dark: #0a0a0a;
  --bg-panel: #1a1a2e;
  --bg-card: #12121e;
  --accent: #39FF14;
  --accent-glow: rgba(57, 255, 20, 0.4);
  --gold: #FFD700;
  --danger: #FF3333;
  --fame-purple: #9B59B6;
  --text-primary: #E8E8E8;
  --text-secondary: #888;
  --text-dim: #555;
  --border-color: #2a2a3e;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Chakra Petch', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Noise Overlay */
#noise-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  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)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* =====================================================
   SCREENS
   ===================================================== */
.screen {
  display: none;
  height: 100vh;
  width: 100vw;
  overflow-y: auto;
}
.screen.active { display: flex; }

/* =====================================================
   TITLE SCREEN
   ===================================================== */
#screen-title {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0a 70%);
}

.title-logo {
  font-family: 'Permanent Marker', cursive;
  font-size: clamp(3rem, 10vw, 7rem);
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow);
  letter-spacing: 0.1em;
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow); }
  50% { text-shadow: 0 0 60px var(--accent-glow), 0 0 120px var(--accent-glow), 0 0 160px var(--accent-glow); }
}

.title-subtitle {
  font-family: 'Share Tech Mono', monospace;
  font-size: clamp(0.8rem, 2vw, 1.2rem);
  color: var(--text-secondary);
  letter-spacing: 0.5em;
  margin: 0.5rem 0 2rem;
}

.title-tagline {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 3rem;
  font-style: italic;
}

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

.title-footer {
  position: absolute;
  bottom: 2rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
  font-family: 'Chakra Petch', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.75rem 2rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: all 0.2s;
  position: relative;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg-dark);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--accent); color: var(--bg-dark); }
.btn-primary:hover { background: transparent; color: var(--accent); }

.btn-secondary { border-color: var(--text-dim); color: var(--text-secondary); }
.btn-secondary:hover { border-color: var(--text-primary); color: var(--text-primary); background: rgba(255,255,255,0.05); box-shadow: none; }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; box-shadow: 0 0 20px rgba(255,51,51,0.4); }

.btn-glow { box-shadow: 0 0 15px var(--accent-glow); }

.btn-large { font-size: 1.1rem; padding: 1rem 3rem; margin-top: 2rem; }
.btn-small { font-size: 0.7rem; padding: 0.4rem 1rem; }
.btn-full { width: 100%; margin-bottom: 0.75rem; }

/* =====================================================
   CHARACTER CREATION
   ===================================================== */
#screen-create {
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-y: auto;
}

.create-container {
  max-width: 800px;
  width: 100%;
}

.section-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 2rem;
  color: var(--accent);
  text-align: center;
  margin-bottom: 2rem;
  text-shadow: 0 0 20px var(--accent-glow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
  margin-bottom: 1.5rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group select {
  font-family: 'Chakra Petch', sans-serif;
  font-size: 1rem;
  padding: 0.75rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.form-group input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-panel);
  border-radius: 3px;
  outline: none;
}

.form-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
}

.range-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.5rem;
  color: var(--accent);
  text-align: center;
  margin-top: 0.25rem;
}

/* Backstory Cards */
.backstory-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.backstory-card {
  cursor: pointer;
}

.backstory-card input { display: none; }

.backstory-content {
  padding: 1rem;
  background: var(--bg-panel);
  border: 2px solid var(--border-color);
  transition: all 0.2s;
}

.backstory-card input:checked + .backstory-content {
  border-color: var(--accent);
  box-shadow: 0 0 15px var(--accent-glow);
}

.backstory-content:hover {
  border-color: var(--text-dim);
}

.backstory-content strong {
  font-family: 'Permanent Marker', cursive;
  color: var(--accent);
  font-size: 0.9rem;
}

.backstory-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
}

.backstory-stats {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Color Swatches */
.color-options {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  cursor: pointer;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.color-swatch input { display: none; }

.swatch {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--swatch-color);
  margin: 0 auto 0.25rem;
  border: 3px solid transparent;
  transition: all 0.2s;
}

.color-swatch input:checked + .swatch {
  border-color: #fff;
  box-shadow: 0 0 20px var(--swatch-color);
  transform: scale(1.2);
}

/* =====================================================
   LOAD GAME SCREEN
   ===================================================== */
#screen-load {
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  overflow-y: auto;
}

.load-container {
  max-width: 600px;
  width: 100%;
}

.saves-list { margin-bottom: 2rem; }

.save-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 1rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.save-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.save-info h3 {
  font-family: 'Permanent Marker', cursive;
  color: var(--accent);
  font-size: 1.1rem;
}

.save-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.save-delete {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: 'Chakra Petch', sans-serif;
}

.save-delete:hover { background: var(--danger); color: #fff; }

.no-saves {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 0;
  font-style: italic;
}

/* =====================================================
   GAME SCREEN
   ===================================================== */
#screen-game {
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  min-height: 48px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 1rem; }

.logo-small {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.2rem;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.header-artist {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-right { display: flex; gap: 0.5rem; }

/* Game Layout */
.game-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Stats Panel */
.stats-panel {
  width: 240px;
  min-width: 240px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats-panel h3 {
  font-family: 'Permanent Marker', cursive;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

/* Stat Bars */
.stat-bar { margin-bottom: 0.6rem; }

.stat-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.stat-icon { font-size: 0.8rem; }

.stat-track {
  height: 8px;
  background: #1a1a1a;
  border: 1px solid #333;
  position: relative;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.8s ease, background 0.3s;
  box-shadow: inset 0 0 8px rgba(255,255,255,0.1);
  position: relative;
}

/* Segmented look like VU meters */
.stat-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0px,
    transparent 4px,
    rgba(0,0,0,0.3) 4px,
    rgba(0,0,0,0.3) 5px
  );
}

.stress-fill { background: var(--danger); }
.health-fill { background: #2ECC71; }

.stat-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: right;
  margin-top: 0.1rem;
}

/* Fame Section */
.fame-section {
  text-align: center;
  padding: 0.75rem;
  background: rgba(155, 89, 182, 0.1);
  border: 1px solid rgba(155, 89, 182, 0.3);
}

.fame-label {
  font-family: 'Permanent Marker', cursive;
  font-size: 0.9rem;
  color: var(--fame-purple);
  margin-bottom: 0.5rem;
}

.fame-track {
  height: 12px;
  background: #1a1a1a;
  border: 1px solid rgba(155, 89, 182, 0.4);
  margin-bottom: 0.3rem;
  overflow: hidden;
}

.fame-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--fame-purple), #E74C3C, var(--gold));
  width: 0%;
  transition: width 1s ease;
  box-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

.fame-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.2rem;
  color: var(--fame-purple);
  text-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

/* Meta Info */
.meta-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
}

.meta-label { color: var(--text-dim); letter-spacing: 0.1em; }
.meta-value { font-family: 'Share Tech Mono', monospace; color: var(--text-primary); }

/* Inventory */
.inventory-section ul,
.relationships-section ul {
  list-style: none;
  font-size: 0.75rem;
}

.inventory-section li,
.relationships-section li {
  padding: 0.2rem 0;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.relationships-section li .npc-name {
  color: var(--accent);
  font-weight: 600;
}

.relationships-section li .npc-role {
  color: var(--text-dim);
  font-size: 0.65rem;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Narrative Panel */
.narrative-panel {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.narrative-text {
  font-size: 1rem;
  line-height: 1.8;
  max-width: 700px;
  margin: 0 auto;
}

.narrative-text p {
  margin-bottom: 1rem;
}

.narrative-text .dialogue {
  color: var(--accent);
  font-style: italic;
}

/* Choices Panel */
.choices-panel {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-panel);
  flex-shrink: 0;
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 700px;
  margin: 0 auto 1rem;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.2s;
  width: 100%;
}

.choice-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  transform: translateX(4px);
}

.choice-btn:active { transform: translateX(2px) scale(0.99); }

.choice-id {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.1rem;
  color: var(--accent);
  min-width: 24px;
}

.choice-text { flex: 1; }

.choice-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.25rem;
}

/* Free Action */
.free-action {
  display: flex;
  gap: 0.5rem;
  max-width: 700px;
  margin: 0 auto;
}

.free-action input {
  flex: 1;
  font-family: 'Chakra Petch', sans-serif;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  outline: none;
}

.free-action input:focus {
  border-color: var(--accent);
}

.free-action input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}

/* Loading — Vinyl + EQ */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 3rem 2rem;
  color: var(--text-secondary);
}

.loading-vinyl {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    var(--accent) 0%, var(--accent) 8%,
    #111 9%, #111 12%,
    #1a1a1a 13%, #1a1a1a 20%,
    #111 21%, #111 24%,
    #1a1a1a 25%, #1a1a1a 35%,
    #111 36%, #111 39%,
    #1a1a1a 40%, #1a1a1a 48%,
    #222 49%, #222 100%
  );
  border: 3px solid #333;
  animation: vinylSpin 2s linear infinite;
  box-shadow: 0 0 20px rgba(0,0,0,0.5), 0 0 10px var(--accent-glow);
}

@keyframes vinylSpin { to { transform: rotate(360deg); } }

.loading-eq {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
}

.loading-eq .eq-bar {
  width: 4px;
  background: var(--accent);
  animation: eqBounce 0.8s ease-in-out infinite alternate;
  box-shadow: 0 0 4px var(--accent-glow);
  border-radius: 1px;
}

.loading-eq .eq-bar:nth-child(1) { height: 30%; animation-delay: 0s; }
.loading-eq .eq-bar:nth-child(2) { height: 60%; animation-delay: 0.1s; }
.loading-eq .eq-bar:nth-child(3) { height: 90%; animation-delay: 0.2s; }
.loading-eq .eq-bar:nth-child(4) { height: 50%; animation-delay: 0.3s; }
.loading-eq .eq-bar:nth-child(5) { height: 80%; animation-delay: 0.15s; }
.loading-eq .eq-bar:nth-child(6) { height: 40%; animation-delay: 0.25s; }
.loading-eq .eq-bar:nth-child(7) { height: 70%; animation-delay: 0.05s; }
.loading-eq .eq-bar:nth-child(8) { height: 55%; animation-delay: 0.35s; }

@keyframes eqBounce {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

.loading-text {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.6s step-end infinite;
}

.hidden { display: none !important; }

/* =====================================================
   OVERLAYS
   ===================================================== */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.overlay-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.overlay-wide { max-width: 600px; }

/* Song Log */
.songlog-list { margin-bottom: 1.5rem; }

.song-card {
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

.song-title {
  font-family: 'Permanent Marker', cursive;
  color: var(--accent);
  font-size: 0.95rem;
}

.song-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
}

.song-lyrics {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.5rem;
  white-space: pre-line;
}

/* Achievements */
.achievements-list { margin-bottom: 1.5rem; }

.achievement-item {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.achievement-item .ach-name {
  color: var(--gold);
  font-weight: 700;
}

.achievement-item.locked {
  color: var(--text-dim);
  font-style: italic;
}

/* =====================================================
   ENDING SCREEN
   ===================================================== */
#screen-ending {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
  text-align: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a0a 70%);
}

.ending-container { max-width: 700px; width: 100%; }

.ending-title {
  font-family: 'Permanent Marker', cursive;
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  margin-bottom: 0.5rem;
}

.ending-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-style: italic;
}

.ending-narrative {
  text-align: left;
  font-size: 1rem;
  line-height: 1.8;
  margin-bottom: 2rem;
}

.ending-narrative p { margin-bottom: 1rem; }

.ending-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
  text-align: center;
}

.ending-stat {
  padding: 1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
}

.ending-stat .es-value {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.5rem;
  color: var(--accent);
}

.ending-stat .es-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

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

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--bg-panel);
  border-left: 3px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.85rem;
  animation: slideIn 0.3s ease, fadeOut 0.5s 3s ease forwards;
  max-width: 300px;
}

.toast.achievement { border-color: var(--gold); }
.toast.danger { border-color: var(--danger); }
.toast.phase { border-color: var(--fame-purple); }

.toast-title {
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
  color: var(--accent);
}

.toast.achievement .toast-title { color: var(--gold); }
.toast.danger .toast-title { color: var(--danger); }
.toast.phase .toast-title { color: var(--fame-purple); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(50%); }
}

/* =====================================================
   STAT CHANGE ANIMATIONS
   ===================================================== */
.stat-change-indicator {
  position: absolute;
  right: 0;
  top: -8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  animation: floatUp 1.5s ease forwards;
  pointer-events: none;
}

.stat-change-indicator.positive { color: var(--accent); }
.stat-change-indicator.negative { color: var(--danger); }

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* Screen transition flash */
.screen-flash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 500;
  animation: flashBang 0.4s ease;
}

@keyframes flashBang {
  0% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* =====================================================
   MOBILE RESPONSIVE
   ===================================================== */
.mobile-stats-toggle {
  display: none;
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  font-family: 'Permanent Marker', cursive;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg-dark);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 15px var(--accent-glow);
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .backstory-options { grid-template-columns: 1fr; }

  .game-layout { flex-direction: column; }

  .stats-panel {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-width: 100%;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .stats-panel.mobile-open {
    transform: translateX(0);
  }

  .mobile-stats-toggle { display: block; }

  .game-main { width: 100%; }

  .narrative-panel { padding: 1rem; }

  .choices-panel { padding: 0.75rem 1rem; }

  .choice-btn { font-size: 0.85rem; padding: 0.6rem 0.75rem; }

  .overlay-content { padding: 1.5rem; width: 95%; }
}

@media (max-width: 480px) {
  .title-logo { font-size: 2.5rem; }

  .game-header {
    padding: 0.4rem 0.75rem;
  }

  .header-artist { display: none; }
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* =====================================================
   TYPEWRITER EFFECT
   ===================================================== */
.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
}

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

/* =====================================================
   STORY ANIMATIONS — Mood & Event FX
   ===================================================== */

/* --- Mood Vignette Overlay --- */
#mood-vignette {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 400;
  opacity: 0;
  transition: opacity 1.2s ease, background 1.5s ease;
}

#mood-vignette.active { opacity: 1; }

#mood-vignette.mood-danger {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 30, 30, 0.15) 100%);
}
#mood-vignette.mood-success {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(57, 255, 20, 0.1) 100%);
}
#mood-vignette.mood-hype {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(155, 89, 182, 0.12) 100%);
}
#mood-vignette.mood-money {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255, 215, 0, 0.12) 100%);
}
#mood-vignette.mood-sad {
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 80, 180, 0.15) 100%);
}
#mood-vignette.mood-tension {
  background: radial-gradient(ellipse at center, transparent 30%, rgba(200, 50, 0, 0.12) 100%);
}

/* --- Narrative Paragraph Entrance --- */
.narrative-text p {
  opacity: 0;
  transform: translateY(12px);
  animation: narrativeFadeIn 0.6s ease forwards;
}

.narrative-text p:nth-child(1) { animation-delay: 0.1s; }
.narrative-text p:nth-child(2) { animation-delay: 0.3s; }
.narrative-text p:nth-child(3) { animation-delay: 0.5s; }
.narrative-text p:nth-child(4) { animation-delay: 0.7s; }
.narrative-text p:nth-child(5) { animation-delay: 0.9s; }
.narrative-text p:nth-child(6) { animation-delay: 1.1s; }

/* During streaming, don't delay — show immediately */
.narrative-text.streaming p {
  animation: none;
  opacity: 1;
  transform: none;
}

@keyframes narrativeFadeIn {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* --- Screen Shake --- */
.fx-shake .narrative-panel {
  animation: screenShake 0.5s ease;
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px) rotate(-0.5deg); }
  20% { transform: translateX(5px) rotate(0.5deg); }
  30% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  50% { transform: translateX(-2px); }
  60% { transform: translateX(2px); }
  70% { transform: translateX(-1px); }
}

/* --- Impact Flash (white-hot moment) --- */
.fx-impact::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 450;
  animation: impactFlash 0.3s ease;
}

@keyframes impactFlash {
  0% { opacity: 0.4; }
  100% { opacity: 0; }
}

/* --- Danger Pulse (red edges) --- */
.fx-danger-pulse::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 410;
  box-shadow: inset 0 0 80px rgba(255, 30, 30, 0.4);
  animation: dangerPulse 1.5s ease;
  opacity: 0;
}

@keyframes dangerPulse {
  0% { opacity: 0; }
  20% { opacity: 1; }
  60% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* --- Success Glow (accent color edges) --- */
.fx-success-glow::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 410;
  box-shadow: inset 0 0 60px var(--accent-glow);
  animation: successGlow 2s ease;
  opacity: 0;
}

@keyframes successGlow {
  0% { opacity: 0; }
  30% { opacity: 1; }
  70% { opacity: 0.5; }
  100% { opacity: 0; }
}

/* --- Money Rain Particle --- */
.money-particle {
  position: fixed;
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 420;
  animation: moneyFall 2.5s ease-in forwards;
  opacity: 0.8;
  color: var(--gold);
  font-family: 'Share Tech Mono', monospace;
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}

@keyframes moneyFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 0.9; }
  70% { opacity: 0.6; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* --- Money Loss (red falling) --- */
.money-loss-particle {
  position: fixed;
  font-size: 1rem;
  pointer-events: none;
  z-index: 420;
  animation: moneyDrain 2s ease-in forwards;
  opacity: 0.7;
  color: var(--danger);
  font-family: 'Share Tech Mono', monospace;
}

@keyframes moneyDrain {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(80vh) scale(0.5); opacity: 0; }
}

/* --- Hype Burst (sparkle outward) --- */
.fx-hype-burst::after {
  content: '';
  position: fixed;
  top: 50%; left: 50%;
  width: 0; height: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 415;
  background: radial-gradient(circle, var(--accent-glow), transparent);
  animation: hypeBurst 1s ease-out forwards;
  transform: translate(-50%, -50%);
}

@keyframes hypeBurst {
  0% { width: 0; height: 0; opacity: 0.8; }
  100% { width: 120vw; height: 120vw; opacity: 0; }
}

/* --- Slow Zoom (tension) --- */
.fx-tension .narrative-panel {
  animation: tensionZoom 3s ease-in-out;
}

@keyframes tensionZoom {
  0% { transform: scale(1); }
  50% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

/* --- Fade to Black (dramatic pause) --- */
.fx-fade-black::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: black;
  pointer-events: none;
  z-index: 430;
  animation: fadeToBlack 2.5s ease;
}

@keyframes fadeToBlack {
  0% { opacity: 0; }
  40% { opacity: 0.7; }
  60% { opacity: 0.7; }
  100% { opacity: 0; }
}

/* --- Cinematic Bars (phase transitions) --- */
.cinematic-bars .cinematic-bar-top,
.cinematic-bars .cinematic-bar-bottom {
  position: fixed;
  left: 0; right: 0;
  height: 0;
  background: black;
  z-index: 440;
  pointer-events: none;
  animation: cinematicBarIn 3s ease forwards;
}

.cinematic-bars .cinematic-bar-top { top: 0; }
.cinematic-bars .cinematic-bar-bottom { bottom: 0; }

@keyframes cinematicBarIn {
  0% { height: 0; }
  20% { height: 60px; }
  80% { height: 60px; }
  100% { height: 0; }
}

/* --- Choice Entrance --- */
.choice-btn {
  opacity: 0;
  transform: translateX(-20px);
  animation: choiceSlideIn 0.4s ease forwards;
}

.choice-btn:nth-child(1) { animation-delay: 0.1s; }
.choice-btn:nth-child(2) { animation-delay: 0.25s; }
.choice-btn:nth-child(3) { animation-delay: 0.4s; }

@keyframes choiceSlideIn {
  0% { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}
