:root {
  --bg-0: #f4f3f8;
  --bg-1: #f8f7fb;
  --bg-2: #ffffff;
  --glass: rgba(70, 44, 150, 0.28);
  --glass-strong: rgba(48, 28, 110, 0.55);
  --line: rgba(20, 16, 50, 0.07);
  --line-strong: rgba(20, 16, 50, 0.12);
  --text: #15122b;
  --text-2: #4d4868;
  --text-3: #8d88a6;
  --coral: #f0385a;
  --coral-soft: rgba(240, 56, 90, 0.08);
  --pink: #7c4dff;
  --mint: #0d9e7c;
  --amber: #c27a00;
  --sans: "Outfit", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Consolas", ui-monospace, monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 70% 35%, rgba(150, 120, 255, 0.10), transparent 70%),
    radial-gradient(50% 60% at 15% 85%, rgba(255, 120, 150, 0.07), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg-1) 45%, var(--bg-0));
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), rgba(20,16,50,0.03) calc(12.5% - 1px) 12.5%);
}

/* ---------- Shared pieces ---------- */

.stage {
  height: 100dvh;
  padding: clamp(10px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.glass {
  position: relative;
  width: 100%;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow:
    0 30px 80px -30px rgba(40, 30, 90, 0.18), 0 2px 6px rgba(40, 30, 90, 0.04),
    inset 0 1px 0 #fff;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  overflow: hidden;
  isolation: isolate;
}

.grid-lines {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 8 - 1px), var(--line) calc(100% / 8 - 1px) calc(100% / 8));
  mask-image: linear-gradient(180deg, transparent, #000 15%, #000 85%, transparent);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 15px;
}
.brand::first-letter { color: var(--coral); }

.eyebrow {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text-2);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 0 0 18px;
  height: 46px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--coral);
  border-radius: 2px;
  font: 600 11px var(--sans);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.btn-outline .arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 100%;
  border-left: 1px solid var(--coral);
  color: var(--coral);
  font-size: 12px;
  transition: background 0.2s, color 0.2s;
}
.btn-outline:hover { background: var(--coral-soft); box-shadow: 0 0 30px -6px rgba(255, 77, 109, 0.6); }
.btn-outline:hover .arrow { background: var(--coral); color: #fff; }
.btn-outline.small { height: 44px; gap: 16px; flex: none; }

:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

input {
  font: 15px var(--sans);
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 0 14px;
  height: 46px;
  min-width: 0;
  transition: border-color 0.2s, background 0.2s;
}
input::placeholder { color: var(--text-3); }
input:focus { outline: none; border-color: var(--pink); background: #fff; box-shadow: 0 0 0 4px rgba(124, 77, 255, 0.1); }

.error { color: var(--coral); min-height: 1.3em; margin: 0; font-size: 13px; }
.muted { color: var(--text-3); font-weight: 400; }

/* ---------- Connect hero ---------- */

.hero {
  max-width: 1180px;
  min-height: min(640px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) 90px;
  grid-template-rows: auto 1fr auto;
  padding: 28px 36px;
}
.hero-top {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-2);
}
.live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.7);
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(255, 77, 109, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0); } }

.hero-copy {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  position: relative;
  z-index: 2;
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 24px 0;
}
.hero-copy h1 {
  margin: 0;
  font-size: clamp(40px, 5.4vw, 68px);
  line-height: 0.98;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-shadow: none;
}
.lede { margin: 0 0 8px; color: var(--text-2); font-weight: 300; max-width: 36ch; }
.field { display: grid; gap: 6px; }
.field span { font-size: 10.5px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--text-3); }
.hero-copy .btn-outline { justify-self: start; }

.hero-art {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 380px;
}
.orb {
  position: absolute;
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(160, 120, 255, 0.35), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(110, 200, 255, 0.28), transparent 60%),
    radial-gradient(circle at 60% 20%, rgba(255, 110, 140, 0.25), transparent 50%);
  filter: blur(40px);
  animation: drift 14s ease-in-out infinite;
}
@keyframes drift { 50% { transform: translate(14px, -18px) scale(1.06) rotate(20deg); } }
.glass-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(20, 16, 50, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 50px -20px rgba(40, 30, 90, 0.25), inset 0 1px 0 #fff;
}
.preview {
  position: relative;
  width: min(400px, 92%);
  padding: 22px 22px 18px;
  transform: rotate(-2deg);
  animation: float 9s ease-in-out infinite;
}
@keyframes float { 50% { transform: rotate(-2deg) translateY(-10px); } }
.pv-head { display: flex; justify-content: space-between; align-items: center; }
.pv-head .eyebrow { color: var(--coral); }
.pv-num { display: grid; gap: 4px; font-weight: 600; font-size: 15px; }
.pv-num i { width: 18px; height: 2px; background: var(--text); }
.pv-q { margin: 12px 0 0; font-size: 19px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; }
.pv-hint { margin: 12px 0 0; font: 600 16px var(--mono); letter-spacing: 0.2em; color: var(--mint); }
.pv-timer { margin-top: 14px; height: 2px; background: rgba(20, 16, 50, 0.08); }
.pv-timer span {
  display: block; height: 100%; width: 62%;
  background: linear-gradient(90deg, var(--pink), var(--mint));
  box-shadow: none;
  animation: tick 6s linear infinite;
}
@keyframes tick { from { width: 100%; } to { width: 0; } }
.pv-feed { list-style: none; margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid rgba(20, 16, 50, 0.07); display: grid; gap: 6px; font-size: 13px; color: var(--mint); }
.pv-feed b { font-weight: 600; color: var(--text); }
.pv-feed em { font-style: normal; font: 600 12px var(--mono); float: right; }
.pv-feed .dim { color: var(--text-3); }
.chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-2);
}
.chip b { font: 600 14px var(--mono); color: var(--text); }
.chip-a { top: 8%; right: 2%; animation: float2 7s ease-in-out infinite; }
.chip-b { bottom: 10%; left: 0; animation: float2 8s ease-in-out infinite reverse; }
.chip-b i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
@keyframes float2 { 50% { transform: translateY(-8px); } }

