/* ============================================================================
 *  «СМ. Инструкция по выживанию» — оформление
 *
 *  Все цвета, шрифт и скругления заданы токенами в :root. Градиент фона —
 *  переменная --grad, снята с фирменной картинки: розовое поле с тёплым
 *  персиковым свечением по центру.
 *
 *  Вёрстка mobile-first: базовые правила рассчитаны на телефон,
 *  медиа-запросы только расширяют макет вверх (min-width).
 * ==========================================================================*/

/* ---------- шрифт ---------- */

@font-face {
  font-family: "ALS Sector";
  src: url("/fonts/ALSSector-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "ALS Sector";
  src: url("/fonts/ALSSectorBold-Bold.woff2") format("woff2"),
       url("/fonts/ALSSectorBold-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- токены ---------- */

:root {
  /* фирменные цвета */
  --ink:        #3b2a6b;   /* тёмно-фиолетовый: весь текст и заголовки */
  --violet:     #6f4b9e;   /* акцент: кнопки, активные состояния */
  --violet-dk:  #593c81;
  --pink:       #e492bf;
  --pink-lt:    #eda6cb;
  --peach:      #f8cfa4;

  /* фон страницы: тёплое персиковое свечение по центру поверх розового поля */
  --grad:
    radial-gradient(70% 46% at 48% 56%, #fbdab0 0%, rgba(251, 218, 176, 0) 72%),
    linear-gradient(150deg, #efa7cf 0%, #e68dc1 34%, #e081b6 60%, #eb9dc4 100%);

  --card:       rgba(255, 255, 255, .82);
  --card-solid: #ffffff;
  --tint:       rgba(111, 75, 158, .09);  /* лёгкий оттенок шапки карточки */
  --line:       rgba(59, 42, 107, .14);
  --ink-soft:   rgba(59, 42, 107, .82);
  --ink-dim:    rgba(59, 42, 107, .62);
  --ink-mute:   rgba(59, 42, 107, .42);

  --ok:   #2f9e6d;
  --warn: #b5711a;
  --err:  #c2405a;

  /* лучи радиального меню — цвет заменяет подписи о состоянии:
     голубой — свободно, фиолетовый — вы записаны, красный — точка пройдена */
  --ray:      #3fbdf0;
  --ray-on:   #8b5cf6;
  --ray-done: #e4344f;

  --font: "ALS Sector", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --shadow:    0 6px 24px rgba(59, 42, 107, .10);
  --shadow-lg: 0 18px 50px rgba(59, 42, 107, .20);

  --gutter: 16px;
  --maxw: 1080px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- база ---------- */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; }

/* скроллбары скрыты везде, прокрутка при этом работает */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

body {
  min-height: 100dvh;
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Градиент отдельным фиксированным слоем, а не background-attachment: fixed —
   тот в мобильном Safari отрисовывается с артефактами при скролле. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--grad);
  pointer-events: none;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 700; line-height: 1.15; }

:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: rgba(111, 75, 158, .22); }

.muted { color: var(--ink-dim); }

/* ---------- каркас ---------- */

.wrap {
  width: min(var(--maxw), 100%);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main { padding-bottom: 56px; }
.section { padding-block: 24px; }
.stack { display: grid; gap: 14px; }

/* minmax(0, 1fr) вместо 1fr: трек не должен раздуваться под min-content
   содержимого — иначе широкая таблица или длинный <option> растягивают
   страницу по горизонтали. Правило стоит раньше конкретных сеток,
   поэтому многоколоночные раскладки ниже его спокойно переопределяют. */
.stack, .form, .field, .roles, .panel, .list, .rank, .orgs,
.sheet__body, .item, .slot, .rank__body, .rank__stats,
.notice div, .hero-stat > div,
.hub, .hub__title, .hero, .stats, .booking, .fixed {
  grid-template-columns: minmax(0, 1fr);
}

.section__head { font-size: 18px; margin-bottom: 12px; }
.section__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section__row .section__head { margin-bottom: 0; }

.note { color: var(--ink-dim); font-size: 13.5px; }
.note--warn { color: var(--warn); }
.note--empty {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 18px;
  text-align: center;
}

/* кнопка внутри пояснения (например, «перейти к брони») */
.note__act { display: block; margin-top: 10px; }

/* ---------- шапка ---------- */

.topbar { padding-block: 22px 8px; }
.topbar__inner { display: grid; gap: 10px; justify-items: center; }

/* Текстовая заглушка логотипа. Когда придёт вектор — заменить содержимое
   на <img>, размеры задать здесь же. */
.brand {
  font-weight: 700;
  font-size: clamp(25px, 7vw, 38px);
  line-height: 1.12;
  letter-spacing: -.005em;
  text-align: center;
  color: var(--ink);
  text-wrap: balance;
}

.usermenu {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.usermenu__info { font-size: 13px; color: var(--ink-dim); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-solid);
  color: var(--ink);
  font: 700 15px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }

.btn--primary { background: var(--violet); border-color: transparent; color: #fff; }
.btn--primary:hover { background: var(--violet-dk); }

.btn--danger { color: var(--err); border-color: rgba(194, 64, 90, .3); background: rgba(194, 64, 90, .07); }

.btn--sm { min-height: 34px; padding: 0 13px; font-size: 13px; }
.btn--lg { min-height: 54px; padding: 0 34px; font-size: 17px; }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 42px; min-height: 42px; }
.btn--icon.btn--sm { width: 30px; min-height: 30px; }

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------- поля ---------- */

input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-solid);
  color: var(--ink);
  transition: border-color .15s var(--ease);
}
input::placeholder { color: var(--ink-mute); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
                    linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.form { display: grid; gap: 13px; }
.field { display: grid; gap: 5px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-mute); }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* поле с подписью внутри компактной формы (баллы за тест / за точку) */
.scorefield { display: grid; gap: 3px; flex: 0 0 auto; }
.scorefield > span { font-size: 11.5px; color: var(--ink-mute); }
.scorefield input { width: 92px; }

/* код организатора */
.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .06em;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--tint);
  user-select: all;
}
.inline-form input,
.inline-form select,
.inline-form textarea { width: auto; flex: 1 1 150px; min-width: 0; }
.inline-form .w-num { flex: 0 0 84px; }

