/* Современный игровой HUD поверх живой карты: стеклянные панели, крупные кнопки действий, шторки, лента событий. */
:root {
  --glass: rgba(13, 17, 30, 0.58);
  --glass-strong: rgba(13, 17, 30, 0.94);
  --glass-line: rgba(255, 255, 255, 0.14);
  --ink: #f5f7fb;
  --muted: rgba(245, 247, 251, 0.66);
  --faint: rgba(245, 247, 251, 0.4);
  --gold: #ffc24b;
  --gold-2: #ff9f1c;
  --red: #ff5a5f;
  --red-2: #e0323a;
  --teal: #4fd1c5;
  --green: #4ade80;
  --radius: 18px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b1020; color: var(--ink); font-family: var(--font); font-size: 15px; overflow: hidden; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }

#world { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.dim { position: fixed; inset: 0; background: linear-gradient(180deg, rgba(8,11,22,0.15), rgba(8,11,22,0.55)); pointer-events: none; transition: opacity .4s; }
.ui { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.ui > * { pointer-events: auto; }
.ui .spacer { flex: 1; pointer-events: none; }

/* ---------- стекло ---------- */
.glass { background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radius); backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%); box-shadow: 0 12px 32px rgba(0,0,0,0.28); }
.glass.strong { background: var(--glass-strong); }
.pad { padding: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.title { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.logo { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: .95; text-shadow: 0 4px 24px rgba(0,0,0,0.35); }
.logo .ia { background: linear-gradient(135deg, var(--gold), var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- кнопки, поля, чипы ---------- */
.btn { appearance: none; border: 0; border-radius: 999px; padding: 13px 20px; font-weight: 800; font-size: 15px; cursor: pointer; color: #1d1405; background: linear-gradient(135deg, var(--gold), var(--gold-2)); box-shadow: 0 6px 18px rgba(255,159,28,0.35); transition: transform .08s, filter .2s, opacity .2s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; box-shadow: none; }
.btn.ghost { background: rgba(255,255,255,0.1); color: var(--ink); box-shadow: none; border: 1px solid var(--glass-line); }
.btn.red { background: linear-gradient(135deg, #ff7a6b, var(--red-2)); color: #fff; box-shadow: 0 6px 18px rgba(224,50,58,0.4); }
.btn.teal { background: linear-gradient(135deg, #7ff0e2, #22b3a5); color: #04211e; box-shadow: 0 6px 18px rgba(34,179,165,0.35); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 14px; font-size: 13px; }
.field { width: 100%; background: rgba(255,255,255,0.08); border: 1px solid var(--glass-line); border-radius: 14px; padding: 12px 14px; outline: none; font-size: 15px; }
.field::placeholder { color: var(--faint); }
.field:focus { border-color: var(--gold); background: rgba(255,255,255,0.12); }
.inputbar { display: flex; gap: 8px; }
.inputbar .field { flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.08); border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.mine { border-color: rgba(255,194,75,0.6); background: rgba(255,194,75,0.16); }
.chip:active { transform: scale(0.97); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.pill.glass { border-radius: 999px; }
.pill.gold { background: rgba(255,194,75,0.18); color: var(--gold); border: 1px solid rgba(255,194,75,0.4); }
.pill.red { background: rgba(255,90,95,0.18); color: #ff9a9d; border: 1px solid rgba(255,90,95,0.45); }
.pill.teal { background: rgba(79,209,197,0.16); color: #8ff3e8; border: 1px solid rgba(79,209,197,0.4); }

/* ---------- вход ---------- */
.join-wrap { justify-content: flex-end; gap: 16px; }
.join-wrap .logo { font-size: 64px; }
.join-wrap .tag { font-family: var(--display); font-size: 17px; margin-top: 6px; color: var(--ink); text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.err { color: #ff9a9d; font-size: 13px; min-height: 16px; }

/* ---------- лобби ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: rgba(255,255,255,0.08); }
.seg button { border: 0; background: transparent; padding: 9px; border-radius: 999px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: rgba(255,255,255,0.16); color: var(--ink); }
.lobby-body { overflow-y: auto; max-height: 58dvh; }
.role-card { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; }
.role-card .stand { height: 92px; border-radius: 16px; background: radial-gradient(circle at 50% 80%, rgba(255,194,75,0.25), rgba(255,255,255,0.04) 70%); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.role-card .stand img { max-height: 86px; width: auto; }
.role-card h3 { font-family: var(--display); font-size: 17px; margin: 3px 0; }
.prep h4 { font-size: 14px; margin-bottom: 2px; }
.prep .field { margin-top: 6px; font-size: 14px; padding: 10px 12px; }
.saved { font-size: 12px; color: var(--green); min-height: 15px; }
.chat-log { display: flex; flex-direction: column; gap: 6px; max-height: 40dvh; overflow-y: auto; font-size: 14px; line-height: 1.4; }
.chat-log .host { color: var(--gold); font-weight: 700; }
.chat-log .system { color: var(--muted); font-size: 13px; }
.chat-log b { margin-right: 4px; }
.count-ring { --p: 1; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: conic-gradient(var(--gold) calc(var(--p) * 360deg), rgba(255,255,255,0.12) 0); position: relative; }
.count-ring::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: rgba(13,17,30,0.9); }
.count-ring span { position: relative; }

/* ---------- HUD раунда ---------- */
.hud-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.me-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; justify-self: start; max-width: 100%; }
.me-chip .av { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,0.1); flex: none; }
.me-chip .av img { width: 100%; height: 140%; object-fit: cover; object-position: top; }
.me-chip .nm { font-weight: 800; font-size: 13px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-chip .sb { font-size: 11px; color: var(--muted); font-weight: 700; }
.timer-pill { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 14px; border-radius: 16px; min-width: 84px; }
.timer-pill b { font-family: var(--display); font-size: 17px; }
.timer-pill .bar { width: 60px; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.15); overflow: hidden; }
.timer-pill .bar i { display: block; height: 100%; background: var(--gold); }
.score-chip { justify-self: end; text-align: right; padding: 7px 12px; border-radius: 16px; }
.score-chip b { font-family: var(--display); font-size: 17px; display: block; }
.bolts { display: flex; gap: 3px; justify-content: flex-end; margin-top: 2px; }
.bolts i { width: 8px; height: 14px; border-radius: 2px; background: var(--red); box-shadow: 0 0 8px rgba(255,90,95,0.6); }
.bolts i.off { background: rgba(255,255,255,0.18); box-shadow: none; }

.feed { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; margin-top: 8px; pointer-events: none !important; }
.feed .ev { max-width: 88%; padding: 7px 12px; border-radius: 12px; font-size: 13px; font-weight: 700; animation: slidein .35s ease-out; }
.feed .ev.hit { border-color: rgba(74,222,128,0.5); }
.feed .ev.miss { border-color: rgba(255,90,95,0.5); }
.feed .ev.host { color: var(--gold); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast { align-self: center; margin-top: 10px; padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700; animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

.hint { align-self: center; text-align: center; max-width: 340px; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.4; }

.controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.joy { width: 132px; height: 132px; border-radius: 50%; position: relative; touch-action: none; background: radial-gradient(circle, rgba(255,255,255,0.10), rgba(255,255,255,0.04) 70%); border: 1px solid var(--glass-line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.joy .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(220,226,240,0.75)); box-shadow: 0 6px 16px rgba(0,0,0,0.35); transition: transform .06s; }
.actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.target { padding: 10px 12px; border-radius: 16px; display: flex; align-items: center; gap: 10px; max-width: 220px; }
.target img { width: 34px; height: 44px; object-fit: contain; }
.target .nm { font-weight: 800; font-size: 13.5px; }
.target .sb { font-size: 12px; color: var(--muted); }
.abtns { display: flex; gap: 10px; }
.abtn { width: 68px; height: 68px; border-radius: 50%; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 22px; font-weight: 800; cursor: pointer; color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,0.35); transition: transform .08s, opacity .2s; }
.abtn small { font-size: 10px; font-weight: 800; letter-spacing: .02em; }
.abtn:active { transform: scale(0.94); }
.abtn:disabled { opacity: .35; }
.abtn.talk { background: linear-gradient(135deg, #6ea8ff, #3d6fe0); }
.abtn.shoot { background: linear-gradient(135deg, #ff7a6b, var(--red-2)); width: 78px; height: 78px; }

/* ---------- шторка допроса ---------- */
.sheet { border-radius: 24px 24px 18px 18px; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; animation: up .3s cubic-bezier(.2,.9,.3,1); max-height: 62dvh; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.25); align-self: center; }
.msgs { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 40px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.38; }
.msg.q { align-self: flex-end; background: linear-gradient(135deg, #6ea8ff, #3d6fe0); border-bottom-right-radius: 6px; }
.msg.a { align-self: flex-start; background: rgba(255,255,255,0.12); border-bottom-left-radius: 6px; }
.msg.a.mine { background: rgba(79,209,197,0.22); }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dots i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.tbar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
.tbar i { display: block; height: 100%; background: var(--teal); }
.tbar.warn i { background: var(--red); }

/* ---------- флип / итоги ---------- */
.center { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.flip-title { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; animation: pop .5s cubic-bezier(.2,1.5,.4,1); text-shadow: 0 6px 30px rgba(0,0,0,.4); }
.flip-title.hunter { color: #ff8a8d; }
.flip-title.uai { color: #8ff3e8; }
.flip-sprite { height: 180px; width: auto; filter: drop-shadow(0 12px 18px rgba(0,0,0,0.45)); }
.board { display: flex; flex-direction: column; gap: 6px; }
.board .r { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,0.06); font-weight: 700; }
.board .r.me { background: rgba(255,194,75,0.16); }
.board .pos { color: var(--muted); font-family: var(--display); font-size: 13px; }
.board .pts { font-family: var(--display); }
.roast { padding: 10px 12px; border-radius: 14px; background: rgba(255,255,255,0.06); font-size: 14px; line-height: 1.4; }
.roast b { color: var(--gold); }
.award { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; }
.award .ico { font-size: 26px; text-align: center; }
.award small { color: var(--muted); }
.award q { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.acc { display: flex; gap: 10px; align-items: flex-end; height: 90px; margin-top: 24px; }
.acc div { flex: 1; border-radius: 8px 8px 2px 2px; background: linear-gradient(180deg, var(--gold), var(--gold-2)); position: relative; min-height: 4px; }
.acc span { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.scroll { overflow-y: auto; }

/* ---------- правила, шпаргалка управления, подсказки ---------- */
.rules { gap: 18px; }
.rule p { color: var(--muted); line-height: 1.5; margin-top: 6px; }
.rule p b { color: var(--ink); }
.ctl { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; margin-top: 10px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.ctl b { color: var(--ink); }
.ctl .ico { justify-self: center; pointer-events: none; }
.joy-ico { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--glass-line); background: radial-gradient(circle, rgba(255,255,255,0.14), rgba(255,255,255,0.04)); display: grid; place-items: center; }
.joy-ico i { width: 22px; height: 22px; border-radius: 50%; background: #e6ebf5; }
.ring-ico { width: 46px; height: 20px; border-radius: 50%; border: 3px solid #ffe14d; }
.abtn.mini { width: 48px; height: 48px; font-size: 20px; }
.ctl .chip, .ctl .btn { font-size: 12px; }
.tells { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.5; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.tells b { color: var(--ink); }
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(5,8,18,0.55); display: flex; align-items: flex-end; justify-content: center; padding: 12px; overflow-y: auto; }
.overlay > .glass { max-height: 88dvh; overflow-y: auto; }
.help { width: 42px; height: 42px; padding: 0; font-size: 18px; font-weight: 800; border-radius: 50%; background: var(--glass-strong); color: var(--gold); border: 1px solid rgba(255,194,75,0.5); box-shadow: 0 6px 16px rgba(0,0,0,0.3); cursor: pointer; }
.coach { position: fixed; inset: 0; z-index: 15; background: rgba(5,8,18,0.35); animation: pop .3s; }
.coach .cm { position: absolute; max-width: 220px; padding: 10px 12px; border-radius: 14px; background: rgba(255,194,75,0.95); color: #1d1405; font-weight: 800; font-size: 13.5px; line-height: 1.35; box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.coach .cm .muted { color: rgba(29,20,5,0.7); font-weight: 700; }
.coach .cm-tap { position: absolute; left: 50%; top: 45%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: rgba(13,17,30,0.85); font-weight: 800; }
.join-wrap .btn.block + .btn.block { margin-top: 0; }

/* пустые области HUD не должны перехватывать тапы по карте */
.hud-top, .controls, #bottom, .actions, .abtns { pointer-events: none !important; }
.hud-top > *, .controls > .joy, .actions > *, .abtns > *, #bottom > .sheet, #bottom > .glass, .controls > .hint { pointer-events: auto; }

/* ---------- танец (DDR) ---------- */
.ddr { position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(540px, calc(100% - 20px)); z-index: 12; padding: 12px; border-radius: 22px; display: flex; flex-direction: column; gap: 10px; animation: up .3s cubic-bezier(.2,.9,.3,1); }
.ddr-judge { font-family: var(--display); font-size: 13px; font-weight: 800; color: var(--muted); text-align: right; }
.ddr-judge.perfect { color: #6bff8f; }
.ddr-judge.good { color: var(--gold); }
.ddr-judge.miss { color: #ff7a7d; }
.ddr-field { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; height: 210px; overflow: hidden; border-radius: 14px; background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)); }
.ddr-lane { position: relative; }
.ddr-rec { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: 52px; height: 52px; border-radius: 14px; border: 2px dashed rgba(255,255,255,0.35); display: grid; place-items: center; font-size: 28px; font-weight: 900; color: rgba(255,255,255,0.35); }
.ddr-note { position: absolute; left: 50%; top: 0; margin-left: -26px; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.4); box-shadow: 0 6px 16px rgba(0,0,0,0.35); will-change: transform; }
.ddr-note.done { opacity: 0 !important; transition: opacity .15s; }
.ddr-note.missed { filter: grayscale(1) brightness(0.6); }
.l-L { background: linear-gradient(135deg, #ff8fe0, #e040b0); }
.l-D { background: linear-gradient(135deg, #7fd6ff, #2b8fe0); }
.l-U { background: linear-gradient(135deg, #8fffa8, #22b356); }
.l-R { background: linear-gradient(135deg, #ffd08a, #f08a1c); }
.ddr-pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ddr-pad { height: 70px; border: 0; border-radius: 18px; font-size: 34px; font-weight: 900; color: #fff; cursor: pointer; touch-action: manipulation; box-shadow: 0 8px 18px rgba(0,0,0,0.35); transition: transform .06s; }
.ddr-pad.hit { transform: scale(0.92); filter: brightness(1.25); }
.dance-chip { border-color: rgba(255,107,214,0.6) !important; background: rgba(255,107,214,0.18) !important; }

/* в игре размытие под стеклом пересчитывается каждый кадр поверх живого canvas — дорого на телефоне; заменяем плотным фоном */
body.ingame .glass, body.screen .glass { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(13, 17, 30, 0.74); }
body.ingame .glass.strong, body.screen .glass.strong { background: rgba(13, 17, 30, 0.94); }
body.ingame .joy { backdrop-filter: none; -webkit-backdrop-filter: none; background: radial-gradient(circle, rgba(13,17,30,0.45), rgba(13,17,30,0.25) 70%); }

.abtn.sit { width: 56px; height: 56px; font-size: 18px; background: linear-gradient(135deg, #b9a6ff, #6d5bd0); align-self: flex-end; }
.abtn.sit.on { background: linear-gradient(135deg, #ffd27a, #e08a1c); }

/* размытие под стеклом убрано везде: за панелями всегда живой canvas, и blur пересчитывался бы каждый кадр */
.glass { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; background: rgba(13, 17, 30, 0.78); }
.glass.strong { background: rgba(13, 17, 30, 0.94); }
.joy { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
