:root {
  --bg: #05070b;
  --glass: rgba(13, 18, 28, 0.78);
  --line: rgba(255, 255, 255, 0.08);
  --txt: #cfd8e3;
  --dim: #7a8699;
  --accent: #ffb347;
  --accent2: #46d2c8;
}

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

[hidden] { display: none !important; }

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

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  pointer-events: none;
  z-index: 10;
}
#topbar h1 {
  font-size: 15px; letter-spacing: 4px; font-weight: 700; color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 179, 71, 0.35);
}
#topbar h1 span { color: var(--dim); font-weight: 400; }
#fps {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--dim);
  background: var(--glass); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 6px;
  backdrop-filter: blur(8px);
}

/* ---------- control panel ---------- */
#panel {
  position: fixed; left: 16px; bottom: 16px;
  width: 292px; max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 20;
  scrollbar-width: thin;
}
#panel.collapsed { width: auto; max-height: none; overflow: hidden; padding: 8px 12px; cursor: pointer; }
#panel.collapsed > :not(#tabs) { display: none; }

#tabs { display: flex; gap: 6px; margin-bottom: 12px; }
#tabs button {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px; letter-spacing: 0.5px;
  padding: 7px 4px; border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
#tabs button:hover { color: var(--txt); border-color: rgba(255,255,255,0.2); }
#tabs button.active {
  background: rgba(255,179,71,0.12);
  border-color: rgba(255,179,71,0.5);
  color: var(--accent);
}

#sys-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
#sys-tag { font-size: 11px; color: var(--dim); margin-bottom: 10px; line-height: 1.4; }

#presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
#presets button {
  font-size: 10px;
  background: rgba(70,210,200,0.08);
  border: 1px solid rgba(70,210,200,0.3);
  color: var(--accent2);
  padding: 4px 9px; border-radius: 20px;
  cursor: pointer;
}
#presets button:hover { background: rgba(70,210,200,0.18); }

.ctrl { margin-bottom: 10px; }
.ctrl label {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--dim); margin-bottom: 3px;
}
.ctrl label output { color: var(--txt); font-family: ui-monospace, monospace; }
input[type=range] {
  width: 100%; height: 18px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(255,255,255,0.1));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  margin-top: -5px;
  box-shadow: 0 0 8px rgba(255,179,71,0.6);
}
input[type=range]::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255,255,255,0.15); }
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%; background: var(--accent);
}

.actions { display: flex; gap: 6px; margin-top: 4px; }
.actions button {
  flex: 1;
  font-size: 11px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 7px 4px; border-radius: 8px;
  cursor: pointer;
}
.actions button:hover { border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.09); }

#hint { margin-top: 10px; font-size: 10.5px; color: var(--dim); line-height: 1.5; }
#hint b { color: var(--accent2); font-weight: 600; }

/* ---------- info overlay ---------- */
#info {
  position: fixed; right: 16px; bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: 70vh; overflow-y: auto;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  backdrop-filter: blur(14px);
  z-index: 30;
}
#info h2 { font-size: 16px; color: var(--accent); margin-bottom: 10px; }
#infoBody { font-size: 13px; line-height: 1.65; color: var(--txt); }
#infoBody p { margin-bottom: 10px; }
#infoBody em { color: var(--accent2); font-style: normal; font-weight: 600; }
#infoClose {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none; color: var(--dim);
  font-size: 20px; cursor: pointer;
}
#infoClose:hover { color: var(--txt); }

#err {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: #ff7b7b;
  font-size: 15px; text-align: center; padding: 40px;
}

@media (max-width: 640px) {
  #panel { width: calc(100vw - 24px); left: 12px; bottom: 12px; }
}