.point-editor-row td { padding-top: 0; }
.point-editor-row summary { color: var(--violet); cursor: pointer; font-weight: 700; }
.point-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 0 8px;
}
.point-editor__wide { grid-column: 1 / -1; }
.point-editor textarea,
.inline-form textarea { resize: vertical; }
.preview-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--tint);
}
.preview-cta > div { display: grid; gap: 3px; }
.preview-cta span { color: var(--ink-dim); font-size: 13px; }
.previewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--violet);
  border-radius: var(--r);
  background: var(--card-solid);
}
.previewbar > div:first-child { display: grid; gap: 2px; }
.previewbar span { color: var(--ink-dim); font-size: 12px; }
.previewbar__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-pick { display: grid; gap: 4px; color: var(--ink-dim); font-size: 12px; }
.upload-preview { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); font-size: 12px; }
.upload-preview img { width: 48px; height: 48px; object-fit: contain; border-radius: 50%; background: var(--tint); }
@media (max-width: 620px) {
  .point-editor { grid-template-columns: minmax(0, 1fr); }
  .point-editor__wide { grid-column: auto; }
  .preview-cta { align-items: stretch; flex-direction: column; }
  .previewbar { align-items: stretch; flex-direction: column; }
  .previewbar__controls > * { flex: 1 1 auto; }
}

/* ---------- карточки организаций ---------- */

.orgs { display: grid; gap: 12px; }

@media (min-width: 620px)  { .orgs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 940px)  { .orgs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.org {
  /* меньшая верхняя часть — логотип и название, нижняя — описание */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  /* по высоте — как две прежние карточки вместе с отступом между ними */
  min-height: 172px;
  /* без отступов: оттенок шапки идёт вплотную к краям карточки */
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.org:hover { background: var(--card-solid); box-shadow: var(--shadow-lg); }
.org:active { transform: scale(.99); }

/* верхняя часть — тот же фон карточки плюс лёгкий оттенок */
.org__head {
  display: flex;
  align-items: center;   /* название ровно по центру логотипа */
  gap: 14px;
  padding: 12px 16px;
  background: var(--tint);
}

.org__logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--violet);
}
.org__logo img { width: 58%; height: 58%; object-fit: contain; }