.hero-index {
  grid-column: 3;
  grid-row: 2;
  align-self: center;
  justify-self: end;
  display: grid;
  justify-items: start;
  gap: 6px;
}
.hero-index .big { font-size: 26px; font-weight: 600; }
.hero-index .rule { width: 26px; height: 2px; background: var(--text); }
.hero-index .small { font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--coral); }

.hero-foot {
  grid-column: 1 / -1;
  display: flex;
  gap: 28px;
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---------- App shell ---------- */

.app { padding: clamp(0px, 2vw, 28px); }
.shell {
  height: 100%;
  max-width: 1480px;
  display: flex;
  flex-direction: column;
  padding: 18px 22px 20px;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.crumb {
  flex: 1;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-2);
}
.icon-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  background: none;
  border: 0;
  cursor: pointer;
}
.icon-btn span { display: block; width: 18px; height: 1.5px; background: var(--text); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 270px;
  gap: 22px;
  padding-top: 18px;
}

/* Channels */
.channels { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.channels button {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text-2);
  font: 500 14px var(--sans);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.channels .idx { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.channels .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  text-align: center;
  color: var(--text-3);
  background: rgba(20, 16, 50, 0.05);
}
.channels button:hover { background: rgba(20, 16, 50, 0.04); border-color: var(--text-3); color: var(--text); }
.channels button[aria-current="true"] { color: var(--text); background: var(--coral-soft); border-color: var(--coral); }
.channels button[aria-current="true"] .idx { color: var(--coral); }
.channels button[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 6px;
  width: 16px;
  height: 2px;
  background: var(--coral);
}
.channels button[aria-current="true"] .count { color: var(--text); background: var(--coral-soft); }

/* Main */
.main-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 14px; }
.topic {
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board {
  position: relative;
  padding: 26px 28px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: linear-gradient(120deg, #ffffff, #f6f3ff);
  overflow: hidden;
  isolation: isolate;
  animation: rise 0.45s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.board-glow {
  position: absolute;
  z-index: -1;
  right: -80px;
  top: -80px;
  width: 320px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(160, 120, 255, 0.22), rgba(110, 200, 255, 0.12) 45%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.board .eyebrow { color: var(--coral); }
.board-question {
  margin: 10px 0 0;
  max-width: 32ch;
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.board-hint {
  margin-top: 14px;
  min-height: 1.4em;
  font: 600 18px var(--mono);
  letter-spacing: 0.22em;
  color: var(--mint);
  overflow-wrap: anywhere;
}
.timer {
  margin-top: 18px;
  height: 2px;
  background: rgba(20, 16, 50, 0.08);
  max-width: 60%;
}
.timer-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), var(--mint));
  box-shadow: none;
}
.timer-bar.closing { background: var(--coral); box-shadow: 0 0 12px rgba(255, 77, 109, 0.8); }

/* Log */
.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  font-size: 14.5px;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 16, 50, 0.15) transparent;
}
.log p { margin: 0; padding: 3px 0; color: var(--text-2); }
.line-time { font: 11px var(--mono); color: var(--text-3); margin-right: 4px; }
.line-nick { font-weight: 600; color: #5b5af0; }
.line-me .line-nick { color: var(--pink); }
.line-chat { color: var(--text); }
.line-question { color: var(--text); font-weight: 600; padding-top: 10px !important; }
.line-hint { color: var(--amber); }
.line-correct { color: var(--mint); font-weight: 600; }
.line-reveal { color: var(--coral); }
.line-status { color: var(--text-3); font-size: 13.5px; }
.line-error { color: var(--coral); }

.say { display: flex; gap: 10px; }
.say input { flex: 1; height: 44px; }

/* Side */
.side { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.panel {
  padding: 16px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 16, 50, 0.15) transparent;
}
.nicks { flex: 0 1 38%; min-height: 110px; }
.ranks { flex: 1 1 62%; min-height: 0; }
.panel h3 {
  margin: 0 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-2);
}
.panel h3 .muted { letter-spacing: 0.1em; text-transform: none; margin-left: 4px; }
.side ul, .side ol { margin: 0; padding: 0; list-style: none; }
.side li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(20, 16, 50, 0.06);
  font-size: 14px;
}
.side li:last-child { border-bottom: 0; }
.side li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side li .num { font: 500 13px var(--mono); color: var(--text-2); }
.side li .rank { display: inline-block; width: 26px; font: 500 11px var(--mono); color: var(--text-3); }
.side li.me .who { color: var(--pink); font-weight: 600; }
.ranks li:nth-child(-n+3) .rank { color: var(--coral); }
.side .empty { display: block; color: var(--text-3); border: 0; font-size: 13px; }

