/* Roboto подключается в HTML через Google Fonts. */

:root {
  --bg: #131416;
  --surface: #18181b;
  --surface-2: #232327;
  --line: #33333a;
  --text: #ececee;
  --muted: #a1a1aa;
  --green: #34d399;
  --sky: #38bdf8;
  --violet: #a78bfa;
  --danger: #fb7185;
  --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

/* Полоса невидима, пока по ней не наведешь или не прокрутишь прямо её. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .45); }
.scrolling::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); }
::-webkit-scrollbar-button, ::-webkit-scrollbar-corner { display: none; }
@supports (-moz-appearance: none) {
  * { scrollbar-color: transparent transparent; scrollbar-width: thin; }
  .scrolling { scrollbar-color: rgba(255, 255, 255, .3) transparent; }
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  /* Матовый угольный фон: мелкозернистый шум + едва заметная неоднородность
     оттенка. Никакой картинки — всё масштабируется вместе с окном. */
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.1'/%3E%3C/svg%3E"),
    radial-gradient(1100px 520px at 92% 108%, rgba(255, 255, 255, .026), transparent 62%),
    radial-gradient(900px 460px at 4% 96%, rgba(255, 255, 255, .022), transparent 62%),
    radial-gradient(760px 420px at 50% -12%, rgba(255, 255, 255, .018), transparent 65%);
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-size: 160px 160px, auto, auto, auto;
  background-attachment: fixed;
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 58px;
  padding: 0 clamp(12px, 3vw, 32px);
  border-bottom: 1px solid #222228;
  background: rgba(0, 0, 0, .86);
  backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 900; }
