:root {
  --bg1: #1b1038;
  --bg2: #2d1b69;
  --ink: #fff;
  --muted: #b9acd9;
  --violet: #7c5cff;
  --pink: #ff4d8d;
  --yellow: #ffd23f;
  --teal: #2ee6c5;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-2: rgba(255, 255, 255, 0.15);
  --radius: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg1)) fixed;
  min-height: 100dvh;
  font-size: 18px;
  line-height: 1.35;
  -webkit-user-select: none;
  user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
main {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 2.2rem; font-weight: 900; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.logo { text-align: center; padding: 18px 0 6px; }
.logo .mark { font-size: 4rem; filter: drop-shadow(0 8px 18px rgba(255, 77, 141, 0.5)); }
.logo h1 span { background: linear-gradient(90deg, var(--yellow), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 18px;
  padding: 16px 20px;
  font: inherit;
  font-weight: 800;
  color: #1b1038;
  background: var(--yellow);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
  min-height: 56px;
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
  width: 100%;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.teal { background: var(--teal); }
.btn.violet { background: var(--violet); color: #fff; }
.btn.ghost { background: var(--panel-2); color: #fff; box-shadow: none; }
.btn.small { min-height: 44px; padding: 10px 14px; width: auto; font-size: 0.95rem; border-radius: 14px; }
.icon-btn {
  appearance: none; border: 0; background: var(--panel); color: #fff; font-size: 1.2rem;
  width: 44px; height: 44px; border-radius: 14px; cursor: pointer;
}

.field {
  width: 100%; border: 2px solid transparent; border-radius: 16px; padding: 14px 16px;
  font: inherit; font-weight: 700; color: #fff; background: var(--panel-2); outline: none; min-height: 52px;
}
.field:focus { border-color: var(--yellow); }
.field::placeholder { color: var(--muted); font-weight: 500; }
.code-field { text-align: center; letter-spacing: 0.35em; text-transform: uppercase; font-size: 1.4rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; border: 2px solid transparent; border-radius: 999px; padding: 10px 16px; font: inherit; font-weight: 700;
  color: #fff; background: var(--panel-2); cursor: pointer; min-height: 44px;
}
.chip[aria-pressed="true"] { background: var(--violet); border-color: var(--yellow); }

.stepper { display: flex; align-items: center; gap: 14px; }
.stepper b { font-size: 1.6rem; min-width: 2ch; text-align: center; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting > span { font-weight: 700; }
.switch { appearance: none; border: 0; width: 64px; height: 36px; border-radius: 999px; background: var(--panel-2); position: relative; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"]::after { transform: translateX(28px); }
select.field { appearance: none; width: auto; min-width: 120px; }

.name-row { display: flex; gap: 8px; }
.name-row .field { flex: 1; }

.players { display: flex; flex-direction: column; gap: 8px; }
.player { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px; padding: 10px 12px; font-weight: 700; }
.player .avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; color: #1b1038; flex: none; }
.player .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.off { opacity: 0.45; }
.tag { font-size: 0.75rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); }

.room-code { font-size: 3rem; font-weight: 900; letter-spacing: 0.25em; text-align: center; padding-left: 0.25em; color: var(--yellow); }

/* ---------- card 3D ---------- */
.card3d { perspective: 1200px; width: min(84vw, 330px); height: min(52dvh, 430px); margin: 0 auto; cursor: pointer; border: 0; background: none; padding: 0; color: inherit; font: inherit; display: block; }
.card3d .inner { position: relative; width: 100%; height: 100%; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); transform-style: preserve-3d; }
.card3d.flipped .inner { transform: rotateY(180deg); }
.card3d.instant .inner { transition: none; }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 22px; text-align: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), inset 0 0 0 4px rgba(255, 255, 255, 0.18);
}
.face.nome { background: linear-gradient(145deg, var(--violet), #4a2fd1); }
.face.nome::before { content: "?"; position: absolute; font-size: 12rem; font-weight: 900; color: rgba(255, 255, 255, 0.08); }
.face.nome .big { font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 900; word-break: break-word; position: relative; }
.face.nome small { color: #e5dcff; font-weight: 700; position: relative; }
.face.segredo { transform: rotateY(180deg); }
.face.segredo.civil { background: linear-gradient(145deg, var(--teal), #18b7a0); color: #06382f; }
.face.segredo.impostor { background: linear-gradient(145deg, var(--pink), #c4155a); color: #fff; }
.face .label { font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; opacity: 0.85; }
.face .word { font-size: clamp(2rem, 10vw, 3rem); font-weight: 900; line-height: 1.05; word-break: break-word; }
.face .skull { font-size: 3.4rem; }
.face .hint { background: rgba(0, 0, 0, 0.22); border-radius: 16px; padding: 12px 14px; font-weight: 700; }

.timer { font-size: 4rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; color: var(--yellow); }
.timer.low { color: var(--pink); }
.big-name { font-size: 2.2rem; font-weight: 900; color: var(--yellow); text-align: center; }

.vote-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vote { appearance: none; border: 3px solid transparent; border-radius: 18px; padding: 14px 10px; font: inherit; font-weight: 800; color: #fff; background: var(--panel-2); cursor: pointer; min-height: 64px; word-break: break-word; }
.vote[aria-pressed="true"] { border-color: var(--yellow); background: var(--violet); }
.vote small { display: block; font-weight: 600; color: var(--muted); }

.banner { border-radius: var(--radius); padding: 18px; text-align: center; font-weight: 900; font-size: 1.5rem; }
.banner.civis { background: linear-gradient(145deg, var(--teal), #18b7a0); color: #06382f; }
.banner.impostores { background: linear-gradient(145deg, var(--pink), #c4155a); }
.reveal-word { font-size: 2.4rem; font-weight: 900; color: var(--yellow); text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0;
  background: #fff; color: #1b1038; font-weight: 800; padding: 12px 18px; border-radius: 14px; pointer-events: none;
  transition: 0.25s; max-width: 90vw; text-align: center; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.dot.off { background: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .card3d .inner, .btn, #toast { transition: none; }
}
