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

:root {
  --rabbit:      #2471A3;
  --rabbit-dark: #1B5378;
  --fox:         #E67E22;
  --fox-dark:    #B85F11;
  --green:       #58CC02;
  --green-dark:  #46A302;
  --gold:        #FFD166;
  --red:         #C0392B;
  --cream:       #F5FFF5;
  --card-bg:     #FFFFFF;
  --sidebar-bg:  #2C5F2D;          /* forest green */
  --text-dark:   #3C3C3C;
  --text-mid:    #777777;
  --border:      #E8E8E8;
  --sidebar-w:   290px;
  --controls-h:  56px;
  --header-h:    64px;
  --radius:      14px;
  --radius-sm:   8px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--text-dark);
  background: var(--cream);
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ===========================
   SIDEBAR
   =========================== */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  scrollbar-width: none;
}
#sidebar::-webkit-scrollbar { display: none; }

.logo-area {
  padding: 24px 20px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.logo-icon { font-size: 2.2rem; line-height: 1; margin-bottom: 4px; }
.logo {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
}
.logo-sub {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
  margin-top: 2px;
}

.section-label {
  padding: 14px 20px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}

#stage-nav {
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}
.stage-btn:hover:not(.active) {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.25);
}
.stage-btn.active {
  background: var(--gold);
  color: var(--text-dark);
  transform: scale(1.02);
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.stage-btn.completed:not(.active)::after {
  content: '✓';
  margin-left: auto;
  color: var(--green);
  font-size: 1rem;
}
.stage-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 900;
  flex-shrink: 0;
}
.stage-btn.active .stage-num { background: rgba(0,0,0,0.12); }
.stage-btn-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  min-width: 0;
}
.stage-btn-title {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-btn-sub {
  font-size: 0.72rem;
  opacity: 0.75;
  font-weight: 600;
}

.substep-dots { display: flex; gap: 4px; margin-top: 4px; }
.substep-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.substep-dot.active { background: #fff; }
.stage-btn.active .substep-dot { background: rgba(0,0,0,0.2); }
.stage-btn.active .substep-dot.active { background: var(--text-dark); }

.lang-switcher {
  display: flex;
  gap: 4px;
  padding: 12px;
  justify-content: center;
  flex-shrink: 0;
}
.lang-btn {
  padding: 4px 10px !important;
  font-size: 0.75rem !important;
  font-weight: 900 !important;
  border-radius: 6px !important;
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
  min-width: auto;
  border: 2px solid transparent;
}
.lang-btn.active {
  background: #fff;
  color: var(--sidebar-bg);
  border-color: rgba(255,255,255,0.5);
}

/* ===========================
   MAIN AREA
   =========================== */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--cream);
}

#substep-header {
  min-height: var(--header-h);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}
#substep-title-area {
  display: flex;
  align-items: center;
  gap: 14px;
}
#stage-badge {
  background: var(--sidebar-bg);
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
#substep-title { font-size: 1.15rem; font-weight: 900; color: var(--text-dark); line-height: 1.2; }
#substep-description { font-size: 0.82rem; color: var(--text-mid); font-weight: 600; margin-top: 1px; }

/* ===========================
   QUESTION BANNER
   =========================== */
#question-box {
  margin: 12px 24px 0;
  padding: 14px 16px;
  background: #FFFBE6;
  border: 2px solid #FFD166;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-shrink: 0;
}
.question-icon { font-size: 1.1rem; flex-shrink: 0; }
.question-body { flex: 1; min-width: 0; }
#question-text { font-size: 0.9rem; font-weight: 700; color: var(--text-dark); line-height: 1.5; }
#question-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-mid);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
#question-close:hover { background: rgba(0,0,0,0.08); color: var(--text-dark); }

#question-reopen {
  position: absolute;
  top: 72px;
  left: 16px;
  z-index: 5;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #FFD166;
  background: #FFFBE6;
  color: var(--text-dark);
  font-size: 0.8rem;
  font-weight: 900;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
#question-reopen:hover { background: #FFD166; }

/* ===========================
   COUNTERS BAR
   =========================== */
