/* «Это Бомба» — стили клиента. Тёмный стол, бумажные карточки (как в public/cards). */
:root {
  --bg: #10131a; --panel: #181d28; --panel2: #212837; --line: #2c3447;
  --text: #ebeef5; --mute: #97a1b6; --paper: #f1ecdf; --paper-ink: #1b2030;
  --mission: #4f8ad0; --role: #5eab88; --support: #d49b4c; --event: #cc7391;
  --danger: #ff6369; --ok: #4cc38a; --r: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.hidden { display: none !important; }
#app { height: 100%; max-width: 520px; margin: 0 auto; position: relative; }
#screen { height: 100%; overflow-y: auto; overflow-x: hidden; padding: calc(14px + var(--safe-t)) 16px calc(24px + var(--safe-b)); }
#screen.game { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 20px; line-height: 1.2; letter-spacing: -.01em; }
h3 { font-size: 16px; }
.mute { color: var(--mute); } .small { font-size: 13px; } .center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; } .grow { flex: 1; min-width: 0; } .wrap { flex-wrap: wrap; }
.gap { display: grid; gap: 12px; } .sp { height: 14px; }
.pn { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.sec { margin-top: 22px; display: grid; gap: 10px; } .sec > h3 { color: var(--mute); font-weight: 600; font-size: 14px; }

/* кнопки */
.btn { min-height: 48px; padding: 0 20px; border-radius: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.btn.primary { background: var(--paper); color: var(--paper-ink); border-color: var(--paper); }
.btn.danger { color: var(--danger); } .btn.block { width: 100%; } .btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: .4; cursor: default; } .btn:active:not(:disabled) { transform: translateY(1px); }
.link { color: var(--mute); text-decoration: underline; text-underline-offset: 3px; padding: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; }

/* главная */
.hero { padding: 28px 0 10px; }
.hero h1 { font-size: 46px; line-height: 1; letter-spacing: -.035em; font-weight: 850; }
.hero p { margin-top: 10px; color: var(--mute); max-width: 32ch; }
.codestrip { display: flex; gap: 8px; margin: 26px 0 8px; }
.codestrip > span { width: 64px; height: 64px; border-radius: 12px; background: var(--paper); display: grid; place-items: center; box-shadow: 0 2px 0 #0006; animation: drop .5s cubic-bezier(.2,.9,.3,1.2) backwards; }
.codestrip > span:nth-child(2) { animation-delay: .12s; } .codestrip > span:nth-child(3) { animation-delay: .24s; } .codestrip > span:nth-child(4) { animation-delay: .36s; }
@keyframes drop { from { transform: translateY(-18px) rotate(-6deg); opacity: 0; } }
.field { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.field:focus { border-color: var(--paper); }
.codeinput { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; }

/* лобби */
.roomcode { font-size: 30px; font-weight: 850; letter-spacing: .18em; }
.pl { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.ava { width: 36px; height: 36px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 800; flex: none; overflow: hidden; position: relative; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava.off { opacity: .45; }
.scroller { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; padding: 2px 16px 8px; margin: 0 -16px; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.cardthumb { flex: none; width: 104px; scroll-snap-align: start; position: relative; border-radius: 10px; }
.cardthumb img { display: block; width: 100%; aspect-ratio: 5/7; border-radius: 10px; background: var(--panel2); }
.cardthumb.sel { outline: 3px solid var(--paper); outline-offset: 2px; }
.cardthumb.taken img { opacity: .35; } .cardthumb .by { position: absolute; left: 6px; bottom: 6px; background: var(--bg); border-radius: 99px; padding: 1px 8px; font-size: 12px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.missionbox { display: grid; grid-template-columns: 104px 1fr; gap: 14px; align-items: start; }
.missionbox img { width: 104px; aspect-ratio: 5/7; border-radius: 10px; }
.tag { font-size: 13px; font-weight: 700; } .tag.mission { color: var(--mission); } .tag.role { color: var(--role); } .tag.support { color: var(--support); } .tag.event { color: var(--event); }

/* игра: шапка */
.gtop { flex: none; padding: calc(8px + var(--safe-t)) 14px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tbar { height: 4px; border-radius: 4px; background: var(--panel2); overflow: hidden; margin-bottom: 8px; }
.tbar > i { display: block; height: 100%; width: 100%; background: var(--paper); transform-origin: left; }
.tbar.low > i { background: var(--danger); }
.timer { font-size: 30px; font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.timer.low { color: var(--danger); } .timer.paused { color: var(--support); }
.pips { display: flex; gap: 5px; } .pips i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--mute); } .pips i.used { background: var(--danger); border-color: var(--danger); } .pips i.ok { background: var(--ok); border-color: var(--ok); }
.pstrip { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.pchip { flex: none; display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 10px 3px 3px; border-radius: 99px; background: var(--panel2); }
.pchip .ava { width: 24px; height: 24px; font-size: 12px; } .pchip.leader { background: var(--paper); color: var(--paper-ink); } .pchip.off { opacity: .5; }
.evt { margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; background: #2a1d25; border: 1px solid var(--event); font-size: 14px; }
.evt b { color: var(--event); } .evt.cancelled { opacity: .5; text-decoration: line-through; }
.gbody { flex: 1; overflow-y: auto; padding: 14px 14px 18px; display: grid; gap: 14px; align-content: start; }
.nav { flex: none; display: grid; grid-template-columns: repeat(3, 1fr) auto; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav button { min-height: 54px; color: var(--mute); font-weight: 650; position: relative; } .nav button.on { color: var(--text); box-shadow: inset 0 3px 0 var(--paper); }
.nav .tools { padding: 0 18px; color: var(--support); } .badge { position: absolute; top: 8px; margin-left: 4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* подсказки */
.clue { padding: 12px 14px; border-radius: 12px; background: var(--paper); color: var(--paper-ink); display: flex; gap: 10px; align-items: flex-start; }
.clue .tx { flex: 1; font-weight: 600; line-height: 1.7; } .clue.hid { background: var(--panel2); color: var(--mute); font-weight: 500; }
.clue .pin { flex: none; font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 8px; background: #0001; } .clue .pin.on { background: var(--paper-ink); color: var(--paper); }
.clue .star { color: #b07a1a; }
.tok { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; margin: 0 1px; border-radius: 8px; background: #0001; font-weight: 700; vertical-align: baseline; white-space: nowrap; }
.tok i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #0004; } .tok svg { width: 16px; height: 16px; }
.dark .tok, .note .tok { background: #fff1; } .note .tok i { border-color: #fff5; }
.note { padding: 10px 12px; border-radius: 10px; background: var(--panel); border-left: 3px solid var(--mute); line-height: 1.7; font-size: 15px; }
.note.pub { border-color: var(--ok); } .note.mine { border-color: var(--role); } .note .who { color: var(--mute); font-size: 12px; display: block; line-height: 1.3; }

/* ответ */
.slots { display: flex; gap: 8px; flex-wrap: wrap; }
.slot { width: 56px; height: 68px; border-radius: 12px; background: var(--panel2); border: 2px dashed var(--line); display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; padding: 4px 0 2px; position: relative; }
.slot svg { width: 36px; height: 36px; } .slot .lb { font-size: 12px; font-weight: 700; color: var(--mute); }
.slot.filled { border-style: solid; border-color: var(--line); } .slot.sel { border-color: var(--paper); background: #2b3446; }
.slot.locked { opacity: .6; } .slot.focus { box-shadow: 0 0 0 3px var(--event); }
.slot .mk { position: absolute; top: -7px; right: -5px; background: var(--support); color: #000; border-radius: 99px; font-size: 11px; padding: 0 5px; font-weight: 800; }
.slot .ok { position: absolute; top: -7px; left: -5px; background: var(--ok); color: #000; border-radius: 99px; font-size: 11px; padding: 0 5px; font-weight: 800; }
.pal { display: flex; gap: 8px; flex-wrap: wrap; }
.sw, .shp { width: 48px; height: 48px; border-radius: 12px; border: 2px solid transparent; display: grid; place-items: center; background: var(--panel2); }
.sw i { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #0006; } .shp svg { width: 30px; height: 30px; }
.sw.on, .shp.on { border-color: var(--paper); }
.cands { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cand { padding: 10px; border-radius: 12px; background: var(--panel2); border: 2px solid var(--line); display: flex; gap: 4px; justify-content: center; align-items: center; min-height: 64px; position: relative; }
.cand svg { width: 34px; height: 34px; } .cand.sel { border-color: var(--paper); background: #2b3446; } .cand.out { opacity: .3; }
.cand .no { position: absolute; top: 3px; left: 7px; font-size: 11px; color: var(--mute); font-weight: 700; }
.hint { font-size: 13px; color: var(--mute); }
.hist { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--panel); flex-wrap: wrap; }
.hist svg { width: 22px; height: 22px; } .hist .v { font-weight: 800; } .hist .v.y { color: var(--ok); } .hist .v.n { color: var(--danger); }
.poll { padding: 12px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--role); display: grid; gap: 8px; }

/* чат */
.chatlist { display: grid; gap: 8px; align-content: end; min-height: 100%; }
.msg { max-width: 86%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--panel2); overflow-wrap: anywhere; } .msg .who { display: block; font-size: 12px; color: var(--mute); }
.msg.me { justify-self: end; background: var(--paper); color: var(--paper-ink); border-radius: 14px 14px 4px 14px; } .msg.me .who { display: none; }
.msg.sys { justify-self: center; max-width: 100%; background: none; color: var(--mute); font-size: 13px; text-align: center; padding: 2px 6px; }
.chatbar { flex: none; display: flex; gap: 8px; padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.chatbar .field { min-height: 44px; } .chatbar .btn { min-height: 44px; padding: 0 16px; }

/* окна */
.overlay { position: fixed; inset: 0; background: #000a; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 88%; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); display: grid; gap: 12px; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toolrow { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel2); }
.toolrow img { width: 52px; aspect-ratio: 5/7; border-radius: 6px; }
.zoom { max-width: 320px; width: 100%; border-radius: 14px; justify-self: center; }
.dots { display: flex; gap: 6px; justify-content: center; } .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); } .dots i.on { background: var(--paper); }
.tutart { display: flex; gap: 8px; justify-content: center; padding: 14px; border-radius: 12px; background: var(--paper); }
.tutart svg { width: 40px; height: 40px; }

/* итог */
.verdict { padding: 22px 18px; border-radius: var(--r); background: var(--paper); color: var(--paper-ink); }
.verdict h1 { font-size: 34px; line-height: 1.05; letter-spacing: -.03em; font-weight: 850; } .verdict.lost { background: #2a1d25; color: var(--text); border: 1px solid var(--danger); }
.reveal { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; } .reveal svg { width: 44px; height: 44px; }
.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* связь и уведомления */
.conn { position: fixed; top: 0; left: 0; right: 0; z-index: 40; padding: calc(6px + var(--safe-t)) 12px 6px; text-align: center; background: var(--danger); color: #fff; font-size: 13px; font-weight: 700; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + var(--safe-b)); z-index: 50; display: grid; gap: 8px; justify-items: center; pointer-events: none; padding: 0 16px; }
.toast { background: var(--paper); color: var(--paper-ink); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: 420px; box-shadow: 0 6px 20px #0008; animation: up .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.pchip.leader .ava { background: var(--paper-ink); color: var(--paper); }
.slots.rev { flex-direction: row-reverse; justify-content: flex-end; }
.note-in { padding: 10px 14px; resize: vertical; line-height: 1.5; }


/* ───────── Тема: красивый фон и приятные детали ───────── */
html { background: #0a0d14; }
body { background: transparent; }
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: radial-gradient(1200px 700px at 15% -10%, #1b2a52 0%, transparent 60%), radial-gradient(900px 600px at 110% 25%, #3a1d2e 0%, transparent 55%), radial-gradient(900px 700px at 50% 125%, #231a3d 0%, transparent 60%), #0a0d14; }
.bg::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(#ffffff16 1px, transparent 1.5px); background-size: 26px 26px; -webkit-mask-image: radial-gradient(ellipse at center, #000 25%, transparent 85%); mask-image: radial-gradient(ellipse at center, #000 25%, transparent 85%); }
.bg i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: drift 24s ease-in-out infinite alternate; }
.bg i:nth-child(1) { width: 340px; height: 340px; left: -90px; top: 8%; background: #3b5bdb66; }
.bg i:nth-child(2) { width: 300px; height: 300px; right: -90px; top: 42%; background: #ff7a3d55; animation-duration: 29s; animation-delay: -8s; }
.bg i:nth-child(3) { width: 280px; height: 280px; left: 25%; bottom: -110px; background: #9c4dcc55; animation-duration: 26s; animation-delay: -14s; }
@keyframes drift { to { transform: translate(60px, -50px) scale(1.15); } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
@keyframes pulse { 50% { opacity: .55; } }

.pn { background: linear-gradient(180deg, #1e2434cc, #171c29cc); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 10px 30px #0005, inset 0 1px 0 #ffffff0d; }
.hero h1 { background: linear-gradient(95deg, #fff 15%, #ffd29a 55%, #ff7a3d); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; filter: drop-shadow(0 6px 24px #ff7a3d44); }
.hero p { color: #b3bdd2; }

.btn { transition: transform .12s, box-shadow .2s, filter .2s; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn.primary { background: linear-gradient(180deg, #fff7e6, #eadfc2); box-shadow: 0 8px 22px #ff8a3d33, inset 0 1px 0 #fff; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 10px 28px #ff8a3d55, inset 0 1px 0 #fff; }

.tbar { background: #ffffff14; }
.tbar > i { background: linear-gradient(90deg, #ffe0b0, #ff8a3d); box-shadow: 0 0 12px #ff8a3d99; }
.tbar.low > i { background: linear-gradient(90deg, #ff9a9d, var(--danger)); box-shadow: 0 0 12px #ff636999; }
.timer { text-shadow: 0 0 18px #ffffff30; }
.timer.low { animation: pulse 1s ease-in-out infinite; text-shadow: 0 0 18px #ff636988; }

.clue { background: linear-gradient(180deg, #f7f2e5, #ebe4d0); border-left: 4px solid #d49b4c; box-shadow: 0 8px 18px #0005, inset 0 1px 0 #fff8; transition: transform .15s; }
.clue:hover { transform: translateY(-1px); }
.clue.hid { background: var(--panel2); border-left-color: var(--line); box-shadow: none; }
.slot.filled { box-shadow: 0 4px 12px #0004; }
.slot.sel { box-shadow: 0 0 0 3px #ffffff22, 0 0 18px #ffd9a066; }
.cand { transition: transform .12s, border-color .15s; } .cand:active { transform: scale(.97); }
.pchip.leader { box-shadow: 0 0 14px #fff3; }
.note { background: #181d28cc; }

.verdict { box-shadow: 0 0 0 1px #ffffff22, 0 22px 60px #ff8a3d33; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
.verdict.lost { box-shadow: 0 0 0 1px #ff636966, 0 22px 60px #ff636933; }
.overlay { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.toast { box-shadow: 0 10px 30px #000a; }

/* подсказки */
.hint { color: #aab4ca; }
p.hint:not(.center)::before { content: "💡 "; }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; background: linear-gradient(135deg, #2a2440d9, #1d2a44d9); border: 1px solid #6c8cff44; box-shadow: 0 8px 22px #0006; }
.tip .ti { font-size: 20px; line-height: 1.2; } .tip b { color: #ffd9a0; }

@media (prefers-reduced-motion: reduce) { .bg i, .timer.low, .verdict { animation: none; } .btn, .clue, .cand { transition: none; } }


/* ───────── Телефон: ничего не перекрывается ───────── */
html, body { overflow: hidden; -webkit-text-size-adjust: 100%; }
button, a, input, textarea { touch-action: manipulation; }
#app { position: fixed; top: var(--app-top, 0px); left: 0; right: 0; bottom: 0; width: 100%; height: var(--app-h, 100dvh); margin: 0 auto; }
#screen { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
#screen.game { padding-left: 0; padding-right: 0; }
.gtop, .gbody, .nav { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
.nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.sheet { max-height: calc(var(--app-h, 100dvh) - 20px); overscroll-behavior: contain; }
#toasts { top: calc(10px + var(--safe-t)); bottom: auto; }
.clue .pin { min-height: 36px; min-width: 44px; }
.kb .nav, .kb .gtop .pstrip, .kb .gtop .evt, .kb .gtop > .small { display: none; }
.kb .gbody { padding-bottom: 10px; }

/* чат */
.chatdock { flex: none; background: var(--panel); border-top: 1px solid var(--line); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.chatdock .chatbar { border-top: 0; background: transparent; padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); }
.chatbar .btn.primary { min-width: 52px; padding: 0 16px; font-size: 18px; }
.chatbar .field:disabled { opacity: .5; }
.qrow { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.qrow::-webkit-scrollbar { display: none; }
.qchip { flex: none; min-height: 38px; padding: 0 14px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap; }
.qchip.share { background: linear-gradient(135deg, #2a3a66, #3b2a5a); border-color: #6c8cff66; }
.qchip:active { transform: scale(.97); }
.chatlist { gap: 6px; }
.msg { max-width: 82%; padding: 7px 12px 5px; box-shadow: 0 2px 8px #0003; }
.msg .who { font-weight: 700; margin-bottom: 1px; }
.msg time { display: block; text-align: right; font-size: 11px; opacity: .55; margin-top: 2px; }
.msg.cont { margin-top: -2px; } .msg.cont .who { display: none; }
.msg.sys { box-shadow: none; }
.chatempty { text-align: center; color: var(--mute); padding: 28px 14px; line-height: 1.6; margin: auto 0; }

/* маленькие экраны */
@media (max-width: 360px), (max-height: 680px) {
  .hero h1 { font-size: 36px; } .timer { font-size: 26px; } .slot { width: 48px; height: 60px; } .slot svg { width: 30px; height: 30px; }
  .gbody { padding-top: 10px; gap: 10px; } .clue { padding: 10px 12px; } .tip { padding: 10px 12px; } .sw, .shp { width: 44px; height: 44px; }
}
