/* «Мафия» поверх общих стилей FUNBASE: стол с вебками по кругу */
#game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.join-alt { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.link-btn { border: 0; background: none; color: var(--muted); font: 700 13px var(--font); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--text); }
.roles-help h3 { margin: 18px 0 6px; }
.roles-help p { color: var(--muted); font-size: 13.5px; margin: 0; line-height: 1.55; }
.roles-help b { color: var(--text); }
.phase-chip { cursor: default; color: var(--text); font-weight: 800; }

/* ---------- Верхняя панель, чат, громкость (как в «Угадай кто») ---------- */
#camBtn .on, #camBtn[aria-pressed="true"] .off, #micBtn .on, #micBtn[aria-pressed="true"] .off { display: none; }
#camBtn[aria-pressed="true"] .on, #micBtn[aria-pressed="true"] .on { display: block; color: var(--ok); }
#camBtn .off, #micBtn .off { color: var(--muted); display: block; }
#camBtn[aria-pressed="true"] .off, #micBtn[aria-pressed="true"] .off { display: none; }
#chatBtn { position: relative; }
.badge-dot { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: #fff; font: 900 10px/16px var(--font); text-align: center; }
.vol-wrap { position: relative; }
.vol-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.vol-pop label { margin-bottom: 10px; font-size: 12.5px; }
.vol-pop label:last-child { margin-bottom: 0; }
.vol-pop input { width: 100%; }
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 80; width: 340px; height: min(480px, calc(100dvh - 90px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.6); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto; }
.chat-msg { background: var(--surface-2); border-radius: 10px 10px 10px 3px; padding: 6px 10px; max-width: 88%; align-self: flex-start; font-size: 14px; overflow-wrap: anywhere; }
.chat-msg b { display: flex; align-items: center; font-size: 12px; color: var(--accent); }
.chat-msg.mine { align-self: flex-end; background: #3a0d14; border-radius: 10px 10px 3px 10px; }
.chat-msg.mine b { color: #ff9aa6; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }
.chat-form .btn { padding: 0 14px; }



/* ---------- Стол ---------- */
.mstage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.table { position: relative; flex: 1; min-height: 0; }
.table::before { content: ''; position: absolute; left: 13%; right: 13%; top: 16%; bottom: 16%; border-radius: 50%;
  background: radial-gradient(60% 60% at 50% 45%, #3a0d14 0%, #1d0a0e 60%, #141416 100%); box-shadow: inset 0 0 0 2px rgba(224,40,60,.25), 0 30px 80px rgba(0,0,0,.5); }
.felt { position: absolute; inset: 0; }
.seat { position: absolute; background: var(--surface); border-radius: 14px; overflow: hidden; border: 2px solid transparent; transition: left .4s, top .4s, width .4s, border-color .2s, box-shadow .2s, opacity .3s; -webkit-tap-highlight-color: transparent; }
.seat .cam { aspect-ratio: 4 / 3; background: #0d0d0f; display: grid; place-items: center; position: relative; }
.seat .cam video { width: 100%; height: 100%; object-fit: cover; }
.seat.me .cam video { transform: scaleX(-1); }
.seat .cam .ava { --s: 48px; }
.seat .num { position: absolute; top: 6px; left: 6px; min-width: 22px; height: 22px; border-radius: 7px; background: rgba(0,0,0,.65); font: 900 12px/22px var(--font); text-align: center; padding: 0 5px; }
.seat .tags { position: absolute; top: 6px; right: 6px; left: 34px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; pointer-events: none; }
.seat .nm { padding: 5px 8px 6px; font: 800 13px/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .nm em { font-style: normal; font: 900 9px var(--font); background: #ffd21f; color: #111; border-radius: 4px; padding: 1px 4px; vertical-align: 2px; }
.seat .nm .off { color: var(--accent-hover); font-size: 11px; }
.seat .nm .role { margin-left: 4px; font-size: 9px; }
.tag, .rtag { font: 900 10px/1 var(--font); text-transform: uppercase; letter-spacing: .03em; padding: 4px 6px; border-radius: 6px; background: rgba(0,0,0,.72); color: #fff; }
.tag.nom { background: #ffd21f; color: #111; }
.tag.ok { background: var(--ok); color: #06200f; }
.tag.bad { background: var(--accent); color: #fff; }
.tag.dead { background: #000; color: var(--muted); }
.rtag { background: #fff; color: #111; }
.rtag.r-mafia, .rtag.r-don { background: var(--accent); color: #fff; }
.rtag.r-maniac { background: #7b3fe4; color: #fff; }
.rtag.r-com { background: #3987e5; color: #fff; }
.rtag.r-doc { background: var(--ok); color: #06200f; }
.seat .ring { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; display: none; }
.seat .ring i { display: block; height: 100%; width: 100%; background: #fff; }
.seat.speaking { border-color: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.14), 0 12px 40px rgba(0,0,0,.5); z-index: 2; }
.seat.speaking .ring { display: block; }
.seat.dead { opacity: .45; }
.seat.dead .cam video { filter: grayscale(1); }
/* Глаза в глаза: оба видят золотое свечение */
.seat.eye { border-color: #ffd21f; box-shadow: 0 0 0 4px rgba(255,210,31,.35), 0 0 36px rgba(255,210,31,.45); }
.seat.eye::after { content: 'смотрите друг на друга'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -80%); font: 900 10px var(--font); text-transform: uppercase;
  background: #ffd21f; color: #111; border-radius: 99px; padding: 4px 9px; white-space: nowrap; pointer-events: none; animation: eyepop .3s ease-out; }
@keyframes eyepop { from { transform: translate(-50%, -40%); opacity: 0; } }
.seat.looking { outline: 2px dashed rgba(255,210,31,.6); outline-offset: 2px; }
.seat.pick { cursor: pointer; }
.seat.pick:hover { border-color: var(--accent); }
.seat.chosen { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(224,40,60,.35); }
.seat .tile-actions { position: absolute; bottom: 30px; right: 4px; display: none; flex-direction: column; gap: 3px; }
.seat.touch .tile-actions { display: flex; }

/* ---------- Центр стола ---------- */
.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: var(--cw, 420px); max-width: calc(100% - 24px);
  display: grid; gap: 10px; text-align: center; z-index: 1; }
.center .say { font: 900 20px/1.2 var(--font); }
.center .say small { display: block; font: 600 13.5px/1.4 var(--font); color: #d4d4d8; margin-top: 6px; }
.center .say em { font-style: normal; color: #ffd21f; }
.night-say { color: #c9d6ff; }
.noms { font-size: 13.5px; color: #d4d4d8; } .noms b { color: #ffd21f; }
.vote-btns, .don-modes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.vote-btns .btn.on { box-shadow: inset 0 0 0 2px #fff; color: var(--text); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.skip { justify-self: center; }
.picked { font-size: 14px; color: #d4d4d8; } .picked b { color: #fff; }
.ctimer { height: 5px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.ctimer i { display: block; height: 100%; width: 100%; background: #fff; border-radius: inherit; }
.csec { font: 900 15px var(--font); color: var(--muted); font-variant-numeric: tabular-nums; }
.tally { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; text-align: left; }
.tally li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; background: rgba(0,0,0,.35); border-radius: 8px; padding: 6px 10px; font-size: 13.5px; }
.tally li span { font: 900 16px var(--font); }
.tally li small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.big-role { border-radius: 16px; padding: 18px; background: #fff; color: #111; display: grid; gap: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: flip .6s ease-out; }
.big-role span { font: 800 11px var(--font); text-transform: uppercase; letter-spacing: .12em; color: #666; }
.big-role b { font: 900 32px/1 var(--font); text-transform: uppercase; }
.big-role p { margin: 0; font-size: 13.5px; color: #333; }
.big-role .team { font-weight: 800; color: #111; }
.big-role.r-mafia, .big-role.r-don { background: linear-gradient(145deg, var(--accent), #8e1523); color: #fff; }
.big-role.r-mafia span, .big-role.r-don span, .big-role.r-mafia p, .big-role.r-don p { color: #ffd0d6; }
.big-role.r-mafia .team, .big-role.r-don .team { color: #fff; }
.big-role.r-maniac { background: linear-gradient(145deg, #7b3fe4, #3d1d7a); color: #fff; }
.big-role.r-maniac span, .big-role.r-maniac p { color: #e2d4ff; }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } }
.rolecard { justify-self: center; border: 0; cursor: pointer; border-radius: 10px; padding: 6px 12px; background: rgba(255,255,255,.92); color: #111; display: grid; font: 900 14px var(--font); text-transform: uppercase; }
.rolecard span { font: 700 9.5px var(--font); letter-spacing: .1em; color: #666; }
.rolecard.r-mafia, .rolecard.r-don { background: var(--accent); color: #fff; } .rolecard.r-mafia span, .rolecard.r-don span { color: #ffd0d6; }
.rolecard.r-maniac { background: #7b3fe4; color: #fff; }
.rolecard.closed b { filter: blur(6px); }
.winner { border-radius: 16px; padding: 16px; display: grid; gap: 4px; background: var(--surface-2); }
.winner span { font: 800 12px var(--font); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.winner b { font: 900 30px/1 var(--font); text-transform: uppercase; }
.winner.w-mafia { background: linear-gradient(145deg, var(--accent), #8e1523); } .winner.w-mafia span { color: #ffd0d6; }
.winner.w-city { background: linear-gradient(145deg, #1f6f4a, #103826); }
.winner.w-maniac { background: linear-gradient(145deg, #7b3fe4, #3d1d7a); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .btn { width: 100%; }
.hint-line { font-size: 13px; color: var(--muted); margin: 0; }
.lobby-c { display: grid; gap: 10px; background: rgba(17,17,19,.72); border-radius: 16px; padding: 14px; backdrop-filter: blur(6px); }
.lset { text-align: left; background: rgba(0,0,0,.3); border-radius: 12px; padding: 10px 12px; }
.lset summary { cursor: pointer; font-weight: 800; font-size: 14px; }
.lgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-top: 10px; }
.lgrid label { margin: 0; font-size: 12.5px; }
.lgrid .check { grid-column: span 3; font-size: 13px; }
.lgrid .check small { color: var(--muted); font-weight: 600; }
.lgrid select, .lgrid input:not([type=checkbox]) { width: 100%; min-width: 0; padding: 8px 9px; }

/* Лог игры */
.glog { background: var(--surface); border-radius: 12px; padding: 8px 12px; flex: none; }
.glog summary { cursor: pointer; font-weight: 800; font-size: 13.5px; }
.glog ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; max-height: 160px; overflow: auto; font-size: 13px; }
.glog .l-dead { color: var(--accent-hover); } .glog .l-night { color: #9fb3ff; } .glog .l-vote { color: #ffd21f; } .glog .l-end { color: var(--ok); font-weight: 800; }

/* ---------- Ночь ---------- */
.nightfall { position: fixed; inset: 0; pointer-events: none; z-index: 0; background: radial-gradient(80% 70% at 50% 40%, rgba(10,14,40,.0), rgba(4,6,20,.0)); transition: background 1.2s; }
body.is-night .nightfall { background: radial-gradient(80% 70% at 50% 40%, rgba(12,18,52,.55), rgba(3,4,14,.8)); }
body.is-night .table::before { background: radial-gradient(60% 60% at 50% 45%, #0f1633 0%, #0a0d1f 60%, #08080c 100%); box-shadow: inset 0 0 0 2px rgba(130,150,255,.25), 0 30px 80px rgba(0,0,0,.6); }
body.is-night .seat:not(.me) .cam video { display: none !important; }
body.is-night.am-mafia .seat:not(.me) .cam video { display: revert !important; }
.mstage, .topbar { position: relative; z-index: 1; }

/* ---------- Телефон и узкий экран: сетка вместо круга ---------- */
.table.compact { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.table.compact::before { display: none; }
.table.compact .center { position: static; transform: none; width: auto; max-width: none; order: -1; background: var(--surface); border-radius: 14px; padding: 12px; }
.table.compact .felt { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.table.compact .seat { position: relative; left: auto !important; top: auto !important; width: auto !important; }
.table.compact .seat .nm { font-size: 12px; }
.table.compact .tag, .table.compact .rtag { font-size: 8.5px; padding: 3px 4px; }
@media (max-width: 760px) {
  .topbar { gap: 4px; padding: 8px 8px; overflow-x: auto; scrollbar-width: none; }
  .topbar .logo.small { display: none; }
  .topbar #copyLink { font-size: 0; gap: 4px; }
  .topbar #copyLink b { font-size: 13px; }
  .topbar .icon-btn { width: 36px; height: 36px; }
  .chat { left: 0; right: 0; bottom: 0; width: auto; height: 62dvh; border-radius: 16px 16px 0 0; }
  .vol-pop { position: fixed; left: 10px; right: 10px; top: 56px; width: auto; }
  .mstage { padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); }
  .lgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .lgrid .check { grid-column: span 2; }
  .center .say { font-size: 17px; }
  .big-role b { font-size: 26px; }
}
@media (min-width: 480px) and (max-width: 699px) { .table.compact .felt { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#micBtn.live { box-shadow: 0 0 0 2px var(--ok); border-radius: 8px; }

/* Светлая тема: светлый стол */
:root[data-theme="light"] .table::before { background: radial-gradient(60% 60% at 50% 45%, #fff 0%, #ffe3e7 60%, #ffcdd4 100%); box-shadow: inset 0 0 0 2px rgba(224,40,60,.2), 0 24px 60px -24px rgba(216,31,52,.4); }
:root[data-theme="light"] :is(.center .say small, .noms) { color: var(--soft); }
:root[data-theme="light"] :is(.center .say em, .noms b) { color: #b07d00; }
:root[data-theme="light"] .night-say { color: #3b4fc4; }
:root[data-theme="light"] .lobby-c { background: rgba(255,255,255,.88); box-shadow: 0 10px 30px -12px rgba(0,0,0,.25); }
:root[data-theme="light"] .seat { box-shadow: 0 6px 18px -10px rgba(0,0,0,.3); }
:root[data-theme="light"] .seat.eye { border-color: #e0b100; }
html[lang="en"] .seat.eye::after { content: 'look at each other'; }
/* Светлая тема: панель «Правила комнаты» светло-серая — поля в ней белые с рамкой */
:root[data-theme="light"] .lset { background: #ececf1; }
:root[data-theme="light"] .lset :is(select, input:not([type=checkbox])) { background: #fff; }
