:root {
  --bg: #0d1a16;
  --panel: rgba(13, 31, 25, 0.88);
  --panel-border: rgba(180, 228, 173, 0.16);
  --text: #edf4e8;
  --muted: #a9bcae;
  --grass: #7ddf64;
  --herbivore: #f8d576;
  --carnivore: #ff7967;
  --accent: #86f0d5;
  --warning: #ffb04f;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(65, 134, 112, 0.35), transparent 35%),
    linear-gradient(180deg, #0f241d 0%, #08110d 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
}

.topbar-stats {
  display: flex;
  gap: 12px;
}

.goal-box,
.panel {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.goal-box {
  min-width: 120px;
  padding: 14px 16px;
  border-radius: 18px;
}

.goal-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: 24px;
  padding: 20px;
}

.metrics-panel,
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.metric-list {
  display: grid;
  gap: 12px;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.metric-copy {
  display: grid;
  gap: 4px;
}

.metric span {
  color: var(--muted);
}

.metric-signal {
  color: #dbe9dd;
  font-size: 0.74rem;
  letter-spacing: 0.01em;
}

.metric strong {
  font-size: 1.1rem;
}

.metric.metric-safe {
  background: rgba(255, 255, 255, 0.04);
}

.metric.metric-warning {
  background: rgba(255, 177, 79, 0.12);
  border-color: rgba(255, 177, 79, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 177, 79, 0.08);
}

.metric.metric-danger {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.4);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.12);
}

.metric.metric-calm {
  background: rgba(113, 214, 255, 0.12);
  border-color: rgba(113, 214, 255, 0.35);
}

.meter-group {
  display: grid;
  gap: 10px;
}

.meter-group label {
  color: var(--muted);
}

.meter {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease;
}

.oxygen-fill {
  background: linear-gradient(90deg, #3eb8ff 0%, #85ffe0 100%);
}

.stability-fill {
  background: linear-gradient(90deg, #ff9d3c 0%, #98ff7b 100%);
}

.legend {
  display: grid;
  gap: 10px;
}

.legend p {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.legend-icon {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
}

.canvas-panel {
  position: relative;
  overflow: hidden;
  padding: 16px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, #9cd0e8 0%, #406b3f 100%);
}

.canvas-overlay {
  position: absolute;
  inset: 28px 28px auto 28px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.badge {
  min-width: 130px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(7, 17, 13, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.badge span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.warning-badge strong {
  color: var(--warning);
}

.control-block {
  display: grid;
  gap: 10px;
}

.control-block label,
.tips p,
.log-panel {
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
}

select,
button {
  border: 0;
  border-radius: 14px;
}

select {
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.control-value {
  display: flex;
  justify-content: flex-end;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
  padding: 13px 14px;
  color: #0c160f;
  background: linear-gradient(135deg, #bafc95 0%, #7de6c4 100%);
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    filter 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

button.secondary {
  background: linear-gradient(135deg, #f4d89b 0%, #ff8f75 100%);
}

button.button-attention {
  animation: buttonPulse 0.95s ease-in-out infinite;
  box-shadow:
    0 0 0 0 rgba(255, 196, 110, 0.45),
    0 12px 24px rgba(0, 0, 0, 0.18);
}

button.button-danger {
  background: linear-gradient(135deg, #ffd0b8 0%, #ff7d7d 100%);
}

@keyframes buttonPulse {
  0%,
  100% {
    transform: translateY(0);
    filter: saturate(1);
    box-shadow:
      0 0 0 0 rgba(255, 196, 110, 0.18),
      0 10px 20px rgba(0, 0, 0, 0.12);
  }

  50% {
    transform: translateY(-1px) scale(1.02);
    filter: saturate(1.1);
    box-shadow:
      0 0 0 10px rgba(255, 196, 110, 0),
      0 14px 28px rgba(0, 0, 0, 0.2);
  }
}

.tips,
.log-panel {
  display: grid;
  gap: 10px;
}

.log-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.log-panel li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  line-height: 1.35;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .canvas-panel {
    order: -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-stats,
  .button-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .canvas-overlay {
    inset: 22px 22px auto 22px;
    flex-direction: column;
    gap: 8px;
  }
}
