@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&display=swap');

:root {
  --bg: #16121f;
  --bg2: #201a2e;
  --card: #2a2340;
  --card2: #342b4f;
  --line: #3f3560;
  --text: #f5f1ff;
  --muted: #a99fc7;
  --yellow: #ffe14d;
  --red: #ff5d73;
  --green: #4fe08a;
  --blue: #6aa8ff;
  --radius: 18px;
  --font: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(circle at 15% -10%, #3a2560 0, transparent 45%),
                    radial-gradient(circle at 110% 20%, #4a1f3a 0, transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(22, 18, 31, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand-sm { font-weight: 800; font-size: 20px; color: var(--yellow); letter-spacing: -1px; }
.brand-sm span { color: var(--red); }
.round { flex: 1; font-weight: 700; color: var(--muted); font-size: 15px; }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 800;
  background: var(--card); border: 1px solid var(--line);
  padding: 4px 12px; border-radius: 999px; min-width: 56px; text-align: center;
}
.timer.low { color: var(--bg); background: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.timebar { position: sticky; top: 55px; z-index: 9; height: 4px; background: transparent; }
.timebar div { height: 100%; background: var(--yellow); transition: width 1s linear; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; font-size: 24px;
}

/* ---------- type ---------- */
h1, h2, h3 { margin: 0 0 8px; line-height: 1.1; letter-spacing: -.5px; }
h2 { font-size: 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.kicker { text-transform: uppercase; letter-spacing: 2px; font-size: 12px; font-weight: 800; color: var(--muted); }

/* ---------- home ---------- */
.logo { text-align: center; margin: 28px 0 22px; }
.logo h1 {
  font-size: clamp(46px, 14vw, 72px); font-weight: 800; line-height: .9; letter-spacing: -3px;
  color: var(--yellow); margin: 0; transform: rotate(-3deg);
  text-shadow: 4px 4px 0 var(--red);
}
.logo h1 small { display: block; color: var(--text); font-size: .55em; letter-spacing: -1px; text-shadow: 3px 3px 0 #5b3fa0; }
.logo p { color: var(--muted); margin: 18px 0 0; }

/* ---------- cards / forms ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.card.flat { background: var(--bg2); }
label.field { display: block; font-weight: 700; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type=text], textarea, select {
  width: 100%; background: var(--bg); border: 2px solid var(--line); border-radius: 14px;
  padding: 14px; font-size: 18px; outline: none; transition: border-color .15s;
}
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--yellow); }
textarea { resize: none; min-height: 110px; line-height: 1.35; }
.code-input { text-transform: uppercase; letter-spacing: 8px; text-align: center; font-weight: 800; font-size: 26px !important; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin: 16px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.counter { text-align: right; font-size: 13px; color: var(--muted); margin-top: 4px; }

.btn {
  display: block; width: 100%; border: 0; cursor: pointer;
  background: var(--yellow); color: #1b1526; font-weight: 800; font-size: 19px;
  padding: 16px; border-radius: 16px; margin-top: 12px;
  box-shadow: 0 5px 0 #b89c1c; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b89c1c; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 5px 0 #a8293d; }
.btn.green { background: var(--green); box-shadow: 0 5px 0 #23904f; }
.btn.ghost { background: transparent; color: var(--text); border: 2px solid var(--line); box-shadow: none; }
.btn.small { font-size: 15px; padding: 10px; }

/* ---------- lobby ---------- */
.room-code {
  text-align: center; padding: 20px 18px;
  background: linear-gradient(135deg, #3b2a66, #5a2346); border: 0;
}
.room-code .code { font-size: 64px; font-weight: 800; letter-spacing: 10px; color: var(--yellow); line-height: 1; margin: 6px 0 10px; padding-left: 10px; }
.room-code .share { font-size: 14px; color: #e3d9ff; word-break: break-all; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border-radius: 12px; padding: 10px 12px; font-weight: 700;
}
.players li.off { opacity: .45; }
.dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #1b1526; font-weight: 800; font-size: 14px; flex: none; }
.tag { margin-left: auto; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.tag.yellow { background: var(--yellow); color: #1b1526; }
.tag.green { background: var(--green); color: #1b1526; }
.mode-pill { display: inline-block; font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: var(--card2); }
.settings { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.settings select { font-size: 16px; padding: 10px; }

details.rules summary { cursor: pointer; font-weight: 800; list-style: none; display: flex; justify-content: space-between; }
details.rules summary::after { content: '+'; font-size: 22px; line-height: 1; }
details.rules[open] summary::after { content: '–'; }
details.rules ol, details.rules ul { padding-left: 20px; margin: 10px 0 0; }
details.rules li { margin-bottom: 6px; }

/* ---------- question ---------- */
.question {
  background: #fff8d6; color: #1b1526; border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px; position: relative;
  box-shadow: 6px 6px 0 var(--red);
}
.question .cat { font-size: 12px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: #8a6b00; }
.question p { font-size: 21px; font-weight: 700; margin: 6px 0 0; line-height: 1.3; }

.role {
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  border: 2px dashed var(--line); background: var(--bg2);
}
.role.insider { border-color: var(--green); background: rgba(79, 224, 138, .08); }
.role h3 { font-size: 20px; }
.secret {
  background: var(--green); color: #102417; font-weight: 800; border-radius: 12px;
  padding: 12px 14px; margin: 10px 0 4px; font-size: 18px;
}

.waiting { text-align: center; padding: 26px 16px; }
.waiting .big { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--card2); }
.chip .dot { width: 20px; height: 20px; font-size: 11px; }
.chip.done { background: var(--green); color: #102417; }
.chip.pending { opacity: .55; }

/* ---------- voting ---------- */
.answers { display: grid; gap: 10px; }
.answer {
  text-align: left; width: 100%; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 16px; font-size: 18px; font-weight: 600; transition: transform .08s, border-color .1s;
}
.answer:hover:not(:disabled) { border-color: var(--muted); }
.answer:active:not(:disabled) { transform: scale(.98); }
.answer.picked { border-color: var(--yellow); background: #3d3320; }
.answer.truth-hint { border-color: var(--green); }
.answer:disabled { cursor: default; }
.answer.mine { opacity: .5; }
.answer .note { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* ---------- reveal ---------- */
.result {
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  background: var(--card); border: 2px solid var(--line);
  animation: pop .35s both;
}
.result.truth { border-color: var(--green); background: rgba(79, 224, 138, .12); }
.result .label { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.result.truth .label { color: var(--green); }
.result.lie .label { color: var(--red); }
.result .text { font-size: 18px; font-weight: 700; margin: 4px 0 8px; }
.result .by { font-size: 14px; color: var(--muted); }
.result .chips { justify-content: flex-start; margin-top: 8px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.deltas { display: grid; gap: 6px; }
.deltas li { display: flex; align-items: center; gap: 10px; }
.plus { margin-left: auto; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.plus.zero { color: var(--muted); }

.stamp {
  display: inline-block; font-weight: 800; font-size: 34px; letter-spacing: 2px; text-transform: uppercase;
  padding: 6px 16px; border: 5px solid currentColor; border-radius: 12px; transform: rotate(-6deg);
  margin: 10px 0 16px; animation: stamp .35s cubic-bezier(.2, 1.6, .5, 1) both;
}
.stamp.truth { color: var(--green); }
.stamp.bs { color: var(--red); }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } }

/* ---------- duel ---------- */
.toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 14px; padding: 4px; margin: 10px 0; }
.toggle button { border: 0; background: transparent; padding: 12px; border-radius: 11px; font-weight: 800; cursor: pointer; color: var(--muted); }
.toggle button.on.t { background: var(--green); color: #102417; }
.toggle button.on.b { background: var(--red); color: #fff; }
.stakes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.stakes button {
  border: 2px solid var(--line); background: var(--bg); border-radius: 50%; aspect-ratio: 1; max-width: 76px; justify-self: center; width: 100%;
  font-weight: 800; font-size: 22px; cursor: pointer;
}
.stakes button.on { background: var(--yellow); color: #1b1526; border-color: var(--yellow); box-shadow: 0 4px 0 #b89c1c; }
.played { font-size: 22px; font-weight: 800; background: var(--card); border: 2px solid var(--yellow); border-radius: 16px; padding: 18px; margin-bottom: 12px; }
.pot { text-align: center; font-weight: 800; color: var(--yellow); margin-bottom: 4px; }
.calls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calls .btn { font-size: 20px; padding: 22px 8px; }

/* ---------- final ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 20px 0; }
.podium .step { flex: 1; max-width: 140px; text-align: center; }
.podium .block { border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: 30px; font-weight: 800; color: #1b1526; }
.podium .name { font-weight: 800; margin-bottom: 6px; word-break: break-word; }
.podium .pts { color: var(--muted); font-size: 14px; }
.board { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.board li { display: flex; align-items: center; gap: 10px; background: var(--bg2); padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.board li .rank { width: 22px; color: var(--muted); }
.board li .pts { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--yellow); }

/* ---------- overlays ---------- */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 30; display: grid; align-items: end; }
.sheet-card { background: var(--bg2); border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; margin: 0 auto; max-height: 80dvh; overflow: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  background: var(--red); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 14px;
  max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: .25s; z-index: 40; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--green); color: #102417; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; font-weight: 700; padding: 6px; z-index: 50; font-size: 14px; }

@media (min-width: 700px) {
  main { padding-top: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
