/* Мир Баловней — неряшливый "детская тетрадка + маркер" стиль. См. docs/DESIGN.md */

:root {
  --paper: #f4ecd3;
  --ink: #2b2118;
  --pink: #ff5d8f;
  --yellow: #ffd23f;
  --teal: #2ec4b6;
  --violet: #8d6bd6;
  --gold: #ffd23f;
  --silver: #cfd8e0;
  --bronze: #e8935c;
  --line: #2b2118;        /* рамки и жёсткие тени (текст — --ink) */
  --on-accent: #2b2118;   /* текст на жёлтых/золотых заливках */
  --shade-rgb: 43, 33, 24;
  --surface: #fffdf2;
  --surface-2: #fff;
  --note: #fff6b8;
  --muted: #6f6256;
  --muted-2: #8b7d6e;
  --muted-3: #9b8d7e;
  --placeholder: #a89a8a;
  --tint-pink: #ffb3cb;
  --tint-teal: #a8ece4;
  --name-shadow: #fff;
  --glow: var(--yellow);  /* ступенька тени у больших чисел */
  --stripe: rgba(255, 210, 63, .55);
  --font-title: 'Rubik Dirt', 'Impact', sans-serif;
  --font-hand: 'Neucha', 'Comic Sans MS', cursive;
  --font-script: 'Marck Script', 'Comic Sans MS', cursive;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 20px;
  /* бумага: пятна, кофейное кольцо, линейки тетради */
  background:
    radial-gradient(circle at 92% 14%, transparent 0 46px, rgba(120, 72, 30, .22) 47px 50px, transparent 52px),
    radial-gradient(circle at 8% 78%, rgba(255, 93, 143, .13) 0 90px, transparent 91px),
    radial-gradient(circle at 85% 70%, rgba(46, 196, 182, .13) 0 120px, transparent 121px),
    radial-gradient(circle at 20% 12%, rgba(255, 210, 63, .22) 0 110px, transparent 111px),
    repeating-linear-gradient(to bottom, transparent 0 33px, rgba(70, 110, 190, .18) 33px 35px),
    var(--paper);
  background-attachment: fixed;
}

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

/* ---------- шапка ---------- */
.hero { text-align: center; }

.title {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(54px, 13vw, 128px);
  line-height: .95;
  letter-spacing: 1px;
  color: var(--pink);
  transform: rotate(-2.5deg);
  text-shadow: 4px 4px 0 var(--glow), 8px 8px 0 var(--line);
}
.title span:nth-child(1) { display: inline-block; transform: rotate(3deg) translateY(-4px); color: var(--teal); }
.title span:nth-child(2) { display: inline-block; transform: rotate(-1.5deg); }

.quote {
  position: relative;
  display: inline-block;
  max-width: 640px;
  margin: 34px auto 6px;
  padding: 18px 26px 16px;
  font-family: var(--font-script);
  font-size: clamp(22px, 3.6vw, 32px);
  line-height: 1.25;
  color: var(--ink);
  transform: rotate(1.2deg);
  isolation: isolate;
}
.quote::before { /* смятый стикер под текстом */
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--note);
  box-shadow: 5px 6px 0 rgba(var(--shade-rgb), .18);
  clip-path: polygon(0 3%, 6% 0, 40% 2%, 78% 0, 100% 4%, 99% 45%, 100% 96%, 60% 100%, 22% 98%, 1% 100%, 2% 50%);
  filter: url(#wobble2);
}
.tape {
  position: absolute;
  top: -14px;
  left: 50%;
  width: 90px;
  height: 26px;
  margin-left: -45px;
  background: rgba(255, 93, 143, .55);
  transform: rotate(-4deg);
  clip-path: polygon(0 10%, 6% 0, 12% 12%, 100% 0, 94% 50%, 100% 100%, 8% 90%, 0 100%, 5% 50%);
}

