:root {
  --bg: #05010f;
  --panel: #0b0620;
  --panel-2: #120a2e;
  --edge: #2a1a52;
  --accent: #00ffd5;
  --accent-2: #ff00a8;
  --accent-3: #ffd500;
  --text: #d8ccff;
  --text-dim: #7b6ca8;
  --danger: #ff3b6b;
  --mono: "Courier New", ui-monospace, monospace;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ============ PANEL ============ */
#panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-right: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
}

.panel-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--edge);
}

.logo {
  font-size: 24px;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(0, 255, 213, 0.6);
}

.tagline {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
  margin-top: 4px;
}

/* glitch text */
.glitch { position: relative; display: inline-block; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
  clip-path: inset(0 0 0 0);
}
.glitch::before { color: var(--accent-2); animation: glitch 2.6s infinite steps(2); left: 2px; }
.glitch::after  { color: var(--accent-3); animation: glitch 3.4s infinite steps(2) reverse; left: -2px; }
@keyframes glitch {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); }
  93% { clip-path: inset(20% 0 40% 0); }
  95% { clip-path: inset(60% 0 10% 0); }
  97% { clip-path: inset(10% 0 70% 0); }
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 6px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}
.panel-scroll::-webkit-scrollbar { width: 8px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 4px; }

/* ---- groups ---- */
.group { border: 1px solid var(--edge); border-radius: 6px; margin: 8px 0; overflow: hidden; background: rgba(0,0,0,0.2); }
.group-head {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.group-head:hover { background: rgba(0, 255, 213, 0.06); }
.chev { transition: transform 0.2s; display: inline-block; }
.group[data-open="true"] .chev { transform: rotate(90deg); }
.group-body { padding: 4px 12px 12px; display: none; }
.group[data-open="true"] .group-body { display: block; }

/* ---- controls ---- */
.ctl { display: block; margin: 10px 0; font-size: 12px; color: var(--text); }
.ctl > span { display: block; margin-bottom: 5px; color: var(--text-dim); letter-spacing: 1px; }
.ctl > span b { color: var(--accent); font-weight: normal; float: right; }

.ctl-row { display: flex; gap: 10px; }
.ctl.half { flex: 1; }

select, input[type="text"] {
  width: 100%;
  background: #060216;
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 7px 8px;
  font-family: var(--mono);
  font-size: 12px;
}
select:focus, input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* Seed inputs with reroll dice */
.seed-row { display: flex; gap: 6px; align-items: stretch; }
.seed-row input[type="text"] { flex: 1 1 auto; }
.seed-dice {
  flex: 0 0 auto;
  cursor: pointer;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 0 9px;
  font-size: 14px;
  line-height: 1;
  transition: border-color .15s, filter .15s;
}
.seed-dice:hover { border-color: var(--accent); filter: brightness(1.25); }
.seed-dice:active { transform: translateY(1px); }
.seed-hint { margin: 2px 0 0; font-size: 11px; color: var(--text-dim); }

input[type="color"] {
  width: 100%;
  height: 32px;
  background: #060216;
  border: 1px solid var(--edge);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
}

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--edge);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 213, 0.8);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 255, 213, 0.8);
}

.ctl.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ctl.toggle > span { margin: 0; color: var(--text); }
.ctl.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px; height: 18px;
  background: #060216;
  border: 1px solid var(--edge);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.2s;
}
.ctl.toggle input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
.ctl.toggle input[type="checkbox"]:checked { background: rgba(0, 255, 213, 0.2); border-color: var(--accent); }
.ctl.toggle input[type="checkbox"]:checked::after { transform: translateX(16px); background: var(--accent); }

.ctl.secret > span { color: var(--danger); }
.ctl.secret input[type="checkbox"]:checked { background: rgba(255, 59, 107, 0.2); border-color: var(--danger); }
.ctl.secret input[type="checkbox"]:checked::after { background: var(--danger); }

.hidden-egg { display: none; }
.hidden-egg.revealed { display: flex; animation: eggIn 0.5s ease; }
@keyframes eggIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.egg-hint { font-size: 10px; color: var(--text-dim); margin-top: 8px; opacity: 0.5; letter-spacing: 0.5px; }
.egg-hint i { color: var(--accent-3); font-style: normal; }

/* logo becomes clickable for the reveal easter egg */
.logo { cursor: pointer; user-select: none; }

/* hyperdrive / party mode */
#app.hyperdrive { animation: hyperhue 0.6s linear infinite; }
@keyframes hyperhue { to { filter: hue-rotate(360deg); } }
#app.hyperdrive #stage { animation: shake 0.25s infinite; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
}

/* ---- actions ---- */
.actions {
  border-top: 1px solid var(--edge);
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
}
.btn-row { display: flex; gap: 8px; margin-bottom: 8px; }
.btn {
  flex: 1;
  background: #0d0726;
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 5px;
  padding: 10px 6px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px rgba(0, 255, 213, 0.25); }
.btn.primary { background: var(--accent); color: #04121b; border-color: var(--accent); font-weight: bold; }
.btn.primary:hover { box-shadow: 0 0 18px rgba(0, 255, 213, 0.6); color: #04121b; }
.btn.primary.playing { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 18px rgba(255, 0, 168, 0.5); }
.btn.ghost { background: transparent; }
.btn.recording { border-color: var(--danger); color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse { 50% { opacity: 0.5; } }

.status {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  min-height: 14px;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============ STAGE ============ */
#stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, #150934, #05010f 70%);
  overflow: hidden;
}
#scene {
  max-width: 100%;
  max-height: 100%;
  background: #000;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--edge);
  image-rendering: auto;
}

.watermark {
  position: absolute;
  right: 16px;
  bottom: 12px;
  font-size: 13px;
  color: rgba(216, 204, 255, 0.55);
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  user-select: none;
}
.watermark.hidden { display: none; }

/* Fullscreen-only randomize dice, sitting next to the watermark */
.fs-dice {
  position: absolute;
  right: 16px;
  bottom: 10px;
  display: none;
  z-index: 5;
  cursor: pointer;
  background: rgba(11, 6, 32, 0.6);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 17px;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: border-color .15s, filter .15s;
}
.fs-dice:hover { border-color: var(--accent); filter: brightness(1.25); }
.fs-dice:active { transform: translateY(1px); }
#stage:fullscreen .fs-dice,
#stage:-webkit-full-screen .fs-dice { display: inline-flex; }
#stage:fullscreen .watermark,
#stage:-webkit-full-screen .watermark { right: 60px; bottom: 14px; }

/* Live creation in full screen — canvas fills the display, letterboxed */
#stage:fullscreen,
#stage:-webkit-full-screen { width: 100vw; height: 100vh; }
#stage:fullscreen #scene,
#stage:-webkit-full-screen #scene {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: none;
}

.rec-dot {
  position: absolute;
  left: 16px;
  top: 14px;
  font-size: 13px;
  color: var(--danger);
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 59, 107, 0.8);
  animation: pulse 1s infinite;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #panel { order: 2; border-right: none; border-top: 1px solid var(--edge); max-height: 45vh; }
  #stage { order: 1; }
  .panel-head { display: none; }
}