#counters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  align-items: center;
}
.counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dark);
}
.counter-val { font-weight: 900; color: var(--sidebar-bg); }
.counter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.counter-dot.rabbit, .legend-dot.rabbit { background: var(--rabbit); }
.counter-dot.fox,    .legend-dot.fox    { background: var(--fox); }
.counter-dot.carrot                     { background: #FF6B35; }
.counter-dot.wolf                       { background: #6E6E73; }
.counter-caption {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-mid);
  font-style: italic;
  margin-left: auto;
}

/* ===========================
   MAIN SCROLL CONTAINER
   The whole stack of views (scene + charts + survival map + banners)
   lives inside this scroller so Stage 5 can fit on smaller screens.
   =========================== */
#main-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ===========================
   SCENE + CHARTS ROW
   Default: column stack (Stages 0-6 fall back to the original layout).
   .split-active (Stage 7): row layout with a draggable handle so the
   user can rebalance the scene vs charts widths.
   =========================== */
#scene-charts-row {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#scene-charts-row.split-active {
  flex-direction: row;
  align-items: stretch;
  /* Grow into available vertical space; floor at 360px on small screens. */
  flex: 1 1 auto;
  min-height: 360px;
  padding: 8px 12px 0;
  gap: 0;
}
#scene-charts-row.split-active #scene-view {
  flex: var(--split-left, 1) 1 0;
  min-width: 200px;
  padding: 0;
}
#scene-charts-row.split-active #scene-canvas-wrap {
  height: 100%;
}
#scene-charts-row.split-active #time-series-view {
  flex: var(--split-right, 1) 1 0;
  min-width: 200px;
  height: 100%;
  padding-top: 0;
}

/* Drag handle — invisible/disabled outside split-active. */
.split-handle {
  display: none;
}
#scene-charts-row.split-active .split-handle {
  display: block;
  flex: 0 0 6px;
  background: rgba(0,0,0,0.06);
  cursor: col-resize;
  align-self: stretch;
  margin: 0 4px;
  border-radius: 3px;
  transition: background 0.12s;
}
#scene-charts-row.split-active .split-handle:hover,
#scene-charts-row.split-active .split-handle.dragging {
  background: var(--rabbit);
}

/* ===========================
   3D SCENE VIEW
   =========================== */
#scene-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 24px 0;
  flex-shrink: 0;
}
#scene-canvas-wrap {
  width: 100%;
  height: 280px;
  min-height: 220px;
  background: #CDE7C9;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.08);
  position: relative;
}

/* Camera-mode toggle, anchored to the top-right of the scene wrap.
   Created by AgentScene._installCameraControls(). */
.scene-camera-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  background: rgba(255,255,255,0.92);
  color: var(--text-dark);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: background 0.15s, transform 0.1s;
}
.scene-camera-toggle:hover { background: #fff; }
.scene-camera-toggle:active { transform: scale(0.96); }
#scene-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.anim-caption {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rabbit-dark);
  text-align: center;
  max-width: 640px;
  line-height: 1.4;
  min-height: 1.2em;
  margin: 0;
}

/* ===========================
   TIME SERIES + PHASE LAYOUT
   Inside the scrollable #main-scroll, charts have explicit heights so
   the survival map below them can also scroll into view.
   =========================== */
#time-series-view, #phase-portrait-view {
  padding: 8px 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
#time-series-view   { height: 240px; min-height: 220px; }
#phase-portrait-view{ height: 220px; min-height: 200px; }

.chart-canvas-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
}
.chart-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-legend {
  flex-shrink: 0;
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  padding: 4px 0 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===========================
   LAG INDICATOR
   =========================== */
#lag-indicator {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 6px 24px;
  background: rgba(36,113,163,0.05);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dark);
  flex-shrink: 0;
}
.lag-cell { display: inline-flex; gap: 6px; align-items: center; }
.lag-cell.highlight { color: var(--fox-dark); }
.lag-val { font-weight: 900; color: var(--rabbit-dark); }
.lag-cell.highlight .lag-val { color: var(--fox-dark); }

/* ===========================
   SURVIVAL MAP
   =========================== */