.org__logo--lg { width: 96px; height: 96px; }

.org__name { font-weight: 700; font-size: 19px; min-width: 0; }

/* нижняя часть — на подложке карточки, без своего фона */
.org__desc {
  padding: 12px 16px 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: justify;
  hyphens: auto;
  /* описания разной длины не должны ломать высоту сетки */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- кнопка входа под карточками ---------- */

.enter { display: flex; justify-content: center; padding-top: 28px; }

/* ---------- партнёры на витрине ---------- */

.partners { margin-top: 42px; }
.partners__intro { margin-top: -6px; margin-bottom: 14px; }
.partners__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.partner-icon {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  padding: 10px 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .48);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.partner-icon:hover, .partner-icon.is-active { background: var(--card-solid); box-shadow: var(--shadow); }
.partner-icon:active { transform: scale(.97); }
.partner-icon.is-active { border-color: rgba(111, 75, 158, .34); }

.partner-icon__image, .partner-card__image {
  display: grid;
  place-items: center;
  /* Логотипы приходят разной формы и часто с прозрачностью: не помещаем их
     в белый круг или прямоугольник, чтобы белые элементы не исчезали. */
  overflow: visible;
  background: transparent;
}
.partner-icon__image {
  width: 58px;
  aspect-ratio: 1;
}
.partner-icon__image img, .partner-card__image img { width: 100%; height: 100%; object-fit: contain; }
.partner-icon__image--mark, .partner-card__image--mark {
  color: var(--violet);
  font-weight: 700;
}
.partner-icon__image--mark { font-size: 26px; }
.partner-icon__name {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

/* У логотипа Black Star Karting большой прозрачный отступ вокруг рисунка.
   Увеличиваем только его, не меняя размеры остальных партнёров. */
.partner-icon--timati-karting .partner-icon__image,
.partner-card--timati-karting .partner-card__image { transform: scale(1.35); }

/* В исходниках «Тайрай» вокруг знака почти 2/3 прозрачного поля, а у
   «Мосигры» — широкие поля по бокам. Масштабируем изображение внутри того же
   окна и отсекаем только пустые края: размер карточек и подписи не меняются. */
.partner-icon--tairai .partner-icon__image,
.partner-card--tairai .partner-card__image,
.partner-icon--mosigra .partner-icon__image,
.partner-card--mosigra .partner-card__image { overflow: clip; }

.partner-icon--tairai .partner-icon__image img,
.partner-card--tairai .partner-card__image img { transform: scale(1.85); }

.partner-icon--mosigra .partner-icon__image img,
.partner-card--mosigra .partner-card__image img { transform: scale(1.5); }

.partner-card {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transform-origin: top;
  animation: partner-card-in .1s var(--ease);
}
.partner-card__head { display: flex; align-items: center; gap: 13px; }
.partner-card__image { width: 72px; aspect-ratio: 1; flex: 0 0 auto; }
.partner-card__image--mark { font-size: 31px; }
.partner-card__eyebrow { color: var(--ink-dim); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.partner-card h3 { font-size: 20px; }
.partner-card > p { color: var(--ink-soft); line-height: 1.45; }
.partner-card__go { justify-self: start; }
.partner-card__go span { margin-left: 5px; }

@keyframes partner-card-in {
  from { opacity: 0; transform: translateY(-4px) scaleY(.94); }
  to { opacity: 1; transform: translateY(0) scaleY(1); }
}

@media (min-width: 520px) { .partners__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 760px) {
  .partners__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
  .partner-icon__image { width: 68px; }
  .partner-card { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .partner-card__head { grid-row: span 2; }
  .partner-card__go { align-self: center; }
}

/* ---------- рекламные баннеры ---------- */

.ad-banner {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  width: min(100%, 920px);
  margin: 18px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 88% 10%, rgba(255, 255, 255, .55), transparent 34%),
    linear-gradient(125deg, rgba(111, 75, 158, .96), rgba(228, 146, 191, .94));
  box-shadow: var(--shadow);
  color: #fff;
  overflow: hidden;
}

.ad-banner__visual {
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  border-radius: var(--r);
  background: rgba(255, 255, 255, .16);
}
.ad-banner__visual img { width: 58%; height: 58%; object-fit: contain; }
.ad-banner__visual--mark { font-size: 28px; font-weight: 800; }
.ad-banner.no-image { grid-template-columns: minmax(0, 1fr); }

.ad-banner__body { display: grid; min-width: 0; gap: 2px; }
.ad-banner__label {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.5;
  text-transform: uppercase;
}
.ad-banner__title { font-size: 17px; line-height: 1.15; text-wrap: balance; }
.ad-banner__text { font-size: 12.5px; line-height: 1.3; opacity: .82; }
.ad-banner__action { display: none; font-size: 13px; font-weight: 700; white-space: nowrap; }
.ad-banner__action span { margin-left: 5px; }

.ad-banner.is-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s var(--ease), box-shadow .18s var(--ease);
}
.ad-banner.is-link:hover { box-shadow: var(--shadow-lg); }
.ad-banner.is-link:active { transform: scale(.99); }

/* Малый формат для экрана с колесом: ниже и спокойнее основного баннера. */
.ad-banner--compact {
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 11px;
  margin-top: 0;
  width: min(100%, 680px);
  padding: 9px 11px;
  border-radius: var(--r);
}
.ad-banner--compact .ad-banner__visual { width: 52px; border-radius: var(--r-sm); }
.ad-banner--compact .ad-banner__title { font-size: 14.5px; }
.ad-banner--compact .ad-banner__text { font-size: 11.5px; }

/* Карусель партнёров сохраняет ширину независимо от длины текущего текста. */
[data-partner-banner] {
  width: min(100%, 680px);
  margin: 0 auto;
}
[data-partner-banner] .ad-banner--compact { width: 100%; }
[data-partner-banner] .ad-banner {
  transition: opacity .18s ease, transform .18s var(--ease), box-shadow .18s var(--ease);
}
[data-partner-banner].is-changing .ad-banner {
  opacity: 0;
  transform: translateY(5px);
}

/* В меню логотипам отдано больше места, чем в обычной рекламной плашке. */
[data-partner-banner] .ad-banner--compact {
  grid-template-columns: 64px minmax(0, 1fr);
}
[data-partner-banner] .ad-banner--compact .ad-banner__visual { width: 64px; }
[data-partner-banner] .ad-banner__visual img { width: 78%; height: 78%; }

/* Эти три логотипа уже увеличены на витрине из-за прозрачных полей в исходниках.
   В баннере сохраняем то же пропорциональное дополнительное увеличение. */
[data-partner-banner] .ad-banner--partner-tairai .ad-banner__visual,
[data-partner-banner] .ad-banner--partner-mosigra .ad-banner__visual,
[data-partner-banner] .ad-banner--partner-timati-karting .ad-banner__visual { overflow: clip; }
[data-partner-banner] .ad-banner--partner-tairai .ad-banner__visual img { transform: scale(1.85); }
[data-partner-banner] .ad-banner--partner-mosigra .ad-banner__visual img { transform: scale(1.5); }
[data-partner-banner] .ad-banner--partner-timati-karting .ad-banner__visual img { transform: scale(1.35); }

@media (min-width: 620px) {
  .ad-banner {
    grid-template-columns: 104px minmax(0, 1fr) auto;
    gap: 20px;
    padding: 16px 18px;
  }
  .ad-banner__visual { width: 104px; }
  .ad-banner__title { font-size: 21px; }
  .ad-banner__text { font-size: 14px; }
  .ad-banner__action { display: inline-flex; align-items: center; }

  .ad-banner--compact {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 13px;
    padding: 10px 13px;
  }
  .ad-banner--compact .ad-banner__visual { width: 58px; }
  .ad-banner--compact .ad-banner__title { font-size: 15px; }

  [data-partner-banner] .ad-banner--compact { grid-template-columns: 70px minmax(0, 1fr) auto; }
  [data-partner-banner] .ad-banner--compact .ad-banner__visual { width: 70px; }
}

/* ---------- развёрнутая карточка ---------- */

.sheet {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  /* диалог скроллится внутри себя, поэтому здесь обычный фон, без fixed */
  background: var(--grad);
  color: var(--ink);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(59, 42, 107, .45); }

.sheet[open] { animation: sheet-in .3s var(--ease); }
.sheet.is-closing { animation: sheet-out .16s ease-in forwards; }

@keyframes sheet-in  { from { opacity: 0; transform: translateY(24px); } }
@keyframes sheet-out { to   { opacity: 0; transform: translateY(12px); } }

.sheet__scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}
.sheet__bar {
  display: flex;
  align-items: center;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
}
.sheet__body {
  display: grid;
  gap: 16px;
  padding-block: 12px 0;
}

/* отдельный бабл с названием организации */
.bubble {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px 12px 12px;
  border-radius: 999px;
  background: var(--card-solid);
  box-shadow: var(--shadow);
  justify-self: start;
  max-width: 100%;
}
.bubble h2 { font-size: clamp(19px, 5vw, 26px); min-width: 0; }

/* карточка под текст и изображения */
.paper {
  display: grid;
  gap: 16px;
  padding: 20px 18px;
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
.paper p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
  text-align: justify;
  hyphens: auto;
}

.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.ph {
  aspect-ratio: 4 / 3;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--tint);
}
.ph img { width: 100%; height: 100%; object-fit: cover; }

