:root {
  --cream: #eef2f1;
  --navy: #081f30;
  --cyan: #68d9df;
  --gold: #f5ca77;
  --text: #081f30;
  --focus: #f5ca77;
  --panel: #f8fbfa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top right, #f8f6eb 0%, var(--cream) 55%, #e6eeec 100%);
  color: var(--text);
}

.page {
  width: min(1280px, 100% - 2rem);
  margin: 1rem auto 2rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1.05;
  color: var(--navy);
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: clamp(1.1rem, 1.8vw, 1.5rem);
  color: var(--navy);
}

.summary {
  max-width: 70ch;
  margin: 0.75rem 0 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.35rem 0.75rem;
  background: rgba(8, 31, 48, 0.07);
  border: 1px solid rgba(8, 31, 48, 0.2);
  border-radius: 10px;
  padding: 0.7rem;
  margin-top: 1rem;
}

.stats p {
  margin: 0;
}

.layout {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1.35fr);
  gap: 1rem;
  align-items: start;
}

.left,
.right {
  min-width: 0;
}

.pond-frame {
  position: relative;
  background: #d6dfdd;
  border-radius: 12px;
  padding: 0.6rem;
  border: 2px solid rgba(8, 31, 48, 0.2);
}

#pond {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  background: var(--navy);
  border-radius: 8px;
  display: block;
}

.extinction-overlay {
  position: absolute;
  inset: 1rem;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  background: rgba(8, 31, 48, 0.78);
  color: #fff;
  border-radius: 8px;
  padding: 0.75rem;
}

.extinction-overlay[hidden] {
  display: none;
}

.extinction-overlay p {
  margin: 0.2rem 0;
}

.cameo-card {
  margin-top: 0.7rem;
  padding: 0.55rem;
  background: rgba(8, 31, 48, 0.05);
  border: 1px solid rgba(8, 31, 48, 0.2);
  border-radius: 8px;
}

.cameo-card svg {
  width: 100%;
  max-height: 140px;
  display: block;
}

.cameo-card p {
  margin: 0.4rem 0 0;
}

.cameo-note {
  font-size: 0.86rem;
}

.legend {
  margin-top: 0.7rem;
  padding: 0.55rem;
  background: rgba(8, 31, 48, 0.05);
  border: 1px solid rgba(8, 31, 48, 0.2);
  border-radius: 8px;
}

.legend h2,
.charts h2,
.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.legend-strip {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  border: 1px solid rgba(8, 31, 48, 0.25);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.9rem;
}

.charts {
  margin-top: 0.75rem;
  padding: 0.55rem;
  background: rgba(8, 31, 48, 0.05);
  border: 1px solid rgba(8, 31, 48, 0.2);
  border-radius: 8px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

figure {
  margin: 0;
}

figcaption {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

figure canvas {
  width: 100%;
  height: 120px;
  border-radius: 6px;
  border: 1px solid rgba(8, 31, 48, 0.2);
  background: #f3f8f7;
}

#meanText {
  margin: 0.55rem 0 0;
  font-size: 0.95rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(8, 31, 48, 0.24);
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.85rem;
}

.row {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.7rem;
}

label,
input,
select,
button {
  font-size: 1rem;
  color: var(--navy);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid rgba(8, 31, 48, 0.45);
  border-radius: 6px;
  padding: 0.42rem;
  background: #fff;
}

button {
  border: 1px solid rgba(8, 31, 48, 0.6);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  background: linear-gradient(180deg, #f9f4e7, #f2e2bc);
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(0.98);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.note {
  margin: 0;
  font-size: 0.92rem;
}

.inspector p {
  margin: 0.2rem 0;
}

details {
  margin-top: 0.8rem;
  background: rgba(8, 31, 48, 0.05);
  border: 1px solid rgba(8, 31, 48, 0.2);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.explain p {
  margin: 0.45rem 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.credits {
  margin-top: 0.8rem;
  font-size: 0.92rem;
}

.credits p {
  margin: 0.25rem 0;
}

.credits a {
  color: var(--navy);
}

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

  .left { display: contents; }
  .pond-frame { order: 0; }
  .right { order: 1; }
  .cameo-card { order: 2; }
  .legend { order: 3; }
  .charts { order: 4; }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}
