:root {
  --bg: #17121f;
  --bg2: #211a2e;
  --card: #2a2139;
  --card2: #342a47;
  --line: #43375b;
  --text: #f4eefb;
  --muted: #b3a6c7;
  --accent: #ffc94a;
  --accent-ink: #2a1d00;
  --green: #4fd18b;
  --red: #ff6b6b;
  --blue: #7cb6ff;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.screen { min-height: 100dvh; }
.center { display: grid; place-items: center; padding: 20px 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 28px; }
.intro { width: 100%; max-width: 400px; text-align: center;
  background: radial-gradient(120% 80% at 50% 0%, #3b2c58 0%, var(--card) 60%); }
.intro .logo { width: 84px; height: 84px; }
.intro h1 { font-size: 44px; font-weight: 900; letter-spacing: -1px; margin: 4px 0 6px; }
.intro p { margin: 0 0 22px; }

.field { display: block; text-align: left; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input:not([type]), select {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; background: var(--card2);
  font-weight: 650; transition: transform .06s, filter .15s, background .15s; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; filter: none; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.green { background: var(--green); color: #052313; }
.btn.red { background: var(--red); color: #2b0606; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { width: 100%; padding: 15px; font-size: 18px; border-radius: 14px; }
.btn.small { padding: 7px 11px; font-size: 14px; border-radius: 10px; }
.btn.round { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn.round.off { background: var(--red); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .btn { flex: 1; }

/* ---------- room layout ---------- */
#screen-room { display: flex; flex-direction: column; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg2); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.brand img { width: 28px; height: 28px; }
.topinfo { flex: 1; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 14px; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill.hl { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

.layout { flex: 1; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.stage { position: relative; display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 10px; }
.panel { border-left: 1px solid var(--line); background: var(--bg2); overflow-y: auto; padding: 18px; }

.grid { flex: 1; display: grid; gap: 10px; min-height: 0; align-content: center;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.tile { position: relative; background: #0e0b14; border-radius: 14px; overflow: hidden;
  border: 2px solid transparent; transition: border-color .2s, opacity .2s; }
.tile::before { content: ''; display: block; padding-top: 75%; } /* пропорция 4:3 — работает во всех браузерах */
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; background: #0e0b14; }
.tile.self video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-size: 40px; font-weight: 800;
  color: var(--muted); background: linear-gradient(160deg, #2c2240, #15111d); }
.tile.has-video .avatar { display: none; }
.tile .label { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; gap: 6px; align-items: center; }
.tile .name { background: rgba(10, 7, 15, .72); padding: 3px 9px; border-radius: 8px; font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile .badge { position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 800; }
.tile .icons { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; font-size: 14px; }
.tile .icons span { background: rgba(10, 7, 15, .72); border-radius: 7px; padding: 2px 5px; }
.tile.explainer { border-color: var(--accent); }
.tile.explainer .badge { background: var(--accent); color: var(--accent-ink); }
.tile.guesser { border-color: var(--blue); }
.tile.guesser .badge { background: var(--blue); color: #061a33; }
.tile.silenced { opacity: .78; }
.tile.offline { opacity: .4; }

.mediabar { display: flex; align-items: center; justify-content: center; gap: 10px; }
.mediainfo { font-size: 13px; color: var(--muted); }

.quiet { position: absolute; z-index: 5; top: 18px; left: 50%; transform: translateX(-50%); background: var(--red); color: #2b0606;
  padding: 8px 16px; border-radius: 999px; font-weight: 750; box-shadow: 0 6px 24px rgba(0,0,0,.4); white-space: nowrap; max-width: calc(100% - 24px);
  overflow: hidden; text-overflow: ellipsis; }

/* ---------- panel content ---------- */
.panel h2 { font-size: 22px; margin-bottom: 4px; }
.panel h3 { font-size: 15px; margin: 22px 0 10px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.sec { margin-bottom: 18px; }
.link-box { display: flex; gap: 8px; margin-top: 10px; }
.link-box input { font-size: 14px; padding: 10px 12px; }

.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 9px 12px; }
.plist li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.plist li .tag { font-size: 12px; color: var(--muted); }
.plist li .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.dot.off { background: #6c6280; }
.pair { border: 1px dashed var(--line); border-radius: 14px; padding: 6px; display: grid; gap: 6px; }
.pair-title { font-size: 12px; color: var(--muted); padding: 0 6px; }

.settings { display: grid; gap: 12px; }
.settings .field { margin: 0; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--text); }
.seg button:disabled { cursor: default; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper b { min-width: 34px; text-align: center; font-size: 18px; }
.stepper .btn { width: 38px; height: 38px; padding: 0; }
.warn { background: rgba(255, 107, 107, .12); color: #ffb3b3; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.note { background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--muted); }

/* words */
.words { display: grid; gap: 8px; margin: 14px 0; }
.words input { padding: 11px 13px; }

/* turn */
.turnhead { text-align: center; margin-bottom: 14px; }
.turnhead .who { font-size: 20px; font-weight: 800; }
.turnhead .who .arrow { color: var(--muted); margin: 0 6px; }
.round-tag { display: inline-block; background: var(--card2); border-radius: 999px; padding: 4px 12px; font-size: 13px; margin-bottom: 10px; }
.banner { text-align: center; background: linear-gradient(135deg, #4a3570, #2e2346); border-radius: 18px; padding: 18px; margin-bottom: 16px; }
.banner b { display: block; font-size: 22px; margin-bottom: 4px; }

.timer { position: relative; width: 170px; height: 170px; margin: 6px auto 16px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 10; }
.timer .track { stroke: var(--card2); }
.timer .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke .3s; }
.timer.low .bar { stroke: var(--red); }
.timer .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 54px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.low .num { color: var(--red); }

.wordcard { background: var(--text); color: #1a1326; border-radius: 20px; padding: 26px 16px; text-align: center;
  font-size: 34px; font-weight: 900; margin-bottom: 14px; word-break: break-word; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.wordcard small { display: block; font-size: 13px; font-weight: 600; color: #6b5d80; margin-bottom: 6px; }
.gbtns { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.gbtns .btn { padding: 18px 10px; font-size: 18px; border-radius: 16px; }
.counter { text-align: center; color: var(--muted); margin-top: 12px; font-size: 15px; }
.counter b { color: var(--text); font-size: 20px; }

.review { list-style: none; padding: 0; margin: 10px 0 16px; display: grid; gap: 6px; }
.review li label { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 600; }
.review li input { width: 20px; height: 20px; accent-color: var(--green); }
.review li.struck label { text-decoration: line-through; color: var(--muted); }

.score { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.score li { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 9px 12px; }
.score li .pl { width: 22px; text-align: center; color: var(--muted); font-weight: 700; }
.score li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score li .pts { font-weight: 900; font-size: 18px; }
.score li.top { background: linear-gradient(90deg, rgba(255,201,74,.25), var(--card)); }
.score li.me .nm { font-weight: 800; }

.hostbar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.hostbar .btn { flex: 1; }

.winner { text-align: center; margin: 6px 0 18px; }
.winner .cup { font-size: 56px; }
.winner b { display: block; font-size: 26px; margin-top: 6px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #fff; color: #1a1326; font-weight: 650;
  padding: 11px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); text-align: center; }
.unmute { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 40; border: 0; border-radius: 999px; padding: 12px 18px;
  background: var(--accent); color: var(--accent-ink); font-weight: 750; cursor: pointer; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  #screen-room { height: auto; min-height: 100dvh; }
  .layout { display: block; }
  .stage { padding: 8px; }
  .grid { gap: 6px; flex: none; }
  .tile { border-radius: 10px; }
  .tile .name { font-size: 12px; padding: 2px 6px; }
  .tile .badge { font-size: 10px; padding: 2px 6px; top: 5px; left: 5px; }
  .tile .avatar { font-size: 26px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 16px; }
  .topbar { padding: 8px 12px; }
  .brand b { display: none; }
  .timer { width: 140px; height: 140px; }
  .timer .num { font-size: 44px; }
  .quiet { top: 12px; font-size: 14px; }
  .wordcard { font-size: 30px; }
}

/* ---------- home: finder ---------- */
.home-wrap { width: 100%; max-width: 860px; display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }
.home-wrap .intro { max-width: none; }
.finder { padding: 22px; min-height: 300px; }
.finder-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.finder-head h2 { font-size: 22px; }
.finder-list { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.room-item { display: flex; align-items: center; gap: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.room-item .ri-main { flex: 1; min-width: 0; }
.room-item .ri-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .ri-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.room-item .btn { flex: none; }
@media (max-width: 900px) {
  .home-wrap { grid-template-columns: 1fr; }
  .center { align-items: start; }
}

/* ---------- popovers ---------- */
.popover { position: fixed; z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5); width: 300px; max-width: calc(100vw - 24px); }
.pop-title { font-weight: 800; margin-bottom: 10px; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.slider span { grid-column: 1 / -1; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); }
.slider b { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.pop-actions { display: grid; gap: 8px; margin-top: 8px; }
.tile { cursor: pointer; }
.tile .vol-ind { position: absolute; right: 8px; bottom: 8px; background: rgba(10,7,15,.72); border-radius: 7px; padding: 2px 6px; font-size: 12px; }
.rec-pill { background: var(--red); color: #2b0606; border-color: var(--red); font-weight: 800; animation: blink 1.4s infinite; }
#rec-btn.on { background: var(--red); color: #2b0606; border-color: var(--red); }
@keyframes blink { 50% { opacity: .55; } }
.pass-row { display: flex; gap: 8px; margin-top: 8px; }
.pass-row input { flex: 1; }
@media (max-width: 900px) {
  #rec-btn { padding: 7px 8px; }
}

.link-box .btn { white-space: nowrap; flex: none; }

.tile .status { position: absolute; left: 8px; right: 8px; top: 50%; transform: translateY(26px); text-align: center; font-size: 13px; font-weight: 600;
  color: var(--muted); text-shadow: 0 1px 2px rgba(0,0,0,.6); pointer-events: none; }
.tile.has-video .status { top: auto; bottom: 44px; transform: none; }
.tile.bad-link .status { color: #ffb3b3; }
@media (max-width: 900px) { .tile .status { font-size: 11px; transform: translateY(16px); } }

.mediabar .btn { flex: none; }
.mediabar .mediainfo { min-width: 0; max-width: 560px; }
@media (max-width: 900px) { .mediabar { flex-wrap: wrap; } .mediabar .mediainfo { flex-basis: 100%; text-align: center; } }

/* ---------- телефон ---------- */
.video-toggle { display: none; }
@media (max-width: 900px) {
  .grid { align-content: start; }
  .topbar { gap: 6px; flex-wrap: nowrap; }
  .topinfo { gap: 4px; font-size: 12px; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .topinfo::-webkit-scrollbar { display: none; }
  .pill { padding: 3px 8px; }
  .rec-pill { font-size: 12px; }
  #rec-btn, #vol-btn { padding: 6px 8px; font-size: 13px; }
  .tile .status { top: auto; bottom: 30px; transform: none; font-size: 10px; line-height: 1.15; }
  .tile .icons { top: 4px; right: 4px; font-size: 11px; }
  .tile .label { left: 4px; bottom: 4px; right: 4px; }
  .video-toggle { display: inline-flex; }
  .stage.collapsed .grid { display: none; }
  .btn.round { width: 42px; height: 42px; font-size: 18px; }
  .panel .words input { font-size: 16px; } /* без автозума в iPhone */
}

.popover select { font-size: 14px; padding: 9px 10px; }
.popover .field { margin-bottom: 10px; }

.brand { cursor: pointer; }
#leave-btn { white-space: nowrap; }
@media (max-width: 900px) { #leave-btn { padding: 6px 8px; font-size: 13px; } }

/* ---------- вместе, без камер ---------- */
body.novideo .stage { display: none; }
body.novideo .layout { display: block; }
body.novideo .panel { max-width: 620px; margin: 0 auto; border-left: 0; height: 100%; }
body.novideo #vol-pop .field, body.novideo #vol-pop .pop-title:nth-of-type(2) { display: none; }
.gbtns.noskip { grid-template-columns: 1fr; }

.mode-seg button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; font-size: 15px; }
.mode-seg button small { font-size: 12px; font-weight: 500; color: var(--muted); }
.mode-seg button.on small { color: var(--text); opacity: .8; }
