:root {
  --bg: #14122b;
  --bg2: #1e1b3f;
  --line: #34306a;
  --text: #f4f1ff;
  --muted: #a49fcf;
  --accent: #ffd166;
  --crew: #4cc9f0;
  --imp: #ff4d6d;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(60vmax 40vmax at 100% 0%, #2b1f5a 0%, transparent 70%),
    radial-gradient(50vmax 40vmax at 0% 100%, #1b2c55 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100svh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.center {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.top { display: flex; justify-content: space-between; align-items: center; }

.logo {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--imp));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline { margin: 0; color: var(--muted); }

.card {
  background: color-mix(in srgb, var(--bg2) 85%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

h2, h3 { margin: 0; font-size: 1.05rem; }
h2 { display: flex; gap: 8px; align-items: center; }

.count {
  background: var(--line);
  border-radius: 99px;
  padding: 0 9px;
  font-size: .85rem;
}

.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 4px;
  background: var(--line); border-radius: 99px; padding: 4px 4px 4px 14px;
}
.icon {
  border: 0; background: transparent; width: 30px; height: 30px; border-radius: 50%;
  color: var(--muted);
}
.icon:active { background: var(--bg); }

.add { display: flex; gap: 8px; }
.add input {
  flex: 1; min-width: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px;
}
.add input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.segs, .lang { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; gap: 2px; }
.seg {
  border: 0; background: transparent; border-radius: 9px; padding: 6px 11px;
  color: var(--muted); font-weight: 700; font-size: .9rem; white-space: nowrap;
}
.seg.on { background: var(--accent); color: #241b00; }

.toggle { cursor: pointer; }
.toggle input {
  appearance: none; width: 48px; height: 28px; border-radius: 99px; flex: none;
  background: var(--line); position: relative; cursor: pointer; transition: background .15s;
}
.toggle input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--text); transition: transform .15s;
}
.toggle input:checked { background: var(--crew); }
.toggle input:checked::after { transform: translateX(20px); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 99px;
  padding: 6px 12px; color: var(--muted); font-size: .9rem;
}
.chip.on { background: var(--crew); border-color: var(--crew); color: #00202b; font-weight: 700; }

.code {
  font: 700 1.05rem ui-monospace, monospace; letter-spacing: .12em;
  background: var(--bg); padding: 3px 10px; border-radius: 8px; color: var(--accent);
}

.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }

.link {
  border: 0; background: none; color: var(--accent); padding: 4px 0;
  text-decoration: underline; text-underline-offset: 3px;
}

.foot { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }

.btn {
  border: 0; border-radius: 16px; padding: 12px 22px; font-weight: 800;
  background: var(--accent); color: #241b00;
  box-shadow: 0 6px 0 #b8902d;
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8902d; }
.btn:disabled { opacity: .4; transform: none; box-shadow: none; }
.btn.big { width: 100%; max-width: 360px; font-size: 1.25rem; padding: 18px; }
.btn.small { padding: 8px 14px; box-shadow: 0 4px 0 #b8902d; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--imp); color: #fff; box-shadow: 0 6px 0 #a12740; }
.btn.danger:active { box-shadow: 0 2px 0 #a12740; }

.step {
  margin: 0; font-weight: 700; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase; font-size: .85rem;
}
.who { margin: 0 0 18px; font-size: clamp(2.2rem, 11vw, 3.6rem); line-height: 1.05; word-break: break-word; }
.quit { margin-top: 18px; color: var(--muted); }

.reveal .secret {
  width: 100%; max-width: 380px;
  border-radius: 26px; padding: 34px 20px; margin: 10px 0 22px;
  border: 3px solid var(--crew);
  background: color-mix(in srgb, var(--crew) 14%, var(--bg2));
  animation: pop .25s ease-out;
}
.reveal.imp .secret {
  border-color: var(--imp);
  background: color-mix(in srgb, var(--imp) 18%, var(--bg2));
}
.role { margin: 0 0 14px; font-size: 1.5rem; font-weight: 900; color: var(--imp); text-transform: uppercase; }
.word { margin: 4px 0 8px; font-size: clamp(2.2rem, 12vw, 3.4rem); line-height: 1.05; hyphens: auto; overflow-wrap: break-word; }
.word.long { font-size: clamp(1.5rem, 8vw, 2.4rem); }
.cat { margin: 4px 0 0; color: var(--muted); }

@keyframes pop {
  from { transform: scale(.85); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.rules { max-width: 360px; color: var(--muted); margin: 0 0 10px; }
.timer { font: 800 3rem ui-monospace, monospace; color: var(--accent); }
.timer.done { color: var(--imp); font-size: 1.6rem; font-family: inherit; }
.play .btn.ghost { margin-bottom: 18px; }

.imps { list-style: none; margin: 0 0 18px; padding: 0; }
.imps li { font-size: clamp(2rem, 10vw, 3rem); font-weight: 900; color: var(--imp); line-height: 1.1; }
.result .btn.ghost { width: 100%; max-width: 360px; margin-top: 8px; }
.result .btn.big { margin-top: 22px; }

.picks { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 360px; margin: 14px 0 22px; }
.pick {
  border: 2px solid var(--line); background: var(--bg2); border-radius: 16px;
  padding: 16px; font-size: 1.3rem; font-weight: 800;
}
.pick.on { border-color: var(--imp); background: color-mix(in srgb, var(--imp) 25%, var(--bg2)); }

.verdict { margin: 0 0 10px; font-size: clamp(2rem, 10vw, 3rem); line-height: 1.1; }
.verdict.win { color: var(--crew); }
.verdict.some { color: var(--accent); }
.verdict.lose { color: var(--imp); }
.picked { list-style: none; margin: 0 0 18px; padding: 0; font-size: 1.1rem; font-weight: 700; }
.picked .hit { color: var(--crew); }
.picked .miss { color: var(--muted); }

.scores { width: 100%; max-width: 360px; border-collapse: collapse; margin: 6px auto 0; }
.scores td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.scores tr:last-child td { border-bottom: 0; }
.scores .got { color: var(--crew); font-weight: 800; text-align: right; width: 3em; }
.scores .pts { font-weight: 900; text-align: right; width: 3em; font-variant-numeric: tabular-nums; }
.result .scores { margin-top: 18px; }
