:root {
  --bg: #0a0a0a;
  --bg2: #121212;
  --panel: #141414;
  --panel2: #1c1c1c;
  --line: #2a2a2a;
  --text: #ececec;
  --muted: #9a9a9a;
  --hazard: #f5a33b;
  --hazard-dim: #6a4618;
  --rust: #e2553a;
  --ok: #7fcf6a;
  --blue: #5ab0e6;
  --radius: 12px;
  --head: 'Montserrat', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 'Montserrat', system-ui, sans-serif; }
body { min-height: 100vh;
  background-image: radial-gradient(ellipse at 20% -10%, #2a1d10 0, transparent 55%), radial-gradient(ellipse at 110% 110%, #1f1410 0, transparent 50%);
  background-attachment: fixed; }
a { color: var(--hazard); }
h1, h2, h3 { font-family: var(--head); font-weight: 800; letter-spacing: -.01em; margin: 0 0 .5em; }
h2 { font-size: 18px; }
h3 { font-size: 14px; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--hazard); }
input[type=checkbox] { width: auto; accent-color: var(--hazard); }
label { display: block; }
.btn {
  border: 1px solid var(--line); background: var(--panel2); padding: 8px 14px; border-radius: 8px; cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s; white-space: nowrap;
}
.btn:hover { border-color: var(--hazard); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--hazard); color: #1a1405; border-color: var(--hazard); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: var(--rust); color: #ffb39c; }
.btn.danger.solid { background: var(--rust); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.tiny { padding: 1px 6px; font-size: 12px; border-radius: 6px; }
.btn.ghost { background: transparent; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stack > * + * { margin-top: 12px; }

/* hazard stripe */
.stripe { height: 6px; background: repeating-linear-gradient(-45deg, var(--hazard) 0 12px, #1a1a14 12px 24px); border-radius: 3px; opacity: .85; }

/* ---------- home ---------- */
.home { max-width: 460px; margin: 6vh auto; padding: 0 16px; }
.logo { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.logo h1 { font-size: 40px; margin: 0; line-height: 1; }
.logo small { display: block; color: var(--muted); font-family: 'Montserrat'; font-size: 14px; letter-spacing: 0; margin-top: 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel2); color: var(--hazard); }

/* ---------- top bar ---------- */
.top { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(18,20,18,.85); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); flex-wrap: wrap; }
.top .brand { font-family: var(--head); font-size: 20px; color: var(--hazard); }
.code { font-family: var(--head); letter-spacing: .15em; background: var(--bg2); border: 1px dashed var(--hazard-dim); padding: 3px 10px; border-radius: 6px; cursor: pointer; }
.pill { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; }
.pill b { color: var(--hazard); font-weight: 600; }
.timer { font-family: var(--head); font-size: 18px; min-width: 70px; text-align: center; padding: 2px 10px; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); }
.timer.low { color: var(--rust); border-color: var(--rust); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- layout ---------- */
.wrap { padding: 16px; }
.lobby { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; max-width: 1200px; margin: 0 auto; }
.game { display: grid; grid-template-columns: 300px 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .game { grid-template-columns: 1fr 340px; } .game .left { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; } .game .left > * + * { margin-top: 0; } }
@media (max-width: 860px) { .game, .lobby { grid-template-columns: 1fr; } .wrap { padding: 10px; } }
.side { position: sticky; top: 70px; max-height: calc(100vh - 86px); display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 860px) { .side { position: static; max-height: none; } }

/* ---------- cards ---------- */
.cat { border-left: 4px solid var(--rust); }
.cat .title { font-family: var(--head); font-size: 20px; color: #ffb39c; margin-bottom: 6px; }
.bunker { border-left: 4px solid var(--hazard); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.items { list-style: none; padding: 0; margin: 8px 0 0; }
.items li { padding: 6px 8px; border-radius: 6px; background: var(--bg2); margin-top: 4px; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.items li.locked { color: var(--muted); font-style: italic; }

.phase { border: 1px solid var(--hazard-dim); background: linear-gradient(180deg, #2a2615, var(--panel)); }
.phase .ph-title { font-family: var(--head); font-size: 20px; color: var(--hazard); }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; position: relative; transition: border-color .2s; }
.pc.turn { border-color: var(--hazard); box-shadow: 0 0 0 1px var(--hazard), 0 0 22px -6px var(--hazard); }
.pc.me { background: linear-gradient(180deg, #252a1f, var(--panel)); }
.pc.dead { opacity: .6; background: repeating-linear-gradient(-45deg, var(--panel) 0 10px, #1b1d1b 10px 20px); }
.pc.voted-by-me { border-color: var(--rust); box-shadow: 0 0 0 1px var(--rust); }
.pc .nm { font-weight: 600; font-size: 16px; display: flex; gap: 6px; align-items: center; }
.pc .nm .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.pc .nm .dot.off { background: #555; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 6px; min-height: 0; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.badge.hz { color: var(--hazard); border-color: var(--hazard-dim); }
.badge.red { color: #ffb39c; border-color: var(--rust); }
.badge.blue { color: var(--blue); border-color: #2c5770; }
.badge.green { color: var(--ok); border-color: #3e5d2e; }
.traits { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.traits li { display: grid; grid-template-columns: 92px 1fr; gap: 6px; padding: 3px 0; border-top: 1px solid #2a2f2a; align-items: start; }
.traits li:first-child { border-top: 0; }
.traits .k { color: var(--muted); font-size: 12px; padding-top: 1px; }
.traits .v.hid { color: #5d6159; letter-spacing: .2em; }
.traits .v.secret { color: #c9c2a3; font-style: italic; }
.traits .v.secret::after { content: ' 🔒'; font-style: normal; font-size: 11px; }
.hctl { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.votebar { margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.score { font-family: var(--head); color: var(--rust); font-size: 18px; }
.acts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #2b2417; border: 1px solid var(--hazard-dim); color: #e8c77a; }
.chip.back { background: repeating-linear-gradient(45deg, #2b2417 0 4px, #231d12 4px 8px); color: var(--muted); }
.chip.used { text-decoration: line-through; opacity: .7; }

/* my card */
.mine .traits li { grid-template-columns: 92px 1fr auto; }
.action { border: 1px solid var(--hazard-dim); background: #221e14; border-radius: 8px; padding: 8px 10px; }
.action .t { font-weight: 600; color: #f0cf7e; }
.action.used { opacity: .45; }

/* tabs, chat, log */
.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px; cursor: pointer; color: var(--muted); }
.tabs button.on { color: var(--hazard); border-color: var(--hazard-dim); background: var(--panel2); }
.feed { flex: 1; overflow-y: auto; min-height: 180px; max-height: 50vh; font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
@media (max-width: 860px) { .feed { max-height: 320px; } }
.feed .m { padding: 4px 8px; border-radius: 6px; background: var(--bg2); }
.feed .m .a { font-weight: 600; color: var(--hazard); margin-right: 4px; }
.feed .m.dead .a { color: var(--muted); }
.feed .m.dead .a::after { content: ' ☠'; }
.feed .m.host .a { color: var(--blue); }
.feed .m.sys { color: var(--muted); font-style: italic; background: transparent; }
.feed .t { color: #6f7268; font-size: 11px; margin-right: 6px; }

/* lobby */
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-bottom: 1px solid #2a2f2a; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.set-grid label > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
fieldset:disabled { opacity: .75; }
legend { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; padding: 0 6px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { width: 100%; max-width: 440px; max-height: 85vh; overflow: auto; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.error { border-color: var(--rust); color: #ffc7b6; }

.tally { list-style: none; padding: 0; margin: 6px 0 0; }
.tally li { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; }
.end-hero { text-align: center; padding: 22px; }
.end-hero h1 { font-size: 34px; color: var(--hazard); }
table.res { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.res th, table.res td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.res th { color: var(--muted); font-weight: 400; font-size: 12px; }
table.res tr.surv td:first-child { color: var(--ok); font-weight: 600; }
.tablewrap { overflow-x: auto; }

/* кнопки ведущего — по наведению, на тач-экранах всегда */
.pc .hctl { display: none; }
.pc .traits li:hover .hctl { display: inline-flex; }
@media (hover: none) { .pc .hctl { display: inline-flex; } }
.side .feed { min-height: 260px; }
.side .mine { max-height: 48vh !important; }
input[type=radio] { width: auto; accent-color: var(--hazard); }
a.btn { text-decoration: none; display: inline-block; }
.wait-hero { display: flex; gap: 16px; align-items: center; }
.wchips { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wchip { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.wchip small { display: block; color: var(--muted); font-size: 12px; }
.wchip b { font-size: 15px; }
.how { margin: 0; padding-left: 20px; } .how li { margin: 6px 0; }
