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

body {
  background: #2a4a64;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e0e0e0;
  user-select: none;
}

#world-canvas {
  display: block;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

/* ── HUD overlay ─────────────────────────────── */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(10,20,36,0.72) 0%, transparent 100%);
}

/* ── Hamburger ───────────────────────────────── */

#hamburger-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e0e0e0;
  width: 32px; height: 32px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.12s;
  pointer-events: all;
  flex-shrink: 0;
}

#hamburger-btn:hover,
#hamburger-btn.open {
  background: rgba(255,255,255,0.18);
}

/* ── Settings panel ──────────────────────────── */

#settings-panel {
  position: absolute;
  top: 52px;
  right: 16px;
  width: 220px;
  background: rgba(12, 22, 38, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 14px 16px;
  pointer-events: all;
  z-index: 10;
}

#settings-panel.hidden { display: none; }

.settings-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 12px;
}

.settings-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin-bottom: 14px;
}

.stats-section { margin-bottom: 14px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 0.25rem 0;
  opacity: 0.9;
}
.stat-label { color: #8aa6c0; }
.stat-row span:last-child { color: #c5e0f8; font-weight: 500; }

.achievement-row { padding: 0.25rem 0; }
.achievement-row.locked { opacity: 0.35; }
.achievement-title { font-size: 12px; color: #c5e0f8; font-weight: 500; }
.achievement-desc { font-size: 10px; color: #8aa6c0; }

.timeline-entry {
  display: flex;
  gap: 6px;
  font-size: 11px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.timeline-day {
  margin-left: auto;
  white-space: nowrap;
  opacity: 0.45;
}

#reset-btn {
  width: 100%;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
  text-align: left;
}

#reset-btn:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.6);
}

.reset-warning {
  font-size: 11px;
  opacity: 0.35;
  margin-top: 8px;
  line-height: 1.5;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.setting-label {
  font-size: 12px;
  opacity: 0.7;
}

.setting-value {
  font-size: 13px;
  font-weight: 600;
  color: #f59e0b;
  min-width: 24px;
  text-align: right;
}

#pop-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.12);
  outline: none;
  margin-bottom: 4px;
  cursor: pointer;
}

#pop-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f59e0b;
  cursor: pointer;
  transition: transform 0.1s;
}

#pop-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

#pop-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f59e0b;
  border: none;
  cursor: pointer;
}

#world-info {
  display: flex;
  gap: 10px;
  font-size: 13px;
}

#world-info span {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

#pop-info {
  font-size: 13px;
  opacity: 0.7;
  display: flex;
  gap: 20px;
}

/* ── Notifications ───────────────────────────── */

#notifications {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: none;
  width: 360px;
}

.notification-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.notification-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.35;
  align-self: flex-start;
}

.notification {
  background: rgba(12, 22, 38, 0.88);
  border-left: 3px solid #f59e0b;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  animation: notif-fade 5s forwards;
}

.notification-env {
  border-left-color: #22c55e;
}

.notification-social {
  border-left-color: #f59e0b;
}

@keyframes notif-fade {
  0%   { opacity: 0; transform: translateY(-6px); }
  12%  { opacity: 1; transform: translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Bottom bar ──────────────────────────────── */

#hud-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 14px 16px;
  background: linear-gradient(0deg, rgba(0,0,0,0.65) 0%, transparent 100%);
  pointer-events: none;
}

/* ── Concepts panel ──────────────────────────── */

#concepts-panel {
  min-width: 190px;
  pointer-events: all;
}

.panel-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.4;
  margin-bottom: 8px;
}

#concepts-list {
  font-size: 13px;
  line-height: 1.7;
}

#concepts-list em {
  opacity: 0.3;
  font-style: normal;
}

.concept-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.concept-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}

.concept-spread {
  font-size: 11px;
  opacity: 0.45;
  margin-left: auto;
  padding-left: 8px;
}

.discoveries-view-all {
  font-size: 11px;
  opacity: 0.5;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.15s;
}

.discoveries-view-all:hover {
  opacity: 0.85;
}

/* ── Discoveries modal ─────────────────────────── */

#discoveries-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20;
  pointer-events: all;
}

#discoveries-modal.hidden { display: none; }

#discoveries-modal-card {
  background: rgba(12, 22, 38, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 20px 24px;
  max-width: 420px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
}

#discoveries-modal-card .panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#discoveries-modal-close {
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}

#discoveries-modal-close:hover {
  opacity: 1;
}

#discoveries-modal-list .concept-item {
  padding: 3px 0;
}

/* ── Speed controls ──────────────────────────── */

#speed-controls {
  display: flex;
  gap: 4px;
  pointer-events: all;
}

.speed-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e0e0e0;
  padding: 6px 13px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  pointer-events: all;
}

.speed-btn:hover {
  background: rgba(255,255,255,0.14);
}

.speed-btn.active {
  background: rgba(245,158,11,0.2);
  border-color: rgba(245,158,11,0.45);
  color: #f59e0b;
}

/* ── Info panel ──────────────────────────────── */

