/* Оверлеи: ордер на обвинение, итог дела, настройки. */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 6, 4, 0.72);
  animation: fade 0.18s ease-out;
}

.overlay[hidden] {
  display: none;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  width: min(640px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  color: var(--ink);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.sheet__title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}

.sheet__sub {
  margin: 0 0 14px;
  text-align: center;
  font-size: 16px;
  color: var(--ink-soft);
  border-bottom: 3px double var(--ink);
  padding-bottom: 12px;
}

.sheet__actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sheet__actions .btn {
  flex: 1 1 0;
}

/* Кнопки внизу листа всегда на виду: длинный лист (вердикт дела на десять
   человек, вступление на низком телефоне) прокручивается под ними, и игрок
   не принимает конец экрана за конец игры. */
.sheet .sheet__actions:last-child {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 16px -18px -18px;
  padding: 10px 18px 18px;
  background: var(--paper);
  box-shadow: 0 -10px 12px -10px var(--shadow);
}

/* ── Ордер: строки «кто — где — чем — почему» ─────────────────────── */

.warrant {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.warrant__row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(43, 33, 24, 0.3);
  background: rgba(43, 33, 24, 0.04);
}

.warrant__photo {
  width: 44px;
  height: 54px;
  background: var(--photo);
  overflow: hidden;
  box-shadow: 0 2px 5px var(--shadow);
}

.warrant__photo svg,
.warrant__photo img {
  display: block;
  width: 100%;
  height: 100%;
}

.warrant__who {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.warrant__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.warrant__field {
  flex: 1 1 180px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.warrant__label {
  font-size: 16px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.warrant__select {
  font-family: var(--font-mono);
  font-size: 16px;
  min-height: 44px;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  width: 100%;
}

.warrant__select[data-empty='true'] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.warrant__note {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--accent);
  min-height: 1.4em;
}

/* ── Штамп ────────────────────────────────────────────────────────── */

.verdict {
  text-align: center;
}

.stamp {
  display: inline-block;
  margin: 14px auto 20px;
  padding: 10px 22px;
  max-width: 100%;
  border: 6px solid currentColor;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(24px, 5.6vw, 40px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  filter: url(#stamp-wear);
  transform: rotate(-8deg);
  animation: slam 0.42s cubic-bezier(0.18, 1.3, 0.4, 1) both;
}

.stamp--blue {
  color: var(--stamp-blue);
}

@keyframes slam {
  0% {
    opacity: 0;
    transform: rotate(-26deg) scale(3.2);
  }
  62% {
    opacity: 1;
    transform: rotate(-5deg) scale(0.92);
  }
  80% {
    transform: rotate(-9deg) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: rotate(-8deg) scale(1);
  }
}

.verdict__body {
  animation: fade 0.3s 0.35s ease-out both;
}

.verdict__list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
}

.verdict__list li {
  border-bottom: 1px dotted var(--ink-faded);
  padding: 4px 0;
}

.verdict__list b {
  font-family: var(--font-serif);
}

/* ── Настройки ────────────────────────────────────────────────────── */

.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px dotted var(--ink-faded);
  font-size: 17px;
}

.opt > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Ширина по подписи, а не фиксированная: «СМЕНИТЬ» и Sound effects длиннее
   «ВКЛ», и на жёстких 74 px подпись обрезалась. */
.opt__switch {
  flex: 0 0 auto;
  min-width: 74px;
  min-height: 44px;
  padding: 0 12px;
  white-space: nowrap;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: 0.08em;
  border-radius: var(--radius);
}

.opt__switch[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}

/* Тост поверх экрана — для коротких сообщений вроде «сетка очищена». */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 60;
  width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--paper);
  color: var(--ink);
  padding: 10px 16px;
  font-size: 16px;
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
  animation: fade 0.2s ease-out;
  max-width: 100%;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

/* ── Выбор обвиняемого ────────────────────────────────────────────── */

/* Лист обвинения шире обычного: в карточке имя не рвётся посреди слова,
   и при более широком листе в ряд помещается больше карточек. */
.sheet:has(.suspects) {
  width: min(880px, 100%);
}

/* Колонка не уже самого длинного слова имени (--word, в символах; ставит
   accuse.js) плюс портрет, отступы и рамка карточки (68 px) и 2 px на округление. */
.suspects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--word) * 1ch + 70px)), 1fr));
  gap: 10px;
  font-size: 16px;
}

.suspects__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  min-height: 60px;
}

.suspects__photo {
  flex: 0 0 auto;
  width: 40px;
  height: 48px;
  background: var(--photo);
  overflow: hidden;
  position: relative;
}

.suspects__photo svg,
.suspects__photo img {
  display: block;
  width: 100%;
  height: 100%;
}

.suspects__photo img {
  position: absolute;
  inset: 0;
  object-fit: cover;
}

.suspects__name {
  font-size: 16px;
  line-height: 1.2;
}

/* Телефон: карточек в ряду одна-две, поэтому портрет и отступы меньше,
   чтобы весь список помещался без прокрутки листа. */
@media (max-width: 600px) {
  .suspects {
    gap: 6px;
  }

  .suspects__item {
    min-height: 48px;
    padding: 3px 8px;
  }

  .suspects__photo {
    width: 34px;
    height: 40px;
  }
}

.verdict__list li[data-killer='true'] {
  color: var(--accent);
  font-weight: 700;
}

