* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #050811;
  color: #e2e8f0;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 960px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #f8fafc;
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  background: #0b1426;
  border: 1px solid #1e293b;
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: 9999px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.2); }
}

.subtitle {
  margin: 0;
  font-size: 13.5px;
  color: #94a3b8;
  line-height: 1.4;
}

.canvas-wrapper {
  background: #03060e;
  border: 1px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  cursor: crosshair;
  touch-action: none;
}

#sim {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Climate & Weather HUD Bar */
.climate-bar {
  background: #090f20;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.climate-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.climate-icon {
  font-size: 20px;
}

.climate-meta {
  display: flex;
  flex-direction: column;
}

.climate-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  font-weight: 600;
}

.climate-val {
  font-size: 13px;
  color: #38bdf8;
  font-weight: 600;
}

.stats-item {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #94a3b8;
}

.stats-item b {
  color: #f1f5f9;
}

/* Controls & Seeding Tools Panel */
.controls-panel {
  background: #080d1a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.controls-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #cbd5e1;
}

.active-tool-label {
  font-size: 12px;
  color: #94a3b8;
}

.active-tool-label b {
  color: #38bdf8;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.tool-btn {
  background: #0b1426;
  border: 1px solid #1e293b;
  color: #cbd5e1;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tool-btn:hover {
  background: #13223f;
  border-color: #38bdf8;
  color: #f8fafc;
}

.tool-btn.active {
  background: #1e3a8a;
  border-color: #60a5fa;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

/* Trophic Sparkline Graph Panel */
.graph-panel {
  background: #080d1a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.graph-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #cbd5e1;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #94a3b8;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.plant-dot { background: #22c55e; }
.grazer-dot { background: #f97316; }
.predator-dot { background: #f43f5e; }

#graphCanvas {
  width: 100%;
  height: 90px;
  display: block;
  background: #040711;
  border: 1px solid #131d31;
  border-radius: 4px;
}

/* Chronicle Panel */
.panel {
  background: #080d1a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #cbd5e1;
}

.epoch-counter {
  font-size: 11px;
  font-family: monospace;
  background: #111a2e;
  border: 1px solid #1e293b;
  color: #38bdf8;
  padding: 2px 8px;
  border-radius: 4px;
}

.log {
  max-height: 160px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.log .epoch {
  color: #38bdf8;
  font-weight: 500;
  padding-top: 2px;
}

.log .event {
  color: #f1f5f9;
}

footer {
  text-align: center;
  margin-top: auto;
}

.meta-tag {
  margin: 0;
  font-size: 12px;
  color: #64748b;
}
