/* Игровой стол под лампой: зелёное сукно, бумажные карточки, латунь для хода и красный кубик. */
:root {
  --felt: #1e3b35;
  --felt-deep: #152a26;
  --felt-line: #2f5a50;
  --paper: #f3eedd;
  --paper-edge: #d9d0b4;
  --ink: #1d2320;
  --ink-soft: #55605a;
  --brass: #d2a63c;
  --dice: #c13b2f;
  --on-felt: #e9efe6;
  --on-felt-soft: #a9bdb2;

  --story-font: "Palatino Linotype", Palatino, "PT Serif", "Noto Serif", Georgia, serif;
  --ui-font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --gap: 0.75rem;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Игра растёт вместе с экраном: от 16 px на телефоне до 30 px на большом мониторе, всё в rem — следом. */
html { color-scheme: dark; font-size: clamp(16px, 1.2vw, 30px); }

body {
  margin: 0;
  min-height: 100dvh;
  font: 1rem/1.45 var(--ui-font);
  color: var(--on-felt);
  /* Общий фон игры — картина (models/backgrounds/common.jpg), притемнённая, чтобы читался текст. */
  background: linear-gradient(rgb(8 18 16 / 0.35), rgb(8 18 16 / 0.75)), url("models/backgrounds/common.jpg") center / cover fixed, var(--felt-deep);
}

main { max-width: 80rem; margin: 0 auto; padding: 0 var(--gap); }

h1, h2 { font-family: var(--story-font); font-weight: 700; line-height: 1.15; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
p { margin: 0; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.hint { color: var(--on-felt-soft); font-size: 0.9rem; }

/* Сова-ведущий */
.owl { width: 2.6rem; height: 2.6rem; flex: none; color: #6b4a2b; }
.owl-large { width: 5rem; height: 5rem; }
.owl-belly { fill: #e7d3a6; }
.owl-eye { fill: #fbf6e6; }
.owl-pupil { fill: var(--ink); }
.owl-beak { fill: var(--brass); }
.thinking .owl-pupil { animation: look 2.4s ease-in-out infinite; }
@keyframes look { 0%, 100% { transform: translateX(-1.5px); } 50% { transform: translateX(1.5px); } }

/* Кнопки и поля */
button, select, input, textarea { font: inherit; color: inherit; }

button {
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.7rem 1.1rem;
  min-height: 2.9rem;
  cursor: pointer;
}
button.primary { background: var(--dice); color: #fff; font-weight: 650; }
button.primary:hover { background: #a93126; }
button.quiet { background: transparent; border-color: var(--felt-line); color: var(--on-felt); }
button.quiet:hover { border-color: var(--on-felt-soft); }
button:disabled { opacity: 0.5; cursor: default; }

:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

select, input[type="text"], input[type="number"], textarea {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--paper-edge);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  min-height: 2.9rem;
}
textarea { resize: none; font-family: var(--story-font); font-size: 1.05rem; line-height: 1.4; }
textarea:disabled { opacity: 0.55; }

label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--on-felt-soft); }

.notice {
  background: #4a1f1a;
  border-left: 4px solid var(--dice);
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  color: #ffe9e4;
}

/* Настройка игры */
#setup { padding: 1.5rem 0 3rem; }
.masthead { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.masthead p { color: var(--on-felt-soft); margin-top: 0.35rem; max-width: 34rem; }
.masthead .gear { margin-left: auto; align-self: flex-start; }
.gear { font-size: 1.15rem; line-height: 1; min-width: 2.3rem; }

/* Настройки экрана */
.settings { display: grid; gap: 0.5rem; margin-top: 0.9rem; }
.setting { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.6rem 0.7rem; background: #fff; border-radius: 8px; cursor: pointer; }
.setting[hidden] { display: none; }
.setting input { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; accent-color: var(--felt); }
.setting span { display: grid; gap: 0.15rem; font-size: 0.85rem; color: var(--ink-soft); }
.setting b { font-size: 1rem; color: var(--ink); }
.setting:has(input:disabled) { opacity: 0.55; cursor: default; }
.setting-block { margin-top: 0.9rem; display: grid; gap: 0.5rem; }
.looks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.look {
  display: grid; justify-items: center; gap: 0.2rem; padding: 0.3rem 0.2rem 0.4rem;
  background: #fff; color: var(--ink); border: 2px solid var(--paper-edge); border-radius: 10px; font-size: 0.85rem;
}
.look[aria-pressed="true"] { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.look-preview { width: 100%; aspect-ratio: 3 / 4; background: radial-gradient(circle at 50% 40%, #33584f, #18302b); border-radius: 7px; }
.install { margin-top: 1rem; display: grid; gap: 0.5rem; justify-items: start; }
.install h3 { font-size: 1rem; }

#setup-form { display: grid; gap: 1.25rem; max-width: 40rem; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 0.6rem; min-width: 0; }
legend { font-family: var(--story-font); font-size: 1.2rem; font-weight: 700; padding: 0; margin-bottom: 0.5rem; }

.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--gap); }
.choice label { display: block; color: var(--on-felt); font-size: 1rem; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: grid; gap: 0.2rem; height: 100%;
  padding: 0.8rem 0.9rem;
  border: 2px solid var(--felt-line);
  border-radius: var(--radius);
  color: var(--on-felt-soft);
  font-size: 0.9rem;
}
.choice b { color: var(--on-felt); font-size: 1.05rem; }
.choice input:checked + span { border-color: var(--brass); background: rgb(210 166 60 / 0.12); }
.choice input:disabled + span { opacity: 0.4; cursor: not-allowed; }
.choice input:focus-visible + span { outline: 3px solid var(--brass); outline-offset: 2px; }

/* Отметка «за игрока ходит ИИ» */
.tick { display: flex; align-items: center; gap: 0.5rem; color: var(--on-felt); cursor: pointer; }
.tick input { width: 1.15rem; height: 1.15rem; accent-color: var(--brass); }
.ai-badge { margin-left: 0.4rem; padding: 0.05rem 0.4rem; border-radius: 6px; background: var(--ink); color: var(--paper); font: 600 0.72rem/1.4 var(--ui-font); vertical-align: middle; }


/* Игра */
#game { display: grid; grid-template-rows: auto 1fr auto; min-height: 100dvh; }

.scene {
  position: sticky; top: 0; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 0.4rem var(--gap); justify-content: space-between; align-items: center;
  padding: 0.6rem 0;
  background: var(--felt-deep);
  border-bottom: 1px solid var(--felt-line);
}
/* Полосы на всю ширину окна: по краям шапки и поля хода лента не просвечивает. */
.scene, #composer { box-shadow: 0 0 0 100vmax var(--felt-deep); clip-path: inset(0 -100vmax); }
.scene-text { flex: 1 1 8rem; min-width: 0; }
.scene-place { font-family: var(--story-font); font-size: 1.25rem; font-weight: 700; }
.scene-about { display: none; color: var(--on-felt-soft); font-size: 0.9rem; margin-top: 0.15rem; }
.scene-tools { display: flex; gap: 0.4rem; flex: none; }
.scene-tools button { min-height: 2.3rem; padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.scene-tools .wide-only { display: none; }
/* Время партии: на паузе не идёт. */
.clock { align-self: center; color: var(--on-felt-soft); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Счёт в шапке телефона: фишка игрока и его здоровье. */
.score { display: flex; gap: 0.6rem; align-items: center; }
.chip { display: inline-flex; gap: 0.3rem; align-items: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.chip::before { content: ""; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--seat); }
.chip.turn-now::before { box-shadow: 0 0 0 2px var(--felt-deep), 0 0 0 4px var(--brass); }

.table { display: grid; gap: 1.25rem; padding: 1rem 0; align-content: start; }
.story { display: grid; gap: 0.9rem; align-content: start; min-width: 0; }
#feed, #live { display: grid; gap: 0.9rem; }
/* Новая карточка встаёт под шапку, а не прячется за ней. */
#feed > *, #live > * { scroll-margin-top: calc(var(--scene-h, 4.5rem) + 0.75rem); }

.tip { color: var(--on-felt-soft); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.tip button { min-height: 2.3rem; padding: 0.3rem 0.7rem; }

/* Слово ведущего: бумажная карточка рядом с совой */
.gm { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; }
.gm-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 0.8rem 1rem;
  font-family: var(--story-font);
  font-size: 1.12rem;
  line-height: 1.55;
  max-width: 44rem;
  box-shadow: 0 2px 0 var(--paper-edge);
  white-space: pre-line;
}
.gm-notes { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px dashed var(--paper-edge); font: 0.9rem/1.4 var(--ui-font); color: var(--ink-soft); display: grid; gap: 0.15rem; }
.gm.waiting .gm-card { color: var(--ink-soft); font-style: italic; }

/* Оценка ответа: неприметно под карточкой, чтобы не отвлекать от игры */
.rate { grid-column: 2; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: -0.3rem; font: 0.85rem/1.3 var(--ui-font); color: var(--on-felt-soft); }
.rate button.rate-mark { min-height: 2.2rem; padding: 0.1rem 0.45rem; background: transparent; font-size: 1rem; opacity: 0.4; filter: grayscale(1); }
.rate button.rate-mark:hover, .rate button.rate-mark:focus-visible { opacity: 0.85; }
.rate button.rate-mark[aria-pressed="true"] { opacity: 1; filter: none; border-color: var(--felt-line); }
.rate-note { display: flex; gap: 0.3rem; flex: 1 1 15rem; max-width: 30rem; }
.rate-note input { flex: 1; min-width: 0; padding: 0.35rem 0.6rem; border-radius: 6px; border: 1px solid var(--felt-line); background: var(--felt-deep); color: var(--on-felt); }
.rate-note button { min-height: 2.2rem; padding: 0.2rem 0.7rem; }
.rate button.rate-comment { min-height: 0; padding: 0.2rem 0.3rem; background: transparent; border: 0; color: var(--on-felt-soft); font-style: italic; text-align: left; }

/* Слово игрока: цвет его фишки слева */
.said {
  justify-self: end;
  max-width: 32rem;
  border-left: 6px solid var(--seat, var(--brass));
  background: rgb(255 255 255 / 0.06);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.55rem 0.9rem;
}
.said b { display: block; font-size: 0.85rem; color: var(--on-felt-soft); font-weight: 600; }

/* Бросок: кубик и счёт */
.roll { display: grid; grid-template-columns: auto 1fr; gap: 0.8rem; align-items: center; justify-self: center; }
.die {
  width: 3.4rem; height: 3.4rem;
  display: grid; place-items: center;
  background: var(--dice); color: #fff;
  border-radius: 12px;
  font: 700 1.5rem/1 var(--ui-font);
  font-variant-numeric: tabular-nums;
  transform: rotate(-6deg);
  box-shadow: 0 3px 0 #7d241c;
}
.roll.fresh .die { animation: tumble 0.6s ease-out; }
@keyframes tumble { from { transform: rotate(-200deg) scale(0.6); } to { transform: rotate(-6deg) scale(1); } }
.roll-sum { font-variant-numeric: tabular-nums; }
.roll-verdict { font-weight: 700; }
.roll-verdict.won { color: #9fd98a; }
.roll-verdict.lost { color: #f0a79c; }
.roll-why { color: var(--on-felt-soft); font-size: 0.9rem; }

/* 20 и 1: кубик золотой или тёмный и завалившийся, вердикт крупнее */
.roll.crit-won .die { background: var(--brass); color: var(--ink); box-shadow: 0 3px 0 #8a6a1c, 0 0 0 5px rgb(210 166 60 / 0.3); }
.roll.crit-lost .die { background: #3d4743; box-shadow: 0 3px 0 #232927; transform: rotate(14deg); }
.roll.crit-won .roll-verdict, .roll.crit-lost .roll-verdict { font-size: 1.15rem; }
.roll.crit-won .roll-verdict { color: var(--brass); }
.roll.fresh.crit-won .die { animation: tumble 0.6s ease-out, shine 1.2s ease-out 0.6s; }
.roll.fresh.crit-lost .die { animation: flop 0.8s ease-out; }
@keyframes shine {
  from { box-shadow: 0 3px 0 #8a6a1c, 0 0 0 0 rgb(210 166 60 / 0.9); }
  to { box-shadow: 0 3px 0 #8a6a1c, 0 0 0 5px rgb(210 166 60 / 0.3); }
}
@keyframes flop {
  from { transform: rotate(-200deg) scale(0.6); }
  70% { transform: rotate(26deg) scale(1); }
  to { transform: rotate(14deg) scale(1); }
}

/* Герои */
.heroes { display: grid; gap: var(--gap); align-content: start; }
#heroes { display: none; }
/* Карточка героя — игральная карта: наклоняется за мышью или пальцем, переворачивается на рюкзак. */
.hero {
  cursor: pointer;
  border-radius: var(--radius);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transform-style: preserve-3d;
  /* Наклон быстрый — карта идёт за пальцем; переворот медленный — его видно. */
  transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.15s ease-out;
}
.hero-inner {
  display: grid;
  transform-style: preserve-3d;
  transform: rotateY(var(--flip, 0deg));
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.hero.flipped { --flip: 180deg; }
.hero-face {
  grid-area: 1 / 1;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background:
    radial-gradient(circle at var(--glare-x, 30%) var(--glare-y, 0%), rgb(255 255 255 / 0.45), transparent 55%),
    linear-gradient(160deg, #fbf7ea, var(--paper) 55%, #e9e0c4);
  color: var(--ink);
  border-radius: var(--radius);
  border: 1px solid var(--paper-edge);
  border-top: 6px solid var(--seat, var(--brass));
  box-shadow: 0 6px 14px rgb(0 0 0 / 0.35), inset 0 0 0 3px rgb(255 255 255 / 0.35);
  padding: 0.6rem 0.9rem 0.7rem;
  display: grid; gap: 0.35rem; align-content: start;
}
.hero-back { transform: rotateY(180deg); }
.hero.turn-now .hero-face { box-shadow: 0 0 0 3px var(--brass), 0 6px 14px rgb(0 0 0 / 0.35); }
.hero.down .hero-face { filter: grayscale(0.7); opacity: 0.7; }
.hero:focus-visible .hero-face { outline: 3px solid var(--brass); outline-offset: 2px; }
.no-tilt .hero { transform: none; }
.hero-head { display: flex; gap: 0.65rem; align-items: center; }
/* Портрет: пока значок класса, позже — картинка героя. */
.hero-portrait {
  flex: none; width: 3rem; height: 3rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.6rem;
  background: radial-gradient(circle at 35% 30%, #fff, #e6dbbb);
  border: 3px solid var(--seat, var(--brass));
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.25);
}
.hero-name { font-family: var(--story-font); font-weight: 700; font-size: 1.1rem; }
.hero-role { color: var(--ink-soft); font-size: 0.85rem; }
.hero-about { color: var(--ink-soft); font-size: 0.85rem; }
.hero-stats { display: flex; gap: 0.35rem; }
.stat {
  flex: 1; display: grid; justify-items: center;
  padding: 0.2rem 0.1rem; border-radius: 6px;
  background: rgb(29 35 32 / 0.06); font-size: 0.75rem; color: var(--ink-soft);
}
.stat b { font-size: 1rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.hero-bag-hint { font-size: 0.85rem; color: var(--ink-soft); text-align: right; }
.bag { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr)); gap: 0.4rem; }
.bag-item {
  display: grid; justify-items: center; gap: 0.15rem; text-align: center;
  padding: 0.35rem 0.25rem; border-radius: 8px;
  background: rgb(255 255 255 / 0.6); border: 1px solid var(--paper-edge);
  font-size: 0.78rem; line-height: 1.2;
}
.bag-icon { font-size: 1.5rem; line-height: 1; }
.pips { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; }
.pip { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 2px solid var(--dice); }
.pip.full { background: var(--dice); }
.pips span { margin-left: 0.4rem; font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Ход */
#composer {
  position: sticky; bottom: 0; z-index: 2;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--felt-deep);
  border-top: 1px solid var(--felt-line);
  display: grid; gap: 0.4rem;
}
.turn { font-weight: 650; }
.turn::before { content: ""; display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--seat, var(--brass)); margin-right: 0.45rem; }
.composer-row { display: grid; grid-template-columns: 1fr; grid-auto-flow: column; grid-auto-columns: auto; gap: 0.5rem; align-items: stretch; }
/* Ход голосом: красный, пока слушает; пульс — чтобы было видно, что идёт запись. */
.mic { min-width: 3.2rem; font-size: 1.3rem; }
.mic.listening { background: #c0392b; color: #fff; border-color: #c0392b; animation: mic-pulse 1.1s ease-in-out infinite; }
.mic.thinking { opacity: 0.7; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 0.45rem rgb(192 57 43 / 0.35); } }
@media (prefers-reduced-motion: reduce) { .mic.listening { animation: none; } }
/* Голос по умолчанию: одна большая кнопка вместо поля; поле — мелкой кнопкой «Ввести текст вручную». */
.composer-row.voice-first { grid-template-columns: auto; justify-content: center; }
.composer-row.voice-first .mic { min-width: 14rem; padding: 0.7rem 1.6rem; font-size: 1.1rem; border-radius: 999px; }
.type-instead { justify-self: center; min-height: 0; padding: 0.15rem 0.6rem; font-size: 0.8rem; opacity: 0.75; }
.composer-extra { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
/* Вопрос ведущему: окно в стекле, как настройки экрана места. */
.ask-dialog { width: min(32rem, 94vw); padding: 1.1rem 1.2rem 1rem; border: 0; border-radius: 18px; color: #f2eee6;
  background: rgb(12 18 20 / 0.86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), 0 24px 60px rgb(0 0 0 / 0.55); }
.ask-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.ask-dialog h2 { margin: 0 0 0.3rem; font: 600 1.25rem var(--story-font); }
.ask-hint { margin: 0 0 0.8rem; color: rgb(242 238 230 / 0.65); font: 0.88rem/1.4 var(--ui-font); }
.ask-row { display: flex; gap: 0.5rem; align-items: stretch; }
.ask-row textarea { flex: 1; min-width: 0; padding: 0.6rem 0.8rem; border: 0; border-radius: 12px; resize: none;
  background: rgb(255 255 255 / 0.07); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); color: #f2eee6; font: 1rem/1.4 var(--ui-font); }
.ask-row .mic { border: 0; border-radius: 12px; background: rgb(255 255 255 / 0.08); color: #f2eee6; }
.ask-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.8rem; }
.ask-actions button { min-height: 2.4rem; padding: 0.35rem 1.1rem; border-radius: 999px; font: 600 0.92rem var(--ui-font); }
.ask-actions .quiet { border: 0; background: rgb(255 255 255 / 0.08); color: #f2eee6; }
/* Ответ на вопрос: стеклянная карточка сверху по центру, под «Ведущий думает». */
.answer { position: fixed; top: 8.4rem; left: 0; right: 0; z-index: 5; margin: 0 auto; width: min(38rem, 92vw);
  padding: 0.75rem 2.4rem 0.85rem 1.1rem; border-radius: 16px; color: #f2eee6;
  background: rgb(12 18 20 / 0.6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), 0 14px 40px rgb(0 0 0 / 0.4); animation: phrase-in 0.45s ease-out both; }
.answer[hidden] { display: none; }
.answer-q { margin: 0 0 0.35rem; color: rgb(242 238 230 / 0.6); font: italic 0.85rem/1.35 var(--ui-font); }
.answer-q::before { content: "Вопрос: "; font-style: normal; }
.answer-text { margin: 0; font: 400 1.05rem/1.55 var(--story-font); }
.answer.waiting .answer-text { display: flex; align-items: center; gap: 0.4rem; font-style: italic; color: rgb(242 238 230 / 0.75); }
.answer-close { position: absolute; top: 0.45rem; right: 0.45rem; min-height: 0; width: 1.8rem; height: 1.8rem; padding: 0;
  border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.08); color: #f2eee6; font-size: 0.8rem; }
.heard { display: grid; gap: 0.5rem; justify-items: center; text-align: center; padding: 0.6rem 0.9rem; border-radius: 12px; background: rgb(8 14 16 / 0.72); border: 1px solid rgb(255 255 255 / 0.12); }
.heard-text { margin: 0; font: italic 600 1.1rem/1.35 var(--story-font); }
.heard-text::before { content: "Вы сказали: "; font-style: normal; font-weight: 500; opacity: 0.7; }
.heard-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.turn-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem 0.8rem; }
.turn-row button { padding: 0.25rem 0.7rem; font-size: 0.9rem; }
#roll-dice { width: 100%; padding: 0.9rem; font-size: 1.15rem; }

/* Окна */
dialog {
  border: 0; border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  padding: 1.2rem;
  width: min(28rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgb(10 20 18 / 0.7); }
dialog h2 { margin-bottom: 0.5rem; }
dialog .hint { color: var(--ink-soft); }
dialog p + p { margin-top: 0.5rem; }
dialog button.quiet { color: var(--ink); border-color: var(--paper-edge); }
.stack { display: grid; gap: 0.5rem; margin-top: 0.9rem; }
.stack button { text-align: left; border-left: 6px solid var(--seat, var(--paper-edge)); background: #fff; color: var(--ink); border-radius: 0 var(--radius) var(--radius) 0; }
/* Уход из игры — не выбор игрока: стоит отдельно и выглядит иначе. */
.stack button.quiet { margin-top: 0.6rem; text-align: center; background: transparent; border: 2px solid var(--paper-edge); border-radius: var(--radius); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; }
.link { font: 600 1.05rem/1.4 ui-monospace, Consolas, monospace; word-break: break-all; background: #fff; padding: 0.6rem 0.7rem; border-radius: 6px; user-select: all; }
/* QR-код: чёрное на белом со светлым полем, иначе камеры его не читают. */
.qr { width: min(15rem, 100%); margin: 0.9rem auto; background: #fff; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr path { fill: #000; }
dialog .link { margin-top: 0; font-size: 0.9rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }

/* Герои и место на телефоне: тёмный лист снизу, чтобы бумажные карточки на нём читались. */
#sheet {
  background: var(--felt-deep); color: var(--on-felt);
  width: 100vw; max-width: 32rem; max-height: 88dvh;
  margin: auto auto 0;
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
}
#sheet .hint { color: var(--on-felt-soft); }
#sheet .heroes { margin-top: 0.9rem; }
#sheet button.quiet { color: var(--on-felt); border-color: var(--felt-line); }
.sheet-head { display: flex; gap: var(--gap); justify-content: space-between; align-items: flex-start; }
.sheet-head button { flex: none; min-height: 2.3rem; padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* Экран режима: две картины на весь экран, выбранная раскрывается и становится фоном. */
.mode-screen { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; gap: 1.2rem; padding: 1.2rem 0 1.5rem; }
/* Шапка экранов: слева «назад», в центре ведущий с репликой, справа настройки. */
.screen-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.screen-head .host { justify-self: center; min-width: 0; }
.screen-head > span:first-child { width: 2.3rem; }
.screen-head > :first-child { justify-self: start; }
.screen-head > .gear { justify-self: end; align-self: start; }
.host { display: flex; align-items: center; gap: 0.9rem; }
.host-avatar { flex: none; width: 5.5rem; height: 5.5rem; display: grid; place-items: center; }
.host-avatar .owl { width: 100%; height: 100%; transform-origin: 50% 90%; animation: host-idle 4s ease-in-out infinite; }
.host-figure, .host-canvas { width: 100%; height: 100%; display: block; }
.host-figure .owl { width: 100%; height: 100%; }
/* Пока ведущий говорит по центру, его место в шапке пустое, а облачко скрыто. */
.host.waiting .host-avatar { visibility: hidden; }
.host .host-bubble { transition: opacity 0.4s, transform 0.4s; }
.host.waiting .host-bubble { opacity: 0; transform: translateX(-10px); }

/* Выход ведущего: крупно по центру поверх всего. */
.host-stage {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-content: center; justify-items: center; gap: 0.5rem;
  background: radial-gradient(circle at 50% 45%, rgb(255 230 170 / 0.18), rgb(5 12 10 / 0.6) 70%);
  backdrop-filter: blur(3px);
  cursor: pointer;
  animation: stage-in 0.45s ease-out both;
}
.host-stage.leaving { animation: stage-out 0.6s ease-in forwards; pointer-events: none; }
@keyframes stage-in { from { opacity: 0; } }
@keyframes stage-out { to { opacity: 0; } }
.host-center { width: min(52vmin, 26rem); height: min(52vmin, 26rem); animation: pop-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes pop-in { from { transform: scale(0.3) translateY(30%); opacity: 0; } }
.host-say {
  max-width: min(34rem, 90vw); min-height: 1.4em;
  background: var(--paper); color: var(--ink);
  padding: 0.8rem 1.3rem; border-radius: 18px;
  font: 700 1.8rem/1.25 var(--story-font); text-align: center;
  box-shadow: 0 14px 30px rgb(0 0 0 / 0.45);
}
.host-say:empty { visibility: hidden; }
@keyframes host-idle { 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes host-talk { 0%, 100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.04, 0.97); } }
.host-bubble {
  position: relative; max-width: 22rem;
  background: var(--paper); color: var(--ink);
  padding: 0.45rem 0.8rem; border-radius: 14px;
  box-shadow: 0 8px 20px rgb(0 0 0 / 0.35);
}
.host-bubble::before {
  content: ""; position: absolute; left: -9px; top: 50%; translate: 0 -50%;
  border: 10px solid transparent; border-right-color: var(--paper); border-left: 0;
}
.host-line { font-size: 1.02rem; min-height: 1.15em; }
.host-sub { color: var(--ink-soft); font-size: 0.78rem; margin-top: 0.15rem; }
.mode-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; min-height: 0; }
.mode-card {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 22rem; padding: 0; border: 0; border-radius: 26px;
  display: flex; align-items: flex-end; text-align: left; cursor: pointer;
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.45);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;
  animation: card-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.mode-card[data-mode="adults"] { animation-delay: 0.12s; }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-6px) scale(1.012); box-shadow: 0 26px 50px rgb(0 0 0 / 0.55), 0 0 0 3px var(--brass); }
.mode-card:focus-visible { outline: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) scale(0.97); } }
.mode-card .art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; object-fit: cover; transition: transform 0.8s ease; }
/* Картина режима медленно «дышит»: живая, но не отвлекает. */
img.art { animation: art-drift 24s ease-in-out infinite alternate; }
@keyframes art-drift { from { object-position: 40% 50%; } to { object-position: 60% 50%; } }
@media (prefers-reduced-motion: reduce) { img.art { animation: none; } }
.mode-card:hover .art { transform: scale(1.06); }
.mode-text {
  display: grid; gap: 0.3rem; width: 100%;
  padding: 3rem 1.6rem 1.5rem;
  background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent);
  color: #fff; font-size: 1rem;
}
.mode-text b { font: 700 2.4rem/1.1 var(--story-font); text-shadow: 0 2px 10px rgb(0 0 0 / 0.4); }
.mode-text span { max-width: 26rem; color: rgb(255 255 255 / 0.9); }

/* Магический значок загрузки: руны по кругу, искры, пульсирующая звезда. */
.magic { display: inline-block; width: 3.2rem; height: 3.2rem; vertical-align: middle; flex: none; animation: magic-appear 0.4s ease-out 0.5s backwards; }
/* Значок проявляется не сразу: что грузится быстро, обходится без него; во время перехода между экранами его нет. */
@keyframes magic-appear { from { opacity: 0; } }
html.transitioning .magic, html.transitioning .magic-wait { visibility: hidden; }
.magic-small { width: 1.4rem; height: 1.4rem; margin-right: 0.45rem; vertical-align: -0.3rem; }
.magic-large { width: 7rem; height: 7rem; }
.magic { position: relative; }
/* Тёплый свет вокруг искры дышит. */
.magic::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; filter: blur(6px);
  background: radial-gradient(circle, rgb(255 170 90 / 0.22), rgb(255 110 40 / 0.07) 55%, transparent 72%); animation: ember-breathe 2.4s ease-in-out infinite; }
/* Искра и хвост: каждый уголёк — та же орбита с отставанием, меньше и тусклее. */
.magic .ember { position: absolute; inset: 0; animation: ember-orbit 1.8s cubic-bezier(0.45, 0.15, 0.55, 0.85) infinite; animation-delay: calc(var(--i) * -0.035s); }
.magic .ember::after { content: ""; position: absolute; left: 50%; top: 7%; width: 10%; height: 10%; margin-left: -5%; border-radius: 50%;
  background: hsl(calc(46 - var(--i) * 2.6) 100% calc(90% - var(--i) * 3.2%)); opacity: calc(1 - var(--i) * 0.068); transform: scale(calc(1 - var(--i) * 0.055));
  box-shadow: 0 0 5px 1px hsl(calc(36 - var(--i) * 2) 100% 62% / 0.8), 0 0 14px 4px rgb(255 110 30 / calc(0.4 - var(--i) * 0.025)); animation: ember-flicker 0.9s ease-in-out infinite alternate; }
.magic-small .ember::after { box-shadow: 0 0 3px 1px rgb(255 190 100 / 0.85); }
@keyframes ember-orbit { to { transform: rotate(360deg); } }
@keyframes ember-breathe { 50% { transform: scale(1.18); opacity: 0.75; } }
@keyframes ember-flicker { to { filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { .magic .ember { animation-duration: 4s; } .magic::before, .magic .ember::after { animation: none; } }
.magic-wait {
  position: fixed; inset: 0; z-index: 120; pointer-events: none;
  display: grid; place-items: center;
  background: radial-gradient(circle, rgb(20 10 40 / 0.35), transparent 40%);
  animation: stage-in 0.3s ease-out both;
}
.pick-stage > .magic, .world-carousel > .magic { margin: auto; }
/* Круг призыва лежит у ног героя и гаснет, когда герой появился. */
.pick-stage > .magic { position: absolute; left: 50%; bottom: 1.5rem; translate: -50% 0; transform: rotateX(62deg); z-index: 1; pointer-events: none; transition: opacity 0.45s, scale 0.45s; }
.pick-stage > .magic.fading { opacity: 0; scale: 1.4; }
.world-carousel > .magic { position: absolute; inset: 0; }
.look-preview { display: grid; place-items: center; }
.card3d-loading { display: grid; justify-items: center; gap: 0.3rem; }

/* Экран мира: витрина 3D-макетов, под ней название, описание и выбор. */
.world-screen { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: 1.2rem 0 1.5rem; }
.world-stage { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; min-height: 22rem; }
.world-carousel { position: relative; height: 100%; min-height: 22rem; touch-action: pan-y; cursor: grab; }
.world-carousel:active { cursor: grabbing; }
.world-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.world-arrow {
  width: 3rem; height: 3rem; border-radius: 50%; padding: 0; font-size: 1.8rem; line-height: 1;
  background: rgb(12 26 23 / 0.6); color: var(--on-felt); border: 1px solid var(--felt-line); z-index: 1;
}
.world-arrow:hover { border-color: var(--brass); }
.world-info { display: grid; justify-items: center; text-align: center; gap: 0.5rem; animation: rise 0.5s both; }
.world-info h2 { font-size: 2rem; text-shadow: 0 2px 12px rgb(0 0 0 / 0.5); }
.world-info p { max-width: 40rem; color: var(--on-felt); text-shadow: 0 1px 6px rgb(0 0 0 / 0.6); min-height: 3em; }
#world-pick { min-width: 16rem; }
#world-pick:disabled { opacity: 0.55; cursor: default; }
.world-dots { display: flex; gap: 0.4rem; }
.world-dot { width: 0.7rem; height: 0.7rem; min-height: 0; padding: 0; border-radius: 50%; background: rgb(255 255 255 / 0.3); border: 0; }
.world-dot[aria-current="true"] { background: var(--brass); transform: scale(1.3); }

/* Экран игроков: ряд живых карточек, как выбор бойцов; на телефоне листается пальцем. */
.lineup {
  display: flex; justify-content: safe center; gap: 0.6rem;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  padding: 0.3rem 0.2rem 0.8rem;
}
.lineup::-webkit-scrollbar { display: none; }
.lineup-wrap { position: relative; min-width: 0; }
/* Ряд не растягивает страницу, а листается внутри себя. */
#setup-form { grid-template-columns: minmax(0, 1fr); }
.lineup-wrap.more-left .lineup { mask-image: linear-gradient(to right, transparent, #000 4rem); }
.lineup-wrap.more-right .lineup { mask-image: linear-gradient(to left, transparent, #000 4rem); }
.lineup-wrap.more-left.more-right .lineup { mask-image: linear-gradient(to right, transparent, #000 4rem, #000 calc(100% - 4rem), transparent); }
.lineup-arrow {
  position: absolute; top: 9rem; z-index: 3;
  width: 3.4rem; height: 3.4rem; border-radius: 50%; padding: 0; font-size: 2rem; line-height: 1;
  background: rgb(12 26 23 / 0.8); color: var(--on-felt); border: 2px solid var(--brass);
  box-shadow: 0 6px 16px rgb(0 0 0 / 0.5);
  animation: stage-in 0.25s ease-out both;
}
.lineup-arrow.prev { left: 0.2rem; }
.lineup-arrow.next { right: 0.2rem; }
.lineup-arrow:hover { background: var(--brass); color: var(--ink); }
/* Карточка игрока — стеклянная, в стиле досье: герой на кольце, имя героя со стрелками, плашки характеристик, рюкзак. */
.pick {
  position: relative; flex: 0 1 16rem; min-width: 13rem; scroll-snap-align: center;
  display: grid; gap: 0.55rem; align-content: start;
  padding: 0 0.9rem 0.9rem; border-radius: 1.1rem;
  background: rgb(8 12 14 / 0.62); backdrop-filter: blur(10px); border: 1px solid rgb(255 255 255 / 0.1);
  box-shadow: inset 0 3px 0 var(--seat, var(--brass)), 0 18px 44px rgb(0 0 0 / 0.4);
  color: #ece9e2;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.pick-stage { position: relative; height: 17rem; margin: 0 -0.9rem; display: grid; place-items: center; }
.pick .pick-hero .pick-value { color: #fff; border-bottom: 2px solid var(--seat, var(--brass)); padding-bottom: 0.1rem; }
.pick-switch button { background: rgb(255 255 255 / 0.08); color: #ece9e2; border-color: rgb(255 255 255 / 0.18); }
.pick-switch button:hover { border-color: #e39a3b; }
.pick-name, .pick-custom input, .pick-custom textarea { background: rgb(255 255 255 / 0.08); color: #ece9e2; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 0.55rem; }
.pick-name::placeholder, .pick-custom input::placeholder, .pick-custom textarea::placeholder { color: rgb(236 233 226 / 0.45); }
.pick-name:focus, .pick-custom input:focus, .pick-custom textarea:focus { outline: none; border-color: var(--seat, #e39a3b); box-shadow: 0 0 0 2px color-mix(in srgb, var(--seat, #e39a3b) 45%, transparent); }
.pick-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pick-icon { font-size: 5.5rem; filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.4)); }
.pick-remove { position: absolute; top: 0.5rem; right: 0.5rem; background: rgb(0 0 0 / 0.45); color: #ece9e2; border-color: rgb(255 255 255 / 0.2); z-index: 1; min-width: 2rem; min-height: 2rem; padding: 0; }
.pick-switch { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.3rem; text-align: center; }
.pick-switch button { min-width: 2.2rem; min-height: 2.1rem; padding: 0; font-size: 1.25rem; line-height: 1; }
.pick-hero .pick-value { font: 700 1.25rem var(--story-font); }
.pick-look .pick-value { font-weight: 600; }
.pick-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(2.7rem, 1fr)); gap: 0.3rem; }
.pick-chip { display: grid; justify-items: center; padding: 0.3rem 0.2rem; border-radius: 0.55rem; background: rgb(255 255 255 / 0.07); }
.pick-chip b { color: #f3b25c; font-size: 0.9rem; white-space: nowrap; }
.pick-chip small { color: rgb(236 233 226 / 0.55); font-size: 0.66rem; }
.pick-about { margin: 0; font-size: 0.82rem; line-height: 1.4; color: rgb(236 233 226 / 0.78); text-align: center; min-height: 2.8em; }
.pick-bag { margin: 0; font-size: 0.78rem; color: rgb(236 233 226 / 0.65); text-align: center; }
.pick-custom { display: grid; gap: 0.4rem; }
.pick-custom[hidden] { display: none; }
.pick-name { font-weight: 600; text-align: center; }
/* «За него ходит ИИ» — переключатель, а не галочка. */
.pick-ai { display: flex; align-items: center; justify-content: center; gap: 0.55rem; cursor: pointer; font-size: 0.88rem; color: rgb(236 233 226 / 0.85); }
.pick-ai input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick-switch-knob { position: relative; width: 2.3rem; height: 1.3rem; border-radius: 1rem; background: rgb(255 255 255 / 0.2); transition: background 0.2s; flex: none; }
.pick-switch-knob::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #ece9e2; transition: transform 0.2s; }
.pick-ai input:checked + .pick-switch-knob { background: #e39a3b; }
.pick-ai input:checked + .pick-switch-knob::after { transform: translateX(1rem); }
.pick-ai input:focus-visible + .pick-switch-knob { box-shadow: 0 0 0 2px #fff; }
.add-slot {
  flex: 0 0 9rem; scroll-snap-align: center; min-height: 22rem; align-self: stretch;
  display: grid; place-content: center; gap: 0.3rem; text-align: center;
  border: 2px dashed rgb(227 154 59 / 0.45); border-radius: 1.1rem; background: rgb(8 12 14 / 0.35); backdrop-filter: blur(6px); color: #ece9e2;
}
.add-slot span { font-size: 2.6rem; line-height: 1; color: #e39a3b; }
.add-slot:hover { border-color: var(--brass); color: var(--on-felt); }

/* Фон выбранного режима за экранами настройки; затемнён, чтобы читались поля. */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: #090c0d; }
.backdrop[hidden] { display: none; }
/* На экранах после меню картина притемнена: текст и карточки читаются. */
.backdrop::after { content: ""; position: absolute; inset: 0; background: rgb(5 8 9 / 0.55); opacity: 0; transition: opacity 0.6s; }
.backdrop.dim::after { opacity: 1; }
#setup.enter > * { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#setup.enter > *:nth-child(2) { animation-delay: 0.08s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
/* Герои стоят прямо на фоне, «в пространстве»; подложка — только под выбором длины партии. */
#setup-form { max-width: none; }
#setup-form > fieldset, #setup-form > .notice { max-width: 40rem; background: rgb(12 26 23 / 0.72); backdrop-filter: blur(6px); padding: 1rem 1.2rem; border-radius: 18px; }
.screen-head .back { align-self: start; white-space: nowrap; }


@media (max-width: 40rem) {
  /* Телефон: кнопки сверху, ведущий с репликой — строкой под ними. */
  .screen-head { grid-template-columns: 1fr auto; }
  .screen-head .host { grid-column: 1 / -1; grid-row: 2; }
  .host-avatar { width: 4rem; height: 4rem; }
  .host-line { font-size: 0.95rem; }
  .mode-choices { grid-template-columns: 1fr; }
  .mode-card { min-height: 15rem; }
  .mode-text b { font-size: 1.9rem; }
}

/* Экран игры с 3D-местом: место — весь фон, шапка и поле хода поверх, ответ ведущего — субтитрами,
   вся история — панелью по кнопке. Без 3D-места (мир без схем) всё как раньше. */
.place3d { display: none; }
.history-button, .feed-head, .subtitle { display: none; }
#game.with-place .place3d { display: block; position: fixed; inset: 0; z-index: 0; background: #0b0908; }
.place3d > .magic { position: absolute; inset: 0; margin: auto; }
/* Размер холста в пикселях — с плотностью экрана; на экране он ровно по окну, иначе при масштабе Windows больше 100 % края уходят за экран. */
.place3d canvas { display: block; width: 100%; height: 100%; animation: stage-in 0.8s ease-out both; }
/* Подписи над героями и персонажами: стекло, точка цвета игрока; у персонажей мира — без точки, мельче. */
.place-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.place-tag {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.22rem 0.7rem 0.24rem 0.55rem; border-radius: 999px; will-change: transform;
  background: rgb(10 16 18 / 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.08), 0 4px 12px rgb(0 0 0 / 0.35);
  color: #f6f2ea; font: 600 0.85rem/1.2 var(--ui-font); letter-spacing: 0.01em;
}
.place-tag::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--seat); box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat) 30%, transparent), 0 0 8px var(--seat); }
.place-tag.npc { padding: 0.16rem 0.6rem; color: rgb(242 238 230 / 0.82); font-size: 0.75rem; font-weight: 500; }
.place-tag.npc::before { display: none; }
.place-tag[hidden] { display: none; }
/* Нарисованное место: картинка под прозрачным 3D-холстом, заполняет экран без искажений. */
.location-canvas.painted { background: #14110f center / cover no-repeat; }
#game.with-place .scene, #game.with-place #composer { box-shadow: none; clip-path: none; background: transparent; border: 0; }
#game.with-place .scene { background: linear-gradient(rgb(6 12 10 / 0.75), transparent); padding-bottom: 1.2rem; }
#game.with-place .scene-about { display: none; }
/* Перетаскивание по месту не выделяет текст поверх него. */
#game.with-place .scene, #game.with-place .story { user-select: none; }
#game.with-place #open-sheet { display: flex; }
#game.with-place .history-button { display: inline-block; }
#game.with-place #heroes { display: none !important; }
#game.with-place .table { display: block; padding: 0; }
#game.with-place .story {
  /* Без transform: иначе панель истории внутри привязалась бы к этому блоку, а не к экрану. */
  position: fixed; left: 0; right: 0; margin-inline: auto; z-index: 2;
  bottom: calc(var(--composer-h, 8rem) + 0.4rem);
  width: min(50rem, 94vw); max-height: 40dvh; overflow-y: auto;
  display: grid; gap: 0.5rem; scrollbar-width: thin;
}
#game.with-place #composer { position: fixed; left: 0; right: 0; bottom: 0; padding-left: max(var(--gap), calc(50vw - 40rem)); padding-right: max(var(--gap), calc(50vw - 40rem)); background: linear-gradient(transparent, rgb(6 12 10 / 0.85) 35%); }
#game.with-place .subtitle { display: grid; }
#game.with-place .subtitle[hidden] { display: none; }
/* «Ведущий думает» — сверху по центру, под шапкой: внизу остаются ход и субтитры (Роман). */
#game.with-place #live .gm.waiting, #game.with-place #subtitle .phrase.thinking {
  position: fixed; top: 5.2rem; left: 0; right: 0; z-index: 4; margin: 0 auto; width: max-content; max-width: 90vw;
}
/* Субтитры и ход поверх места: бумага полупрозрачная, место видно сквозь неё. */
/* Без подложки: белый текст с тёмной обводкой читается на любом месте. */
#game.with-place #live .owl { display: none; }
#game.with-place #live .gm:not(.waiting) { display: none; }
#game.with-place #live .gm-card, #game.with-place #live .said {
  background: transparent; box-shadow: none; border: 0; color: #fff; max-width: none; justify-self: center; text-align: center;
  text-shadow: 0 0 2px #000, 0 2px 6px #000, 0 0 16px rgb(0 0 0 / 0.8);
}
#game.with-place #live .said { font-style: italic; }
#game.with-place #live .said b, #game.with-place #live .said .said-player { color: var(--seat, var(--brass)); }
#game.with-place .subtitle { cursor: pointer; justify-items: center; gap: 0.5rem; }
.phrase {
  /* Некрупно и по экрану: на ноутбуке около 18–21 px, на телефоне 15 px. */
  max-width: 48rem; text-align: center; color: #fff;
  font: 600 clamp(0.95rem, 0.6rem + 0.6vw, 1.3rem)/1.4 var(--story-font);
  text-shadow: 0 0 2px #000, 0 0 3px #000, 0 3px 8px #000, 0 0 24px rgb(0 0 0 / 0.85);
  animation: phrase-in 0.45s ease-out both;
}
@keyframes phrase-in { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }
.phrase-dots { display: flex; gap: 0.4rem; justify-content: center; }
.phrase-dot { width: 0.6rem; height: 0.6rem; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.35); box-shadow: 0 0 4px #000; }
.phrase-dot[aria-current="true"] { background: var(--brass); transform: scale(1.25); }
#game.with-place #feed { display: none; }
/* Вступление: место приглушено, ведущий крупно слева, текст истории целиком, текущая фраза ярче. */
.intro {
  position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(8rem, 18rem) minmax(0, 46rem);
  justify-content: center; align-items: center; gap: 2rem; padding: 4rem 2rem 6rem;
  background: radial-gradient(ellipse at center, rgb(6 10 9 / 0.72), rgb(4 6 6 / 0.92));
  animation: stage-in 0.6s ease-out both;
}
.intro[hidden] { display: none; }
.intro-host { height: min(60vh, 26rem); }
.intro-text {
  max-height: 70vh; overflow-y: auto; scrollbar-width: none; cursor: pointer; user-select: none;
  font: 600 1.6rem/1.5 var(--story-font); color: #fff; text-shadow: 0 2px 8px #000;
}
.intro-phrase { opacity: 0.28; transition: opacity 0.6s ease; }
.intro-phrase.done { opacity: 0.75; }
.intro-phrase.current { opacity: 1; }
/* С картой: ведущий слева, карта мира в центре, рассказ под ней некрупно. */
.intro-map { display: none; }
.intro.with-map { grid-template-columns: minmax(6rem, 13rem) minmax(0, 64rem); grid-template-rows: auto auto; align-content: center; row-gap: 1rem; padding-top: 2rem; }
.intro.with-map .intro-host { grid-row: 1 / span 2; }
.intro.with-map .intro-map { display: block; width: min(100%, 92vh); justify-self: center; border-radius: 12px; overflow: hidden; box-shadow: 0 18px 50px rgb(0 0 0 / 0.6); }
.intro.with-map .intro-text { max-height: 20vh; font-size: clamp(1rem, 0.7rem + 0.6vw, 1.35rem); text-align: center; }
/* Конец вступления: фон и рассказ гаснут, карта летит в кнопку «Карта», под ней — основной экран. */
.intro.leaving { background: transparent; transition: background 0.7s ease; pointer-events: none; }
.intro.leaving .intro-host, .intro.leaving .intro-text, .intro.leaving ~ .intro-skip, .intro.leaving .intro-skip { opacity: 0; transition: opacity 0.4s ease; }
#open-map.arrived { animation: map-arrived 1.2s ease-out; }
@keyframes map-arrived { 30% { box-shadow: 0 0 0 0.35rem rgb(243 178 92 / 0.55), 0 0 24px rgb(243 178 92 / 0.8); } }
/* Пока идёт вступление, шапка, субтитры и поле хода не просвечивают. */
#game.in-intro .scene, #game.in-intro .story, #game.in-intro #composer, #game.in-intro .game-host { visibility: hidden; }
.intro-skip { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 21; width: auto; }
@media (max-width: 40rem) {
  .intro { grid-template-columns: 1fr; align-content: start; gap: 0.5rem; padding: 1.5rem 1rem 5rem; }
  .intro-host { height: 9rem; }
  .intro-text { font-size: 1.2rem; max-height: 60dvh; }
  .intro.with-map { grid-template-columns: 1fr; padding-top: 1rem; }
  .intro.with-map .intro-host { grid-row: auto; height: 6rem; }
  .intro.with-map .intro-text { max-height: 30dvh; }
}

/* Ведущий на месте — слева от субтитров, над полем хода. */
.game-host { display: none; }
#game.with-place .game-host:not([hidden]) {
  display: block; position: fixed; z-index: 3; left: max(0.75rem, calc(50vw - 40rem)); bottom: calc(var(--composer-h, 8rem) + 0.2rem);
  width: 10rem; height: 12rem; min-height: 0; padding: 0; border: 0; background: transparent; box-shadow: none; cursor: pointer;
  filter: drop-shadow(0 6px 10px rgb(0 0 0 / 0.6));
}
@media (max-width: 75rem) {
  #game.with-place .game-host:not([hidden]) { left: 0.4rem; width: 6rem; height: 7.5rem; }
  #game.with-place:has(.game-host:not([hidden])) .story { padding-left: 5.5rem; }
}
@media (max-width: 40rem) {
  #game.with-place .game-host:not([hidden]) { width: 4.5rem; height: 5.5rem; }
  #game.with-place:has(.game-host:not([hidden])) .story { padding-left: 4.2rem; }
}
#game.with-place.show-history #feed {
  display: grid; align-content: start; position: fixed; z-index: 6; top: 0; right: 0; bottom: 0;
  width: min(34rem, 96vw); overflow-y: auto; padding: 0 1rem 2rem;
  background: rgb(8 18 16 / 0.94); backdrop-filter: blur(6px); box-shadow: -10px 0 30px rgb(0 0 0 / 0.5);
  animation: history-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes history-in { from { transform: translateX(40px); opacity: 0; } }
/* История открыта — она над всем, субтитры под ней не просвечивают. */
#game.with-place.show-history .story { z-index: 10; }
#game.with-place.show-history .subtitle, #game.with-place.show-history #live { visibility: hidden; }
#game.with-place.show-history .feed-head {
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 1; padding: 0.9rem 0; background: rgb(8 18 16 / 0.96);
  font: 700 1.2rem var(--story-font);
}

@media (min-width: 56rem) {
  main { padding: 0 1.5rem; }
  h1 { font-size: 2.4rem; }
  .scene-about { display: block; }
  .scene-tools .wide-only { display: inline-block; }
  #open-sheet, .tip { display: none; }
  .table { grid-template-columns: minmax(0, 1fr) 21rem; }
  /* Панель героев стоит под шапкой и прокручивается сама, если героев много. */
  #heroes {
    display: grid;
    position: sticky; top: calc(var(--scene-h, 4.5rem) + 1rem);
    align-self: start;
    max-height: calc(100dvh - var(--scene-h, 4.5rem) - var(--composer-h, 8rem) - 1.5rem);
    overflow-y: auto;
    /* Запас под рамку «сейчас ходит»: прокрутка её обрезает. */
    padding: 4px; margin: -4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* На узком телефоне у «Истории» и «Карты» только значки: иначе шапка не влезает. */
@media (max-width: 420px) { .map-word { display: none; } }

/* Карта мира: нарисованная картинка, поверх — тропы, места и фишки героев. */
.map-dialog { width: min(96vw, 1200px); max-width: none; max-height: 96vh; overflow: hidden; padding: 0.8rem; background: #241d14; color: #f3e6c8; }
.map-dialog h2 { color: #f3e6c8; }
.map-dialog button.quiet { color: #f3e6c8; border-color: #6b5434; }
.map-dialog.travelling .sheet-head button { visibility: hidden; }
/* Карта целиком в окне: по ширине или по высоте, что меньше. */
.map-board { position: relative; width: min(100%, calc((96vh - 5rem) / var(--map-aspect, 0.68))); margin: 0 auto; }
.map-board img { display: block; width: 100%; height: auto; border-radius: 8px; }
.map-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-path { stroke: #6b3d12; stroke-width: 5; stroke-dasharray: 12 9; stroke-linecap: round; opacity: 0.9; }
.map-path.hidden-path { opacity: 0.25; }
.map-point circle { fill: #f6e7c1; stroke: #5b3511; stroke-width: 4; }
.map-point.here circle { fill: #ffcf5a; stroke: #8a2a0a; stroke-width: 5; }
.map-point.unknown circle { fill: #8a7d68; opacity: 0.75; }
.map-point text { font: 600 22px Georgia, serif; fill: #2c1a08; paint-order: stroke; stroke: #f6e7c1; stroke-width: 6px; stroke-linejoin: round; }
.map-point.unknown text { fill: #5b4a33; }
.map-token circle { stroke: #fff; stroke-width: 3; }
.map-token text { font: 700 13px system-ui, sans-serif; fill: #fff; }
.map-token.away { opacity: 0.55; }
@media (max-width: 700px) {
  .map-dialog { width: 100vw; padding: 0.5rem; }
  .map-point text { font-size: 30px; }
}
/* Объёмная карта: поле в 3D, подсказка по нажатию на место или героя. */
.map3d { position: relative; }
.map3d-canvas { display: block; width: 100%; border-radius: 8px; touch-action: none; cursor: grab; }
.map3d-info { position: absolute; transform: translate(-50%, -130%); padding: 0.3rem 0.6rem; border-radius: 8px; background: #f6e7c1; color: #2c1a08; font: 600 0.95rem Georgia, serif; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 14px rgb(0 0 0 / 0.4); }

/* Текст рассказа выключен: ведущего только слушают, точки фраз остаются. */
#subtitle.voice-only .phrase { visibility: hidden; }

/* Ответ ещё озвучивается целиком: вместо фразы — «Ведущий думает…». */
.phrase.thinking { display: flex; align-items: center; justify-content: center; gap: 0.3rem; font-style: italic; font-size: 0.95em; text-shadow: none; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.95)) drop-shadow(0 0 8px rgb(0 0 0 / 0.6)); }
.phrase.thinking .magic { animation: none; width: 1.6rem; height: 1.6rem; }
/* Надпись переливается, как пламя: тёплый блик бежит по буквам. */
.thinking-text { background: linear-gradient(90deg, rgb(236 233 226 / 0.85) 30%, #ffe2ad 45%, #ffad5c 50%, #ffe2ad 55%, rgb(236 233 226 / 0.85) 70%) 0 0 / 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0; animation: thinking-shine 2.4s linear infinite; }
@keyframes thinking-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Начальный экран: ведущий у костра, меню слева столбиком ---------- */
.menu-screen { position: fixed; inset: 0; overflow: hidden; z-index: 5; }
.menu-art, .menu-live { position: absolute; inset: -3%; width: 106%; height: 106%; object-fit: cover; animation: menu-drift 38s ease-in-out infinite alternate; }
/* Живая картина рисуется шейдером поверх той же раскладки; сама картинка остаётся мерилом для искр. */
.menu-live { display: none; }
.backdrop.live .menu-live { display: block; }
.backdrop.live .menu-art { visibility: hidden; }
/* Слева темнее: меню читается на любом месте картины. */
.menu-screen::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgb(4 6 7 / 0.78) 0%, rgb(4 6 7 / 0.35) 34%, transparent 58%), linear-gradient(0deg, rgb(4 6 7 / 0.45), transparent 30%); }
.menu-list { position: absolute; left: 6vw; top: 24vh; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.menu-item { position: relative; isolation: isolate; background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0.55em 3.4em 0.55em 0.9em;
  color: #ece9e2; font: 500 clamp(15px, 1.05vw, 24px)/1.2 var(--ui-font); letter-spacing: 0.16em; text-transform: uppercase; text-align: left;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.7); cursor: pointer; transition: color 0.25s; }
.menu-item::before { content: ""; position: absolute; inset: 0 -12% 0 -3%; z-index: -1; background: url("models/ui/brush.svg") center / 100% 100% no-repeat;
  transform: scaleX(0); transform-origin: left center; transition: transform 0.38s cubic-bezier(0.3, 0.7, 0.2, 1); }
.menu-item:hover::before, .menu-item:focus::before { transform: scaleX(1); }
.menu-item:hover, .menu-item:focus { color: #15181a; text-shadow: none; outline: none; }
#menu-continue:not([hidden]), #menu-load:not([hidden]) { animation: menu-item-in 0.5s ease-out; }
@keyframes menu-item-in { from { opacity: 0; transform: translateX(-0.6rem); } }
.menu-item small { display: block; margin-top: 0.25em; font-size: 0.62em; letter-spacing: 0.03em; text-transform: none; opacity: 0.8; }
@keyframes menu-drift { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.04) translate(-1%, -0.5%); } }
@media (prefers-reduced-motion: reduce) { .menu-art, .menu-live { animation: none; } .menu-item::before { transition: none; } }
@media (max-aspect-ratio: 1/1) {
  .menu-list { left: 7vw; top: 14vh; }
  /* Узкий экран: картина сдвинута к костру. */
  .menu-art, .menu-live { object-position: 92% 50%; }
}
/* Настройки как в играх: вкладки сверху, слева пункт и значение, справа — что он делает. Из главного меню — поверх его
   картины (пункты меню уходят), с других экранов — окном на весь экран поверх размытой игры. */
.menu-list { transition: opacity 0.3s, transform 0.3s; }
.menu-screen.panel-open .menu-list { opacity: 0; transform: translateX(-2rem); pointer-events: none; }
dialog.options { position: fixed; inset: 0; z-index: 6; width: auto; height: auto; max-width: none; max-height: none; margin: 0;
  padding: 4vh 5vw 3vh; border-radius: 0; color: #ece9e2; font-family: var(--ui-font);
  background: linear-gradient(90deg, rgb(5 7 9 / 0.86), rgb(5 7 9 / 0.6)); }
dialog.options[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; gap: 3.5vh; animation: settings-in 0.35s ease-out; }
dialog.options::backdrop { background: rgb(5 7 9 / 0.55); backdrop-filter: blur(8px); }
.options-head { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.options-gear { font-size: clamp(28px, 2.4vw, 44px); line-height: 1; color: #ece9e2; }
.options-head h2 { margin: 0; padding-right: 1.6rem; border-right: 1px solid rgb(255 255 255 / 0.22);
  font: 600 clamp(18px, 1.5vw, 28px)/1.2 var(--ui-font); letter-spacing: 0.1em; text-transform: uppercase; }
.options-tabs { display: flex; gap: 0.4rem 1.8rem; flex-wrap: wrap; }
.options-tabs [role="tab"] { position: relative; padding: 0.4em 0; background: none; border: 0; border-radius: 0; box-shadow: none;
  color: rgb(236 233 226 / 0.55); font: 500 clamp(14px, 1vw, 19px)/1.2 var(--ui-font); letter-spacing: 0.05em; cursor: pointer; }
.options-tabs [role="tab"]:hover { color: #ece9e2; }
.options-tabs [aria-selected="true"] { color: #fff; font-weight: 700; }
.options-tabs [aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -0.25em; height: 2px; background: #e39a3b; }
.options-tabs [role="tab"][hidden] { display: none; }
.options-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 4vw; min-height: 0; }
.options-list { overflow: hidden auto; align-self: start; max-height: 100%; padding-right: 0.4rem; }
.option { position: relative; isolation: isolate; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
  padding: 0.95em 1.1em; border-bottom: 1px solid rgb(255 255 255 / 0.12); cursor: pointer; outline: none;
  font-size: clamp(14px, 1.05vw, 20px); }
.option[hidden], .option.off-tab { display: none; }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.option b { font-weight: 500; }
.option .about { display: none; }
.option .value { font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: rgb(236 233 226 / 0.6); }
.option .value:empty::before { content: "Выкл"; }
.option:has(input:checked) .value::before { content: "Вкл"; }
.option:has(input:checked) .value { color: #f3b25c; }
.option:has(input:disabled) { opacity: 0.45; cursor: default; }
.option.option-pick .value, #install .value, .save-row .value { display: flex; align-items: center; gap: 0.7em; color: #ece9e2; }
.option .step { padding: 0 0.2em; background: none; border: 0; box-shadow: none; color: inherit; font-size: 0.8em; cursor: pointer; visibility: hidden; }
.option.active .step { visibility: visible; }
/* Выбранный пункт — светлее и с огненной чертой слева; мазок кисти — только в главном меню. */
.option { border-radius: 6px; transition: background-color 0.2s, box-shadow 0.2s; }
.option.active { background: rgb(255 255 255 / 0.1); box-shadow: inset 3px 0 0 #e39a3b; }
.options .option.active b { color: #fff; }
.options-info { align-self: start; display: grid; gap: 1rem; padding: 1.6rem 1.8rem; border-radius: 6px;
  background: rgb(18 26 31 / 0.82); border: 1px solid rgb(255 255 255 / 0.08); box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
.options-info h3 { margin: 0; font: 800 clamp(15px, 1.2vw, 23px)/1.25 var(--ui-font); letter-spacing: 0.06em; text-transform: uppercase; }
.options-info p { margin: 0; line-height: 1.55; color: rgb(236 233 226 / 0.82); font-size: clamp(14px, 0.95vw, 18px); }
.options-info .options-note { color: #f3b25c; font-size: clamp(12px, 0.8vw, 15px); }
.info-look { height: min(38vh, 22rem); border-radius: 6px; background: radial-gradient(circle at 50% 40%, #2a3d3a, #101a19); }
.info-look[hidden] { display: none; }
.options-keys { display: flex; align-items: center; gap: 2.2rem; font-size: clamp(13px, 0.9vw, 17px); }
.options-keys .key { display: inline-flex; align-items: center; gap: 0.5em; color: #ece9e2; }
.options-keys button.key { padding: 0; background: none; border: 0; box-shadow: none; font: inherit; cursor: pointer; }
.options-keys kbd { padding: 0.1em 0.5em; border-radius: 4px; background: rgb(236 233 226 / 0.9); color: #111; font: 700 0.85em/1.3 var(--ui-font); }
/* Загрузка игры: строка — мир и игроки, справа — сколько сыграно. */
.save-row { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid rgb(255 255 255 / 0.12); box-shadow: none; color: #ece9e2; font: inherit; font-size: clamp(14px, 1.05vw, 20px); }
.save-row b small { display: block; margin-top: 0.2em; font-weight: 400; font-size: 0.8em; color: rgb(236 233 226 / 0.6); }
.save-row .value { font-weight: 600; letter-spacing: 0.04em; text-transform: none; }
.save-bar { display: grid; gap: 0.4rem; }
.save-bar span { display: block; height: 0.9rem; border-radius: 2px; background: rgb(255 255 255 / 0.18) linear-gradient(90deg, #e39a3b, #f3b25c) no-repeat; background-size: var(--done, 0%) 100%; }
.save-bar small { color: rgb(236 233 226 / 0.7); font-size: clamp(12px, 0.85vw, 16px); }
.options-info .primary { justify-self: start; background: #e39a3b; border-color: #e39a3b; color: #15181a; box-shadow: none; }
.options-info .primary:hover { background: #f3b25c; }
.options-head h2:last-child { border-right: 0; }
.options-list { scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 0.25) transparent; }
@keyframes settings-in { from { opacity: 0; transform: translateX(-1.5rem); } }
@media (prefers-reduced-motion: reduce) { dialog.options[open] { animation: none; } .menu-list, .option { transition: none; } }
@media (pointer: coarse) { .options-keys span.key { display: none; } }
@media (max-aspect-ratio: 1/1) {
  dialog.options { padding: 3vh 5vw; }
  .options-head { gap: 0.6rem 1rem; }
  .options-head h2 { border-right: 0; }
  .options-tabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .options-tabs [role="tab"] { white-space: nowrap; }
  .options-body { grid-template-columns: 1fr; grid-template-rows: auto auto; overflow: auto; }
  .options-list { max-height: none; overflow: visible; }
  .info-look { height: 30vh; }
}
.saves { display: grid; gap: 0.5rem; max-height: 60vh; overflow: auto; }
.save { display: grid; gap: 0.15rem; text-align: left; padding: 0.7rem 0.9rem; background: rgb(255 255 255 / 0.45); color: var(--ink); border: 1px solid var(--paper-edge); box-shadow: none; }
.save:hover, .save:focus-visible { background: #fff; border-color: var(--brass); }
.save b { font-family: var(--story-font); font-size: 1.05em; }
.save span { font-size: 0.85em; opacity: 0.8; }

/* Магический переход между экранами (transitions.js): копия прежнего экрана и холст эффекта поверх всего. */
.screen-ghost { position: fixed; margin: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.screen-transition { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

/* Отряд на 3D-месте: портреты героев в углу, досье по нажатию (вариант A, выбор Романа). */
.party, .dossier { display: none; }
#game.with-place .party { display: grid; gap: 0.6rem; position: fixed; z-index: 4; left: max(0.75rem, calc(50vw - 44rem)); top: calc(var(--scene-h, 4.5rem) + 0.4rem); }
.party-hero, .dossier { background: rgb(8 12 14 / 0.78); backdrop-filter: blur(10px); border: 1px solid rgb(255 255 255 / 0.1); box-shadow: 0 14px 40px rgb(0 0 0 / 0.4); color: #ece9e2; }
.party-hero { display: grid; grid-template-columns: 3.6rem 9.5rem; gap: 0.7rem; align-items: center; padding: 0.45rem 0.8rem 0.45rem 0.45rem; border-radius: 2.4rem 0.8rem 0.8rem 2.4rem; text-align: left; font: inherit; cursor: pointer; transition: box-shadow 0.25s, opacity 0.25s; }
.party-hero:hover, .party-hero.open { border-color: rgb(255 255 255 / 0.3); }
.party-hero.now { box-shadow: 0 0 0 1px #e39a3b, 0 0 22px rgb(227 154 59 / 0.45), 0 14px 40px rgb(0 0 0 / 0.4); }
.party-hero.down { opacity: 0.5; }
.party-hero.away .party-face { filter: grayscale(0.8); }
.party-face, .dossier-face { display: grid; place-items: center; background: #101719 center / cover no-repeat; color: var(--seat); font: 700 1.4rem var(--story-font); }
.party-face { width: 3.6rem; height: 3.6rem; border-radius: 50%; box-shadow: 0 0 0 3px var(--seat); }
.party-hero.now .party-face { box-shadow: 0 0 0 3px var(--seat), 0 0 16px var(--seat); }
.party-text { display: grid; gap: 0.15rem; min-width: 0; }
.party-text b { font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.party-text small { color: rgb(236 233 226 / 0.62); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.party-tag { padding: 0.05rem 0.4rem; border-radius: 4px; background: #e39a3b; color: #15181a; font: 700 0.62rem/1.4 var(--ui-font); letter-spacing: 0.06em; text-transform: uppercase; }
.party-tag.ai { background: rgb(255 255 255 / 0.2); color: #ece9e2; }
.hp-bar { height: 0.35rem; border-radius: 3px; background: rgb(255 255 255 / 0.15); overflow: hidden; }
.hp-bar i { display: block; height: 100%; background: linear-gradient(90deg, #c8433a, #ef7a5a); transition: width 0.5s; }
#game.with-place .dossier:not([hidden]) { display: grid; gap: 0.7rem; position: fixed; z-index: 5; width: 19rem; max-height: calc(100dvh - var(--scene-h, 4.5rem) - var(--composer-h, 8rem) - 1rem); overflow-y: auto;
  left: calc(max(0.75rem, calc(50vw - 44rem)) + 15.6rem); top: calc(var(--scene-h, 4.5rem) + 0.4rem); padding: 1rem; border-radius: 0.9rem; animation: dossier-in 0.25s ease-out; scrollbar-width: thin; }
@keyframes dossier-in { from { opacity: 0; transform: translateX(-0.8rem); } }
.dossier-close { position: absolute; top: 0.6rem; right: 0.6rem; min-width: 2rem; min-height: 2rem; padding: 0; background: rgb(0 0 0 / 0.45); color: #ece9e2; border-color: rgb(255 255 255 / 0.2); z-index: 1; }
.dossier-head { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.8rem; align-items: center; padding-right: 2rem; }
.dossier-head > div { display: grid; gap: 0.45rem; }
.dossier-face { width: 6.5rem; height: 6.5rem; border-radius: 0.7rem; box-shadow: 0 0 0 2px var(--seat); font-size: 2.6rem; }
.dossier h3 { margin: 0; font: 700 1.3rem var(--story-font); display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.dossier h3 small { font: 400 0.85rem var(--ui-font); color: rgb(236 233 226 / 0.62); }
.dossier h4 { margin: 0.2rem 0 0; font: 600 0.72rem var(--ui-font); letter-spacing: 0.14em; text-transform: uppercase; color: rgb(236 233 226 / 0.55); }
.dossier-hp { display: grid; gap: 0.3rem; font-weight: 700; font-size: 0.9rem; }
.dossier h3 { padding-right: 0; }
.dossier-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.dossier-stat { display: grid; justify-items: center; padding: 0.35rem 0.2rem; border-radius: 0.5rem; background: rgb(255 255 255 / 0.07); }
.dossier-stat b { color: #f3b25c; font-size: 0.95rem; }
.dossier-stat small { color: rgb(236 233 226 / 0.6); font-size: 0.72rem; }
.dossier-about { margin: 0; font-size: 0.88rem; line-height: 1.45; color: rgb(236 233 226 / 0.82); }
.dossier-bag { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.dossier-item { display: grid; justify-items: center; gap: 0.2rem; padding: 0.45rem 0.2rem; border-radius: 0.5rem; background: rgb(255 255 255 / 0.07); text-align: center; }
.dossier-item b { font-size: 1.4rem; line-height: 1; }
.dossier-item small { font-size: 0.68rem; color: rgb(236 233 226 / 0.75); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { #game.with-place .dossier:not([hidden]) { animation: none; } }
/* Телефон: портреты без подписей рядком, досье — листом снизу. */
@media (max-width: 56rem) {
  #game.with-place .party { grid-auto-flow: column; gap: 0.45rem; left: 0.6rem; }
  .party-hero { grid-template-columns: 2.8rem; padding: 0.25rem; border-radius: 50%; }
  .party-face { width: 2.8rem; height: 2.8rem; font-size: 1.1rem; }
  .party-text { display: none; }
  #game.with-place .dossier:not([hidden]) { left: 0.5rem; right: 0.5rem; width: auto; top: auto; bottom: calc(var(--composer-h, 8rem) + 0.4rem); max-height: 60dvh; }
  #game.with-place .dossier:not([hidden]) { background: rgb(8 12 14 / 0.9); }
}

/* «Кто играет на этом экране?» — в стиле отряда: весь отряд крупно первым, ниже свои герои с портретами. */
dialog.who { width: min(34rem, calc(100vw - 1.5rem)); padding: 1.5rem; border-radius: 1.1rem; color: #ece9e2;
  background: rgb(8 12 14 / 0.9); border: 1px solid rgb(255 255 255 / 0.12); box-shadow: 0 24px 70px rgb(0 0 0 / 0.55); }
dialog.who::backdrop { background: rgb(5 7 9 / 0.5); backdrop-filter: blur(6px); }
.who h2 { margin: 0 0 0.4rem; font: 700 1.5rem var(--story-font); }
.who h3 { margin: 1.1rem 0 0.5rem; font: 600 0.72rem var(--ui-font); letter-spacing: 0.14em; text-transform: uppercase; color: rgb(236 233 226 / 0.55); }
.who-hint { margin: 0 0 1rem; color: rgb(236 233 226 / 0.7); font-size: 0.92rem; line-height: 1.45; }
.who-options button { font: inherit; color: inherit; cursor: pointer; }
.who-all { width: 100%; display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1rem; border-radius: 0.9rem; text-align: left;
  background: rgb(227 154 59 / 0.12); border: 1px solid rgb(227 154 59 / 0.6); box-shadow: 0 0 24px rgb(227 154 59 / 0.18); }
.who-all:hover, .who-all:focus-visible { background: rgb(227 154 59 / 0.22); outline: none; }
.who-all b { display: block; font-size: 1.1rem; }
.who-all small { color: rgb(236 233 226 / 0.65); }
.who-faces { display: flex; flex: none; }
.who-faces .who-face + .who-face { margin-left: -0.9rem; }
.who-face { width: 3rem; height: 3rem; border-radius: 50%; display: grid; place-items: center; background: #101719 center / cover no-repeat;
  box-shadow: 0 0 0 3px var(--seat), 0 0 0 4px rgb(8 12 14); color: var(--seat); font: 700 1.2rem var(--story-font); }
.who-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.6rem; }
.who-hero { display: grid; justify-items: center; gap: 0.25rem; padding: 0.8rem 0.5rem; border-radius: 0.8rem; background: rgb(255 255 255 / 0.06);
  border: 1px solid rgb(255 255 255 / 0.1); border-top: 3px solid var(--seat); }
.who-hero:hover, .who-hero:focus-visible { background: rgb(255 255 255 / 0.12); outline: none; }
.who-hero .who-face { width: 3.6rem; height: 3.6rem; margin-bottom: 0.2rem; }
.who-hero small { color: rgb(236 233 226 / 0.6); font-size: 0.8rem; }
.who-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.1rem; }
.who-link { background: none; border: 0; box-shadow: none; padding: 0.4rem 0; color: rgb(236 233 226 / 0.75) !important; text-decoration: underline; text-underline-offset: 3px; }
.who-link:hover { color: #fff !important; }

/* Ведущий думает: тёплое свечение у головы и искры, поднимающиеся вокруг фигуры. */
.mind-sparks { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s; }
.thinking > .mind-sparks { opacity: 1; }
.thinking { position: relative; }
#game-host.thinking::before, .intro-host.thinking::before { content: ""; position: absolute; left: 50%; top: 8%; width: 70%; aspect-ratio: 1; translate: -50% 0; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 190 110 / 0.35), rgb(255 120 40 / 0.12) 50%, transparent 70%); filter: blur(4px); animation: ember-breathe 2.2s ease-in-out infinite; pointer-events: none; }
.mind-sparks i { position: absolute; bottom: 35%; left: calc(18% + var(--i) * 5.5%); width: 5px; height: 5px; border-radius: 50%;
  background: #ffe0a8; box-shadow: 0 0 8px 3px rgb(255 150 60 / 0.75); opacity: 0;
  animation: mind-spark calc(2.2s + var(--i) * 0.13s) ease-out infinite; animation-delay: calc(var(--i) * -0.37s); }
@keyframes mind-spark {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc((var(--i) - 5.5) * 0.25rem), -7rem) scale(1.1); }
}
@media (prefers-reduced-motion: reduce) { .mind-sparks { display: none; } #game-host.thinking::before, .intro-host.thinking::before, .thinking-text { animation: none; } }

/* Ведущий готовит вступление: своя живая картина на весь экран, искры собираются в кольцо, под ним надпись. */
#starting { position: fixed; inset: 0; z-index: 5; overflow: hidden; display: grid; align-content: end; justify-items: center; gap: 0.6rem; padding: 0 1rem 16vh; text-align: center; background: #07090a; }
.prep-art { position: absolute; inset: -3%; width: 106%; height: 106%; object-fit: cover; animation: menu-drift 40s ease-in-out infinite alternate; }
.prep-live { opacity: 0; transition: opacity 2s ease; }
.prep-live.on { opacity: 1; }
#starting::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 42%, transparent 20%, rgb(5 7 9 / 0.45) 75%); }
.prep-fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.starting-title, .starting-hint { position: relative; z-index: 2; }
/* Проценты озвучки — в центре кольца искр (центр кольца в prep.js: 50 %, 42 %). */
.prep-percent {
  position: absolute; left: 50%; top: 42%; z-index: 2; transform: translate(-50%, -50%);
  font: 300 clamp(2rem, 5vw, 3.6rem)/1 var(--ui-font); font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
  color: #fff3dc; text-shadow: 0 0 18px rgb(255 170 80 / 0.75), 0 0 40px rgb(255 140 50 / 0.45);
  animation: phrase-in 0.6s ease-out both;
}
.prep-percent[hidden] { display: none; }
.starting-title { margin: 0; font: 700 clamp(1.6rem, 3vw, 2.6rem)/1.15 var(--story-font); filter: drop-shadow(0 2px 6px rgb(0 0 0 / 0.85)); }
.starting-hint { margin: 0; max-width: 32rem; color: rgb(236 233 226 / 0.75); text-shadow: 0 1px 6px rgb(0 0 0 / 0.85); }
@media (prefers-reduced-motion: reduce) { .prep-art { animation: none; } }

/* Мигающий курсор — только там, где пишут: в остальном тексте его нет, даже если браузер включил навигацию курсором. */
body { caret-color: transparent; }
input, textarea, [contenteditable="true"] { caret-color: auto; }
/* На экранах без ввода текст не выделяется: это картинка, а не документ. */
#menu, #mode, #world, #starting, #intro, .subtitle, .party, .dossier { -webkit-user-select: none; user-select: none; cursor: default; }


/* Экран места, современный вид (Роман): кнопки шапки — стекло без рамок, надписи — шрифт интерфейса,
   ход — полупрозрачный чип по центру, кнопки хода — тоже стекло. */
#game.with-place .scene { background: linear-gradient(rgb(6 10 12 / 0.55), transparent); }
#game.with-place .scene-place { font-size: 1.3rem; letter-spacing: 0.01em; text-shadow: 0 2px 10px rgb(0 0 0 / 0.7); }
#game.with-place .scene-tools { gap: 0.35rem; align-items: center; }
#game.with-place .scene-tools button,
#game.with-place #composer button.quiet,
#game.with-place #composer .mic:not(.listening) {
  border: 0; border-radius: 999px; min-height: 2.2rem; padding: 0.35rem 0.95rem;
  background: rgb(12 18 20 / 0.42); color: #f2eee6; font: 500 0.85rem/1.2 var(--ui-font); letter-spacing: 0.01em;
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07), 0 4px 14px rgb(0 0 0 / 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
#game.with-place .scene-tools button:hover:not(:disabled),
#game.with-place #composer button.quiet:hover:not(:disabled),
#game.with-place #composer .mic:hover:not(:disabled):not(.listening) {
  background: rgb(22 30 34 / 0.66); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16), 0 6px 18px rgb(0 0 0 / 0.3);
}
#game.with-place .scene-tools button:active:not(:disabled) { transform: scale(0.97); }
#game.with-place .scene-tools button:disabled { opacity: 0.45; }
#game.with-place .scene-tools .gear { width: 2.2rem; padding: 0; font-size: 1rem; }
#game.with-place .clock { padding: 0 0.3rem; color: rgb(242 238 230 / 0.7); font: 500 0.8rem var(--ui-font); }
#game.with-place #composer .mic:not(.listening) { min-height: 2.8rem; padding-inline: 1.6rem; font-size: 1rem; }
#game.with-place #composer .type-instead { min-height: 0; padding: 0.2rem 0.8rem; font-size: 0.78rem; opacity: 0.8; }
/* Чей ход и что сейчас: чип по центру над кнопкой хода. */
#game.with-place .turn-row { justify-content: center; }
#game.with-place .turn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.95rem 0.35rem 0.75rem; border-radius: 999px;
  background: rgb(12 18 20 / 0.42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07);
  color: #f2eee6; font: 500 0.88rem/1.2 var(--ui-font); letter-spacing: 0.01em; text-shadow: none;
}
#game.with-place .turn::before {
  margin: 0; width: 0.55rem; height: 0.55rem; flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat, var(--brass)) 30%, transparent), 0 0 10px var(--seat, var(--brass));
}
/* «Ведущий думает…» сверху — тот же чип, мягче. */
#game.with-place #live .gm.waiting .gm-card, #game.with-place #subtitle .phrase.thinking {
  padding: 0.35rem 1rem; border-radius: 999px; background: rgb(12 18 20 / 0.4);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07);
  font: italic 500 0.95rem/1.3 var(--story-font); text-shadow: none; filter: none;
}

/* История партии в том же стиле (Роман): тёмное стекло справа, рассказ ведущего — светлым текстом без «бумаги»,
   слова игрока — пузырём с точкой его цвета, бросок и оценки — некрупно. */
#game.with-place.show-history #feed {
  width: min(32rem, 96vw); padding: 0 1.1rem 2rem; gap: 0.8rem;
  background: linear-gradient(180deg, rgb(10 16 18 / 0.82), rgb(8 12 14 / 0.9));
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-radius: 18px 0 0 18px; box-shadow: -18px 0 40px rgb(0 0 0 / 0.45), inset 1px 0 0 rgb(255 255 255 / 0.06);
  scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 0.18) transparent;
}
#game.with-place.show-history .feed-head {
  padding: 1rem 0 0.7rem; background: linear-gradient(rgb(10 16 18 / 0.96) 70%, transparent);
  font: 600 1.05rem/1.2 var(--ui-font); letter-spacing: 0.04em; text-transform: uppercase; color: rgb(242 238 230 / 0.85);
}
#game.with-place.show-history .feed-head button {
  border: 0; border-radius: 999px; min-height: 2rem; padding: 0.25rem 0.85rem; background: rgb(255 255 255 / 0.08);
  color: #f2eee6; font: 500 0.82rem var(--ui-font); text-transform: none; letter-spacing: 0;
}
#game.with-place.show-history #feed .owl { display: none; }
#game.with-place.show-history #feed .gm { grid-template-columns: 1fr; gap: 0.35rem; }
#game.with-place.show-history #feed .gm-card {
  max-width: none; padding: 0.75rem 0.95rem 0.8rem; border-radius: 14px;
  background: rgb(255 255 255 / 0.045); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
  color: #ece7dc; font: 400 1.02rem/1.6 var(--story-font);
}
#game.with-place.show-history #feed .gm-notes { border-top-color: rgb(255 255 255 / 0.1); color: rgb(236 231 220 / 0.6); }
#game.with-place.show-history #feed .said {
  max-width: 85%; border: 0; border-radius: 14px 14px 4px 14px; padding: 0.5rem 0.85rem;
  background: color-mix(in srgb, var(--seat, var(--brass)) 16%, rgb(255 255 255 / 0.04));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--seat, var(--brass)) 35%, transparent);
  color: #f2eee6; font: 400 0.95rem/1.45 var(--ui-font);
}
#game.with-place.show-history #feed .said b { display: flex; align-items: center; gap: 0.4rem; color: rgb(242 238 230 / 0.7); font: 600 0.78rem var(--ui-font); letter-spacing: 0.03em; }
#game.with-place.show-history #feed .said b::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--seat, var(--brass)); box-shadow: 0 0 6px var(--seat, var(--brass)); }
#game.with-place.show-history #feed .roll {
  justify-self: stretch; padding: 0.5rem 0.8rem; border-radius: 14px; background: rgb(255 255 255 / 0.035);
  font: 0.88rem/1.4 var(--ui-font); color: rgb(242 238 230 / 0.85);
}
#game.with-place.show-history #feed .roll .die { width: 2.4rem; height: 2.4rem; }
#game.with-place.show-history #feed .rate { grid-column: 1; margin-top: 0; color: rgb(242 238 230 / 0.5); }
#game.with-place.show-history #feed .rate button.rate-mark { border: 0; background: transparent; }
#game.with-place.show-history #feed .notice, #game.with-place.show-history #feed .tip { color: rgb(242 238 230 / 0.6); font: 0.85rem/1.4 var(--ui-font); }
#game.with-place.show-history #feed .tip button {
  border: 0; border-radius: 999px; background: rgb(255 255 255 / 0.08); color: #f2eee6; font: 500 0.82rem var(--ui-font);
}

/* Вход, очередь и оплата — в стиле окна «Кто играет». */
.account-dialog form { display: grid; gap: 0.8rem; }
.account-dialog label { color: rgb(236 233 226 / 0.75); }
.account-dialog input[type="email"], .account-dialog input[type="password"] { width: 100%; min-height: 2.9rem; padding: 0.6rem 0.7rem;
  border-radius: 8px; border: 1px solid rgb(255 255 255 / 0.2); background: rgb(255 255 255 / 0.08); color: #ece9e2; }
.account-dialog .tick { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.88rem; }
.account-dialog .notice { margin: 0; }
.account-dialog button.quiet { color: #ece9e2; border-color: rgb(255 255 255 / 0.25); }
.queue-position { font: 700 1.3rem var(--story-font); margin: 0.4rem 0; }
.account { position: absolute; left: 6vw; bottom: 5vh; z-index: 3; display: flex; align-items: center; gap: 1rem; margin: 0;
  color: rgb(236 233 226 / 0.75); font-size: 0.9rem; text-shadow: 0 1px 3px rgb(0 0 0 / 0.7); }
.account a { color: inherit; }
.menu-screen.panel-open .account { opacity: 0; pointer-events: none; }
