:root {
  --bg: #0e1014; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8e6e1; --muted: #8c93a1;
  --accent: #e0a84a; --op: #6fd0c4; --an: #a495ff; --danger: #ef6a5e; --ok: #7bd389;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 2rem; letter-spacing: .08em; text-transform: uppercase; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .7em; }
small, .muted { color: var(--muted); }
small { font-size: .82rem; }
.nl { white-space: pre-wrap; word-break: break-word; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(150px + env(safe-area-inset-bottom)); }
.wrap.flat { padding-bottom: 32px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* кнопки и поля */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 16px; font-weight: 600; transition: .15s; }
.btn:hover { border-color: #3a4150; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #1a1405; border-color: var(--accent); }
.btn.danger { background: #3a1c1a; border-color: #6b2a25; color: #ffb3ab; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: .86rem; border-radius: 10px; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=search], textarea, select {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
label.f { display: block; margin: 12px 0 5px; color: var(--muted); font-size: .88rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card.hl { border-color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: .82rem; white-space: nowrap; }
.chip.op { color: var(--op); border-color: #2c5b56; } .chip.an { color: var(--an); border-color: #443d7e; }
.chip.warn { color: #1a1405; background: var(--danger); border-color: var(--danger); font-weight: 700; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #555; margin-right: 6px; }
.dot.on { background: var(--ok); }

/* главная */
.hero { text-align: center; padding: 38px 0 22px; }
.hero .logo { width: 92px; height: 92px; border-radius: 22px; margin-bottom: 14px; }
.hero p { color: var(--muted); }
.mode-card { display: block; width: 100%; text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: var(--r); padding: 14px; }
.mode-card.sel { border-color: var(--accent); background: #211c10; }
.mode-card b { display: block; margin-bottom: 2px; }
.code { font: 700 2.6rem/1 ui-monospace, Consolas, monospace; letter-spacing: .25em; text-align: center; padding: 14px 0 14px .25em; background: var(--panel2); border-radius: var(--r); border: 1px dashed #4a4230; color: var(--accent); user-select: all; }
.banner { padding: 10px 14px; border-radius: 12px; background: #2a2210; border: 1px solid #5c4a1f; color: #ffe2a3; font-size: .9rem; }
.banner.err { background: #2c1514; border-color: #6b2a25; color: #ffc0b9; }

/* генерация */
.brief p { opacity: 0; animation: fadeUp .8s forwards; font-size: 1.05rem; }
.brief p:nth-child(1) { animation-delay: .2s } .brief p:nth-child(2) { animation-delay: 2.4s } .brief p:nth-child(3) { animation-delay: 4.6s } .brief p:nth-child(4) { animation-delay: 6.8s }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg) } }

/* шапка игры */
.top { position: sticky; top: 0; z-index: 20; background: rgba(14,16,20,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 8px 14px calc(8px) 14px; padding-top: max(8px, env(safe-area-inset-top)); }
.top .inner { max-width: 760px; margin: 0 auto; }
.top .ttl { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .chips { display: flex; gap: 6px; margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.warnbar { background: var(--danger); color: #1a0806; text-align: center; font-weight: 700; padding: 7px; }
.pbanner { position: sticky; top: 82px; z-index: 15; }

/* нижняя навигация */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(23,26,33,.97); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; background: none; border: 0; padding: 9px 2px 8px; color: var(--muted); font-size: .72rem; position: relative; }
.tabs button .i { display: block; font-size: 1.3rem; line-height: 1.2; }
.tabs button.on { color: var(--accent); }
.tabs .badge { position: absolute; top: 4px; left: 54%; background: var(--danger); color: #fff; border-radius: 99px; font-size: .68rem; padding: 0 6px; }

/* улики */
.item .item-head { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.item .ico { font-size: 1.5rem; width: 34px; text-align: center; }
.item .item-body { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .95rem; }
.item .chev { margin-left: auto; color: var(--muted); transition: .2s; }
.item.open .chev { transform: rotate(180deg); }
.item.fresh { border-color: var(--accent); }

/* места / запросы / люди */
.loc .cost, .q .cost { color: var(--accent); font-weight: 700; }
.person { display: flex; gap: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 700; flex: none; border: 1px solid var(--line); }
.group-title { margin: 18px 0 8px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }

/* чат / допрос */
.log { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); }
.msg.me { align-self: flex-end; background: #1f2a28; border-color: #2c5b56; }
.msg.me.an { background: #25223d; border-color: #443d7e; }
.msg.sys { align-self: center; max-width: 100%; background: transparent; border: 0; color: var(--muted); font-size: .82rem; text-align: center; padding: 2px; }
.msg .who { font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.msg.q { align-self: flex-end; background: #1f2a28; border-color: #2c5b56; }
.msg.a { align-self: flex-start; }
.msg.broke { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.mood { font-size: .72rem; color: var(--accent); }
.composer { position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0 6px; margin-top: 12px; z-index: 5; }
.composer .row { align-items: stretch; flex-wrap: nowrap; }
.evtag { display: inline-block; margin-top: 6px; padding: 2px 9px; border-radius: 8px; background: #2a2210; border: 1px solid #5c4a1f; color: #ffe2a3; font-size: .78rem; cursor: pointer; }

/* модалки */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.65); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 20px 20px 0 0; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; background: var(--panel2); }
.check input { margin-top: 4px; accent-color: var(--accent); }

/* итог */
.verdict { text-align: center; padding: 18px 0 6px; }
.verdict .big { font-size: 3rem; }
.verdict.good h1 { color: var(--ok); } .verdict.bad h1 { color: var(--danger); }
.score { font-size: 2.2rem; font-weight: 800; color: var(--accent); }
table.parts { width: 100%; border-collapse: collapse; } table.parts td { padding: 4px 0; border-bottom: 1px solid var(--line); } table.parts td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.timeline li { margin-bottom: 4px; } .timeline b { color: var(--accent); font-variant-numeric: tabular-nums; }

/* доска расследования */
.cork { position: relative; padding: 4px 0 20px; }
.cork svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.cork .cases { display: grid; gap: 14px; position: relative; z-index: 1; }
.ccard { background: #2a2418; border: 1px solid #4a4230; border-radius: 6px; padding: 12px 12px 12px; box-shadow: 0 6px 14px rgba(0,0,0,.35); transform: rotate(-.4deg); }
.ccard:nth-child(even) { transform: rotate(.5deg); }
.ccard.locked { opacity: .5; filter: grayscale(.6); }
.ccard.active { border-color: var(--accent); }
.pins { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pin { background: #f1e3b3; color: #2b2410; border: 0; border-radius: 3px; padding: 6px 9px; font-size: .78rem; text-align: left; max-width: 100%; position: relative; }
.pin::before { content: "📌"; position: absolute; top: -9px; left: -3px; font-size: .9rem; }
.villain { position: relative; z-index: 1; margin: 22px auto 0; width: 150px; height: 150px; border-radius: 50%; border: 2px dashed #7a3a35; display: grid; place-items: center; text-align: center; background: #1d1212; padding: 10px; }
.villain.rev { border-style: solid; border-color: var(--danger); }
.villain b { display: block; color: var(--danger); }

/* тосты */
#toasts { position: fixed; left: 0; right: 0; top: max(10px, env(safe-area-inset-top)); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { background: #262b36; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; max-width: 520px; box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: fadeUp .25s; }
.toast.err { background: #3a1c1a; border-color: #6b2a25; color: #ffc0b9; }
.toast.ok { background: #14301c; border-color: #2c6a3b; color: #bff0c9; }
.toast.big { font-weight: 700; border-color: var(--danger); }
