:root {
  --bg: #07080a;
  --ink: #f4e7d4;
  --ink-soft: #d9c4a8;
  --muted: #a8927a;
  --ember: #ff9a3c;
  --ember-deep: #c2521f;
  --glass: rgba(22, 16, 13, 0.62);
  --glass-strong: rgba(26, 19, 15, 0.86);
  --line: rgba(255, 196, 140, 0.14);
  --line-strong: rgba(255, 196, 140, 0.28);
  --ok: #8fd18b;
  --danger: #ff8a70;
  --radius: 14px;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --safe-t: max(16px, env(safe-area-inset-top));
  --safe-b: max(16px, env(safe-area-inset-bottom));
  --safe-l: max(16px, env(safe-area-inset-left));
  --safe-r: max(16px, env(safe-area-inset-right));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.5 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); letter-spacing: 0.06em; }

#fire {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}
#fire.pointer { cursor: pointer; }

/* WebGL flames of the realistic looks: black is transparent under "screen". */
#flame, #labels {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
#flame { mix-blend-mode: screen; }

.theme-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 5, 0.5);
}
.segmented button {
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}
.segmented button[aria-checked="true"] { background: rgba(255, 154, 60, 0.2); color: #ffd9a8; }
#theme-btn svg { display: none; }
#theme-btn[data-theme="classic"] .t-classic,
#theme-btn[data-theme="real"] .t-real,
#theme-btn[data-theme="camp"] .t-camp { display: block; }

.shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 55%, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
  transition: background 0.8s ease;
}
body.in-lobby .shade {
  background:
    radial-gradient(120% 90% at 50% 55%, rgba(0, 0, 0, 0.25) 30%, rgba(0, 0, 0, 0.7) 100%),
    rgba(7, 8, 10, 0.35);
}

.screen { position: fixed; inset: 0; }

/* ---------- Вход ---------- */

.lobby {
  display: grid;
  place-items: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  overflow-y: auto;
}

.card {
  width: min(420px, 100%);
  padding: 32px 28px 26px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 220, 180, 0.06);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  animation: rise 0.7s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.eyebrow {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ember);
}

h1 {
  margin: 0;
  font: 600 44px/1.05 var(--serif);
  letter-spacing: -0.01em;
  color: #fff1dc;
}

.lead { margin: 10px 0 22px; color: var(--ink-soft); font-size: 14.5px; }

