/* ============================================================
   БУНКЕР 1337 — interface
   ============================================================ */
:root {
  --bg: #080a0e;
  --bg-2: #0e1218;
  --panel: #121821;
  --panel-2: #161e29;
  --line: #222d3c;
  --line-2: #2f3d50;
  --text: #e8eef6;
  --dim: #8b9aad;
  --dim-2: #5d6b7d;
  --acc: #ffb340;
  --acc-2: #ff8a1f;
  --ok: #3ddc84;
  --bad: #ff4d5e;
  --warn: #ffd166;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .95);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --acc-rgb: 255, 179, 64;
}

[data-theme="light"] {
  --bg: #eceff4;
  --bg-2: #e2e7ee;
  --panel: #ffffff;
  --panel-2: #f4f6fa;
  --line: #d7dee8;
  --line-2: #c2ccda;
  --text: #131a24;
  --dim: #5b6879;
  --dim-2: #8894a4;
  --shadow: 0 18px 36px -20px rgba(20, 30, 50, .45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(120% 70% at 50% -10%, rgba(var(--acc-rgb), .10), transparent 60%),
    radial-gradient(90% 60% at 110% 100%, rgba(255, 77, 94, .06), transparent 60%);
  background-attachment: fixed;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
}

/* subtle CRT grid */
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: 100% 3px;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: calc(14px + var(--safe-t)) 16px calc(18px + var(--safe-b));
  gap: 14px;
  animation: screen-in .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 18px;
  transition: .15s;
}
.icon-btn:active { transform: scale(.94); color: var(--text); border-color: var(--line-2); }
.icon-btn.on { color: var(--acc); border-color: rgba(var(--acc-rgb), .45); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim-2);
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.page-sub { color: var(--dim); font-size: 14px; }

/* ---------- logo ---------- */
.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px 0 8px;
  gap: 6px;
}
.logo-mark {
  width: 92px; height: 92px;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 3px solid var(--acc);
  position: relative;
  box-shadow: 0 0 0 6px rgba(var(--acc-rgb), .07), 0 0 44px -8px rgba(var(--acc-rgb), .55);
  background: radial-gradient(circle at 50% 30%, rgba(var(--acc-rgb), .18), transparent 70%);
  animation: pulse 4s ease-in-out infinite;
}
.logo-mark::before, .logo-mark::after {
  content: "";
  position: absolute;
  background: var(--acc);
  opacity: .9;
}
.logo-mark::before { width: 44px; height: 4px; }
.logo-mark::after { width: 4px; height: 44px; }
.logo-mark span {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px dashed rgba(var(--acc-rgb), .4);
  animation: spin 18s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(var(--acc-rgb), .07), 0 0 40px -10px rgba(var(--acc-rgb), .5); }
  50% { box-shadow: 0 0 0 10px rgba(var(--acc-rgb), .05), 0 0 60px -6px rgba(var(--acc-rgb), .7); }
}
.logo-title {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: .12em;
  line-height: 1;
  margin-top: 12px;
  text-transform: uppercase;
}
.logo-title em { color: var(--acc); font-style: normal; }
.logo-tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  letter-spacing: .14em;
  text-transform: uppercase;
  max-width: 300px;
}

/* ---------- buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  transition: transform .12s, filter .15s, background .15s;
  user-select: none;
}
.btn:active { transform: scale(.975); }
.btn.primary {
  background: linear-gradient(180deg, var(--acc), var(--acc-2));
  color: #1a1005;
  border-color: transparent;
  box-shadow: 0 10px 30px -12px rgba(var(--acc-rgb), .8), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn.primary:active { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(255,77,94,.35); }
.btn.sm { min-height: 40px; font-size: 14px; padding: 8px 12px; border-radius: 11px; }
.btn.xs { min-height: 32px; font-size: 12px; padding: 4px 10px; border-radius: 9px; gap: 5px; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.block { width: 100%; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt-auto { margin-top: auto; }

/* ---------- cards / panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.panel.flat { background: var(--panel); }
.panel-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.panel-head h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.panel-head .spacer { flex: 1; }
.hint { color: var(--dim); font-size: 13px; }
.tiny { font-size: 11px; }
.mono { font-family: var(--mono); }
.acc { color: var(--acc); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.dim { color: var(--dim); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.divider { height: 1px; background: var(--line); margin: 4px 0; }

/* hazard strip */
.hazard {
  height: 6px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, var(--acc) 0 8px, transparent 8px 16px);
  opacity: .55;
}

