/* «Толкай-ка!» — стили. Тёплые цвета, крупный шрифт, округлые формы, большие кнопки. */

:root {
  --bg: #fff6ea;
  --bg2: #ffe9d1;
  --card: #ffffff;
  --ink: #2a2340;
  --ink-soft: #625a7d;
  --ink-faint: #9c95b3;
  --line: #efe4d6;
  --primary: #ff7a1a;
  --primary-dark: #e05a00;
  --primary-shadow: #c24d00;
  --accent: #7c4dff;
  --good: #1fae5b;
  --good-dark: #168a47;
  --danger: #e8364f;
  --danger-dark: #b82237;
  --gold: #ffc61a;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 2px 0 rgba(42, 35, 64, 0.06), 0 8px 24px rgba(42, 35, 64, 0.08);
  --shadow-lift: 0 4px 0 rgba(42, 35, 64, 0.08), 0 14px 32px rgba(42, 35, 64, 0.14);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --gutter: 16px;
  --sl: max(var(--gutter), env(safe-area-inset-left));
  --sr: max(var(--gutter), env(safe-area-inset-right));
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 138, 0, 0.09) 1.5px, transparent 0),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-size: 26px 26px, 100% 100%;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.has-modal { overflow: hidden; }

body[data-screen="game"] {
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
}

a { color: var(--accent); }
a:hover { color: #5b2fe0; }
img, canvas, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
p { margin: 0; }
kbd {
  display: inline-block;
  min-width: 1.9em;
  padding: 2px 7px;
  margin: 1px 2px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  font: 700 15px/1.3 var(--font);
  text-align: center;
  color: var(--ink);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 12px;
}

.muted { color: var(--ink-soft); }
.small { font-size: 15px; }
.icon { flex: none; }

/* ---------- Загрузка ---------- */

.boot, .loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-soft);
  font-weight: 700;
}
.boot { min-height: 100vh; flex-direction: column; font-size: 20px; }
.loader { padding: 24px 8px; font-size: 16px; }
.boot-dots, .dots { display: inline-flex; gap: 6px; }
.boot-dots i, .dots i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary);
  animation: dot 1s infinite ease-in-out;
}
.boot-dots i:nth-child(2), .dots i:nth-child(2) { animation-delay: 0.15s; background: var(--accent); }
.boot-dots i:nth-child(3), .dots i:nth-child(3) { animation-delay: 0.3s; background: var(--good); }
@keyframes dot { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.boot-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px var(--sr) 20px var(--sl);
}

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

.btn {
  --b-bg: #fff;
  --b-ink: var(--ink);
  --b-sh: #e3d6c6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: 16px;
  background: var(--b-bg);
  color: var(--b-ink);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--b-sh);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.04); color: var(--b-ink); }