/* блок без реального фото: плейсхолдер белый, поэтому инвертируем его
   в тёмный — иначе на светлой плашке его не видно */
.ph--empty { display: grid; place-items: center; }
.ph--empty img {
  width: 30%;
  height: 30%;
  object-fit: contain;
  filter: invert(1);
  opacity: .5;
}

@media (min-width: 820px) {
  .sheet {
    width: min(760px, 92vw);
    height: min(88dvh, 880px);
    margin: auto;
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
  }
}

/* ---------- главная вошедшего: радиальное меню ---------- */

.hub { display: grid; gap: 18px; justify-items: center; }
.hub .notice { width: 100%; margin-bottom: 0; }

/* стрелки листают меню по кругу, между ними — ссылки в кабинет */
.hub__links { display: flex; align-items: center; gap: 10px; justify-content: center; }

.hub__title { display: grid; justify-items: center; gap: 8px; }
.hub__title h2 { font-size: clamp(18px, 5vw, 22px); }

.hub__dots { display: flex; gap: 6px; }
.hub__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(59, 42, 107, .22);
  transition: background .2s var(--ease);
}
.hub__dots i.is-on { background: var(--violet); }

/* назначенные админом точки: только время, действий нет */
.hub .fixed { width: 100%; display: grid; gap: 8px; background: var(--card-solid); }
.fixed__head { font-size: 15px; }
.fixed__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.fixed__row:last-of-type { border-bottom: 0; }
.fixed__row b { font-size: 15px; }
.fixed__row span { color: var(--ink-dim); font-size: 13.5px; white-space: nowrap; }