/* ---------- option rows (settings) ---------- */
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: .15s;
}
.opt + .opt { margin-top: 8px; }
.opt .opt-ico { font-size: 20px; width: 24px; text-align: center; }
.opt .opt-body { flex: 1; min-width: 0; }
.opt .opt-name { font-weight: 600; font-size: 15px; }
.opt .opt-desc { color: var(--dim); font-size: 12px; }

.switch {
  width: 48px; height: 28px;
  border-radius: 20px;
  background: var(--line);
  position: relative;
  flex: none;
  transition: background .18s;
  border: 1px solid var(--line);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--dim);
  transition: .18s cubic-bezier(.3,.9,.3,1);
}
.switch.on { background: rgba(var(--acc-rgb), .2); border-color: rgba(var(--acc-rgb), .5); }
.switch.on::after { left: 23px; background: var(--acc); box-shadow: 0 0 10px rgba(var(--acc-rgb), .8); }

/* stepper */
.stepper {
  display: flex; align-items: center; gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  flex: none;
}
.stepper button {
  width: 34px; height: 34px;
  border-radius: 9px;
  font-size: 20px;
  font-weight: 700;
  color: var(--dim);
  display: grid; place-items: center;
}
.stepper button:active { background: var(--line); color: var(--text); }
.stepper .val {
  min-width: 34px;
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
}

/* ---------- scenario picker ---------- */
.scn-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.scn-scroll::-webkit-scrollbar { display: none; }
.scn {
  flex: none;
  width: 152px;
  min-height: 150px;
  border-radius: 14px;
  padding: 12px;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(var(--acc-rgb), .16), transparent 60%),
    var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  scroll-snap-align: start;
  transition: .18s;
  position: relative;
  overflow: hidden;
}
.scn:active { transform: scale(.97); }
.scn.sel { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc) inset, 0 12px 26px -16px rgba(var(--acc-rgb), .8); }
.scn .scn-emoji { font-size: 26px; line-height: 1; }
.scn .scn-name { font-weight: 800; font-size: 15px; line-height: 1.15; }
.scn .scn-tag { color: var(--dim); font-size: 11px; line-height: 1.3; margin-top: auto; }
.scn .scn-check {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--line-2);
}
.scn.sel .scn-check { background: var(--acc); border-color: var(--acc); }
.scn.sel .scn-check::after {
  content: "✓"; color: #1a1005; font-size: 12px; font-weight: 900;
  display: grid; place-items: center; height: 100%;
}

/* ---------- player chips ---------- */
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.player-row + .player-row { margin-top: 8px; }

.avatar {
  width: 44px; height: 44px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 22px;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  position: relative;
  overflow: hidden;
}
.avatar.sm { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
.avatar.lg { width: 64px; height: 64px; font-size: 32px; border-radius: 18px; }
.avatar .ring {
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--p-color, var(--acc));
  opacity: .85;
}
.avatar.dead { filter: grayscale(1); opacity: .4; }

.pl-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.pl-name .you {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  background: var(--acc); color: #1a1005;
  padding: 1px 5px; border-radius: 4px; font-weight: 900;
}
.pl-meta { font-size: 12px; color: var(--dim); }

/* ---------- game table ---------- */
.game-top {
  position: sticky; top: 0;
  z-index: 5;
  margin: -8px -16px 0;
  padding: calc(8px + var(--safe-t)) 16px 8px;
  background: linear-gradient(180deg, var(--bg) 65%, transparent);
  backdrop-filter: blur(8px);
}
.game-top-inner {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
}
.stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.stat .k { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim-2); }
.stat .v { font-family: var(--mono); font-weight: 800; font-size: 15px; line-height: 1.1; }
.stat .v.bad { color: var(--bad); }

.round-pill {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(var(--acc-rgb), .12);
  color: var(--acc);
  border: 1px solid rgba(var(--acc-rgb), .3);
  text-transform: uppercase;
  white-space: nowrap;
}

.pl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.pl-card {
  text-align: left;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: .16s;
  min-height: 118px;
}
.pl-card:active { transform: scale(.97); }
.pl-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--p-color, var(--acc));
  opacity: .8;
}
.pl-card.dead { opacity: .45; filter: grayscale(.7); }
.pl-card.dead::after {
  content: "ВНЕ БУНКЕРА";
  position: absolute; inset: auto 0 0 0;
  background: var(--bad);
  color: #fff;
  font-size: 9px; font-weight: 900; letter-spacing: .16em;
  text-align: center;
  padding: 2px 0;
}
.pl-card.me { border-color: rgba(var(--acc-rgb), .45); }
.pl-card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pl-card-name { font-weight: 700; font-size: 13px; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card-sub { font-size: 10px; color: var(--dim); font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--dim);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  line-height: 1.4;
}
.chip.open { color: var(--text); border-color: var(--line-2); }
.chip.locked { color: var(--dim-2); opacity: .7; letter-spacing: .05em; }