.invite {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(255, 154, 60, 0.09);
  border: 1px solid rgba(255, 154, 60, 0.25);
  font-size: 14px;
}
.invite b { color: #ffd9a8; }
.invite-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.invite-dot {
  flex: none;
  width: 9px; height: 9px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 0 4px rgba(255, 154, 60, 0.18);
  animation: pulse 2s ease-in-out infinite;
}
.invite.cold .invite-dot { background: var(--muted); box-shadow: none; animation: none; }

@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 154, 60, 0.05); } }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 6, 5, 0.55);
  outline: none;
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: rgba(217, 196, 168, 0.35); }
.field input:focus { border-color: rgba(255, 154, 60, 0.7); box-shadow: 0 0 0 4px rgba(255, 154, 60, 0.14); }
.field input.mono { text-transform: uppercase; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 50px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, filter 0.2s, opacity 0.2s, background 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { cursor: default; opacity: 0.5; filter: saturate(0.3); }
.btn.primary {
  color: #fff6ea;
  background: linear-gradient(180deg, #ec8a3f 0%, #c4521e 100%);
  border-color: rgba(255, 190, 120, 0.35);
  box-shadow: 0 10px 30px rgba(220, 90, 30, 0.35), inset 0 1px 0 rgba(255, 230, 190, 0.35);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: rgba(255, 230, 200, 0.05); border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 230, 200, 0.1); }
.btn.small { height: 42px; font-size: 14px; width: auto; }
.btn svg { width: 22px; height: 22px; fill: currentColor; flex: none; }

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 12.5px;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.error { min-height: 1.5em; margin: 12px 0 0; color: var(--danger); font-size: 13.5px; text-align: center; }

.link {
  display: block;
  margin: 6px auto 0;
  padding: 6px;
  background: none;
  border: 0;
  color: var(--ember);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- У огня ---------- */

.hearth { pointer-events: none; }
.hearth > * { pointer-events: auto; }

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-left { justify-self: start; }
.top-right { justify-self: end; display: flex; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}
.chip:hover, .chip[aria-expanded="true"] { background: var(--glass-strong); border-color: var(--line-strong); }
.chip svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#room-btn svg { fill: var(--ember); stroke: none; }
#room-btn b { color: #ffd9a8; font-weight: 600; }
.chip-label { color: var(--muted); }
.chip.icon { width: 40px; padding: 0; justify-content: center; }
.chip.icon .off { display: none; }
.chip.icon[aria-pressed="false"] .on { display: none; }
.chip.icon[aria-pressed="false"] .off { display: block; }
.chip.icon.blocked { border-color: rgba(255, 154, 60, 0.6); animation: pulse 2s ease-in-out infinite; }

.timer-wrap { text-align: center; padding-top: 2px; }
.timer {
  font: 600 46px/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  color: #ffe2b0;
  text-shadow: 0 0 24px rgba(255, 140, 50, 0.45);
  letter-spacing: 0.02em;
}
.timer.out { color: var(--muted); text-shadow: none; }
.timer-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel {
  position: absolute;
  top: calc(var(--safe-t) + 52px);
  width: min(320px, calc(100vw - 32px));
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: pop 0.22s cubic-bezier(.2, .8, .2, 1) both;
}
.panel-right { right: var(--safe-r); transform-origin: top right; }
.panel-left { left: var(--safe-l); transform-origin: top left; }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-6px); } }

