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

body {
  background: #0a0610;
  overflow: hidden;
  height: 100svh;
  font-family: 'DM Mono', ui-monospace, monospace;
  color: #e8e0f0;
  user-select: none;
}

#sim-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#sim-hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.sim-back {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #a090b8;
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  pointer-events: auto;
  transition: color 0.15s;
}
.sim-back:hover { color: #e8e0f0; }

#hud-clock {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  pointer-events: none;
}

#clock-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #c8b8e0;
  text-transform: uppercase;
}

.clock-bar {
  width: 120px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.clock-fill {
  height: 100%;
  width: 0%;
  background: #f5c060;
  border-radius: 2px;
  transition: width 0.3s linear, background 1s ease;
}


#hud-controls {
  position: absolute;
  top: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(10, 6, 16, 0.75);
  border: 1px solid #4040608a;
  color: #c8b8e0;
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.15s, color 0.15s;
}
.hud-btn:hover {
  border-color: #6ab0f5;
  color: #e8e0f0;
}
.hud-btn.active {
  border-color: #6ab0f5;
  color: #6ab0f5;
  background: rgba(106, 176, 245, 0.12);
}

.speed-group {
  display: flex;
  gap: 0.25rem;
}
.speed-btn {
  padding: 0.3rem 0.5rem;
}

/* ── right-side column ──────────────────────── */
#hud-right {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  min-width: 200px;
}

.panel-label {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: #6a5880;
  text-transform: uppercase;
}

#hud-env {
  background: rgba(10, 6, 16, 0.82);
  border: 1px solid #30284060;
  padding: 0.6rem 1rem 0.7rem;
}

.env-chips {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.env-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.env-icon {
  font-size: 0.85rem;
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
}

.env-name {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: #a090b8;
  flex: 1;
}

.env-row.env-event .env-name {
  color: #c8913a;
  font-weight: 600;
}

@keyframes env-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
.env-row.env-event {
  animation: env-pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .env-row.env-event { animation: none; }
}

#hud-population {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(10, 6, 16, 0.82);
  border: 1px solid #30284060;
  padding: 0.75rem 1rem;
  pointer-events: none;
}

.pop-row {
  display: grid;
  grid-template-columns: 10px 1fr 80px 28px;
  align-items: center;
  gap: 0.4rem;
}

.pop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pop-name {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: #a090b8;
}

.pop-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.pop-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.pop-count {
  font-size: 0.65rem;
  color: #c8b8e0;
  text-align: right;
}

