:root {
  --bg: #0b0a09;
  --surface: #141210;
  --panel: #191714;
  --panel-in: #100e0c;
  --hair: #2a2622;
  --hair-2: #403a34;
  --ink: #ece4d9;
  --mute: #9a9084;
  --ghost: #6a6259;
  --rose: #e8a0b0;
  --rose-deep: #c4788a;
  --rose-wash: rgba(232, 160, 176, 0.09);
  --ok: #8fbc8f;
  --warn: #d4a574;
  --bad: #c97b7b;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--serif);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 90% 55% at 100% -15%, var(--rose-wash), transparent 55%),
    radial-gradient(ellipse 55% 40% at -5% 95%, rgba(170, 140, 110, 0.05), transparent 50%);
  padding: 2rem 1.4rem 4rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  font-weight: 400;
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}
h1 span { color: var(--rose); font-style: italic; }

.sub {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--mute);
  letter-spacing: 0.04em;
  margin-bottom: 1.75rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.25);
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ghost);
}

input[type="text"],
input[type="number"],
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel-in);
  border: 1px solid var(--hair-2);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  outline: none;
  transition: border-color 0.12s;
}
input:focus, select:focus {
  border-color: var(--rose-deep);
  outline: 1px solid var(--rose-deep);
  outline-offset: 1px;
}
select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--rose) 50%),
    linear-gradient(135deg, var(--rose) 50%, transparent 50%);
  background-position: calc(100% - 9px) 50%, calc(100% - 5px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  padding-right: 1.4rem;
  cursor: pointer;
}
select:disabled { opacity: 0.4; cursor: not-allowed; }

.btns {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

button {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  padding: 0.6rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.08s;
}
button:active { transform: translateY(1px); }

.go {
  flex: 1;
  background: var(--rose);
  color: #1a1214;
  font-weight: 500;
  border-color: var(--rose);
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset;
}
.go:hover { background: #f0b4c0; }

.stop {
  flex: 1;
  background: transparent;
  color: var(--mute);
  border-color: var(--hair);
}
.stop:hover { color: var(--bad); border-color: var(--bad); }

.answer-panel {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 8px 24px rgba(0,0,0,0.25);
}

.auto-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--mute);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0.02em;
}

.toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.95rem;
  height: 0.95rem;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--hair-2);
  border-radius: 2px;
  background: var(--panel-in);
  cursor: pointer;
  position: relative;
}
.toggle input[type="checkbox"]:hover { border-color: var(--mute); }
.toggle input[type="checkbox"]:checked {
  background: var(--rose);
  border-color: var(--rose);
}
.toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 0.24rem;
  top: 0.06rem;
  width: 0.28rem;
  height: 0.5rem;
  border: solid #1a1214;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

#autoChoice { width: 150px; }

.manual-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}
.manual-row.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.ans {
  padding: 0.65rem 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 3px;
}
.ans.red { background: var(--red); }
.ans.blue { background: var(--blue); }
.ans.yellow { background: var(--yellow); color: #1a1214; }
.ans.green { background: var(--green); }
.ans.random { background: var(--hair-2); color: var(--ink); }
.ans.balance { background: #5c3d7a; }
.ans:hover { filter: brightness(1.08); }

.hint {
  margin-top: 0.7rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ghost);
  letter-spacing: 0.02em;
}

.stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--mute);
  text-transform: uppercase;
}
.stats #running { color: var(--ghost); }
.stats #running.live { color: var(--ok); }

.log {
  background: var(--panel-in);
  border: 1px solid var(--hair);
  border-radius: 8px;
  height: 160px;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  margin-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--hair-2) transparent;
  color: var(--mute);
}
.log div { margin-bottom: 1px; }

.bots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.4rem;
}
.bot {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  border-left: 3px solid var(--hair-2);
  color: var(--ink);
}
.bot small {
  color: var(--ghost);
  font-size: 0.62rem;
}
.bot.joined { border-left-color: var(--ok); }
.bot.answering { border-left-color: var(--rose); }
.bot.joining { border-left-color: var(--warn); }

@media (max-width: 560px) {
  .controls { grid-template-columns: 1fr; }
  .manual-row { grid-template-columns: repeat(2, 1fr); }
  body { padding: 1.25rem 1rem 3rem; }
}

/* --- multi-mode answer sections --- */
.qtype-bar {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--rose);
  background: var(--panel-in);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  margin-bottom: 0.75rem;
}

.manual-section {
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hair);
}
.manual-section:last-of-type { border-bottom: none; }

.sec-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ghost);
  margin-bottom: 0.4rem;
}

.tf-row, .slider-row, .text-row, .array-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.tf-row .ans.tf {
  background: #1a3a2a;
  border-color: #2a5a3a;
}
.tf-row .ans.tf.false {
  background: #3a1a1a;
  border-color: #5a2a2a;
}

.slider-row input,
.text-row input,
.array-row input {
  flex: 1 1 120px;
  min-width: 100px;
  background: var(--panel-in);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  outline: none;
}
.slider-row input:focus,
.text-row input:focus,
.array-row input:focus {
  border-color: var(--rose-deep);
}

.manual-row.disabled,
.manual-section.disabled {
  opacity: 0.4;
  pointer-events: none;
}

#qtype {
  color: var(--rose);
  font-family: var(--mono);
  font-size: 0.72rem;
}

/* ── Auto name toggle ── */
.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.slider-knob {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--hair-2);
  border-radius: 20px;
  transition: background 0.2s;
}

.slider-knob::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  top: 3px;
  background: var(--mute);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .slider-knob { background: var(--rose-deep); }
.toggle input:checked + .slider-knob::before {
  transform: translateX(18px);
  background: var(--ink);
}

#nameStyleLabel select {
  margin-top: 0.15rem;
  background: var(--panel-in);
  border: 1px solid var(--hair-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
#nameStyleLabel select:focus { border-color: var(--rose-deep); }

#nameStyleLabel {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Humanized delay range inputs ──────────────────────────────────────── */
.delay-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.delay-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.delay-range input[type="number"] {
  width: 80px;
}

.delay-sep {
  color: var(--muted, #888);
  font-size: 0.9em;
  user-select: none;
}

.delay-hint {
  color: var(--muted, #888);
  font-size: 0.78em;
  font-style: italic;
  margin-top: 2px;
}

.auto-delay-row {
  margin: 8px 0 4px 0;
  padding: 8px 10px;
  background: var(--panel-bg, rgba(255,255,255,0.04));
  border-radius: 6px;
  border: 1px solid var(--border, rgba(255,255,255,0.09));
}