/* event banner */
.event-banner {
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255,77,94,.13), rgba(255,179,64,.08));
  border: 1px solid rgba(255,77,94,.32);
  display: flex; gap: 10px; align-items: flex-start;
  animation: screen-in .3s ease;
}
.event-banner.ok { background: linear-gradient(135deg, rgba(61,220,132,.12), rgba(61,220,132,.04)); border-color: rgba(61,220,132,.32); }
.event-banner .ev-ico { font-size: 22px; line-height: 1.1; }
.event-banner .ev-title { font-weight: 800; font-size: 14px; }
.event-banner .ev-text { font-size: 12.5px; color: var(--dim); margin-top: 2px; }

/* bottom dock */
.dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 10px 0 calc(4px + var(--safe-b));
  background: linear-gradient(0deg, var(--bg) 55%, transparent);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 4;
}

/* timer bar */
.timer-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}
.timer-bar { flex: 1; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.timer-bar i { display: block; height: 100%; background: var(--acc); border-radius: 4px; transition: width .95s linear; }
.timer-bar i.low { background: var(--bad); }
.timer-num { font-family: var(--mono); font-weight: 800; font-size: 14px; min-width: 44px; text-align: right; }

/* ---------- full player card ---------- */
.card-hero {
  display: flex; gap: 14px; align-items: center;
  padding: 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(var(--p-rgb, var(--acc-rgb)), .18), transparent 55%),
    linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
}
.card-hero .name { font-size: 22px; font-weight: 900; line-height: 1.1; }
.card-hero .sub { color: var(--dim); font-size: 12.5px; margin-top: 3px; font-family: var(--mono); }

.attr-list { display: flex; flex-direction: column; gap: 8px; }
.attr {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.attr .a-ico { font-size: 18px; width: 22px; text-align: center; flex: none; }
.attr .a-body { flex: 1; min-width: 0; }
.attr .a-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim-2); }
.attr .a-v { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.attr.locked .a-v { color: var(--dim-2); font-weight: 400; letter-spacing: .2em; }
.attr.locked { background: repeating-linear-gradient(45deg, var(--panel) 0 10px, var(--bg-2) 10px 20px); }
.attr .a-badge {
  font-family: var(--mono); font-size: 10px; padding: 1px 6px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
}
.attr.fresh { animation: fresh .8s ease; }
@keyframes fresh {
  0% { box-shadow: 0 0 0 0 rgba(var(--acc-rgb), .6); border-color: var(--acc); }
  100% { box-shadow: 0 0 0 14px rgba(var(--acc-rgb), 0); }
}

/* ---------- vote ---------- */
.vote-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  width: 100%;
  text-align: left;
  transition: .15s;
}
.vote-item + .vote-item { margin-top: 8px; }
.vote-item.sel { border-color: var(--bad); background: rgba(255,77,94,.1); box-shadow: 0 0 0 1px var(--bad) inset; }
.vote-item:disabled { opacity: .35; }

.tally {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 4px;
}
.tally-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.tally-row .bar { flex: 1; height: 16px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.tally-row .bar i { display: block; height: 100%; background: var(--bad); }
.tally-row .bar i.win { background: var(--bad); }
.tally-row .bar i.safe { background: var(--line-2); }

/* ---------- result ---------- */
.big-emoji { font-size: 64px; line-height: 1; text-align: center; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.verdict {
  text-align: center;
  font-size: 28px; font-weight: 900; letter-spacing: -.01em;
}
.verdict.bad { color: var(--bad); }
.verdict.ok { color: var(--ok); }

/* ---------- end screen ---------- */
.gauge {
  position: relative;
  width: 140px; height: 140px;
  margin: 0 auto;
  display: grid; place-items: center;
}
.gauge svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.gauge .g-val { font-family: var(--mono); font-size: 30px; font-weight: 900; }
.gauge .g-lab { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; color: var(--dim); text-transform: uppercase; }

.epilogue {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
}
.epilogue p + p { margin-top: 10px; }
.epilogue .em { color: var(--acc); font-weight: 700; }

.log-line {
  display: flex; gap: 8px;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  color: var(--dim);
}
.log-line:last-child { border-bottom: 0; }
.log-line .r { font-family: var(--mono); color: var(--acc); flex: none; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translate(-50%, 20px);
  background: rgba(18,24,33,.96);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: .25s cubic-bezier(.2,.9,.2,1);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- misc ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim);
  letter-spacing: .04em;
}
.tag.acc { color: var(--acc); border-color: rgba(var(--acc-rgb), .35); background: rgba(var(--acc-rgb), .08); }
.tag.bad { color: var(--bad); border-color: rgba(255,77,94,.32); background: rgba(255,77,94,.08); }
.tag.ok { color: var(--ok); border-color: rgba(61,220,132,.32); background: rgba(61,220,132,.08); }

.input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--text);
  outline: none;
  font-size: 15px;
}
.input:focus { border-color: var(--acc); }
textarea.input { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; }

