/* ============================================================
   Мафия: Ночь города — mobile-first noir UI
   ============================================================ */
:root {
  --bg: #07090e;
  --bg-2: #0b0e15;
  --panel: #121722;
  --panel-2: #171e2c;
  --panel-3: #1d2535;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f1ece4;
  --text-2: #c9c2b7;
  --muted: #8b93a1;
  --muted-2: #646c79;
  --red: #e23b4e;
  --red-2: #ff5c6c;
  --red-deep: #861b2a;
  --gold: #d7b26c;
  --gold-2: #f1d79c;
  --green: #55d18c;
  --blue: #63b3ed;
  --purple: #c084fc;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(143, 29, 44, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 100%, rgba(42, 58, 91, 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--gold); text-decoration: none; }
img, svg { display: block; max-width: 100%; }
::selection { background: rgba(226, 59, 78, 0.35); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.13); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 10.5px; }
.gold { color: var(--gold); }
.red { color: var(--red-2); }
.green { color: var(--green); }
.display { font-family: var(--font-display); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.noscript {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: var(--bg); color: var(--text); z-index: 999; text-align: center;
}

/* ---------- layout ---------- */
.app {
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
}
@media (min-width: 700px) {
  .app {
    box-shadow: 0 0 0 1px rgba(255,255,255,.05), 0 40px 120px rgba(0,0,0,.7);
    background: linear-gradient(180deg, rgba(255,255,255,.012), transparent 30%);
  }
}
.screen { min-height: 100dvh; padding-bottom: calc(18px + var(--safe-bottom)); }
.screen-pad { padding: 0 16px; }
.safe-top { padding-top: max(10px, var(--safe-top)); }

/* ---------- typography ---------- */
h1, h2, h3, h4, p { margin: 0; }
h1, .h1 { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; }
h2, .h2 { font-family: var(--font-display); font-weight: 700; font-size: 27px; line-height: 1.1; }
h3, .h3 { font-weight: 700; font-size: 17px; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: 10px;
  font-weight: 800; color: var(--gold);
}
.title-lg { font-size: clamp(38px, 11vw, 52px); line-height: .95; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.section-title h2 { font-size: 26px; }
.section-title .link { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--panel-2);
  --btn-border: var(--line);
  --btn-text: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 17px; border-radius: 14px;
  background: var(--btn-bg); border: 1px solid var(--btn-border); color: var(--btn-text);
  font-weight: 700; font-size: 14px; letter-spacing: .01em;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease, border-color .15s;
  user-select: none; text-align: center;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .42; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn-primary {
  --btn-bg: linear-gradient(135deg, #f04a5c, #b32234);
  --btn-border: rgba(255, 120, 130, .25);
  box-shadow: 0 12px 30px rgba(190, 30, 50, .32), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-gold {
  --btn-bg: linear-gradient(135deg, #f0d79a, #c79b4c);
  --btn-border: rgba(255, 230, 170, .4);
  --btn-text: #23190b;
  box-shadow: 0 10px 26px rgba(197, 150, 70, .18);
}
.btn-ghost { --btn-bg: rgba(255,255,255,.035); --btn-border: var(--line-strong); }
.btn-soft { --btn-bg: rgba(255,255,255,.055); --btn-border: transparent; }
.btn-danger { --btn-bg: rgba(226,59,78,.13); --btn-border: rgba(226,59,78,.36); --btn-text: #ff9ba5; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 16px; border-radius: 16px; padding: 0 22px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 12px; border-radius: 11px; gap: 5px; }
.btn-xs { min-height: 28px; padding: 0 9px; font-size: 11px; border-radius: 9px; gap: 4px; }
.btn-icon { width: 44px; padding: 0; flex: 0 0 44px; border-radius: 13px; font-size: 18px; }
.btn-circle { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: 0 0 44px; }
.btn .spinner { width: 18px; height: 18px; }
.link-btn { color: var(--gold); font-weight: 700; font-size: 13px; padding: 4px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: rgba(255,255,255,.045); border: 1px solid var(--line);
  color: var(--text-2); font-size: 18px;
}
.icon-btn:active { transform: scale(.95); }

/* ---------- badges / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 99px; background: rgba(255,255,255,.055);
  border: 1px solid var(--line); color: var(--text-2); font-size: 10.5px; font-weight: 700;
  white-space: nowrap;
}
.chip-gold { background: rgba(215,178,108,.12); border-color: rgba(215,178,108,.28); color: var(--gold-2); }
.chip-red { background: rgba(226,59,78,.12); border-color: rgba(226,59,78,.28); color: #ff9ba5; }
.chip-green { background: rgba(85,209,140,.1); border-color: rgba(85,209,140,.22); color: #9debbd; }
.chip-blue { background: rgba(99,179,237,.1); border-color: rgba(99,179,237,.24); color: #a9d8f7; }
.chip-purple { background: rgba(192,132,252,.1); border-color: rgba(192,132,252,.26); color: #dfb9ff; }
.status-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
  border-radius: 99px; font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em;
}
.status-lobby { color: #9debbd; background: rgba(85,209,140,.1); border: 1px solid rgba(85,209,140,.22); }
.status-playing { color: #ffadb6; background: rgba(226,59,78,.12); border: 1px solid rgba(226,59,78,.25); }
.status-finished { color: #c7c1b7; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.count-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 9.5px; font-weight: 800;
  display: inline-grid; place-items: center;
}

/* ---------- avatars ---------- */
.avatar {
  --size: 48px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size);
  border-radius: 50%; position: relative; display: grid; place-items: center;
  background:
    radial-gradient(circle at 32% 24%, color-mix(in srgb, var(--a1) 88%, white 12%), var(--a1) 38%, var(--a2) 100%);
  box-shadow:
    inset 0 1px 1px rgba(255,255,255,.22),
    inset 0 -8px 18px rgba(0,0,0,.35),
    0 0 0 1.5px rgba(255,255,255,.16),
    0 5px 14px rgba(0,0,0,.25);
  overflow: hidden; font-size: calc(var(--size) * .48);
  line-height: 1; isolation: isolate;
}
.avatar::before {
  content: ""; position: absolute; inset: -20%;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.2), transparent 45%);
  pointer-events: none;
}
.avatar::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.13); pointer-events: none;
}
.avatar .av-icon { filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); transform: translateY(-1%); }
.avatar.av-xs { --size: 24px; }
.avatar.av-sm { --size: 32px; }
.avatar.av-md { --size: 42px; }
.avatar.av-lg { --size: 58px; }
.avatar.av-xl { --size: 84px; }
.avatar.av-2xl { --size: 108px; }
.avatar.av-hero { --size: 92px; }
.avatar-system {
  background: radial-gradient(circle at 35% 25%, #2a3346, #0d1119);
  color: var(--gold); font-family: var(--font-display); font-size: calc(var(--size) * .45);
}
.avatar-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.avatar-wrap .online-dot {
  position: absolute; right: 0; bottom: 0; width: 11px; height: 11px;
  border-radius: 50%; background: var(--green); border: 2px solid var(--bg);
}
.avatar-wrap .offline-dot {
  position: absolute; right: 0; bottom: 0; width: 11px; height: 11px;
  border-radius: 50%; background: #5c6370; border: 2px solid var(--bg);
}
.dead-avatar { filter: grayscale(1) brightness(.6); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label {
  font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute; left: 14px; width: 20px; text-align: center;
  color: var(--muted); font-size: 15px; pointer-events: none;
}
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 0 14px;
  border-radius: 14px; border: 1px solid #2a3242; background: #0d1119;
  color: var(--text); font-size: 16px; outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input::placeholder, .textarea::placeholder { color: #5c6472; }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(215,178,108,.55);
  box-shadow: 0 0 0 3px rgba(215,178,108,.09);
  background: #0f1420;
}
.input-wrap .input { padding-left: 44px; }
.input-wrap .input.has-right { padding-right: 46px; }
.input-right {
  position: absolute; right: 8px; width: 36px; height: 36px;
  display: grid; place-items: center; border-radius: 10px; color: var(--muted);
}
.textarea { padding: 12px 14px; min-height: 90px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.field-error { color: #ff9ba5; font-size: 12px; min-height: 16px; }
.field-hint { color: var(--muted-2); font-size: 11.5px; line-height: 1.35; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-copy { display: flex; flex-direction: column; gap: 2px; }
.toggle-copy strong { font-size: 13.5px; }
.toggle-copy span { font-size: 11px; color: var(--muted); }
.toggle { position: relative; width: 46px; height: 28px; flex: 0 0 46px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  position: absolute; inset: 0; border-radius: 99px; background: #2a3140;
  transition: background .2s; border: 1px solid rgba(255,255,255,.08);
}
.toggle .track::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  top: 2px; left: 2px; background: #aeb5c1; transition: transform .2s, background .2s;
}
.toggle input:checked + .track { background: rgba(226,59,78,.9); }
.toggle input:checked + .track::after { transform: translateX(18px); background: #fff; }

/* ---------- auth ---------- */
.auth-screen {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(18px + var(--safe-top)) 20px calc(22px + var(--safe-bottom));
  position: relative; overflow: hidden;
}
.auth-bg { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.auth-bg::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 420px at 72% 13%, rgba(190, 35, 57, .25), transparent 65%),
    radial-gradient(500px 400px at 10% 90%, rgba(51, 70, 105, .22), transparent 70%),
    linear-gradient(180deg, #0a0d14 0%, #07090e 60%, #05070b 100%);
}
.auth-bg::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3%;
  height: 46%; background: url("assets/skyline.svg") bottom center / cover no-repeat;
  opacity: .55; mask-image: linear-gradient(to top, #000 35%, transparent 100%);
}
.auth-fog {
  position: absolute; left: -20%; right: -20%; bottom: 15%; height: 200px;
  background: radial-gradient(ellipse at 50% 60%, rgba(180, 195, 225, .09), transparent 65%);
  filter: blur(18px); animation: fog 16s ease-in-out infinite alternate;
}
.dust { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.dust i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: rgba(241, 215, 156, .45); animation: drift linear infinite;
}
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand img { width: 36px; height: 36px; }
.auth-brand span { font-size: 11px; font-weight: 800; letter-spacing: .17em; color: var(--gold); }
.auth-language { font-size: 11px; color: var(--muted); padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; }
.auth-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 12px; min-height: 280px; }
.auth-logo { width: 92px; height: 92px; margin-bottom: 18px; filter: drop-shadow(0 18px 26px rgba(0,0,0,.55)); animation: logoIn .8s cubic-bezier(.2,.8,.2,1) both; }
.auth-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(54px, 16vw, 78px); line-height: .82; letter-spacing: .015em; margin: 0; text-shadow: 0 12px 40px rgba(0,0,0,.6); }
.auth-title em { color: var(--red); font-style: normal; }
.auth-sub { margin-top: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: .32em; font-size: 10.5px; font-weight: 800; }
.auth-tagline { margin-top: 10px; color: var(--muted); max-width: 290px; font-size: 12.5px; line-height: 1.45; }
.auth-card {
  position: relative; z-index: 2; background: linear-gradient(180deg, rgba(23,30,44,.94), rgba(13,17,25,.96));
  border: 1px solid rgba(255,255,255,.09); border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.06);
  padding: 16px; backdrop-filter: blur(16px);
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #0a0e15; border-radius: 13px; margin-bottom: 14px; }
.auth-tab { min-height: 38px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 12.5px; }
.auth-tab.active { background: var(--panel-3); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.auth-form { display: flex; flex-direction: column; gap: 11px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.auth-check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.auth-check input { accent-color: var(--red); width: 14px; height: 14px; }
.auth-footer { margin-top: 14px; text-align: center; font-size: 10.5px; color: var(--muted-2); line-height: 1.5; }
.auth-footer a { color: var(--muted); text-decoration: underline; text-decoration-color: rgba(255,255,255,.18); text-underline-offset: 2px; }
.auth-error {
  min-height: 0; color: #ff9ba5; font-size: 12px; background: rgba(226,59,78,.09);
  border: 1px solid rgba(226,59,78,.2); border-radius: 10px; padding: 0 10px;
  max-height: 0; overflow: hidden; transition: max-height .2s, padding .2s;
}
.auth-error.show { max-height: 80px; padding: 8px 10px; }
.auth-avatar-label { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.auth-avatars { display: flex; gap: 7px; overflow-x: auto; padding: 3px 0 4px; scrollbar-width: none; }
.auth-avatars::-webkit-scrollbar { display: none; }
.auth-avatars .avatar-choice { flex: 0 0 auto; padding: 2px; border-radius: 50%; border: 2px solid transparent; }
.auth-avatars .avatar-choice.selected { border-color: var(--gold); }

/* ---------- home ---------- */
.home-screen { padding-bottom: calc(30px + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, var(--safe-top)) 16px 10px;
  background: linear-gradient(180deg, rgba(7,9,14,.96) 55%, rgba(7,9,14,.72) 100%);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand img { width: 32px; height: 32px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-copy strong { font-family: var(--font-display); font-size: 20px; letter-spacing: .08em; }
.brand-copy span { font-size: 7.5px; color: var(--gold); letter-spacing: .24em; font-weight: 800; margin-top: 2px; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(85,209,140,.12); }
.conn-dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(226,59,78,.12); animation: blink 1.2s infinite; }
.profile-pill {
  display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 99px;
  max-width: 174px;
}
.profile-pill .who { min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.profile-pill .who strong { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-pill .who span { font-size: 9px; color: var(--muted); margin-top: 2px; }

.home-hero {
  position: relative; margin: 14px 16px 0; padding: 22px 18px 18px; border-radius: 26px;
  overflow: hidden; border: 1px solid rgba(255,255,255,.07);
  background:
    radial-gradient(280px 180px at 85% 5%, rgba(226,59,78,.25), transparent 70%),
    radial-gradient(380px 280px at 0% 100%, rgba(45,62,96,.35), transparent 70%),
    linear-gradient(160deg, #171e2c, #0c1018 60%);
  box-shadow: 0 22px 50px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.05);
}
.home-hero::before {
  content: ""; position: absolute; right: -26px; top: -34px; width: 150px; height: 150px;
  border-radius: 50%; border: 1px solid rgba(215,178,108,.18);
  box-shadow: 0 0 0 22px rgba(215,178,108,.035), 0 0 0 44px rgba(215,178,108,.02);
}
.home-hero::after {
  content: ""; position: absolute; right: -10px; bottom: -20px; width: 190px; height: 120px;
  background: url("assets/skyline.svg") bottom right / contain no-repeat; opacity: .2;
  pointer-events: none;
}
.hero-kicker { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.hero-kicker .line { width: 22px; height: 1px; background: var(--gold); opacity: .7; }
.home-hero h1 { font-size: clamp(30px, 8.8vw, 39px); line-height: 1.02; max-width: 320px; position: relative; z-index: 1; }
.home-hero h1 em { color: var(--gold-2); font-style: italic; }
.home-hero p { margin-top: 8px; color: var(--text-2); font-size: 12.5px; max-width: 300px; position: relative; z-index: 1; }
.home-hero .hero-stats { display: flex; gap: 14px; margin-top: 15px; position: relative; z-index: 1; }
.hero-stat { display: flex; flex-direction: column; gap: 1px; }
.hero-stat strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1; }
.hero-stat span { font-size: 8.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 800; }
.hero-stat + .hero-stat { padding-left: 14px; border-left: 1px solid var(--line); }
.quick-cta {
  width: 100%; margin-top: 18px; min-height: 62px; border-radius: 18px;
  display: flex; align-items: center; gap: 13px; padding: 10px 14px 10px 12px;
  background: linear-gradient(135deg, #ef4a5c, #a81f31 80%);
  box-shadow: 0 16px 34px rgba(190, 30, 50, .34), inset 0 1px 0 rgba(255,255,255,.2);
  color: #fff; position: relative; z-index: 2; text-align: left;
  transition: transform .15s, filter .15s;
}
.quick-cta:active { transform: scale(.985); }
.quick-cta .q-icon {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: rgba(0,0,0,.18); font-size: 21px; flex: 0 0 42px;
}
.quick-cta .q-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quick-cta strong { font-size: 15px; }
.quick-cta span { font-size: 10.5px; opacity: .8; }
.quick-cta .q-arrow { margin-left: auto; font-size: 20px; opacity: .7; }
.hero-secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; position: relative; z-index: 2; }
.hero-secondary .btn { min-height: 42px; font-size: 12.5px; border-radius: 13px; background: rgba(9,12,18,.55); backdrop-filter: blur(8px); }

.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 16px 0; }
.stat-card {
  background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 15px;
  padding: 10px 11px; display: flex; flex-direction: column; gap: 2px;
}
.stat-card strong { font-family: var(--font-display); font-size: 24px; line-height: 1; }
.stat-card span { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 800; }
.stat-card .sub { font-size: 9px; color: var(--muted-2); letter-spacing: 0; text-transform: none; }

.home-section { margin: 22px 16px 0; }
.room-list { display: flex; flex-direction: column; gap: 9px; }
.room-card {
  width: 100%; display: flex; align-items: center; gap: 11px; text-align: left;
  padding: 11px 12px; border-radius: 17px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.02));
  transition: border-color .15s, transform .15s, background .15s;
}
.room-card:active { transform: scale(.99); }
.room-card.joinable:hover { border-color: rgba(215,178,108,.28); background: rgba(255,255,255,.055); }
.room-card .room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.room-card .room-name { font-size: 13.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card .room-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; }
.room-card .room-sub .dot { width: 2px; height: 2px; border-radius: 50%; background: var(--muted-2); }
.room-card .room-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: 0 0 auto; }
.room-card .players-count { font-size: 10px; color: var(--muted); font-weight: 700; }
.empty-state {
  text-align: center; padding: 26px 18px; border: 1px dashed rgba(255,255,255,.12);
  border-radius: 18px; color: var(--muted); font-size: 12px; line-height: 1.5;
}
.empty-state .empty-icon { font-size: 28px; margin-bottom: 7px; opacity: .8; }
.leader-list { display: flex; flex-direction: column; gap: 4px; }
.leader-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 12px; }
.leader-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.leader-rank { width: 17px; font-family: var(--font-display); font-size: 16px; color: var(--muted); text-align: center; }
.leader-row .avatar { --size: 30px; }
.leader-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-size: 10.5px; color: var(--gold); font-weight: 800; }
.home-footer { display: flex; justify-content: center; gap: 18px; margin: 26px 16px 0; padding-top: 16px; border-top: 1px solid var(--line); }
.home-footer button, .home-footer a { color: var(--muted); font-size: 11px; font-weight: 600; }
.home-fab { position: fixed; right: max(18px, calc((100vw - 560px)/2 + 18px)); bottom: calc(18px + var(--safe-bottom)); z-index: 25; }

/* ---------- lobby ---------- */
.lobby-screen { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; }
.lobby-head { flex: 0 0 auto; padding: max(12px, var(--safe-top)) 16px 12px; border-bottom: 1px solid var(--line); background: rgba(9,12,18,.72); backdrop-filter: blur(14px); }
.lobby-head .row-between { align-items: flex-start; }
.lobby-title { font-family: var(--font-display); font-size: 28px; line-height: 1.05; margin-top: 4px; }
.lobby-code-row { display: flex; align-items: center; gap: 7px; margin-top: 8px; flex-wrap: wrap; }
.code-box {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 10px;
  background: rgba(215,178,108,.08); border: 1px solid rgba(215,178,108,.22);
  color: var(--gold-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; font-weight: 800; letter-spacing: .18em;
}
.lobby-content { flex: 1 1 auto; padding: 14px 16px 8px; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lobby-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.players-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
@media (min-width: 360px) { .players-grid { grid-template-columns: repeat(4, 1fr); } }
.lobby-player {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 4px 7px; border-radius: 15px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  min-width: 0; transition: border-color .15s, transform .15s;
}
.lobby-player .avatar { --size: 52px; }
.lobby-player:active { transform: scale(.985); }
.lobby-player.you { border-color: rgba(215,178,108,.34); background: rgba(215,178,108,.055); }
.lobby-player.empty {
  justify-content: center; border-style: dashed; background: transparent; min-height: 88px;
  color: var(--muted-2); font-size: 18px;
}
.lobby-player .lp-name { width: 100%; text-align: center; font-size: 10.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-player .lp-status { min-height: 15px; display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 9px; color: var(--muted); }
.lobby-player .lp-status.ready { color: var(--green); }
.lobby-player .lp-status.no { color: var(--muted-2); }
.lobby-player .host-crown { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); font-size: 15px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.lobby-player .ready-tick {
  position: absolute; right: 6px; top: 6px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--green); color: #062313; font-size: 10px; font-weight: 900;
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(85,209,140,.3);
}
.lobby-player .kick-dot {
  position: absolute; right: 5px; top: 5px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.45); border: 1px solid var(--line);
  color: var(--muted); font-size: 10px;
}
.ready-progress { height: 4px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; margin: 12px 0 2px; }
.ready-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #f5dda6); transition: width .35s ease; }
.lobby-settings { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.lobby-chat-wrap { flex: 0 0 270px; min-height: 0; margin: 0 16px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; overflow: hidden; background: rgba(10,13,20,.72); display: flex; }
.lobby-chat-wrap > .chat-panel { flex: 1; min-height: 0; }
.lobby-actions {
  position: relative; flex: 0 0 auto; z-index: 20; display: flex; gap: 8px;
  padding: 9px 16px calc(9px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(7,9,14,.82), rgba(7,9,14,.99));
  border-top: 1px solid var(--line);
}
.lobby-actions .btn-primary { flex: 1; }
.lobby-hint { flex: 0 0 auto; text-align: center; font-size: 10px; color: var(--muted); padding: 4px 16px calc(5px + var(--safe-bottom)); background: #07090e; }

/* ---------- game ---------- */
.game-screen {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  position: relative; background: var(--bg);
  transition: background .5s;
}
.game-screen.phase-night {
  background:
    radial-gradient(600px 380px at 50% 0%, rgba(50, 70, 118, .2), transparent 70%),
    linear-gradient(180deg, #080b13, #06080d);
}
.game-screen.phase-day {
  background:
    radial-gradient(600px 380px at 50% 0%, rgba(122, 92, 35, .18), transparent 70%),
    linear-gradient(180deg, #0c0e12, #07090d);
}
.game-screen.phase-vote {
  background:
    radial-gradient(600px 380px at 50% 0%, rgba(150, 35, 50, .18), transparent 70%),
    linear-gradient(180deg, #0d0a0e, #07090d);
}
.game-screen.phase-over {
  background:
    radial-gradient(600px 380px at 50% 0%, rgba(215, 178, 108, .12), transparent 70%),
    linear-gradient(180deg, #0d0d10, #07090d);
}
.game-head { flex: 0 0 auto; padding: max(8px, var(--safe-top)) 14px 8px; border-bottom: 1px solid var(--line); background: rgba(7,9,14,.6); backdrop-filter: blur(12px); }
.game-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.game-room-name { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.game-room-name strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.game-room-name span { font-size: 9px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.game-top-actions { display: flex; gap: 5px; }
.phase-strip { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.phase-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.phase-kicker { font-size: 9px; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); font-weight: 800; }
.phase-title { font-family: var(--font-display); font-size: 25px; line-height: 1; font-weight: 700; }
.phase-desc { font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-ring {
  --p: 100; --ring: var(--gold); --size: 48px;
  width: var(--size); height: var(--size); flex: 0 0 var(--size); border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), rgba(255,255,255,.08) 0);
  display: grid; place-items: center; position: relative;
  box-shadow: 0 0 18px rgba(215,178,108,.08);
}
.timer-ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #0b0f17; }
.timer-ring .timer-text { position: relative; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.timer-ring.urgent { --ring: var(--red); animation: timerPulse 1s infinite; }
.role-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 99px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 10px; color: var(--text-2);
  font-weight: 700; max-width: 145px;
}
.role-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-zone {
  flex: 0 1 auto; min-height: 0; max-height: 40dvh; overflow-y: auto;
  padding: 10px 10px 8px; position: relative;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, rgba(29, 45, 39, .28), transparent 70%),
    radial-gradient(ellipse 70% 45% at 50% 50%, rgba(255,255,255,.025), transparent 70%);
}
.table-zone::before {
  content: "NIGHT CITY"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: 44px; letter-spacing: .14em; color: rgba(255,255,255,.022);
  pointer-events: none; white-space: nowrap;
}
.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; position: relative; z-index: 1; }
@media (max-width: 370px) { .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.player-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 0; padding: 7px 3px 6px; border-radius: 14px; border: 1px solid transparent;
  background: rgba(255,255,255,.028); transition: border-color .18s, background .18s, transform .15s, opacity .2s;
}
.player-card:active { transform: scale(.97); }
.player-card.you { border-color: rgba(215,178,108,.35); background: rgba(215,178,108,.055); }
.player-card.mate { border-color: rgba(226,59,78,.25); background: rgba(226,59,78,.05); }
.player-card.dead { opacity: .52; filter: grayscale(.9); }
.player-card.dead .pc-name { text-decoration: line-through; text-decoration-color: rgba(255,255,255,.25); }
.player-card.selected { border-color: var(--red); background: rgba(226,59,78,.12); box-shadow: 0 0 0 2px rgba(226,59,78,.15), 0 0 22px rgba(226,59,78,.18); }
.player-card.valid-target { border-color: rgba(215,178,108,.28); background: rgba(215,178,108,.05); }
.player-card.valid-target .avatar { box-shadow: 0 0 0 2px rgba(215,178,108,.45), 0 0 18px rgba(215,178,108,.15); }
.player-card.invalid-target { opacity: .38; }
.player-card .avatar { --size: 44px; }
.player-card.you .avatar { box-shadow: 0 0 0 2px rgba(215,178,108,.6), 0 0 20px rgba(215,178,108,.12); }
@media (max-height: 700px) { .player-card .avatar { --size: 40px; } .player-card { padding: 5px 3px; } }
.pc-name { width: 100%; font-size: 10px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.pc-status { min-height: 12px; max-width: 100%; display: flex; align-items: center; justify-content: center; gap: 2px; font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-status b { font-weight: 800; }
.pc-badge {
  position: absolute; top: 3px; right: 3px; min-width: 14px; height: 14px; padding: 0 3px;
  display: grid; place-items: center; border-radius: 7px; background: rgba(0,0,0,.55);
  font-size: 8px; line-height: 1; border: 1px solid rgba(255,255,255,.08);
}
.pc-badge.crown { color: var(--gold); }
.pc-badge.drunk { background: rgba(192,132,252,.24); border-color: rgba(192,132,252,.35); }
.pc-badge.mate { background: rgba(226,59,78,.3); border-color: rgba(226,59,78,.4); }
.pc-badge.offline { color: var(--muted); }
.role-tag {
  position: absolute; left: 2px; right: 2px; bottom: 2px; padding: 1px 3px; border-radius: 5px;
  background: rgba(0,0,0,.72); font-size: 7.5px; color: var(--text-2); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700;
}
.pc-voted {
  position: absolute; left: 4px; top: 4px; width: 14px; height: 14px; border-radius: 50%;
  background: rgba(226,59,78,.9); color: #fff; font-size: 8px; display: grid; place-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

.action-bar {
  flex: 0 0 auto; min-height: 64px; display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18,23,34,.92), rgba(10,13,20,.96));
}
.action-icon {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(226,59,78,.1); border: 1px solid rgba(226,59,78,.2); font-size: 18px;
}
.action-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.action-copy strong { font-size: 11.5px; line-height: 1.2; }
.action-copy span { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-buttons { display: flex; gap: 5px; flex: 0 0 auto; }
.action-buttons .btn { min-height: 38px; font-size: 11.5px; padding: 0 12px; border-radius: 11px; }
.mafia-votes {
  display: flex; gap: 5px; overflow-x: auto; padding: 0 14px 6px; font-size: 9.5px; color: var(--muted);
  background: rgba(10,13,20,.96); scrollbar-width: none;
}
.mafia-votes::-webkit-scrollbar { display: none; }
.mafia-votes .mv { white-space: nowrap; padding: 3px 7px; border-radius: 99px; background: rgba(226,59,78,.1); border: 1px solid rgba(226,59,78,.18); color: #ffb4bc; }
.vote-tally { display: flex; gap: 3px; align-items: center; }
.vote-tally i { width: 4px; height: 10px; border-radius: 2px; background: rgba(255,255,255,.15); }
.vote-tally i.on { background: var(--red); }

/* ---------- chat ---------- */
.chat-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: #080b11; border-top: 1px solid var(--line); }
.chat-panel.in-lobby { flex: 1 1 auto; min-height: 0; }
.chat-head { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; padding: 7px 10px 0; }
.chat-tabs { display: flex; gap: 3px; overflow-x: auto; flex: 1; scrollbar-width: none; padding-bottom: 6px; }
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tab {
  position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 28px;
  padding: 0 9px; border-radius: 8px; font-size: 10.5px; font-weight: 800; color: var(--muted);
  white-space: nowrap; border: 1px solid transparent;
}
.chat-tab:focus, .chat-tab:focus-visible { outline: none; }
.chat-tab.active { color: var(--text); background: rgba(255,255,255,.06); border-color: var(--line); }
.chat-tab .count-badge { margin-left: 2px; }
.chat-tab.mafia.active { color: #ffb4bc; background: rgba(226,59,78,.1); border-color: rgba(226,59,78,.18); }
.chat-tab.dead.active { color: #c9c2b7; }
.chat-tab.private.active { color: var(--gold-2); }
.chat-mini { width: 34px; height: 28px; display: grid; place-items: center; color: var(--muted); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 12px 10px; display: flex; flex-direction: column; gap: 7px; scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; color: var(--muted-2); font-size: 11px; padding: 16px; line-height: 1.5; }
.chat-empty .big { font-size: 24px; margin-bottom: 5px; opacity: .7; }
.msg { display: flex; gap: 7px; align-items: flex-end; max-width: 100%; }
.msg .avatar { --size: 27px; margin-bottom: 1px; }
.msg-body { min-width: 0; max-width: 84%; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.msg-meta { display: flex; align-items: baseline; gap: 5px; padding: 0 3px; }
.msg-nick { font-size: 9.5px; font-weight: 800; color: var(--gold); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-time { font-size: 8px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.msg-text {
  padding: 7px 10px; border-radius: 13px 13px 13px 4px; background: #171e2b;
  border: 1px solid rgba(255,255,255,.045); font-size: 13px; line-height: 1.4;
  color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.own { flex-direction: row-reverse; }
.msg.own .msg-body { align-items: flex-end; }
.msg.own .msg-meta { flex-direction: row-reverse; }
.msg.own .msg-text { border-radius: 13px 13px 4px 13px; background: linear-gradient(135deg, #5e1f2b, #3f1720); border-color: rgba(255,120,130,.12); }
.msg.own .msg-nick { color: #ffbcc2; }
.msg.private .msg-text { background: rgba(215,178,108,.09); border-color: rgba(215,178,108,.22); color: #f2e1bc; }
.msg.drunk .msg-text { background: linear-gradient(135deg, #3c2a52, #261b36); border-color: rgba(192,132,252,.28); animation: drunkWobble 2.4s ease-in-out infinite; }
.msg.drunk .msg-text::after { content: " 🍺"; font-size: 11px; }
.msg-system {
  align-self: center; text-align: center; max-width: 92%; margin: 3px 0;
  font-size: 10px; line-height: 1.4; color: var(--muted); padding: 4px 8px;
  background: rgba(255,255,255,.025); border-radius: 8px;
}
.msg-system.death { color: #ff9ba5; background: rgba(226,59,78,.07); }
.msg-system.night { color: #9db8e8; background: rgba(80,110,170,.08); }
.msg-system.day { color: #e4c98d; background: rgba(215,178,108,.07); }
.msg-system.vote { color: #ffb4bc; }
.msg-system.drink { color: #d7b8ff; background: rgba(192,132,252,.08); }
.msg-system.end { color: var(--gold-2); background: rgba(215,178,108,.1); font-weight: 700; }
.msg-system.start { color: var(--text-2); }
.typing-line { flex: 0 0 auto; min-height: 15px; padding: 0 14px 2px; font-size: 9.5px; color: var(--muted); font-style: italic; }
.chat-composer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 6px 9px calc(7px + var(--safe-bottom)); border-top: 1px solid var(--line);
  background: #0b0f17;
}
.chat-input {
  flex: 1; min-width: 0; height: 42px; padding: 0 13px; border-radius: 21px;
  border: 1px solid #283040; background: #111723; color: var(--text);
  font-size: 16px; outline: none;
}
.chat-input:focus { border-color: rgba(215,178,108,.35); background: #131a28; }
.chat-input::placeholder { color: #5c6472; font-size: 12px; }
.chat-send {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #ef4a5c, #b32234); color: #fff; font-size: 17px;
  box-shadow: 0 6px 16px rgba(190,30,50,.28);
}
.chat-send:disabled { opacity: .4; }
.chat-locked {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px; justify-content: center;
  min-height: 54px; padding: 6px 12px calc(7px + var(--safe-bottom)); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 10.5px; background: #0b0f17;
}
.chat-locked .lock-icon { font-size: 14px; }

/* ---------- modal / sheet ---------- */
.modal-root:empty { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(3, 5, 9, .76);
  backdrop-filter: blur(8px); animation: fadeIn .2s ease both;
}
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: linear-gradient(180deg, #161d2b, #0d1119 60%);
  border: 1px solid rgba(255,255,255,.1); border-bottom: 0;
  border-radius: 26px 26px 0 0; padding: 10px 18px calc(18px + var(--safe-bottom));
  box-shadow: 0 -20px 70px rgba(0,0,0,.55);
  animation: sheetUp .3s cubic-bezier(.2,.8,.2,1) both; overscroll-behavior: contain;
}
@media (min-width: 700px) {
  .modal { align-items: center; padding: 22px; }
  .sheet { border-radius: 26px; border-bottom: 1px solid rgba(255,255,255,.1); max-height: 88dvh; animation: modalIn .25s ease both; }
}
.sheet-handle { width: 38px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.16); margin: 2px auto 12px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-title { font-family: var(--font-display); font-size: 28px; line-height: 1.05; }
.sheet-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.sheet-close { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.055); color: var(--muted); font-size: 16px; flex: 0 0 32px; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.modal-note { font-size: 10px; color: var(--muted-2); line-height: 1.45; text-align: center; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.divider-text { display: flex; align-items: center; gap: 8px; color: var(--muted-2); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* avatar picker */
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
@media (max-width: 370px) { .avatar-grid { grid-template-columns: repeat(5, 1fr); } }
.avatar-choice {
  position: relative; padding: 3px; border-radius: 50%; border: 2px solid transparent;
  display: grid; place-items: center; transition: border-color .15s, transform .15s;
}
.avatar-choice:active { transform: scale(.94); }
.avatar-choice.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215,178,108,.1); }
.avatar-choice .avatar { --size: 43px; }
.avatar-choice .pick-name { display: none; }

/* choice cards (create room) */
.choice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.choice {
  min-height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.035); color: var(--muted); font-size: 11px; font-weight: 700;
}
.choice.active { border-color: rgba(215,178,108,.4); background: rgba(215,178,108,.1); color: var(--gold-2); }
.stepper { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 0; }
.stepper .stepper-value { font-family: var(--font-display); font-size: 30px; min-width: 52px; text-align: center; }
.stepper .icon-btn { width: 36px; height: 36px; }

/* role / rules */
.role-modal-icon {
  width: 92px; height: 92px; margin: 2px auto 4px; border-radius: 28px; display: grid; place-items: center;
  font-size: 46px; background: radial-gradient(circle at 35% 25%, rgba(255,255,255,.12), rgba(0,0,0,.15)), #1a2232;
  border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.role-modal-name { text-align: center; font-family: var(--font-display); font-size: 34px; line-height: 1; }
.role-modal-team { text-align: center; margin: 5px 0 10px; }
.role-modal-desc { color: var(--text-2); font-size: 12.5px; line-height: 1.5; text-align: center; }
.role-goal {
  margin-top: 12px; padding: 10px 12px; border-radius: 13px; background: rgba(215,178,108,.07);
  border: 1px solid rgba(215,178,108,.18); font-size: 11.5px; color: var(--gold-2); line-height: 1.45;
}
.role-goal strong { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin-bottom: 2px; }
.mates-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.mate-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(226,59,78,.06); border: 1px solid rgba(226,59,78,.14); }
.mate-row .avatar { --size: 28px; }
.mate-row .name { font-size: 12px; font-weight: 700; }
.mate-row .status { margin-left: auto; font-size: 9px; color: var(--muted); }
.rules-section h3 { margin: 16px 0 7px; font-family: var(--font-display); font-size: 24px; }
.rule-role { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rule-role:last-child { border-bottom: 0; }
.rule-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.05); font-size: 18px; }
.rule-copy { min-width: 0; }
.rule-copy strong { font-size: 12px; }
.rule-copy p { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.flow-list { display: flex; flex-direction: column; gap: 8px; }
.flow-step { display: flex; gap: 9px; font-size: 11px; color: var(--text-2); line-height: 1.45; }
.flow-step b { color: var(--gold); }
.flow-num { width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; display: grid; place-items: center; background: rgba(215,178,108,.1); color: var(--gold); font-size: 9px; font-weight: 800; }

/* player sheet */
.player-sheet-head { display: flex; align-items: center; gap: 12px; }
.player-sheet-head .avatar { --size: 64px; }
.player-sheet-head .who { min-width: 0; }
.player-sheet-head .who h3 { font-size: 20px; font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sheet-head .who p { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.player-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 14px; }
.player-sheet-actions .btn { min-height: 44px; font-size: 12px; }
.player-sheet-actions .full { grid-column: 1 / -1; }

/* result */
.result-screen {
  position: fixed; inset: 0; z-index: 90; overflow-y: auto;
  background:
    radial-gradient(700px 520px at 50% 0%, rgba(215,178,108,.16), transparent 65%),
    radial-gradient(500px 400px at 50% 100%, rgba(143,29,44,.18), transparent 70%),
    #07090e;
  padding: max(24px, var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  animation: fadeIn .35s ease both;
}
.result-inner { max-width: 520px; margin: 0 auto; }
.result-emblem {
  width: 92px; height: 92px; margin: 18px auto 8px; border-radius: 50%; display: grid; place-items: center;
  font-size: 44px; background: radial-gradient(circle at 35% 25%, rgba(255,255,255,.15), rgba(0,0,0,.2)), #1a2232;
  border: 1px solid rgba(215,178,108,.3); box-shadow: 0 0 60px rgba(215,178,108,.12);
  animation: resultPop .5s cubic-bezier(.2,.8,.2,1) both;
}
.result-kicker { text-align: center; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.result-title { text-align: center; font-family: var(--font-display); font-size: 42px; line-height: .95; margin-top: 3px; }
.result-sub { text-align: center; color: var(--text-2); font-size: 12.5px; margin: 7px auto 0; max-width: 340px; line-height: 1.45; }
.result-you {
  margin: 18px 0 12px; padding: 12px 14px; border-radius: 15px; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.045); border: 1px solid var(--line);
}
.result-you.win { background: rgba(85,209,140,.08); border-color: rgba(85,209,140,.22); }
.result-you.lose { background: rgba(226,59,78,.07); border-color: rgba(226,59,78,.18); }
.result-you .big { font-size: 22px; }
.result-you .copy { flex: 1; min-width: 0; }
.result-you .copy strong { display: block; font-size: 12px; }
.result-you .copy span { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.result-roles { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.result-role-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.025); }
.result-role-row .avatar { --size: 28px; }
.result-role-row .name { flex: 1; min-width: 0; font-size: 11.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-role-row .role { font-size: 9.5px; color: var(--muted); }
.result-role-row.dead { opacity: .65; }
.result-role-row .win-tag { font-size: 8px; color: var(--green); border: 1px solid rgba(85,209,140,.25); padding: 2px 5px; border-radius: 99px; }
.result-actions { display: flex; gap: 8px; margin-top: 16px; }
.result-actions .btn { flex: 1; }
.result-share { margin-top: 12px; text-align: center; }

/* profile */
.profile-screen { padding: max(12px, var(--safe-top)) 16px calc(24px + var(--safe-bottom)); }
.profile-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.profile-hero { text-align: center; padding: 10px 0 16px; }
.profile-hero .avatar { --size: 96px; margin: 0 auto 10px; }
.profile-hero h1 { font-family: var(--font-display); font-size: 34px; line-height: 1; }
.profile-hero p { color: var(--muted); font-size: 11px; margin-top: 4px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0; }
.profile-stats .stat-card { padding: 9px 7px; text-align: center; }
.profile-stats .stat-card strong { font-size: 21px; }
.profile-section { margin-top: 18px; }
.profile-section h2 { font-size: 24px; margin-bottom: 8px; }
.danger-zone { margin-top: 24px; padding-top: 14px; border-top: 1px solid rgba(226,59,78,.15); }
.profile-version { text-align: center; color: var(--muted-2); font-size: 9.5px; margin-top: 18px; }

/* toasts / connection / overlays */
.toast-root {
  position: fixed; left: 50%; top: max(10px, var(--safe-top)); transform: translateX(-50%);
  z-index: 300; width: min(92vw, 460px); display: flex; flex-direction: column; gap: 7px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 13px;
  background: rgba(23,30,44,.96); border: 1px solid var(--line-strong);
  box-shadow: 0 14px 40px rgba(0,0,0,.45); font-size: 11.5px; line-height: 1.4;
  animation: toastIn .25s ease both; backdrop-filter: blur(12px);
}
.toast.error { border-color: rgba(226,59,78,.35); background: rgba(46,17,24,.97); }
.toast.ok { border-color: rgba(85,209,140,.28); }
.toast .ti { font-size: 14px; line-height: 1.1; }
.toast .tx { flex: 1; }
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 250;
  padding: max(8px, var(--safe-top)) 14px 8px; text-align: center;
  background: rgba(146, 42, 25, .96); color: #ffe5d9; font-size: 11px; font-weight: 700;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
}
.conn-banner.ok { background: rgba(24, 104, 66, .96); }
.phase-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(4,6,10,.9); backdrop-filter: blur(10px);
  animation: fadeIn .25s ease both; text-align: center; padding: 24px;
}
.phase-overlay .po-icon { font-size: 54px; margin-bottom: 12px; animation: floatY 2.2s ease-in-out infinite; }
.phase-overlay .po-kicker { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); font-weight: 800; }
.phase-overlay .po-title { font-family: var(--font-display); font-size: 48px; line-height: 1; margin-top: 4px; }
.phase-overlay .po-sub { color: var(--muted); font-size: 12px; margin-top: 8px; max-width: 280px; }
.phase-overlay.hide { animation: fadeOut .3s ease both; }
.drunk-fx { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; display: none; }
body.is-drunk .drunk-fx { display: block; }
.drunk-fx .bubble {
  position: absolute; bottom: -30px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), rgba(215,178,108,.08));
  border: 1px solid rgba(255,255,255,.18); animation: bubbleUp linear infinite;
}

/* misc */
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.22);
  border-top-color: #fff; animation: spin .7s linear infinite; display: inline-block;
}
.spinner.dark { border-color: rgba(0,0,0,.2); border-top-color: #23190b; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 5px 0; }
.kv span { color: var(--muted); }
.kv strong { font-weight: 700; }
.notice {
  padding: 10px 12px; border-radius: 12px; background: rgba(99,179,237,.07);
  border: 1px solid rgba(99,179,237,.18); color: #b9d9f2; font-size: 10.5px; line-height: 1.45;
}
.notice.warn { background: rgba(215,178,108,.07); border-color: rgba(215,178,108,.2); color: var(--gold-2); }
.notice.danger { background: rgba(226,59,78,.07); border-color: rgba(226,59,78,.2); color: #ffb4bc; }
.scroll-x { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.hr { height: 1px; background: var(--line); margin: 10px 0; }

/* animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes modalIn { from { transform: translateY(14px) scale(.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes logoIn { from { transform: translateY(8px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fog { from { transform: translateX(-4%) scale(1); opacity: .55; } to { transform: translateX(4%) scale(1.08); opacity: .95; } }
@keyframes drift {
  0% { transform: translate3d(0, 20vh, 0); opacity: 0; }
  12% { opacity: .8; } 85% { opacity: .5; }
  100% { transform: translate3d(18px, -110vh, 0); opacity: 0; }
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes timerPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(226,59,78,.0); } 50% { box-shadow: 0 0 0 4px rgba(226,59,78,.12); } }
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes resultPop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes drunkWobble { 0%,100% { transform: rotate(0) translateX(0); } 25% { transform: rotate(-.6deg) translateX(-1px); } 75% { transform: rotate(.6deg) translateX(1px); } }
@keyframes bubbleUp {
  0% { transform: translateY(0) scale(.7); opacity: 0; }
  10% { opacity: .5; } 90% { opacity: .2; }
  100% { transform: translateY(-108vh) scale(1.15); opacity: 0; }
}
@keyframes targetPulse { 0%,100% { box-shadow: 0 0 0 2px rgba(215,178,108,.35); } 50% { box-shadow: 0 0 0 4px rgba(215,178,108,.12); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* very short screens */
@media (max-height: 620px) {
  .auth-hero { min-height: 190px; padding: 10px 0 8px; }
  .auth-logo { width: 64px; height: 64px; margin-bottom: 10px; }
  .auth-title { font-size: 48px; }
  .auth-tagline { display: none; }
  .table-zone { max-height: 34dvh; }
  .player-card .avatar { --size: 36px; }
  .game-head { padding-top: max(5px, var(--safe-top)); }
  .phase-title { font-size: 21px; }
  .action-bar { min-height: 56px; padding: 7px 12px; }
}

/* ---------- additions ---------- */
body.modal-open { overflow: hidden; }
.boot-screen { justify-content: flex-start; }
.boot-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px 0 40px; }
.boot-wrap .auth-title { font-size: 58px; }
.boot-loader { display: flex; align-items: center; gap: 9px; margin-top: 28px; color: var(--muted); font-size: 12px; }
.boot-actions { display: flex; gap: 8px; margin-top: 18px; }
.boot-actions .btn { min-height: 42px; font-size: 12px; }

.pc-flags { position: absolute; top: 3px; right: 3px; display: flex; gap: 2px; z-index: 2; }
.pc-flags .pc-badge { position: static; }
.player-card { overflow: hidden; }
.player-card .role-tag { z-index: 2; }
.player-card .pc-voted { z-index: 3; }

.choice { position: relative; display: grid; place-items: center; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: rgba(215,178,108,.4); background: rgba(215,178,108,.1); color: var(--gold-2); }
.choice span { pointer-events: none; }

.range { width: 100%; height: 28px; accent-color: var(--red); margin: 4px 0 0; }

.result-role-row.you { border: 1px solid rgba(215,178,108,.22); background: rgba(215,178,108,.045); }
.result-role-row .win-tag { flex: 0 0 auto; }

.msg.private .msg-nick { color: var(--gold-2); }

.avatar { background: radial-gradient(circle at 32% 24%, var(--a1), var(--a2)); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .avatar { background: radial-gradient(circle at 32% 24%, color-mix(in srgb, var(--a1) 88%, white 12%), var(--a1) 38%, var(--a2) 100%); }
}

/* ============================================================
   V2: 25 players, new roles, frames, keyboard-safe chat
   ============================================================ */
:root { --vvh: 100dvh; }
.game-screen, .lobby-screen { height: var(--vvh, 100dvh); min-height: 0; }
.game-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.player-card { padding: 6px 2px 5px; border-radius: 12px; gap: 2px; }
.player-card .avatar { --size: 36px; }
.pc-name { font-size: 9.5px; }
.pc-status { font-size: 7.5px; }
.table-zone { max-height: 33dvh; padding: 8px 9px 6px; }
.chat-panel { min-height: 190px; }
.chat-list { padding: 6px 12px 8px; }
.chat-head { padding-top: 6px; }
.role-emblem {
  position: absolute; right: 4px; bottom: 18px; z-index: 4;
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(7,9,14,.85); border: 1px solid rgba(255,255,255,.15);
  font-size: 9px; font-weight: 900; line-height: 1;
}
.msg-role { font-size: 10px; margin-right: 3px; font-weight: 900; }
.players-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.lobby-player { padding: 7px 3px 6px; }
.lobby-player .avatar { --size: 44px; }
.lobby-player .lp-name { font-size: 9.5px; }
.lobby-player.empty { min-height: 76px; }
.lobby-chat-wrap { flex-basis: 280px; }

/* role counters in settings */
.role-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.role-count {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-height: 38px; padding: 4px 7px 4px 10px; border-radius: 10px;
  background: rgba(255,255,255,.035); border: 1px solid var(--line);
  font-size: 10.5px; color: var(--text-2);
}
.role-count input {
  width: 44px; height: 30px; padding: 0 4px; text-align: center;
  border-radius: 8px; border: 1px solid #2a3242; background: #0d1119;
  color: var(--text); font-size: 13px; font-weight: 800;
}
.role-count input:focus { outline: none; border-color: rgba(215,178,108,.55); }
#role-summary strong { color: var(--gold-2); }

/* frames */
.avatar.frame-royal { box-shadow: 0 0 0 2px #f0d79a, 0 0 0 4px #8a5a1f, 0 0 22px rgba(240,215,154,.35); }
.avatar.frame-blood { box-shadow: 0 0 0 2px #ff5c6c, 0 0 0 4px #6d1421, 0 0 20px rgba(226,59,78,.3); }
.avatar.frame-neon { box-shadow: 0 0 0 2px #22d3ee, 0 0 0 4px #0e5d6e, 0 0 22px rgba(34,211,238,.35); }
.avatar.frame-emerald { box-shadow: 0 0 0 2px #34d399, 0 0 0 4px #105c43, 0 0 20px rgba(52,211,153,.3); }
.avatar.frame-rose { box-shadow: 0 0 0 2px #f472b6, 0 0 0 4px #6d2148, 0 0 20px rgba(244,114,182,.32); }
.avatar.frame-shadow { box-shadow: 0 0 0 2px #a78bfa, 0 0 0 4px #3b2a63, 0 0 22px rgba(167,139,250,.35); }
.frame-crown {
  position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: #ffe9ab; text-shadow: 0 1px 4px #000; z-index: 5;
}
.frame-shop { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.frame-card {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  min-width: 0;
}
.frame-card.active { border-color: rgba(215,178,108,.4); background: rgba(215,178,108,.06); }
.frame-card .avatar { --size: 38px; }
.frame-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.frame-copy strong { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-copy span { font-size: 8.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame-btn {
  flex: 0 0 auto; min-height: 28px; padding: 0 7px; border-radius: 8px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  color: var(--text-2); font-size: 9px; font-weight: 800;
}
.frame-btn.buy { background: rgba(215,178,108,.12); border-color: rgba(215,178,108,.28); color: var(--gold-2); }
.frame-btn.equipped { background: rgba(85,209,140,.1); border-color: rgba(85,209,140,.25); color: #9debbd; }
.chip-pink { background: rgba(244,114,182,.1); border-color: rgba(244,114,182,.26); color: #ffb6d5; }

/* keyboard: chat takes over the screen */
body.keyboard-open .game-head,
body.keyboard-open .table-zone,
body.keyboard-open .action-bar,
body.keyboard-open .mafia-votes,
body.keyboard-open .lobby-head,
body.keyboard-open .lobby-content,
body.keyboard-open .lobby-actions,
body.keyboard-open .lobby-hint { display: none !important; }
body.keyboard-open .game-screen { height: var(--vvh, 100dvh) !important; }
body.keyboard-open .chat-panel { flex: 1 1 auto !important; min-height: 0 !important; }
body.keyboard-open .lobby-screen { height: var(--vvh, 100dvh) !important; }
body.keyboard-open .lobby-chat-wrap { flex: 1 1 auto !important; margin: 0 !important; border: 0 !important; border-radius: 0 !important; }
body.keyboard-open .chat-composer { padding-bottom: calc(8px + var(--safe-bottom)); }
body.keyboard-open .chat-list { padding-bottom: 14px; }

@media (max-width: 370px) {
  .game-grid, .players-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .player-card .avatar { --size: 34px; }
}

.role-emblem-inline { font-size: 13px; line-height: 1; font-weight: 900; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.avatar.frame-royal { overflow: visible; }
.frame-crown { pointer-events: none; }

.frame-shop { grid-template-columns: 1fr; }
.frame-card { padding: 9px 10px; }
.frame-copy strong { font-size: 11.5px; }
.frame-copy span { font-size: 9px; }
.frame-btn { min-height: 30px; padding: 0 10px; font-size: 10px; }

/* default width is 4 columns; 5 only for big rooms */
.game-grid, .players-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.game-grid.many, .players-grid.many { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pc-emblem { font-size: 9px; line-height: 1; margin-right: 2px; font-weight: 900; vertical-align: 1px; }
@media (max-width: 370px) {
  .game-grid.many, .players-grid.many { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* V3: role avatars, counters, radiance */
.role-avatar { position: relative; background: radial-gradient(circle at 35% 25%, var(--a1), var(--a2) 72%); border-color: rgba(255,255,255,.16); }
.role-avatar .av-icon { font-size: clamp(14px, 42%, 30px); opacity: .95; }
.role-avatar-emblem {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px;
  display: grid; place-items: center; border-radius: 50%;
  background: #0a0d14; border: 1px solid rgba(255,255,255,.2);
  color: var(--gold-2); font-size: 9px; font-weight: 900; line-height: 1;
}
.role-modal-avatar-wrap { display: flex; justify-content: center; margin: 2px 0 10px; }
.role-modal-avatar { --size: 96px !important; box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 10px 35px rgba(0,0,0,.45); }
.role-modal-avatar .role-avatar-emblem { width: 22px; height: 22px; font-size: 12px; }

.chat-counters { display: flex; align-items: center; gap: 4px; margin-left: auto; margin-right: 4px; flex: 0 0 auto; }
.chat-counter {
  display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 6px;
  border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04);
  font-size: 9px; font-weight: 800; color: var(--text-2);
}
.chat-counter.mafia { color: #ff9aa7; border-color: rgba(226,59,78,.25); background: rgba(226,59,78,.08); }
.chat-counter.town { color: #e8cf9a; border-color: rgba(215,178,108,.22); background: rgba(215,178,108,.06); }
.msg.anonymous .msg-nick { color: #9fb6cc; }
.anon-label { font-size: 7px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-left: 2px; }
.anonymous-avatar { filter: saturate(.7); }

.avatar.frame-radiance {
  box-shadow: 0 0 0 2px #ffe9a8, 0 0 0 4px #b47a20, 0 0 18px rgba(255,220,130,.55);
  animation: radiance-pulse 2.4s ease-in-out infinite;
}
@keyframes radiance-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #ffe9a8, 0 0 0 4px #b47a20, 0 0 14px rgba(255,220,130,.4); }
  50% { box-shadow: 0 0 0 2px #fff3c9, 0 0 0 5px #d6a13a, 0 0 30px rgba(255,225,140,.8); }
}
.role-avatar.av-xs .av-icon { font-size: 11px; }
.role-avatar.av-xs .role-avatar-emblem { width: 12px; height: 12px; font-size: 7px; right: -2px; bottom: -2px; }
.role-modal-avatar .av-icon { font-size: 34px !important; }
.role-modal-avatar .role-avatar-emblem { width: 24px; height: 24px; font-size: 13px; }

/* ============================================================
   V4: VK-style table — chat left, players right, light theme
   ============================================================ */
.vk-layout {
  --vk-bg: #e9ede4;
  --vk-panel: #fbfaf3;
  --vk-panel-2: #f2f0e5;
  --vk-ink: #171912;
  --vk-muted: #74776a;
  --vk-line: rgba(23, 25, 18, .13);
  --vk-red: #c62828;
  --vk-red-deep: #8e1d24;
  background: var(--vk-bg) !important;
  color: var(--vk-ink);
  height: var(--vvh, 100dvh);
  display: flex;
  flex-direction: column;
}
.vk-layout.phase-night { background: linear-gradient(180deg, #e4ebe5, #eef0e7) !important; }
.vk-layout.phase-day { background: linear-gradient(180deg, #f1efe2, #e9ede4) !important; }
.vk-layout.phase-vote { background: linear-gradient(180deg, #f4e6e2, #ece8df) !important; }
.vk-layout.phase-over { background: linear-gradient(180deg, #f1ead8, #e9ede4) !important; }

.vk-game-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  min-height: 54px;
  padding: max(8px, var(--safe-top)) 10px 8px;
  background: var(--vk-red);
  border: 0;
  color: #fff;
  box-shadow: 0 2px 10px rgba(90, 0, 0, .18);
}
.vk-back {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 22px; line-height: 1;
  background: rgba(255,255,255,.12);
}
.vk-room-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.vk-room-title strong { font-size: 14px; font-weight: 800; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vk-room-title span { font-size: 9px; color: rgba(255,255,255,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vk-menu { width: 34px; height: 34px; color: #fff; font-size: 18px; }

.vk-game-body { flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; }
.vk-game-main {
  flex: 1 1 66%; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 5px;
  padding: 7px 6px 0 8px;
}
.vk-players-pane {
  flex: 0 0 34%; min-width: 112px; max-width: 155px;
  display: flex; flex-direction: column; min-height: 0;
  padding: 7px 5px 0;
  background: rgba(255,255,255,.32);
  border-left: 1px solid var(--vk-line);
}

/* role card */
.vk-role-card {
  flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
  min-height: 66px; padding: 6px 6px 6px 7px;
  border-radius: 13px; border: 1px solid var(--vk-line);
  background: var(--vk-panel);
  box-shadow: 0 2px 8px rgba(28, 32, 20, .06);
}
.vk-role-avatar { flex: 0 0 auto; }
.vk-role-avatar .avatar { --size: 46px; }
.vk-role-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.vk-role-kicker { font-size: 7.5px; text-transform: uppercase; letter-spacing: .13em; color: var(--vk-muted); font-weight: 800; }
#role-summary-name { font-family: var(--font-display); font-size: 20px; line-height: 1.05; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#role-summary-sub { font-size: 7.5px; color: var(--vk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vk-role-counts { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.vk-count { font-size: 8px; font-weight: 700; white-space: nowrap; }
.vk-count.mafia { color: #b32636; }
.vk-count.town { color: #447941; }
.vk-count b { font-size: 10px; }
.vk-layout .timer-ring {
  --size: 43px; flex: 0 0 43px; margin-left: 1px;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), rgba(23,25,18,.12) 0);
  box-shadow: none;
}
.vk-layout .timer-ring::before { inset: 4px; background: var(--vk-panel); }
.vk-layout .timer-ring .timer-text { color: var(--vk-ink); font-size: 10.5px; }

/* phase line */
.vk-phase-line {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 5px;
  padding: 0 2px; min-height: 17px; overflow: hidden;
}
.vk-phase-line .phase-kicker { color: var(--vk-muted); font-size: 7px; }
.vk-phase-line .phase-title { font-family: var(--font-display); font-size: 15px; line-height: 1.1; color: #24271d; white-space: nowrap; }
.vk-phase-line .phase-desc { font-size: 8px; color: var(--vk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* action bar */
.vk-layout .action-bar {
  flex: 0 0 auto; min-height: 48px; padding: 5px 6px;
  gap: 6px; border: 1px solid var(--vk-line); border-radius: 12px;
  background: var(--vk-panel);
}
.vk-layout .action-icon { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; font-size: 14px; background: rgba(198,40,40,.08); border-color: rgba(198,40,40,.16); }
.vk-layout .action-copy strong { font-size: 10px; color: var(--vk-ink); }
.vk-layout .action-copy span { font-size: 8px; color: var(--vk-muted); }
.vk-layout .action-buttons { gap: 3px; }
.vk-layout .action-buttons .btn { min-height: 30px; font-size: 9px; padding: 0 8px; border-radius: 8px; }
.vk-layout .btn-ghost { background: #ece9dd; color: #33372b; border: 1px solid #d7d3c5; }
.vk-layout .mafia-votes { background: transparent; color: var(--vk-muted); padding: 0 2px 4px; }

/* chat */
.vk-layout .chat-panel {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  background: #f8f6ec; border: 1px solid var(--vk-line); border-bottom: 0;
  border-radius: 12px 12px 0 0; overflow: hidden;
}
.vk-layout .chat-head { padding: 4px 5px 0; gap: 2px; }
.vk-layout .chat-tabs { padding-bottom: 4px; gap: 2px; }
.vk-layout .chat-tab { min-height: 24px; padding: 0 7px; font-size: 9px; color: #85887a; border-radius: 7px; }
.vk-layout .chat-tab.active { color: var(--vk-ink); background: #e7e3d5; border-color: #d8d4c5; }
.vk-layout .chat-tab.mafia.active { color: #a83240; background: #f4e2e3; border-color: #eccfd2; }
.vk-layout .chat-mini { width: 28px; height: 24px; color: #85887a; }
.vk-layout .chat-counters { display: none; }
.vk-layout .chat-list { padding: 2px 6px 5px; gap: 4px; }
.vk-layout .msg { gap: 4px; }
.vk-layout .msg .avatar { --size: 23px; }
.vk-layout .msg-body { max-width: 89%; gap: 1px; }
.vk-layout .msg-meta { gap: 3px; padding: 0 2px; }
.vk-layout .msg-nick { color: #a66f25; font-size: 8px; }
.vk-layout .msg-time { color: #a6a899; font-size: 6.5px; }
.vk-layout .msg-text {
  background: #fffdf7; border: 1px solid #e7e3d6; color: #1b1d16;
  font-size: 11.5px; line-height: 1.35; padding: 5px 8px; border-radius: 11px 11px 11px 3px;
}
.vk-layout .msg.own .msg-text { background: #f7dde0; border-color: #ecc8cc; color: #3a161b; border-radius: 11px 11px 3px 11px; }
.vk-layout .msg.own .msg-nick { color: #a33a47; }
.vk-layout .msg.private .msg-text { background: #f5edcf; border-color: #e6d9ad; color: #4d3b15; }
.vk-layout .msg.drunk .msg-text { background: #eee4f8; border-color: #d9c8ef; color: #3e2d4d; animation: none; }
.vk-layout .msg.drunk .msg-text::after { content: " 🌀"; }
.vk-layout .msg-system {
  color: #76796b; background: rgba(255,255,255,.6); font-size: 8px;
  padding: 3px 6px; border-radius: 7px; max-width: 95%;
}
.vk-layout .msg-system.death { color: #a83240; background: #f5dfe1; }
.vk-layout .msg-system.night { color: #4b6182; background: #e4eaf2; }
.vk-layout .msg-system.day { color: #8b681f; background: #f5edcf; }
.vk-layout .msg-system.start { color: #626657; }
.vk-layout .typing-line { min-height: 12px; padding: 0 8px 1px; color: #85887a; font-size: 8px; }
.vk-layout .chat-composer { padding: 4px 5px calc(4px + var(--safe-bottom)); background: var(--vk-panel); border-top: 1px solid var(--vk-line); gap: 4px; }
.vk-layout .chat-input {
  height: 36px; border-radius: 18px; background: #fffdf7; border: 1px solid #dcd8ca;
  color: var(--vk-ink); font-size: 15px; padding: 0 11px;
}
.vk-layout .chat-input:focus { border-color: #c9a55d; background: #fff; }
.vk-layout .chat-input::placeholder { color: #999b8e; font-size: 11px; }
.vk-layout .chat-send { width: 36px; height: 36px; flex-basis: 36px; background: var(--vk-red); box-shadow: 0 4px 10px rgba(160,0,20,.2); font-size: 15px; }
.vk-layout .chat-locked { min-height: 44px; padding: 5px 8px calc(5px + var(--safe-bottom)); background: var(--vk-panel); color: #85887a; font-size: 9px; border-top: 1px solid var(--vk-line); }

/* right players panel */
.vk-players-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 1px 3px 5px; color: #6c7062; font-size: 8px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; border-bottom: 1px solid var(--vk-line);
}
.vk-players-head b { color: var(--vk-ink); font-size: 10px; }
.vk-players-pane .table-zone {
  flex: 1 1 auto; max-height: none; min-height: 0; overflow-y: auto;
  padding: 5px 0 8px; background: transparent;
}
.vk-players-pane .table-zone::before { display: none; }
.vk-grid, .vk-grid.many { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.vk-grid .player-card {
  gap: 2px; padding: 4px 2px 3px; border-radius: 9px;
  background: var(--vk-panel); border: 1px solid var(--vk-line);
}
.vk-grid .player-card .avatar { --size: 34px; }
.vk-grid .pc-name { font-size: 8.5px; color: var(--vk-ink); }
.vk-grid .pc-status { font-size: 6.5px; color: #777a6d; min-height: 9px; }
.vk-grid .player-card.you { border-color: #c9a55d; background: #fbf7e8; }
.vk-grid .player-card.mate { border-color: #d7a4a9; background: #fbeeef; }
.vk-grid .player-card.dead { opacity: 1; filter: none; background: #e5e2d6; border-color: #c9c5b7; }
.vk-grid .player-card.dead .pc-name { color: #5b5e52; }
.vk-grid .pc-badge { top: 2px; right: 2px; min-width: 12px; height: 12px; font-size: 7px; background: rgba(255,255,255,.88); color: #2a2d24; border-color: rgba(23,25,18,.15); }
.vk-grid .pc-badge.drunk { background: #eadcf5; color: #5a3b71; border-color: #d8c2ea; }
.vk-grid .pc-badge.mate { background: #f2d5d8; color: #9d2f3a; border-color: #e3b9be; }
.vk-grid .pc-voted { background: var(--vk-red); }

/* blood on dead avatars */
.avatar.dead-avatar { filter: brightness(.78) saturate(.65); opacity: 1; }
.avatar.dead-avatar::before {
  content: ""; position: absolute; inset: 0; z-index: 4; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle at 27% 25%, rgba(180,18,35,.95) 0 8%, transparent 9%),
    radial-gradient(circle at 70% 35%, rgba(140,10,25,.88) 0 6%, transparent 7%),
    radial-gradient(circle at 49% 68%, rgba(160,12,28,.82) 0 5%, transparent 6%),
    radial-gradient(circle at 76% 73%, rgba(120,8,20,.7) 0 3%, transparent 4%),
    linear-gradient(104deg, transparent 42%, rgba(155,12,28,.55) 43% 46%, transparent 47%);
}
.avatar.dead-avatar::after { border-color: rgba(150,20,35,.55); }
.player-card.dead .avatar { opacity: .9; }

/* keyboard: chat only */
body.keyboard-open .vk-game-head,
body.keyboard-open .vk-role-card,
body.keyboard-open .vk-phase-line,
body.keyboard-open .vk-players-pane { display: none !important; }
body.keyboard-open .vk-game-main { padding: 0 !important; gap: 0; }
body.keyboard-open .vk-layout .chat-panel { border: 0; border-radius: 0; }
body.keyboard-open .vk-game-body { background: #f8f6ec; }

@media (max-width: 370px) {
  .vk-players-pane { flex-basis: 32%; min-width: 104px; }
  .vk-grid .player-card .avatar { --size: 30px; }
  .vk-layout .action-icon { display: none; }
  .vk-layout .chat-tab { padding: 0 5px; font-size: 8.5px; }
}
.role-avatar .av-icon { color: var(--role-color, #f1d79c); text-shadow: 0 2px 5px rgba(0,0,0,.55); }
.avatar.dead-avatar::before {
  background:
    radial-gradient(circle at 24% 23%, rgba(205,22,38,.98) 0 12%, transparent 13%),
    radial-gradient(circle at 72% 30%, rgba(170,12,28,.92) 0 9%, transparent 10%),
    radial-gradient(circle at 47% 70%, rgba(190,18,32,.9) 0 7%, transparent 8%),
    radial-gradient(circle at 80% 76%, rgba(140,8,20,.8) 0 5%, transparent 6%),
    linear-gradient(104deg, transparent 40%, rgba(180,15,30,.65) 41% 45%, transparent 46%),
    linear-gradient(78deg, transparent 60%, rgba(160,10,25,.5) 61% 64%, transparent 65%);
}
.vk-grid .player-card.dead .avatar { box-shadow: 0 0 0 1px rgba(170,20,35,.55), 0 0 10px rgba(170,20,35,.16); }

/* radiance spotlight in profile */
.radiance-cta {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(255,232,160,.1), rgba(120,70,20,.06));
  border: 1px solid rgba(255,220,140,.28);
  border-radius: 18px;
  padding: 12px;
}
.radiance-cta-avatar { flex: 0 0 auto; }
.radiance-cta-avatar .avatar { --size: 64px; }
.radiance-cta-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.radiance-cta-copy .eyebrow { color: var(--gold); font-size: 9px; }
.radiance-cta-copy h2 { margin: 0; font-family: var(--font-display); font-size: 26px; color: var(--gold-2); }
.radiance-cta-copy p { margin: 0; font-size: 10px; color: var(--muted); line-height: 1.35; }
.radiance-cta .frame-btn { flex: 0 0 auto; }

/* more frames */
.avatar.frame-ice { box-shadow: 0 0 0 2px #c9f4ff, 0 0 0 4px #4d9cb8, 0 0 18px rgba(140,230,255,.55); }
.avatar.frame-fire { box-shadow: 0 0 0 2px #ffc28a, 0 0 0 4px #a83b12, 0 0 20px rgba(255,120,40,.6); }
.avatar.frame-galaxy {
  box-shadow: 0 0 0 2px #d7c2ff, 0 0 0 4px #5b2e9e, 0 0 20px rgba(150,90,255,.55);
  animation: galaxyPulse 3.2s ease-in-out infinite;
}
.avatar.frame-sakura { box-shadow: 0 0 0 2px #ffd3e4, 0 0 0 4px #9e4160, 0 0 18px rgba(255,150,190,.5); }
.avatar.frame-aurora {
  box-shadow: 0 0 0 2px #9dffdc, 0 0 0 4px #1b7a68, 0 0 22px rgba(90,255,210,.55);
  animation: auroraPulse 3.8s ease-in-out infinite;
}
.avatar.frame-cyber { box-shadow: 0 0 0 2px #7dffe8, 0 0 0 4px #086b62, 0 0 20px rgba(0,255,210,.55); }
.avatar.frame-gold { box-shadow: 0 0 0 2px #fff0b8, 0 0 0 4px #9a681c, 0 0 24px rgba(255,210,100,.65); }
.avatar.frame-diamond { box-shadow: 0 0 0 2px #f3ffff, 0 0 0 4px #6d9cb8, 0 0 26px rgba(190,245,255,.7); }
.avatar.frame-ocean { box-shadow: 0 0 0 2px #9fe8ff, 0 0 0 4px #155b82, 0 0 18px rgba(60,180,240,.5); }
.avatar.frame-forest { box-shadow: 0 0 0 2px #b9f5c7, 0 0 0 4px #2b6b43, 0 0 18px rgba(80,210,120,.45); }
.avatar.frame-sunset { box-shadow: 0 0 0 2px #ffd2a8, 0 0 0 4px #a34a1d, 0 0 20px rgba(255,140,70,.55); }
.avatar.frame-violet { box-shadow: 0 0 0 2px #e4c5ff, 0 0 0 4px #6b2c98, 0 0 20px rgba(190,110,255,.55); }
.avatar.frame-silver { box-shadow: 0 0 0 2px #f5f8ff, 0 0 0 4px #66758c, 0 0 18px rgba(200,220,245,.55); }
.avatar.frame-rainbow {
  animation: rainbowRing 5s linear infinite;
}
.avatar.frame-skull { box-shadow: 0 0 0 2px #f7edd2, 0 0 0 4px #3f4340, 0 0 20px rgba(220,220,200,.35); }
.avatar.frame-snow { box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #86a6b8, 0 0 22px rgba(220,245,255,.65); }
.avatar.frame-heart { box-shadow: 0 0 0 2px #ffb3c1, 0 0 0 4px #a31436, 0 0 20px rgba(255,70,110,.55); }

@keyframes galaxyPulse {
  0%, 100% { box-shadow: 0 0 0 2px #d7c2ff, 0 0 0 4px #5b2e9e, 0 0 16px rgba(150,90,255,.4); }
  50% { box-shadow: 0 0 0 2px #f0e4ff, 0 0 0 5px #7a45c9, 0 0 32px rgba(170,120,255,.8); }
}
@keyframes auroraPulse {
  0%, 100% { box-shadow: 0 0 0 2px #9dffdc, 0 0 0 4px #1b7a68, 0 0 16px rgba(90,255,210,.4); }
  50% { box-shadow: 0 0 0 2px #d5fff0, 0 0 0 5px #27a88d, 0 0 32px rgba(100,255,220,.8); }
}
@keyframes rainbowRing {
  0% { box-shadow: 0 0 0 2px #ff5c7a, 0 0 0 4px #8e1b3a, 0 0 20px rgba(255,90,120,.55); }
  25% { box-shadow: 0 0 0 2px #ffd166, 0 0 0 4px #8e651b, 0 0 20px rgba(255,210,100,.55); }
  50% { box-shadow: 0 0 0 2px #6ee7b7, 0 0 0 4px #1b6e4f, 0 0 20px rgba(110,230,180,.55); }
  75% { box-shadow: 0 0 0 2px #7dd3fc, 0 0 0 4px #1b5b8e, 0 0 20px rgba(120,210,255,.55); }
  100% { box-shadow: 0 0 0 2px #c084fc, 0 0 0 4px #5b2e9e, 0 0 20px rgba(190,130,255,.55); }
}

/* keyboard keeps the players list visible */
body.keyboard-open .vk-players-pane { display: flex !important; flex: 0 0 32% !important; min-width: 104px; }
body.keyboard-open .vk-players-pane .table-zone { display: block !important; max-height: none !important; }
body.keyboard-open .vk-players-pane .vk-players-head { display: flex !important; }
body.keyboard-open .vk-game-main { padding: 0 6px 0 6px !important; }
body.keyboard-open .vk-layout .chat-panel { border: 0; border-radius: 0; }

/* keyboard: keep the whole table, only let the chat shrink */
body.keyboard-open .vk-game-head,
body.keyboard-open .vk-role-card,
body.keyboard-open .vk-phase-line,
body.keyboard-open .action-bar,
body.keyboard-open .mafia-votes { display: flex !important; }
body.keyboard-open .vk-game-main { padding: 7px 6px 0 8px !important; gap: 5px; }
body.keyboard-open .vk-layout .chat-panel { border: 1px solid var(--vk-line); border-radius: 12px 12px 0 0; }
body.keyboard-open .vk-players-pane { display: flex !important; }
body.keyboard-open .vk-players-pane .table-zone { display: block !important; }

/* reply + message styles */
.chat-composer-v { flex-direction: column !important; align-items: stretch !important; gap: 3px !important; }
.chat-composer-row { display: flex; align-items: center; gap: 5px; width: 100%; }
.chat-style-btn {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255,255,255,.06);
  border: 1px solid var(--line); font-size: 15px; color: var(--text-2);
}
.chat-style-btn.style-flame { background: rgba(255,90,20,.16); border-color: rgba(255,120,40,.4); }
.chat-style-btn.style-neon { background: rgba(0,255,220,.12); border-color: rgba(0,255,220,.35); }
.chat-style-btn.style-gold { background: rgba(255,210,100,.14); border-color: rgba(255,210,100,.35); }
.chat-style-btn.style-ice { background: rgba(120,210,255,.13); border-color: rgba(120,210,255,.35); }
.chat-style-picker { display: flex; gap: 3px; overflow-x: auto; padding: 1px 0 2px; scrollbar-width: none; }
.chat-style-picker::-webkit-scrollbar { display: none; }
.chat-style-chip {
  min-height: 26px; padding: 0 7px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255,255,255,.04); color: var(--muted); font-size: 9px; white-space: nowrap; font-weight: 700;
}
.chat-style-chip.active { color: var(--text); background: rgba(255,255,255,.1); }
.chat-style-chip.style-flame.active { color: #ffb06a; border-color: rgba(255,120,40,.4); }
.chat-style-chip.style-neon.active { color: #7dfff0; border-color: rgba(0,255,220,.4); }
.chat-style-chip.style-gold.active { color: #ffe2a0; border-color: rgba(255,210,100,.4); }
.chat-style-chip.style-ice.active { color: #c9f4ff; border-color: rgba(120,210,255,.4); }
.reply-preview {
  display: flex; align-items: center; gap: 5px; padding: 4px 6px;
  border-left: 3px solid var(--gold); border-radius: 6px; background: rgba(255,255,255,.04);
}
.reply-preview-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.reply-preview-text b { font-size: 8.5px; color: var(--gold-2); }
.reply-preview-text span { font-size: 8.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-cancel { width: 24px; height: 24px; flex: 0 0 24px; color: var(--muted); font-size: 12px; }
.msg-reply {
  display: flex; flex-direction: column; gap: 0; max-width: 100%; text-align: left;
  padding: 3px 6px; margin-bottom: 2px; border-left: 2px solid rgba(215,178,108,.55);
  border-radius: 5px; background: rgba(215,178,108,.08); overflow: hidden;
}
.msg-reply b { font-size: 8px; color: var(--gold-2); }
.msg-reply span { font-size: 8.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-reply-btn { margin-left: 2px; color: var(--muted-2); font-size: 11px; opacity: .5; padding: 0 2px; }
.msg.own .msg-reply-btn { color: #ffbcc2; }
.msg.own .msg-reply { border-left-color: rgba(255,150,160,.6); background: rgba(255,150,160,.1); }
.msg.own .msg-reply b { color: #ffd0d4; }
.msg-flash { animation: msgFlash 0.85s ease; }
@keyframes msgFlash { 0%, 100% { background: transparent; } 30% { background: rgba(215,178,108,.16); } }

.msg-style-flame .msg-text {
  background: linear-gradient(135deg, #5a180b, #a52c0b 55%, #3a0d07) !important;
  border-color: #ff7a2e !important; color: #fff3e6 !important;
  box-shadow: 0 0 14px rgba(255,90,20,.35), inset 0 0 10px rgba(255,160,60,.15);
  animation: flamePulse 1.8s ease-in-out infinite;
}
.msg-style-flame .msg-text::after { content: " 🔥"; }
.msg-style-neon .msg-text {
  background: linear-gradient(135deg, #062e2d, #07524a) !important;
  border-color: #22ffe1 !important; color: #d8fff9 !important;
  box-shadow: 0 0 14px rgba(0,255,220,.35);
}
.msg-style-neon .msg-text::after { content: " ⚡"; }
.msg-style-gold .msg-text {
  background: linear-gradient(135deg, #3d2a08, #6d4c12) !important;
  border-color: #f0c96a !important; color: #fff4cf !important;
  box-shadow: 0 0 14px rgba(240,201,106,.3);
}
.msg-style-gold .msg-text::after { content: " ✨"; }
.msg-style-ice .msg-text {
  background: linear-gradient(135deg, #0b2a3d, #124b63) !important;
  border-color: #a8e8ff !important; color: #e6faff !important;
  box-shadow: 0 0 14px rgba(140,230,255,.3);
}
.msg-style-ice .msg-text::after { content: " ❄️"; }
@keyframes flamePulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,90,20,.3), inset 0 0 8px rgba(255,160,60,.12); }
  50% { box-shadow: 0 0 20px rgba(255,120,30,.55), inset 0 0 14px rgba(255,180,80,.2); }
}

.vk-layout .chat-composer { padding: 4px 5px calc(4px + var(--safe-bottom)); }
.vk-layout .chat-composer-v { gap: 3px; }
.vk-layout .chat-style-btn { width: 30px; height: 30px; flex-basis: 30px; background: #ece9dd; border-color: #d7d3c5; }
.vk-layout .chat-style-picker { padding-bottom: 2px; }
.vk-layout .chat-style-chip { background: #ece9dd; border-color: #d7d3c5; color: #6f7265; }
.vk-layout .chat-style-chip.active { background: #e2ddcb; color: #1b1d16; }
.vk-layout .reply-preview { background: #eee9da; border-left-color: #c39a4c; }
.vk-layout .reply-preview-text b { color: #8a5a1f; }
.vk-layout .reply-preview-text span { color: #77796c; }
.vk-layout .reply-cancel { color: #77796c; }
.vk-layout .msg-reply { background: rgba(195,154,76,.1); border-left-color: #c39a4c; }
.vk-layout .msg-reply b { color: #8a5a1f; }
.vk-layout .msg-reply span { color: #77796c; }
.vk-layout .msg-reply-btn { color: #8d8f80; }
.vk-layout .msg-style-flame .msg-text { background: linear-gradient(135deg, #6b1f0d, #b43c12) !important; color: #fff3e6 !important; }
.vk-layout .msg-style-neon .msg-text { background: linear-gradient(135deg, #073b38, #087066) !important; color: #d8fff9 !important; }
.vk-layout .msg-style-gold .msg-text { background: linear-gradient(135deg, #4b350b, #7c5915) !important; color: #fff4cf !important; }
.vk-layout .msg-style-ice .msg-text { background: linear-gradient(135deg, #0d344b, #145b79) !important; color: #e6faff !important; }

.role-protected {
  display: inline-flex; align-items: center; gap: 3px; align-self: flex-start;
  margin-top: 3px; padding: 2px 6px; border-radius: 999px;
  background: rgba(70, 190, 120, .14); border: 1px solid rgba(70, 190, 120, .38);
  color: #2f7a52; font-size: 8px; font-weight: 800;
  animation: protectedPulse 1.8s ease-in-out infinite;
}
.role-protected.hidden { display: none !important; }
@keyframes protectedPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(70,190,120,0); }
  50% { box-shadow: 0 0 12px rgba(70,190,120,.25); }
}

/* detective check result */
.detective-result { text-align: center; align-items: center; }
.detective-avatars { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 2px 0 6px; }
.detective-person-avatar .avatar { --size: 82px; }
.detective-role-avatar .avatar { --size: 88px; }
.detective-nick { font-family: var(--font-display); font-size: 34px; line-height: 1.05; color: var(--text); }
.detective-verdict {
  display: inline-flex; margin: 4px auto 2px; padding: 3px 12px; border-radius: 999px;
  font-size: 10px; font-weight: 900; letter-spacing: .12em;
}
.detective-verdict.mafia { background: rgba(226,59,78,.14); border: 1px solid rgba(226,59,78,.4); color: #ff9aa7; }
.detective-verdict.town { background: rgba(85,209,140,.12); border: 1px solid rgba(85,209,140,.35); color: #9debbd; }
.detective-role-name { font-size: 12px; font-weight: 800; }
.detective-desc { font-size: 10.5px; color: var(--muted); line-height: 1.45; max-width: 300px; margin: 0 auto 6px; }

/* drunk chat */
.chat-panel.chat-drunk .chat-list { animation: chatDrift 4.2s ease-in-out infinite; transform-origin: 50% 20%; }
.chat-panel.chat-drunk .chat-list .msg-text { animation: chatTextDrift 3.4s ease-in-out infinite; }
.chat-panel.chat-drunk .chat-head { animation: chatHeadDrift 5s ease-in-out infinite; }
@keyframes chatDrift {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(-2px) rotate(-0.22deg); }
  45% { transform: translateX(2px) rotate(0.18deg); }
  70% { transform: translateX(-1px) rotate(-0.12deg); }
}
@keyframes chatTextDrift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-1px) rotate(0.25deg); }
}
@keyframes chatHeadDrift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(1px); }
}
.msg-system.news { color: #f1d79c; background: rgba(215,178,108,.12); border: 1px solid rgba(215,178,108,.25); font-weight: 700; }
.vk-layout .msg-system.news { color: #8a651f; background: #f5edcf; border-color: #e6d9ad; }

/* level / xp */
.level-card { padding: 10px 12px; border-radius: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.035); }
.level-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 10px; color: var(--muted); }
.level-head b { color: var(--gold-2); font-size: 17px; }
.level-head span:last-child { color: var(--text-2); font-variant-numeric: tabular-nums; }
.xp-bar { height: 7px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; margin: 6px 0 4px; }
.xp-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8e5a14, #f1d79c); box-shadow: 0 0 12px rgba(240,201,106,.35); transition: width .4s; }

/* nickname animations */
.nick-style-none { color: var(--text); }
.nick-style-glow {
  color: #f1d79c; text-shadow: 0 0 8px rgba(241,215,156,.6), 0 0 18px rgba(241,215,156,.25);
  animation: nickGlow 2.4s ease-in-out infinite;
}
.nick-style-flame {
  background: linear-gradient(90deg, #ffb35c, #ff5c3d, #ffd166, #ff7a2e);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 5px rgba(255,120,40,.5));
  animation: nickFlame 2s ease-in-out infinite;
}
.nick-style-neon {
  color: #8dfff2; text-shadow: 0 0 6px rgba(34,255,225,.9), 0 0 16px rgba(34,255,225,.45);
  animation: nickNeon 1.6s ease-in-out infinite;
}
.nick-style-gold {
  color: #ffd166; text-shadow: 0 0 8px rgba(255,210,100,.7);
  animation: nickGold 2.8s ease-in-out infinite;
}
.nick-style-rainbow {
  background: linear-gradient(90deg, #ff5c7a, #ffd166, #6ee7b7, #7dd3fc, #c084fc, #ff5c7a);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: nickRainbow 3.6s linear infinite;
}
.nick-style-ice {
  color: #c9f4ff; text-shadow: 0 0 7px rgba(140,230,255,.75), 0 0 15px rgba(140,230,255,.3);
  animation: nickIce 2.2s ease-in-out infinite;
}
@keyframes nickGlow { 0%,100% { text-shadow: 0 0 6px rgba(241,215,156,.45); } 50% { text-shadow: 0 0 16px rgba(241,215,156,.9); } }
@keyframes nickFlame { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes nickNeon { 0%,100% { opacity: .82; } 50% { opacity: 1; } }
@keyframes nickGold { 0%,100% { text-shadow: 0 0 6px rgba(255,210,100,.5); } 50% { text-shadow: 0 0 18px rgba(255,210,100,.95); } }
@keyframes nickRainbow { 0% { background-position: 0% 50%; } 100% { background-position: 300% 50%; } }
@keyframes nickIce { 0%,100% { text-shadow: 0 0 5px rgba(140,230,255,.5); } 50% { text-shadow: 0 0 15px rgba(140,230,255,.9); } }

.style-shop { display: flex; flex-direction: column; gap: 6px; }
.style-card { align-items: center; }
.nick-preview { width: 86px; flex: 0 0 86px; display: flex; align-items: center; justify-content: center; min-height: 32px; font-size: 13px; font-weight: 800; }
.bubble-preview { width: 86px; flex: 0 0 86px; display: flex; align-items: center; justify-content: center; }
.bubble-preview .msg-text { font-size: 8.5px !important; padding: 4px 6px !important; line-height: 1.2; white-space: normal; text-align: center; }
.bubble-preview .msg-text::after { content: "" !important; }
.avatar .av-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.nick-style-none { color: inherit; }