.info-panel {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: 230px;
  background: rgba(10, 6, 16, 0.82);
  border: 1px solid #30284060;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}

.info-tabs {
  display: flex;
  border-bottom: 1px solid #30284060;
}

.info-tab {
  flex: 1;
  background: none;
  border: none;
  color: #604868;
  font-family: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.5rem 0;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.info-tab:hover { color: #a090b8; }
.info-tab.active {
  color: #6ab0f5;
  background: rgba(106, 176, 245, 0.08);
}

.info-content {
  padding: 0.75rem 0.9rem;
  height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a3060 transparent;
}

.info-content::-webkit-scrollbar {
  width: 4px;
}
.info-content::-webkit-scrollbar-track {
  background: transparent;
}
.info-content::-webkit-scrollbar-thumb {
  background: #4a3060;
  border-radius: 2px;
}
.info-content::-webkit-scrollbar-thumb:hover {
  background: #7a50a0;
}

.info-trait-head {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a090b8;
  margin: 0.4rem 0 0.35rem;
}
.info-trait-head:first-child { margin-top: 0; }

.info-trait {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
}

.info-trait-desc {
  font-size: 0.6rem;
  color: #c8b8e0;
  line-height: 1.3;
}

.info-keys {
  border-collapse: collapse;
  font-size: 0.66rem;
  width: 100%;
}
.info-keys td { padding: 0.22rem 0.5rem 0.22rem 0; color: #c8b8e0; }
.info-keys td:first-child { color: #e8e0f0; font-weight: bold; white-space: nowrap; }

.help-note {
  font-size: 0.62rem;
  color: #6ab0f5;
  letter-spacing: 0.04em;
}

.info-event-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.info-event-icon {
  font-size: 0.85rem;
  width: 1.2em;
  text-align: center;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.info-event-name {
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: #c8b8e0;
  text-transform: uppercase;
}

.hud-nametags {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.nametag {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(10, 6, 16, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.05rem 0.35rem;
  border-radius: 2px;
  white-space: nowrap;
  will-change: transform, opacity;
}

.hud-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 12;
}
.hud-crosshair::before,
.hud-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.7);
}
.hud-crosshair::before {
  top: 50%; left: 0; width: 100%; height: 1px; transform: translateY(-50%);
}
.hud-crosshair::after {
  left: 50%; top: 0; height: 100%; width: 1px; transform: translateX(-50%);
}
.hud-crosshair.locked::before,
.hud-crosshair.locked::after {
  background: #6ab0f5;
}

.hud-search {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  pointer-events: auto;
  background: rgba(10, 6, 16, 0.82);
  border: 1px solid #30284060;
  padding: 0.4rem 0.5rem;
}
.hud-search input {
  background: rgba(0,0,0,0.3);
  border: 1px solid #30284080;
  color: #e8e0f0;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.3rem 0.5rem;
  width: 150px;
  outline: none;
}
.hud-search input:focus { border-color: #6ab0f5; }
.hud-search input::placeholder { color: #604868; }

#hud-graph {
  position: absolute;
  bottom: 3.5rem;
  right: 1rem;
  width: 200px;
  height: 70px;
  border: 1px solid #30284060;
  background: rgba(10, 6, 16, 0.82);
  display: block;
  pointer-events: none;
}

.inspect-panel {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  width: 240px;
  background: rgba(10, 6, 16, 0.9);
  border: 1px solid #6ab0f580;
  padding: 0.85rem 1rem;
  pointer-events: auto;
  transform: translateX(-110%);
  transition: transform 0.22s cubic-bezier(0.16,1,0.3,1);
}

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

.inspect-header {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #30284060;
  padding-bottom: 0.5rem;
}

.inspect-type {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: #6ab0f5;
  text-transform: uppercase;
  flex: 1;
}

.inspect-id {
  font-size: 0.6rem;
  color: #504060;
}

.inspect-close {
  background: none;
  border: none;
  color: #a090b8;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
  margin-left: auto;
}
.inspect-close:hover { color: #e8e0f0; }

.inspect-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.inspect-name {
  font-family: 'Basteleur', 'Georgia', serif;
  font-size: 1.05rem;
  color: #e8e0f0;
  letter-spacing: 0.03em;
}

.trait-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.2rem;
}

.trait {
  font-size: 0.56rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.trait-good { color: #6ad08a; }
.trait-bad { color: #e07060; }

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
}

.stat-label { color: #a090b8; }
.stat-val { color: #e8e0f0; }

.stat-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

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

.inspect-deceased {
  font-size: 0.7rem;
  color: #804040;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 0.5rem 0;
}

.inspect-focus {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
  color: #e8e0f0;
}

.inspect-focus .focus-label {
  color: #c8913a;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
  margin-right: 0.4rem;
}

[hidden] { display: none !important; }

.controls-help {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(10, 6, 16, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.help-inner {
  border: 1px solid #30284090;
  padding: 2rem 2.5rem;
  background: rgba(20, 12, 28, 0.9);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.help-inner h2 {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6ab0f5;
  font-weight: normal;
}

.help-inner table {
  border-collapse: collapse;
  font-size: 0.72rem;
}

.help-inner td {
  padding: 0.25rem 0.8rem 0.25rem 0;
  color: #c8b8e0;
}

.help-inner td:first-child {
  color: #e8e0f0;
  font-weight: bold;
  min-width: 90px;
}

.extinction-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 6, 16, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.extinction-inner {
  border: 1px solid #c4607a80;
  background: rgba(20, 12, 28, 0.95);
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 380px;
  text-align: center;
}

.extinction-inner h2 {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #e07060;
  font-weight: normal;
}

.extinction-inner p {
  font-size: 0.75rem;
  color: #c8b8e0;
  line-height: 1.5;
}

.extinction-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.desktop-only {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0a0610;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.desktop-only-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 420px;
}

.desktop-only-inner h1 {
  font-family: 'Basteleur', 'Georgia', serif;
  font-size: clamp(1.8rem, 6vw, 3rem);
  color: #c8b8e0;
  font-weight: normal;
  letter-spacing: 0.05em;
}

.desktop-only-inner p {
  font-size: 0.8rem;
  color: #a090b8;
  line-height: 1.5;
}

.desktop-only-inner .hud-btn {
  text-decoration: none;
  margin-top: 0.5rem;
}

.startup-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0a0610;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

.startup-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.startup-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 520px;
  width: 90%;
}

.startup-title {
  font-family: 'Basteleur', 'Georgia', serif;
  font-size: clamp(2rem, 6vw, 3.5rem);
  color: #c8b8e0;
  font-weight: normal;
  letter-spacing: 0.05em;
}

.startup-sub {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #604868;
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 100%;
}

.config-group {
  border-top: 1px solid #30284060;
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-group-label {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #6ab0f5;
  margin-bottom: 0.2rem;
}

.config-note {
  font-size: 0.62rem;
  line-height: 1.45;
  color: #7c6c90;
  margin: 0.1rem 0 0;
}

.config-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
}

.config-row label {
  font-size: 0.68rem;
  color: #a090b8;
  letter-spacing: 0.04em;
}

.config-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
  accent-color: #c4607a;
}

.config-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #c4607a;
  cursor: pointer;
  transition: background 0.15s;
}

.config-row input[type="range"]::-webkit-slider-thumb:hover {
  background: #e8b0c0;
}

.cfg-val {
  font-size: 0.68rem;
  color: #e8e0f0;
  text-align: right;
}

.start-btn {
  background: none;
  border: 1px solid #c4607a;
  color: #c4607a;
  font-family: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.75rem 2.5rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-top: 0.5rem;
}

.start-btn:hover {
  background: #c4607a;
  color: #0a0610;
}

@media (prefers-reduced-motion: reduce) {
  .inspect-panel,
  .startup-screen,
  .stat-fill,
  .pop-fill,
  .clock-fill { transition: none; }
}
