:root {
  color-scheme: dark;
  --bg: #06131c;
  --bg-accent: #0f2433;
  --panel: rgba(9, 27, 39, 0.9);
  --panel-strong: rgba(12, 34, 49, 0.94);
  --line: rgba(160, 208, 236, 0.18);
  --text: #ecf7ff;
  --muted: #a7c5d7;
  --accent: #83f0d3;
  --accent-strong: #f4b860;
  --warning: #ffb4a2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(45, 156, 219, 0.18), transparent 28%),
    radial-gradient(circle at right center, rgba(131, 240, 211, 0.12), transparent 24%),
    linear-gradient(145deg, #051018 0%, #0a1824 38%, #07131d 100%);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: 100vh;
}

.control-panel {
  padding: 28px;
  backdrop-filter: blur(28px);
  background:
    linear-gradient(180deg, rgba(6, 19, 28, 0.94), rgba(8, 23, 35, 0.88)),
    rgba(7, 18, 29, 0.88);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.panel-header,
.control-group,
.info-card,
.stats-grid,
.notes-card {
  margin-bottom: 22px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 0.95;
  margin-bottom: 14px;
}

.intro,
.hint,
#shape-description,
.notes-card p {
  color: var(--muted);
  line-height: 1.55;
}

.control-group,
.info-card,
.notes-card,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-group,
.info-card,
.notes-card {
  padding: 18px;
}

label,
.stat-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #d6ebf8;
}

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

select {
  margin-top: 10px;
  border: 1px solid rgba(131, 240, 211, 0.28);
  border-radius: 14px;
  padding: 14px;
  background: rgba(8, 22, 31, 0.95);
  color: var(--text);
  font: inherit;
}

.range-header,
.range-caption,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.range-header {
  margin-bottom: 10px;
}

.range-caption {
  margin-top: 8px;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
}

output,
.mono,
.equation {
  font-family: "IBM Plex Mono", monospace;
}

output {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 500;
}

input[type="range"] {
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(131, 240, 211, 0.25), rgba(244, 184, 96, 0.8));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid white;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(131, 240, 211, 0.16);
  cursor: pointer;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  margin-top: 14px;
  background: linear-gradient(135deg, var(--accent), #4fb7ff);
  color: #06202c;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

button.secondary {
  background: rgba(15, 44, 62, 0.88);
  color: var(--text);
}

.button-row {
  gap: 10px;
}

.equation {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(5, 16, 24, 0.82);
  color: #cefbe8;
  font-size: 0.87rem;
  line-height: 1.45;
}

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

.stat-card {
  padding: 14px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1rem;
}

.viewport-shell {
  position: relative;
  min-height: 100vh;
}

#viewport {
  position: absolute;
  inset: 0;
}

.viewport-overlay {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

.viewport-overlay span {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 24, 35, 0.64);
  color: #d4e7f4;
  backdrop-filter: blur(18px);
}

.runtime-error {
  position: absolute;
  top: 22px;
  right: 22px;
  max-width: min(520px, calc(100% - 44px));
  padding: 14px 16px;
  border: 1px solid rgba(255, 180, 162, 0.4);
  border-radius: 16px;
  background: rgba(52, 13, 10, 0.88);
  color: #ffd8cf;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
  z-index: 3;
}


@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .viewport-shell {
    min-height: 60vh;
  }
}