.seg {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--dim);
  transition: .15s;
}
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 2px 10px -4px rgba(0,0,0,.6); }

.chip-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-select button {
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--dim);
  font-weight: 600;
}
.chip-select button.on { border-color: var(--acc); color: var(--acc); background: rgba(var(--acc-rgb), .1); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid transparent;
  position: relative;
}
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }

.note {
  font-size: 12.5px;
  color: var(--dim);
  background: var(--panel-2);
  border-left: 2px solid var(--acc);
  border-radius: 0 10px 10px 0;
  padding: 9px 11px;
  line-height: 1.45;
}

.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.stat-big {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.stat-big .sv { font-family: var(--mono); font-size: 22px; font-weight: 900; }
.stat-big .sk { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim-2); }

@media (min-width: 480px) {
  .pl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- доп. элементы ---------- */
.emoji-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  scrollbar-width: none;
}
.emoji-row::-webkit-scrollbar { display: none; }
.emoji-btn {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 21px;
  display: grid;
  place-items: center;
  transition: .15s;
}
.emoji-btn:active { transform: scale(.92); }
.emoji-btn.on {
  border-color: var(--acc);
  background: rgba(var(--acc-rgb), .12);
  box-shadow: 0 0 0 1px var(--acc) inset;
}
textarea.input { flex: 1; }

/* ---------- терминал на главной ---------- */
.terminal {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 2;
  color: var(--dim);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}
.terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.terminal .t-k { color: var(--dim-2); letter-spacing: .1em; display: inline-block; min-width: 168px; }
.terminal .cursor { animation: blink 1.1s steps(1) infinite; color: var(--acc); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- строка раунда ---------- */
.round-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 0;
}

/* ---------------------------------------------------------- */
.screen { padding-bottom: calc(26px + var(--safe-b)); }

.home .logo-wrap { flex: 1; justify-content: center; padding-top: 0; }

.btn:disabled {
  background: var(--panel);
  color: var(--dim-2);
  border: 1px solid var(--line);
  box-shadow: none;
  opacity: .8;
}

.opt { text-align: left; }
.center > .avatar { margin-left: auto; margin-right: auto; }
.screen > textarea.input { flex: 0 1 auto; min-height: 170px; max-height: 42vh; }

.scn-scroll {
  scroll-padding-inline: 2px;
  overscroll-behavior-x: contain;
}

/* ============================================================
   Десктоп / широкие экраны
   ============================================================ */
.home-grid { display: flex; flex-direction: column; flex: 1; gap: 14px; }
.home-side { display: flex; flex-direction: column; gap: 14px; }
.home-foot { margin-top: 4px; }
.setup-cols { display: flex; flex-direction: column; gap: 14px; }
.setup-col { display: flex; flex-direction: column; gap: 14px; }
.game-cols { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.game-main { display: flex; flex-direction: column; gap: 14px; }
.game-side { display: contents; }
.side-panel { display: none; }
.resume-card { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }

.room-code {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 900;
  letter-spacing: .18em;
  color: var(--acc);
  line-height: 1.1;
  margin: 6px 0 2px;
  text-shadow: 0 0 26px rgba(var(--acc-rgb), .45);
}
.room-code.small { font-size: 24px; letter-spacing: .12em; margin: 0; }
.code-input {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .34em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
}

@media (min-width: 860px) {
  #app { max-width: 1120px; }
  .screen { padding: 22px 28px 32px; gap: 18px; }
  .screen.narrow { max-width: 780px; margin: 0 auto; width: 100%; }

  .home-grid {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    align-items: center;
    gap: 56px;
    padding-top: 10px;
  }
  .home .logo-wrap { padding: 0; }
  .logo-mark { width: 118px; height: 118px; }
  .logo-mark::before { width: 56px; }
  .logo-mark::after { height: 56px; }
  .logo-title { font-size: 58px; letter-spacing: .1em; }
  .logo-tag { font-size: 13px; max-width: 380px; }

  .setup-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 22px;
    align-items: start;
  }
  .setup-col { gap: 18px; }
  .scn { width: 176px; min-height: 168px; }

  .game-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 22px;
    align-items: start;
  }
  .game-side { display: block; position: sticky; top: 18px; }
  .side-panel { display: block; margin-bottom: 12px; }
  .game-side .dock {
    position: static;
    margin: 0;
    padding: 0;
    background: none;
    backdrop-filter: none;
  }
  .game-top { margin: -10px -28px 0; padding: 12px 28px 10px; }
  .pl-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .pl-card { min-height: 140px; }
  .attr-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .kbd-grid { grid-template-columns: repeat(3, 1fr); }

  .btn { min-height: 50px; }
  .panel { padding: 18px; border-radius: 18px; }
}