.brand-mark { font-size: 23px; }
.topnav { display: flex; gap: 20px; margin-right: auto; color: var(--muted); font-weight: 700; }
.topnav a:hover { color: var(--text); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 800;
  transition: filter .15s ease, transform .15s ease;
}
.button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.button.primary {    color: #d7d7d7; background: none; border: 1px solid #282828; }
.button.ghost { color: var(--text); border-color: var(--line); background: var(--surface); }
.button.small { padding: 7px 13px; font-size: 13px; }
.button.danger { color: #fff; background: #7f1d2e; }
.button:disabled { opacity: .42; cursor: not-allowed; filter: none; transform: none; }
.button:disabled:hover { filter: none; transform: none; }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(52, 211, 153, .12); }
.live-dot.off { background: var(--muted); box-shadow: none; }
.card { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; font-size: 13px; font-weight: 800; }
.count { color: var(--green); font-size: 12px; }
.label { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; }
.link-button { border: 0; padding: 0; color: var(--sky); background: transparent; font-size: 13px; font-weight: 700; text-decoration: underline; }

/* Главная */
.home { max-width: 1180px; margin: 0 auto; padding: 0 20px 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(280px, 420px); align-items: center; gap: 40px; padding: 70px 0 62px; }
.hero-doodle-mark { display: none; width: 250px; max-width: 100%; height: auto; margin: 0 0 18px; }
.hero h1 { margin: 0 0 30px; font-size: clamp(38px, 5.5vw, 64px); line-height: 1.04; letter-spacing: -.04em; }
.hero h1 span { background: linear-gradient(90deg, var(--green), var(--sky), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; }
.hero-play {
  flex: 0 1 auto;
  min-width: min(270px, calc(100% - 68px));
  min-height: 76px;
  padding: 18px 40px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--green), var(--sky));
  color: #08221c;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: .01em;
  box-shadow: 0 18px 42px rgba(52, 211, 153, .18);
}
.hero-play:hover { filter: brightness(1.08); transform: translateY(-2px); }
.hero-avatar-button {
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.hero-avatar-button:hover { transform: translate(-2px,-2px) rotate(-4deg); box-shadow: 6px 6px 0 #1c1917; }
.hero-avatar-button[aria-pressed="true"] { border-color: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.hero-avatar-button svg { display: block; width: 100%; height: 100%; }

.hero-room-window {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .45);
}
.room-window-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.room-title-group { display: flex; flex: 0 1 auto; align-items: center; gap: 8px; min-width: 0; margin-right: auto; }
.room-window-head h2 { margin: 0; color: var(--muted); font-size: 19px; letter-spacing: -.02em; }
.room-stats { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 800; opacity: .55; font-variant-numeric: tabular-nums; white-space: nowrap; }
.room-stats .room-person, .room-stats .room-lock, .room-stats .bi-door-closed { flex: 0 0 14px; width: 14px; height: 14px; }
.room-stats .bi-door-closed { fill: currentColor; }
.room-stats-sep { margin: 0 2px; opacity: .6; }
.room-window-head .avatar-name-title { flex: 1 1 auto; width: 100%; max-width: none; min-width: 0; margin: 0; font-size: 20px; }
.room-window-head .room-window-done { flex: 0 0 auto; color: #08221c; border-color: var(--green); background: var(--green); font-weight: 900; }
.room-window-head .room-window-done:hover { color: #08221c; filter: brightness(1.08); }
.room-window-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px; }
.room-window-editor { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px; }
.room-row { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; transition: background .15s ease; }
.room-row:hover { background: var(--surface-2); }
.room-row-main { display: flex; flex: 1 1 auto; align-items: center; gap: 10px; min-width: 0; }
.room-row-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.room-row-name em { margin-left: 6px; color: var(--green); font-size: 11px; font-style: normal; text-transform: uppercase; }
.room-row-count { flex: 0 0 auto; color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.room-person { flex: 0 0 24px; width: 24px; height: 24px; color: var(--muted); }
.room-enter { flex: 0 0 auto; padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 13px; font-weight: 800; }
.room-enter:hover { border-color: var(--green); color: var(--green); }
.room-window-footer { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.room-footer-create { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-weight: 900; }
.room-footer-create:hover { border-color: var(--green); }
.own-room-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.own-room-actions { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 6px; }
.create-room-menu { position: absolute; right: 12px; bottom: 76px; left: 12px; z-index: 4; box-shadow: 0 -14px 34px rgba(0, 0, 0, .5); }
.create-room-menu label, .dict-editor label { display: grid; gap: 5px; }
.create-room-menu label > span, .dict-editor label > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
input[type="color"] { height: 38px; padding: 3px; cursor: pointer; }
textarea { resize: vertical; }

.avatar-name-title { display: block; width: auto; max-width: 100%; padding: 3px 2px; border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; color: var(--name-color, var(--green)); font-family: inherit; font-size: 26px; font-weight: 900; letter-spacing: -.02em; }
.avatar-name-title:hover { box-shadow: inset 0 -1px 0 var(--line); }
.avatar-name-title:focus { box-shadow: inset 0 -2px 0 var(--name-color, var(--green)); }
.avatar-name-title::placeholder { color: var(--muted); opacity: 1; }
.gender-tools { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.gender-btn { display: inline-flex; width: 34px; height: 34px; padding: 0; align-items: center; justify-content: center; border: 2px solid var(--line); border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; transition: color .15s ease, border-color .15s ease, background .15s ease; }
.gender-btn svg { display: block; width: 20px; height: 20px; }
.gender-btn:hover { border-color: var(--muted); }
.gender-boy[aria-pressed="true"] { border-color: var(--sky); background: rgba(56, 189, 248, .14); color: var(--sky); }
.gender-girl[aria-pressed="true"] { border-color: #fb71b1; background: rgba(251, 113, 177, .14); color: #fb71b1; }
.room-window-editor .character-studio { display: grid; grid-template-columns: 34px minmax(0, 210px) 34px; align-items: stretch; justify-content: center; gap: 8px; width: 100%; }
.char-side { display: flex; flex-direction: column; gap: 6px; }
.avatar-preview-wrap { display: grid; justify-items: center; gap: 8px; width: 100%; }
.avatar-preview { width: 100%; aspect-ratio: 1 / 1; border-radius: 16px; background: radial-gradient(circle at 50% 40%, var(--surface-2), transparent 75%); overflow: hidden; }
.avatar-preview .avatar-large { display: block; width: 100%; height: 100%; border-radius: inherit; }
.char-btn { flex: 1; width: 100%; min-height: 40px; padding: 0; border: 2px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 20px; line-height: 1; }
.char-btn:hover { border-color: var(--green); color: var(--green); }
.char-btn:active { transform: translateY(2px); }
.room-window-editor .avatar-tools { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.swatches { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.sw { width: 24px; height: 24px; padding: 0; border: 2px solid var(--line); border-radius: 50%; }
.sw[aria-pressed="true"] { border-color: var(--green); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--green); }
.dice { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 18px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 16px; }
.dice svg { display: block; width: 16px; height: 16px; }
.dice:hover { border-color: var(--green); }

/* Игра */
.room-badge { padding: 2px 7px; border-radius: 5px; background: rgba(167, 139, 250, .16); color: var(--violet); font-size: 11px; font-weight: 900; }
.dict-label { display: none; }
.connection { color: var(--muted); font-size: 12px; }
.connection.online { color: var(--green); }

.game-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 960px) 450px;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
  min-height: 100vh;
  padding: 12px 12px 18px;
}

/* На широком экране страница игры — одно окно без прокрутки: прокручиваются
   только чат, список игроков и настройки. Холст сужается по высоте окна, но
   не меньше 280 px; если окно совсем низкое, обычная прокрутка возвращается. */
@media (min-width: 1100px) and (min-height: 500px) {
  body[data-page="game"] { height: 100vh; overflow: hidden; }
  .game-shell { height: 100vh; min-height: 0; max-height: 100vh; overflow: hidden; }
}

/* Тонкая панель кистей: всегда одна колонка слева от холста, без сжатия
   в два столбца. На экране уже 1100px она уходит под холст и становится
   горизонтальным рядом прямо над нижней палитрой. */
.tool-rail {
  position: sticky;
  top: 8px;
  align-self: start;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: max-content;
  padding: 6px 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.tool-rail.rail-horizontal {
  position: static;
  align-self: stretch;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  gap: 4px;
  padding: 5px 6px;
  margin: 10px 0 0;
}
/* В горизонтальном режиме кнопки сидят плотно, как кляксы в нижней панели.
   Auto-margin из обычной вертикальной панели убирается, иначе кнопки
   разлетаются по всей ширине. */
.rail-horizontal .tool-btn,
.rail-horizontal .pipette-btn,
.rail-horizontal .toggle-btn,
.rail-horizontal .knob,
.rail-horizontal .bg-square { margin: 0; flex: none; }
.rail-horizontal .rail-sep { width: 1px; height: 28px; align-self: center; flex: none; }
.rail-horizontal .tool-btn.tool-sep { width: 1px; height: 28px; padding: 0; border: 0; align-self: center; }
.rail-horizontal .rail-control { width: 30px; gap: 0; }
.rail-horizontal .tool-btn,
.rail-horizontal .pipette-btn,
.rail-horizontal .toggle-btn { width: 28px; height: 28px; }
.rail-horizontal .knob { width: 30px; height: 30px; }
.rail-horizontal .bg-square { width: 30px; height: 30px; }
.rail-control { display: grid; justify-items: center; gap: 2px; width: 34px; flex: none; }
.rail-caption { display: none; }
.rail-bg { flex: none; width: 36px; height: 36px; margin: 0 auto; }
.recent-title { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
/* Кнопки кистей участвуют в общей flex-раскладке панели. */
.tool-grid { display: contents; }
.tool-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: #d7dbe0;
}
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover { border-color: var(--sky); }
.tool-btn.active { border-color: var(--green); background: rgba(52, 211, 153, .16); color: var(--green); }
.rail-sep { flex: none; width: 34px; height: 1px; background: var(--line); }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.swatch { height: 20px; padding: 0; border: 1px solid var(--line); border-radius: 5px; }
.swatch.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }
.empty-swatch { height: 20px; border: 1px dashed var(--line); border-radius: 5px; }
.tool-rail.disabled .tool-btn:not(.tool-sep),
.tool-rail.disabled .knob,
.tool-rail.disabled .bg-square,
.tool-rail.disabled .pipette-btn { opacity: .45; }

/* Нижняя палитра должна стоять на одном уровне с правой колонкой: свободное
   место после квадрата уходит между холстом и палитрой, а не под палитру. */
.stage { grid-column: 2; display: flex; flex-direction: column; min-width: 0; }
.wordbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.word-block { display: grid; justify-items: start; }
.word-block strong {
  display: block;
  max-width: 430px;
  min-height: 32px;
  color: #b5b5b5;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 32px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Открытые буквы выделяются зелёным; остальные остаются серыми. */
.word-letter.shared { color: var(--green); }
.word-mask { color: inherit; }
.round-info { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.round-info b { color: var(--text); }
.timer { padding: 4px 8px; border-radius: 6px; background: var(--surface-2); color: var(--green); font-size: 13px; font-weight: 900; }
.timer.timer-danger {
  color: #fff;
  background: rgba(248, 113, 113, .22);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .65), 0 0 12px rgba(248, 113, 113, .22);
  animation: timer-warning 1s ease-in-out infinite;
}
@keyframes timer-warning {
  50% { background: rgba(248, 113, 113, .38); }
}
/* Нулевой таймер остаётся заметным, но больше не мигает. */
.timer.timer-expired {
  color: #fff;
  background: rgba(248, 113, 113, .22);
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .65), 0 0 12px rgba(248, 113, 113, .22);
  animation: none;
}

.brush-cursor {
  position: absolute;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, .85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
/* Служебные режимы сохраняют форму последней кисти, но добавляют маленькую
   точку в центре: она показывает точное место взятия цвета или заливки. */
.brush-cursor.utility-cursor {
  border-width: 2px;
  border-style: solid;
  background: rgba(255, 255, 255, .18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .95), 0 3px 10px rgba(0, 0, 0, .45);
}
.brush-cursor.utility-cursor::after {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .95);
}
.brush-cursor.pipette-cursor { color: #34d399; }
.brush-cursor.fill-cursor { color: #60a5fa; }
.hit-toast {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  top: 14px;
  left: 50%;
  padding: 9px 16px;
  border: 2px solid var(--green);
  border-radius: 10px;
  background: rgba(6, 37, 30, .94);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  transform: translateX(-50%);
  animation: hit-pop 2.4s ease forwards;
}
.size-toast {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 5px;
  background: rgba(9, 12, 20, .94);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50%, -100%, 0);
  will-change: transform, opacity;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}
.word-reveal {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: min(82%, 520px);
  padding: 20px 26px;
  border: 2px solid var(--green);
  border-radius: 14px;
  background: rgba(6, 37, 30, .96);
  color: #fff;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .65);
  transform: translate(-50%, -50%);
}
.word-reveal[hidden] { display: none; }
.word-reveal span {
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.word-reveal strong {
  font-size: clamp(24px, 4vw, 44px);
  font-weight: 900;
  line-height: 1.1;
  word-break: break-word;
}
.word-reveal small { color: var(--muted); font-size: 12px; }
/* Слово не угадано: таймаут или уход художника. Та же плашка, но красная. */
.word-reveal.missed {
  border-color: var(--danger);
  background: rgba(56, 10, 20, .96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .65), 0 0 32px rgba(251, 113, 133, .18);
}
.word-reveal.missed span { color: #fecdd3; }
.canvas-wrap.celebrate { animation: canvas-pulse 2.4s ease; }
@keyframes hit-pop {
  0% { opacity: 0; transform: translate(-50%, -18px) scale(.85); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  24% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px) scale(.98); }
}
@keyframes canvas-pulse {
  0%, 100% { box-shadow: 0 16px 40px rgba(0, 0, 0, .45); }
  25%, 65% { box-shadow: 0 0 0 3px rgba(52, 211, 153, .75), 0 16px 40px rgba(0, 0, 0, .45); }
}
/* На широком экране правая колонка занимает всю высоту окна, как верхняя
   и нижняя панели: чат, игроки и настройки тянутся вместе с ней. */
.side-panel {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 30px);
  max-height: calc(100vh - 30px);
}
.panel-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 6px; }
.panel-actions { display: flex; gap: 6px; }
.mobile-leave { display: none; }
.panel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel-leave {
  display: grid;
  place-items: center;
  width: 34px;
  height: 37px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
}
.panel-leave:hover { border-color: var(--danger); color: var(--danger); background: rgba(248, 113, 113, .08); }
.panel-leave svg { display: block; width: 20px; height: 20px; }
.panel-tab { padding: 7px 4px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 800; }
.panel-tab:hover { color: var(--text); }
.panel-tab.active { background: var(--surface-2); color: var(--green); }
.tab-count { margin-left: 3px; color: var(--green); font-size: 11px; }
.tab-panel { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; margin-top: 8px; }
.players { display: grid; gap: 5px; min-height: 0; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.player { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.avatar { display: block; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 6px; overflow: hidden; }
.players .avatar { flex-basis: 32px; width: 32px; height: 32px; border-radius: 8px; }
.player-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.player-tag { color: var(--green); font-size: 11px; font-weight: 900; }
.ban-btn { padding: 3px 6px; border: 1px solid rgba(251, 113, 133, .35); border-radius: 4px; background: transparent; color: var(--danger); font-size: 11px; font-weight: 900; }
.ban-btn:hover { background: rgba(251, 113, 133, .14); }
.messages {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
/* Как на croch.ru: при одном-двух сообщениях они висят внизу, а не сверху. */
.messages > :first-child { margin-top: auto; }
/* Блок словаря находится над чатом и виден только на вкладке чата; слово
   «Словарь» убрано из подписи. */
.chat-panel { position: relative; }
.chat-source {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #303536;
  padding: 8px;
  margin-top: 8px;
  text-align: center;
}
.chat-source .label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}
.chat-stream { position: relative; display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
/* Системные события живут отдельной плашкой над сообщениями чата и не
   занимают место в ленте: пользовательские сообщения остаются на своих местах. */
.system-feed {
  position: absolute;
  top: 4px;
  right: 4px;
  left: 4px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}
.system-feed:empty { display: none; }
.system-notice {
  --notice-accent: var(--sky);
  --notice-glow: rgba(56, 189, 248, .45);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, .28);
  border-radius: 9px;
    background: #202e38;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 8px 22px rgba(0, 0, 0, .42);
  transform-origin: right center;
  backdrop-filter: blur(8px);
  animation: system-notice-in 220ms ease-out both;
}
.system-notice::before {
  content: '';
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--notice-accent);
  box-shadow: 0 0 10px var(--notice-glow);
}
.system-notice[data-kind="reveal"] {
  --notice-accent: var(--green);
  --notice-glow: rgba(52, 211, 153, .5);
  border-color: rgba(52, 211, 153, .3);
  background: #405a40;
}
.system-notice[data-kind="warning"] {
  --notice-accent: #fbbf24;
  --notice-glow: rgba(251, 191, 36, .5);
  border-color: rgba(251, 191, 36, .3);
  background: rgba(251, 191, 36, .3);
}
.system-notice.leaving {
  pointer-events: none;
  animation: system-notice-out 350ms ease-in forwards;
}
@keyframes system-notice-in {
  from { opacity: 0; transform: translateX(18px) scale(.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes system-notice-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
    max-height: 60px;
  }
  to {
    opacity: 0;
    transform: translateX(56px) scale(.96);
    max-height: 0;
  }
}
.message { padding: 5px 8px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.message b { color: var(--green); }
/* Угаданное сообщение больше не выделяется фоном: о раунде говорит
   системная строка сразу под ним. */
.message.hit { border-color: transparent; background: var(--surface-2); }
.chat-verdict {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.chat-verdict.missed { color: var(--danger); }
.chat-verdict.old { opacity: .42; }
.round-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
}
.round-divider::before,
.round-divider::after { content: ''; flex: 1; height: 1px; background: rgba(148, 163, 184, .16); }
.round-divider span { opacity: .38; }
.save-round {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--green);
  line-height: 0;
  cursor: pointer;
}
.save-round svg { display: block; width: 16px; height: 16px; }
.save-round:hover { color: #fff; background: rgba(52, 211, 153, .16); }
.save-round[hidden] { display: none; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { min-width: 0; }
.chat-form .button { flex: 0 0 auto; }

.settings-panel { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.settings-scroll {
  display: grid;
  align-content: start;
  flex: 1 1 auto;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 13px 14px 14px;
}
.settings-section { display: grid; gap: 10px; }
.settings-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.settings-section-head h3 { margin: 0; color: var(--muted); font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.room-heading { justify-content: flex-start; }
.room-heading h3 { flex: 0 0 auto; }
.room-name-input {
  min-width: 0;
  flex: 1 1 auto;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 700;
}
.room-controls { gap: 10px; }
.room-time-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-time-row > span { flex: 1 1 auto; }
.round-min-input {
  flex: 0 0 76px;
  width: 76px;
  padding: 6px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}
.settings-card { display: grid; gap: 9px; padding: 2px 0; }
.settings-prefs { gap: 12px; }
.settings-divider { display: flex; align-items: center; gap: 10px; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.settings-divider::before, .settings-divider::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--line); }
.settings-divider span { white-space: nowrap; }
.settings-line, .settings-note { margin: 0; font-size: 12px; }
.settings-field { display: grid; gap: 5px; }
.settings-field > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.settings-subhead { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.inline-dict-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.settings-panel select, .settings-panel input, .settings-panel textarea { padding: 8px 10px; font-size: 13px; }
/* Недоступные для изменения пункты настроек читаются одним цветом. */
.settings-panel input:disabled, .settings-panel textarea:disabled, .settings-panel select:disabled { opacity: 1; cursor: default; color: #3c3c40; }
.settings-panel input:disabled::placeholder { color: #3c3c40; opacity: 1; }
.settings-panel .settings-check input:disabled ~ .switch-copy,
.settings-panel .settings-check input:disabled ~ .switch-copy b,
.settings-panel .settings-check input:disabled ~ .switch-copy small { color: #3c3c40; }
.settings-panel .settings-section--room.read-only .settings-section-head h3,
.settings-panel .settings-section--room.read-only .settings-subhead,
.settings-panel .settings-section--room.read-only .settings-field > span { color: #3c3c40; }
.settings-panel .dict-check.readonly,
.settings-panel .dict-check.readonly span,
.settings-panel .dict-check.readonly small { color: #3c3c40; }
.settings-panel .button:disabled, .dict-modal .button:disabled { color: #3c3c40; }
.dict-add-slot { display: grid; width: 100%; margin-top: 1px; }
.dict-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(52, 211, 153, .38);
  border-radius: 9px;
  color: var(--green);
  background: linear-gradient(180deg, rgba(52, 211, 153, .12), rgba(52, 211, 153, .05));
  font-size: 13px;
  font-weight: 800;
}
.dict-add-btn::before { content: '+'; font-size: 18px; line-height: 1; }
.dict-add-btn:hover { background: linear-gradient(180deg, rgba(52, 211, 153, .2), rgba(52, 211, 153, .09)); }
.settings-sync {
  flex: 0 0 auto;
  padding: 9px 14px 10px;
  border-top: 1px solid var(--line);
  color: rgba(52, 211, 153, .86);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.dict-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); font-size: 13px; text-align: left; }
.dict-item.active { border-color: var(--green); color: var(--green); }
.dict-item small { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; }

.modal { width: min(400px, calc(100vw - 30px)); padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .75); }
.modal h3 { margin: 0 0 4px; }
.modal p { margin: 0 0 12px; font-size: 13px; }
.modal input { margin-bottom: 12px; }
.dict-modal { width: min(460px, calc(100vw - 30px)); }
.dict-modal h3 { margin-bottom: 14px; }
.dict-modal .settings-field { margin-bottom: 12px; }
.dict-modal input { margin-bottom: 0; width: 100%; }
.dict-modal textarea { width: 100%; min-height: 120px; resize: vertical; font-size: 13px; }
.dict-modal .inline-dict-actions { margin-top: 2px; }
.room-password-modal { width: min(380px, calc(100vw - 30px)); }
.room-password-modal .settings-field { margin-bottom: 10px; }
.room-password-modal input { width: 100%; margin-bottom: 0; }
.room-password-error { margin: 0 0 10px; color: var(--danger); font-size: 13px; font-weight: 700; }
/* Пока пароль не введён, комнаты как будто нет: полупрозрачное окно не должно
   пропускать рисунок, чат и слова, которые пришли до проверки доступа. */
body.room-locked .game-shell { visibility: hidden; }

@media (max-width: 1200px) {
  .game-shell { grid-template-columns: auto minmax(0, 1fr) 450px; gap: 8px; padding: 10px 8px 16px; }
  .side-panel { height: calc(100vh - 26px); max-height: calc(100vh - 26px); }
}
/* Планшетный режим: всё, что уже 1100px, остаётся обычным; ниже — один
   вариант с вводом чата сверху и прокруткой всей страницы. */
@media (max-width: 1099px) {
  .topnav { display: none; }
  .hero { grid-template-columns: 1fr; gap: 30px; padding: 40px 0 34px; }
  .hero-room-window { margin: 0 auto; }
  .room-window-editor .character-studio { grid-template-columns: 34px minmax(0, 210px) 34px; gap: 8px; }
  .char-btn { min-height: 40px; font-size: 20px; border-radius: 10px; }
  .game-shell { grid-template-columns: auto minmax(0, 1fr); padding: 8px; gap: 8px; }
  .stage { grid-column: 2; }
  .side-panel { grid-column: 1 / -1; height: auto; max-height: none; }
  .tab-panel { min-height: 0; }
  /* Как на croch.ru: на узком экране чат под холстом, поле ввода и свежие
     сообщения сверху, старые уходят вниз; страница прокручивается целиком. */
  .chat-panel { flex-direction: column-reverse; }
  .messages {
    flex: 0 0 auto;
    flex-direction: column-reverse;
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .messages > :first-child { margin-top: 0; }
  .settings-scroll { flex: 0 0 auto; max-height: 400px; }
  .wordbar { flex-wrap: wrap; }
  .panel-tabs { grid-template-columns: repeat(3, 1fr); }
}

/* Компактная панель кистей и кружки-индикаторы */
.tool-btn.tool-sep {
  width: 34px;
  height: 1px;
  padding: 0;
  border: 0;
  background: var(--line);
  pointer-events: none;
}
.tool-btn.tool-sep:hover { border-color: var(--line); }

.knob {
  flex: none;
  --knob-size: 12px;
  --knob-fill: var(--green);
  --knob-alpha: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    repeating-conic-gradient(#d4d4d8 0% 25%, #52525b 0% 50%) 0 0 / 8px 8px;
  box-shadow: inset 0 0 0 2px var(--surface);
  touch-action: none;
  user-select: none;
}
.knob::after {
  content: '';
  width: var(--knob-size);
  height: var(--knob-size);
  border-radius: 50%;
  background: var(--knob-fill);
  opacity: var(--knob-alpha);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), inset 0 1px 2px rgba(255, 255, 255, .45);
  transition: width .12s ease, height .12s ease, background .12s ease, opacity .12s ease;
}
.alpha-knob::after { width: 26px; height: 26px; }
.knob:hover { border-color: var(--sky); }
.knob.dragging { border-color: var(--green); }
.pipette-btn, .toggle-btn, .rail-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}
.pipette-btn:hover, .toggle-btn:hover, .rail-button:hover { border-color: var(--sky); }
.pipette-btn.active, .toggle-btn.active {
  border-color: var(--green);
  background: rgba(52, 211, 153, .16);
  color: var(--green);
}
.rail-button.danger:hover { border-color: var(--danger); color: var(--danger); }
.pipette-btn svg, .toggle-btn svg, .rail-button svg { display: block; width: 18px; height: 18px; }

.canvas-wrap {
  position: relative;
  flex: 0 1 auto;
  width: min(100%, 960px);
  min-width: 0;
  max-width: 960px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #252932;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
}
/* Тач не должен превращать мазок в жест прокрутки/зума и отменять pointer. */
.canvas-wrap, #drawCanvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* На широком экране холст дополнительно вписывается в высоту окна, чтобы
   страница не прокручивалась. Минимальный размер 280 px оставляет рисунок
   видимым даже в очень низком окне. Нижняя панель и горизонтальный ряд
   кистей занимают место над холстом, поэтому вычитаем их высоту. */
@media (min-width: 1100px) and (min-height: 500px) {
  /* На FullHD квадрат занимает всё свободное место между словом и палитрой:
     30 px внешних отступов, 54 px wordbar, 10 px над холстом и 58 px dock. */
  .canvas-wrap {
    width: min(100%, 960px, max(280px, calc(100vh - 152px)));
    margin-bottom: 0;
  }
}
/* В узком режиме кисти занимают отдельный горизонтальный ряд между холстом
   и нижней палитрой, поэтому квадрат уменьшается ещё на высоту этого ряда. */
@media (max-width: 1099px) and (min-height: 500px) {
  .canvas-wrap { width: min(100%, 760px, max(280px, calc(100vh - 210px))); }
}
/* Нативный курсор прячем только у рисующего: угадывающий видит обычную стрелку. */
body.can-draw .canvas-wrap, body.can-draw #drawCanvas { cursor: none; }
#drawCanvas, #draftCanvas { width: 100%; height: 100%; display: block; }
#draftCanvas { position: absolute; inset: 0; pointer-events: none; }
.brush-cursor.shape-square { border-radius: 2px; }
.brush-cursor.shape-circle { border-radius: 50%; }
.brush-cursor.shape-stripe { border-radius: 2px; background: rgba(52, 211, 153, .14); }
.brush-cursor.shape-stripe::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 12%;
  width: 76%;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%);
}

.color-dock {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.ink-blobs { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; }
.ink-blob {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: 47% 53% 62% 38% / 55% 42% 58% 45%;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.35), 0 2px 4px rgba(0,0,0,.35);
  transition: transform .15s ease, outline-color .15s ease;
}
.ink-blob:nth-child(3n) { border-radius: 62% 38% 44% 56% / 42% 58% 42% 58%; }
.ink-blob:nth-child(4n) { border-radius: 38% 62% 55% 45% / 60% 45% 55% 40%; }
.ink-blob:hover { transform: scale(1.12) rotate(-4deg); }
.ink-blob.active { outline: 2px solid var(--green); outline-offset: 2px; transform: scale(1.14); }
.empty-blob { width: 27px; height: 27px; border: 1px dashed var(--line); border-radius: 50%; }
.bg-square {
  position: relative;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.bg-square-label {
  position: absolute;
  bottom: -15px;
  left: 50%;
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
  transform: translateX(-50%);
}
.dock-tool {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
}
.dock-tool:hover { border-color: var(--sky); }
.dock-actions { display: flex; align-items: center; gap: 8px; }
.dock-tool svg { display: block; width: 18px; height: 18px; }
.dock-tool.danger:hover { border-color: var(--danger); color: var(--danger); }

.palette-popover {
  position: fixed;
  z-index: 60;
  width: 240px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, .35);
  box-shadow: 0 20px 55px rgba(0,0,0,.7);
}
.popover-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.popover-close { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.palette-preview { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 8px; }
.palette-current {
  display: grid;
  place-items: center;
  height: 34px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 7px;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.palette-hex-label { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.popover-hex-input { width: 100%; padding: 6px 8px; font-size: 12px; }
.popover-sliders { display: grid; gap: 8px; margin: 10px 0; }
.popover-slider {
  display: grid;
  grid-template-columns: 72px 1fr 38px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.popover-slider output { color: var(--text); text-align: right; }
.popover-slider input[type="range"] {
  width: 100%;
  height: 10px;
  margin: 0;
  border-radius: 5px;
  background: linear-gradient(to right, var(--green), var(--sky));
  appearance: none;
  cursor: pointer;
}
.popover-slider input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  appearance: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .7);
}
.popover-slider input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .7);
}
.palette-popover.bg-mode .popover-sliders { display: none; }
.palette-sv {
  --palette-hue: 210;
  position: relative;
  height: 104px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--palette-hue), 100%, 50%));
  cursor: crosshair;
  touch-action: none;
}
.palette-sv-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.75), 0 2px 6px rgba(0,0,0,.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.palette-hue {
  width: 100%;
  height: 12px;
  margin: 10px 0;
  border-radius: 6px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  appearance: none;
  cursor: pointer;
}
.palette-hue::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0,0,0,.7);
  appearance: none;
}
.palette-hue::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0,0,0,.7);
}
.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(9, 12, 20, .58);
  backdrop-filter: blur(6px);
}
.screen-overlay[hidden] { display: none; }
.overlay-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 280px;
  padding: 24px 28px;
  border: 1px solid rgba(148, 163, 184, .32);
  border-radius: 16px;
  background: rgba(20, 24, 34, .92);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .65);
  color: var(--text);
  font-size: 17px;
  text-align: center;
}
.overlay-card small { max-width: 260px; color: var(--muted); font-size: 12px; line-height: 1.4; text-align: center; }
.overlay-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: overlay-spin .9s linear infinite;
}
@keyframes overlay-spin { to { transform: rotate(360deg); } }
.duplicate-overlay { z-index: 120; background: rgba(9, 12, 20, .84); }

.message { font-size: 14px; line-height: 1.45; }
.message.old { opacity: .42; }
.chat-form input { font-size: 14px; }
.reaction-slot {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 6px;
  vertical-align: baseline;
}
.react-btn {
  display: inline-grid;
  place-items: center;
  padding: 0 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #f4f4f5;
  line-height: 1;
}
.react-btn svg { display: block; width: 14px; height: 14px; fill: currentColor; }
.react-btn:hover { color: #fff; }
.react-btn[data-react="like"].active { color: var(--green); }
.react-btn[data-react="dislike"].active { color: #ef4444; }
.react-mark {
  display: inline-grid;
  place-items: center;
  margin-right: 6px;
  vertical-align: baseline;
}
.react-mark svg { display: block; width: 14px; height: 14px; fill: currentColor; }
.react-mark.like { color: var(--green); }
.react-mark.dislike { color: #ef4444; }
/* Снятая создателем реакция остаётся видимой, но уже не выделяется цветом. */
.react-mark.muted.like, .react-mark.muted.dislike { color: #9ca3af; }
/* У зрителей слева от ника резервируется только аватарка: одно место 20px.
   Реакция подменяет её в этом же месте. */
.chat-lead {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-right: 6px;
  vertical-align: middle;
}
.chat-lead .avatar.chat-avatar {
  display: block;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
}
/* Обводка аватарки нужна только в чате и только когда выбран пол:
   зелёный цвет по умолчанию считается «без пола» и рамку не рисует. */
.message.name-colored .chat-lead .avatar.chat-avatar {
  /* box-shadow вместо outline: outline у SVG мигает при клике и перерисовке. */
  box-shadow: 0 0 0 2px var(--name-color);
}
.chat-lead-mark .react-mark {
  width: 20px;
  height: 20px;
  margin-right: 0;
}
/* У ведущего реакции остаются слева от аватара, как и раньше. Аватар при
   этом тоже виден; слот реакций фиксирован, чтобы он не смещался. */
.chat-lead-drawer {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.chat-react-lead {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 34px;
  width: 34px;
  height: 20px;
  margin-right: 6px;
}
.chat-react-lead .reaction-slot { gap: 0; margin-right: 0; }
.chat-react-lead .react-btn { padding: 0 1px; }
.chat-react-lead .react-mark { width: 20px; margin-right: 0; }

.dict-check-list { display: grid; gap: 6px; }
.dict-check {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 13px;
  cursor: pointer;
}
.dict-check input { justify-self: start; }
.dict-check span, .dict-check label { color: var(--text); font-weight: 700; white-space: normal; }
.dict-check label { cursor: pointer; }
.dict-check small { color: var(--muted); font-size: 12px; }
.dict-check.has-actions { grid-template-columns: 34px 1fr auto auto; }
.dict-row-actions { display: flex; align-items: center; gap: 4px; }
.dict-icon-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  font-size: 12px;
  line-height: 1;
}
.dict-edit-btn { color: var(--sky); border-color: rgba(96, 165, 250, .35); }
.dict-edit-btn:hover { background: rgba(96, 165, 250, .14); }
.dict-delete-btn { color: var(--danger); border-color: rgba(251, 113, 133, .35); font-size: 15px; }
.dict-delete-btn:hover { background: rgba(251, 113, 133, .14); }
.dict-check.readonly { grid-template-columns: 1fr auto; padding-left: 10px; cursor: default; }
.settings-check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.settings-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
.settings-check.switch-row { align-items: flex-start; cursor: pointer; }
.settings-check.switch-row input, .dict-check input {
  position: relative;
  flex: 0 0 34px;
  width: 34px;
  height: 19px;
  margin: 1px 0 0;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.settings-check.switch-row input::after, .dict-check input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s ease, background .15s ease;
}
.settings-check.switch-row input:checked, .dict-check input:checked { border-color: rgba(52, 211, 153, .65); background: rgba(52, 211, 153, .24); }
.settings-check.switch-row input:checked::after, .dict-check input:checked::after { transform: translateX(15px); background: var(--green); }
.settings-check.switch-row input:disabled, .dict-check input:disabled { opacity: .5; cursor: default; }
.switch-copy { display: grid; gap: 2px; }
.switch-copy b { font-size: 14px; font-weight: 800; }
.switch-copy small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.blacklist-block { flex: 0 0 auto; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.settings-subhead small { margin-left: 6px; color: var(--violet); font-size: 11px; font-weight: 700; text-transform: none; letter-spacing: 0; }
.ban-list { display: grid; gap: 5px; max-height: 140px; overflow-y: auto; }
.ban-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); font-size: 13px; }
.ban-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unban-btn {
  padding: 3px 7px;
  border: 1px solid rgba(52, 211, 153, .35);
  border-radius: 4px;
  background: transparent;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}
.unban-btn:hover { background: rgba(52, 211, 153, .12); }
.ban-empty { color: var(--muted); font-size: 12px; }
.ban-notice { margin-top: 10px; padding: 8px 12px; border: 1px solid rgba(251, 113, 133, .4); border-radius: 8px; background: rgba(251, 113, 133, .12); color: var(--danger); font-size: 13px; font-weight: 700; }

.drawer-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 20px; background: var(--surface-2); }
.drawer-avatar { display: inline-flex; width: 22px; height: 22px; }
.drawer-avatar svg { width: 100%; height: 100%; border-radius: 6px; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }
/* Цвет точки в плашке ведущего показывает, что происходит с комнатой:
   зелёный — ведущий рисует, голубой — идёт пауза между раундами,
   красный — ведущий пропал, серый — ждём состояние или связи. */
.drawer-chip[data-mode="pause"] .chip-dot { background: var(--sky); box-shadow: 0 0 0 3px rgba(56, 189, 248, .15); }
.drawer-chip[data-mode="lost"] .chip-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(251, 113, 133, .15); }
.drawer-chip[data-mode="offline"] .chip-dot,
.drawer-chip[data-mode="connecting"] .chip-dot,
.drawer-chip[data-mode="nostate"] .chip-dot { background: var(--muted); box-shadow: none; }

@media (max-width: 1099px) {
  .color-dock { flex-wrap: wrap; gap: 10px; }
  .word-block strong { max-width: 100%; font-size: 16px; line-height: 28px; }
  .messages { height: auto; }
  /* В смартфоне панели рисования нужны только ведущему. Угадывающий видит
     тот же холст, но без кистей и нижней палитры. */
  body:not(.can-draw) .tool-rail.rail-horizontal,
  body:not(.can-draw) .color-dock { display: none; }
  /* Кнопка выхода переезжает к таймеру раунда, а не остаётся в нижнем чате. */
  .round-info { gap: 8px; }
  .panel-head > .panel-actions { display: none; }
  .round-info .mobile-leave { display: flex; }
}