/* Стили страницы «Мои рекорды» и страниц игр.
   Цвета — только из токенов css/style.css, поэтому обе темы работают сами. */

/* ---------- Заголовок страницы ---------- */

.page-title { font-size: clamp(1.9rem, 5vw, 2.6rem); margin-bottom: 6px; }
.page-lead { color: var(--ink-muted); font-style: italic; margin-bottom: 26px; }

/* ---------- Таблица рекордов ---------- */

.records { width: 100%; border-collapse: collapse; }

.records th,
.records td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px dashed var(--border);
}

.records th {
  font-family: var(--font-head);
  font-weight: 400;
  color: var(--ink-muted);
  border-bottom: 2px solid var(--border);
}

.records tr:last-child td { border-bottom: 0; }
.records td.num, .records th.num { text-align: right; font-variant-numeric: tabular-nums; }
.records a { font-weight: 700; }

@media (max-width: 560px) {
  .records thead { display: none; }
  .records, .records tbody, .records tr, .records td { display: block; }
  .records tr { padding: 10px 0; border-bottom: 1px dashed var(--border); }
  .records tr:last-child { border-bottom: 0; }
  .records td { padding: 2px 0; border: 0; text-align: left !important; }
  .records td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--ink-muted);
  }
}

/* ---------- Достижения ---------- */

.ach-group + .ach-group { margin-top: 24px; }
.ach-group-title { font-size: 1.2rem; margin-bottom: 12px; }

.ach-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.ach {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 2px 12px;
  align-items: center;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--ink-muted);
}

/* медаль */
.ach::before {
  content: "";
  grid-row: 1 / span 3;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px dashed var(--border);
}

.ach-title { font-family: var(--font-head); font-size: 1.05rem; line-height: 1.2; }
.ach-desc { font-size: 0.88rem; line-height: 1.35; }
.ach-state { font-size: 0.8rem; font-style: italic; }

.ach.is-unlocked {
  border: 1px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  color: var(--ink);
}

.ach.is-unlocked::before {
  border: 3px double var(--paper-2);
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--gold);
}

.ach.is-unlocked .ach-state { color: var(--green); font-style: normal; font-weight: 700; }

/* ---------- Сводка и сброс ---------- */

.summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 26px; }

.summary-item {
  flex: 1 1 150px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--paper-2);
  text-align: center;
}

.summary-value { display: block; font-family: var(--font-head); font-size: 1.9rem; color: var(--accent); line-height: 1.1; }
.summary-label { color: var(--ink-muted); font-size: 0.9rem; }

.reset-row { margin-top: 30px; text-align: center; }

dialog.confirm {
  max-width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: var(--font-body);
}

dialog.confirm::backdrop { background: rgba(20, 12, 4, 0.55); }
dialog.confirm h2 { font-size: 1.4rem; margin-bottom: 10px; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Страница игры ---------- */

.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 14px;
}

.game-top h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-right: auto; }
.game-back { font-weight: 700; text-decoration: none; }
.game-controls { display: flex; flex-wrap: wrap; gap: 8px; }