/* ---------- вкладки ---------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 34px 0 22px;
}
.tab {
  position: relative;
  padding: 8px 20px 10px;
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  isolation: isolate;
}
.tab::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface-2);
  border: 3px solid var(--line);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  filter: url(#wobble2);
}
.tab:nth-child(2n) { transform: rotate(1.5deg); }
.tab:nth-child(3n) { transform: rotate(-1deg); }
.tab.active { color: var(--on-accent); }
.tab.active::before { background: var(--yellow); box-shadow: 3px 3px 0 var(--line); }
.tab.active { transform: rotate(-1.5deg) scale(1.06); }
.tab:disabled { cursor: not-allowed; color: var(--muted-2); }
.tab:disabled::before { border-style: dashed; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.tab small { font-size: 13px; color: var(--pink); margin-left: 4px; }

.panel[hidden] { display: none; }

/* ---------- статус ---------- */
.status {
  text-align: center;
  font-size: 18px;
  margin-bottom: 8px;
  min-height: 28px;
}
.chip {
  display: inline-block;
  margin: 0 4px;
  padding: 2px 12px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 20px 6px 18px 8px;
  transform: rotate(-1deg);
}
.chip:nth-child(2n) { transform: rotate(1.2deg); }
.chip.live { background: var(--pink); color: #fff; }
.chip.live::before { content: '● '; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- пьедестал ---------- */
.podium {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: end;
  gap: 12px;
  margin: 18px auto 34px;
  max-width: 820px;
  padding-top: 56px;
}

.step { display: flex; flex-direction: column; align-items: center; min-width: 0; }

.who { text-align: center; margin-bottom: 8px; position: relative; max-width: 100%; }
.crown {
  position: absolute;
  top: -44px;
  left: 50%;
  margin-left: -4px;
  font-size: 50px;
  transform: translateX(-50%) rotate(-14deg);
  filter: drop-shadow(2px 3px 0 rgba(var(--shade-rgb), .3));
}
.avatar {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 0 auto 6px;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-size: 40px;
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .35);
  isolation: isolate;
}
.avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--c, var(--violet));
  border: 4px solid var(--line);
  border-radius: 50% 46% 54% 48% / 48% 54% 46% 52%;
  filter: url(#wobble2);
}
.step.first .avatar { width: 96px; height: 96px; font-size: 50px; }

.name {
  font-size: 24px;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 2px 2px 0 var(--name-shadow);
}
.step.first .name { font-size: 30px; }
.badges { margin-top: 2px; font-size: 20px; letter-spacing: 1px; min-height: 26px; }

.block {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 14px;
  color: var(--on-accent);
  isolation: isolate;
}
.step.first  .block { height: 250px; --bg: var(--gold);   transform: rotate(.8deg); }
.step.second .block { height: 185px; --bg: var(--silver); transform: rotate(-1.2deg); }
.step.third  .block { height: 140px; --bg: var(--bronze); transform: rotate(1.5deg); }
.block::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .0) 0 9px, rgba(255, 255, 255, .28) 9px 12px),
    var(--bg);
  border: 4px solid var(--line);
  border-radius: 10px 22px 6px 14px / 14px 8px 20px 10px;
  box-shadow: 6px 7px 0 rgba(var(--shade-rgb), .25);
  filter: url(#wobble);
}
.place {
  font-family: var(--font-title);
  font-size: 76px;
  line-height: 1;
  color: var(--ink);
  opacity: .85;
}
.step.first .place { font-size: 100px; }
.count { font-size: 24px; margin-top: auto; padding-bottom: 12px; }
.count b { font-size: 30px; }

.step.empty .block::before { background: transparent; border-style: dashed; box-shadow: none; }
.step.empty .name { color: var(--muted-3); font-size: 20px; }
.step.empty .avatar::before { background: transparent; border-style: dashed; }

