:root {
  --bg: #07071a;
  --bg-2: #0b0a24;
  --card: #15143a;
  --card-2: #1b1945;
  --line: rgba(150, 130, 255, 0.14);
  --line-strong: rgba(170, 140, 255, 0.35);
  --text: #f4f2ff;
  --muted: #a9a6c8;
  --faint: #6f6c93;
  --purple: #a77bf5;
  --purple-deep: #6d3fc0;
  --btn-a: #57247f;
  --btn-b: #2f1550;
  --teal: #74f0d4;
  --red: #f0675c;
  --gold: #f5c35a;
  --blue: #4f8df7;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 70% at 50% 0%, #10103a 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  animation: in .22s ease-out;
}
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- top bar */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; position: relative; }
.bar .title { position: absolute; left: 50%; transform: translateX(-50%); font-size: 19px; font-weight: 500; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: rgba(255,255,255,.06); }
.big-title { font-size: 30px; font-weight: 700; margin: 6px 0 14px; letter-spacing: .2px; }
.lede { color: var(--muted); margin: -6px 0 16px; }

/* ---------- buttons */
.btn {
  display: block; width: 100%; height: 56px; border-radius: 22px;
  font-weight: 700; font-size: 18px; letter-spacing: .2px;
  background: linear-gradient(90deg, var(--btn-a), var(--btn-b));
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.985); filter: brightness(1.15); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.outline { background: transparent; border: 1.5px solid #4a2368; }
.btn.danger { background: linear-gradient(90deg, #6a1410, #3d0806); }
.btn.small { height: 44px; font-size: 16px; border-radius: 14px; }
.btn + .btn { margin-top: 12px; }
.link { color: var(--purple); font-weight: 600; padding: 10px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* ---------- home */
.home { text-align: center; }
.hood { width: 210px; margin: 9vh auto 0; display: block; }
.home h1 { font-size: 48px; margin: -8px 0 0; font-weight: 700; letter-spacing: .5px; text-shadow: 0 0 18px rgba(255,255,255,.12); }
.home h2 { font-size: 34px; margin: 4px 0 0; color: var(--purple); font-weight: 600; }
.home p { color: var(--muted); margin: 28px 24px 0; font-size: 17px; }

/* ---------- cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.glow { border-color: var(--line-strong); box-shadow: 0 0 0 1px rgba(160,130,255,.05), 0 0 24px rgba(120, 90, 255, .08); }
.howto-card { display: flex; gap: 16px; align-items: flex-start; padding: 20px 18px; }
.howto-card h3 { margin: 0 0 6px; font-size: 19px; }
.howto-card p { margin: 0; color: var(--muted); font-size: 15px; }
.badge { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #3a2766; }
.badge svg { width: 22px; height: 22px; }
.tip { margin-top: 24px; text-align: center; padding: 22px 26px; background: linear-gradient(110deg, #3c2266, #24476e); border: 1px solid rgba(160,170,255,.3); border-radius: var(--radius); }
.tip b { display: block; color: var(--gold); font-size: 18px; margin: 6px 0 8px; }
.tip p { margin: 0; color: #e6e4ff; font-size: 15px; }

/* settings */
.stat { text-align: center; padding: 18px 10px; border-radius: 18px; background: var(--card); border: 1px solid var(--line-strong); }
.stat .ico { width: 42px; height: 42px; margin: 0 auto 10px; border-radius: 12px; background: #3a2766; display: grid; place-items: center; }
.stat .ico svg { width: 22px; height: 22px; }
.stat small { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat strong { display: block; font-size: 22px; margin-top: 4px; }
.section { display: flex; align-items: center; gap: 10px; color: #dcd9f5; font-size: 17px; margin: 26px 0 12px; }
.section svg { width: 20px; height: 20px; color: var(--purple); }
.mode { text-align: center; padding: 22px 10px 18px; border-radius: 18px; background: var(--card); border: 1.5px solid var(--line); }
.mode svg { width: 30px; height: 30px; color: #cfcce8; }
.mode b { display: block; font-size: 18px; margin: 10px 0 6px; }
.mode small { color: var(--muted); font-size: 13px; display: block; }
.mode.on { border-color: var(--purple); background: linear-gradient(160deg, #2b1747, #1a1238); box-shadow: 0 0 22px rgba(167,123,245,.25); }
.mode.on svg, .mode.on b { color: var(--purple); }
.opts { border-radius: 20px; border: 1.5px solid rgba(120,150,220,.45); background: var(--card); padding: 4px 20px; box-shadow: 0 0 24px rgba(90,120,220,.12); }
.opt { display: flex; align-items: center; gap: 12px; min-height: 64px; border-bottom: 1px solid var(--line); }
.opt:last-child { border-bottom: 0; }
.opt .lbl { flex: 1; color: #dedbf6; font-size: 16px; }
.opt svg.lead { width: 20px; height: 20px; color: var(--purple); flex: 0 0 auto; }
.opt.cats .lbl { font-weight: 600; font-size: 17px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 30px; height: 30px; border-radius: 8px; background: #2c3f5c; display: grid; place-items: center; }
.chev svg { width: 16px; height: 16px; }
.toggle { width: 52px; height: 32px; border-radius: 16px; background: #3b3a52; position: relative; transition: background .2s; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #d8d8e2; transition: transform .2s; }
.toggle.on { background: #5b2e8a; }
.toggle.on::after { transform: translateX(20px); background: #fff; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; background: #2a2852; font-size: 20px; font-weight: 700; }
.stepper span { min-width: 22px; text-align: center; font-weight: 700; }
.footer { position: sticky; bottom: 0; padding: 14px 0 calc(6px + var(--safe-bottom)); background: linear-gradient(transparent, var(--bg) 30%); margin-top: 18px; }

/* list rows (settings screen) */
.group { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.group + .group { margin-top: 16px; }
.li { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.li:last-child { border-bottom: 0; }
.li .sq { width: 30px; height: 30px; border-radius: 8px; background: #2a2552; display: grid; place-items: center; flex: 0 0 auto; }
.li .sq svg { width: 17px; height: 17px; color: var(--purple); }
.li span { flex: 1; }
.li em { font-style: normal; color: var(--muted); font-size: 15px; }
.caption { color: var(--muted); font-size: 15px; margin: 22px 4px 10px; }
.input {
  width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--card-2); padding: 0 16px; font-size: 17px; outline: none;
}
.input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(167,123,245,.2); }
.input.code { text-transform: uppercase; letter-spacing: 8px; text-align: center; font-size: 26px; font-weight: 700; height: 62px; }

/* player names */
.pill { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; background: linear-gradient(90deg, #35205a, #241a4a); border: 1px solid var(--line-strong); box-shadow: 0 0 22px rgba(150,100,255,.18); }
.pill .sq { width: 38px; height: 38px; border-radius: 10px; background: #4c3080; display: grid; place-items: center; }
.pill .sq svg { width: 20px; height: 20px; color: var(--purple); }
.pill select { flex: 1; background: transparent; border: 0; color: var(--text); font-size: 18px; font-weight: 600; appearance: none; outline: none; }
.pill .updown { width: 26px; height: 26px; border-radius: 6px; background: #5a4a7a; display: grid; place-items: center; pointer-events: none; }
.count { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 14px; background: #121836; border: 1px solid var(--line); margin-top: 12px; }
.count b { flex: 1; } .count em { font-style: normal; color: var(--muted); font-size: 14px; }
.count .sq { width: 30px; height: 30px; border-radius: 8px; background: #2e2856; display: grid; place-items: center; }
.count .sq svg { width: 17px; height: 17px; color: var(--purple); }
.pname { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; background: var(--card); margin-top: 12px; }
.num { width: 40px; height: 40px; border-radius: 11px; background: #4a3178; display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.pname input { flex: 1; background: transparent; border: 0; outline: none; font-size: 17px; color: var(--text); min-width: 0; }
.pname input::placeholder { color: var(--muted); }
.bottom-tray { position: sticky; bottom: 0; display: flex; gap: 14px; padding: 16px 0 calc(10px + var(--safe-bottom)); margin-top: auto; background: linear-gradient(transparent, var(--bg) 25%); }
.tray-btn { flex: 1; height: 58px; border-radius: 16px; border: 1.5px solid #4c4a66; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 18px; color: #b9b7cf; }
.tray-btn.add { border-color: var(--purple); color: var(--purple); background: rgba(167,123,245,.08); }
.tray-btn svg { width: 22px; height: 22px; }

/* categories picker */
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat { position: relative; padding: 16px 14px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); text-align: left; min-height: 92px; }
.cat .e { font-size: 28px; display: block; }
.cat b { display: block; margin-top: 8px; font-size: 15px; }
.cat small { color: var(--muted); font-size: 12px; }
.cat.on { border-color: var(--purple); background: linear-gradient(160deg, #2b1747, #1a1238); }
.cat .tick { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--faint); display: grid; place-items: center; }
.cat.on .tick { background: var(--purple); border-color: var(--purple); }
.cat .tick svg { width: 14px; height: 14px; opacity: 0; }
.cat.on .tick svg { opacity: 1; }
.free { display: inline-block; font-size: 11px; font-weight: 700; color: #07332a; background: var(--teal); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }

/* players grid */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ptile { border-radius: 16px; background: var(--card); border: 1.5px solid rgba(110,110,255,.55); padding: 14px 8px 14px; text-align: center; box-shadow: 0 0 16px rgba(90,110,255,.22); }
.avatar { width: 92px; height: 92px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 700; background: linear-gradient(140deg, var(--blue), #a548d9); box-shadow: 0 0 18px rgba(120,100,255,.25); }
.ptile span { display: block; margin-top: 10px; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptile.done { opacity: .38; box-shadow: none; border-color: var(--line); }
.ptile.done .avatar { background: #2b2a49; }

/* reveal */
.reveal { text-align: center; }
.reveal .for { color: var(--muted); font-size: 18px; margin-top: 22vh; }
.reveal .for b { color: #d6b5ff; }
.reveal h2 { font-size: 26px; margin: 8px 0 26px; }
.box { position: relative; width: 82%; max-width: 330px; aspect-ratio: 1.4; margin: 0 auto; border-radius: 18px; background: #191842; overflow: hidden; display: grid; place-items: center; }
.box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.box .word { font-size: 30px; font-weight: 700; letter-spacing: .6px; color: var(--teal); text-shadow: 0 0 14px rgba(116,240,212,.55); padding: 0 16px; }
.box .word.q { font-size: 21px; color: #e5e1ff; text-shadow: none; line-height: 1.35; }
.box.imp { border: 2px solid var(--red); box-shadow: 0 0 22px rgba(240,103,92,.45), inset 0 0 18px rgba(240,103,92,.15); }
.box.imp .word { color: var(--red); text-shadow: 0 0 14px rgba(240,103,92,.6); }
.tap-hint { color: #5ec7f2; margin-top: 16px; font-size: 15px; }
.clue-card { width: 90%; max-width: 360px; margin: 22px auto 0; padding: 16px; border-radius: 16px; background: #2a1426; border: 1px solid rgba(240,103,92,.25); }
.clue-card .lab { color: var(--gold); font-weight: 600; font-size: 15px; }
.clue-card b { display: block; font-size: 24px; letter-spacing: 1.5px; margin: 6px 0; text-transform: uppercase; }
.clue-card small { color: #e8dede; }
.fellow { margin-top: 12px; color: #f2b3ad; font-size: 15px; }

/* voting */
.vstep { display: flex; gap: 18px; align-items: center; padding: 18px; border-radius: 18px; background: var(--card); border: 1px solid; }
.vstep + .vstep { margin-top: 16px; }
.vstep .vi { position: relative; width: 58px; height: 58px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; }
.vstep .vi svg { width: 26px; height: 26px; }
.vstep .n { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; display: grid; place-items: center; color: #fff; }
.vstep h4 { margin: 0 0 4px; font-size: 17px; }
.vstep p { margin: 0; color: var(--muted); font-size: 15px; }
.s1 { border-color: rgba(80,150,255,.55); } .s1 .vi { background: #23476f; color: #6fb2ff; } .s1 .n { background: #3b9cf5; }
.s2 { border-color: rgba(150,100,255,.35); } .s2 .vi { background: #3b2a6a; color: #a98af5; } .s2 .n { background: #9b6cf0; }
.s3 { border-color: rgba(255,210,120,.35); } .s3 .vi { background: #4d4232; color: #f3c45a; } .s3 .n { background: #e2b23f; color: #3a2a00; }
.s4 { border-color: rgba(240,103,92,.35); } .s4 .vi { background: #4c2732; color: #f06b5d; } .s4 .n { background: #e5554a; }

/* results */
.results { text-align: center; }
.results .lab { letter-spacing: 2.5px; font-size: 16px; text-transform: uppercase; }
.results .who { font-size: 34px; font-weight: 700; color: #ee7a6c; text-shadow: 0 0 16px rgba(240,103,92,.35); margin: 6px 0 30px; }
.results .secret { font-size: 34px; font-weight: 800; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 0 16px rgba(245,195,90,.35); margin-top: 6px; }
.results .q { font-size: 18px; color: #f1e8c9; margin: 6px 12px 0; }
.verdict { display: inline-block; margin: 0 auto 22px; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 15px; }
.verdict.win { background: rgba(116,240,212,.12); color: var(--teal); }
.verdict.lose { background: rgba(240,103,92,.12); color: var(--red); }

/* online */
.room-code { text-align: center; padding: 18px; }
.room-code small { color: var(--muted); letter-spacing: 2px; text-transform: uppercase; font-size: 12px; }
.room-code b { display: block; font-size: 46px; letter-spacing: 12px; margin: 4px 0 6px; padding-left: 12px; color: #fff; text-shadow: 0 0 22px rgba(167,123,245,.45); }
.plist .pl { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.plist .pl:last-child { border-bottom: 0; }
.plist .mini { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: linear-gradient(140deg, var(--blue), #a548d9); flex: 0 0 auto; }
.plist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .tag { font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #3ed598; flex: 0 0 auto; }
.dot.off { background: #6a6888; }
.crown { color: var(--gold); font-size: 14px; }
.x { color: var(--faint); font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
.status { text-align: center; color: var(--muted); padding: 10px; font-size: 15px; }
.clue-list .cl { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: baseline; }
.clue-list .cl:last-child { border-bottom: 0; }
.clue-list .cl b { min-width: 0; flex: 0 1 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 500; }
.clue-list .cl span { flex: 1; font-weight: 600; }
.clue-list .cl span.spoken { color: var(--faint); font-weight: 400; font-style: italic; }
.turn { text-align: center; padding: 14px; border-radius: 16px; background: linear-gradient(110deg, #3c2266, #24476e); margin: 14px 0; }
.turn b { color: #fff; }
.vote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vote { padding: 14px 10px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); text-align: center; position: relative; }
.vote .avatar { width: 56px; height: 56px; font-size: 20px; }
.vote span { display: block; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote.on { border-color: var(--red); box-shadow: 0 0 18px rgba(240,103,92,.35); }
.vote .vc { position: absolute; top: 8px; right: 10px; font-size: 12px; color: var(--muted); }
.vote[disabled] { opacity: .4; }
.peek { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); margin-top: 12px; }
.peek span { color: var(--muted); font-size: 14px; }
.peek b { filter: blur(7px); transition: filter .2s; user-select: none; }
.peek.open b { filter: none; }
.score-row { display: flex; justify-content: space-between; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.score-row:last-child { border-bottom: 0; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); background: #2b2350; border: 1px solid var(--line-strong); padding: 12px 18px; border-radius: 14px; max-width: 90%; z-index: 9; animation: in .2s; text-align: center; }
.conn { position: fixed; top: calc(8px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: #4d2a1a; color: #ffd7b8; padding: 6px 12px; border-radius: 999px; font-size: 13px; z-index: 9; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 8; display: flex; align-items: flex-end; justify-content: center; animation: in .15s; }
.sheet { width: 100%; max-width: 480px; background: #14133a; border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + var(--safe-bottom)); border-top: 1px solid var(--line-strong); }
.sheet h3 { margin: 0 0 16px; text-align: center; }
.big-stepper { display: flex; align-items: center; justify-content: center; gap: 28px; margin: 10px 0 22px; }
.big-stepper button { width: 56px; height: 56px; border-radius: 16px; background: #2a2852; font-size: 28px; font-weight: 700; }
.big-stepper b { font-size: 44px; min-width: 60px; text-align: center; }

/* category selection (matches the original layout) */
.seg { display: flex; background: #121233; border: 1px solid #2a2656; border-radius: 16px; padding: 0; overflow: hidden; margin: 2px 0 18px; }
.seg button { flex: 1; height: 50px; font-size: 17px; color: #b5b2d4; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 14px; }
.seg button.on { background: #3d2468; color: #fff; }
.cbadge { min-width: 22px; height: 22px; border-radius: 11px; background: #2c6fd0; color: #fff; font-size: 13px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 6px; }
.ctiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ctile { position: relative; text-align: left; min-height: 132px; padding: 16px 16px 14px; border-radius: 22px; background: linear-gradient(160deg, #1a1a3c, #14142f); border: 1.5px solid #2c2852; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform .08s; user-select: none; }
.ctile:active { transform: scale(.98); }
.ctile b { font-size: 17px; line-height: 1.25; letter-spacing: .2px; padding-right: 26px; overflow-wrap: anywhere; }
.ctile small { color: #c9c7e0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ctile small i { width: 9px; height: 9px; border-radius: 50%; background: #19b6f0; display: inline-block; }
.ctile.on { background: linear-gradient(160deg, #7c2a49, #6d2442); border-color: #8db9de; box-shadow: 0 0 22px rgba(120, 180, 240, .18); }
.ctile.on small i { background: #8fd0ee; }
.ctile.create { border-color: #8a6f45; background: #15142f; }
.ctile.create .pen { color: #f3c45a; width: 30px; height: 30px; }
.ctile.create .pen svg { width: 30px; height: 30px; }
.ctile.create small { color: #a8a6c4; }
.cedit { position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.08); display: grid; place-items: center; color: #f3c45a; }
.cedit svg { width: 16px; height: 16px; }
.input.area { height: 240px; padding: 14px 16px; resize: vertical; line-height: 1.5; font-family: inherit; }
.danger-link { color: var(--red); }
.tag { font-size: 12px; color: var(--muted); font-weight: 400; }
.dev-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin: 16px 4px 8px; }
.dev-head:first-of-type { margin-top: 0; }
.pname .x { flex: 0 0 auto; }