#survival-map {
  padding: 10px 24px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 24px 0;
  flex-shrink: 0;
}
.survival-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}
.survival-map-header h3 {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--text-dark);
}
.survival-map-actions { display: flex; gap: 6px; }
.survival-map-actions button {
  padding: 6px 12px;
  font-size: 0.78rem;
  background: #f0f0f0;
  color: var(--text-dark);
}
.map-help {
  font-size: 0.74rem;
  color: var(--text-mid);
  font-style: italic;
  margin-bottom: 8px;
}
#survival-grid {
  display: grid;
  gap: 3px;
  font-size: 0.74rem;
  font-weight: 800;
}
.sg-corner, .sg-header {
  background: var(--cream);
  padding: 4px 6px;
  text-align: center;
  color: var(--text-mid);
  border-radius: 4px;
}
.sg-corner { font-weight: 900; color: var(--text-dark); }
.sg-cell {
  background: #fafafa;
  padding: 6px 4px;
  text-align: center;
  border-radius: 4px;
  border: 1px solid var(--border);
  min-height: 24px;
  color: var(--text-mid);
}
.sg-cell.ok {
  background: rgba(46,204,113,0.18);
  color: #1F7A3D;
  border-color: #2ECC71;
}
.sg-cell.fail {
  background: rgba(192,57,43,0.18);
  color: #8E1F14;
  border-color: #C0392B;
}

/* ===========================
   REINTRO PANEL
   =========================== */
#reintro-panel {
  margin: 8px 24px 0;
  padding: 10px 14px;
  background: rgba(230,126,34,0.08);
  border: 2px solid var(--fox);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.reintro-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}
.reintro-row input[type="number"] {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-weight: 700;
}
.reintro-toggle { display: inline-flex; gap: 6px; align-items: center; }
#btn-reintroduce {
  background: var(--fox);
  color: white;
  padding: 6px 12px;
  font-size: 0.85rem;
}
#btn-reintroduce:hover { background: var(--fox-dark); }
.reintro-status {
  font-size: 0.78rem;
  color: var(--fox-dark);
  font-weight: 700;
  min-height: 1.2em;
  margin-top: 4px;
}

/* ===========================
   BANNERS
   =========================== */
#collapse-banner {
  margin: 8px 24px 0;
  padding: 10px 16px;
  background: rgba(192,57,43,0.12);
  border: 2px solid var(--red);
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: var(--red);
  flex-shrink: 0;
}
#survived-banner {
  margin: 8px 24px 0;
  padding: 10px 16px;
  background: rgba(46,204,113,0.18);
  border: 2px solid #2ECC71;
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: #1F7A3D;
  flex-shrink: 0;
}

/* ===========================
   SLIDERS
   =========================== */
#slider-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 24px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
#slider-container {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  flex: 1;
}
.slider-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  font-family: 'Nunito', sans-serif;
}
.slider-group label { white-space: nowrap; font-weight: 700; }
.slider-group input[type="range"] {
  width: 140px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  cursor: pointer;
}
.slider-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  cursor: pointer;
  border: none;
}
.slider-value {
  font-weight: 900;
  color: var(--sidebar-bg);
  min-width: 80px;
  text-align: center;
}
.sliders-play-locked { opacity: 0.55; }
.sliders-play-locked input[type="range"] { cursor: not-allowed; }
/* Per-slider lock state — applied while a simulation is running or
   paused. Reset clears it. */
.slider-group.slider-locked { opacity: 0.5; }
.slider-group.slider-locked input[type="range"] { cursor: not-allowed; }
.slider-group.slider-locked label,
.slider-group.slider-locked .slider-value { color: var(--text-mid); }
.slider-accent-new {
  background: rgba(230, 126, 34, 0.08);
  border: 2px solid var(--fox);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.slider-accent-new label { color: var(--fox); }
.slider-accent-new input[type="range"]::-webkit-slider-thumb { background: var(--fox); }
.slider-accent-new input[type="range"]::-moz-range-thumb     { background: var(--fox); }
.slider-accent-new .slider-value { color: var(--fox); }

#btn-apply-changes {
  background: var(--rabbit);
  color: #fff;
  padding: 8px 14px;
  font-size: 0.85rem;
  flex-shrink: 0;
}
#btn-apply-changes:hover { background: var(--rabbit-dark); }
#btn-apply-changes:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===========================
   CONTROLS BAR
   =========================== */
#controls {
  height: var(--controls-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--card-bg);
  border-top: 2px solid var(--border);
  flex-shrink: 0;
}

.nav-group { display: flex; gap: 6px; }
.control-group { display: flex; gap: 8px; flex: 1; justify-content: center; align-items: center; flex-wrap: wrap; }

/* Speed control: a single slider with 8 discrete stops, plus a numeric
   display of the current multiplier. */
.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 4px 10px;
  background: rgba(36,113,163,0.06);
  border-radius: var(--radius-sm);
}
.speed-control #speed-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-mid);
}
#speed-slider {
  width: 130px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--rabbit);
  cursor: pointer;
}
#speed-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--rabbit);
  cursor: pointer;
  border: none;
}
.speed-value {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--rabbit);
  min-width: 38px;
  text-align: right;
}

