/* ─── THEME VARIABLES ─────────────────────────────────────── */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2332;
  --bg-card: #151d2e;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #64B5F6;
  --accent-glow: rgba(100, 181, 246, 0.15);
  --border: rgba(148, 163, 184, 0.1);
  --shadow: rgba(0, 0, 0, 0.4);
  --choice-bg: rgba(100, 181, 246, 0.08);
  --choice-hover: rgba(100, 181, 246, 0.18);
  --choice-border: rgba(100, 181, 246, 0.25);
  --stat-trust: #4CAF50;
  --stat-suspicion: #FF5252;
  --highlight: #FFD54F;
  --highlight-bg: rgba(255, 213, 79, 0.1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eaed;
    --bg-card: #ffffff;
    --text-primary: #1a2332;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent: #1976D2;
    --accent-glow: rgba(25, 118, 210, 0.1);
    --border: rgba(0, 0, 0, 0.08);
    --shadow: rgba(0, 0, 0, 0.08);
    --choice-bg: rgba(25, 118, 210, 0.06);
    --choice-hover: rgba(25, 118, 210, 0.14);
    --choice-border: rgba(25, 118, 210, 0.2);
    --highlight: #E65100;
    --highlight-bg: rgba(230, 81, 0, 0.08);
  }
}

html[data-theme="dark"] {
  --bg-primary: #0a0e17 !important;
  --bg-secondary: #111827 !important;
  --bg-tertiary: #1a2332 !important;
  --bg-card: #151d2e !important;
  --text-primary: #e2e8f0 !important;
  --text-secondary: #94a3b8 !important;
  --text-muted: #64748b !important;
  --accent: #64B5F6 !important;
  --accent-glow: rgba(100, 181, 246, 0.15) !important;
  --border: rgba(148, 163, 184, 0.1) !important;
  --shadow: rgba(0, 0, 0, 0.4) !important;
  --choice-bg: rgba(100, 181, 246, 0.08) !important;
  --choice-hover: rgba(100, 181, 246, 0.18) !important;
  --choice-border: rgba(100, 181, 246, 0.25) !important;
  --highlight: #FFD54F !important;
  --highlight-bg: rgba(255, 213, 79, 0.1) !important;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg-primary: #f0f2f5 !important;
  --bg-secondary: #ffffff !important;
  --bg-tertiary: #e8eaed !important;
  --bg-card: #ffffff !important;
  --text-primary: #1a2332 !important;
  --text-secondary: #4a5568 !important;
  --text-muted: #718096 !important;
  --accent: #1976D2 !important;
  --accent-glow: rgba(25, 118, 210, 0.1) !important;
  --border: rgba(0, 0, 0, 0.08) !important;
  --shadow: rgba(0, 0, 0, 0.08) !important;
  --choice-bg: rgba(25, 118, 210, 0.06) !important;
  --choice-hover: rgba(25, 118, 210, 0.14) !important;
  --choice-border: rgba(25, 118, 210, 0.2) !important;
  --highlight: #E65100 !important;
  --highlight-bg: rgba(230, 81, 0, 0.08) !important;
  color-scheme: light;
}

/* ─── RESET & BASE ────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  font-family: 'Kenney Future Narrow', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

@font-face {
  font-family: 'Kenney Future Narrow';
  src: url('https://popchat.com/assets/kenney/fonts/Kenney%20Future%20Narrow.ttf');
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-primary);
}

/* ─── STATUS BAR ──────────────────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
  min-height: 56px;
}

#location-tag {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

#status-items {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 10px;
  padding: 3px 8px;
  background: var(--accent-glow);
  border: 1px solid var(--choice-border);
  border-radius: 4px;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.stats-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-bar {
  width: 60px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.stat-fill.trust { background: var(--stat-trust); }
.stat-fill.suspicion { background: var(--stat-suspicion); }

/* ─── STORY CONTAINER ─────────────────────────────────────── */
#story-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 20px 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#story-container::-webkit-scrollbar {
  width: 4px;
}

#story-container::-webkit-scrollbar-track {
  background: transparent;
}

#story-container::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

#scene-text {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 24px;
  white-space: pre-wrap;
}

#scene-text .highlight {
  color: var(--highlight);
  background: var(--highlight-bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  display: inline;
}

#scene-text em {
  font-style: italic;
  color: var(--text-secondary);
}

/* ─── CHOICES ─────────────────────────────────────────────── */
#choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.choice-btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  background: var(--choice-bg);
  border: 1px solid var(--choice-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0;
  transform: translateY(8px);
  animation: fadeInUp 0.3s ease forwards;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.choice-btn:hover {
  background: var(--choice-hover);
  border-color: var(--accent);
  transform: translateX(4px);
}

.choice-btn:active {
  transform: translateX(4px) scale(0.98);
  background: var(--choice-hover);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── NARRATIVE FOOTER ────────────────────────────────────── */
#narrative-footer {
  padding: 10px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 480px) {
  #app {
    max-width: 100%;
  }
  
  #story-container {
    padding: 16px 14px 14px;
  }
  
  #scene-text {
    font-size: 14px;
    line-height: 1.7;
  }
  
  .choice-btn {
    padding: 12px 14px;
    font-size: 13px;
  }
  
  #status-bar {
    padding: 10px 14px;
  }
  
  #location-tag {
    font-size: 11px;
    max-width: 45%;
  }
  
  .stat-bar {
    width: 40px;
  }
}

@media (min-width: 768px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  
  #scene-text {
    font-size: 16px;
    line-height: 1.8;
  }
}

/* ─── ENDING STYLING ──────────────────────────────────────── */
#scene-text:has(.highlight) {
  animation: sceneAppear 0.6s ease;
}

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