/* ---------- 4–10 места ---------- */
.rest {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 700px;
  display: grid;
  gap: 12px;
  counter-reset: none;
}
.row {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 10px;
  isolation: isolate;
  overflow: hidden;
}
.row:nth-child(odd)  { transform: rotate(-.6deg); }
.row:nth-child(even) { transform: rotate(.5deg) translateX(6px); }
.row::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--surface);
  border: 3px solid var(--line);
  border-radius: 16px 6px 14px 8px / 8px 14px 6px 16px;
  box-shadow: 4px 4px 0 rgba(var(--shade-rgb), .2);
}
.bar { /* закрашено маркером пропорционально числу сообщений */
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  z-index: -1;
  width: calc((100% - 8px) * var(--w, .1));
  background: var(--c, var(--pink));
  opacity: .38;
  border-radius: 4px 14px 6px 12px;
  transition: width .6s cubic-bezier(.3, 1.4, .5, 1);
}
.rank {
  font-family: var(--font-title);
  font-size: 34px;
  text-align: center;
  color: var(--pink);
}
.row .name { font-size: 24px; text-shadow: none; }
.row .badges { display: inline; margin-left: 8px; font-size: 18px; min-height: 0; }
.row .count { margin: 0; padding: 0; font-size: 20px; white-space: nowrap; }
.row .count b { font-size: 26px; }

.empty { text-align: center; font-family: var(--font-script); font-size: 30px; margin-top: 40px; transform: rotate(-1deg); }

/* ---------- уведомления о достижениях ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 12px; z-index: 10; max-width: calc(100vw - 32px); }
.toast {
  position: relative;
  width: 300px;
  max-width: 100%;
  padding: 14px 16px 12px;
  background: var(--note);
  box-shadow: 4px 5px 0 rgba(var(--shade-rgb), .3);
  clip-path: polygon(0 4%, 8% 0, 60% 3%, 100% 0, 98% 50%, 100% 97%, 50% 100%, 3% 98%, 1% 50%);
  transform: rotate(1.5deg);
  animation: slap .5s cubic-bezier(.3, 1.6, .5, 1);
}
.toast b { font-family: var(--font-script); font-size: 24px; display: block; }
.toast.out { opacity: 0; transform: translateX(60px) rotate(6deg); transition: .5s; }
@keyframes slap { from { transform: translateY(40px) rotate(-10deg) scale(.6); opacity: 0; } }

.foot { margin-top: 50px; text-align: center; color: var(--muted-2); font-size: 16px; transform: rotate(-.6deg); }

/* ---------- анимация "счётчик подпрыгнул" ---------- */
.pop { animation: pop .4s ease-out; }
@keyframes pop { 40% { transform: scale(1.35) rotate(-4deg); color: var(--pink); } }

/* ---------- вкладка "Достижения" ---------- */
.lead { text-align: center; font-family: var(--font-script); font-size: 26px; margin: 0 auto 26px; max-width: 640px; transform: rotate(-.7deg); }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 26px 22px; padding: 6px 4px; }

.ach {
  position: relative; /* для подсказки */
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 16px 18px;
  text-align: center;
  isolation: isolate;
}
.ach:nth-child(3n + 1) { transform: rotate(-1.3deg); }
.ach:nth-child(3n + 2) { transform: rotate(.9deg); }
.ach:nth-child(3n)     { transform: rotate(-.4deg); }
.ach.open { z-index: 5; } /* подсказка поверх соседних карточек */
.ach::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface);
  border: 3px solid var(--line);
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  box-shadow: 5px 6px 0 rgba(var(--shade-rgb), .22);
  filter: url(#wobble2);
}

.ach-icon {
  position: relative;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  font-size: 40px;
  isolation: isolate;
}
.ach-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--yellow);
  border: 3px solid var(--line);
  border-radius: 50% 46% 54% 48% / 48% 54% 46% 52%;
  filter: url(#wobble2);
}
.ach:nth-child(2n) .ach-icon::before { background: var(--tint-pink); }
.ach:nth-child(3n) .ach-icon::before { background: var(--tint-teal); }

