/* «Шпион» поверх общих стилей 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; }
.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; }
#createTheme { width: 100%; }
.sstage { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px; min-height: 0; }
.sstage > * { min-width: 0; }

/* Лобби */
.lobby { display: grid; gap: 10px; }
.lobby h2 { font-size: 17px; margin: 0 0 10px; }
.lobby .pools { 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; }
.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); }
.miccheck { background: var(--surface-2); border-radius: 12px; padding: 12px; display: grid; gap: 10px; margin-bottom: 16px; }
.mc-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.mc-head span { color: var(--muted); font-size: 13px; }
.miccheck[data-ok="1"] .mc-head span { color: var(--ok); }
.miccheck[data-ok="0"] .mc-head span { color: var(--accent-hover); }
.miccheck .meter { background: var(--surface-3); }
.miccheck .btn { justify-self: start; }
.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); }
.tag.you { color: #111; background: #ffd21f; border-radius: 99px; padding: 2px 8px; }
.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; }

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


/* Темы */
.themes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.theme { border: 2px solid transparent; background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 8px 14px; font: 700 13px var(--font); cursor: pointer; }
.theme:hover:not(:disabled) { background: var(--surface-3); }
.theme.active { border-color: var(--accent); background: #3a0d14; }
.theme.rnd { border-style: dashed; border-color: var(--surface-3); }
.theme.rnd.active { border-style: solid; border-color: var(--accent); }
.theme:disabled { cursor: default; opacity: .75; }
.theme.active:disabled { opacity: 1; }
.lobby .modes { margin-bottom: 14px; }

/* ---------- Игра ---------- */
.play { display: flex; flex-direction: column; gap: 10px; }
.main-col, .side-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; }
.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); }
.card-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.card-row > * { min-width: 0; }