.tabs { display: flex; gap: 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  padding: 0 0 10px;
  background: none;
  border: 0;
  color: var(--text-3);
  font: 600 10.5px var(--sans);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
}
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--coral);
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 160px minmax(0, 1fr) 230px; gap: 16px; }
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    padding: 22px 20px;
    min-height: 0;
  }
  .hero-art { grid-column: 1; grid-row: 3; min-height: 0; padding: 12px 0 8px; }
  .chip { display: none; }
  .preview { transform: none; animation: none; width: 100%; }
  .hero-copy { grid-row: 2; padding: 20px 0 8px; max-width: none; }
  .hero-index { display: none; }
  .hero-foot { grid-row: 4; flex-wrap: wrap; gap: 8px 18px; }
  .stage { align-items: stretch; }
  #connect { overflow-y: auto; }
}

@media (max-width: 760px) {
  .app { padding: 0; }
  .shell { border-radius: 0; border-width: 0; padding: 12px 14px 14px; }
  .icon-btn { display: flex; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    padding-top: 10px;
    position: relative;
  }
  .channels { flex-direction: row; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .channels button { flex: none; grid-template-columns: auto auto; padding: 8px 12px; }
  .channels .idx { display: none; }
  .channels button[aria-current="true"]::after { left: 12px; bottom: 3px; }
  .board { padding: 18px 18px 16px; }
  .side {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    padding-top: 10px;
    background: #f8f7fb;
  }
  .side .panel { background: #fff; }
  .board-hint { font-size: 16px; letter-spacing: 0.12em; }
  .side.open { display: flex; }
  .btn-outline.small { gap: 0; padding-left: 0; }
  .btn-outline.small .label { display: none; }
}

.board.idle .board-question { color: var(--text-2); font-weight: 400; }
.board.idle .board-glow { opacity: 0.5; }

/* Add a question */
.btn-add {
  flex: none;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: 600 12px var(--sans);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.btn-add:hover { color: var(--coral); border-color: var(--coral); }
.suggest {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -30px rgba(40, 30, 90, 0.35);
}
.suggest::backdrop { background: rgba(21, 18, 43, 0.4); }
.suggest h2 { margin: 0; font-size: 20px; font-weight: 700; }
.suggest-note { margin: 4px 0 16px; color: var(--text-2); font-size: 14px; }
.suggest form { display: flex; flex-direction: column; }
.suggest .field { display: block; margin-bottom: 14px; }
.suggest .field > span { display: block; margin-bottom: 4px; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--text-2); }
.suggest input, .suggest textarea, .suggest select {
  display: block;
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: 15px var(--sans);
}
.suggest textarea { resize: vertical; }
.suggest .error { margin: 0 0 12px; }
.suggest .error:empty { display: none; }
.suggest-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; }
.suggest-actions .btn-add { height: 44px; padding: 0 16px; }
.suggest-actions .btn-outline:disabled { opacity: 0.5; cursor: default; }
.suggest { width: min(560px, calc(100vw - 32px)); }
.qtabs { display: flex; gap: 18px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.qtab {
  padding: 8px 0;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.qtab:hover { color: var(--text-2); }
.qtab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--coral); }
.qlist { list-style: none; margin: 0 0 14px; padding: 0; max-height: min(46vh, 380px); overflow-y: auto; }
.qlist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.qlist li:last-child { border-bottom: 0; }
.qlist .empty { color: var(--text-3); font-size: 14px; }
.q-text { margin: 0; overflow-wrap: anywhere; }
.q-meta { margin: 2px 0 0; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.q-answer { margin: 6px 0 0; font-size: 13px; color: var(--mint); overflow-wrap: anywhere; }
.q-actions { display: flex; gap: 8px; margin-top: 8px; }
.admin-form { display: flex; gap: 8px; margin-bottom: 12px; }
.admin-form input { flex: 1; }
.admin-form .btn-add { height: auto; }
.btn-link {
  margin-right: auto;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-3);
  font: 13px var(--sans);
  text-decoration: underline;
  cursor: pointer;
}
.suggest .btn-outline.small { padding-left: 18px; gap: 16px; }
.suggest .btn-outline.small .label { display: inline; }

/* Your nick */
.btn-nick { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-label { margin: 0 0 4px; font-size: 13px; color: var(--text-2); }
.me-code-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.me-code {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font: 600 16px var(--mono);
  overflow-wrap: anywhere;
}
#me-copy { height: 40px; }
@media (max-width: 760px) {
  .topbar { gap: 8px; }
  .topbar .crumb { display: none; }
  .btn-nick { max-width: 96px; margin-left: auto; }
}