/* Hide the top counters bar entirely while Stage 7 is active — counts
   live in the chart legend instead. */
.counters-hidden { display: none !important; }

button {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
  white-space: nowrap;
}
button:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.15); }
button:active { transform: scale(0.95); box-shadow: none; }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

#btn-play {
  background: var(--green);
  color: white;
  padding: 10px 24px;
  font-size: 1rem;
  min-width: 110px;
}
#btn-play.playing {
  background: var(--gold);
  color: var(--text-dark);
}
#btn-play:hover { background: var(--green-dark); }
#btn-play.playing:hover { background: #e5b94f; }

#btn-reset {
  background: #f0f0f0;
  color: var(--text-dark);
}
#btn-reset:hover { background: #e0e0e0; }

#btn-back, #btn-next {
  background: #f0f0f0;
  color: var(--text-dark);
  padding: 10px 14px;
}
#btn-back:hover, #btn-next:hover { background: #e0e0e0; }

#btn-run-again {
  background: var(--rabbit);
  color: white;
  padding: 10px 20px;
}
#btn-run-again:hover { background: var(--rabbit-dark); }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
}
@media (max-width: 700px) {
  :root { --sidebar-w: 200px; }
  .stage-btn-sub { display: none; }
  .substep-dots { display: none; }
  .counter { font-size: 0.74rem; }
  #survival-grid { font-size: 0.66rem; }
}

/* ===========================
   REDUCED MOTION
   =========================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================
   FLOATING HOME BUTTON
   =========================== */
#home-btn {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #333;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.08);
  transition: transform 0.12s, box-shadow 0.12s;
}
#home-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

/* ===========================
   STAGE 0 — ACTOR SHOWCASE
   Four cards explaining the food chain. No simulation runs.
   =========================== */
#showcase-view {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  padding: 32px 24px;
  flex: 1 1 auto;
  align-content: center;
}
@media (max-width: 900px) {
  #showcase-view { grid-template-columns: repeat(2, 1fr); }
}
.actor-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.actor-card .actor-icon {
  font-size: 4rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.12s, background 0.12s;
}
.actor-card .actor-icon:hover {
  transform: scale(1.08);
  background: rgba(0,0,0,0.04);
}
.actor-card .actor-icon svg {
  width: 4rem;
  height: 4rem;
}
.actor-card .actor-icon.busy { cursor: progress; opacity: 0.45; }
.actor-card .actor-icon.hidden { visibility: hidden; }

/* Animated clones used by the showcase click animations.
   They live on document.body during a single animation cycle. */
.showcase-flier {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  font-size: 4rem;
  line-height: 1;
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.7s cubic-bezier(0.4, 0.0, 0.2, 1),
              opacity 0.4s ease;
  will-change: transform, opacity;
}
.showcase-flier svg { width: 4rem; height: 4rem; }
.showcase-shot-line {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  background: rgba(192, 57, 43, 0.85);
  height: 3px;
  border-radius: 2px;
  transform-origin: left center;
  box-shadow: 0 0 6px rgba(192, 57, 43, 0.6);
  transition: opacity 0.25s ease;
}
.actor-card h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-dark);
  margin: 0;
}
.actor-card p {
  font-size: 0.95rem;
  color: var(--text-mid);
  line-height: 1.45;
  margin: 0;
}

/* ===========================
   SCENE POPUPS
   Extinction / survived notifications floated over the 3D scene.
   =========================== */
#scene-canvas-wrap { position: relative; }   /* anchor for absolute popups */
.scene-popup {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(80%, 480px);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  z-index: 10;
  /* Flex so the close button is its own column — text wraps inside the
     remaining space and can never slide under the × button. */
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.scene-popup > span {
  flex: 1 1 auto;
  line-height: 1.35;
  min-width: 0;
}
#collapse-banner.scene-popup {
  background: rgba(192, 57, 43, 0.95);  /* red */
  color: #fff;
  border: 1px solid rgba(0,0,0,0.15);
}
#survived-banner.scene-popup {
  background: rgba(46, 204, 113, 0.95); /* green */
  color: #fff;
  border: 1px solid rgba(0,0,0,0.15);
}
.scene-popup-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: -2px;            /* nudge to align with first text line */
  border: none;
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.scene-popup-close:hover { background: rgba(255,255,255,0.35); }