/* Карточка */
.scard { position: relative; overflow: hidden; border: 0; cursor: pointer; text-align: left; color: #111; border-radius: 18px; padding: 18px 18px 38px; min-height: 170px;
  display: grid; align-content: start; gap: 8px; background: linear-gradient(145deg, #fff 0%, #ececf0 100%); box-shadow: 0 18px 40px rgba(0,0,0,.35); -webkit-tap-highlight-color: transparent; }
.scard .theme-l { font: 800 12px var(--font); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.scard b { font: 900 clamp(28px, 8.5vw, 46px)/1 var(--font); text-transform: uppercase; letter-spacing: -.02em; overflow-wrap: anywhere; }
.scard small { font: 600 13px/1.35 var(--font); color: #55555c; max-width: 420px; }
.scard .hide-l { position: absolute; right: 14px; bottom: 12px; font: 700 11px var(--font); color: #8a8a92; }
.scard.is-spy { background: linear-gradient(145deg, var(--accent) 0%, #8e1523 100%); color: #fff; }
.scard.is-spy .theme-l { color: #ffd0d6; }
.scard.is-spy small, .scard.is-spy .hide-l { color: #ffd0d6; }
.scard.is-watch { background: var(--surface-2); color: var(--text); }
.scard.is-watch small { color: var(--muted); }
.scard .cover { position: absolute; inset: 0; display: none; place-items: center; align-content: center; gap: 8px; background: repeating-linear-gradient(135deg, #1f1f24 0 14px, #26262c 14px 28px); color: var(--muted); font: 700 13px var(--font); text-align: center; padding: 16px; }
.scard .cover svg { width: 30px; height: 30px; }
.scard.closed .cover { display: grid; }

.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.good { color: var(--ok); } .action .say.bad { color: var(--accent-hover); }
.action .btn.big { padding: 15px; }
.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: 14px 10px; }
.hint-line { font-size: 12.5px; color: var(--muted); text-align: center; }
.clue-form { display: flex; gap: 8px; }
.clue-form input { flex: 1; min-width: 0; width: 100%; font-size: 16px; }

/* Подсказки */
.clues h3 { margin: 0 0 8px; }
.clues ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.clues li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.clues li b { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clues li span { min-width: 0; overflow-wrap: anywhere; color: #e4e4e7; }
.clues li .muted, .clues li.muted { color: var(--muted); }
.clues li.rnd { font: 800 11px var(--font); text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-top: 4px; }

/* Плитки игроков */
.ptiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ptile { position: relative; background: var(--surface); border-radius: 14px; overflow: hidden; border: 2px solid transparent; transition: border-color .2s, transform .1s, box-shadow .2s; }
.ptile .cam { aspect-ratio: 4 / 3; background: #0d0d0f; display: grid; place-items: center; }
.ptile .cam video { width: 100%; height: 100%; object-fit: cover; }
.ptile .cam .ava { --s: 44px; }
.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: #ffd21f; color: #111; border-radius: 4px; padding: 1px 4px; vertical-align: 2px; }
.pinfo small { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.ptile.turn { border-color: #fff; box-shadow: 0 0 0 4px rgba(255,255,255,.12); }
.ptile.turn .pinfo small { color: #fff; }
.ptile.off { opacity: .45; }
.ptiles.voting .ptile.votable { cursor: pointer; }
.ptiles.voting .ptile.votable:hover { border-color: var(--surface-3); }
.ptiles.voting .ptile.votable:active { transform: scale(.97); }
.ptile.lead { box-shadow: 0 0 0 3px #ffd21f; }
.ptile.picked { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(224,40,60,.25); }
.ptile.picked::after { content: 'ваш голос'; position: absolute; top: 6px; left: 6px; font: 900 10px var(--font); text-transform: uppercase; background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 6px; }
.ptile .rev { position: absolute; top: 6px; right: 6px; font: 900 10px var(--font); text-transform: uppercase; border-radius: 6px; padding: 3px 7px; background: var(--ok); color: #06200f; }
.ptile.rev-spy { border-color: var(--accent); }
.ptile.rev-spy .rev { background: var(--accent); color: #fff; }
.ptile .tile-actions { position: absolute; top: 4px; right: 4px; display: none; flex-direction: column; gap: 3px; }
.ptile.touch .tile-actions { display: flex; }
.ptiles.voting .ptile.touch .tile-actions { display: none; }

/* Вскрытие */
.overlay-sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.72); display: grid; align-items: end; justify-items: center; }
.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); text-transform: uppercase; }
.sheet .reason { color: var(--muted); font-size: 14px; }
.sheet .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .btns.one { grid-template-columns: 1fr; }
.sheet .btns .btn { width: 100%; padding: 14px; }
.flips { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; perspective: 800px; }
.flip { width: 150px; min-height: 170px; border-radius: 16px; padding: 16px 10px; display: grid; justify-items: center; align-content: center; gap: 8px; animation: flip .6s ease-out both; }
.flip b { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flip span { font: 900 14px var(--font); text-transform: uppercase; letter-spacing: .06em; }
.flip.ok { background: var(--surface-2); }
.flip.ok span { color: var(--ok); }
.flip.spy { background: linear-gradient(145deg, var(--accent), #8e1523); color: #fff; box-shadow: 0 16px 40px rgba(224,40,60,.4); }
.flip.wait { background: var(--surface-2); color: var(--muted); animation: pulse 1s ease-in-out infinite; }
.flip.wait b { font-size: 40px; }
@keyframes flip { from { transform: rotateY(90deg); opacity: 0; } }
@keyframes pulse { 50% { opacity: .5; } }
.word { font-size: 16px; }
.word b { font: 900 22px var(--font); text-transform: uppercase; }
.word span { color: var(--muted); }

/* ---------- Телефон ---------- */
@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; }
  .sstage { 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; }
  /* Порядок: карточка, действие, игроки (голосование), подсказки */
  .play { display: flex; }
  .main-col { display: contents; }
  .round-line { order: 1; } .card-row { order: 2; } .side-col { order: 3; } .clues { order: 4; }
  .scard { min-height: 140px; }
}
@media (max-width: 380px) { .ptiles { gap: 6px; } .pinfo b { font-size: 12px; } .flip { width: 130px; } }

/* ---------- Планшет ---------- */
@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; }
  .card-row { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .ptiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .overlay-sheet { align-items: center; padding: 16px; }
  .sheet { border-radius: 18px; }
}

/* ---------- Компьютер: игра слева, игроки справа ---------- */
@media (min-width: 1000px) {
  #game { height: 100vh; height: 100dvh; }
  .sstage { padding: 12px; overflow: auto; }
  .play { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; align-items: start; width: min(1240px, 100%); margin: 0 auto; }
  .ptiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side-col { position: sticky; top: 0; }
  .scard { min-height: 220px; padding: 22px 22px 40px; }
  .clues ol { max-height: 40vh; }
  .lobby { width: min(1100px, 100%); margin: 0 auto; }
}
@media (min-width: 1400px) { .play { grid-template-columns: minmax(0, 1fr) 460px; } .ptiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Телефон горизонтально */
@media (max-width: 999px) and (orientation: landscape) and (max-height: 560px) {
  .card-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ptiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .scard { min-height: 120px; }
}
.settings .set-note { grid-column: 1 / -1; margin: -6px 0 0; color: var(--warn); }

/* Светлая тема */
:root[data-theme="light"] .theme.active { background: #fde2e5; }
html[lang="en"] .ptile.picked::after { content: 'your vote'; }