/* Карусель держит предыдущее, текущее и следующее колесо рядом. За счёт этого
   соседнее меню входит в кадр прямо под пальцем, без поздней подмены DOM. */
.hub__carousel {
  width: min(100%, 520px);
  overflow: hidden;
  padding-bottom: 30px;
  touch-action: pan-y;
}
.hub__carousel-track {
  display: flex;
  width: 300%;
  translate: calc(-33.333333% + var(--carousel-x, 0px)) 0;
  will-change: translate;
}
.hub__carousel-page { flex: 0 0 33.333333%; min-width: 0; }

/* Ветви гаснут на месте; по треку движется только центральный шарик. */
.wheel__branches {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}
.wheel--current .wheel__branches {
  opacity: 1;
  pointer-events: auto;
  translate: calc(0px - var(--carousel-x, 0px)) 0;
}
.hub__carousel.is-swiping .wheel__branches { opacity: 0; pointer-events: none; }
.hub__carousel.is-swiping .wheel--current .wheel__branches {
  opacity: var(--branches-opacity, 1);
  transition: none;
}
.hub__carousel.is-revealing:not(.is-swiping) .wheel--current .wheel__branches {
  animation: wheel-branches-reveal 340ms ease-out both;
}
@keyframes wheel-branches-reveal {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .wheel__branches { transition-duration: 1ms; }
  .hub__carousel.is-revealing:not(.is-swiping) .wheel--current .wheel__branches {
    animation-duration: 1ms;
  }
}