@media (min-width: 860px) and (hover: hover) {
  .btn:hover { border-color: var(--line-2); background: var(--panel-2); }
  .btn.primary:hover { filter: brightness(1.06); background: linear-gradient(180deg, var(--acc), var(--acc-2)); }
  .pl-card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow); }
  .vote-item:hover { border-color: var(--line-2); }
  .scn:hover { transform: translateY(-2px); }
  .opt:hover { border-color: var(--line-2); }
}

@media (min-width: 1200px) {
  .game-cols { grid-template-columns: minmax(0, 1fr) 380px; }
}

.setup-cta { display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 860px) {
  .setup-cta { max-width: 560px; margin: 4px auto 0; width: 100%; }
}

/* ---------- место под бейдж Netlify (бесплатный план) ---------- */
:root { --badge-space: 68px; }
@media (min-width: 860px) { :root { --badge-space: 0px; } }
.dock { bottom: var(--badge-space); }
.screen { padding-bottom: calc(26px + var(--badge-space) + var(--safe-b)); }
.home-foot { margin-bottom: var(--badge-space); }
@media (min-width: 860px) { .game-side .dock { bottom: auto; } }

@media (hover: hover) {
  .scn:hover { transform: none; border-color: var(--line-2); box-shadow: 0 10px 24px -18px rgba(0,0,0,.9); }
  .scn.sel:hover { border-color: var(--acc); }
}

.screen.no-anim { animation: none; }

/* ---------- экран пароля ---------- */
.lock-screen .logo-wrap { flex: 1; justify-content: center; padding-top: 0; }
.lock-screen .logo-tag { color: var(--acc); }

/* ---------- карты бункера и угроз ---------- */
.round-cards { display: flex; flex-direction: column; gap: 8px; }
.rcard {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
}
.rcard.bunker { border-color: rgba(61,220,132,.28); background: linear-gradient(135deg, rgba(61,220,132,.09), transparent); }
.rcard.threat { border-color: rgba(255,179,64,.28); background: linear-gradient(135deg, rgba(255,179,64,.08), transparent); }
.rcard.threat.ok { border-color: rgba(61,220,132,.35); background: linear-gradient(135deg, rgba(61,220,132,.10), transparent); }
.rcard.threat.bad { border-color: rgba(255,77,94,.35); background: linear-gradient(135deg, rgba(255,77,94,.10), transparent); }
.rc-ico { font-size: 20px; line-height: 1.15; flex: none; }
.rc-body { min-width: 0; }
.rc-k { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim-2); }
.rc-v { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.rc-f { font-size: 12px; margin-top: 3px; }
.rc-f.ok { color: var(--ok); }
.rc-f.bad { color: var(--bad); }

/* ---------- выбор карты ---------- */
.choose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choose-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; border-radius: 14px; text-align: left;
  background: var(--panel); border: 1px solid var(--line);
  transition: .15s;
}
.choose-card:active { transform: scale(.98); }
.cc-ico { font-size: 22px; }
.cc-name { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.cc-val { font-weight: 700; font-size: 13.5px; line-height: 1.3; }

@media (min-width: 860px) {
  .round-cards { display: grid; grid-template-columns: 1fr 1fr; }
  .choose-grid { grid-template-columns: repeat(3, 1fr); }
  .choose-card:hover { border-color: var(--line-2); }
}

/* нижний док игры выше остальных — оставляем место под него */
.screen.has-dock { padding-bottom: calc(150px + var(--badge-space) + var(--safe-b)); }
@media (min-width: 860px) { .screen.has-dock { padding-bottom: 32px; } }
.screen.has-dock .dock .btn.sm { font-size: 13px; padding: 8px 6px; }
