/* «Угадай кто» поверх общих стилей 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; }

/* ---------- Вход ---------- */
.set-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.set-opt { border: 2px solid transparent; background: var(--surface-2); border-radius: 12px; padding: 6px; cursor: pointer; display: grid; gap: 6px; text-align: center; color: var(--text); }
.set-opt.active { border-color: var(--accent); }
.set-opt:disabled { cursor: default; }
.set-opt .cov { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.set-opt .cov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.set-opt b { font-size: 13px; line-height: 1.15; }
.set-opt span { font-size: 11px; color: var(--muted); }
.create-modes { margin: 0 0 14px; }
.create-modes .mode, .lobby .mode { background: var(--surface-2); padding: 12px; }
.create-modes .mode span { font-size: 12.5px; }

/* ---------- Сцена ---------- */
.gstage { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; }
.lobby { display: grid; gap: 10px; }
.lobby h2 { font-size: 17px; margin: 0 0 10px; }
.lobby h2 + .set-pick, .lobby .modes { margin-bottom: 14px; }
.lobby-note { margin: 8px 0 0; font-size: 14px; }
.result-banner { background: linear-gradient(135deg, #3a0d14, #1c1c21); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.result-banner b { color: #ffd21f; }
.queue { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; counter-reset: q; }
.queue li { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; counter-increment: q; }
.queue li::before { content: counter(q); width: 18px; font: 900 14px var(--font); color: var(--muted); text-align: center; }
.queue li.next::before { color: #ffd21f; }
.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 { font-size: 11px; font-weight: 800; color: var(--muted); }
.queue .tag.play { color: var(--ok); }
.queue .mv { display: flex; gap: 4px; }
.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: 1fr 1fr; gap: 12px; }
.settings .check { grid-column: 1 / -1; padding: 0; }

/* ---------- Дуэль ---------- */
.duel { display: flex; flex-direction: column; gap: 10px; }
.duel-side { display: contents; }
.duelist { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 8px 10px; border: 2px solid transparent; transition: border-color .2s; }
.duelist.turn { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(224,40,60,.18); }
.duelist .cam { width: 54px; height: 54px; border-radius: 12px; overflow: hidden; flex: none; background: #0d0d0f; display: grid; place-items: center; position: relative; }
.duelist .cam video { width: 100%; height: 100%; object-fit: cover; }
.duelist.mine .cam video { transform: scaleX(-1); }
.duelist .cam .ava { --s: 54px; border-radius: 12px; }
.duelist .info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.duelist .nm { font-weight: 800; font-size: 15px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.duelist .nm span { overflow: hidden; text-overflow: ellipsis; }
.duelist .sub { font-size: 12.5px; color: var(--muted); }
.duelist .sub b { color: var(--text); }
.wins { display: flex; gap: 4px; }
.wins i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); }
.wins i.on { background: #ffd21f; box-shadow: 0 0 8px rgba(255,210,31,.6); }
.secret-card { flex: none; width: 64px; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 2px solid #ffd21f; cursor: zoom-in; padding: 0; color: var(--text); position: relative; }
.secret-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.secret-card span { display: block; font: 800 10.5px/1.2 var(--font); padding: 3px 2px 4px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.secret-card::before { content: 'Вы'; position: absolute; top: 3px; left: 3px; font: 900 9px var(--font); background: #ffd21f; color: #111; border-radius: 4px; padding: 1px 4px; }
.secret-card.hidden-secret img { filter: blur(10px); }

.action { background: var(--surface); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.action .say { font: 800 16px/1.3 var(--font); text-align: center; }
.action .say small { display: block; font: 600 13px var(--font); color: var(--muted); margin-top: 3px; }
.action .qbubble { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font: 800 17px/1.3 var(--font); text-align: center; overflow-wrap: anywhere; }
.action .ans-big { font: 900 30px var(--font); text-align: center; letter-spacing: .02em; }
.ans-big.yes { color: var(--ok); } .ans-big.no { color: var(--accent); } .ans-big.unsure { color: var(--warn); }
.action .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action .row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.action .btn { width: 100%; padding: 14px 10px; font-size: 15px; }
.btn.yes { background: var(--ok); color: #06200f; }
.btn.no { background: var(--accent); color: #fff; }
.btn.unsure { background: var(--surface-3); }
.btn.guess { background: #ffd21f; color: #111; }
.btn.guess.on { box-shadow: 0 0 0 3px #fff; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; min-width: 0; font-size: 16px; }
.ask-form .btn { width: auto; flex: none; }
.hint-line { font-size: 12.5px; color: var(--muted); text-align: center; }
.timer-line { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.timer-line div { height: 100%; background: #fff; border-radius: inherit; }
.timer-line.low div { background: var(--accent); }

.board-wrap { display: grid; gap: 8px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; padding: 0 2px; }
.board-tools { display: flex; gap: 6px; }
.board-tools .btn { padding: 6px 10px; font-size: 12.5px; }
.gboard { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.gcard { position: relative; border: 0; padding: 0; background: var(--surface); border-radius: 10px; overflow: hidden; cursor: pointer; color: var(--text); text-align: center;
  transition: transform .15s, opacity .2s, filter .2s; -webkit-tap-highlight-color: transparent; }
.gcard img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #0d0d0f; }
.gcard .cn { display: block; font: 800 11px/1.15 var(--font); padding: 4px 3px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gcard.down { opacity: .28; filter: grayscale(1); }
.gcard.down::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(255,255,255,.07) 10px 20px); }
.gcard.static { cursor: default; }
.gcard:active:not(.static) { transform: scale(.96); }
.guess-mode .gcard:not(.down) { box-shadow: 0 0 0 2px #ffd21f; animation: wiggle 1.4s ease-in-out infinite; }
.guess-mode .gcard.down { pointer-events: none; }
@keyframes wiggle { 50% { transform: rotate(-1.2deg); } }
.gcard.mine-secret::before { content: 'Вы'; position: absolute; top: 4px; left: 4px; z-index: 1; font: 900 9px var(--font); background: #ffd21f; color: #111; border-radius: 4px; padding: 1px 4px; }

.log { background: var(--surface); border-radius: 14px; padding: 10px 12px; }
.log summary { cursor: pointer; font-weight: 800; font-size: 14px; list-style: none; }
.log summary::-webkit-details-marker { display: none; }
.log summary::after { content: ' ▾'; color: var(--muted); }
.log ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.log li { font-size: 13.5px; display: flex; gap: 8px; align-items: baseline; }
.log li b { flex: none; }
.log li .q { flex: 1; min-width: 0; color: #d4d4d8; overflow-wrap: anywhere; }
.log li .a { flex: none; font-weight: 900; }
.a.yes { color: var(--ok); } .a.no { color: var(--accent); } .a.unsure { color: var(--warn); }
.log .empty-log { color: var(--muted); font-size: 13px; }

/* Зрители и очередь с камерами */
.watchers { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.watchers:empty { display: none; }
.wtile { flex: none; width: 92px; background: var(--surface); border-radius: 10px; overflow: hidden; position: relative; }
.wtile .cam { aspect-ratio: 4/3; display: grid; place-items: center; background: #0d0d0f; }
.wtile video { width: 100%; height: 100%; object-fit: cover; }
.wtile .ava { --s: 38px; }
.wtile .nm { font: 800 11px var(--font); padding: 4px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.wtile .tile-actions { position: absolute; top: 3px; right: 3px; display: none; flex-direction: column; gap: 3px; }
.wtile.touch .tile-actions { display: flex; }
.duelist .tile-actions { display: none; gap: 4px; }
.duelist.touch .tile-actions { display: flex; }

/* Итоги и подтверждение */
.overlay-sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.7); display: grid; align-items: end; justify-items: center; padding: 0; }
.sheet { width: min(560px, 100%); background: var(--surface); border-radius: 18px 18px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 14px; text-align: center; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0; font: 900 26px/1.1 var(--font); }
.sheet .reason { color: var(--muted); font-size: 14px; }
.reveal-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reveal-card { background: var(--surface-2); border-radius: 12px; padding: 8px; display: grid; gap: 6px; }
.reveal-card.win { box-shadow: inset 0 0 0 2px #ffd21f; }
.reveal-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }
.reveal-card b { font-size: 15px; }
.reveal-card span { font-size: 12px; color: var(--muted); }
.sheet .score { font: 900 34px var(--font); }
.sheet .score i { font-style: normal; color: var(--muted); margin: 0 8px; }
.sheet .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .btns .btn { width: 100%; padding: 14px; }
.guess-card { width: 150px; justify-self: center; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 3px #ffd21f; }
.guess-card img { width: 100%; display: block; }
.confetti { font-size: 40px; line-height: 1; }

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

@media (max-width: 760px) {
  .topbar { gap: 4px; padding: 8px 8px; overflow-x: auto; scrollbar-width: none; }
  .topbar .logo.small, .topbar .set-chip { 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; }
  .gstage { padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
}
@media (max-width: 380px) {
  .set-opt b { font-size: 12px; }
  .create-modes .mode span { display: none; }
  .action .btn { padding: 13px 6px; font-size: 14px; }
}

/* ---------- Планшет ---------- */
@media (min-width: 640px) {
  .gboard { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  .gcard .cn { font-size: 12px; }
  .overlay-sheet { align-items: center; padding: 16px; }
  .sheet { border-radius: 18px; }
  .lobby { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
}

/* ---------- Компьютер: панель слева, поле справа ---------- */
@media (min-width: 1000px) {
  #game { height: 100vh; height: 100dvh; }
  .gstage { padding: 12px; }
  .duel { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 12px; align-items: start; }
  .duel-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
  .duelist .cam, .duelist .cam .ava { width: 84px; height: 84px; --s: 84px; }
  .secret-card { width: 84px; }
  .board-wrap { min-height: 0; }
  .gboard { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .gcard:hover:not(.static):not(.down) { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.4); }
  .log ol { max-height: 30vh; }
  .lobby { width: min(1100px, 100%); margin: 0 auto; }
}
@media (min-width: 1400px) { .gboard { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* Ничто не шире экрана */
.lobby > *, .duel > *, .gstage > * { min-width: 0; }
.settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings select, .settings input:not([type=checkbox]) { width: 100%; min-width: 0; }
.settings label:not(.check) { grid-column: auto; }
.set-pick { display: grid; gap: 8px; margin-bottom: 14px; grid-template-columns: 1fr; }
.set-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.set-more { width: 100%; }
.set-own-link { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; justify-self: start; }
.set-own-link:hover { color: var(--text); }

/* ---------- Порядок на телефоне и планшете: поле сразу под панелью хода ---------- */
@media (max-width: 999px) {
  #oppBox { order: 1; }
  #meBox { order: 2; }
  .action { order: 3; }
  .board-wrap { order: 4; }
  .log { order: 5; }
  .duelist { padding: 6px 8px; }
  .duelist .cam, .duelist .cam .ava { width: 46px; height: 46px; --s: 46px; }
  .secret-card { width: 56px; }
}
/* Телефон горизонтально: панель слева, поле справа — как на компьютере */
@media (min-width: 640px) and (max-width: 999px) and (orientation: landscape) and (max-height: 560px) {
  .duel { display: grid; grid-template-columns: minmax(250px, 34%) minmax(0, 1fr); gap: 8px; align-items: start; }
  .duel-side { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 8px; }
  .gboard { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  .gcard .cn { font-size: 10px; padding: 3px 2px 4px; }
  .action { padding: 10px; gap: 8px; }
  .action .btn { padding: 11px 8px; }
  .action .say { font-size: 14px; }
  .log ol { max-height: 120px; }
}
:root[data-theme="light"] .queue .tag.play { color: #0f6e3d; }
html[lang="en"] .secret-card::before, html[lang="en"] .gcard.mine-secret::before { content: 'You'; }