.game-frame {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 8px;
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.game-frame canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  border: 1px solid var(--gold);
  border-radius: calc(var(--radius) - 6px);
  background: #bfe6ff;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
/* телефон: без серо-синей вспышки браузера при каждом касании игры и без меню «сохранить картинку» при долгом нажатии */
.game-frame, .game-frame * {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* ---------- Полный экран ----------
   Класс is-fullscreen ставит js/game-page.js: и при настоящем полноэкранном
   режиме, и при запасном (растягивание окна) — например, на iPhone. */

/* ---------- Афиша: живая обложка до начала игры ---------- */

.game-poster {
  position: absolute;
  inset: 8px;
  z-index: 2;
  overflow: hidden;
  border-radius: calc(var(--radius) - 6px);
  cursor: pointer;
  background: #bfe6ff;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.game-poster .live-art,
.game-poster img {
  display: block;
  width: 100%;
  height: 100%;
}

.game-poster img { object-fit: cover; object-position: 50% 100%; }

.game-poster-title {
  position: absolute;
  left: 5%;
  top: 7%;
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 4.6vw, 3.2rem);
  line-height: 1.05;
  color: #1c2a4a;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.95), 0 0 4px rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.game-poster-modes {
  position: absolute;
  left: 5%;
  right: 5%;            /* четыре кнопки: на узком экране переносятся во второй ряд, а не уходят за край */
  bottom: 9%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.game-poster-extra { display: flex; flex-wrap: wrap; gap: 6px; }
.game-poster-extra .btn-ghost {
  background: rgba(255, 255, 255, 0.9);
  color: #1c2a4a;   /* на картинке — всегда тёмный текст, и в тёмной теме */
  border-color: rgba(28, 42, 74, 0.18);
}
/* «🔊 Включить звук» — если игру открыли сразу с главной, а браузер ещё не разрешил звук */
.sound-chip {
  position: absolute; left: 12px; bottom: 40px;   /* слева внизу: сверху — реплики, по центру внизу — кнопки игр */
  z-index: 5;
  padding: 8px 18px; border-radius: 999px; border: 2px solid #9e2216;
  background: #d2372a; color: #fff; font: inherit; font-weight: 800; font-size: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); cursor: pointer;
  animation: sound-chip-pulse 1.4s ease-in-out infinite;
}
.sound-chip[hidden] { display: none; }
@keyframes sound-chip-pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .sound-chip { animation: none; } }

/* режим, выбранный на главной: его и запустит нажатие на афишу */
.game-poster-extra .btn-ghost.is-preset { background: var(--accent); color: #fff; border-color: var(--accent); }

.game-poster.is-leaving { opacity: 0; transform: scale(1.02); pointer-events: none; }

.game-frame.is-fullscreen .game-poster { inset: 0; border-radius: 0; }

@media (max-width: 760px) {
  .game-poster { inset: 4px; }
  .game-poster-modes { bottom: 6%; gap: 5px; }
  .game-poster-extra { gap: 4px; }
  .game-poster-extra .btn { font-size: 0.72rem; padding: 0.3em 0.7em; min-height: 0; }
}
@media (max-width: 420px) {
  .game-poster-modes { left: 3%; right: 3%; bottom: 4%; }
  .game-poster-extra .btn { font-size: 0.68rem; padding: 0.28em 0.55em; }
}


/* круглая кнопка «на весь экран / свернуть» в правом верхнем углу игры (класс fs-exit — исторический) */
.fs-exit {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(20, 14, 6, 0.45);
  color: #fff;
  cursor: pointer;
}
.fs-exit:hover { background: rgba(20, 14, 6, 0.7); }
@media (max-width: 760px) {
  .fs-exit { top: 10px; right: 10px; width: 38px; height: 38px; }
}

.game-frame.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  max-width: none;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: #0b1020;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-frame.is-fullscreen canvas {
  width: min(100vw, 200vh);
  width: min(100vw, 200dvh);
  height: auto;
  border: 0;
  border-radius: 0;
}

/* iPhone: вырез экрана и полоска «домой» — игра внутри безопасной области, фон — до самых краёв */
@supports (padding: env(safe-area-inset-top)) {
  .game-frame.is-fullscreen {
    box-sizing: border-box;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .game-frame.is-fullscreen canvas {
    width: min(100%, calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 2));
  }
}

.game-frame.is-fullscreen .fs-exit { top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }

/* подсказка на iPhone: как открыть сказки без панели браузера */
.ios-home-hint {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 5;
  max-width: min(520px, 90%);
  padding: 10px 40px 10px 14px;
  border-radius: 14px;
  background: rgba(20, 14, 6, 0.82);
  color: #fff;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}
.ios-home-hint button {
  position: absolute;
  top: 6px;
  right: 8px;
  border: 0;
  background: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

body.has-pseudo-fullscreen { overflow: hidden; }

.voice-hint {
  max-width: 960px;
  margin: 10px auto 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
  font-style: italic;
  text-align: center;
}

.game-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 26px;
  align-items: start;
}

.game-info h2 { font-size: 1.35rem; margin-bottom: 10px; }
.howto-list { margin: 10px 0 0; padding-left: 20px; }
.howto-list li + li { margin-top: 4px; }
.game-best { margin-bottom: 12px; color: var(--ink-muted); }
.game-info .ach-grid { grid-template-columns: 1fr; gap: 8px; }
.game-info .ach { padding: 8px 10px; grid-template-columns: 30px 1fr; }
.game-info .ach::before { width: 30px; height: 30px; }
/* наклейка из альбома вместо кружка-медали */
.ach.has-sticker::before { display: none; }
.ach-sticker {
  grid-row: 1 / span 3; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18), 0 0 0 3px #fff; transform: rotate(var(--tilt, 0deg));
}
.ach-sticker svg { width: 38px; height: 38px; }
.ach:not(.is-unlocked) .ach-sticker {
  background: transparent; box-shadow: none; border: 2px dashed var(--border); transform: none;
  filter: grayscale(1); opacity: 0.35;
}
.game-info .ach.has-sticker { grid-template-columns: 40px 1fr; }

kbd {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--paper);
  font-family: inherit;
  font-size: 0.88em;
}

@media (max-width: 760px) {
  .game-info { grid-template-columns: 1fr; }
  .game-frame { padding: 4px; }
}

/* ---------- Уведомления о достижениях ---------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border: 1px solid var(--gold);
  border-left: 6px solid var(--gold);
  border-radius: 12px;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--shadow);
  animation: toast-in 0.35s ease;
}

.toast-kicker { font-size: 0.8rem; font-weight: 700; color: var(--green); letter-spacing: 0.5px; text-transform: uppercase; }
.toast-title { font-family: var(--font-head); font-size: 1.15rem; line-height: 1.2; }
.toast-desc { font-size: 0.9rem; color: var(--ink-muted); }
.toast.is-leaving { opacity: 0; transition: opacity 0.4s ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Кнопка «В меню» поверх игры — внизу справа, где у всех сказок только земля */
.game-menu-btn {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(20, 14, 6, 0.45);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.game-menu-btn:hover { background: rgba(20, 14, 6, 0.7); }
.game-menu-btn[hidden] { display: none; }

/* на сенсорных экранах клавиатуры нет — строку только про клавиши прячем */
@media (pointer: coarse) {
  .howto-list .keys-only { display: none; }
}

/* выбор уровня сложности на афише — под названием сказки */
.game-poster-levels {
  position: absolute;
  left: 5%;
  top: calc(7% + clamp(1.6rem, 4.6vw, 3.2rem) * 1.05 + 10px);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.level-chip {
  padding: 0.35em 0.9em;
  border: 1px solid rgba(28, 42, 74, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: #1c2a4a;
  font: 700 clamp(0.78rem, 1.7vw, 0.95rem) var(--font-body, inherit);
  cursor: pointer;
}
.level-chip:hover { background: #fff; }
.level-chip[aria-pressed="true"] { background: #d2372a; border-color: #9e2216; color: #fff; }

/* пауза поверх игры: продолжить, начать сначала, в меню, уровень */
.game-pause {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(20, 14, 6, 0.45);
  border-radius: inherit;
}
.game-pause[hidden] { display: none; }
.game-pause-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(320px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--paper, #fff8ea);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.game-pause-title { margin: 0 0 4px; font-family: var(--font-head); font-size: 1.5rem; color: var(--ink); }
.game-pause-levels { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.game-pause-note { margin: 0; font-size: 0.8rem; color: var(--ink-muted); }
.game-pause-card { position: relative; }
.game-pause-close {
  position: absolute; top: 6px; right: 6px;
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(28, 42, 74, 0.08); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
}
.game-pause-close:hover { background: rgba(28, 42, 74, 0.16); }
/* телефон: рамка игры невысокая — кнопки в ряд, заголовок и пояснение прячем */
.game-pause.is-compact { padding: 6px; }
.game-pause.is-compact .game-pause-card {
  flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center;
  width: 100%; gap: 6px; padding: 8px 44px 8px 8px; border-radius: 14px;
}
.game-pause.is-compact .game-pause-title,
.game-pause.is-compact .game-pause-note { display: none; }
.game-pause.is-compact .game-pause-card > .btn { padding: 6px 12px; font-size: 0.9rem; min-height: 0; }
.game-pause.is-compact .game-pause-levels { width: 100%; margin-top: 0; }
.game-pause.is-compact .game-pause-close { top: 50%; transform: translateY(-50%); }

/* сердечко «Понравилось» на карточке каталога и на странице игры */
.like[aria-pressed="true"] { color: #d2372a; }

/* таблица рекордов на странице игры — во всю ширину под «Как играть» и «Достижениями» */
.game-info .board { grid-column: 1 / -1; }
.board-tabs { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 4px 0 12px; }
.board-row { display: flex; flex-wrap: wrap; gap: 6px; }
.board-list { margin: 0 0 10px; padding: 0; list-style: none; counter-reset: place; }
.board-list li {
  counter-increment: place;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px dashed var(--border);
}
.board-list li::before { content: counter(place) "."; min-width: 1.6em; color: var(--ink-muted); font-weight: 700; }
.board-list li.board-empty { counter-increment: none; color: var(--ink-muted); font-style: italic; }
.board-list li.board-empty::before { content: none; }
.board-list li.is-me { background: var(--chip); border-radius: 10px; font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent); }
/* своя строка под таблицей (если не попал в верхние места): своё место или «—» */
.board-list li.board-own { counter-increment: none; margin-top: 8px; }
.board-list li.board-own::before { content: attr(data-place); }
.board-nick { flex: 1; }
.board-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.board-me { margin: 0 0 10px; color: var(--ink-muted); }

/* выбор имени */
/* выбор ника: герой карточками с картинками, «какой он» — плашками */
.name-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  border: 0;
  border-radius: 24px;
  padding: 18px 22px 20px;
  background: var(--paper-2, #fffdf6);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.name-dialog::backdrop { background: rgba(20, 14, 6, 0.45); }
.name-dialog h3 { margin: 0 0 10px; font-family: var(--font-head); font-size: 1.6rem; text-align: center; }
.name-me { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 6px; }
.name-me .nick-ava svg { width: 84px; height: 84px; }
.name-preview { margin: 0; font-family: var(--font-head); font-size: 1.8rem; line-height: 1.15; }
.name-hint { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.name-label { margin: 12px 0 8px; font-weight: 800; color: var(--green); font-size: 0.95rem; }
.name-heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.name-hero {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 2px 6px; border: 2px solid transparent; border-radius: 16px;
  background: var(--chip, #fff1d6); color: var(--ink); font: 700 0.78rem var(--font-body, inherit); cursor: pointer;
}
.name-hero .nick-ava svg { width: 52px; height: 52px; }
.name-hero[aria-pressed="true"] { border-color: var(--accent); background: #fff1d6; color: #1c2a4a; }
.name-adjs { display: flex; flex-wrap: wrap; gap: 6px; }
.name-adj {
  padding: 6px 12px; border-radius: 999px; border: 2px solid #f2dca8;
  background: var(--chip, #fff8e8); color: var(--ink); font: 700 0.9rem inherit; cursor: pointer;
}
.name-adj[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.name-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
/* картинка героя рядом с ником в таблицах */
.nick-ava { display: inline-flex; flex: none; line-height: 0; }
.nick-ava svg { border-radius: 50%; box-shadow: 0 0 0 2px #f2c87a; }

/* рекорды по уровням — каждый уровень своей строкой */
.num.levels { white-space: pre-line; font-size: 0.9rem; line-height: 1.5; }

/* «Мои рекорды»: своё место в общем рейтинге; «Рейтинг»: ссылки на сказки */
.overall-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rating-tales { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 8px 0 0; padding: 0; list-style: none; }
.rating-tales a { font-weight: 700; color: var(--accent); }

/* карточка «место в рейтинге» — ссылка на страницу «Рейтинг» */
.summary-link { text-decoration: none; color: inherit; transition: transform 0.15s; }
.summary-link:hover { transform: translateY(-2px); border-color: var(--accent); }


/* «Мои рекорды»: настройка для родителей — скрыть страшилки */
.parent-row { display: flex; gap: 10px; align-items: center; margin: 18px 0 6px; font-weight: 600; cursor: pointer; }
.parent-row input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Альбом сказок ---------- */
.album-total { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; font-weight: 800; margin: 4px 0 22px; }
.album-bar { flex: 0 1 340px; height: 14px; border-radius: 7px; background: #f2e4c4; overflow: hidden; }
.album-bar i { display: block; height: 100%; background: linear-gradient(90deg, #f2a41c, #e0523a); border-radius: 7px; }
.album-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 470px), 1fr)); gap: 22px; }
.album-page {
  position: relative; overflow: hidden; border-radius: 22px; padding: 16px 18px 18px;
  background: var(--paper-2, #fffaf0); box-shadow: var(--shadow-lift);
}
/* обложка сказки: едва видна, у собранной страницы — целиком */
.album-page > * { position: relative; }
.album-page > .album-cover {
  position: absolute; inset: 0; background: center / cover no-repeat; opacity: 0.12; transition: opacity 0.6s;
}
.album-page.is-done > .album-cover { opacity: 0.9; }
.album-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.album-title { margin: 0; font-size: 1.5rem; }
.album-title a { color: var(--ink); text-decoration: none; }
.album-count { font-weight: 800; color: var(--green); white-space: nowrap; }
.album-page.is-done .album-head { background: rgba(255, 253, 246, 0.88); margin: -6px -8px 0; padding: 6px 10px; border-radius: 14px; }
.album-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px 8px; margin-top: 12px; }
.sticker { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.sticker-pic {
  display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 0 0 4px #fff; transform: rotate(var(--tilt, 0deg));
}
.sticker-pic svg { width: 72px; height: 72px; }
.sticker-name { font-size: 0.74rem; font-weight: 800; line-height: 1.15; color: #1c2a4a; }
.album-page.is-done .sticker-name { background: rgba(255, 253, 246, 0.85); border-radius: 6px; padding: 1px 5px; }
.sticker-how { font-size: 0.66rem; line-height: 1.15; color: #8a7a5a; }
.sticker.is-empty .sticker-pic {
  background: transparent; box-shadow: none; border: 3px dashed #d8c8a0; transform: none;
  filter: grayscale(1); opacity: 0.35;
}
.sticker.is-empty .sticker-name { color: #8a7a5a; }
/* новая наклейка: подпрыгивает и светится несколько раз */
.sticker.is-new .sticker-pic { animation: sticker-new 0.9s ease 3; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 0 0 4px #fff, 0 0 0 8px rgba(242, 164, 28, 0.6); }
@keyframes sticker-new { 50% { transform: rotate(var(--tilt, 0deg)) scale(1.15); } }
.album-done {
  margin: 14px auto 0; width: fit-content; padding: 6px 20px; border-radius: 14px; transform: rotate(-2deg);
  background: #e0523a; color: #fff; font: 700 1.25rem var(--font-head); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
/* всплывашка в игре: картинка наклейки и ссылка в альбом */
.toast-sticker { display: flex; align-items: center; gap: 12px; }
.toast-sticker svg { flex: none; width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 0 0 3px #fff; }
.toast-album { font-size: 0.82rem; font-weight: 700; color: var(--accent); }

/* «Мои рекорды» → перенос на другое устройство */
.transfer-code { display: flex; align-items: center; gap: 14px; margin: 12px 0 4px; padding: 12px 16px; border-radius: 18px; background: var(--chip, #fff1d6); width: fit-content; }
.transfer-code .nick-ava svg { width: 64px; height: 64px; }
.transfer-words { font-family: var(--font-head); font-size: 1.7rem; letter-spacing: 0.5px; }
.transfer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.transfer-preview { text-align: center; margin: 0 0 6px; }
.transfer-digits {
  display: block; width: 7.5em; padding: 8px 12px; border: 2px solid #f2dca8; border-radius: 14px;
  font: 700 1.6rem var(--font-head, inherit); letter-spacing: 0.3em; text-align: center; background: #fff; color: #1c2a4a;
}
.transfer-err { min-height: 1.2em; margin: 8px 0 0; color: var(--accent); font-weight: 700; text-align: center; }
.transfer-code { width: auto; max-width: 100%; }
.transfer-scan { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 22px; }
.transfer-qr { display: block; width: 180px; height: 180px; padding: 6px; background: #fff; border-radius: 14px; flex: none; }
.transfer-qr svg { width: 100%; height: 100%; display: block; }
.transfer-side { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.transfer-step { margin: 0; font-weight: 700; }
.transfer-short { display: flex; align-items: center; gap: 12px; }
.transfer-short .nick-ava svg { width: 52px; height: 52px; }
.transfer-short.is-expired { opacity: 0.35; text-decoration: line-through; }
.transfer-left { margin: 0; font-size: 0.85rem; color: var(--ink-muted); }
.transfer-side .btn { background: #fff; }

/* ---------- Гардероб: наряды героя за наклейки ---------- */
.wardrobe { margin-top: 16px; }
.wardrobe-title { font-family: var(--font-head); font-size: 1.1rem; margin: 0 0 8px; }
.wardrobe-row { display: flex; flex-wrap: wrap; gap: 10px; }
.outfit {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 112px; padding: 8px 6px 7px;
  border: 2px solid var(--border); border-radius: 14px; background: var(--paper-2, #fffaf0); color: var(--ink);
  font: inherit; cursor: pointer; text-align: center;
}
.outfit:hover:not(:disabled) { border-color: var(--gold); }
.outfit-pic svg { display: block; width: 56px; height: 56px; }
.outfit-name { font-weight: 800; font-size: 0.82rem; line-height: 1.15; }
.outfit-state { font-size: 0.72rem; color: var(--ink-muted); }
.outfit.is-worn { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent); }
.outfit.is-worn .outfit-state { color: var(--green); font-weight: 800; }
.outfit.is-locked { cursor: default; }
.outfit.is-locked .outfit-pic { filter: grayscale(1) brightness(0.6); opacity: 0.35; }
.album-page .wardrobe { background: rgba(255, 253, 246, 0.88); border-radius: 14px; padding: 8px 10px 10px; }
.album-page .wardrobe-title { color: #1c2a4a; }
.album-page .outfit { background: #fffdf6; color: #1c2a4a; }

.look-row { display: flex; flex-wrap: wrap; gap: 8px; }
.look-pick {
  width: 48px; height: 48px; padding: 2px; border: 2px solid var(--border); border-radius: 50%;
  background: var(--paper-2, #fffaf0); color: var(--ink-muted); font: inherit; font-size: 1.1rem; cursor: pointer;
  display: grid; place-items: center;
}
.look-pick svg { width: 40px; height: 40px; }
.look-pick[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 35%, transparent); }
.album-look { display: flex; align-items: center; gap: 16px; margin: -8px 0 22px; padding: 12px 16px; border-radius: 18px; background: var(--chip); }
.album-look-title { margin: 0 0 8px; font-weight: 800; }

/* ---------- Набор друга сказок ---------- */
.friend-buy { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.friend-price-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.friend-price { margin: 0; font-family: var(--font-head); font-size: 2.4rem; line-height: 1; color: var(--accent); }
.friend-once { margin: 0; color: var(--ink-muted); font-weight: 700; }
.friend-note { flex-basis: 100%; margin: 0; color: var(--ink-muted); font-size: 0.92rem; }
.friend-owned { border: 2px solid var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--paper-2, #fffaf0)); }
.friend-key { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.friend-key code { padding: 6px 10px; border-radius: 8px; background: var(--chip); font-size: 0.95rem; word-break: break-all; }
.friend-key-label { font-weight: 800; }
.friend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.friend-item { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px 14px; padding: 10px 12px; border-radius: 14px; background: var(--chip); }
.friend-item-icon { font-size: 1.9rem; text-align: center; }
.friend-item-title { margin: 0; font-weight: 800; }
.friend-item-desc { margin: 2px 0 0; font-size: 0.9rem; color: var(--ink-muted); }
.friend-item-state { font-size: 0.8rem; font-weight: 800; color: var(--ink-muted); white-space: nowrap; }
.friend-item.is-ready .friend-item-state { color: var(--green); }
.friend-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.friend-input { flex: 1 1 260px; min-height: 44px; padding: 8px 14px; border: 2px solid var(--border); border-radius: 12px; background: var(--paper-2, #fffaf0); color: var(--ink); font: inherit; }
.friend-gate .friend-form { justify-content: center; }
.friend-gate-q { font-family: var(--font-head); font-size: 1.8rem; }
.friend-gate-input { flex: 0 0 96px; font-size: 1.5rem; text-align: center; }
.friend-legal { margin-top: 18px; text-align: center; color: var(--ink-muted); }
@media (max-width: 520px) {
  .friend-item { grid-template-columns: 36px 1fr; }
  .friend-item-state { grid-column: 2; }
}

/* ---------- Условия и конфиденциальность ---------- */
.legal-toc { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 18px; font-weight: 700; }
.legal .panel { margin-bottom: 18px; scroll-margin-top: 16px; }
.legal .panel p { line-height: 1.6; margin: 0 0 10px; }
.friend-gate .friend-gate-input { flex: 0 0 96px; width: 96px; }

/* ---------- «Сказка на ночь»: сказка внутри bedtime.html — только мультфильм на весь экран ---------- */
html.is-bedtime, html.is-bedtime body { background: #05070f; overflow: hidden; }
html.is-bedtime .site-header, html.is-bedtime .site-footer, html.is-bedtime .game-top, html.is-bedtime .game-info,
html.is-bedtime .voice-hint, html.is-bedtime .fs-exit, html.is-bedtime .toasts, html.is-bedtime .board, html.is-bedtime main > :not(.game-frame) { display: none !important; }
html.is-bedtime .game-frame {
  position: fixed; inset: 0; z-index: 100; max-width: none; width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; background: #05070f; display: flex; align-items: center; justify-content: center;
}
html.is-bedtime .game-frame canvas { width: min(100vw, 200vh); width: min(100vw, 200dvh); height: auto; border: 0; border-radius: 0; }

/* ---------- «Сказка на ночь» ---------- */
.night {
  position: relative; overflow: hidden; border-radius: 26px; padding: 34px 28px 30px; color: #eef0ff;
  background: radial-gradient(ellipse at 80% 10%, #3a4486 0%, #1b2150 45%, #0c1030 100%);
  box-shadow: var(--shadow-lift);
}
.night > * { position: relative; }
.night .night-sky { position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(1.6px 1.6px at 12% 22%, #fff 50%, transparent 51%), radial-gradient(1.2px 1.2px at 32% 64%, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 58% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 70% 52%, #fff 50%, transparent 51%),
    radial-gradient(1.6px 1.6px at 88% 70%, #fff 50%, transparent 51%), radial-gradient(1.1px 1.1px at 22% 84%, #fff 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 46% 40%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 94% 30%, #fff 50%, transparent 51%);
  opacity: 0.85; animation: night-twinkle 5s ease-in-out infinite alternate; }
@keyframes night-twinkle { to { opacity: 0.45; } }
.night > .night-moon { position: absolute; }
.night-moon { position: absolute; top: 22px; right: 30px; width: 74px; height: 74px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffbe0, #f4e2a0 70%); box-shadow: 0 0 40px 10px rgba(255, 236, 160, 0.25); }
.night-title { margin: 0 0 8px; font-family: var(--font-head); font-size: clamp(2rem, 6vw, 2.8rem); color: #fff6d8; }
.night-lead { max-width: 560px; margin: 0 0 22px; color: #c9cdf2; line-height: 1.55; }
.night-locked p { color: #e6e8ff; font-weight: 700; }
.night-label { margin: 0 0 8px; font-weight: 800; color: #fff6d8; }
.night-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.night-chip, .night-shuffle { min-height: 44px; padding: 8px 16px; border: 2px solid rgba(255, 255, 255, 0.25); border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); color: #eef0ff; font: inherit; font-weight: 800; cursor: pointer; }
.night-chip[aria-pressed="true"] { background: #f4e2a0; border-color: #f4e2a0; color: #1b2150; }
.night-tales { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.night-tale { width: 150px; border-radius: 14px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.night-tale img { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; filter: brightness(0.8) saturate(0.85); }
.night-tale span { display: block; padding: 6px 10px 8px; font-weight: 800; font-size: 0.9rem; }
.night-shuffle { margin-bottom: 16px; }
.night-check { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-weight: 700; cursor: pointer; }
.night-check input { width: 20px; height: 20px; accent-color: #f4e2a0; }
.night-start { font-size: 1.15rem; padding: 12px 28px; }

body.has-bed-player { overflow: hidden; }
.bed-player { position: fixed; inset: 0; z-index: 200; background: #05070f; }
.bed-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
  filter: brightness(0.8) saturate(0.8) sepia(0.12); transition: opacity 1.5s ease; }
.bed-frame.is-gone { opacity: 0; }
.bed-dark { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  color: #8f96c8; opacity: 0; pointer-events: none; transition: opacity 1.5s ease;
  background: radial-gradient(ellipse at 50% 40%, #141a3c 0%, #05070f 70%); }
.bed-dark.is-on { opacity: 1; }
.bed-dark .night-moon { position: static; width: 90px; height: 90px; }
.bed-dark p { margin: 0; font-family: var(--font-head); font-size: 1.3rem; }
.bed-card { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(5, 7, 15, 0.92); color: #fff6d8; text-align: center; animation: bed-fade 1.2s ease; }
.bed-card.is-end { background: transparent; }
.bed-card-small { margin: 0; color: #a9b0e0; font-size: 1.1rem; }
.bed-card-title { margin: 0; font-family: var(--font-head); font-size: clamp(2rem, 7vw, 3.4rem); }
@keyframes bed-fade { from { opacity: 0; } }
.bed-player.is-asleep .bed-dark, .bed-player.is-asleep .bed-card { opacity: 0.08; transition: opacity 40s ease; }
.bed-bar { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 10px; transition: opacity 0.6s; }
.bed-bar.is-hidden { opacity: 0.45; }
.bed-bar:hover, .bed-bar:focus-within { opacity: 1; }
.bed-count { color: #8f96c8; font-weight: 800; }
.bed-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.12); color: #dfe3ff; font-size: 1.2rem; cursor: pointer; }
.bed-card.is-end::before { content: ""; width: 96px; height: 96px; margin-bottom: 16px; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffbe0, #f4e2a0 70%); box-shadow: 0 0 50px 14px rgba(255, 236, 160, 0.22); }
.bed-dark.is-end .night-moon { display: none; }

/* ---------- Раскраски ---------- */
/* вкладки сказок: на телефоне листаются пальцем в одну строку */
.col-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 2px 10px; margin: 0 -2px 8px; }
.col-tab { flex: none; min-height: 44px; padding: 8px 16px; border: 2px solid var(--border); border-radius: 999px; background: var(--paper-2, #fffaf0);
  color: var(--ink); font: inherit; font-weight: 800; white-space: nowrap; cursor: pointer; scroll-snap-align: start; }
.col-tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.col-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }
.col-tale-title { margin: 0; font-size: 1.6rem; }
.col-group { margin: 18px 0 10px; font-size: 1.1rem; color: var(--ink-muted); font-family: var(--font-body, inherit); font-weight: 800; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 210px), 1fr)); gap: 14px; }
.col-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 10px; border: 2px solid var(--border);
  border-radius: 18px; background: var(--paper-2, #fffaf0); color: var(--ink); text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
.col-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.col-thumb { display: block; width: 100%; height: auto; aspect-ratio: 800 / 566; border-radius: 12px; background: #fff; }
.col-card-title { padding: 0 4px; font-weight: 800; line-height: 1.2; }
.col-card-badge { position: absolute; top: 12px; right: 12px; font-size: 1.3rem; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3)); }

/* раскрашивание */
.col-top { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.col-title { flex: 1 1 200px; margin: 0; font-size: 1.6rem; }
.col-nav { display: flex; align-items: center; gap: 8px; }
.col-arrow { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--chip); color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.col-arrow:hover { background: var(--chip-hover); }
.col-count { min-width: 3.4em; text-align: center; font-weight: 800; color: var(--ink-muted); }
.col-work { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 18px; align-items: start; }
.col-stage { border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lift); background: #fff; }
.col-canvas { display: block; width: 100%; height: auto; aspect-ratio: 800 / 566; touch-action: manipulation; cursor: crosshair; }
.col-panel { position: sticky; top: 14px; display: flex; flex-direction: column; gap: 14px; padding: 14px; border-radius: 18px; background: var(--paper-2, #fffaf0); box-shadow: var(--shadow-lift); }
.col-current-row { display: flex; align-items: center; gap: 10px; }
.col-current { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.15), 0 0 0 3px #fff, 0 0 0 4px var(--border); }
.col-hint { font-size: 0.85rem; line-height: 1.3; color: var(--ink-muted); }
.col-palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.col-colour { width: 100%; aspect-ratio: 1; min-width: 40px; border: 3px solid #fff; border-radius: 50%; background: var(--c); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); transition: transform 0.1s; }
.col-colour[aria-pressed="true"] { transform: scale(1.12); box-shadow: 0 0 0 3px var(--ink); }
.col-colour.is-eraser { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 17l8-8 6 6-4 4H7z' fill='%23f48fb1'/%3E%3Cpath d='M12 9l3-3 6 6-3 3z' fill='%23bdbdbd'/%3E%3C/svg%3E") center / 60% no-repeat; }
.col-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.col-tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; padding: 6px 4px; border: 0; border-radius: 14px;
  background: var(--chip); color: var(--ink); font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer; }
.col-tool > span:first-child { font-size: 1.3rem; line-height: 1; }
.col-tool:hover:not(:disabled) { background: var(--chip-hover); }
.col-tool:disabled { opacity: 0.4; cursor: default; }
.col-print-sheet { display: none; }

/* телефон и узкий планшет: картинка на всю ширину, палитра и кнопки прилипают к низу экрана */
@media (max-width: 860px) {
  .col-work { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .col-tabs { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; margin: 0 -16px 8px; padding: 4px 16px 10px; }
  .col-tabs::-webkit-scrollbar { display: none; }
  .col-title { font-size: 1.25rem; flex-basis: 100%; order: -1; }
  .col-stage { border-radius: 14px; }
  .col-panel { position: sticky; top: auto; bottom: 0; z-index: 5; margin: 12px -16px 0; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px 18px 0 0; box-shadow: 0 -6px 18px rgba(20, 30, 60, 0.12); }
  .col-hint { display: none; }
  .col-current-row { display: none; }
  .col-palette { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
  .col-palette::-webkit-scrollbar { display: none; }
  .col-colour { flex: none; width: 44px; height: 44px; min-width: 0; }
  .col-tools { grid-template-columns: repeat(4, 1fr); }
  .col-tool { min-height: 50px; font-size: 0.72rem; }
  body.is-colouring .site-footer { display: none; }
}
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body > *:not(.col-print-sheet) { display: none !important; }
  .col-print-sheet { display: block !important; width: 100%; height: auto; }
}
