:root {
  --bg0: #2a2622;
  --bg1: #0e0d0c;
  --panel: rgba(22, 20, 18, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --text: #ece6dc;
  --muted: #a39a8c;
  --accent: #ff9f2e;
  --accent2: #47c8ff;
  --btn: rgba(255, 255, 255, 0.06);
  --btn-hover: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, var(--bg0), var(--bg1) 75%);
  color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; outline: none; }

#panel {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  user-select: none;
}
#panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
#panel h1 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: 0.02em; }
#panel .body { overflow-y: auto; padding: 4px 12px 12px; }
#panel.collapsed .body { display: none; }
#panel.collapsed header { border-bottom: 0; }

section { padding: 10px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.badge {
  background: var(--accent);
  color: #1a1206;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  letter-spacing: 0;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: var(--btn-hover); }
button:disabled { opacity: 0.4; cursor: default; }
button.icon { width: 26px; height: 26px; padding: 0; line-height: 1; }
button.on, .seg button.active {
  background: rgba(255, 159, 46, 0.18);
  border-color: var(--accent);
  color: #ffd8a8;
}
kbd {
  font: 10px ui-monospace, monospace;
  color: var(--muted);
  margin-left: 3px;
}

.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.seg4 { grid-template-columns: repeat(4, 1fr); }
.seg4 button { padding: 6px 2px; font-size: 12px; }
.seg4 kbd { display: none; }
.btns { display: flex; flex-wrap: wrap; gap: 5px; }
.btns button { flex: 1 1 auto; }

.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.row span { color: var(--muted); white-space: nowrap; }
.row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
output { flex-shrink: 0; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }

.hint { margin: 6px 0 0; color: var(--muted); font-size: 11.5px; }
details { padding-top: 10px; color: var(--muted); }
summary { cursor: pointer; font-size: 12px; }
.help { padding-left: 16px; margin: 8px 0 0; font-size: 12px; }
.help li { margin-bottom: 4px; }
.help b { color: var(--text); font-weight: 600; }

#hud {
  position: fixed;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

#toast {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -20px);
  padding: 7px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  #panel { left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; max-height: 55%; }
  #hud { top: 12px; bottom: auto; }
}