.ach-head { position: relative; max-width: 100%; }
.ach-title {
  font: inherit;
  font-size: 25px;
  line-height: 1.1;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
  text-decoration: underline wavy var(--pink);
  text-underline-offset: 5px;
  text-decoration-thickness: 2px;
}
.ach-title:hover, .ach-title:focus-visible { color: var(--pink); outline: none; }

.ach-hint {
  position: absolute;
  z-index: 6;
  top: calc(100% + 10px);
  left: 50%;
  width: 230px;
  max-width: 80vw;
  margin-left: -115px;
  padding: 10px 14px 12px;
  font-size: 18px;
  line-height: 1.2;
  text-align: left;
  background: var(--note);
  border: 3px solid var(--line);
  border-radius: 6px 16px 8px 14px;
  box-shadow: 4px 5px 0 rgba(var(--shade-rgb), .3);
  transform: rotate(-1.5deg);
  animation: slap .35s cubic-bezier(.3, 1.6, .5, 1);
}
.ach-hint[hidden] { display: none; }

.ach-count { font-size: 17px; color: var(--muted); }

.ach-holders { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.holder {
  padding: 1px 10px 2px;
  font-size: 16px;
  background: color-mix(in srgb, var(--c, var(--pink)) 30%, var(--surface-2));
  border: 2px solid var(--line);
  border-radius: 14px 5px 12px 6px;
}
.holder:nth-child(2n) { transform: rotate(1.5deg); }
.holder:nth-child(2n + 1) { transform: rotate(-1deg); }

/* ---------- вкладка "Общее дело" ---------- */
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 28px 24px; max-width: 760px; margin: 0 auto 34px; }
.counter {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 22px 18px 18px;
  text-align: center;
  isolation: isolate;
}
.counter:nth-child(odd)  { transform: rotate(-1.4deg); }
.counter:nth-child(even) { transform: rotate(1.1deg); }
.counter::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface);
  border: 4px solid var(--line);
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  box-shadow: 6px 7px 0 rgba(var(--shade-rgb), .22);
  filter: url(#wobble);
}
.counter-icon { font-size: 44px; transform: rotate(-8deg); }
.counter-title { margin: 0; font-family: var(--font-script); font-weight: 400; font-size: 34px; line-height: 1.1; }
.counter-value {
  font-family: var(--font-title);
  font-size: 96px;
  line-height: 1.05;
  color: var(--pink);
  text-shadow: 4px 4px 0 var(--glow), 7px 7px 0 var(--line);
  margin: 4px 0 10px;
}
.counter-note { font-size: 17px; color: var(--muted); }

.construction {
  position: relative;
  max-width: 460px;
  margin: 20px auto;
  padding: 18px 24px 16px;
  text-align: center;
  isolation: isolate;
  transform: rotate(-1deg);
}
.construction::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(-45deg, var(--stripe) 0 18px, rgba(255, 255, 255, 0) 18px 36px),
    var(--surface);
  border: 4px dashed var(--line);
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  box-shadow: 6px 7px 0 rgba(var(--shade-rgb), .22);
  filter: url(#wobble);
}
.construction .cone { font-size: 38px; transform: rotate(-8deg); display: inline-block; }
.construction p { margin: 0; font-size: 20px; background: color-mix(in srgb, var(--surface) 85%, transparent); display: inline-block; padding: 2px 8px; }

