:root {
  --ink:      #14101c;
  --panel:    #1d1730;
  --panel-2:  #241d3b;
  --line:     #34294f;
  --text:     #ece5f7;
  --muted:    #9a8cb8;
  --hot:      #ff4d7e;
  --strike:   #c9322d;
  --live:     #4fe3c1;
  --amber:    #ffb547;
  --radius:   14px;
  --display:  "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body:     Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono:     "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 600px at 85% -10%, #2a1c46 0%, transparent 60%),
    var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--live); }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 16, 28, 0.85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-family: var(--display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.03em; }
.brand span { color: var(--hot); }
.topbar .spacer { flex: 1; }

.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(79, 227, 193, 0.6);
  animation: pulse 2.2s infinite;
}
.pulse.off { background: var(--muted); animation: none; box-shadow: none; }
@keyframes pulse {
  70%  { box-shadow: 0 0 0 9px rgba(79, 227, 193, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 227, 193, 0); }
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.25rem; align-items: start; }
@media (max-width: 940px) { .cols { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.9rem; }
.card-head .spacer { flex: 1; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit; font-size: 0.86rem;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0.42rem 0.8rem;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.15s, transform 0.06s;
}
button:hover, .btn:hover { border-color: var(--hot); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--live); outline-offset: 2px;
}
.btn-primary { background: var(--hot); border-color: var(--hot); color: #21071a; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-strike { background: var(--strike); border-color: var(--strike); color: #fff; font-weight: 600; }
.btn-strike:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 0.22rem 0.55rem; font-size: 0.78rem; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

input, select, textarea {
  font: inherit; font-size: 0.9rem;
  width: 100%;
  background: #17122a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 0.45rem 0.6rem;
}
textarea { font-family: var(--mono); font-size: 0.82rem; resize: vertical; }
label { display: block; }
label .lbl { font-size: 0.72rem; color: var(--muted); display: block; margin-bottom: 0.2rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.row > * { flex: 1 1 130px; min-width: 0; }

/* ---------- rules ---------- */
.rule {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 11px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.6rem;
  background: var(--panel-2);
}
.rule.off { opacity: 0.5; }
.rule.flash { animation: flash 1.1s ease-out; }
@keyframes flash {
  0%   { border-left-color: var(--hot); background: #35204a; }
  100% { border-left-color: var(--line); background: var(--panel-2); }
}
.rule-top { display: flex; align-items: center; gap: 0.6rem; }
.rule-name { font-weight: 600; }
.rule-top .spacer { flex: 1; }
.cond {
  font-family: var(--mono); font-size: 0.76rem; color: var(--muted);
  margin-top: 0.3rem; word-break: break-word;
}
.tag {
  font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0.1rem 0.4rem; border-radius: 5px;
  background: #2d2247; color: var(--live); border: 1px solid var(--line);
}
.tag.gift { color: var(--hot); }
.tag.chat { color: var(--amber); }
.acts { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.45rem; }
.chip {
  font-size: 0.72rem; padding: 0.12rem 0.45rem; border-radius: 20px;
  border: 1px solid var(--line); color: var(--muted);
}

/* ---------- the wire ---------- */
.wire { max-height: 60vh; overflow: auto; padding-left: 0.9rem; position: relative; }
.wire::before {
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(var(--hot), transparent);
}
.tick {
  position: relative; font-size: 0.83rem; padding: 0.28rem 0;
  border-bottom: 1px solid rgba(52, 41, 79, 0.5);
}
.tick::before {
  content: ""; position: absolute; left: -0.9rem; top: 0.75rem;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--live); box-shadow: 0 0 8px var(--live);
}
.tick.gift::before { background: var(--hot); box-shadow: 0 0 8px var(--hot); }
.tick .who { color: var(--live); font-weight: 600; }
.tick.gift .who { color: var(--hot); }
.tick .what { color: var(--text); }
.tick .meta { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }

/* ---------- poll ---------- */
.bar { height: 8px; border-radius: 6px; background: #2b2145; overflow: hidden; margin-top: 0.25rem; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--hot), var(--amber)); transition: width 0.4s; }
.opt { margin-bottom: 0.55rem; }
.opt-top { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.86rem; }
.opt-top .spacer { flex: 1; }
.opt-emoji { font-size: 1.1rem; }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mono  { font-family: var(--mono); font-size: 0.78rem; }
.empty { color: var(--muted); font-size: 0.88rem; padding: 0.5rem 0; }
.copyfield { display: flex; gap: 0.4rem; align-items: center; }
.copyfield input { font-family: var(--mono); font-size: 0.72rem; }
.toast {
  position: fixed; bottom: 1.1rem; left: 50%; transform: translateX(-50%);
  background: var(--hot); color: #21071a; font-weight: 600;
  padding: 0.5rem 1rem; border-radius: 30px; z-index: 60;
}
.err { color: var(--hot); font-size: 0.85rem; }
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); width: min(620px, 94vw); padding: 1.25rem;
}
dialog::backdrop { background: rgba(10, 7, 16, 0.72); }

/* ---------- auth page ---------- */
.auth { max-width: 400px; margin: 8vh auto; padding: 0 1.25rem; }
.auth .card { padding: 1.5rem; }
.auth h1 { margin-bottom: 0.35rem; }
.auth label { margin-bottom: 0.7rem; }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tabs button, .tabs [role="tab"] { flex: 1; }
.tabs button[aria-selected="true"],
.tabs a[aria-selected="true"],
.tabs [role="tab"][aria-selected="true"] { border-color: var(--hot); color: var(--hot); }
.tabpanel[hidden] { display: none !important; }

/* ---------- co-hosts from chat ---------- */
.chatters { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.chatter {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.28rem 0.6rem; font-size: 0.8rem; border-radius: 999px;
}
.chatter .n {
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted);
}
.chatter:hover .n { color: var(--text); }

.oauth-or {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 1rem 0 0.9rem;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}
.oauth-or::before, .oauth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-oauth {
  display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  width: 100%; padding: 0.55rem; font-weight: 500;
}
.btn-oauth svg { width: 18px; height: 18px; flex: none; }

/* ---------- degraded mode ---------- */
/* Deliberately loud. The whole risk of a silent failover is that the operator
   does not realise where their data is going. */
.degraded {
  padding: 0.6rem 1.25rem;
  background: repeating-linear-gradient(45deg, #4a2410, #4a2410 12px, #3d1e0d 12px, #3d1e0d 24px);
  border-bottom: 2px solid var(--amber);
  color: #ffe0b8;
  font-size: 0.85rem;
}
.degraded strong { color: var(--amber); }

/* ---------- app switcher ---------- */
/* Tools and Sounds are two sides of one suite. This is the seam between them,
   so it has to read as "you are here" at a glance, not as another nav link. */
.side-switch {
  display: flex; align-items: center;
  background: #17122a; border: 1px solid var(--line);
  border-radius: 999px; padding: 2px;
}
.side-switch__on, .side-switch__off {
  font-size: 0.76rem; font-weight: 600; line-height: 1;
  padding: 0.34rem 0.72rem; border-radius: 999px; text-decoration: none;
}
.side-switch__on  { background: var(--hot); color: #21071a; }
.side-switch__off { color: var(--muted); }
.side-switch__off:hover { color: var(--text); background: var(--panel-2); }

.topnav { display: flex; gap: 0.35rem; }
.topnav .is-on { border-color: var(--hot); color: var(--hot); }

/* ---------- games ---------- */
.q-box {
  border: 1px solid var(--line); border-radius: 11px;
  padding: 0.85rem 1rem; background: var(--panel-2);
}
.q-prompt {
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  line-height: 1.3; letter-spacing: -0.01em; margin-bottom: 0.7rem;
}
.q-cat {
  display: block; font-family: var(--mono); font-size: 0.66rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 0.35rem;
}
.q-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.q-choice {
  padding: 0.5rem 0.7rem; border-radius: 9px;
  border: 1px solid var(--line); background: #17122a;
  font-size: 0.88rem;
}
.q-choice b { color: var(--muted); margin-right: 0.35rem; }
/* A choice removed by fifty-fifty stays in place but greys out, so the host can
   still see what was taken away without the layout jumping. */
.q-choice.gone  { opacity: 0.28; text-decoration: line-through; }
.q-choice.right { border-color: var(--live); background: #14312b; color: #b9ffee; }
.q-choice.right b { color: var(--live); }
.q-why {
  font-size: 0.8rem; color: var(--muted);
  margin: 0.7rem 0 0; padding-top: 0.55rem; border-top: 1px solid var(--line);
}

button.ok  { border-color: var(--live); color: var(--live); }
button.bad { border-color: var(--hot);  color: var(--hot); }
button.spent { opacity: 0.4; text-decoration: line-through; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); }

/* ---------- phrase guess (wheel) ---------- */
.wboard {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
  padding: 0.7rem; border-radius: 11px;
  background: #17122a; border: 1px solid var(--line);
}
.wword { display: flex; gap: 0.2rem; }
.wtile {
  display: grid; place-items: center;
  width: 1.5rem; height: 2rem; border-radius: 4px;
  font-family: var(--display); font-weight: 700; font-size: 1rem;
  background: #cfc4e4; color: var(--ink);
}
.wtile.is-on { background: #fff; }
.wtile--punct { background: transparent; color: var(--muted); width: auto; min-width: 0.5rem; }

.wletters { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.wkey {
  width: 2rem; height: 2rem; padding: 0;
  font-family: var(--mono); font-weight: 600; font-size: 0.85rem;
}
/* Vowels are bought rather than earned, so they read differently. */
.wkey--vowel { border-color: var(--amber); color: var(--amber); }
.wkey.is-used { opacity: 0.25; text-decoration: line-through; }

/* ---------- board quiz grid ---------- */
.jgrid { display: grid; gap: 4px; }
.jcat {
  display: grid; place-items: center; text-align: center;
  min-height: 40px; padding: 0.3rem 0.35rem;
  font-family: var(--display); font-weight: 700; font-size: 0.72rem;
  line-height: 1.15; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--amber);
  background: rgba(255, 77, 126, 0.12);
  border-radius: 8px;
}
.jcell {
  min-height: 42px; padding: 0.3rem;
  font-family: var(--display); font-weight: 700; font-size: 0.95rem;
  color: var(--amber);
  background: #17122a;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.jcell:hover:not(:disabled) { border-color: var(--hot); color: var(--text); }
/* A played clue keeps its slot so the grid never reflows mid-show. */
.jcell.is-taken { background: transparent; border-style: dashed; opacity: 0.35; cursor: default; }
.jcell.is-live  { border-color: var(--live); color: var(--live); box-shadow: 0 0 0 2px rgba(79,227,193,0.25); }
.jcell--empty   { background: transparent; border: 0; }

.q-stake {
  margin-left: 0.5rem; padding: 0.05rem 0.4rem; border-radius: 999px;
  background: rgba(255, 181, 71, 0.18); color: var(--amber);
  font-size: 0.62rem; letter-spacing: 0.08em;
}
/* Free-text clues have nothing to highlight, so the answer is written out. */
.q-answer {
  margin-top: 0.5rem; padding: 0.5rem 0.7rem; border-radius: 9px;
  background: #14312b; border: 1px solid var(--live); color: #b9ffee;
  font-family: var(--display); font-weight: 700; font-size: 1rem;
}

@media (max-width: 560px) { .q-choices { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- locked-in answer (coin ladder) ---------- */
/* The host clicks a choice to put it on the board while they ask "final
   answer?". Amber here too, matching the board, and never green — green is
   reserved for the revealed answer on both screens. */
.q-choice.js-pick { cursor: pointer; }
.q-choice.js-pick:hover { border-color: var(--amber); }
.q-choice.picked {
  border-color: var(--amber);
  background: rgba(255, 181, 71, 0.12);
}
.q-final {
  margin-left: 0.5rem; font-family: var(--mono); font-size: 0.68rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber);
}
