:root {
  --bg: #0d0d12;
  --bg2: #16161f;
  --card: #1d1d28;
  --card2: #25253340;
  --line: #2e2e3d;
  --txt: #f2f2f7;
  --muted: #9a9aac;
  --red: #ff4338;
  --red-dk: #d8362d;
  --green: #2fd573;
  --amber: #ffb020;
  --blue: #4a8cff;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #1c1320 0%, var(--bg) 55%);
  color: var(--txt);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 18px 60px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 20px;
  margin-bottom: 4px;
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 16px var(--red); }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }

h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}

.field { width: 100%; }
input[type="text"], textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--txt);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
input[type="text"]:focus, textarea:focus { border-color: var(--red); }
textarea { resize: vertical; min-height: 64px; }
label.qlabel { display: block; font-size: 14px; color: var(--txt); margin: 14px 0 8px; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: var(--red);
  color: white;
  font-size: 16px;
  font-weight: 700;
  padding: 15px 18px;
  cursor: pointer;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--red-dk); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: var(--card2); border: 1px solid var(--line); }
.btn.secondary:hover { background: #2c2c3c; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* option grid (names) */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.opt {
  background: var(--card2);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, background .12s, transform .08s;
  word-break: break-word;
}
.opt:active { transform: scale(.97); }
.opt.selected { border-color: var(--red); background: #ff43381f; }
.opt.correct { border-color: var(--green); background: #2fd5731f; }
.opt.wrong { border-color: var(--red); background: #ff43381f; opacity: .8; }
.opt.dim { opacity: .4; }
.opt:disabled { cursor: default; }

.answer-bubble {
  background: linear-gradient(135deg, #221722, #1a1622);
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 14px;
  padding: 18px 20px;
  font-size: 19px;
  line-height: 1.4;
  font-style: italic;
  margin: 16px 0;
}
.prompt-tag { font-size: 13px; color: var(--amber); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }

.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.live { background: #ff43382e; color: var(--red); }
.pill.ok { background: #2fd5732e; color: var(--green); }

.badge { display:inline-flex; align-items:center; gap:6px; font-size: 13px; color: var(--muted); }

.spacer { flex: 1; }

/* leaderboard */
.lb { list-style: none; }
.lb li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 8px;
  background: var(--card2); border: 1px solid var(--line);
}
.lb .rk { width: 28px; height: 28px; border-radius: 8px; display:grid; place-items:center; font-weight:800; font-size:14px; background:#33333f; }
.lb li:nth-child(1) .rk { background: linear-gradient(135deg,#ffd24a,#f0a000); color:#241a00; }
.lb li:nth-child(2) .rk { background: linear-gradient(135deg,#dfe6ee,#aab4c2); color:#1a2026; }
.lb li:nth-child(3) .rk { background: linear-gradient(135deg,#e8a878,#c5763e); color:#231203; }
.lb .nm { flex:1; font-weight:600; }
.lb .sc { font-weight:800; color: var(--txt); font-variant-numeric: tabular-nums; }
.lb li.you { outline: 2px solid var(--red); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2a2a38; border: 1px solid var(--line); color: var(--txt);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50;
  box-shadow: 0 10px 30px #0008; max-width: 90%;
}
.hidden { display: none !important; }

.progress { height: 6px; background: var(--line); border-radius: 99px; overflow:hidden; margin: 8px 0 4px; }
.progress > i { display:block; height:100%; background: var(--red); transition: width .3s; }

/* ===================== HOST (big screen) ===================== */
body.host { background: radial-gradient(1400px 900px at 50% -10%, #241526 0%, var(--bg) 55%); }
.host-wrap { max-width: 1100px; margin: 0 auto; padding: 36px 32px; }
.host-wrap h1 { font-size: 40px; }
.host-top { display:flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }
.qr-card { background: white; border-radius: 24px; padding: 22px; display:inline-block; }
.qr-card img { width: 320px; height: 320px; display:block; }
.join-url { font-size: 22px; font-weight: 800; color: var(--red); margin-top: 14px; text-align:center; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.player-chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; font-size: 18px; font-weight: 600; display:flex; align-items:center; gap:10px;
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.8); opacity:0; } to { transform: scale(1); opacity:1; } }
.player-chip .st { width:10px; height:10px; border-radius:50%; background: var(--muted); }
.player-chip .st.on { background: var(--green); box-shadow:0 0 8px var(--green); }
.player-chip .st.done { background: var(--green); }
.player-chip .st.pending { background: var(--amber); }

.host-question { font-size: 30px; font-weight: 800; line-height:1.2; }
.host-answer {
  background: linear-gradient(135deg, #2a1a2a, #1d1726);
  border: 1px solid var(--line); border-left: 6px solid var(--red);
  border-radius: 20px; padding: 36px 40px; font-size: 40px; line-height: 1.3;
  font-style: italic; margin: 24px 0;
}
.host-stat { font-size: 56px; font-weight: 900; font-variant-numeric: tabular-nums; }
.dim2 { color: var(--muted); font-size: 16px; }
.controls { display:flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.controls .btn { width: auto; flex: 0 0 auto; padding: 16px 28px; font-size: 18px; }
.big-count { font-size: 22px; font-weight: 800; }
.podium { display:flex; align-items:flex-end; justify-content:center; gap: 18px; margin: 30px 0; }
.podium .col { text-align:center; }
.podium .bar { width: 150px; border-radius: 16px 16px 0 0; display:flex; align-items:flex-start; justify-content:center; padding-top:14px; font-weight:900; font-size: 28px; }
.podium .p1 .bar { height: 220px; background: linear-gradient(180deg,#ffd24a,#f0a000); color:#241a00; }
.podium .p2 .bar { height: 170px; background: linear-gradient(180deg,#dfe6ee,#aab4c2); color:#1a2026; }
.podium .p3 .bar { height: 130px; background: linear-gradient(180deg,#e8a878,#c5763e); color:#231203; }
.podium .nm { font-size: 22px; font-weight:800; margin-bottom: 8px; }
.podium .sc { font-size: 16px; color: var(--muted); }

/* ===================== IMPOSTER ===================== */

/* carta de rol: toca-para-ver (el de al lado no debe alcanzar a leerla) */
.role-card {
  position: relative;
  width: 100%;
  min-height: 260px;
  border-radius: 22px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.role-card .role-back, .role-card .role-front {
  position: absolute; inset: 0;
  display: grid; place-content: center; place-items: center;
  border-radius: 22px; padding: 24px; text-align: center;
  transition: opacity .12s;
}
.role-card .role-back {
  background: linear-gradient(145deg, #2a1f33, #1a1622);
  border: 2px dashed var(--line);
  opacity: 1;
}
.role-card .role-front {
  background: linear-gradient(145deg, #241726, #1c1728);
  border: 2px solid var(--red);
  opacity: 0;
  pointer-events: none;
}
.role-card.open .role-back { opacity: 0; }
.role-card.open .role-front { opacity: 1; }
.role-lock { font-size: 44px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.role-hint { color: var(--muted); font-size: 15px; font-weight: 600; margin-top: 10px; }
.role-imposter { font-size: 34px; font-weight: 900; line-height: 1.1; color: var(--red); letter-spacing: -0.02em; }
.role-loyal { font-size: 30px; font-weight: 900; line-height: 1.15; letter-spacing: -0.02em; }
.role-sub { font-size: 14px; font-weight: 600; color: var(--muted); margin: 8px 0; letter-spacing: 0; }
.peek-out {
  margin-top: 14px; padding: 20px; border-radius: 14px;
  background: var(--bg2); border: 1px solid var(--red); text-align: center;
}
#peekBtn { user-select: none; touch-action: none; }

/* turno del jugador */
.turn-hot { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 10px 40px #ff433826; }
.turn-list { list-style: none; counter-reset: t; }
.turn-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px; margin-bottom: 7px;
  background: var(--card2); border: 1px solid var(--line);
  counter-increment: t;
}
.turn-list li::before {
  content: counter(t); width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: #33333f; color: var(--muted); flex: 0 0 auto;
}
.turn-list li .nm { flex: 1; font-weight: 600; }
.turn-list li.done { opacity: .45; }
.turn-list li.now { border-color: var(--red); background: #ff43381a; }
.turn-list li.now::before { background: var(--red); color: #fff; }
.turn-list li.you .nm::after { content: " (tú)"; color: var(--muted); font-weight: 500; }

/* host: tira de turnos */
.turn-strip { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0 4px; }
.turn-chip {
  padding: 10px 16px; border-radius: 999px; font-size: 16px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line);
}
.turn-chip.done { opacity: .4; }
.turn-chip.now { border-color: var(--red); background: #ff43382e; color: var(--red); font-weight: 800; }
.turn-chip.off { text-decoration: line-through; opacity: .3; }

/* host: editor de personajes + selector de impostores */
/* Editor de personajes colapsable: la pantalla del host se proyecta, así que
   la lista arranca cerrada y no muestra la cantidad. */
.char-details { padding: 0; }
.char-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px;
  cursor: pointer;
  font-size: 19px;
  font-weight: 700;
  list-style: none;
  user-select: none;
}
.char-summary::-webkit-details-marker { display: none; }
.char-summary::after { content: "▸"; color: var(--muted); font-weight: 400; }
.char-details[open] .char-summary::after { content: "▾"; }
.char-summary:hover { color: var(--red); }
.char-body { padding: 0 20px 20px; }

.pack-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
#charEditor { font-size: 15px; line-height: 1.5; min-height: 150px; }
.imp-pick { display: flex; gap: 10px; margin-top: 12px; }
.imp-opt {
  flex: 1; padding: 16px; border-radius: 14px; cursor: pointer;
  background: var(--card2); border: 2px solid var(--line); color: var(--txt);
  font-size: 22px; font-weight: 800; font-family: inherit;
  transition: border-color .12s, background .12s;
}
.imp-opt.on { border-color: var(--red); background: #ff43381f; color: var(--red); }
.player-chip { cursor: pointer; }

/* host: conteo de votos del reveal */
.tally { max-width: 460px; margin: 24px auto 0; }
.tally-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tally-row .nm { width: 150px; text-align: right; font-weight: 600; font-size: 16px; }
.tally-row .bar { height: 22px; border-radius: 6px; background: var(--red); min-width: 4px; }
.tally-row .n { font-weight: 800; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .host-wrap { padding: 20px 16px; }
  .host-wrap h1 { font-size: 28px; }
  .qr-card img { width: 240px; height: 240px; }
  .host-answer { font-size: 26px; padding: 24px; }
  #cCurrent { font-size: 34px !important; }
}
