:root {
  --bg: #05070a;
  --panel: rgba(10, 13, 18, 0.74);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #cdd6e4;
  --text-dim: #7d8aa0;
  --accent: #6ee7ff;
  --accent-dim: rgba(110, 231, 255, 0.35);
  font-size: 16px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

canvas#sim {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 120% 100% at 50% 45%,
              transparent 62%, rgba(0, 0, 0, 0.38) 100%);
}

/* ---- branding ---- */
.brand {
  position: fixed;
  top: 22px;
  left: 26px;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.brand h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e8eef8;
}
.brand p {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* ---- control panel ---- */
.panel {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 248px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-size: 12.5px;
  user-select: none;
  overflow: hidden;
  transition: opacity 0.25s, transform 0.25s;
}
.panel.hidden { opacity: 0; transform: translateX(12px); pointer-events: none; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  color: #dfe7f2;
  border-bottom: 1px solid var(--panel-border);
}
.panel-head .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}
.panel-head .fps {
  margin-left: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

.panel section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.panel section:last-child { border-bottom: none; }

.field-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: -4px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.row > span { color: var(--text-dim); }

select {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 24px 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%237d8aa0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
select:hover { border-color: var(--accent-dim); }

/* segmented control */
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
}
.seg button {
  all: unset;
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button + button { border-left: 1px solid rgba(255, 255, 255, 0.06); }
.seg button:hover { color: var(--text); }
.seg button.active {
  background: rgba(110, 231, 255, 0.14);
  color: var(--accent);
}

/* sliders */
.slider { display: flex; flex-direction: column; gap: 5px; }
.slider > span {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
}
.slider em {
  font-style: normal;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--text);
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -4.5px;
  box-shadow: 0 0 6px rgba(110, 231, 255, 0.5);
}
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(110, 231, 255, 0.5);
}

/* buttons */
.btns { flex-direction: row !important; }
.btns button {
  all: unset;
  flex: 1;
  text-align: center;
  padding: 7px 0;
  border-radius: 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btns button:hover { border-color: var(--accent-dim); background: rgba(110, 231, 255, 0.08); }
.btns button.active { background: rgba(110, 231, 255, 0.16); color: var(--accent); border-color: var(--accent-dim); }

/* ---- follow link ---- */
.follow-link {
  position: fixed;
  bottom: 44px;
  left: 26px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: color 0.2s, border-color 0.2s;
}
.follow-link:hover { color: var(--text); border-color: var(--accent-dim); }
.follow-link svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* ---- footer hint ---- */
.hint {
  position: fixed;
  bottom: 16px;
  left: 26px;
  font-size: 11.5px;
  color: var(--text-dim);
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
}
.hint kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

/* ---- fallback ---- */
#fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  text-align: center;
  padding: 24px;
}
#fallback[hidden] { display: none; }
#fallback h2 { font-size: 18px; margin-bottom: 10px; color: #e8eef8; }
#fallback p { color: var(--text-dim); max-width: 420px; line-height: 1.5; }
#fallback code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--accent);
}

@media (max-width: 640px) {
  .panel { width: 216px; top: 12px; right: 12px; }
  .brand { top: 14px; left: 16px; }
  .hint { display: none; }
  .follow-link { bottom: 12px; left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
}
