* { box-sizing: border-box; }
:root { --bg: rgba(14,10,34,.86); --line: rgba(255,255,255,.1); --accent: #8f7bff; --gold: #ffd23f; --text: #f1eeff; --muted: #a9a3c9; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
canvas { display: block; }
body.playing canvas { cursor: none; }
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); border-radius: 10px;
  padding: 7px 12px; font-weight: 700; transition: background .12s, transform .08s, border-color .12s; }
button:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); }
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(180deg, #ffd23f, #ff9a3c); color: #24122e; border-color: transparent; font-weight: 900; }
button.primary:hover { filter: brightness(1.08); }
button.primary.off { filter: grayscale(.8) brightness(.7); }
button.accent { background: var(--accent); border-color: transparent; color: #fff; }
button.icon { width: 46px; font-size: 20px; padding: 0; border-radius: 14px; }
select { background: #221b45; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; padding: 6px 8px; font-weight: 700; cursor: pointer; }
kbd { display: inline-block; font: 700 11px/1 ui-monospace, Menlo, monospace; padding: 3px 5px; border-radius: 5px;
  background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.25); margin-left: 4px; vertical-align: 1px; }
.muted { color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 8px; }

.ov { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.ov > * { pointer-events: auto; }
.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px;
  backdrop-filter: blur(8px); box-shadow: 0 12px 40px rgba(0,0,0,.4); }
h3 { margin: 2px 0 10px; font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: #cfc6ff; }
section { margin-bottom: 14px; }
.desc { color: #bdb4e0; font-size: 12.5px; line-height: 1.45; margin: 8px 0 6px; }
.desc.small { font-size: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.row > span { font-size: 13px; color: #cfc6ff; font-weight: 700; }

/* ---------- верх ---------- */
.lb-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 12px; align-items: stretch; justify-content: center; }
.logo { font: 900 40px/1 "Arial Black", Impact, sans-serif; letter-spacing: 1px; text-shadow: 0 4px 0 #3b1f58, 0 0 30px rgba(255,120,80,.4);
  display: flex; flex-direction: column; justify-content: center; white-space: nowrap; pointer-events: none; margin-right: 6px; }
.logo small { font: 800 11px/1.6 system-ui, sans-serif; letter-spacing: 1px; color: #ffd9a0; text-shadow: none; }
.room { display: flex; gap: 16px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 8px 16px; backdrop-filter: blur(8px); }
.room label { display: block; font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 800; margin-bottom: 2px; }
.room-name input { background: transparent; border: 0; border-bottom: 2px dashed rgba(255,255,255,.22); font-weight: 900; font-size: 19px; width: 190px; outline: none; padding: 1px 0; }
.room-name input:focus { border-bottom-color: var(--gold); }
.room-code b { font: 900 32px/1 "Arial Black", Impact, sans-serif; letter-spacing: 6px; color: #ffe066; }
.room-how { font-size: 12.5px; color: #d8d0f5; max-width: 360px; line-height: 1.4; }
.room-how b { color: #9fe3ff; }

/* ---------- панели ---------- */
.lb-left { position: absolute; left: 12px; top: var(--panelTop, 92px); bottom: var(--panelBottom, 84px); width: 384px; overflow-y: auto; }
.lb-right { position: absolute; right: 12px; top: var(--panelTop, 92px); bottom: var(--panelBottom, 84px); width: 404px; overflow-y: auto; overflow-x: hidden; }

.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mapcard { position: relative; padding: 0; border-radius: 12px; overflow: hidden; text-align: left; border: 2px solid transparent; background: #000; }
.mapcard canvas { width: 100%; aspect-ratio: 16/9; display: block; }
.mapcard .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 5px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.85));
  font-size: 12.5px; font-weight: 900; display: flex; justify-content: space-between; align-items: end; }
.mapcard .cap i { font-style: normal; }
.mapcard.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,210,63,.25); }
.mapcard:hover { border-color: rgba(255,255,255,.5); }
.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.tags span { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(143,123,255,.18); color: #d8d0ff; font-weight: 700; }

.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.themes button { display: flex; align-items: center; gap: 7px; padding: 6px 8px; font-size: 12.5px; }
.themes button i { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.themes button.on { border-color: var(--gold); background: rgba(255,210,63,.14); }

.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 5px; }
.modes button { display: flex; align-items: center; gap: 7px; padding: 6px 9px; min-height: 36px; font-size: 12px; font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modes button i { font-style: normal; font-size: 17px; }
.modes button.on { border-color: var(--gold); background: rgba(255,210,63,.14); }
.seg { display: inline-flex; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; padding: 6px 11px; background: transparent; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; }
.seg.small button { padding: 6px 7px; font-size: 12px; }
details { border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; color: #cfc6ff; font-weight: 800; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.chips button { font-size: 12px; padding: 5px 9px; border-radius: 99px; }
.chips button.on { background: #43e07a; color: #0d2a17; border-color: transparent; }

/* ---------- игроки ---------- */
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.pc { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 2px 8px; padding: 7px 8px; border-radius: 13px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-left: 4px solid var(--c); min-height: 74px; }
.pc.empty { display: flex; align-items: center; justify-content: center; color: #7f78a3; font-size: 12.5px; border: 1px dashed rgba(255,255,255,.14); }
.pc canvas { grid-row: 1 / span 3; width: 40px; height: 54px; align-self: center; }
.pc input { min-width: 0; width: calc(100% - 22px); background: transparent; border: 0; border-bottom: 1px dashed transparent; font-weight: 900; color: var(--c); outline: none; font-size: 13.5px; padding: 0; }
.pc input:hover, .pc input:focus { border-bottom-color: rgba(255,255,255,.3); }
.pc .meta { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.pc .meta .gone { color: #ff8a8a; }
.pc select { padding: 1px 3px; font-size: 11px; border-radius: 6px; max-width: 100%; min-width: 0; }
.pc .meta select.per { flex: 1 1 100%; }
.pc .rm { position: absolute; top: 4px; right: 4px; padding: 0 6px; font-size: 11px; border-radius: 7px; line-height: 18px; opacity: .55; }
.pc .rm:hover { opacity: 1; }
.pc .team { padding: 0 6px; font-size: 11px; border-radius: 6px; font-weight: 900; line-height: 18px; }
.pc .stars { color: #ffd23f; letter-spacing: -1px; }
.botbar { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.botbar select { flex: 1; min-width: 0; }

/* ---------- низ ---------- */
.lb-bottom { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 16px; backdrop-filter: blur(8px); max-width: calc(100vw - 24px); }
.summary { font-size: 13px; color: #d8d0f5; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-bottom button { white-space: nowrap; padding: 10px 14px; font-size: 15px; }
.lb-bottom button.primary { font-size: 19px; padding: 10px 28px; }

.hint { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); background: var(--bg); padding: 7px 14px;
  border-radius: 99px; font-size: 13px; z-index: 6; pointer-events: none; }
.toast { position: fixed; top: 46%; left: 50%; transform: translate(-50%,-50%); background: rgba(16,12,38,.94); padding: 14px 22px;
  border-radius: 14px; font-weight: 800; z-index: 20; pointer-events: none; border: 1px solid rgba(255,255,255,.15); }

/* ---------- модальные ---------- */
.modal { background: rgba(6,4,18,.6); pointer-events: auto; display: flex; align-items: center; justify-content: center; z-index: 10; backdrop-filter: blur(3px); }
.box { background: #18123a; border: 1px solid rgba(255,255,255,.14); border-radius: 22px; padding: 20px 22px; width: 380px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 40px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.box.xwide { width: 880px; }
.box h2 { margin: 0 0 6px; font: 900 30px "Arial Black", Impact, sans-serif; }
button.wide { width: 100%; padding: 11px; font-size: 16px; }

#post { display: flex; align-items: flex-end; justify-content: center; padding-bottom: 60px; }
.postbtns { display: flex; gap: 12px; }
.postbtns button { padding: 12px 26px; font-size: 18px; }

.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.tabs button.on { background: var(--accent); border-color: transparent; }
.tabs .grow { flex: 1; }
.tab h4 { margin: 14px 0 6px; font-size: 14px; color: #ffe066; }
.kbgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
table.binds { width: 100%; border-collapse: collapse; }
table.binds td { padding: 4px 4px; font-size: 13px; }
table.binds td:first-child { color: #cfc6ff; font-weight: 700; }
.key { min-width: 64px; padding: 4px 8px; font: 800 13px ui-monospace, Menlo, monospace; }
.key.wait { background: #ffd23f; color: #24122e; animation: blink .6s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.opt > span { font-size: 14px; font-weight: 700; }
.opt > span em { display: block; font-style: normal; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 2px; }
.opt input[type=range] { width: 200px; }
.padlist { font-size: 13px; color: #bdb4e0; }

@media (max-width: 1250px) {
  .lb-left { width: 340px; } .lb-right { width: 360px; }
  .logo { font-size: 28px; } .room-how { display: none; } .summary { display: none; }
}

.teamsrow { display: flex; gap: 6px; align-items: center; margin: -2px 0 8px; }
.teamsrow .seg { flex: 1; }
.teamsrow .seg button { flex: 1; white-space: nowrap; padding: 6px 4px; }
.tsel { display: inline-flex; gap: 3px; }
.tsel button { width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 2px solid transparent; opacity: .45; }
.tsel button.on { opacity: 1; border-color: #fff; transform: scale(1.15); }

/* ---------- поля, плитки, строки игроков ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 2px; min-width: 0; }
.field > label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.field select { width: 100%; }
.tiles { display: grid; gap: 5px; }
.tiles.t5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles.t3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles.t6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tiles.presets { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.tiles.presets button { flex-direction: row; justify-content: flex-start; gap: 7px; min-height: 36px; padding: 5px 9px; }
.tiles.presets button i { font-size: 17px; letter-spacing: 0; }
.tiles.presets button span { font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.toggle { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; font-size: 12.5px; font-weight: 700; color: #d8d0ff; cursor: pointer; user-select: none; }
.toggle input { width: 16px; height: 16px; accent-color: var(--gold); margin: 0; }
.toggle input:disabled + span { opacity: .75; }
.tiles button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 7px 2px; min-height: 52px; }
.tiles button i { font-style: normal; font-size: 17px; line-height: 1; letter-spacing: -4px; }
.tiles button span { font-size: 11.5px; white-space: nowrap; }
.tiles button.on { border-color: var(--gold); background: rgba(255,210,63,.14); }

.pgrid { display: flex; flex-direction: column; gap: 5px; }
.pc { position: relative; display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 6px; border-radius: 12px; min-height: 46px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-left: 4px solid var(--c); }
.pc.empty { justify-content: center; min-height: 32px; color: #7f78a3; font-size: 12px; border: 1px dashed rgba(255,255,255,.12); }
.pc canvas { width: 26px; height: 36px; flex: none; }
.pc .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pc .who input { width: 100%; min-width: 0; background: transparent; border: 0; border-bottom: 1px dashed transparent; font-weight: 900; color: var(--c); outline: none; font-size: 14px; padding: 0; }
.pc .who input:hover, .pc .who input:focus { border-bottom-color: rgba(255,255,255,.3); }
.pc .who small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc .who small .gone { color: #ff8a8a; }
.pc select { flex: none; padding: 3px 4px; font-size: 12px; border-radius: 8px; }
.pc select.per { width: 132px; }
.pc select.sk { width: 64px; }
.pc .tdot { flex: none; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); }
.pc .rm { flex: none; padding: 0 7px; font-size: 12px; border-radius: 8px; line-height: 22px; opacity: .55; position: static; }
.pc .rm:hover { opacity: 1; }
.botbox { margin-top: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.botgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.botgrid.b3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
.botgrid.b3 button { white-space: nowrap; padding: 8px 4px; font-size: 13px; }

.teamsrow .tlabel { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 800; white-space: nowrap; }
.pc .who { gap: 3px; }
.pc .who .top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pc .who .top input { flex: 1; }
.pc .who .bot { display: flex; gap: 5px; min-width: 0; }
.pc .who .bot select.per { flex: 1; width: auto; min-width: 0; }
.pc .who .bot select.sk { flex: none; width: 66px; }
.pc .tdot { width: 18px; height: 18px; }
.pc .rm { line-height: 20px; }

.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.chips button { text-align: left; border-radius: 10px; padding: 7px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Пост-эффекты стилей поверх холста — их рисует видеокарта при компоновке, а не холст каждый кадр */
#fx { position: fixed; pointer-events: none; z-index: 1; display: none; }
#fx.neon { display: block; background:
  radial-gradient(circle farthest-corner at 50% 50%, rgba(0,0,0,0) 34%, rgba(0,0,0,.55) 98%),
  repeating-linear-gradient(to bottom, rgba(0,0,0,.13) 0, rgba(0,0,0,.13) 1px, transparent 1px, transparent 3px); }
#fx.noir { display: block; background: radial-gradient(circle farthest-corner at 50% 50%, rgba(10,10,10,0) 34%, rgba(10,10,10,.7) 98%); }
#fx.noir::before { content: ''; position: absolute; inset: 0; background-image: var(--grain); animation: grain .5s steps(1) infinite; }
@keyframes grain { 0% { background-position: 0 0; } 20% { background-position: -83px 41px; } 40% { background-position: 57px -120px; } 60% { background-position: -140px -33px; } 80% { background-position: 101px 77px; } }

/* Список игроков: 12 мест сеткой 2×6 фиксированной высоты — от входа и выхода игроков ничего не сдвигается */
.lb-right { display: flex; flex-direction: column; overflow: hidden; }
.lb-right > * { flex: none; }
.lb-right .pgrid { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 58px; gap: 6px; align-content: start; }
.pgrid .pc, .pgrid .pc.empty { min-height: 0; height: 58px; box-sizing: border-box; padding: 4px 5px; }
.pgrid .pc canvas { width: 22px; height: 30px; }
.pgrid .pc .who .top input { font-size: 13px; }
.pgrid .pc .who .bot select { font-size: 11px; padding: 2px 3px; }
.pgrid .pc .who .bot select.sk { width: 52px; }
.pgrid .pc .rm { padding: 0 5px; line-height: 18px; font-size: 11px; }
.invisible { visibility: hidden !important; }
#btnSettings { align-self: center; width: 46px; height: 46px; padding: 0; font-size: 20px; }
details.help { margin-top: 8px; padding-top: 8px; }
details.help summary { cursor: pointer; font-size: 12px; font-weight: 800; color: #cfc6ff; letter-spacing: .5px; }
details.help .desc { margin: 6px 0 0; }
.pgrid .pc.empty.join { flex-direction: column; gap: 2px; border-color: rgba(255,210,63,.35); color: #ffe9a0; }
.pgrid .pc.empty.join b { font-size: 12px; }
.pgrid .pc.empty.join small { font-size: 10.5px; color: #cfc6ff; white-space: nowrap; }
.pgrid .pc.empty.join kbd { font-size: 9.5px; padding: 0 4px; margin: 0; }
/* узкие карточки: селекты без системной стрелки — имя характера помещается целиком */
.pgrid .pc .who .bot select { -webkit-appearance: none; appearance: none; cursor: pointer; padding: 2px 13px 2px 4px; font-size: 11px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23bdb4e0'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; }
.pgrid .pc .who .bot select.sk { width: 46px; }
.box.xwide { width: 1000px; }
.key { white-space: nowrap; min-width: 58px; padding: 4px 6px; }
table.binds td:first-child { white-space: nowrap; font-size: 12.5px; }
.kbgrid { gap: 12px; }
table.binds td { padding: 3px 3px; }