/* ---------- вкладка "Найти баловня" ---------- */
.search { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 0 auto 30px; max-width: 560px; }
.search input {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 18px;
  font: inherit;
  font-size: 26px;
  color: var(--ink);
  background: var(--surface);
  border: 4px solid var(--line);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
  box-shadow: 4px 5px 0 rgba(var(--shade-rgb), .25);
  transform: rotate(-.8deg);
}
.search input::placeholder { color: var(--placeholder); }
.search input:focus { outline: 3px dashed var(--pink); outline-offset: 4px; }
.go {
  display: inline-block;
  text-decoration: none;
  padding: 8px 26px 10px;
  font: inherit;
  font-size: 26px;
  color: var(--on-accent);
  background: var(--yellow);
  border: 4px solid var(--line);
  border-radius: 18px 255px 18px 225px / 225px 18px 255px 18px;
  box-shadow: 4px 5px 0 var(--line);
  cursor: pointer;
  transform: rotate(1.2deg);
}
.go:hover { background: var(--pink); color: #fff; }
.go:active { box-shadow: 1px 2px 0 var(--line); transform: translate(3px, 3px) rotate(1.2deg); }
.go:disabled { opacity: .6; cursor: progress; }

.empty.small { font-size: 26px; margin-top: 10px; }
.lead.small { font-size: 22px; margin-bottom: 10px; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.holder.suggest { font: inherit; font-size: 20px; cursor: pointer; padding: 3px 14px 4px; }
.holder.suggest:hover { background: var(--yellow); color: var(--on-accent); }

.profile {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 22px 24px;
  text-align: center;
  isolation: isolate;
  transform: rotate(-.6deg);
}
.profile::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface);
  border: 4px solid var(--line);
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  box-shadow: 6px 7px 0 rgba(var(--shade-rgb), .22);
  filter: url(#wobble);
}
.profile-kicker { font-family: var(--font-script); font-size: 30px; transform: rotate(-3deg); color: var(--pink); }
.profile-name {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(40px, 9vw, 70px);
  line-height: 1.05;
  overflow-wrap: anywhere;
  color: var(--c, var(--pink));
  text-shadow: 3px 3px 0 var(--line);
}
.profile-messages { margin-top: 14px; font-size: 24px; }
.profile-messages b {
  display: block;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(64px, 14vw, 104px);
  line-height: 1.05;
  color: var(--pink);
  text-shadow: 4px 4px 0 var(--glow), 7px 7px 0 var(--line);
}
.profile-since { font-size: 16px; color: var(--muted-2); margin-top: 4px; }
.profile-awards { margin-top: 18px; font-family: var(--font-script); font-size: 30px; }
.profile-awards b { font-size: 38px; color: var(--pink); }

.pa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; margin-top: 20px; }
.pa {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 16px 10px 12px;
  isolation: isolate;
}
.pa:nth-child(odd)  { transform: rotate(-1.4deg); }
.pa:nth-child(even) { transform: rotate(1deg); }
.pa::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--note);
  border: 3px solid var(--line);
  border-radius: 10px 18px 8px 16px;
  box-shadow: 4px 4px 0 rgba(var(--shade-rgb), .25);
}
.pa-icon { font-size: 36px; }
.pa-title { font-size: 22px; line-height: 1.1; }
.pa-count { font-size: 18px; }
.pa-count b { font-size: 26px; color: var(--pink); }
.pa-note { font-size: 15px; color: var(--muted); line-height: 1.15; }

