@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,400;0,600;1,400&family=JetBrains+Mono:wght@400;500&family=Alegreya+Sans:wght@400;500;700&display=swap');

:root {
  --bg-deep: #0a0a0f;
  --bg-panel: #151520;
  --bg-card: #12121a;
  --border: #2a2a3a;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-dim: #606080;
  --gold: #c0a060;
  --red: #c06060;
  --purple: #c084fc;
  --font-narrative: 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  --font-ui: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
  --side-panel-width: 480px;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

/* Auth */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.logo {
  font-size: 3rem;
  color: #c084fc;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tagline {
  color: #888;
  margin-bottom: 2rem;
  font-style: italic;
}

.auth-form {
  background: #14141f;
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  border: 1px solid #2a2a3a;
}

.auth-form h2 {
  margin-bottom: 1.2rem;
  color: #c084fc;
}

.auth-form input {
  width: 100%;
  padding: 0.7rem 1rem;
  margin-bottom: 0.8rem;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.95rem;
}

.auth-form input:focus {
  outline: none;
  border-color: #c084fc;
}

.auth-switch {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: #888;
}

.auth-switch a {
  color: #c084fc;
  text-decoration: none;
}

.error-msg {
  color: #f87171;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 0.7rem;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #6d28d9;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #c084fc;
  border: 1px solid #c084fc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: rgba(192, 132, 252, 0.1);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  background: #14141f;
  border-bottom: 1px solid #2a2a3a;
}

.logo-small {
  font-size: 1.3rem;
  color: #c084fc;
  letter-spacing: 0.05em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#user-email {
  color: #888;
  font-size: 0.85rem;
}

/* Dashboard */
.dashboard {
  padding: 2rem;
  max-width: 1000px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.dashboard-header h2 {
  color: #c084fc;
}

.dashboard-header .btn-primary {
  width: auto;
  padding: 0.6rem 1.2rem;
}

.villages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.village-card {
  background: #14141f;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 1.2rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.village-card:hover {
  border-color: #7c3aed;
  transform: translateY(-2px);
}

.village-card h3 {
  color: #e0e0e0;
  margin-bottom: 0.5rem;
}

.village-card .meta {
  font-size: 0.8rem;
  color: #666;
}

.village-card .card-actions {
  margin-top: 0.8rem;
  display: flex;
  justify-content: flex-end;
}

.btn-danger {
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: #f87171;
  border: 1px solid #f87171;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.empty-state {
  text-align: center;
  color: #666;
  padding: 3rem;
  grid-column: 1 / -1;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: #14141f;
  border: 1px solid #2a2a3a;
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content.modal-wide {
  max-width: 480px;
}

.modal-content h2 {
  color: #c084fc;
  margin-bottom: 1rem;
}

.modal-content label {
  display: block;
  font-size: 0.85rem;
  color: #888;
  margin: 0.8rem 0 0.3rem;
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 6px;
  color: #e0e0e0;
  font-size: 0.9rem;
}

.modal-content input:focus,
.modal-content select:focus {
  outline: none;
  border-color: #c084fc;
}

.modal-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  flex: 1;
}

/* Village View */
.village-layout {
  display: flex;
  height: calc(100vh - 53px);
}

.canvas-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#village-canvas {
  flex: 1;
  background: #0d0d15;
  display: block;
}

.playback-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 8px 16px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.side-panel {
  width: var(--side-panel-width);
  background: linear-gradient(180deg, var(--bg-panel) 0%, #0d0d14 100%);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#village-tick {
  font-size: 1.1rem;
  color: #888;
}

#topbar-status {
  font-size: 1.1rem;
  color: #4ade80;
}

/* === Selected Creature Toggle === */

.creature-avatar-large {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border: 2px solid;
  flex-shrink: 0;
}

/* Trait-based avatar colors (dominant trait) */
.creature-avatar-large.trait-bold { background: linear-gradient(135deg, #c06060, #a04040); border-color: #c06060; }
.creature-avatar-large.trait-social { background: linear-gradient(135deg, #e8a060, #c08040); border-color: #e8a060; }
.creature-avatar-large.trait-curious { background: linear-gradient(135deg, #9070b0, #705090); border-color: #9070b0; }
.creature-avatar-large.trait-tenacious { background: linear-gradient(135deg, #60a080, #408060); border-color: #60a080; }
.creature-avatar-large.trait-volatile { background: linear-gradient(135deg, #6080c0, #4060a0); border-color: #6080c0; }

.rename-icon {
  font-size: 0.7em;
  cursor: pointer;
  opacity: 0.4;
  margin-left: 4px;
}

.rename-icon:hover {
  opacity: 1;
}

.rename-input {
  background: #1a1a2e;
  border: 1px solid #c084fc;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 1.3rem;
  padding: 0.3rem 0.5rem;
  width: 100%;
  font-family: inherit;
  outline: none;
}

/* === Compact Needs Bar === */
#needs-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  background: #0d0d14;
  border-bottom: 1px solid #2a2a3a;
}

.need-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.need-icon {
  font-size: 1.3rem;
}

.need-meter {
  width: 100%;
  height: 6px;
  background: #1a1a28;
  border-radius: 3px;
  overflow: hidden;
}

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

.need-fill.critical {
  animation: pulse-critical 1s ease-in-out infinite;
}

@keyframes pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.need-value {
  font-size: 0.95rem;
  color: #606070;
}

.need-fill.hunger { background: linear-gradient(90deg, #c07050, #a05030); }
.need-fill.thirst { background: linear-gradient(90deg, #5090c0, #3070a0); }
.need-fill.social { background: linear-gradient(90deg, #c080a0, #a06080); }
.need-fill.rest { background: linear-gradient(90deg, #80a080, #608060); }
.need-fill.stim { background: linear-gradient(90deg, #c0a050, #a08030); }

/* Creature Grid — Compact Pips */
#creature-grid {
  padding: 12px;
  border-bottom: 1px solid #1a1a28;
}

.creatures-pips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.creature-pip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  border: 2px solid transparent;
}

.creature-pip:hover {
  transform: scale(1.15);
  z-index: 10;
}

.creature-pip.selected {
  border-color: #e8d5f0;
  box-shadow: 0 0 12px rgba(232, 213, 240, 0.4);
}

.creature-pip.dead {
  opacity: 0.3;
  filter: grayscale(1);
}

.creature-pip.critical::after {
  content: '!';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  background: #c04040;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.creature-pip .pip-name {
  display: none;
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: #a0a0b0;
  white-space: nowrap;
  background: #1a1a28;
  padding: 2px 8px;
  border-radius: 4px;
  z-index: 20;
}

.creature-pip:hover .pip-name {
  display: block;
}

/* Trait-based pip colors (dominant trait) */
.creature-pip.trait-bold { background: linear-gradient(135deg, #c06060, #a04040); }
.creature-pip.trait-social { background: linear-gradient(135deg, #e8a060, #c08040); }
.creature-pip.trait-curious { background: linear-gradient(135deg, #9070b0, #705090); }
.creature-pip.trait-tenacious { background: linear-gradient(135deg, #60a080, #408060); }
.creature-pip.trait-volatile { background: linear-gradient(135deg, #6080c0, #4060a0); }

.pip-status-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #c0a060;
  border-radius: 50%;
  border: 1.5px solid var(--bg-card);
}

.exile-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #2a2030 0%, #1a1520 100%);
  border: 1px solid #3a2a3a;
  border-radius: 8px;
  color: #c0a0b0;
  font-size: 1.15rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.exile-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #3a2a40 0%, #2a1a30 100%);
  border-color: #5a3a5a;
  color: #e0c0d0;
}

.exile-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.exile-cooldown {
  font-size: 1.0rem;
  color: #605060;
  text-align: center;
  margin-top: 6px;
}

.btn-primary-sm {
  padding: 0.4rem 1.0rem;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
}

.btn-primary-sm:hover {
  background: #6d28d9;
}

#speed-select {
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 1.1rem;
}

/* Drama Level Cards */
.drama-cards {
  display: flex;
  gap: 0.5rem;
}

.drama-card {
  flex: 1;
  padding: 0.6rem 0.9rem;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.drama-card:hover {
  border-color: #7c3aed;
}

.drama-card.selected {
  border-color: #c084fc;
  background: rgba(192, 132, 252, 0.1);
}

.drama-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 0.1rem;
}

.drama-card.selected .drama-card-name {
  color: #c084fc;
}

.drama-card-desc {
  font-size: 0.75rem;
  color: #777;
  font-style: italic;
  font-family: var(--font-narrative);
}

.catalog-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
}

.catalog-header:hover {
  opacity: 0.8;
}

.catalog-arrow {
  font-size: 0.6rem;
  color: #606080;
  width: 12px;
}

.catalog-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #606080;
  flex: 1;
}

.catalog-count {
  font-size: 0.7rem;
  color: #808090;
  background: #1a1a28;
  padding: 2px 6px;
  border-radius: 8px;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
}

.catalog-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.8rem;
}

.catalog-item:hover {
  background: rgba(100, 100, 140, 0.1);
}

.catalog-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.catalog-name {
  flex: 1;
  color: #a0a0b0;
  text-transform: capitalize;
}

.catalog-status {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
}

.catalog-status.healthy {
  color: #60a060;
  background: rgba(96, 160, 96, 0.1);
}

.catalog-status.sabotaged {
  color: #c06060;
  background: rgba(192, 96, 96, 0.15);
}

.catalog-status.depleted {
  color: #808090;
  background: rgba(128, 128, 144, 0.1);
}

.catalog-duration {
  font-size: 0.65rem;
  color: #606080;
}

.catalog-item.active-element {
  border-left: 2px solid #606080;
}

.catalog-item.tier-2 {
  border-left-color: #b490ff;
}

.catalog-item.tier-2 .catalog-name {
  color: #c0a0ff;
}

.catalog-item.tier-3 {
  border-left-color: #ffd060;
}

.catalog-item.tier-3 .catalog-name {
  color: #ffd060;
  font-weight: 600;
}

.totem-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.totem-panel-emoji {
  font-size: 2rem;
}

.totem-panel-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffd700;
}

.totem-panel-status {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.totem-panel-desc {
  font-size: 0.8rem;
  color: var(--text-secondary, #808090);
  font-style: italic;
  margin-bottom: 8px;
}

.totem-panel-buttons {
  display: flex;
  gap: 6px;
}

.totem-btn {
  flex: 1;
  padding: 8px;
  background: linear-gradient(135deg, #1a1a30, #12121e);
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  color: #c0c0d0;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.totem-btn:hover:not(:disabled) {
  border-color: #ffd700;
  color: #ffd700;
}

.totem-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.totem-btn.give {
  border-left: 3px solid #4a8c2a;
}

.totem-btn.take {
  border-left: 3px solid #c06060;
}

/* === Village Header Panel === */
#village-header-panel {
  padding: 14px 16px;
  background: linear-gradient(135deg, #1a1a28 0%, var(--bg-panel) 100%);
  border-bottom: 1px solid var(--border);
}

.village-header-name {
  font-family: var(--font-narrative);
  font-size: 1.6rem;
  font-weight: 600;
  color: #e8d5f0;
  margin-bottom: 8px;
}

.village-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.village-header-meta .director-style {
  color: var(--gold);
  text-transform: capitalize;
  font-style: italic;
  font-family: var(--font-narrative);
}

/* === Narrative Feed Panel === */
#narrative-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.narrative-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 6px 12px;
  border-bottom: 1px solid #1a1a28;
  flex-shrink: 0;
}

.narrative-feed-title {
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

/* ── Pinned Director Headlines ── */
.director-headlines {
  flex-shrink: 0;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(192, 160, 96, 0.06) 0%, rgba(192, 160, 96, 0.02) 100%);
  border-bottom: 1px solid rgba(192, 160, 96, 0.15);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.headline-entry {
  font-size: 1.1rem !important;
  padding: 6px 8px !important;
  border-radius: 4px !important;
}

/* ── Scrolling Feed Area ── */
.feed-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.feed-entry {
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 1.15rem;
  line-height: 1.4;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
}

.feed-entry .feed-tick {
  font-size: 0.9rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-right: 5px;
}

.feed-entry.type-director {
  color: var(--gold);
  font-family: var(--font-narrative);
  font-style: italic;
  border-left-color: var(--gold);
  background: rgba(192, 160, 96, 0.04);
}

.feed-entry.type-element {
  color: #c0a060;
  border-left-color: #c0a060;
}

.feed-entry.type-death {
  color: var(--red);
  border-left-color: var(--red);
  background: rgba(192, 96, 96, 0.05);
}

.feed-entry.type-intervention {
  color: #d0b0ff;
  border-left-color: var(--purple);
  background: rgba(192, 132, 252, 0.06);
}

.feed-entry.type-social {
  color: #90a0b0;
  border-left-color: #3a3a4a;
}

.feed-entry.type-corruption {
  color: #c08080;
  border-left-color: #804040;
}

.feed-entry.type-conflict {
  color: #c07070;
  border-left-color: #a04040;
}

.feed-entry.type-violence {
  color: #e74c3c;
  border-left: 3px solid #c0392b;
}

.feed-entry.type-totem {
  color: #f1c40f;
  border-left: 3px solid #f39c12;
}

.feed-show-more {
  text-align: center;
  padding: 8px;
  font-size: 1.05rem;
  color: var(--text-dim);
  cursor: pointer;
}

.feed-show-more:hover {
  color: var(--text-secondary);
}

/* Narrative feed scrollbar */
.feed-scroll-area::-webkit-scrollbar {
  width: 5px;
}

.feed-scroll-area::-webkit-scrollbar-track {
  background: transparent;
}

.feed-scroll-area::-webkit-scrollbar-thumb {
  background: #2a2a3a;
  border-radius: 3px;
}

.feed-scroll-area::-webkit-scrollbar-thumb:hover {
  background: #3a3a4a;
}

/* === Selected Creature Panel === */
#selected-creature-panel {
  border-top: 1px solid var(--border);
  max-height: 360px;
  overflow-y: auto;
}

.selected-creature-inner {
  padding: 12px;
}

.selected-creature-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  background: rgba(20, 20, 30, 0.5);
}

.selected-creature-toggle:hover {
  background: rgba(30, 30, 45, 0.5);
}

.selected-creature-toggle .toggle-arrow {
  font-size: 0.9rem;
  color: var(--text-dim);
  width: 14px;
}

.selected-creature-name {
  font-size: 1.3rem;
  font-weight: 600;
  color: #e8d5f0;
  cursor: pointer;
  flex: 1;
}

.selected-creature-name:hover {
  text-decoration: underline dashed;
}

.selected-temperament {
  font-size: 1.05rem;
  color: #9080a0;
}

/* Status pills on selected creature */
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.status-pill {
  font-size: 0.95rem;
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(100, 100, 140, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(100, 100, 140, 0.2);
}

.status-pill.harmful {
  color: var(--red);
  background: rgba(192, 96, 96, 0.1);
  border-color: rgba(192, 96, 96, 0.2);
}

.status-pill.beneficial {
  color: #80c080;
  background: rgba(96, 192, 96, 0.1);
  border-color: rgba(96, 192, 96, 0.2);
}

/* Relationships in selected creature */
.creature-relationships {
  margin-top: 8px;
}

.creature-relationships-title {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.relationship-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.05rem;
  padding: 2px 0;
}

.relationship-row .rel-name {
  flex: 1;
  color: var(--text-secondary);
}

.relationship-row .rel-score {
  font-family: var(--font-mono);
  font-size: 1.0rem;
}

.relationship-row .rel-score.positive { color: #80c080; }
.relationship-row .rel-score.negative { color: var(--red); }

/* === Divine Acts Panel === */
#divine-acts-panel {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

/* === Pulsing Auto-Play Badge (dashboard cards) === */
.auto-play-badge {
  color: #4ade80;
  font-weight: 600;
  animation: pulse-play 1.5s ease-in-out infinite;
}

@keyframes pulse-play {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === Toast Notification === */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1b4b;
  color: #c4b5fd;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  border: 1px solid #312e81;
}

#toast.visible {
  opacity: 1;
}

/* === Post-Mortem Autopsy Panel === */
#post-mortem-panel { padding: 0; }
#post-mortem-panel:empty { display: none; }

.post-mortem-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 6px;
  border-top: 2px solid var(--red);
}
.post-mortem-icon { font-size: 1.4rem; }
.post-mortem-title {
  font-family: var(--font-narrative); font-size: 1.4rem; font-weight: 600;
  color: var(--red); letter-spacing: 0.03em;
}
.post-mortem-cause {
  padding: 0 16px 12px; font-size: 1.1rem;
  color: var(--text-secondary); font-family: var(--font-narrative); font-style: italic;
}
.post-mortem-section {
  padding: 10px 16px; border-top: 1px solid var(--border);
}
.post-mortem-section-title {
  font-size: 0.85rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 8px;
}
.post-mortem-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px;
}
.pm-stat {
  display: flex; flex-direction: column;
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px;
}
.pm-stat-val {
  font-family: var(--font-mono); font-size: 1.2rem; font-weight: 500;
  color: var(--text-primary);
}
.pm-stat-label { font-size: 0.8rem; color: var(--text-dim); margin-top: 2px; }

/* Death timeline */
.pm-timeline { display: flex; flex-direction: column; gap: 4px; }
.pm-death-entry { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 1.0rem; }
.pm-death-tick { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim); min-width: 40px; }
.pm-death-name { color: var(--text-primary); flex: 1; }
.pm-death-cause { font-family: var(--font-mono); font-size: 0.85rem; color: var(--red); text-transform: capitalize; }

/* Creature fates */
.pm-creature-row { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.pm-creature-row:last-child { border-bottom: none; }
.pm-creature-name { font-size: 1.05rem; color: var(--text-primary); margin-bottom: 2px; }
.pm-creature-detail { font-size: 0.9rem; color: var(--text-secondary); }

/* === Resource Pools === */
.resource-pools {
  margin: 8px 0 0 0;
  padding: 6px 0 0 0;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.resource-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.resource-label {
  width: 28px;
  font-size: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}
.resource-track {
  flex: 1;
  height: 14px;
  background: #1a1a2e;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.resource-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s ease;
}
.resource-fill.food {
  background: linear-gradient(90deg, #2d5016, #4a8c2a);
}
.resource-fill.water {
  background: linear-gradient(90deg, #1a3a5c, #2a7abc);
}
.resource-fill.critical {
  animation: pulse-resource-critical 1s infinite;
}
.resource-fill.low.food {
  background: linear-gradient(90deg, #8c6a1a, #c9872a);
}
.resource-fill.low.water {
  background: linear-gradient(90deg, #6a5a1a, #c99a2a);
}
.resource-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
}

@keyframes pulse-resource-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