.panel h2 { margin: 0 0 10px; font: 600 24px/1.1 var(--serif); color: #fff1dc; }
.panel-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.panel h2 + .panel-note { margin: -4px 0 12px; }

.people { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.people li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.people li:last-child { border-bottom: 0; }
.people .dot { width: 8px; height: 8px; border-radius: 50%; background: #5d5148; flex: none; }
.people .online .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(143, 209, 139, 0.15); }
.people .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .tag { font-size: 12px; color: var(--muted); }
.people .away .name { color: var(--muted); }
.sound-panel { width: min(340px, calc(100vw - 32px)); }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-title-row h2 { margin: 0; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span[aria-hidden] {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: rgba(255, 230, 200, 0.12);
  border: 1px solid var(--line-strong);
  transition: background 0.2s;
}
.switch span[aria-hidden]::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ink-soft);
  transition: transform 0.2s, background 0.2s;
}
.switch input:checked + span { background: rgba(236, 138, 63, 0.75); border-color: rgba(255, 190, 120, 0.5); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff6ea; }
.switch input:focus-visible + span { outline: 2px solid var(--ember); outline-offset: 2px; }

.volume { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; color: var(--muted); }
.volume svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.volume input { flex: 1; accent-color: var(--ember); }

.sound-list {
  display: grid;
  gap: 2px;
  max-height: calc(100vh - var(--safe-t) - 210px);
  overflow-y: auto;
  margin: 0 -6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sound-list button {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 10px;
  align-items: start;
  padding: 9px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  transition: background 0.15s;
}
.sound-list button:hover { background: rgba(255, 230, 200, 0.06); }
.sound-list button::before {
  content: "";
  width: 14px; height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  box-sizing: border-box;
}
.sound-list button[aria-checked="true"] { background: rgba(255, 154, 60, 0.12); }
.sound-list button[aria-checked="true"]::before { border: 4px solid var(--ember); }
.sound-list b { font-size: 14px; font-weight: 600; color: var(--ink); }
.sound-list small { grid-column: 2; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.sound-list .now { color: var(--ember); font-weight: 600; }
.sound-panel.muted .sound-list, .sound-panel.muted .volume { opacity: 0.5; }

.people .divider { padding: 12px 2px 4px; border: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

.code-big {
  margin: 4px 0 12px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(8, 6, 5, 0.55);
  border: 1px dashed var(--line-strong);
  text-align: center;
  font-size: 26px;
  font-weight: 600;
  color: #ffd9a8;
  user-select: all;
}
.share-link {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 6, 5, 0.4);
  color: var(--ink-soft);
  font-size: 13px;
  outline: none;
}
.panel-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.panel-actions .btn { flex: 1; }

.bottombar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  pointer-events: none;
}
.bottombar > * { pointer-events: auto; }
.btn.big { width: auto; min-width: 250px; height: 56px; border-radius: 999px; font-size: 16.5px; padding: 0 28px; }
.status {
  margin: 0;
  min-height: 1.5em;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}
.status .warn { color: #ffb38a; }
.status b { color: #ffd9a8; font-weight: 600; }

.toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 92px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
  width: calc(100% - 32px);
}
.toast {
  max-width: 100%;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: toast-in 0.3s cubic-bezier(.2, .8, .2, 1) both;
}
.toast b { color: #ffd9a8; font-weight: 600; }
.toast.hide { animation: toast-out 0.4s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(0.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

.modal {
  width: min(380px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: #1a1310;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.modal h2 { margin: 0 0 8px; font: 600 28px/1.1 var(--serif); color: #fff1dc; }
.modal p { margin: 0 0 20px; color: var(--ink-soft); font-size: 14.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { flex: 1; }

:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Кнопка чата ---------- */

.actions { display: flex; align-items: center; justify-content: center; gap: 10px; }

.round-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  transition: background 0.2s, transform 0.12s;
}
.round-btn:hover { background: rgba(40, 29, 23, 0.92); }
.round-btn:active { transform: scale(0.96); }
.round-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ember);
  color: #1a0f08;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- Чат ---------- */

.chat {
  position: fixed;
  z-index: 7;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  display: flex;
  flex-direction: column;
  background: rgba(18, 13, 11, 0.9);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.45);
  animation: slide-in 0.28s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--safe-t) 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.chat-head h2 { margin: 0; font: 600 26px/1.1 var(--serif); color: #fff1dc; }
.chat-head .chip.icon svg { width: 18px; height: 18px; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 8px;
}
.chat-more { margin: 0 auto 10px; font-size: 13px; }
.chat-empty { margin: 30% 16px 0; text-align: center; color: var(--muted); font-size: 14px; }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 12px; }
.msg.cont { margin-top: 3px; }
.msg.mine { align-items: flex-end; }
.msg-head { display: flex; gap: 8px; align-items: baseline; margin: 0 6px 3px; font-size: 12px; color: var(--muted); }
.msg-name { color: #ffd9a8; font-weight: 600; font-size: 13px; }
.bubble {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 16px;
  border-top-left-radius: 6px;
  background: rgba(255, 236, 214, 0.07);
  border: 1px solid var(--line);
  font-size: 14.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.mine .bubble {
  border-top-left-radius: 16px;
  border-top-right-radius: 6px;
  background: linear-gradient(180deg, rgba(236, 138, 63, 0.3), rgba(196, 82, 30, 0.26));
  border-color: rgba(255, 170, 100, 0.3);
}
.msg.pending .bubble { opacity: 0.6; }
.bubble.has-img { padding: 4px; }
.bubble.has-img .msg-text { padding: 6px 8px 4px; }
.msg-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  min-width: 80px;
  min-height: 60px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.04);
  cursor: zoom-in;
}
.msg-text a { color: #ffc27a; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px var(--safe-b);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  border-radius: 22px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 6, 5, 0.6);
  color: var(--ink);
  font: 500 15px/1.4 var(--sans);
  resize: none;
  outline: none;
  overflow-y: hidden;
}
.composer textarea:focus { border-color: rgba(255, 154, 60, 0.6); }
.composer textarea::placeholder { color: rgba(217, 196, 168, 0.4); }
.attach, .send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  cursor: pointer;
}
.attach { color: var(--ink-soft); border: 1px solid var(--line); background: rgba(255, 230, 200, 0.04); }
.attach:hover { background: rgba(255, 230, 200, 0.1); }
.attach.disabled { opacity: 0.4; pointer-events: none; }
.send { border: 0; color: #fff6ea; background: linear-gradient(180deg, #ec8a3f, #c4521e); }
.send:disabled { opacity: 0.45; cursor: default; }
.attach svg, .send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.drop-hint {
  position: absolute;
  inset: 10px;
  display: none;
  place-items: center;
  border: 2px dashed rgba(255, 154, 60, 0.7);
  border-radius: 18px;
  background: rgba(20, 12, 8, 0.85);
  color: #ffd9a8;
  font-weight: 600;
  pointer-events: none;
}
.chat.drop .drop-hint { display: grid; }

/* On wide screens the chat docks beside the fire instead of covering it. */
body.chat-docked .hearth,
body.chat-docked .shade { right: 380px; }
/* Canvases are replaced elements: left/right alone would not resize them. */
body.chat-docked #fire,
body.chat-docked #flame,
body.chat-docked #labels { width: calc(100% - 380px); }
body.chat-docked #chat-btn { display: none; }
body.chat-docked .toasts { left: calc((100% - 380px) / 2); }
body.chat-docked .install { right: calc(380px + var(--safe-r)); }

.lightbox {
  max-width: 96vw;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: zoom-out;
}
.lightbox::backdrop { background: rgba(0, 0, 0, 0.88); }
.lightbox img { display: block; max-width: 96vw; max-height: 94vh; object-fit: contain; }

/* ---------- Установка ---------- */

.install {
  position: fixed;
  z-index: 8;
  right: var(--safe-r);
  bottom: calc(var(--safe-b) + 96px);
  width: min(400px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 12px 12px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: var(--glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.35s cubic-bezier(.2, .8, .2, 1) both;
}
.install img { border-radius: 12px; flex: none; }
.install-text { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-soft); line-height: 1.35; }
.install-text b { display: block; font-size: 14.5px; color: #fff1dc; margin-bottom: 2px; }
.install .btn.small { height: 38px; padding: 0 14px; }
.install .chip.icon { width: 32px; height: 32px; border: 0; background: transparent; }
.install .chip.icon svg { width: 16px; height: 16px; }
.install-menu { width: 100%; margin-top: 8px; }
.install-menu svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* The app opened from the home screen: no browser chrome to make room for. */
@media (display-mode: standalone) {
  body { user-select: none; -webkit-user-select: none; }
  input, textarea, .msg-text, .code-big { user-select: text; -webkit-user-select: text; }
}

/* ---------- Телефоны ---------- */

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "left right" "timer timer";
    row-gap: 14px;
  }
  .top-left { grid-area: left; }
  .top-right { grid-area: right; gap: 6px; }
  .timer-wrap { grid-area: timer; }
  .chip-label { display: none; }
  .chip { padding: 0 12px; }
  .timer { font-size: 52px; }
  .toasts { top: calc(var(--safe-t) + 150px); }
  .card { padding: 26px 20px 20px; }
  h1 { font-size: 38px; }
  .actions { width: 100%; max-width: 480px; }
  .btn.big { flex: 1; min-width: 0; width: auto; }
  .chat { width: 100%; border-left: 0; animation-name: rise; }
  .install {
    left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--safe-b) + 104px);
    display: grid;
    grid-template-columns: 48px 1fr auto;
    grid-template-areas: "icon text close" "btn btn btn";
    row-gap: 10px;
  }
  .install img { grid-area: icon; }
  .install-text { grid-area: text; }
  .install .chip.icon { grid-area: close; align-self: start; }
  .install .btn.small { grid-area: btn; width: 100%; }
}

@media (max-width: 400px) {
  .top-right { gap: 4px; }
  .chip { padding: 0 10px; }
  .chip.icon { width: 36px; }
}

@media (min-width: 641px) {
  /* Desktop: the chat button sits in the corner, the log button stays centred. */
  #chat-btn { position: fixed; right: var(--safe-r); bottom: var(--safe-b); }
}

@media (max-width: 360px) {
  #room-btn svg { display: none; }
  .chip { padding: 0 10px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