/* ---------- тёмная тема: «тихо... за тобой кто-то смотрит» ---------- */
:root[data-theme='dark'] {
  --paper: #0a090d;
  --ink: #d6cfc0;
  --line: #5e2733;
  --on-accent: #0d0b10;
  --shade-rgb: 0, 0, 0;
  --pink: #c1213f;
  --yellow: #a8872f;
  --teal: #4f8f86;
  --violet: #6b4f9e;
  --gold: #9c7d2a;
  --silver: #6f7782;
  --bronze: #7d4a2e;
  --surface: #15121b;
  --surface-2: #1d1824;
  --note: #241c2b;
  --muted: #9a8f9f;
  --muted-2: #7f7589;
  --muted-3: #6f6678;
  --placeholder: #5f566a;
  --tint-pink: #5a1f33;
  --tint-teal: #1f4a47;
  --name-shadow: #000;
  --glow: #3d0a16;
  --stripe: rgba(140, 20, 40, .35);
}
[data-theme='dark'] body {
  background:
    radial-gradient(ellipse at 50% -12%, rgba(130, 20, 45, .32), transparent 55%),
    radial-gradient(circle at 92% 14%, transparent 0 46px, rgba(170, 30, 55, .28) 47px 50px, transparent 52px),
    radial-gradient(ellipse at 50% 125%, rgba(70, 35, 120, .38), transparent 60%),
    repeating-linear-gradient(to bottom, transparent 0 33px, rgba(130, 110, 170, .06) 33px 35px),
    var(--paper);
  background-attachment: fixed;
}
[data-theme='dark'] body::before { /* виньетка: края страницы тонут во тьме */
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, .78) 100%);
}
[data-theme='dark'] body::after { /* медленный туман */
  content: '';
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 40% 25% at 20% 70%, rgba(120, 110, 150, .09), transparent),
    radial-gradient(ellipse 45% 22% at 75% 40%, rgba(120, 110, 150, .08), transparent);
  animation: fog 38s ease-in-out infinite alternate;
}
@keyframes fog { to { transform: translate(9%, -4%); } }
[data-theme='dark'] .page { position: relative; z-index: 1; }
[data-theme='dark'] .title { text-shadow: 4px 4px 0 var(--glow), 8px 8px 0 #000, 0 0 34px rgba(193, 33, 63, .4); }
[data-theme='dark'] .title span:nth-child(1) { color: #7fa89c; animation: flicker 7s steps(1) infinite; }
@keyframes flicker { 0%, 91%, 94%, 100% { opacity: 1; } 92% { opacity: .25; } 93% { opacity: .8; } 97% { opacity: .5; } }
[data-theme='dark'] .counter-value,
[data-theme='dark'] .profile-messages b { text-shadow: 4px 4px 0 var(--glow), 7px 7px 0 #000, 0 0 26px rgba(193, 33, 63, .3); }
[data-theme='dark'] .profile-name { color: color-mix(in srgb, var(--c, var(--pink)) 65%, #fff); text-shadow: 3px 3px 0 #000; }
[data-theme='dark'] .tape { background: rgba(120, 30, 50, .6); }
[data-theme='dark'] .crown { filter: drop-shadow(0 0 8px rgba(255, 200, 60, .35)); }
[data-theme='dark'] .go:hover,
[data-theme='dark'] .tab:hover:not(:disabled):not(.active) { color: #fff; }
[data-theme='dark'] .tab:hover:not(:disabled):not(.active)::before { background: var(--tint-pink); }

/* ---------- переключатель темы ---------- */
.theme-toggle {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 20;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  transform: rotate(6deg);
  isolation: isolate;
}
.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface-2);
  border: 3px solid var(--line);
  border-radius: 50% 46% 54% 48% / 48% 54% 46% 52%;
  box-shadow: 3px 4px 0 rgba(var(--shade-rgb), .3);
  filter: url(#wobble2);
}
.theme-toggle:hover { transform: rotate(-8deg) scale(1.1); }
.theme-toggle:active { transform: rotate(-8deg) scale(.95); }
.theme-toggle:focus-visible { outline: 3px dashed var(--pink); outline-offset: 4px; }

/* ---------- телефоны ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .page { padding-top: 72px; }
  .theme-toggle { top: 10px; right: 10px; width: 46px; height: 46px; font-size: 23px; }
  .podium { gap: 6px; padding-top: 46px; }
  .avatar { width: 56px; height: 56px; font-size: 28px; }
  .step.first .avatar { width: 70px; height: 70px; font-size: 36px; }
  .name { font-size: 17px; }
  .step.first .name { font-size: 21px; }
  .crown { font-size: 38px; top: -36px; }
  .place { font-size: 50px; }
  .step.first .place { font-size: 66px; }
  .step.first .block { height: 210px; }
  .step.second .block { height: 160px; }
  .step.third .block { height: 125px; }
  .count { font-size: 17px; }
  .count b { font-size: 22px; }
  .row { grid-template-columns: 38px 1fr auto; padding-right: 10px; }
  .row .name { font-size: 19px; }
  .ach-grid { grid-template-columns: 1fr; }
  .lead { font-size: 22px; }
  .counter-value { font-size: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