#info-panel {
  position: absolute;
  top: 52px;
  right: 16px;
  width: 210px;
  background: rgba(12, 22, 38, 0.92);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 14px;
  pointer-events: all;
}

#info-panel.hidden {
  display: none;
}

#info-close {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.4;
  padding: 4px 6px;
  border-radius: 3px;
  line-height: 1;
}

#info-close:hover { opacity: 1; }

#info-content { font-size: 13px; line-height: 1.65; }

.info-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.info-label { opacity: 0.45; font-size: 12px; }

.info-bar-wrap {
  width: 80px;
  height: 5px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.info-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: #4ade80;
  transition: width 0.4s;
}

.info-bar-fill.warn { background: #fbbf24; }
.info-bar-fill.crit { background: #f87171; }

.info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.info-tag {
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.28);
  color: #f59e0b;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
}

.info-state {
  font-size: 11px;
  opacity: 0.5;
  text-transform: capitalize;
  letter-spacing: 0.03em;
}

/* ── Loading screen ──────────────────────────── */

#loading {
  position: fixed;
  inset: 0;
  background: #2a4a64;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.6s;
}

#loading.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loading-text {
  font-size: 14px;
  opacity: 0.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── Game Over overlay ───────────────────────── */

#game-over {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  animation: go-fade-in 1.2s ease forwards;
}

#game-over.hidden { display: none; }

/* ── Error banner ─────────────────────────────────────────────────────────── */
#error-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(185, 28, 28, 0.92);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  color: #fecaca;
  font-size: 13px;
  z-index: 1000;
  pointer-events: all;
}
#error-banner.hidden { display: none; }
#error-banner #error-message { flex: 1; }
#error-banner #error-dismiss {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: none;
  color: inherit;
  width: 28px; height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

@keyframes go-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#game-over-card {
  background: rgba(12, 22, 38, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 36px 44px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  animation: go-card-in 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes go-card-in {
  from { transform: translateY(24px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

#game-over-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f87171;
  margin-bottom: 6px;
}

#game-over-subtitle {
  font-size: 13px;
  opacity: 0.4;
  margin-bottom: 24px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#game-over-stats {
  font-size: 14px;
  line-height: 2;
  opacity: 0.75;
  margin-bottom: 28px;
  border-top: 1px solid rgba(255,255,255,0.07);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 16px 0;
}

#game-over-stats strong {
  color: #f59e0b;
  font-weight: 600;
}

#game-over-reset {
  width: 100%;
  padding: 11px 16px;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: background 0.15s, border-color 0.15s;
}

#game-over-reset:hover {
  background: rgba(239, 68, 68, 0.26);
  border-color: rgba(239, 68, 68, 0.65);
}

/* ── Stats panel (CAD-155) ───────────────────────────────────────────── */

#stats-panel {
  position: absolute;
  top: 52px;
  left: 16px;
  width: 180px;
  background: rgba(12, 22, 38, 0.88);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 8px;
  padding: 10px 14px;
  pointer-events: none;
  font-size: 12px;
  line-height: 1.7;
}

/* The panel itself is click-through, but its buttons must stay interactive
   (overlay toggles: graph, knowledge, resource, heatmap, timeline) */
#stats-panel button {
  pointer-events: all;
}

/* Overlay panels sit inside the click-through #hud — without this their
   close buttons and scrollbars receive no pointer events */
#timeline-panel,
#pop-graph-panel,
#knowledge-overlay-panel {
  pointer-events: all;
}

/* Seed input + New World button (in the click-through #hud-top) */
#seed-controls input,
#seed-controls button {
  pointer-events: all;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.stats-row-label {
  opacity: 0.45;
  flex-shrink: 0;
}

.stats-row-value {
  color: #c5e0f8;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Speech bubble (CAD-330) ─────────────────────────────────────────── */

.speech-bubble {
  position: fixed;
  background: rgba(10, 20, 38, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  color: #f5c542;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  transition: opacity 0.4s;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(245, 158, 11, 0.5);
}

/* ── Follow mode button (CAD-156) ────────────────────────────────────── */

#follow-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 12px;
  background: rgba(99,179,237,0.12);
  border: 1px solid rgba(99,179,237,0.35);
  color: #93c5fd;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
  text-align: center;
  transition: background 0.12s;
  pointer-events: all;
}

#follow-btn:hover {
  background: rgba(99,179,237,0.22);
}

#follow-btn.active {
  background: rgba(99,179,237,0.28);
  border-color: rgba(99,179,237,0.7);
  color: #bfdbfe;
}

/* ── Discovery ring (CAD-331) ────────────────────────────────────────── */

@keyframes discovery-ring {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(3.0); opacity: 0; }
}

.discovery-ring {
  position: fixed;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #f5c542;
  box-shadow: 0 0 8px 2px rgba(245,197,66,0.6);
  pointer-events: none;
  z-index: 199;
  animation: discovery-ring 1s ease-out forwards;
  /* centred on injected left/top */
  margin-left: -20px;
  margin-top: -20px;
}