/* Квадратное поле, внутри всё позиционируется в процентах от его стороны:
   лучи (svg 100×100), кружки организаций и центральная кнопка.
   container-type даёт cqw — размер подписей тоже привязан к колесу. */
.wheel {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  container-type: inline-size;
  /* Горизонтальный жест листает разделы, вертикальный остаётся прокруткой. */
  touch-action: pan-y;
  /* подписи нижних лучей выходят за круг — оставляем им место */
  margin-bottom: 0;
}

.wheel__rays { position: absolute; inset: 0; width: 100%; height: 100%; }
.wheel__ring { fill: none; stroke: rgba(59, 42, 107, .16); stroke-width: .4; stroke-dasharray: 1.4 2; }
/* Луч — единственный индикатор состояния организации, поэтому переход
   плавный: смена цвета на глазах читается как событие.
   Единицы обводки и свечения — доли viewBox (100 = ширина колеса),
   так что толщина сама масштабируется вместе с колесом. */
.wheel__lines line {
  stroke: var(--ray);
  stroke-width: .55;
  stroke-linecap: round;
  filter: drop-shadow(0 0 .8px var(--ray));
  transition: stroke .35s var(--ease), stroke-width .35s var(--ease), filter .35s var(--ease);
}

/* активная бронь — ярче и толще остальных */
.wheel__lines .is-booked {
  stroke: var(--ray-on);
  stroke-width: .95;
  filter: drop-shadow(0 0 1.4px var(--ray-on));
}

/* точка пройдена: организатор подтвердил визит, записаться повторно нельзя */
.wheel__lines .is-done {
  stroke: var(--ray-done);
  stroke-width: .8;
  filter: drop-shadow(0 0 1.1px var(--ray-done));
}

/* Позиционирование живёт в отдельном свойстве translate, а увеличение — в
   scale: свойство transform остаётся свободным под дрейф из float.js.
   Порядок применения фиксирован спекой (translate → scale → transform),
   поэтому они не спорят друг с другом. */
.node {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: 15%;
  aspect-ratio: 1;
  translate: -50% -50%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  transition: scale .14s var(--ease);
}
.node:hover { scale: 1.07; }
.node:active { scale: .97; }

.node__logo {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: var(--shadow);
}
.node__logo img { width: 54%; height: 54%; object-fit: contain; }

.node__name {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  width: 150%;
  font-weight: 700;
  font-size: clamp(10px, 2.4cqw, 13px);
  line-height: 1.15;
  text-align: center;
  /* длинное название не должно наезжать на соседний луч */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Пройденную точку приглушаем — состояние читается и без цвета луча.
   Записанную не выделяем: за неё отвечает яркий фиолетовый луч. */
.node--done .node__logo { opacity: .55; }
.node--done .node__name { color: var(--ink-dim); }

.core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30%;
  aspect-ratio: 1;
  translate: -50% -50%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card-solid);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  transition: scale .14s var(--ease);
}
.core:hover { scale: 1.05; }
.core:active { scale: .98; }

.core__art {
  display: grid;
  place-items: center;
  width: clamp(40px, 13cqw, 74px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--tint);
  overflow: hidden;
}
.core__art img { width: 100%; height: 100%; object-fit: cover; }
/* плейсхолдер белый — на светлой плашке инвертируем, иначе его не видно */
.core__art.is-empty img { width: 50%; height: 50%; object-fit: contain; filter: invert(1); opacity: .45; }

.core__label { font-weight: 700; font-size: clamp(11px, 3.1cqw, 17px); }

/* ---------- запись в короткой карточке организации ---------- */