.btn:active:not(:disabled), .btn.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--b-sh); }
.btn:disabled { opacity: 0.45; cursor: default; filter: grayscale(0.4); }
.btn-plain { border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn-plain:active:not(:disabled) { box-shadow: 0 1px 0 var(--line); }
.btn-primary { --b-bg: linear-gradient(180deg, #ff9a3d, var(--primary)); --b-ink: #fff; --b-sh: var(--primary-shadow); text-shadow: 0 1px 0 rgba(150, 50, 0, 0.35); }
.btn-good { --b-bg: linear-gradient(180deg, #36c873, var(--good)); --b-ink: #fff; --b-sh: var(--good-dark); }
.btn-danger { --b-bg: linear-gradient(180deg, #ff5a70, var(--danger)); --b-ink: #fff; --b-sh: var(--danger-dark); }
.btn-danger-soft { --b-bg: #fff0f2; --b-ink: var(--danger-dark); --b-sh: #f5c6cd; }
.btn-ghost { --b-bg: transparent; --b-sh: transparent; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 16px; border-radius: 14px; }
.btn-big { min-height: 56px; font-size: 20px; padding: 12px 26px; border-radius: 18px; }
.btn-huge { min-height: 76px; font-size: 26px; padding: 14px 30px; border-radius: 24px; box-shadow: 0 6px 0 var(--b-sh); }
.btn-huge:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--b-sh); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(42, 35, 64, 0.1);
  transition: transform 0.08s ease;
  touch-action: manipulation;
  flex: none;
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(42, 35, 64, 0.1); }
.icon-btn.off { color: var(--ink-faint); }

.link-btn {
  background: none;
  border: 0;
  padding: 10px 8px;
  min-height: 44px;
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.link { font-weight: 700; text-decoration: none; font-size: 16px; }

/* ---------- Карточки, чипы, полоски ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.center-card {
  max-width: 520px;
  margin: 24px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.card-title {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.card-title-note { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.card-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-title-row .card-title { margin: 0; margin-right: auto; }
.card-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.card-actions.start { justify-content: flex-start; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff4e3;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.chip-link { text-decoration: none; background: #efeaff; color: var(--accent); }
.chip-gold { background: #fff2bf; color: #6b4a00; }
.chip-soft { background: #f3f0f8; color: var(--ink-soft); }
.chip-mini { padding: 2px 8px; font-size: 12.5px; }
.chip-warn { background: #ffe3e7; color: var(--danger-dark); }
.me-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold);
  color: #5a3d00;
  font-size: 12px;
  font-weight: 800;
  vertical-align: 2px;
  white-space: nowrap;
}

.bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(42, 35, 64, 0.1);
  overflow: hidden;
}
.bar > i {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--th-a, #ffb547), var(--th-b, var(--primary)));
  transition: width 0.4s ease;
}
.bar-big { height: 18px; margin-top: 14px; }

.stars { display: inline-flex; gap: 1px; line-height: 1; }
.star { color: #ded6ea; font-size: 20px; }
.star.on { color: var(--gold); text-shadow: 0 1px 0 #d99a00; }
.stars-sm .star { font-size: 16px; }

.avatar {
  flex: none;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(42, 35, 64, 0.16);
  background: #fff;
}

/* ---------- Поля ввода ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-weight: 800; font-size: 16px; }
.field-hint { font-size: 14.5px; color: var(--ink-soft); }
.field-error { color: var(--danger-dark); font-weight: 700; font-size: 15px; min-height: 0; }
.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2.5px solid var(--line);
  background: #fffdfa;
  font-size: 19px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 77, 255, 0.15); }
.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 56px; }
.input-addon {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: 0;
  background: none;
  border-radius: 12px;
  color: var(--ink-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.input-addon.on { color: var(--accent); }
.input-search { min-height: 46px; width: auto; flex: 1 1 200px; max-width: 320px; font-size: 17px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 200px; width: auto; }
.form-error {
  display: none;
  margin: 4px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffe8ec;
  color: var(--danger-dark);
  font-weight: 700;
  font-size: 16px;
}
.form-error.show { display: block; }

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #f4eee6;
  border-radius: 16px;
}
.seg {
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink-soft);
}
.seg.active { background: #fff; color: var(--ink); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08); }

.switch-row { display: flex; align-items: center; gap: 12px; font-weight: 700; margin-bottom: 16px; cursor: pointer; min-height: 44px; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  position: relative;
  width: 58px;
  height: 34px;
  border-radius: 999px;
  background: #d8d0e3;
  flex: none;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch-input:checked + .switch { background: var(--good); }
.switch-input:checked + .switch::after { transform: translateX(24px); }
.switch-input:focus-visible + .switch { outline: 3px solid var(--accent); outline-offset: 2px; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  flex: 1 0 auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 17px;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.active { background: linear-gradient(180deg, #ff9a3d, var(--primary)); color: #fff; box-shadow: 0 3px 0 var(--primary-shadow); }

/* ---------- Каркас страницы ---------- */

.page { min-height: 100vh; display: flex; flex-direction: column; }
.page.themed {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.5) 1.5px, transparent 0),
    linear-gradient(180deg, var(--th-bg1) 0%, var(--th-bg2) 70%, var(--bg) 100%);
  background-size: 26px 26px, 100% 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 248, 238, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(42, 35, 64, 0.06);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--sr) 8px var(--sl);
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  font-weight: 900;
  font-size: 23px;
  letter-spacing: -0.3px;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}
.brand:hover { color: var(--ink); }
.brand-name {
  background: linear-gradient(90deg, #ff7a1a, #ff4d6d 55%, #7c4dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.topnav { display: flex; align-items: center; gap: 8px; }
.user-area { display: flex; align-items: center; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(42, 35, 64, 0.1);
  color: var(--ink);
  text-decoration: none;
  max-width: 190px;
}
.user-chip:hover { color: var(--ink); }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.user-chip-name { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-points { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }

.page-main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px var(--sr) 28px var(--sl);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page-title { font-size: 30px; font-weight: 900; letter-spacing: -0.4px; }
.page-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  padding: 14px var(--sr) calc(18px + env(safe-area-inset-bottom)) var(--sl);
  font-size: 15px;
  color: var(--ink-soft);
}
.page-foot a { color: var(--ink-soft); font-weight: 700; text-decoration: none; padding: 8px 2px; }
.page-foot a:hover { color: var(--accent); }
.foot-site { padding: 8px 2px; opacity: 0.8; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title { font-size: 24px; font-weight: 900; }
.section-note { color: var(--ink-soft); font-weight: 700; font-size: 15px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 10px; }
.empty-title { font-size: 24px; font-weight: 900; }
.empty-text { color: var(--ink-soft); max-width: 420px; }

/* Приглашение войти вместо таблицы, профилей и рекордов */
.members-teaser { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 6px 4px; }
.members-teaser-text { font-size: 19px; font-weight: 800; line-height: 1.3; max-width: 340px; }
.members-teaser-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.members-teaser-actions .btn { min-width: 132px; }

/* ---------- Главная ---------- */

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr);
  grid-template-areas: "hero lb" "guest guest" "chapters chapters";
  gap: 18px;
}
.hero { grid-area: hero; }
.lb-snippet { grid-area: lb; }
.home-guest { grid-area: guest; }
.home-chapters { grid-area: chapters; }

.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 26px;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 210, 120, 0.45), transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(124, 77, 255, 0.12), transparent 50%),
    #fff;
  overflow: hidden;
}
.hero-bip { position: relative; display: flex; flex-direction: column; align-items: center; flex: none; }
.bip-canvas, .hero-canvas, .mascot-canvas { cursor: pointer; flex: none; }
.bubble {
  position: relative;
  max-width: 220px;
  padding: 10px 14px;
  margin-bottom: 4px;
  border-radius: 18px;
  background: #fff4dd;
  border: 2px solid #ffd9a0;
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.3;
  text-align: center;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -11px;
  margin-left: -10px;
  border: 10px solid transparent;
  border-top-color: #ffd9a0;
  border-bottom: 0;
}
.hero-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; flex: 1; }
.hero-title {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(90deg, #ff7a1a, #ff4d6d 50%, #7c4dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 2px;
}
.hero-sub { color: var(--ink-soft); font-weight: 600; }
.play-btn { justify-content: flex-start; gap: 14px; padding-left: 18px; white-space: normal; text-align: left; align-self: flex-start; min-width: min(100%, 320px); }
.play-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  flex: none;
}
.play-text { display: flex; flex-direction: column; gap: 2px; }
.play-label { font-size: 28px; }
.play-sub { font-size: 15px; font-weight: 700; opacity: 0.95; text-shadow: none; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px; }

.guest-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #efe8ff, #e4f7ff);
  border: 2px dashed #b9a6ff;
}
.guest-banner-emoji { font-size: 34px; }
.guest-banner-text { flex: 1; font-size: 16px; }
.guest-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; }
.ch-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  box-shadow: 0 5px 0 rgba(42, 35, 64, 0.1), 0 10px 22px rgba(42, 35, 64, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.ch-card:hover { transform: translateY(-3px) rotate(-0.4deg); color: var(--ink); box-shadow: 0 8px 0 rgba(42, 35, 64, 0.1), 0 16px 30px rgba(42, 35, 64, 0.12); }
a.ch-card:active { transform: translateY(2px); }
.ch-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1;
}
.ch-num {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
}
.ch-done, .ch-lock {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  font-weight: 900;
  color: var(--good);
}
.ch-lock { color: var(--ink-soft); }
.ch-emoji {
  display: grid;
  place-items: center;
  height: 104px;
  font-size: 58px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 55%),
    linear-gradient(145deg, var(--th-a), var(--th-b));
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.18);
}
.ch-title { font-weight: 900; font-size: 20px; padding: 10px 14px 0; }
.ch-bottom { padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.ch-stats { display: flex; justify-content: space-between; font-weight: 800; font-size: 15px; color: var(--ink-soft); }
.ch-card .bar { height: 10px; }
.ch-card.locked { cursor: default; }
.ch-card.locked .ch-emoji { filter: grayscale(0.85) brightness(1.08); opacity: 0.75; }
.ch-locked-text { padding: 6px 14px 14px; font-size: 14.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.3; }
.ch-card.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.lb-mini { display: flex; flex-direction: column; gap: 6px; }
.lb-mini-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 52px;
  border-radius: 14px;
  background: #fbf7f1;
  color: var(--ink);
  text-decoration: none;
}
.lb-mini-row:hover { background: #fff1de; color: var(--ink); }
.lb-mini-row.me { background: #fff3c4; }
.lb-medal { font-size: 26px; width: 32px; text-align: center; flex: none; font-weight: 900; }
.lb-mini-name { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-mini-pts { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.lb-mini-pts small { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.lb-mini-empty { color: var(--ink-soft); padding: 12px 4px; font-weight: 600; font-size: 16px; }

/* ---------- Глава ---------- */

.ch-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.ch-head-top { display: flex; align-items: center; gap: 14px; }
.ch-head-emoji {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  border-radius: 24px;
  font-size: 46px;
  flex: none;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.45), transparent 55%),
    linear-gradient(145deg, var(--th-a), var(--th-b));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
}
.ch-head-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ch-head-num { font-weight: 800; color: var(--ink-soft); font-size: 15px; }
.ch-head-title { font-size: 32px; font-weight: 900; overflow-wrap: anywhere; }
.ch-head-stats { display: flex; gap: 18px; flex-wrap: wrap; font-weight: 800; color: var(--ink-soft); font-size: 16px; }
.ch-head-nav { display: flex; gap: 8px; flex: none; }
.ch-head .icon-btn { background: #f5f0ea; }

.lock-note {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #fff8e6;
  border: 2px solid #ffe2a3;
  box-shadow: none;
}
.lock-note-icon { font-size: 32px; }
.lock-note > div { flex: 1 1 220px; }

.lt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.lt {
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  border: 3px solid transparent;
  box-shadow: 0 4px 0 rgba(42, 35, 64, 0.08), 0 6px 16px rgba(42, 35, 64, 0.06);
  transition: transform 0.12s ease;
}
a.lt:hover { transform: translateY(-2px); color: var(--ink); }
a.lt:active { transform: translateY(2px); }
.lt-pic {
  position: relative;
  aspect-ratio: 10 / 7;
  background: linear-gradient(180deg, var(--th-bg1), var(--th-bg2));
}
.lt-thumb { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; }
@supports not (aspect-ratio: 1 / 1) {
  .lt-pic { height: 0; padding-top: 70%; }
}
.lt-num {
  min-width: 34px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #f3eee8;
  font-weight: 900;
  font-size: 15px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.lt.solved .lt-num { background: var(--good); color: #fff; }
.lt.perfect .lt-num { background: linear-gradient(180deg, #ffd84d, #ffb300); color: #5a3d00; }
.lt-play, .lt-lock {
  position: absolute;
  right: 6px;
  top: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 0 var(--primary-shadow);
}
.lt-lock { background: rgba(255, 255, 255, 0.9); color: var(--ink-soft); box-shadow: none; }
.lt.next { border-color: var(--primary); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 0%, 100% { box-shadow: 0 4px 0 rgba(42, 35, 64, 0.08), 0 0 0 0 rgba(255, 122, 26, 0.35); } 50% { box-shadow: 0 4px 0 rgba(42, 35, 64, 0.08), 0 0 0 6px rgba(255, 122, 26, 0.15); } }
.lt.locked { opacity: 0.6; filter: grayscale(0.6); }
.lt-info { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 7px 8px 2px; }
.lt-best { padding: 0 8px 8px; font-size: 13px; font-weight: 800; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-best.started { color: var(--primary-dark); }

/* ---------- Экран игры ---------- */

.game {
  --g-ink: var(--ink);
  --g-soft: var(--ink-soft);
  --g-plate: rgba(255, 255, 255, 0.78);
  --dp: 60px;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  height: var(--app-h, 100vh);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "head head" "stats stats" "stage stage" "btns dpad";
  gap: 8px 10px;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  color: var(--g-ink);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.55) 1.5px, transparent 0),
    linear-gradient(180deg, var(--th-bg1), var(--th-bg2));
  background-size: 24px 24px, 100% 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
.game.dark {
  --g-ink: #fff;
  --g-soft: rgba(255, 255, 255, 0.75);
  --g-plate: rgba(255, 255, 255, 0.12);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.22) 1px, transparent 0),
    linear-gradient(180deg, var(--th-bg1), var(--th-bg2));
}
.game[data-theme="space"] {
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 20%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 80%, #ffe9a8, transparent),
    radial-gradient(1px 1px at 85% 65%, #fff, transparent),
    radial-gradient(1px 1px at 10% 70%, #cfe3ff, transparent),
    radial-gradient(2px 2px at 55% 50%, rgba(255, 255, 255, 0.7), transparent),
    linear-gradient(180deg, var(--th-bg1), var(--th-bg2));
  background-size: 180px 180px, 230px 230px, 260px 260px, 200px 200px, 150px 150px, 320px 320px, 100% 100%;
}
.game[data-theme="ocean"] {
  background-image:
    radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.35) 0 6px, transparent 7px),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.3) 0 4px, transparent 5px),
    radial-gradient(circle at 60% 70%, rgba(255, 255, 255, 0.25) 0 3px, transparent 4px),
    linear-gradient(180deg, var(--th-bg1), var(--th-bg2));
  background-size: 140px 160px, 190px 170px, 120px 130px, 100% 100%;
}
.g-controls { display: contents; }
.g-head { grid-area: head; display: flex; align-items: center; gap: 10px; min-width: 0; }
.g-title { flex: 1; min-width: 0; }
.g-level { font-size: 22px; font-weight: 900; line-height: 1.1; }
.g-sub { display: flex; flex-wrap: wrap; column-gap: 8px; font-size: 14px; font-weight: 700; color: var(--g-soft); line-height: 1.25; }
.g-sub > span { white-space: nowrap; }
.g-head-actions { display: flex; gap: 8px; flex: none; }
.game .icon-btn { background: var(--g-plate); color: var(--g-ink); }
.game.dark .icon-btn { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); }
.game .icon-btn.off { color: var(--g-soft); }

.g-stats { grid-area: stats; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 4px 6px;
  border-radius: 14px;
  background: var(--g-plate);
  line-height: 1.1;
  min-width: 0;
}
.stat-label { font-size: 12px; font-weight: 800; color: var(--g-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.stat-val { font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-best .stat-val { color: var(--good-dark); }
.game.dark .stat-best .stat-val { color: #7dffb0; }

.g-stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  min-width: 0;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  touch-action: none;
  overflow: hidden;
}
.game.dark .g-stage { background: rgba(0, 0, 0, 0.18); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06); }
.board { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.g-hint, .g-first-hint, .g-winbar {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}
.g-hint { bottom: 12px; background: #fff0f0; color: #b3182c; border: 2px solid #ffb3bd; white-space: normal; width: max-content; border-radius: 22px; }
.g-hint.show { opacity: 1; transform: translate(-50%, 0); }
.g-first-hint { top: 12px; opacity: 1; transform: translate(-50%, 0); background: #fff; color: var(--ink); white-space: normal; width: max-content; }
.g-first-hint.hide { opacity: 0; transform: translate(-50%, -10px); }
.g-winbar { top: 12px; display: flex; align-items: center; gap: 12px; background: #fff; color: var(--ink); padding: 6px 6px 6px 18px; }
.g-winbar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.g-buttons { grid-area: btns; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto minmax(0, 1fr); gap: 8px; align-content: end; }
.game:not(.with-dpad) .g-buttons { grid-column: 1 / -1; }
.g-btn { min-height: 52px; padding: 8px 10px; font-size: 16px; gap: 6px; }
.g-btn-icon { width: 56px; padding: 8px; }
.g-btn-icon.active { --b-bg: #efe8ff; --b-ink: var(--accent); --b-sh: #d6c9ff; }
.g-btn-undo { --b-bg: linear-gradient(180deg, #fff, #fff4e6); --b-ink: var(--primary-dark); --b-sh: #f0c9a0; }
.game.dark .g-btn-undo { --b-sh: rgba(0, 0, 0, 0.45); }
.game.dpad-left { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "head head" "stats stats" "stage stage" "dpad btns"; }
.game.dpad-left .g-btn-restart { order: 1; }
.game.dpad-left .g-btn-levels { order: 2; }
.game.dpad-left .g-btn-undo { order: 3; }
.game.dpad-left .g-btn-dpad { order: 4; }
.game.dark .g-btn { --b-sh: rgba(0, 0, 0, 0.45); }

.dpad {
  grid-area: dpad;
  display: none;
  grid-template-columns: repeat(3, var(--dp));
  grid-template-rows: repeat(3, var(--dp));
  gap: 5px;
  align-self: end;
  touch-action: none;
}
.game.with-dpad .dpad { display: grid; }
.dp {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(42, 35, 64, 0.16);
  cursor: pointer;
  touch-action: none;
  padding: 0;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.game.dark .dp { box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45); }
.dp.pressed { transform: translateY(4px); box-shadow: 0 1px 0 rgba(42, 35, 64, 0.16); background: var(--th-soft, #fff3e3); }
.dp-u { grid-column: 2; grid-row: 1; }
.dp-l { grid-column: 1; grid-row: 2; }
.dp-r { grid-column: 3; grid-row: 2; }
.dp-d { grid-column: 2; grid-row: 3; }
.dp-center { grid-column: 2; grid-row: 2; border-radius: 50%; margin: 14px; background: var(--g-plate); }
.dp-tri {
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 17px solid var(--ink);
}
.dp-d .dp-tri { transform: rotate(180deg); }
.dp-l .dp-tri { transform: rotate(-90deg); }
.dp-r .dp-tri { transform: rotate(90deg); }

/* С крестиком на телефоне: кнопки 2×2 слева, крестик справа */
.game.with-dpad .g-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: end; }
.game.with-dpad .g-btn { flex-direction: column; gap: 2px; min-height: calc(var(--dp) * 1.5 - 4px); font-size: 14px; }
.game.with-dpad .g-btn-icon { width: auto; }

/* Альбомная ориентация и широкие экраны: панель слева, поле в центре, крестик справа */
@media (min-aspect-ratio: 5/4) {
  .game {
    grid-template-columns: minmax(210px, 280px) minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "head stage dpad" "stats stage dpad" "btns stage dpad";
    gap: 10px 14px;
  }
  .game:not(.with-dpad) .g-buttons { grid-column: auto; }
  .game.dpad-left { grid-template-columns: auto minmax(0, 1fr) minmax(210px, 280px); grid-template-areas: "dpad stage head" "dpad stage stats" "dpad stage btns"; }
  .g-head { flex-wrap: wrap; align-items: flex-start; }
  .g-title { order: 3; flex-basis: 100%; }
  .g-head-actions { margin-left: auto; }
  .g-sub { flex-direction: column; }
  .g-level { font-size: 26px; }
  .g-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 8px; }
  .stat { padding: 8px 6px; }
  .stat-val { font-size: 24px; }
  .g-buttons, .game.with-dpad .g-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: end; }
  .g-btn, .game.with-dpad .g-btn { flex-direction: column; gap: 4px; min-height: 76px; font-size: 15px; }
  .g-btn-icon, .game.with-dpad .g-btn-icon { width: auto; }
}
@media (min-aspect-ratio: 5/4) and (max-height: 500px) {
  .game { --dp: 54px; gap: 6px 10px; }
  .g-level { font-size: 20px; }
  .g-sub { font-size: 12.5px; }
  .stat { padding: 3px 4px; }
  .stat-val { font-size: 18px; }
  .stat-label { font-size: 10.5px; }
  .g-btn, .game.with-dpad .g-btn { min-height: 50px; font-size: 13px; padding: 4px; }
  .g-btn .icon { width: 20px; height: 20px; }
  .g-head .icon-btn { width: 42px; height: 42px; }
}
@media (max-width: 380px) {
  .game { --dp: 54px; }
  .g-btn-label { font-size: 14px; }
  .g-level { font-size: 20px; }
}
@media (max-aspect-ratio: 5/4) and (max-height: 700px) {
  .game { --dp: 50px; }
  .stat-val { font-size: 18px; }
  .game.with-dpad .g-btn { min-height: 70px; }
}

/* ---------- Окна ---------- */

.modal-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) var(--sr) max(16px, env(safe-area-inset-bottom)) var(--sl);
  background: rgba(30, 20, 56, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-backdrop.modal-out { animation: fade-out 0.18s ease forwards; }
.modal {
  position: relative;
  width: min(100%, 460px);
  margin: auto;
  padding: 26px 22px 20px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 10, 40, 0.35);
  animation: pop-in 0.26s cubic-bezier(0.2, 1.4, 0.4, 1);
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}
.modal-out .modal { animation: pop-out 0.18s ease forwards; }
.modal-x { position: absolute; top: 10px; right: 10px; background: #f6f1ea; box-shadow: none; }
.modal-emoji { font-size: 46px; line-height: 1; margin-bottom: 6px; }
.modal-title { font-size: 26px; font-weight: 900; margin: 0 30px 10px; }
.modal-text { color: var(--ink-soft); font-size: 18px; margin-bottom: 4px; }
.modal-body { text-align: center; }
.modal-body .field { text-align: left; margin-top: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 140px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { transform: scale(0.85) translateY(20px); opacity: 0; } }
@keyframes pop-out { to { transform: scale(0.92); opacity: 0; } }

/* Победа */
.win-modal { width: min(100%, 480px); }
.win { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.win-cat { margin: -14px 0 -6px; }
.win-stars { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: -4px 0 4px; }
.win-star { font-size: 56px; line-height: 1; color: #e9e2f2; }
.win-star:nth-child(2) { font-size: 72px; margin-bottom: 10px; }
.win-star.on {
  color: var(--gold);
  text-shadow: 0 3px 0 #dc9a00, 0 0 22px rgba(255, 198, 26, 0.55);
  animation: star-pop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  animation-delay: var(--d, 0s);
}
@keyframes star-pop {
  0% { transform: scale(0) rotate(-50deg); opacity: 0; }
  70% { transform: scale(1.25) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
.win-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.win-chip { padding: 6px 12px; border-radius: 999px; background: #f6f1ea; font-weight: 800; font-size: 15.5px; }
.win-points {
  font-size: 30px;
  font-weight: 900;
  color: var(--primary-dark);
  animation: pop-in 0.4s 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.win-points.muted { font-size: 18px; color: var(--ink-soft); }
.win-status { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center; }
.win-status .loader { padding: 4px; }
.win-record {
  padding: 10px 18px;
  border-radius: 16px;
  background: linear-gradient(90deg, #ffe680, #ffc94d);
  color: #6b4500;
  font-weight: 900;
  font-size: 19px;
  box-shadow: 0 3px 0 #e2a300;
  animation: wiggle 0.9s ease 0.5s both;
}
@keyframes wiggle {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.08) rotate(-3deg); opacity: 1; }
  60% { transform: rotate(3deg); }
  80% { transform: rotate(-1deg); }
  100% { transform: none; }
}
.win-note { font-weight: 700; font-size: 16px; color: var(--ink-soft); }
.win-note.good { color: var(--good-dark); }
.win-note.warn { color: #7a4cc2; background: #f1ebff; padding: 8px 14px; border-radius: 14px; }
.win-guest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #eefaf2;
  font-size: 15.5px;
  font-weight: 600;
}
.win-tip { font-size: 15px; color: var(--ink-soft); font-weight: 600; }
.win-links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.win-badges { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.win-badges:empty { display: none; }
.win-badges-title { font-weight: 900; color: var(--accent); }
.badge-pop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(90deg, #f3edff, #fff6e0);
  text-align: left;
  animation: pop-in 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both;
  animation-delay: var(--d, 0s);
}
.badge-pop-icon { font-size: 34px; }
.badge-pop-text { display: flex; flex-direction: column; line-height: 1.2; }
.badge-pop-text small { color: var(--ink-soft); font-size: 14px; }

/* Рекорды уровня */
.rec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.rec-row {
  display: grid;
  grid-template-columns: 34px 32px minmax(0, 1fr) auto;
  grid-template-areas: "rank av name moves" "rank av extra moves";
  align-items: center;
  column-gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #fbf7f1;
}
.rec-row.me { background: #fff3c4; }
.rec-rank { grid-area: rank; font-size: 22px; text-align: center; font-weight: 900; }
.rec-row .avatar { grid-area: av; }
.rec-name { grid-area: name; font-weight: 800; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-extra { grid-area: extra; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.rec-moves { grid-area: moves; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.rec-moves b { font-size: 20px; }
.rec-moves small { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.rec-foot { margin-top: 12px; color: var(--ink-soft); font-weight: 700; font-size: 15px; }

/* ---------- Тосты ---------- */

#toasts {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(calc(100vw - 32px), 460px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 18px;
  background: #2f2752;
  color: #fff;
  font-weight: 700;
  font-size: 16.5px;
  line-height: 1.3;
  box-shadow: 0 10px 30px rgba(20, 10, 40, 0.3);
  pointer-events: auto;
  cursor: pointer;
  animation: toast-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.toast-error { background: #d6304b; }
.toast-success { background: #179a50; }
.toast-offline { background: #5b47c4; }
.toast-warn { background: #b86b00; }
.toast-emoji { font-size: 22px; }
.toast-out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in { from { transform: translateY(-20px) scale(0.95); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-14px); opacity: 0; } }

#fx { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; z-index: 150; pointer-events: none; }

/* ---------- Таблица участников ---------- */

.lb-card { padding: 10px; }
.lb-table { display: flex; flex-direction: column; gap: 4px; }
.lb-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) repeat(5, 78px);
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px 12px;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
}
a.lb-row:hover { background: #fff1de; color: var(--ink); }
a.lb-row:nth-child(odd) { background: #fbf7f1; }
a.lb-row:nth-child(odd):hover { background: #fff1de; }
.lb-row.top1 { background: linear-gradient(90deg, #fff4c4, #fffaf0) !important; }
.lb-row.me { box-shadow: inset 0 0 0 3px var(--gold); background: #fff7d6 !important; }
.lb-header { min-height: 40px; font-size: 13px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.lb-c-rank { text-align: center; font-weight: 900; font-size: 20px; }
.medal { font-size: 30px; line-height: 1; }
.lb-c-player { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lb-name { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; }
.lb-name-text { font-weight: 800; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lb-c-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-c-num.main { font-weight: 900; color: var(--primary-dark); font-size: 19px; }
.lb-header .lb-c-num { font-weight: 800; }
.lb-mobile-sub, .lb-mobile-main { display: none; }
.lb-foot { color: var(--ink-soft); font-size: 15px; text-align: center; font-weight: 600; }

@media (max-width: 760px) {
  .lb-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 8px 10px; }
  .lb-row .lb-c-num, .lb-header { display: none; }
  .lb-mobile-sub { display: block; flex-basis: 100%; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lb-mobile-main { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
  .lb-mobile-main b { font-size: 21px; color: var(--primary-dark); }
  .lb-mobile-main small { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
  .lb-c-player { gap: 10px; }
  .lb-name-text { font-size: 17px; }
  .medal { font-size: 26px; }
}

/* ---------- Профиль ---------- */

.profile { display: flex; flex-direction: column; gap: 18px; }
.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
  background:
    radial-gradient(circle at 10% 30%, rgba(255, 210, 120, 0.35), transparent 50%),
    #fff;
}
.profile-bip { flex: none; }
.profile-id { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 14px; }
.profile-name { font-size: 34px; font-weight: 900; overflow-wrap: anywhere; }
.profile-hero { font-weight: 800; color: var(--ink-soft); font-size: 16px; }
.profile-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 8px;
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}
.stat-tile-emoji { font-size: 26px; }
.stat-tile-val { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-tile-label { font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.profile-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ch-progress { display: flex; flex-direction: column; gap: 10px; }
.chp-row { display: grid; grid-template-columns: 30px minmax(70px, 1fr) minmax(60px, 1.4fr) auto auto; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.chp-emoji { font-size: 22px; text-align: center; }
.chp-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chp-num { font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }
.chp-stars { color: var(--ink-soft); font-size: 14px; min-width: 50px; text-align: right; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 20px;
  text-align: center;
}
.badge.earned { background: linear-gradient(160deg, #fff6d9, #ffe9f1); box-shadow: 0 3px 0 rgba(255, 170, 60, 0.35); }
.badge.locked { background: #f5f3f8; }
.badge.locked .badge-icon { filter: grayscale(1); opacity: 0.35; }
.badge.locked .badge-title { color: var(--ink-faint); }
.badge-icon { font-size: 40px; line-height: 1.1; }
.badge-title { font-weight: 900; font-size: 16px; line-height: 1.2; }
.badge-desc { font-size: 13px; color: var(--ink-soft); font-weight: 600; line-height: 1.25; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "lv stars moves" "at at at";
  align-items: center;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fbf7f1;
  color: var(--ink);
  text-decoration: none;
}
.recent-row:hover { background: #fff1de; color: var(--ink); }
.recent-lv { grid-area: lv; font-weight: 800; }
.recent-row .stars { grid-area: stars; }
.recent-moves { grid-area: moves; font-weight: 700; color: var(--ink-soft); font-size: 15px; }
.recent-at { grid-area: at; font-size: 13px; color: var(--ink-faint); font-weight: 600; }

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

.auth-card { width: 100%; max-width: 460px; margin: 8px auto; display: flex; flex-direction: column; }
.auth-card.shake, form.shake { animation: shake 0.4s ease; }
.auth-wide { max-width: 680px; }
.auth-bip { display: flex; justify-content: center; margin: -6px 0 2px; }
.auth-title { font-size: 30px; font-weight: 900; text-align: center; margin-bottom: 16px; }
.auth-alt { text-align: center; margin-top: 16px; font-weight: 600; }
.auth-alt a { font-weight: 800; }
.auth-note { text-align: center; margin-top: 10px; font-size: 15px; color: var(--ink-soft); }
.auth-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.hero-picker { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: center; }
.hp-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 22px;
  background: radial-gradient(circle at 50% 40%, #fff7e6, #ffe6c2);
}
.hp-name { font-weight: 900; font-size: 18px; text-align: center; }
.hp-caption { font-size: 14px; color: var(--ink-soft); text-align: center; }
.hero-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hero-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 8px 4px 9px;
  border: 0;
  border-radius: 18px;
  background: #f8f3ec;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}
.hero-opt:hover { transform: translateY(-2px); background: #fff3e2; }
.hero-opt.sel { background: #fff; box-shadow: 0 0 0 3px var(--primary), 0 6px 14px rgba(255, 122, 26, 0.25); }
.hero-opt-pic { width: 64px; height: 64px; }
.hero-opt-name { font-size: 13.5px; font-weight: 800; line-height: 1.15; text-align: center; color: var(--ink); }

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

.settings-page .page-main { max-width: 820px; }
.pass-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-of-type { border-bottom: 0; }
.setting-label { font-weight: 800; }

/* ---------- Админка ---------- */

.adm-table { display: flex; flex-direction: column; gap: 4px; }
.adm-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) 80px 90px 150px 120px;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 10px;
  border-radius: 14px;
}
.adm-row:nth-child(even) { background: #fbf7f1; }
.adm-row.me { background: #fff7d6; }
.adm-header { min-height: 36px; font-size: 13px; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; }
.adm-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.adm-name { font-weight: 800; color: var(--ink); text-decoration: none; }
.adm-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.adm-seen { font-size: 14px; color: var(--ink-soft); }
.adm-act { text-align: right; }
.adm-mobile-meta { display: none; }
.act-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.act-btn { justify-content: flex-start; gap: 12px; }
@media (max-width: 760px) {
  .adm-row { grid-template-columns: minmax(0, 1fr) auto; }
  .adm-header, .adm-row > .num, .adm-row > .adm-seen { display: none; }
  .adm-mobile-meta { display: block; flex-basis: 100%; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
}

/* ---------- Как играть ---------- */

.help-page .page-main { max-width: 960px; }
.help-intro { display: flex; align-items: center; gap: 18px; }
.lead { font-size: 19px; margin-top: 8px; font-weight: 600; }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.rule { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 20px; background: #fbf7f1; }
.rule-pic { position: relative; display: flex; justify-content: center; align-items: center; min-height: 112px; border-radius: 16px; background: linear-gradient(180deg, #fff, #f6efe6); }
.rule-mark {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  background: var(--good);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.rule-no .rule-mark { background: var(--danger); }
.rule-warn .rule-mark { background: #ff9800; }
.rule-text h3 { font-size: 19px; font-weight: 900; margin-bottom: 4px; }
.rule-text p { color: var(--ink-soft); font-size: 16px; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.controls-col h3 { font-size: 18px; margin-bottom: 8px; }
.keys { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 16.5px; }
.stars-explain { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.se-row { display: flex; align-items: center; gap: 14px; font-weight: 700; padding: 8px 12px; border-radius: 14px; background: #fbf7f1; }
.se-stars { color: var(--gold); font-size: 26px; letter-spacing: 1px; min-width: 92px; text-shadow: 0 1px 0 #d99a00; }
.se-stars .off { color: #e1d9ec; text-shadow: none; }
.help-page .card p + p { margin-top: 10px; }
.help-site { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.help-site .card-title { margin-bottom: 6px; }

/* ---------- Телефоны ---------- */

@media (max-width: 860px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "guest" "chapters" "lb"; }
  .profile-cols { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .brand { font-size: 20px; }
  .brand .mini-bip { width: 36px !important; height: 36px !important; }
  .topnav { gap: 6px; }
  .icon-btn { width: 44px; height: 44px; }
  .user-chip { max-width: 140px; padding-right: 10px; }
  .page-main { padding-top: 14px; gap: 14px; }
  .page-title { font-size: 25px; }
  .card { padding: 16px; border-radius: 20px; }
  .hero { flex-direction: column; text-align: center; padding: 16px 16px 20px; gap: 6px; }
  .hero-main { align-items: center; gap: 10px; }
  .hero-title { font-size: 38px; }
  .hero-sub { font-size: 16px; }
  .play-btn { align-self: stretch; }
  .hero-stats { justify-content: center; }
  .bubble { max-width: 260px; }
  .guest-banner { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .guest-banner-emoji { display: none; }
  .guest-banner-actions { width: 100%; }
  .guest-banner-actions .btn { flex: 1; }
  .ch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .ch-emoji { height: 86px; font-size: 46px; }
  .ch-title { font-size: 18px; padding: 8px 12px 0; }
  .ch-bottom { padding: 6px 12px 12px; }
  .ch-locked-text { padding: 6px 12px 12px; font-size: 13.5px; }
  .ch-stats { font-size: 14px; }
  .ch-head { padding: 12px 14px 14px; gap: 10px; }
  .ch-head-top { gap: 10px; }
  .ch-head-emoji { width: 56px; height: 56px; font-size: 32px; border-radius: 16px; }
  .ch-head-title { font-size: 24px; }
  .ch-head-nav .icon-btn { width: 40px; height: 44px; }
  .ch-head-stats { font-size: 15px; gap: 14px; }
  .lt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .lt { border-radius: 16px; }
  .lt-info { padding: 6px 6px 1px; }
  .lt-best { padding: 0 6px 7px; font-size: 12.5px; }
  .lt-num { font-size: 14px; min-width: 28px; padding: 1px 5px; }
  .stars-sm .star { font-size: 14px; }
  .tab-emoji { display: none; }
  .badge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .badge { padding: 10px 5px; border-radius: 16px; }
  .badge-icon { font-size: 30px; }
  .badge-title { font-size: 13.5px; }
  .badge-desc { font-size: 11.5px; }
  .stat-tiles { gap: 8px; }
  .stat-tile { padding: 10px 4px; }
  .stat-tile-val { font-size: 22px; }
  .profile-head { flex-direction: column; text-align: center; }
  .profile-name-row { justify-content: center; }
  .profile-name { font-size: 28px; }
  .profile-meta, .profile-actions { justify-content: center; }
  .chp-row { grid-template-columns: 26px minmax(0, 1fr) auto auto; font-size: 15px; }
  .chp-bar { grid-column: 2 / -1; grid-row: 2; }
  .hero-picker { grid-template-columns: 1fr; gap: 10px; }
  .hp-preview { flex-direction: row; justify-content: center; gap: 12px; padding: 6px 8px; }
  .hp-preview .hero-canvas { width: 110px !important; height: 121px !important; }
  .hero-opt-pic { width: 56px; height: 56px; }
  .hero-opt-name { font-size: 12.5px; }
  .pass-grid { grid-template-columns: 1fr; }
  .controls-grid { grid-template-columns: 1fr; }
  .help-intro { flex-direction: column; text-align: center; }
  .modal { padding: 22px 16px 16px; border-radius: 24px; }
  .modal-title { font-size: 23px; }
  .win-star { font-size: 48px; }
  .win-star:nth-child(2) { font-size: 62px; }
  .tab { font-size: 15.5px; padding: 8px 10px; }
  .lb-card { padding: 6px; }
}

@media (max-width: 360px) {
  .brand-name { font-size: 18px; }
  .user-chip-text { display: none; }
  .user-chip { padding-right: 6px; }
  .ch-grid { gap: 10px; }
}

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