:root {
  --bg: #12130f;
  --panel: #1d1f19;
  --panel2: #272a22;
  --line: #3d4133;
  --text: #e8e4d4;
  --dim: #9a9784;
  --yellow: #f2b705;
  --red: #e0483a;
  --green: #8fb339;
  --head: 'Russo One', Impact, 'Arial Black', sans-serif;
  --body: 'Roboto Condensed', 'Arial Narrow', Arial, sans-serif;
  --mono: 'PT Mono', Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(242, 183, 5, .12), transparent 60%),
    repeating-linear-gradient(90deg, transparent 0 119px, rgba(255, 255, 255, .018) 119px 120px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(0, 0, 0, .25) 79px 80px),
    var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--body);
}
h1, h2, h3 { font-family: var(--head); font-weight: 400; letter-spacing: .04em; margin: 0 0 .5em; }
h2 { font-size: 1.1rem; text-transform: uppercase; color: var(--yellow); }
h3 { font-size: .95rem; text-transform: uppercase; }
.hazard { height: 10px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 18px, #14130f 18px 36px); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .35);
  margin-bottom: 14px;
}
label { display: block; margin-bottom: 10px; color: var(--dim); font-size: .9rem; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
input, select {
  display: block; width: 100%; margin-top: 3px; padding: 9px 10px;
  background: #0d0e0b; color: var(--text); border: 1px solid var(--line); border-radius: 3px;
  font: inherit;
}
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--yellow); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 3px;
  padding: 8px 14px; font: 700 .95rem var(--body); cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--yellow); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--yellow); border-color: var(--yellow); color: #17150b; font-family: var(--head); font-weight: 400; }
.btn.danger { border-color: var(--red); color: #ffb4ab; }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 9px; font-size: .82rem; }
.btn.on { background: var(--yellow); color: #17150b; border-color: var(--yellow); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- главная ---------- */
.home { max-width: 760px; margin: 0 auto; padding: 30px 16px 60px; text-align: center; }
.home .logo { width: 96px; }
.home h1 { font-size: clamp(3rem, 14vw, 7rem); margin: 0; color: var(--yellow); text-shadow: 4px 4px 0 #000; }
.tagline { color: var(--dim); font-family: var(--mono); margin-bottom: 28px; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; text-align: left; }
.home-grid form { display: flex; flex-direction: column; }
.home-grid .btn { margin-top: auto; }
.code-input { text-transform: uppercase; font-family: var(--mono); letter-spacing: .35em; }

/* ---------- игра ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  padding: 8px 16px; background: rgba(18, 19, 15, .96); border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--head); color: var(--yellow); font-size: 1.2rem; }
.stat { font-family: var(--mono); font-size: .85rem; color: var(--dim); }
.stat b { color: var(--text); font-size: 1rem; }
.timer { font-family: var(--mono); font-size: 1.5rem; margin-left: auto; min-width: 4.5ch; text-align: right; }
.timer.low { color: var(--red); animation: blink 1s steps(2) infinite; }
.timer.paused { color: var(--dim); }
@keyframes blink { 50% { opacity: .45; } }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; padding: 14px 16px; align-items: start; }
.side { position: sticky; top: 62px; max-height: calc(100vh - 74px); display: flex; flex-direction: column; overflow-y: auto; }
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
}

.cat-card { border-left: 6px solid var(--red); }
.cat-card h2 { color: var(--red); font-size: 1.35rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: .8rem var(--mono); padding: 3px 8px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel2); }
.chip.closed { color: var(--dim); border-style: dashed; }
.chip.warn { border-color: var(--red); color: #ffb4ab; }

.action { border-color: var(--yellow); }
.action p { margin: 0 0 10px; }
.big { font-size: 1.15rem; }

.mine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.card {
  position: relative; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; min-height: 86px;
}
.card small { color: var(--dim); text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; }
.card.open { border-color: var(--green); }
.card .btn { margin-top: auto; align-self: flex-start; }
.card.special { border-color: var(--yellow); background: linear-gradient(160deg, #33300f, var(--panel2) 60%); }
.card.special p { margin: 0; font-size: .88rem; color: var(--dim); }
.card.used { opacity: .4; filter: grayscale(1); }
.notes { font-family: var(--mono); font-size: .82rem; color: var(--green); }

.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.player { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.player.me { border-color: var(--green); }
.player.turn { border-color: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }
.player.out { opacity: .55; background: repeating-linear-gradient(45deg, #1d1f19 0 10px, #2a1a17 10px 20px); }
.player header { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.player header strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: .8rem; }
.player dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 0; font-size: .87rem; }
.player dt { color: var(--dim); font-size: .75rem; padding-top: 2px; }
.player dd { margin: 0; overflow-wrap: anywhere; }
.player dd.hidden { color: #55584a; }
.player dd.secret { color: var(--dim); font-style: italic; }

.comms { display: flex; flex-direction: column; min-height: 300px; flex: 1; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab { flex: 1; background: transparent; border: 0; border-bottom: 2px solid var(--line); color: var(--dim); padding: 4px; cursor: pointer; font-family: var(--head); }
.tab.active { color: var(--yellow); border-color: var(--yellow); }
.feed { flex: 1; overflow-y: auto; height: 280px; font-size: .88rem; overflow-wrap: anywhere; }
.feed div { padding: 2px 0; }
.feed b { color: var(--yellow); }
.feed .system { color: #ffd9a0; font-family: var(--mono); font-size: .8rem; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { margin: 0; }

.host { border-color: #6a5410; }
.host .row .btn { flex: 1; }
.host .row { margin-bottom: 8px; }

.code-big { font: 2.6rem var(--mono); letter-spacing: .3em; color: var(--yellow); }
.lobby-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.lobby-list li { display: flex; gap: 6px; align-items: center; background: var(--panel2); padding: 6px 8px; border-radius: 3px; }
.lobby-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score { font: 4rem var(--head); line-height: 1; }
.score.good { color: var(--green); }
.score.mid { color: var(--yellow); }
.score.bad { color: var(--red); }
.story { padding-left: 0; list-style: none; }
.story li { padding: 6px 0 6px 28px; position: relative; border-bottom: 1px dashed var(--line); }
.story li::before { content: '•'; position: absolute; left: 8px; color: var(--yellow); }
.story li.good::before { content: '✔'; color: var(--green); }
.story li.bad::before { content: '✖'; color: var(--red); }

dialog {
  background: var(--panel); color: var(--text); border: 2px solid var(--yellow); border-radius: 6px;
  width: min(520px, calc(100vw - 32px)); max-height: 85vh; padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.chip.current { background: var(--yellow); border-color: var(--yellow); color: #17150b; }
dialog .pick small { display: block; font-weight: 400; font-size: .76rem; opacity: .75; overflow-wrap: anywhere; }
dialog .choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin-bottom: 12px; }
dialog .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.casting {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 15;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  background: var(--yellow); color: #17150b; border: 3px solid #14130f; border-radius: 6px;
  padding: 12px 20px; font-family: var(--head); box-shadow: 0 6px 30px rgba(0, 0, 0, .6);
}
.casting p { margin: 0; }
.casting small { display: block; font-family: var(--body); }
.casting .row { justify-content: center; margin-top: 8px; }
.casting .btn { font-family: var(--body); }
.casting .btn.primary { background: #14130f; border-color: #14130f; color: var(--yellow); }
.error { color: #ffb4ab; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 200%); transition: transform .25s;
  background: var(--red); color: #fff; padding: 10px 18px; border-radius: 4px; max-width: calc(100vw - 32px);
  z-index: 20; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