/* ── Обучающая записка ────────────────────────────────────────────── */

/* Затемнение с окнами на то, о чём говорит шаг обучения. Тапы проходят
   насквозь: игрок делает ход прямо в подсвеченном месте. */
.coach-dim {
  position: absolute;
  inset: 0;
  z-index: 39;
  width: 100%;
  height: 100%;
  pointer-events: none;
  animation: fade 0.25s ease-out;
}

.coach-dim__shade {
  fill: rgba(8, 6, 4, 0.74);
}

.coach-dim__glow {
  fill: none;
  stroke: var(--lamp);
  stroke-width: 9;
  stroke-opacity: 0.45;
}

.coach-dim__ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  animation: coach-ring 1.4s ease-in-out infinite;
}

@keyframes coach-ring {
  50% {
    stroke-width: 6;
  }
}

.coach {
  position: absolute;
  z-index: 41;
  width: max-content;
  max-width: min(400px, calc(100% - 16px));
  padding: 14px 16px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow:
    0 0 0 3px var(--lamp),
    0 14px 34px rgba(0, 0, 0, 0.6);
  animation: coach-in 0.22s ease-out;
}

.coach__text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.4;
}

.coach__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.coach__ok {
  min-width: 132px;
  font-weight: 700;
  box-shadow: none;
}

/* Стрелка: тёмный треугольник с бумажной сердцевиной, остриём к цели. */
.coach:not([data-side='top'])::before,
.coach:not([data-side='top'])::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border: solid transparent;
}

.coach::before {
  border-width: 16px;
}

.coach::after {
  border-width: 11px;
}

.coach[data-side='below']::before,
.coach[data-side='above']::before {
  left: calc(var(--arrow, 30px) - 16px);
}

.coach[data-side='below']::after,
.coach[data-side='above']::after {
  left: calc(var(--arrow, 30px) - 11px);
}

.coach[data-side='below']::before {
  bottom: 100%;
  border-bottom-color: var(--ink);
}

.coach[data-side='below']::after {
  bottom: calc(100% - 1px);
  border-bottom-color: var(--paper);
}

.coach[data-side='above']::before {
  top: 100%;
  border-top-color: var(--ink);
}

.coach[data-side='above']::after {
  top: calc(100% - 1px);
  border-top-color: var(--paper);
}

.coach[data-side='right']::before,
.coach[data-side='left']::before {
  top: calc(var(--arrow, 30px) - 16px);
}

.coach[data-side='right']::after,
.coach[data-side='left']::after {
  top: calc(var(--arrow, 30px) - 11px);
}

.coach[data-side='right']::before {
  right: 100%;
  border-right-color: var(--ink);
}

.coach[data-side='right']::after {
  right: calc(100% - 1px);
  border-right-color: var(--paper);
}

.coach[data-side='left']::before {
  left: 100%;
  border-left-color: var(--ink);
}

.coach[data-side='left']::after {
  left: calc(100% - 1px);
  border-left-color: var(--paper);
}

@keyframes coach-in {
  from {
    opacity: 0;
  }
}

/* ── Вступление к первому делу ───────────────────────────────────── */

.intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.intro__art {
  margin: -18px -18px 0;
  aspect-ratio: 1200 / 686;
  max-height: clamp(140px, 30dvh, 320px);
  overflow: hidden;
  border-bottom: 3px double var(--ink);
}

.intro__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 70%;
}

.intro__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 3px double var(--ink);
}

.intro__app {
  margin: 0 0 4px;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.intro__title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.15;
}

/* Штамп «дело №» — рамка красными чернилами, чуть под углом. */
.intro__stamp {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 3px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-align: center;
  white-space: pre-line;
  transform: rotate(-4deg);
}

.intro__text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.45;
}

.intro__text--note {
  font-size: 18px;
  color: var(--ink-soft);
}

.intro .btn {
  min-height: 54px;
  font-size: 18px;
}

/* Цель дела в шапке привлекает внимание, пока игрок её не прочитал. */
.hdr__task[data-fresh='true'] {
  animation: task-pulse 1.1s ease-in-out 3;
}

@keyframes task-pulse {
  50% {
    color: var(--accent);
  }
}

/* Пауза от площадки: во время рекламы и сворачивания ввод не проходит. */
.app[data-paused='true'] {
  pointer-events: none;
}

/* ── Опрос за ролик или монеты ──────────────────────────────────── */

.ask__note {
  margin: 0;
  font-size: 17px;
  text-align: center;
}

.ask__actions .btn {
  margin-left: 0;
  white-space: normal;
}

.ask__actions .btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.ask__cancel {
  margin-top: 10px;
}

/* Лавка из листа опроса — скромно, без тени и цвета главной кнопки. */
.ask__shop {
  margin-top: 10px;
  box-shadow: none;
  white-space: normal;
}

/* ── Награда на экране итогов ─────────────────────────────────────── */

.reward {
  margin: 12px 0;
  padding: 10px 12px;
  border: 3px double var(--ink);
  text-align: center;
}

.reward__line {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 20px;
}

.reward__coins {
  color: var(--stamp-blue);
}

.reward__rank {
  margin-top: 4px;
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.reward .btn {
  margin-top: 10px;
}

.reward__note {
  margin: 6px 0 0;
  font-size: 16px;
  color: var(--ink-soft);
}