.link {
  justify-self: start;
  color: var(--violet);
  font-weight: 700;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.booking { display: grid; gap: 10px; }
.booking__head { font-size: 16px; }

/* ---------- страница персонажа ---------- */

.hero { max-width: 560px; display: grid; gap: 16px; }
.hero .backlink { margin-bottom: 0; }

.hero__art {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  max-height: 54dvh;
  border-radius: var(--r-xl);
  background: var(--card-solid);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero__art img { width: 100%; height: 100%; object-fit: cover; }
.hero__art.is-empty img { width: 34%; height: 34%; object-fit: contain; filter: invert(1); opacity: .3; }

.hero__title { display: grid; gap: 4px; justify-items: center; text-align: center; }
/* имя персонажа придёт от заказчика и может оказаться длинным */
.hero__title h1 { font-size: clamp(22px, 6vw, 30px); overflow-wrap: anywhere; }
.hero__sub { color: var(--ink-dim); font-size: 14px; }

.pointsbar {
  display: grid;
  /* на совсем узких экранах счётчики переносятся, а не сжимаются в кашу */
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: var(--shadow);
  text-align: center;
}
.pointsbar > div { display: grid; gap: 2px; }
.pointsbar__label { font-size: 11.5px; color: var(--ink-mute); }
.pointsbar__value { font-size: 22px; font-weight: 700; }
/* свободные очки — то, чем прокачивают, поэтому выделены */
.pointsbar > div:first-child .pointsbar__value { color: var(--violet); }

.stats { display: grid; gap: 8px; }

.stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
/* раскладка задана явно: порядок в разметке на неё не влияет */
.stat__name  { grid-area: 1 / 1; font-weight: 700; font-size: 15.5px; }
.stat__value { grid-area: 1 / 2; font-weight: 700; font-size: 18px; }
.stat .btn   { grid-area: 1 / 3; }
.stat__pips  { grid-area: 2 / 1 / 3 / 4; display: flex; gap: 3px; }

.stat__pips i {
  flex: 1 1 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(59, 42, 107, .12);
}
.stat__pips i.is-on { background: var(--violet); }

/* ---------- вход и регистрация ---------- */

.auth { max-width: 460px; }

.panel {
  display: grid;
  gap: 16px;
  padding: 20px 18px;
  border-radius: var(--r-xl);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(59, 42, 107, .07);
}
.segmented__btn {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font: 700 14px/1 var(--font);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.segmented__btn.is-active { background: var(--violet); color: #fff; }

.roles { display: grid; gap: 8px; }
.role {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
/* радио нужен только для данных формы; прячем так, чтобы он не занимал
   места — иначе базовое input{width:100%} растягивает страницу */
.role input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  clip-path: inset(50%);
}
.role b { font-size: 15px; }
.role.is-active { border-color: var(--violet); background: rgba(111, 75, 158, .08); }

/* строка-предупреждение под полем (например, «староста уже есть») */
.hint {
  display: flex;
  gap: 9px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-soft);
}
.hint[hidden] { display: none; }
.hint__marker {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--violet);
}

/* ---------- вкладки кабинета ---------- */

.tabs {
  display: flex;
  gap: 8px;
  padding: 4px var(--gutter) 12px;
  overflow-x: auto;
}

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 700 14px/1 var(--font);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tab.is-active { background: var(--violet); color: #fff; }

/* ---------- карточки контента ---------- */

.card {
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.card--accent { background: var(--card-solid); }
.card__head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.card__head h3 { font-size: 17px; }
.card__meta { color: var(--ink-mute); font-size: 13px; margin-bottom: 6px; }
.card__text { color: var(--ink-dim); font-size: 14.5px; margin-bottom: 12px; }

.badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(59, 42, 107, .07);
}
.badge--done    { color: var(--ok); background: rgba(47, 158, 109, .12); }
.badge--current { color: var(--violet); background: rgba(111, 75, 158, .12); }

.notice {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: var(--r-lg);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
.notice__dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--violet);
}
.notice div { display: grid; gap: 3px; font-size: 14px; }
.notice span { color: var(--ink-dim); font-size: 13px; }

/* Кнопки прямо в плашке брони: отменить её можно там же, где она показана.
   Селектор с двумя классами — иначе выигрывает `.notice div` выше. */
.notice .notice__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.hero-stat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 4px; }
.hero-stat > div { display: grid; gap: 2px; }
.hero-stat__label { font-size: 12px; color: var(--ink-mute); }
.hero-stat__value { font-size: 19px; font-weight: 700; }

/* ---------- слоты ---------- */

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.slots--dense { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); margin-top: 6px; }

