:root {
  --bg: #1b1033;
  --bg2: #2a1650;
  --card: #ffffff;
  --ink: #1b1033;
  --muted: #6b6185;
  --text: #f5f0ff;
  --text-dim: #b9acd9;
  --accent: #ff4f8b;
  --accent-ink: #ffffff;
  --yellow: #ffd23f;
  --green: #2fd18b;
  --blue: #4fa3ff;
  --line: rgba(255, 255, 255, 0.12);
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 700px at 10% -10%, #4b1f8a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 10%, #7a1f5a 0%, transparent 55%),
              var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 48px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; font-size: 14px; color: var(--text-dim);
}
.topbar .brand { font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--text); letter-spacing: -0.02em; }
.topbar .brand span { color: var(--accent); }
.topbar .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,0.08);
  font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap;
}
.pill.hot { background: var(--yellow); color: var(--ink); }
.linkish { background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 4px; text-decoration: underline; font-size: 13px; }
.linkish:hover { color: var(--text); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 28px 0 18px; }
.logo {
  font-family: var(--display); font-weight: 800; font-size: clamp(64px, 18vw, 120px);
  line-height: 0.9; letter-spacing: -0.04em; margin: 0;
  background: linear-gradient(100deg, #fff 10%, var(--accent) 55%, var(--yellow) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transform: rotate(-3deg);
}
.tagline { color: var(--text-dim); font-size: 17px; margin: 14px 0 0; }

.panel {
  background: rgba(255,255,255,0.06); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-top: 18px;
}
.panel h2 { font-family: var(--display); font-size: 20px; margin: 0 0 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
input[type=text] {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 2px solid transparent;
  background: #fff; color: var(--ink); font-size: 18px; outline: none;
}
input[type=text]:focus { border-color: var(--accent); }
input.code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.or { text-align: center; color: var(--text-dim); margin: 6px 0 14px; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: 14px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 17px; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 0 #b3245a; transition: transform .08s, box-shadow .08s, opacity .2s;
  width: 100%;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3245a; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.secondary { background: #fff; color: var(--ink); box-shadow: 0 4px 0 #a99cc8; }
.btn.ghost { background: rgba(255,255,255,0.1); color: var(--text); box-shadow: none; }
.btn.small { padding: 9px 14px; font-size: 14px; width: auto; border-radius: 10px; }

.how { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin: 0; padding-left: 20px; }

/* ---------- lobby ---------- */
.room-code {
  text-align: center; padding: 18px; border-radius: var(--radius);
  background: var(--yellow); color: var(--ink); box-shadow: var(--shadow);
}
.room-code small { display: block; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; opacity: .7; }
.room-code strong { font-family: var(--display); font-size: 64px; letter-spacing: .14em; line-height: 1.1; }
.room-code .share { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.room-code .share button { background: rgba(0,0,0,.08); color: var(--ink); border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 600; cursor: pointer; font-size: 14px; }

.players { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.08); font-weight: 600; min-width: 0;
}
.players li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.players li.off { opacity: .45; }
.players li.me { outline: 2px solid var(--accent); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #fff;
}
.kick { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; }
.kick:hover { color: var(--accent); }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.settings select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 0; background: #fff; color: var(--ink); font-weight: 600;
}
.settings .val { font-weight: 700; font-size: 16px; padding: 10px 0; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.mode {
  border: 2px solid var(--line); background: rgba(255,255,255,0.04); color: var(--text);
  border-radius: 14px; padding: 12px 8px; cursor: pointer; text-align: center;
}
.mode b { display: block; font-size: 15px; margin-top: 4px; }
.mode span { font-size: 24px; }
.mode small { display: block; color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.mode.on { border-color: var(--accent); background: rgba(255,79,139,0.15); }
.mode:disabled { cursor: default; }
.hint { color: var(--text-dim); font-size: 14px; text-align: center; margin: 12px 0 0; }

/* ---------- question card ---------- */
.round-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.round-head .cat { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; color: var(--yellow); }
.card {
  background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); position: relative;
}
.fact { font-family: var(--display); font-weight: 700; font-size: clamp(22px, 5vw, 30px); line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
.blank {
  display: inline-block; min-width: 3.5em; border-bottom: 4px solid var(--accent);
  color: var(--accent); padding: 0 .1em; line-height: 1.1;
}
.blank.filled { animation: pop .5s ease; }
.photo {
  display: block; width: 100%; max-height: 52vh; object-fit: cover; border-radius: 12px; margin-bottom: 16px;
  background: #e9e4f5; aspect-ratio: 4 / 3;
}
.photo.loaded { aspect-ratio: auto; }

.timer { height: 8px; border-radius: 99px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 14px 0 6px; }
.timer > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); width: 100%; transition: width .25s linear; }
.timer.low > i { background: var(--accent); }
.timer-label { font-size: 13px; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }

.answer-box { margin-top: 16px; }
.answer-box form { display: flex; gap: 10px; }
.answer-box input { flex: 1; }
.answer-box .btn { width: auto; }
.counter { font-size: 12px; color: var(--text-dim); text-align: right; margin-top: 4px; }

.waiting { text-align: center; padding: 18px 8px 4px; }
.waiting h3 { font-family: var(--display); font-size: 22px; margin: 0 0 4px; }
.waiting p { margin: 0; color: var(--text-dim); }
.your-lie { display: inline-block; margin-top: 8px; padding: 6px 12px; border-radius: 10px; background: rgba(255,255,255,0.1); font-weight: 600; }

.status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; justify-content: center; }
.status .chip { padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,0.08); color: var(--text-dim); }
.status .chip.done { background: var(--green); color: #05301c; }
.status .chip.done::before { content: '✓ '; }

/* ---------- voting ---------- */
.options { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  text-align: left; width: 100%; padding: 16px 18px; border-radius: 14px; border: 0; cursor: pointer;
  background: #fff; color: var(--ink); font-weight: 700; font-size: 18px; box-shadow: 0 4px 0 #a99cc8;
  transition: transform .08s, background .2s;
  overflow-wrap: anywhere;
}
.opt:hover:not(:disabled) { background: #fff3f8; }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a99cc8; }
.opt:disabled { cursor: default; }
.opt.mine { background: rgba(255,255,255,0.15); color: var(--text-dim); box-shadow: none; font-weight: 600; }
.opt.mine::after { content: '  · your lie'; font-size: 13px; font-weight: 600; }
.opt.picked { background: var(--accent); color: #fff; box-shadow: 0 4px 0 #b3245a; }
.opt.picked::after { content: '  ✓ your pick'; font-size: 13px; }
.options.locked .opt:not(.picked):not(.mine) { opacity: .55; }
.options.spect .opt { cursor: default; }

/* ---------- reveal ---------- */
.reveal-stage { margin-top: 18px; min-height: 230px; }
.reveal-card {
  background: #fff; color: var(--ink); border-radius: var(--radius); padding: 22px; text-align: center;
  box-shadow: var(--shadow); animation: slideIn .45s cubic-bezier(.2,.9,.3,1.3);
}
.reveal-card .answer { font-family: var(--display); font-size: clamp(26px, 6vw, 38px); font-weight: 800; margin: 0 0 6px; overflow-wrap: anywhere; }
.reveal-card .pickers { color: var(--muted); font-size: 15px; margin: 0; }
.reveal-card .pickers b { color: var(--ink); }
.verdict {
  margin-top: 16px; padding: 14px; border-radius: 14px; font-weight: 700; font-size: 18px;
  opacity: 0; animation: verdict .5s ease 1.7s forwards;
}
.verdict.lie { background: var(--accent); color: #fff; }
.verdict.house { background: #e9e4f5; color: var(--ink); }
.verdict.truth { background: var(--green); color: #05301c; }
.verdict .big { display: block; font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: .02em; }
.verdict .sub { display: block; font-size: 15px; font-weight: 600; margin-top: 4px; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 14px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.dots i.on { background: var(--yellow); }
.unpicked { margin-top: 14px; color: var(--text-dim); font-size: 14px; text-align: center; }
.unpicked b { color: var(--text); }
.loc { display: block; margin-top: 8px; font-size: 15px; color: var(--muted); font-family: 'Inter', sans-serif; font-weight: 600; }

/* ---------- scores ---------- */
.board { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.board li {
  display: grid; grid-template-columns: 34px 34px 1fr auto; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.08); padding: 10px 14px; border-radius: 14px; animation: slideIn .4s ease both;
}
.board li.me { outline: 2px solid var(--accent); }
.board .rank { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--text-dim); text-align: center; }
.board .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-family: var(--display); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; text-align: right; }
.board .plus { display: block; font-size: 13px; color: var(--green); font-weight: 700; font-family: 'Inter', sans-serif; }

h1.title { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 7vw, 44px); margin: 0; text-align: center; letter-spacing: -0.02em; }
.sub-title { text-align: center; color: var(--text-dim); margin: 6px 0 0; }
.winner { text-align: center; padding: 10px 0 4px; }
.winner .crown { font-size: 64px; display: block; animation: bounce 1.6s ease infinite; }
.winner .who { font-family: var(--display); font-size: clamp(34px, 9vw, 56px); font-weight: 800; color: var(--yellow); line-height: 1.05; overflow-wrap: anywhere; }

.actions { display: grid; gap: 10px; margin-top: 18px; }
.host-bar { display: flex; justify-content: center; margin-top: 16px; }

.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 30px auto 14px; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%);
  background: #fff; color: var(--ink); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: var(--shadow); transition: transform .3s ease; max-width: calc(100% - 32px); z-index: 10; text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
#toast.err { background: var(--accent); color: #fff; }

@keyframes slideIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes verdict { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  .answer-box form { flex-direction: column; }
  .answer-box .btn { width: 100%; }
  .room-code strong { font-size: 52px; }
  .modes { grid-template-columns: 1fr; }
  .mode { display: grid; grid-template-columns: 32px 1fr; text-align: left; align-items: center; column-gap: 8px; }
  .mode span { grid-row: span 2; }
  .mode b { margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition: none !important; }
  .verdict { opacity: 1; }
}
