:root {
  --bg: #0b0812;
  --bg-2: #130d1f;
  --panel: rgba(22, 15, 34, 0.78);
  --panel-solid: #181024;
  --line: rgba(232, 193, 90, 0.22);
  --line-strong: rgba(232, 193, 90, 0.5);
  --gold: #e8c15a;
  --gold-2: #b8862f;
  --gold-3: #f7e3a1;
  --bronze: #9a6a35;
  --violet: #8d5cf6;
  --violet-2: #b894ff;
  --text: #efe6d2;
  --muted: #a79fb8;
  --danger: #e0645f;
  --ok: #6fcf97;
  --radius: 14px;
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --display: 'Cinzel', 'Alegreya', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 var(--serif);
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: 0.03em; margin: 0; }
h1 { font-size: 30px; color: var(--gold-3); }
h2 { font-size: 20px; color: var(--gold-3); }
h3 { font-size: 17px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.grow { flex: 1; min-width: 0; }
.full { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.center { align-items: center; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- элементы форм ---------- */
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: rgba(8, 5, 14, 0.7);
  border: 1px solid rgba(232, 193, 90, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.15); }
textarea { resize: vertical; }
select option { background: var(--panel-solid); }
input[type='color'] { padding: 2px; width: 44px; height: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }
.field.inline, label.inline { flex-direction: row; align-items: center; gap: 10px; display: flex; }
.form-error { color: var(--danger); min-height: 1.2em; font-size: 15px; }

.btn {
  font: 600 15px/1 var(--display);
  letter-spacing: 0.06em;
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, filter 0.15s, background 0.15s;
  color: var(--text);
  background: transparent;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.gold {
  color: #1e1405;
  background: linear-gradient(180deg, #f6dd8c, #d9a93f 55%, #b8862f);
  border-color: #f7e3a1;
  box-shadow: 0 4px 18px rgba(232, 193, 90, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.ghost { border-color: var(--line-strong); color: var(--gold-3); }
.btn.ghost:hover:not(:disabled) { background: rgba(232, 193, 90, 0.08); }
.btn.danger { background: #8b2a2a; border-color: #c65050; }
.btn.danger.ghost { background: transparent; color: var(--danger); border-color: rgba(224, 100, 95, 0.5); }
.btn.sm { padding: 8px 14px; font-size: 13px; }
.btn.wide { width: 100%; padding: 14px; font-size: 16px; }
.link { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 10, 24, 0.7);
  color: var(--gold-3);
  cursor: pointer;
  font-size: 18px;
  flex: none;
}
.icon-btn:hover { border-color: var(--gold); background: rgba(40, 28, 60, 0.9); }
.badge { font: 600 11px/1 var(--display); letter-spacing: 0.08em; padding: 4px 7px; border-radius: 6px; border: 1px solid; }
.badge.warn { color: #f2c46d; border-color: rgba(242, 196, 109, 0.4); }
.badge.dm { color: var(--violet-2); border-color: rgba(184, 148, 255, 0.4); }
.badge.imp { color: var(--gold); border-color: rgba(232, 193, 90, 0.5); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.range { padding: 0; accent-color: var(--gold); flex: 1; }
.range-row { display: flex; gap: 8px; align-items: center; }
.num { width: 72px; padding: 5px 8px; font-size: 14px; }

.avatar { width: 40px; height: 57px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-strong); flex: none; }
.avatar.sm { width: 34px; height: 48px; border-radius: 7px; }
.avatar.xs { width: 26px; height: 37px; border-radius: 6px; }
.avatar-empty {
  display: grid; place-items: center;
  background: linear-gradient(160deg, #3a2463, #1a1030);
  color: var(--gold-3);
  font: 600 13px var(--display);
}
.avatar-empty.xs { font-size: 10px; }

/* ---------- тосты и модалки ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20, 13, 32, 0.95);
  border: 1px solid var(--line-strong);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast-error { border-color: rgba(224, 100, 95, 0.7); color: #ffd6d4; }
.toast-success { border-color: rgba(111, 207, 151, 0.6); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.modal-back { position: fixed; inset: 0; background: rgba(5, 3, 10, 0.72); display: grid; place-items: center; z-index: 900; padding: 16px; animation: fade 0.2s; backdrop-filter: blur(3px); }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel-solid); }
.modal.wide { width: min(720px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
@keyframes fade { from { opacity: 0; } }

.crop { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.crop-frame { border: 2px solid var(--gold); border-radius: 8px; overflow: hidden; line-height: 0; box-shadow: 0 0 0 6px rgba(232, 193, 90, 0.1); }
.crop-canvas { cursor: grab; touch-action: none; }
.crop .range { width: 280px; flex: none; }
.crop .row { align-self: stretch; }

/* ---------- экран входа ---------- */
.login-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #2a1450 0%, #120a22 45%, #07050c 100%);
  padding: 24px 16px;
}
.nebula {
  position: absolute; inset: -30%;
  background:
    radial-gradient(closest-side at 30% 40%, rgba(141, 92, 246, 0.25), transparent),
    radial-gradient(closest-side at 70% 60%, rgba(83, 52, 180, 0.22), transparent),
    radial-gradient(closest-side at 55% 25%, rgba(232, 193, 90, 0.06), transparent);
  animation: drift 40s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes drift { to { transform: rotate(12deg) scale(1.08); } }
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 90px 120px, #e8d9ff, transparent),
    radial-gradient(1.5px 1.5px at 160px 60px, #fff3c4, transparent),
    radial-gradient(1px 1px at 230px 180px, #fff, transparent),
    radial-gradient(1px 1px at 300px 40px, #d7c6ff, transparent),
    radial-gradient(1.5px 1.5px at 360px 150px, #fff, transparent);
  background-size: 400px 220px;
  opacity: 0.55;
  animation: twinkle 5s ease-in-out infinite alternate;
  pointer-events: none;
}
.stars-2 { background-size: 560px 340px; background-position: 130px 90px; opacity: 0.35; animation-duration: 7s; animation-delay: -3s; }
@keyframes twinkle { to { opacity: 0.15; } }

.login-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-width: 420px; }
.logo-wrap { position: relative; width: min(340px, 80vw, 40vh); }
.logo { position: relative; width: 100%; display: block; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6)); animation: logo-in 1s ease-out; }
.portal-glow {
  position: absolute; left: 50%; top: 38%; width: 70%; aspect-ratio: 1; transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(157, 108, 255, 0.55), rgba(157, 108, 255, 0) 65%);
  filter: blur(10px);
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.55; transform: translate(-50%, -50%) scale(1.12); } }
@keyframes logo-in { from { opacity: 0; transform: translateY(14px) scale(0.97); } }
.login-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(28, 18, 44, 0.86), rgba(15, 10, 24, 0.9));
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(247, 227, 161, 0.08);
  backdrop-filter: blur(12px);
}
.login-card.enter { animation: logo-in 0.35s ease-out; }
.card-title { text-align: center; font-size: 19px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.email-badge { align-self: center; font-size: 15px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--gold-3); background: rgba(232, 193, 90, 0.06); }
.code-input { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.3em; text-transform: uppercase; text-align: center; font-size: 20px; }
.login-foot { color: var(--muted); font-size: 14px; text-align: center; }

/* ---------- лобби ---------- */
.lobby { min-height: 100vh; position: relative; }
.lobby-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse at 15% -10%, rgba(141, 92, 246, 0.22), transparent 50%),
    radial-gradient(ellipse at 100% 0%, rgba(232, 193, 90, 0.08), transparent 40%),
    linear-gradient(180deg, #110b1c, #0b0812 60%);
}
.lobby-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 12px 32px;
  background: rgba(11, 8, 18, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px var(--display); color: var(--gold); letter-spacing: 0.08em; }
.brand img { height: 42px; }
.tabs { display: flex; gap: 6px; }
.tab { font: 600 15px var(--display); letter-spacing: 0.08em; color: var(--muted); padding: 10px 16px; border-radius: 10px; position: relative; }
.tab:hover { color: var(--gold-3); }
.tab.active { color: var(--gold); background: rgba(232, 193, 90, 0.08); }
.tab.active::after { content: ''; position: absolute; left: 16px; right: 16px; bottom: 3px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.user-menu { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: 99px; border: 1px solid var(--line); color: var(--text); }
.user-chip.active, .user-chip:hover { border-color: var(--gold); }
.user-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 14px var(--display); color: #1e1405; background: linear-gradient(180deg, #f6dd8c, #b8862f); }
.lobby-content { max-width: 1320px; margin: 0 auto; padding: 32px; display: flex; flex-direction: column; gap: 26px; }
.section-head { display: flex; flex-direction: column; gap: 6px; }
.section-head.row { flex-direction: row; justify-content: space-between; align-items: flex-end; }
.sub-head { margin-top: 10px; }

.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 26px; }
.poster {
  position: relative;
  aspect-ratio: 7 / 10;
  border-radius: 14px;
  overflow: hidden;
  display: block;
  color: var(--text);
  background: #150e22;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}
.poster:hover { transform: translateY(-6px); border-color: var(--gold); box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55), 0 0 30px rgba(141, 92, 246, 0.25); }
.poster-art, .poster-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #3b2170, #120a20 70%);
}
.poster-placeholder img { width: 40% !important; height: auto !important; position: static !important; opacity: 0.7; }
.poster-info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 60px 14px 14px;
  background: linear-gradient(180deg, transparent, rgba(8, 5, 14, 0.85) 35%, rgba(8, 5, 14, 0.97));
  display: flex; flex-direction: column; gap: 6px;
}
.poster-info h3 { font-size: 18px; color: var(--gold-3); line-height: 1.2; }
.poster-meta { display: flex; gap: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.poster-meta .online { color: var(--ok); }
.poster-when { display: flex; flex-direction: column; font-size: 13px; border-top: 1px solid var(--line); padding-top: 6px; }
.poster-when strong { color: var(--gold); font-weight: 500; font-size: 15px; }
.poster-when small { color: var(--muted); }
.poster-when.past strong { color: var(--muted); }
.when-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.role-badge { position: absolute; top: 10px; right: 10px; font: 700 11px var(--display); letter-spacing: 0.1em; padding: 5px 8px; border-radius: 6px; background: rgba(20, 12, 34, 0.85); border: 1px solid var(--violet-2); color: var(--violet-2); }
.poster-new {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: repeating-linear-gradient(135deg, rgba(232, 193, 90, 0.03) 0 12px, transparent 12px 24px), #120b1d;
  border: 2px dashed var(--line-strong);
  color: var(--gold-3);
  font-family: var(--display);
  text-align: center;
}
.poster-new .plus {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 54px; line-height: 1; color: var(--gold);
  border: 2px solid var(--gold);
  box-shadow: 0 0 30px rgba(141, 92, 246, 0.4), inset 0 0 20px rgba(141, 92, 246, 0.3);
  margin-bottom: 8px;
}
.poster-new span { font-size: 17px; letter-spacing: 0.08em; }
.empty-state { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* редактор игры */
.editor { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }
.editor-side { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 90px; }
.editor-main { display: flex; flex-direction: column; gap: 20px; }
.poster-edit { position: relative; aspect-ratio: 7 / 10; width: 100%; border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong); background: #150e22; cursor: pointer; padding: 0; }
.poster-edit img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-edit-hint, .portrait-hint {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px;
  font: 600 13px var(--display); letter-spacing: 0.08em; color: var(--gold-3);
  background: linear-gradient(180deg, transparent, rgba(8, 5, 14, 0.9));
  opacity: 0; transition: opacity 0.2s;
}
.poster-edit:hover .poster-edit-hint, .portrait:hover .portrait-hint, .poster-edit:has(.poster-placeholder) .poster-edit-hint { opacity: 1; }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; background: rgba(8, 5, 14, 0.45); border: 1px solid rgba(232, 193, 90, 0.1); }
.invite-code { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 14px; border-radius: 12px; border: 1px dashed var(--gold); background: rgba(232, 193, 90, 0.06); }
.invite-code .code { font: 700 26px ui-monospace, Consolas, monospace; letter-spacing: 0.25em; color: var(--gold); }
.editor form.row input { flex: 1; }

/* профиль */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px; }
.character-card { display: flex; gap: 18px; align-items: flex-start; padding: 16px; }
.portrait { position: relative; width: 140px; height: 200px; flex: none; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); background: #150e22; cursor: pointer; padding: 0; }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-empty { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--gold); gap: 4px; background: radial-gradient(circle at 50% 40%, #2d1a55, #120a20 75%); }
.portrait-empty span { font-size: 44px; line-height: 1; }
.portrait-empty small { color: var(--muted); font-size: 12px; }

/* ---------- игровое пространство ---------- */
.game-screen { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(ellipse at center, #1a1128, #07050c 80%); }
.map-box { position: absolute; inset: 0; }
.map-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.map-canvas.over-token { cursor: pointer; }
.map-canvas.grabbing { cursor: grabbing; }
.map-empty { position: absolute; left: calc(50% - 190px); top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 18px; pointer-events: none; font-style: italic; text-align: center; }

.game-top { position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 12px; padding: 6px 16px 6px 6px; border-radius: 12px; background: rgba(12, 8, 20, 0.78); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.game-title { display: flex; flex-direction: column; line-height: 1.15; }
.game-title span { font: 600 17px var(--display); color: var(--gold-3); letter-spacing: 0.05em; }
.game-title small { color: var(--muted); font-size: 13px; }
.map-tools { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.map-help { position: absolute; left: 64px; bottom: 16px; font-size: 13px; color: var(--muted); background: rgba(12, 8, 20, 0.7); padding: 6px 12px; border-radius: 8px; pointer-events: none; }

.dm-stack { position: absolute; top: 74px; left: 14px; width: 310px; max-height: calc(100vh - 150px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; scrollbar-width: thin; scrollbar-color: rgba(184, 148, 255, 0.35) transparent; }
.narrative .dm-stack { max-height: calc(100vh - 74px - min(42vh, 440px) - 36px); }
.dm-panel { width: 100%; flex: none; border-radius: 12px; background: rgba(14, 9, 24, 0.9); border: 1px solid rgba(184, 148, 255, 0.35); backdrop-filter: blur(10px); }
.dm-toggle { width: 100%; text-align: left; background: none; border: 0; color: var(--violet-2); font: 600 14px var(--display); letter-spacing: 0.06em; padding: 11px 14px; cursor: pointer; }
.dm-panel.collapsed { width: auto; }

/* саундборд */
.sb-badge { margin-left: 8px; min-width: 20px; padding: 2px 6px; border-radius: 99px; background: var(--violet); color: #fff; font: 700 11px var(--serif); }
.sb-body { gap: 12px; }
.sb-add { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid rgba(184, 148, 255, 0.2); }
.sb-add input { padding: 7px 10px; font-size: 14px; }
.sb-add-row { display: flex; gap: 6px; }
.sb-add-row input { flex: 1; }
.sb-list { display: flex; flex-direction: column; gap: 8px; }
.sb-item { padding: 8px; border-radius: 10px; background: rgba(8, 5, 14, 0.55); border: 1px solid rgba(184, 148, 255, 0.15); display: flex; flex-direction: column; gap: 6px; }
.sb-item.playing { border-color: rgba(184, 148, 255, 0.6); box-shadow: inset 0 0 18px rgba(141, 92, 246, 0.18); }
.sb-head { display: flex; align-items: center; gap: 6px; }
.sb-head .inline-edit { flex: 1; min-width: 0; font-size: 14px; padding: 2px 4px; }
.sb-kind { color: var(--violet-2); width: 18px; text-align: center; flex: none; }
.sb-status { font-size: 11px; color: var(--violet-2); white-space: nowrap; animation: pulse-text 1.6s ease-in-out infinite; }
@keyframes pulse-text { 50% { opacity: 0.45; } }
.sb-controls { display: flex; align-items: center; gap: 4px; }
.sb-btn { width: 32px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: rgba(12, 8, 20, 0.8); color: var(--gold-3); cursor: pointer; font-size: 14px; flex: none; }
.sb-btn:hover:not(:disabled) { border-color: var(--gold); }
.sb-btn.on { background: linear-gradient(180deg, #a57cff, #6a3fd6); border-color: #cdb6ff; color: #fff; }
.sb-btn:disabled { opacity: 0.35; cursor: default; }
.sb-btn:last-child { margin-left: auto; }
.sb-every { width: 58px; padding: 4px 6px; }
.sb-volume { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.sb-pct { width: 38px; text-align: right; color: var(--muted); font-size: 12px; }

.yt-host { position: fixed; left: -10000px; top: 0; width: 200px; height: 200px; overflow: hidden; pointer-events: none; opacity: 0; }
.sound-unlock { position: fixed; left: 50%; top: 90px; transform: translateX(-50%); z-index: 700; padding: 10px 18px; border-radius: 99px; border: 1px solid var(--gold); background: rgba(18, 11, 30, 0.95); color: var(--gold-3); font: 600 14px var(--serif); cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); animation: pop-in 0.25s ease-out; }
.dm-panel.collapsed .dm-body { display: none; }
.dm-body { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 16px; }
.dm-section { display: flex; flex-direction: column; gap: 10px; }
.dm-section .field > span { font-size: 13px; }
.dm-section select { padding: 6px 8px; font-size: 14px; }

.log-panel {
  position: absolute; top: 14px; right: 14px; bottom: 14px; width: 360px;
  display: flex; flex-direction: column;
  background: rgba(14, 9, 24, 0.66);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.log-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); gap: 10px; }
.log-title { font: 600 14px var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.online-list { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.online-list .avatar { box-shadow: 0 0 0 2px rgba(111, 207, 151, 0.55); }
.log-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; scrollbar-color: rgba(232, 193, 90, 0.3) transparent; }
.log-empty { color: var(--muted); text-align: center; font-style: italic; padding: 30px 10px; }
.msg { display: flex; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(8, 5, 14, 0.5); border: 1px solid rgba(232, 193, 90, 0.08); animation: msg-in 0.25s ease-out; }
.msg.mine { background: rgba(62, 38, 110, 0.35); }
.msg.is-important { border-color: rgba(232, 193, 90, 0.4); box-shadow: inset 0 0 20px rgba(232, 193, 90, 0.06); }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.msg-head strong { color: var(--gold-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head time { margin-left: auto; color: var(--muted); font-size: 12px; }
.msg-text { overflow-wrap: anywhere; font-size: 15px; }
.roll-line { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.roll-info { flex: 1; min-width: 0; }
.roll-text { font-style: italic; font-size: 14px; }
.roll-formula { font: 600 13px ui-monospace, Consolas, monospace; color: var(--violet-2); }
.roll-dice { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.roll-result {
  min-width: 52px; height: 44px; padding: 0 8px;
  display: grid; place-items: center;
  font: 700 24px var(--display); color: var(--gold);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 30%, rgba(232, 193, 90, 0.18), rgba(8, 5, 14, 0.6));
  border: 1px solid var(--line-strong);
}
.roll-result.crit { color: #fff1b8; border-color: var(--gold); box-shadow: 0 0 16px rgba(232, 193, 90, 0.5); }
.roll-result.fail { color: #ffb4b0; border-color: rgba(224, 100, 95, 0.7); }

.log-form { position: relative; padding: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.log-input-row { display: flex; gap: 8px; align-items: center; }
.log-input { flex: 1; padding: 10px 12px; font-size: 15px; }
.dice-btn { width: 46px; height: 46px; flex: none; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(8, 5, 14, 0.7); cursor: pointer; display: grid; place-items: center; padding: 0; transition: transform 0.2s; }
.dice-btn:hover { transform: rotate(-18deg) scale(1.06); border-color: var(--gold); }
.send-btn { width: 42px; height: 42px; flex: none; border-radius: 10px; border: 1px solid var(--gold-2); background: linear-gradient(180deg, #f6dd8c, #b8862f); color: #1e1405; font-size: 16px; cursor: pointer; }
.important { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; user-select: none; }
.important input { position: absolute; opacity: 0; pointer-events: none; }
.check-box { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--line-strong); background: rgba(8, 5, 14, 0.7); display: grid; place-items: center; flex: none; }
.important input:checked + .check-box { background: linear-gradient(180deg, #f6dd8c, #b8862f); border-color: var(--gold-3); }
.important input:checked + .check-box::after { content: '✓'; color: #1e1405; font-weight: 700; font-size: 14px; }
.important input:focus-visible + .check-box { box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.3); }
.important small { margin-left: auto; font-size: 12px; }

.dice-pop {
  position: absolute; bottom: calc(100% + 8px); left: 10px; right: 10px;
  background: rgba(18, 11, 30, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.18s ease-out;
  z-index: 5;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.die-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; border-radius: 10px; border: 1px solid rgba(232, 193, 90, 0.15); background: rgba(8, 5, 14, 0.5); color: var(--text); cursor: pointer; font: inherit; }
.die-pick:hover { border-color: var(--gold); }
.die-pick.picked { border-color: var(--gold); background: rgba(232, 193, 90, 0.1); }
.die-name { font: 700 14px var(--serif); }
.die-count { position: absolute; top: 4px; right: 6px; font: 700 12px var(--display); color: var(--gold); }
.dice-mod { display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--muted); }
.mod-ctrl { display: flex; align-items: center; gap: 4px; }
.mod-ctrl button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: rgba(8, 5, 14, 0.6); color: var(--gold-3); cursor: pointer; font-size: 18px; }
.mod-input { width: 64px; text-align: center; padding: 5px; }
.dice-preview { text-align: center; font: 600 15px ui-monospace, Consolas, monospace; color: var(--violet-2); padding: 6px; border-radius: 8px; background: rgba(8, 5, 14, 0.5); }

/* ---------- сцены ---------- */
.scene-layer { position: absolute; inset: 0; }
.log-compose { display: flex; gap: 8px; align-items: center; }
.log-compose > form { flex: 1; min-width: 0; }
.scenes-btn { margin-left: 6px; }
.stack.tight { gap: 2px; }

.no-scene-box { position: absolute; left: calc(50% - 190px); top: 50%; transform: translate(-50%, -50%); width: min(460px, 80vw); text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.no-scene-box img { width: 72px; opacity: 0.8; }

/* нарративная сцена */
.scene-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, #2a1a40, #07050c 80%); }
.scene-bg img, .scene-bg video { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade 0.8s ease-out; }
.scene-bg-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-style: italic; text-align: center; max-width: 60vw; }
.scene-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5, 3, 10, 0.72) 0%, rgba(5, 3, 10, 0) 18%, rgba(5, 3, 10, 0) 70%, rgba(5, 3, 10, 0.7) 100%),
    radial-gradient(ellipse at center, transparent 55%, rgba(5, 3, 10, 0.55) 100%);
}
.scene-title { position: absolute; top: 22px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; max-width: 44vw; }
.scene-title h1 { font-size: 36px; color: #f6ecd2; letter-spacing: 0.06em; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.6); line-height: 1.1; }
.scene-subtitle { margin-top: 4px; font: 600 13px var(--display); letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
.scene-side-tools { position: absolute; top: 18px; right: 372px; display: flex; flex-direction: column; gap: 10px; }
.round-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(12, 8, 20, 0.7); color: var(--gold-3); font-size: 18px; cursor: pointer; backdrop-filter: blur(8px); }
.round-btn:hover { border-color: var(--gold); }

.log-panel.compact { top: auto; right: auto; left: 14px; bottom: 14px; width: 330px; height: min(42vh, 440px); background: rgba(10, 7, 18, 0.58); }
.log-panel.compact .msg { padding: 6px 8px; }
.log-panel.compact .roll-result { min-width: 44px; height: 38px; font-size: 20px; }

.roll-dock { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.roll-dock .dice-btn {
  width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle at 50% 35%, #3a2362, #140c22 75%);
  box-shadow: 0 0 0 5px rgba(12, 8, 20, 0.75), 0 0 30px rgba(141, 92, 246, 0.45), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.roll-dock .dice-btn svg { width: 50px; height: 50px; }
.roll-dock .important { padding: 6px 14px; border-radius: 99px; background: rgba(12, 8, 20, 0.72); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.roll-dock .important small { display: none; }
.roll-dock .dice-pop { left: 50%; right: auto; width: 340px; transform: translateX(-50%); bottom: calc(100% + 12px); }

/* персонажи на сцене */
.cast { position: absolute; top: 14px; right: 14px; width: 344px; max-height: 62vh; display: flex; flex-direction: column; background: rgba(10, 7, 18, 0.55); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(12px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); }
.cast-tabs { display: flex; border-bottom: 1px solid var(--line); }
.cast-tab { flex: 1; background: none; border: 0; padding: 13px 8px 11px; font: 600 14px var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.cast-tab.active { color: var(--gold-3); border-bottom-color: var(--gold); }
.cast-body { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: rgba(232, 193, 90, 0.3) transparent; }
.cast-row { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 12px; cursor: pointer; }
.cast-row:hover, .cast-row.active { background: rgba(232, 193, 90, 0.08); }
.cast-row.is-hidden { opacity: 0.55; }
.cast-thumb { position: relative; flex: none; }
.cast-portrait { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 2px solid rgba(232, 193, 90, 0.45); display: block; }
.cast-portrait.empty { display: grid; place-items: center; background: linear-gradient(160deg, #3a2463, #1a1030); color: var(--gold-3); font: 600 16px var(--display); }
.online-dot { position: absolute; right: 2px; bottom: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid #120b1d; }
.cast-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cast-text strong { font: 600 16px var(--display); color: #f3e6c4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-text small { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cast-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.cast-row:hover .cast-actions { opacity: 1; }
.mini-btn { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: rgba(12, 8, 20, 0.8); color: var(--gold-3); cursor: pointer; font-size: 13px; }
.mini-btn:hover { border-color: var(--gold); }
.cast-section { margin: 10px 8px 2px; font-size: 14px; letter-spacing: 0.08em; text-transform: none; color: var(--gold-3); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.cast-empty { color: var(--muted); font-style: italic; font-size: 14px; padding: 14px 10px; text-align: center; }
.cast-add { align-self: flex-end; margin: 6px 4px 4px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(12, 8, 20, 0.8); color: var(--gold); font-size: 26px; line-height: 1; cursor: pointer; flex: none; }
.cast-add:hover { border-color: var(--gold); box-shadow: 0 0 16px rgba(232, 193, 90, 0.3); }
.cast-card { position: absolute; top: 0; right: calc(100% + 12px); width: 250px; padding: 14px; border-radius: 14px; background: rgba(12, 8, 20, 0.82); border: 1px solid var(--line); backdrop-filter: blur(12px); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); animation: pop-in 0.18s ease-out; }
.cast-card-head { text-align: center; display: flex; flex-direction: column; margin-bottom: 10px; }
.cast-card-head strong { font: 700 15px var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: #f6ecd2; }
.cast-card-head small { font: 600 12px var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.cast-card-art { position: relative; aspect-ratio: 7 / 10; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); }
.cast-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-card-empty { width: 100%; height: 100%; display: grid; place-items: center; font: 600 48px var(--display); color: var(--gold-3); background: radial-gradient(circle at 50% 40%, #2d1a55, #120a20 75%); }
.cast-card-tag { position: absolute; right: 8px; bottom: 8px; font: 700 11px var(--display); letter-spacing: 0.1em; padding: 5px 9px; border-radius: 6px; background: rgba(12, 8, 20, 0.85); border: 1px solid var(--gold-2); color: var(--gold); }

/* состояния на фишках */
.token-actions { position: absolute; z-index: 5; display: flex; gap: 6px; }
.token-action { display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 99px; border: 1px solid var(--gold); background: rgba(14, 9, 24, 0.94); color: var(--gold-3); font: 600 13px var(--serif); cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55); animation: pop-in 0.15s ease-out; }
.token-action span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #2a1b40; border: 1px solid #f2cf6b; }
.token-action:hover { background: rgba(40, 26, 62, 0.96); }
.cond-pop { position: absolute; z-index: 6; width: 372px; padding: 12px; border-radius: 14px; background: rgba(14, 9, 24, 0.97); border: 1px solid var(--line-strong); box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 10px; animation: pop-in 0.15s ease-out; }
.cond-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cond-head strong { font: 600 15px var(--display); color: var(--gold-3); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 13px; }
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.cond-item { --c: #999; display: flex; align-items: center; gap: 7px; min-width: 0; padding: 5px 7px; border-radius: 9px; border: 1px solid rgba(232, 193, 90, 0.12); background: rgba(8, 5, 14, 0.55); color: var(--muted); font: 13px var(--serif); cursor: pointer; text-align: left; }
.cond-item:hover { border-color: var(--c); color: var(--text); }
.cond-item.on { border-color: var(--c); color: #fff; background: color-mix(in srgb, var(--c) 18%, rgba(8, 5, 14, 0.8)); }
.cond-icon { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #140d20; border: 2px solid var(--c); opacity: 0.55; }
.cond-item.on .cond-icon { opacity: 1; }
.cond-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond-level { display: flex; align-items: center; gap: 3px; }
.cond-level button { width: 18px; height: 18px; padding: 0; border-radius: 5px; border: 1px solid var(--c); background: transparent; color: #fff; font-size: 12px; line-height: 1; cursor: pointer; }
.cond-level b { min-width: 10px; text-align: center; }

/* бой */
.combat-bar { position: absolute; top: 14px; left: 360px; right: 388px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 4; }
.combat-bar > * { pointer-events: auto; }
.fight-btn { padding: 12px 26px; font-size: 16px; letter-spacing: 0.12em; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 20px rgba(224, 100, 95, 0.25); }
.init-strip { display: flex; gap: 5px; align-items: flex-start; max-width: 100%; overflow-x: auto; padding: 6px 8px 14px; border-radius: 12px; background: linear-gradient(180deg, rgba(10, 7, 18, 0.72), rgba(10, 7, 18, 0.35)); scrollbar-width: thin; }
.init-card { position: relative; flex: none; width: 54px; aspect-ratio: 7 / 10; border-radius: 4px; overflow: visible; border: 2px solid; background: #1a1128; transition: transform 0.25s, filter 0.3s, opacity 0.3s; }
.init-card img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; display: block; border-radius: 2px; }
.init-card.player { border-color: #4caf7a; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.init-card.npc { border-color: #c0473f; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.init-card.player { border-color: #1c8f7a; }
.init-card.npc.neutral { border-color: #9aa0ab; }
.init-card.npc.elite { border-color: #7c4dff; }
.init-card.npc.boss { border-color: #c96a1c; }
.init-card.me { border-color: #5aa9e6; }
.init-card.done { filter: grayscale(1) brightness(0.55); opacity: 0.8; }
.init-card.waiting img, .init-card.waiting .init-initials { filter: grayscale(0.7) brightness(0.7); }
.init-card.current { width: 66px; border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 24px rgba(255, 255, 255, 0.35); }
.init-card.current::after { content: '▲'; position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); color: #fff; font-size: 11px; text-shadow: 0 1px 4px #000; }
.init-initials { width: 100%; height: 100%; display: grid; place-items: center; font: 600 15px var(--display); color: var(--gold-3); background: linear-gradient(160deg, #3a2463, #1a1030); }
.init-value { position: absolute; right: -4px; bottom: -6px; min-width: 20px; padding: 1px 4px; border-radius: 6px; background: rgba(8, 5, 14, 0.92); border: 1px solid var(--line-strong); font: 700 11px var(--serif); color: var(--gold-3); text-align: center; }
.init-value.pending { color: var(--violet-2); animation: pulse-text 1.4s ease-in-out infinite; }
.init-remove { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong); background: #1a1128; color: var(--gold-3); font-size: 9px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity 0.15s; padding: 0; }
.init-card:hover .init-remove { opacity: 1; }
.combat-info { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 16px; border-radius: 99px; background: rgba(12, 8, 20, 0.85); border: 1px solid var(--line); backdrop-filter: blur(8px); flex-wrap: wrap; justify-content: center; }
.combat-status { font-size: 15px; }
.combat-status strong { color: var(--gold-3); }
.combat-actions { display: flex; gap: 6px; }
.init-rolls { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: rgba(12, 8, 20, 0.9); border: 1px solid var(--line-strong); }
.init-roll { display: flex; align-items: center; gap: 8px; }
.init-roll > span:first-child { min-width: 130px; font-weight: 600; }
.init-roll .num { width: 58px; padding: 4px 6px; }
.npc-kind { display: flex; flex-direction: column; gap: 4px; }
.npc-kind select, .npc-create select { padding: 4px 6px; font-size: 13px; }
.npc-init { display: flex; align-items: center; gap: 4px; color: var(--gold); font-size: 13px; }
.npc-init .num { width: 54px; padding: 4px 6px; }

.round-banner { position: fixed; left: 0; right: 0; top: 34%; z-index: 750; display: flex; align-items: center; justify-content: center; gap: 22px; pointer-events: none; animation: round-in 2.6s ease-in-out forwards; }
.round-banner strong { font: 700 56px var(--display); letter-spacing: 0.14em; color: #f6ecd2; text-shadow: 0 0 30px rgba(232, 193, 90, 0.55), 0 3px 12px rgba(0, 0, 0, 0.9); }
.round-line { width: min(220px, 18vw); height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
@keyframes round-in {
  0% { opacity: 0; transform: scale(0.9); }
  15%, 75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}
.msg-system { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 8px; font: 600 13px var(--display); letter-spacing: 0.08em; color: var(--gold); text-align: center; }
.msg-system::before, .msg-system::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
.msg-system time { font: 11px var(--serif); color: var(--muted); letter-spacing: 0; }

/* менеджеры сцен и NPC */
.kind-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kind-card { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(8, 5, 14, 0.5); color: var(--text); cursor: pointer; font: inherit; }
.kind-card strong { font: 600 16px var(--display); color: var(--gold-3); }
.kind-card small { color: var(--muted); font-size: 14px; line-height: 1.3; }
.kind-card.active { border-color: var(--gold); background: rgba(232, 193, 90, 0.08); box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.12); }
.kind-icon { font-size: 22px; color: var(--gold); }
.row.fields { align-items: flex-start; }
.scene-list, .npc-library { display: flex; flex-direction: column; gap: 8px; }
.scene-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; background: rgba(8, 5, 14, 0.45); border: 1px solid rgba(232, 193, 90, 0.1); }
.scene-row.active { border-color: var(--gold); }
.scene-thumb { width: 96px; height: 60px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.scene-thumb.empty { display: grid; place-items: center; color: var(--gold); font-size: 22px; background: #150e22; }
.scene-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.inline-edit { background: transparent; border-color: transparent; padding: 2px 6px; font: 600 16px var(--display); color: var(--gold-3); }
.inline-edit.sub { font: 14px var(--serif); color: var(--muted); }
.inline-edit:hover { border-color: var(--line); }
.npc-create { display: flex; gap: 16px; align-items: flex-start; padding: 14px; border-radius: 12px; border: 1px dashed var(--line-strong); }
.portrait.sm { width: 105px; height: 150px; }

/* ---------- лист персонажа ---------- */
.sheet-drawer {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 650;
  width: min(640px, 100vw);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(22, 14, 34, 0.98), rgba(12, 8, 20, 0.98));
  border-right: 1px solid var(--line-strong);
  box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6);
  transform: translateX(-102%); transition: transform 0.25s ease-out;
  outline: none;
}
.sheet-drawer.open { transform: none; }
.sheet-head { display: flex; gap: 14px; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); position: relative; }
.sheet-portrait .avatar { width: 84px; height: 120px; border-radius: 10px; }
.sheet-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sheet-head .sheet-name { font: 600 22px var(--display); color: var(--gold-3); padding: 4px 8px; background: transparent; border-color: transparent; }
.sheet-name:hover, .sheet-name:focus { border-color: var(--line); }
.sheet-id-row { display: flex; gap: 8px; }
.sheet-id-row .sh-field { flex: 1; min-width: 0; }
.sheet-id-row .sh-field.narrow { flex: 0 0 64px; }
.sheet-x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; }
.sheet-tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.sheet-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 10px 8px; color: var(--muted); font: 600 13px var(--display); letter-spacing: 0.05em; cursor: pointer; white-space: nowrap; }
.sheet-tab.active { color: var(--gold-3); border-bottom-color: var(--gold); }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: rgba(232, 193, 90, 0.3) transparent; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.sheet-status { margin-right: auto; font-size: 13px; color: var(--muted); }

.sh-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sh-field > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.sh-field.wide { width: 100%; }
.sh-text, .sh-num, .sh-select { padding: 5px 8px; font-size: 14px; }
.sh-num { width: 74px; text-align: center; }
.sh-area { width: 100%; font-size: 14px; line-height: 1.45; padding: 8px 10px; resize: vertical; }
.sh-inline { display: flex; align-items: center; gap: 8px; }
.sh-inline .sh-num { width: 58px; }
.sh-section { display: flex; flex-direction: column; gap: 8px; }
.sh-section h4 { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.sh-strip { display: flex; flex-wrap: wrap; gap: 14px 22px; padding: 10px 12px; border-radius: 12px; background: rgba(8, 5, 14, 0.5); border: 1px solid rgba(232, 193, 90, 0.12); }
.sh-strip b { font: 700 20px var(--display); color: var(--gold-3); }
.sh-strip.big .sh-num { font-size: 18px; font-weight: 700; width: 70px; }
.sh-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--gold-2); background: transparent; cursor: pointer; padding: 0; flex: none; }
.sh-check.on { background: radial-gradient(circle, var(--gold) 45%, transparent 50%); }
.sh-roll { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; border-radius: 6px; }
.sh-roll:not(.static):hover { color: var(--gold); text-shadow: 0 0 10px rgba(232, 193, 90, 0.5); }
.sh-roll:not(.static):hover::after { content: ' 🎲'; font-size: 12px; }
.sh-mini { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: rgba(12, 8, 20, 0.8); color: var(--gold-3); cursor: pointer; padding: 0; flex: none; font-size: 13px; }
.sh-mini:hover { border-color: var(--gold); }
.sh-mini.del:hover { border-color: var(--danger); color: var(--danger); }

.ab-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ab-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 12px; background: rgba(8, 5, 14, 0.55); border: 1px solid var(--line); text-align: center; }
.ab-name { font: 600 11px var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ab-card .sh-roll b, .ab-card > span > b { font: 700 26px var(--display); color: var(--gold-3); }
.ab-score { width: 56px; padding: 2px; font-size: 13px; }
.ab-save { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.ab-save .sh-check { width: 14px; height: 14px; border-width: 1.5px; }
.sk-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.sk-row { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; }
.sk-row:hover { background: rgba(232, 193, 90, 0.05); }
.sk-row b { margin-left: auto; font: 700 15px var(--serif); color: var(--gold-3); }
.sk-name small { margin-left: 6px; font-size: 10px; color: var(--muted); letter-spacing: 0.06em; }
.sk-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--gold-2); background: transparent; cursor: pointer; padding: 0; flex: none; }
.sk-dot[data-level='1'] { background: radial-gradient(circle, var(--gold) 45%, transparent 50%); }
.sk-dot[data-level='2'] { background: var(--gold); box-shadow: 0 0 0 2px rgba(232, 193, 90, 0.35); }

.hp-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.hp-cur { font-size: 18px; font-weight: 700; color: var(--gold-3); }
.hp-ops { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.hp-ops .sh-num { width: 80px; }
.death { display: flex; flex-direction: column; gap: 4px; margin-left: auto; }
.pips { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.pips > span { width: 58px; }
.pip { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--gold-2); background: transparent; cursor: pointer; padding: 0; }
.pip.on { background: var(--gold); }
.death .pips:last-child .pip.on { background: var(--danger); border-color: var(--danger); }
.atk-list, .res-list { display: flex; flex-direction: column; gap: 8px; }
.atk-row { display: grid; grid-template-columns: 1fr 64px 1.2fr auto auto auto; gap: 6px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(8, 5, 14, 0.5); border: 1px solid rgba(232, 193, 90, 0.1); }
.atk-notes { grid-column: 1 / -1; font-size: 13px; }
.atk-bonus { text-align: center; }
.res-row { display: flex; align-items: center; gap: 6px; }
.res-row .sh-text { flex: 1; }
.res-row .sh-num { width: 58px; }
.res-count { min-width: 24px; text-align: center; color: var(--gold-3); }
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border-radius: 10px; background: rgba(8, 5, 14, 0.5); border: 1px solid rgba(232, 193, 90, 0.1); }
.slot-cell > b { font: 700 14px var(--display); color: var(--gold); width: 14px; }
.slot-cell .sh-num { width: 48px; padding: 3px; }
.slot-pips { display: flex; gap: 3px; flex-wrap: wrap; }
.slot-pips .pip.on { background: rgba(141, 92, 246, 0.85); border-color: var(--violet-2); }
.coins { display: flex; gap: 10px; flex-wrap: wrap; }
.coins .sh-num { width: 88px; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cast-card-sheet { width: 100%; margin-top: 10px; }

.lss-preview .lss-who { display: flex; flex-direction: column; }
.lss-who strong { font: 600 20px var(--display); color: var(--gold-3); }
.lss-abilities { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.lss-abilities > div { display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 8px; background: rgba(8, 5, 14, 0.55); border: 1px solid var(--line); }
.lss-abilities small { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.lss-abilities b { font: 700 18px var(--display); color: var(--gold-3); }
.lss-abilities span { font-size: 12px; color: var(--muted); }
.lss-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.lss-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.lss-warn { color: #f2c46d; font-size: 14px; }

@media (max-width: 640px) {
  .ab-grid { grid-template-columns: repeat(3, 1fr); }
  .sk-list, .persona-grid { grid-template-columns: 1fr; }
  .slot-grid, .looks { grid-template-columns: repeat(2, 1fr); }
  .atk-row { grid-template-columns: 1fr 56px auto auto auto; }
  .atk-dmg { grid-column: 1 / -1; grid-row: 2; }
  .sheet-id-row { flex-wrap: wrap; }
  .lss-abilities { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- анимация важного броска ---------- */
.roll-stage {
  position: fixed; inset: 0; z-index: 800;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(20, 10, 40, 0.55), rgba(3, 2, 6, 0.8));
  animation: fade 0.3s ease-out;
  cursor: pointer;
  transition: opacity 0.35s;
}
.roll-stage.out { opacity: 0; }
.roll-card {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  padding: 38px 36px 30px;
  text-align: center;
  color: #efe3c6;
  border-radius: 46% 46% 30px 30px / 90px 90px 30px 30px;
  background:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 70% 20%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 40% 80%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(ellipse at 50% 60%, #2a1c3e 0%, #150f1f 55%, #0c0911 100%);
  border: 2px solid #8a6034;
  box-shadow:
    0 0 0 6px #0f0b14,
    0 0 0 7px rgba(154, 106, 53, 0.6),
    0 40px 100px rgba(0, 0, 0, 0.75),
    inset 0 0 60px rgba(0, 0, 0, 0.6);
  animation: card-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.roll-card::before {
  content: ''; position: absolute; inset: 10px;
  border-radius: inherit;
  border: 1px solid rgba(184, 134, 47, 0.45);
  pointer-events: none;
}
@keyframes card-in { from { opacity: 0; transform: scale(0.85) translateY(20px); } }
.corner { position: absolute; width: 64px; height: 64px; color: #b8862f; pointer-events: none; }
.corner-tl { top: -10px; left: -10px; }
.corner-tr { top: -10px; right: -10px; transform: scaleX(-1); }
.corner-bl { bottom: -10px; left: -10px; transform: scaleY(-1); }
.corner-br { bottom: -10px; right: -10px; transform: scale(-1, -1); }
.roll-kicker { font: 600 15px var(--display); letter-spacing: 0.22em; text-transform: uppercase; color: #efe3c6; }
.roll-who { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; font: 600 22px var(--display); color: var(--gold-3); }
.roll-label { font-style: italic; color: #d9cba6; margin-top: 2px; }
.roll-expr { font: 600 14px ui-monospace, Consolas, monospace; color: var(--violet-2); margin-top: 4px; }
.tray-wrap { position: relative; margin: 18px -12px 10px; }
.braid {
  position: absolute; left: -24px; right: -24px; top: 50%; height: 16px; transform: translateY(-50%);
  background:
    repeating-linear-gradient(60deg, #c4935a 0 3px, #6b4524 3px 7px, #d9a96b 7px 9px, #6b4524 9px 12px),
    #8a6034;
  border-top: 1px solid #e0b880;
  border-bottom: 1px solid #3d2612;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  border-radius: 3px;
}
.braid::before, .braid::after { content: '◆'; position: absolute; top: 50%; transform: translateY(-50%); color: #e0b880; font-size: 16px; }
.braid::before { left: -4px; }
.braid::after { right: -4px; }
.tray {
  position: relative;
  margin: 0 auto;
  width: 92%;
  min-height: 130px;
  border-radius: 26px;
  background: radial-gradient(ellipse at 50% 40%, #2c2040, #120c1c 75%);
  border: 1px solid rgba(184, 134, 47, 0.55);
  box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.8), inset 0 -2px 0 rgba(232, 193, 90, 0.08), 0 6px 20px rgba(0, 0, 0, 0.5);
  overflow: visible;
}
.die { position: absolute; will-change: transform; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6)); }
.die svg { width: 100%; height: 100%; display: block; }
.die.landed.crit { filter: drop-shadow(0 0 16px rgba(247, 220, 134, 0.9)); animation: glow 1.4s ease-in-out infinite alternate; }
.die.landed.fail { filter: drop-shadow(0 0 14px rgba(224, 100, 95, 0.8)); }
@keyframes glow { to { filter: drop-shadow(0 0 26px rgba(247, 220, 134, 1)); } }
.die-shadow { position: absolute; height: 12px; border-radius: 50%; background: radial-gradient(ellipse, rgba(0, 0, 0, 0.7), transparent 70%); }
.roll-total {
  font: 700 64px/1 var(--display);
  color: #fff;
  text-shadow: 0 0 24px rgba(184, 148, 255, 0.5), 0 2px 0 #000;
  opacity: 0; transform: scale(0.6);
  transition: opacity 0.35s, transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  margin-top: 6px;
}
.roll-card.revealed .roll-total { opacity: 1; transform: none; }
.roll-card.is-crit .roll-total { color: #fff1b8; text-shadow: 0 0 30px rgba(247, 220, 134, 0.9); }
.roll-card.is-fail .roll-total { color: #ffc2bd; text-shadow: 0 0 30px rgba(224, 100, 95, 0.8); }
.roll-verdict { font: 600 16px var(--display); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 4px; opacity: 0; transition: opacity 0.4s 0.2s; }
.roll-verdict.crit { color: var(--gold); }
.roll-verdict.fail { color: var(--danger); }
.roll-card.revealed .roll-verdict { opacity: 1; }
.roll-breakdown { margin-top: 10px; color: #bfb3cf; font-size: 15px; opacity: 0; transition: opacity 0.4s 0.15s; }
.roll-card.revealed .roll-breakdown { opacity: 1; }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .lobby-header { padding: 10px 16px; gap: 14px; flex-wrap: wrap; }
  .brand span, .user-chip span:last-child { display: none; }
  .lobby-content { padding: 20px 16px; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; max-width: 240px; }
  .character-grid { grid-template-columns: 1fr; }
  .log-panel { top: auto; height: 46vh; left: 8px; right: 8px; bottom: 8px; width: auto; }
  .map-help { display: none; }
  .map-tools { bottom: calc(46vh + 20px); }
  .map-empty { left: 50%; top: 25%; }
  .dm-stack { width: calc(100vw - 28px); max-height: 40vh; z-index: 6; }
  .combat-bar { left: 8px; right: 8px; top: 64px; }
  .round-banner strong { font-size: 36px; }
  .no-scene-box { left: 50%; top: 25%; }
  .scene-title { top: 70px; max-width: 90vw; }
  .scene-title h1 { font-size: 24px; }
  .cast { top: auto; bottom: calc(30vh + 124px); right: 8px; width: min(300px, calc(100vw - 16px)); max-height: 30vh; }
  .cast-card { right: 0; top: auto; bottom: calc(100% + 8px); width: 200px; }
  .cast-portrait { width: 44px; height: 44px; }
  .scene-side-tools { right: 8px; top: 70px; }
  .log-panel.compact { left: 8px; right: 8px; width: auto; height: 30vh; }
  .roll-dock { bottom: calc(30vh + 22px); flex-direction: row; }
  .roll-dock .dice-btn { width: 64px; height: 64px; }
  .roll-dock .dice-pop { width: min(340px, calc(100vw - 16px)); }
  .kind-cards { grid-template-columns: 1fr; }
  .scene-row { flex-wrap: wrap; }
  .npc-create { flex-direction: column; align-items: center; }
}
@media (max-width: 480px) {
  .character-card { flex-direction: column; align-items: center; }
  .section-head.row { flex-direction: column; align-items: flex-start; gap: 12px; }
}