.slot {
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
.slot__time { font-weight: 700; font-size: 14px; }
.slot__state { font-size: 12px; color: var(--ink-dim); }
.slot .btn { width: 100%; margin-top: 2px; }

.slot--mine { outline: 2px solid var(--violet); outline-offset: -2px; }
.slot--full { opacity: .6; }
.slot--past { opacity: .4; }

.slot--mini { grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; }
.slot--mini .slot__time { font-size: 12.5px; }
.slot--mini .slot__state { grid-column: 1; }
.slot--mini .btn { grid-column: 2; grid-row: 1 / span 2; width: auto; margin: 0; }

.slotrow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.slotrow:last-of-type { border-bottom: 0; }

/* ---------- списки записей ---------- */

.list { display: grid; gap: 8px; }

.item {
  display: grid;
  gap: 6px;
  padding: 13px 15px;
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
.item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item__head b { font-size: 15.5px; }
.item__meta { color: var(--ink-mute); font-size: 12.5px; }
.item__text { color: var(--ink-dim); font-size: 14px; }
.item__actions { margin-top: 2px; }

.status {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status--active    { color: var(--ok);       background: rgba(47, 158, 109, .12); }
.status--completed { color: var(--violet);   background: rgba(111, 75, 158, .12); }
.status--cancelled { color: var(--ink-mute); background: rgba(59, 42, 107, .07); }

.points { font-weight: 700; font-size: 15px; color: var(--ok); }

/* ---------- рейтинг ---------- */

.rank { list-style: none; padding: 0; display: grid; gap: 6px; }
.rank__row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow);
}
.rank__row.is-me { outline: 2px solid var(--violet); outline-offset: -2px; }
.rank__place { font-weight: 700; font-size: 15px; color: var(--ink-mute); text-align: center; }
.rank__place.is-top { color: var(--violet); }
.rank__body { display: grid; gap: 2px; min-width: 0; }
.rank__name { font-weight: 700; font-size: 15px; }
.rank__meta { color: var(--ink-mute); font-size: 12px; }
.rank__stats { display: grid; gap: 2px; text-align: right; }
.rank__points { font-weight: 700; font-size: 16px; }
.rank__level { font-size: 11.5px; color: var(--ink-mute); }

/* ---------- таблицы (только админка) ---------- */

.tablewrap {
  overflow-x: auto;
  margin-inline: -16px;
  padding-inline: 16px;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-mute);
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.is-me td { background: rgba(111, 75, 158, .07); }
td.nowrap { white-space: nowrap; }
td select, td input { min-height: 34px; padding: 5px 9px; font-size: 13px; width: auto; min-width: 110px; }

/* ---------- подтверждения ---------- */
/* Своё окно вместо confirm/prompt: во встроенных браузерах (мессенджеры,
   webview) нативные диалоги подавляются, и кнопка выглядит сломанной. */

.ask {
  width: min(380px, calc(100vw - 32px));
  /* глобальный сброс `* { margin: 0 }` перебивает браузерное margin:auto,
     без которого модальный диалог прижимается к левому верхнему углу */
  margin: auto;
  padding: 20px 18px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--card-solid);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.ask::backdrop { background: rgba(59, 42, 107, .45); }
.ask[open] { animation: sheet-in .2s var(--ease); }

.ask__text { font-size: 15px; line-height: 1.45; }
.ask__form { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }

.ask__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.ask__form .ask__row { margin-top: 0; }

/* ---------- уведомления ---------- */

.flash {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  transform: translate(-50%, 130%);
  width: min(420px, calc(100vw - 32px));
  padding: 13px 16px;
  border-radius: var(--r);
  background: var(--card-solid);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: transform .28s var(--ease), opacity .28s var(--ease);
}
.flash.show { transform: translate(-50%, 0); opacity: 1; }
.flash--err { color: var(--err); }

@media (min-width: 720px) {
  .flash { left: auto; right: 24px; bottom: 24px; transform: translate(0, 130%); }
  .flash.show { transform: translate(0, 0); }
}

/* ---------- доступность ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
