/* «Кто я?» поверх общих стилей FUNBASE. Сначала телефон, потом шире */
#game { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.card-flat { background: var(--surface); border-radius: 14px; padding: 16px; }
.muted-text { color: var(--muted); font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.wstage { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; }
.wstage > * { min-width: 0; }

/* Лобби */
.lobby { display: grid; gap: 10px; }
.lobby h2 { font-size: 17px; margin: 0 0 10px; }
.lobby-note { margin: 8px 0 0; font-size: 14px; }
.result-banner { background: linear-gradient(135deg, #3a2d0d, #1c1c21); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.result-banner b { color: #ffd84a; }
.how { display: grid; gap: 8px; margin-bottom: 14px; }
.how div { display: flex; align-items: center; gap: 12px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; }
.how b { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font: 900 14px var(--font); }
.cam-tip { background: #2b2410; border: 1px solid #5a4a14; color: #ffe9a3; border-radius: 12px; padding: 12px; font-size: 13.5px; font-weight: 600; margin-bottom: 14px; display: grid; gap: 10px; }
.cam-tip .btn { justify-self: start; }
.self-prev { position: relative; width: min(260px, 100%); aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #0d0d0f; margin-bottom: 14px; }
.self-prev video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.self-prev span { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px; font-size: 12px; font-weight: 700; background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.action [data-camon] { justify-self: center; }
.queue { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.queue li { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.queue .n { flex: 1; min-width: 0; font-weight: 800; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
.queue .n span { overflow: hidden; text-overflow: ellipsis; }
.queue .tag, .tag { font-size: 11px; font-weight: 800; color: var(--muted); }
.queue .mv button { border: 0; background: var(--surface-3); color: var(--text); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.queue li.off { opacity: .45; }
.seat-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings .check { grid-column: 1 / -1; padding: 0; }
.settings select, .settings input:not([type=checkbox]) { width: 100%; min-width: 0; }

/* Категории */
.themes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.theme { border: 2px solid transparent; background: var(--surface-2); color: var(--muted); border-radius: 99px; padding: 8px 14px; font: 700 13px var(--font); cursor: pointer; }
.theme .cnt { font-size: 11px; opacity: .7; margin-left: 2px; }
.theme:hover:not(:disabled) { background: var(--surface-3); }
.theme.active { border-color: #ffd84a; background: #2b2410; color: var(--text); }
.theme:disabled { cursor: default; }

/* ---------- Верхняя панель, чат, громкость ---------- */
#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; }

/* ---------- Игра ---------- */
.play { display: flex; flex-direction: column; gap: 10px; }
.tiles-col, .panel-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.round-line { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.round-line b { color: var(--text); }
.round-line .timer-line { flex: 1; min-width: 60px; }
.timer-line { display: block; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.timer-line i { display: block; height: 100%; width: 0; background: #fff; border-radius: inherit; }
.timer-line.low i { background: var(--accent); }

/* Плитки с видео */
.wtiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wtile { position: relative; background: var(--surface); border-radius: 14px; overflow: hidden; border: 2px solid transparent; transition: border-color .2s, box-shadow .2s; }
.wtile .cam { position: relative; aspect-ratio: 4 / 3; background: #0d0d0f; display: grid; place-items: center; overflow: hidden; }
.wtile .cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wtile.me .cam video { transform: scaleX(-1); }
.wtile .cam .ava { --s: 56px; }
.wtile .ava-box { position: absolute; inset: 0; display: grid; place-items: center; padding-top: 18%; }
.pinfo { padding: 6px 8px 8px; display: grid; gap: 1px; min-width: 0; }
.pinfo b { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pinfo .you { font: 900 9px var(--font); background: #ffd84a; color: #111; border-radius: 4px; padding: 1px 4px; vertical-align: 2px; }
.pinfo small { font-size: 11.5px; color: var(--muted); font-weight: 700; min-height: 1em; }
.wtile.turn { border-color: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.12); }
.wtile.turn .pinfo small { color: #fff; }
.wtile.off { opacity: .45; }
.wtile.done-guessed { border-color: var(--ok); }
.wtile.done-guessed .pinfo small { color: var(--ok); }
.wtile.done-gave .pinfo small { color: var(--accent-hover); }
.wtile .tile-actions { position: absolute; top: 4px; right: 4px; display: none; flex-direction: column; align-items: flex-end; gap: 3px; z-index: 3; }
.wtile.touch .tile-actions { display: flex; }
@media (hover: hover) { .wtile:hover .tile-actions { display: flex; } }
.wtile.flash-win { animation: fwin 1.2s ease-out; }
.wtile.flash-bad { animation: fbad .8s ease-out; }
@keyframes fwin { 0% { box-shadow: 0 0 0 0 rgba(47,208,122,.9); } 100% { box-shadow: 0 0 0 26px rgba(47,208,122,0); } }
@keyframes fbad { 0%, 60% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: none; } }

/* Карточка-стикер на лбу */
.fnote { position: absolute; z-index: 2; pointer-events: none; background: #ffd84a; color: #1a1400; border-radius: 4px; padding: .35em .45em .4em;
  font: 900 16px/1.05 var(--font); text-transform: uppercase; text-align: center; letter-spacing: -.01em; width: max-content; overflow-wrap: normal;
  box-shadow: 0 6px 16px rgba(0,0,0,.45), inset 0 -3px 0 rgba(0,0,0,.08); will-change: transform, left, top; }
.fnote::before { content: ''; position: absolute; left: 50%; top: -6px; width: 38%; height: 11px; transform: translateX(-50%) rotate(-2deg); background: rgba(255,255,255,.55); border-radius: 2px; }
.fnote.mine { background: linear-gradient(145deg, var(--accent), #8e1523); color: #fff; font-size: 30px; }
.fnote.ok { background: #9ef0c0; color: #06200f; }
.fnote.none { display: none; }
/* Нет лица на видео — стикер просто сверху плитки */
.fnote.static { left: 50%; top: 8%; width: auto; max-width: 84%; transform: translateX(-50%) rotate(-3deg); font-size: clamp(13px, 2.2vw, 22px); }
.fnote.static.mine { font-size: clamp(22px, 3.4vw, 34px); padding: .2em .8em; }
.abadge { position: absolute; left: 6px; bottom: 6px; z-index: 3; display: none; font: 900 13px var(--font); text-transform: uppercase; border-radius: 8px; padding: 4px 9px; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.abadge.show { display: block; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.a-yes { background: var(--ok); color: #06200f; }
.a-no { background: var(--accent); color: #fff; }
.a-idk { background: #5a5a66; color: #fff; }
.a-got { background: #ffd84a; color: #1a1400; }

/* Панель действий */
.action { background: var(--surface); border-radius: 16px; padding: 14px; display: grid; gap: 10px; align-content: center; }
.action .say { font: 800 18px/1.3 var(--font); text-align: center; }
.action .say small { display: block; font: 600 13px var(--font); color: var(--muted); margin-top: 4px; }
.action .say small b { color: #ffd84a; }
.action .left { text-align: center; font: 900 22px var(--font); font-variant-numeric: tabular-nums; color: var(--muted); }
.action .ghost { justify-self: center; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .btn { width: 100%; padding: 13px 10px; }
.owner-row { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.hint-line { font-size: 12.5px; color: var(--muted); text-align: center; }
.mycat { text-align: center; font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.mycat b { color: #ffd84a; }
.mycat.good b { color: var(--ok); }
.answers { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 30px; }
.answers .ans { font-size: 13px; font-weight: 700; border-radius: 99px; padding: 5px 10px; }
.answers .muted { font-size: 13px; align-self: center; }
.abtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.abtns .btn { width: 100%; padding: 15px 8px; font-size: 16px; font-weight: 900; }
.abtns .btn.on.ab-yes { background: var(--ok); color: #06200f; }
.abtns .btn.on.ab-no { background: var(--accent); color: #fff; }
.abtns .btn.on.ab-idk { background: #5a5a66; color: #fff; }
.abtns .btn.on.ab-got { background: #ffd84a; color: #1a1400; }
.guess-form { display: flex; gap: 8px; }
.guess-form input { flex: 1; min-width: 0; width: 100%; font-size: 16px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.results li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.results .n { display: flex; align-items: center; gap: 8px; font-weight: 800; min-width: 0; overflow: hidden; white-space: nowrap; }
.results .n span { overflow: hidden; text-overflow: ellipsis; }
.results b { color: #ffd84a; text-align: right; }
.results small { grid-column: 1 / -1; color: var(--muted); font-weight: 700; font-size: 12px; }
.results li.first { box-shadow: inset 0 0 0 2px var(--ok); }

/* Ход игры */
.log h3 { margin: 0 0 8px; }
.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.log li { font-size: 13.5px; }
.log li b { margin-right: 4px; }
.log li span b { color: #ffd84a; }

/* ---------- Телефон ---------- */
@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; }
  .chat-form { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .vol-pop { position: fixed; left: 10px; right: 10px; top: 56px; width: auto; }
  .wstage { padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .toast { text-align: center; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .wtile .pinfo small { font-size: 11px; }
}
@media (max-width: 380px) { .wtiles { gap: 6px; } .pinfo b { font-size: 12px; } }

/* ---------- Планшет ---------- */
@media (min-width: 640px) {
  .lobby { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .how { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .how div { flex-direction: column; align-items: flex-start; }
  .wtiles[data-n="5"], .wtiles[data-n="6"], .wtiles[data-n="7"], .wtiles[data-n="8"], .wtiles[data-n="9"], .wtiles[data-n="10"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Компьютер: плитки слева, панель справа ---------- */
@media (min-width: 1000px) {
  #game { height: 100vh; height: 100dvh; }
  .wstage { padding: 12px; overflow: auto; }
  .play { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; align-items: start; width: min(1500px, 100%); margin: 0 auto; }
  .panel-col { position: sticky; top: 0; }
  .wtiles[data-n="7"], .wtiles[data-n="8"], .wtiles[data-n="9"], .wtiles[data-n="10"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .log ol { max-height: 36vh; }
  .lobby { width: min(1100px, 100%); margin: 0 auto; }
}
/* Телефон горизонтально */
@media (max-width: 999px) and (orientation: landscape) and (max-height: 560px) {
  .play { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .wtiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Устная игра: у отвечающих одна кнопка — «Угадал!» */
.action .btn.ab-got { width: 100%; padding: 16px; font-size: 17px; font-weight: 900; }
.action .btn.ab-got.on { background: #ffd84a; color: #1a1400; }

/* Светлая тема */
:root[data-theme="light"] .theme.active { border-color: #e0b100; background: #fff4cc; }
:root[data-theme="light"] .result-banner { background: linear-gradient(135deg, #fff4cc, var(--surface)); }
:root[data-theme="light"] :is(.result-banner b, .action .say small b, .mycat b, .results b, .log li span b) { color: #a86f00; }
:root[data-theme="light"] .cam-tip { background: #fff4cc; border-color: #e8c95a; color: #5c4600; }
:root[data-theme="light"] .chat-msg.mine { background: #fde2e5; }
:root[data-theme="light"] .chat-msg.mine b { color: #c0162b; }
:root[data-theme="light"] .timer-line i { background: var(--text); }
:root[data-theme="light"] .wtile.turn { border-color: var(--text); box-shadow: 0 0 0 4px rgba(0,0,0,.1); }
:root[data-theme="light"] .wtile.turn .pinfo small { color: var(--text); }
