/* Телефон прежде всего: одна колонка, крупные кнопки, статус цветом. */
:root {
  --bg: #eef0f6;
  --surface: #ffffff;
  --surface-2: #f5f6fa;
  --line: #dde1ec;
  --ink: #151a2d;
  --muted: #5c6379;
  --accent: #3157f5;
  --accent-ink: #ffffff;
  --ok: #18865a;
  --ok-bg: #e2f5ec;
  --warn: #a8640a;
  --warn-bg: #fdf0da;
  --bad: #c7362f;
  --bad-bg: #fde6e4;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1220;
    --surface: #181c2e;
    --surface-2: #1f2438;
    --line: #2c3250;
    --ink: #e8ebf6;
    --muted: #9aa1b9;
    --accent: #6e8cff;
    --accent-ink: #0b0f22;
    --ok: #4cc993;
    --ok-bg: #12352a;
    --warn: #f0b155;
    --warn-bg: #3a2b12;
    --bad: #ff7b72;
    --bad-bg: #3d1a1a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.wrap { max-width: 560px; margin: 0 auto; display: grid; gap: 14px; padding-top: 14px; }
.wrap.wide { max-width: 900px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
header.top h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.who { color: var(--muted); font-size: 14px; text-align: right; }
h2 { font-size: 18px; margin: 0; text-wrap: balance; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.step { display: grid; gap: 8px; }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.choice {
  display: grid; gap: 2px; text-align: left;
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 12px; padding: 12px; font: inherit; cursor: pointer;
}
.choice small { color: var(--muted); font-size: 13px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.choice:disabled { opacity: .5; cursor: not-allowed; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: 600 16px var(--font); cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .choice:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }
.stack { display: grid; gap: 8px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: 16px var(--font); color: var(--ink); background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.accent { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--accent); }
.notice { border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.rules { white-space: pre-line; background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: 15px; max-height: 50vh; overflow: auto; }
.photo-drop {
  display: grid; place-items: center; gap: 6px; text-align: center;
  border: 2px dashed var(--line); border-radius: 14px; padding: 22px 14px; cursor: pointer; background: var(--surface-2);
}
.photo-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: #000; }
.timer { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.checkline input { width: 22px; height: 22px; margin: 0; flex: none; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); z-index: 50; }
/* админка */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab { flex: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: 600 15px var(--font); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.req { border-left: 4px solid var(--line); }
.req.st-pending { border-left-color: var(--accent); }
.req.st-finished { border-left-color: var(--warn); }
.req.overdue { border-left-color: var(--bad); }
.req-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.req-head .name { font-weight: 700; font-size: 17px; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.qr-img { width: 100%; max-height: 360px; object-fit: contain; border-radius: 12px; background: #000; cursor: zoom-in; }
.console-group { display: grid; gap: 10px; }
.slot { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.hist { display: grid; gap: 0; }
.hist-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.hist-row:first-child { border-top: 0; }
.cons-row { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 60; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; }
a { color: var(--accent); }
/* админка: колонка «Играют» справа на широком экране */
.wrap.xwide { max-width: 1280px; }
.admin-grid { display: grid; gap: 14px; }
.admin-main, .admin-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.admin-side { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.big-num { font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
@media (min-width: 1000px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
  .admin-side { display: grid; position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; }
  .tab-playing { display: none; }
}
.playing-page .console-group { break-inside: avoid; }
@media (min-width: 900px) { .playing-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; align-items: start; } }
/* доступы */
.acc { display: grid; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.acc.off { opacity: .6; }
.cred { font: 600 15px ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .02em; }
.copybox { white-space: pre-line; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .choice { flex: 1 1 0; text-align: center; padding: 10px; }
/* клиент: переключатель П2/П3 сверху */
.kind-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.kind-switch button { border: 0; border-radius: 10px; padding: 10px 8px; font: 700 17px var(--font); background: transparent; color: var(--muted); cursor: pointer; display: grid; gap: 1px; }
.kind-switch button small { font-weight: 500; font-size: 12px; }
.kind-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.kind-switch button:disabled { opacity: .45; cursor: not-allowed; }
.kind-switch.single { grid-template-columns: 1fr; }

/* ---------- чат поддержки */
body.has-sup { padding-bottom: 84px; }
.sup-fab { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 20px rgba(20,30,80,.28); cursor: pointer; z-index: 45; }
.sup-fab.on { opacity: .85; }
.sup-fab:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.sup-badge { position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.sup-badge[hidden] { display: none; }
.sup-panel { position: fixed; right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); width: 370px; max-width: calc(100vw - 32px); height: min(560px, calc(100dvh - 120px)); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 16px 48px rgba(10,15,40,.3); display: flex; flex-direction: column; overflow: hidden; z-index: 46; }
.sup-panel[hidden] { display: none; }
.sup-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sup-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.sup-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.sup-msg { display: flex; flex-direction: column; max-width: 85%; }
.sup-msg.in { align-self: flex-start; }
.sup-msg.out { align-self: flex-end; align-items: flex-end; }
.sup-who { font-size: 12px; color: var(--muted); margin: 0 4px 2px; }
.sup-bubble { padding: 9px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.4; }
.sup-msg.out .sup-bubble { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.sup-bubble img { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin-bottom: 4px; }
.sup-time { font-size: 11px; color: var(--muted); margin: 2px 4px 0; }
.sup-form { display: flex; align-items: flex-end; gap: 6px; padding: 8px; border-top: 1px solid var(--line); background: var(--surface); }
.sup-form.busy { opacity: .6; pointer-events: none; }
.sup-form textarea { flex: 1; resize: none; min-height: 42px; max-height: 120px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px; }
.sup-cam, .sup-send { width: 42px; height: 42px; flex: none; border-radius: 12px; border: 0; display: grid; place-items: center; cursor: pointer; }
.sup-cam { background: var(--surface-2); color: var(--ink); }
.sup-send { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 520px) {
  .sup-panel { left: 8px; right: 8px; width: auto; max-width: none; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); height: calc(100dvh - 100px); }
}

/* ---------- камера на странице */
.cam { position: fixed; inset: 0; background: #000; z-index: 70; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #000; }
.cam-frame { position: absolute; left: 50%; top: 42%; width: min(64vw, 320px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.25); pointer-events: none; }
.cam-hint { position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); left: 16px; right: 16px; text-align: center; color: #fff; background: rgba(0,0,0,.55); padding: 10px 12px; border-radius: 12px; font-size: 15px; }
.cam-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); background: #000; color: #fff; }
.cam-cancel { justify-self: start; background: transparent; border: 0; color: #fff; font-size: 16px; padding: 10px; cursor: pointer; }
.cam-shot { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.cam-shot:active { background: #fff; }
.cam-note { justify-self: end; font-size: 12px; opacity: .7; text-align: right; }

/* Админка: чат поддержки */
.sup-bubble.bot { background: var(--surface-2); border-style: dashed; }
.chat-grid { display: grid; gap: 14px; }
.chat-grid.has-open .chat-list-card { display: none; }
.chat-grid:not(.has-open) .chat-conv { display: none; }
.chat-back { align-self: flex-start; }
@media (min-width: 760px) {
  .chat-grid, .chat-grid.has-open { grid-template-columns: minmax(240px, 320px) 1fr; align-items: start; }
  .chat-grid.has-open .chat-list-card, .chat-grid:not(.has-open) .chat-conv { display: block; }
  .chat-back { display: none; }
}
.chat-thread { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; }
.chat-thread[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chat-thread-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.chat-thread .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.chat-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv .chat-msgs { height: 55vh; min-height: 260px; border-radius: 12px; margin: 10px 0 0; }
.chat-conv .sup-form { border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-head > .btn { flex: none; width: auto; }
.chat-head-name { flex: 1; min-width: 0; font-weight: 600; }

/* client: «Сейчас играют» */
.client-grid { display: grid; gap: 14px; }
.client-side .side-head h2 { margin: 0; font-size: 17px; }
.client-side .big-num { font-size: 28px; }
.play-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.play-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.04); }
.play-list li.me { outline: 1px solid rgba(120,160,255,.45); }
.play-nick { font-weight: 700; }
.play-game { flex: 1 1 100%; font-size: 13px; }
@media (min-width: 1000px) {
  .wrap.client-wrap { max-width: 900px; }
  .client-grid { grid-template-columns: minmax(0, 560px) 1fr; align-items: start; }
  .client-side { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; }
}
.pick-btn { align-self: center; margin-top: -4px; }

/* общий чат игроков */
.client-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.client-side[hidden], #pchat[hidden] { display: none; }
#playing .side-head h2, #pchat h2 { margin: 0; font-size: 17px; }
.pchat-list { display: grid; gap: 6px; align-content: start; max-height: 300px; overflow-y: auto; margin: 10px 0 8px; padding-right: 2px; }
.pchat-list.admin { max-height: 55vh; }
.pchat-row { padding: 7px 10px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.pchat-row.me { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.pchat-row.admin { border-left: 3px solid var(--accent); }
.pchat-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; margin-top: 2px; }
.pchat-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.pchat-form { border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.pchat-rules { margin: 6px 0 0; }
.client-wrap { padding-bottom: 84px; }
.play-list li { background: var(--surface-2); }

/* сворачиваемые блоки «Сейчас играют» и «Чат игроков» */
.fold-head { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; min-height: 28px; }
.fold-head .chev { flex: none; transition: transform .15s; color: var(--muted, currentColor); }
.fold-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.fold-body { margin-top: 8px; }
.fold-body[hidden] { display: none; }
.fold-body > p.small:first-child { margin: 0; }
