/*
 * Дизайн-система hubbo. Своя палитра (не из Telegram themeParams) с двумя темами:
 * светлой (по умолчанию) и тёмной. Тема переключается атрибутом data-theme
 * на <html> ("light" | "dark") — см. app.js. Брендовые фиолетовый и золотой
 * между темами не меняются, меняются только фон/поверхности/текст.
 */
:root {
  --violet:       #6D28D9;
  --violet-deep:  #4A1C99; /* нижняя «губа» 3D-элементов */
  --gold:         #FFB020;
  --gold-deep:    #C98404;

  --bg:           #F5F2FC;
  --surface:      #FFFFFF;
  --surface-2:    #EEE8FB;
  --ink:          #211433;
  --hint:         #897FA3;
  --border:       rgba(74, 28, 153, .12);
  --shadow:       0 8px 24px rgba(74, 28, 153, .12);
  --shadow-sm:    0 3px 10px rgba(74, 28, 153, .10);
  --lip:          rgba(20, 6, 50, .16);

  /* Тема-зависимые «белые» элементы: в светлой теме — белые, в тёмной — стекло/тонированные */
  --cta-bg:         #fff;                     /* кнопка «▶ Играть» на «Хит недели» */
  --cta-fg:         var(--violet-deep);
  --cta-border:     transparent;
  --progress-track: rgba(255, 255, 255, .35); /* полоски прогресса «Продолжить» */
  --progress-fill:  #fff;
  --gloss:          rgba(255, 255, 255, .35); /* блик на «Хит недели» */
  --gloss-tile:     rgba(255, 255, 255, .32); /* блик на плитках игр (в светлой теме был .32) */
  --act-bg:         rgba(255, 255, 255, .2);  /* звёздочка/«Поделиться» на «Хит недели» */
  --switch-knob:    #fff;                     /* бегунок переключателя */
  --toast-bg:       var(--ink);
  --toast-fg:       var(--bg);
  --toast-border:   transparent;

  --tabbar-h: 68px;
}

html[data-theme="dark"] {
  --violet:       #8B5CF6;
  --violet-deep:  #3A1E70;
  --gold:         #FFC24B;
  --gold-deep:    #D79A2A;

  --bg:           #0C0813;
  --surface:      #15101D;
  --surface-2:    #1F1730;
  --ink:          #F2ECFF;
  --hint:         #A99BC7;
  --border:       rgba(255, 255, 255, .08);
  --shadow:       0 10px 30px rgba(0, 0, 0, .5);
  --shadow-sm:    0 3px 12px rgba(0, 0, 0, .4);
  --lip:          rgba(0, 0, 0, .3);

  --cta-bg:         rgba(255, 255, 255, .12);
  --cta-fg:         var(--ink);
  --cta-border:     rgba(255, 255, 255, .20);
  --progress-track: rgba(255, 255, 255, .12);
  --progress-fill:  #B9A5F0;
  --gloss:          rgba(255, 255, 255, .16);
  --gloss-tile:     rgba(255, 255, 255, .15);
  --act-bg:         rgba(255, 255, 255, .12);
  --switch-knob:    #B9A5F0;
  --toast-bg:       var(--surface-2);
  --toast-fg:       var(--ink);
  --toast-border:   rgba(255, 255, 255, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: inherit; }

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

.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------- Шапка ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 18px 8px;
  min-height: 56px;
  flex: 0 0 auto;
}

.back {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.back svg { width: 18px; height: 18px; }
.back[hidden] { display: none; }

.mark {
  display: flex;
  align-items: center;
  gap: 11px;
}
.mark[hidden] { display: none; }
.mark-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: block;
  object-fit: cover;
  filter: drop-shadow(0 4px 10px rgba(74, 28, 153, .28));
}
.mark b {
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: .3px;
  line-height: 1;
}

.title {
  margin: 0;
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 21px;
}
.title[hidden] { display: none; }

.spacer { flex: 1; }

.toggle {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--hint);
  font-size: 15px;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Контент / экраны ---------- */

.content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 18px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
}
.content::-webkit-scrollbar { display: none; }

.screen[hidden] { display: none; }
.screen { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 2px 12px;
}
.row-head:first-child { margin-top: 6px; }
.row-head h3 {
  margin: 0;
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 17px;
}
.row-head[hidden] { display: none; }

/* ---------- Хит недели ---------- */

.featured {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  background: var(--violet);
  color: #fff;
  box-shadow: 0 6px 0 var(--violet-deep), 0 16px 30px rgba(109, 40, 217, .34);
}
.featured:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--violet-deep), 0 10px 20px rgba(109, 40, 217, .3); }
.featured .gloss {
  position: absolute;
  inset: 0;
  background: radial-gradient(150px 110px at 82% 4%, var(--gloss), transparent 68%);
}
.featured .spark { position: absolute; top: 16px; left: 18px; width: 20px; height: 20px; opacity: .85; }
.featured .glyph {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-56%);
  width: 96px;
  height: 96px;
  border-radius: 22px;
  overflow: hidden;
  filter: drop-shadow(0 8px 14px rgba(20, 6, 50, .35));
}
.featured .glyph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.featured .glyph.is-placeholder { display: flex; align-items: center; justify-content: center; }
.featured .glyph.is-placeholder img { width: 55%; height: 55%; object-fit: contain; }
.featured .meta { position: absolute; left: 20px; right: 20px; bottom: 18px; }
.hit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--gold);
  color: #3a2500;
  font: 800 11px "Inter";
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 9px;
}
.featured h2 {
  margin: 0 0 12px;
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800;
  font-size: 27px;
  letter-spacing: .3px;
  max-width: 62%;
}
.play {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--cta-bg);
  color: var(--cta-fg);
  font: 800 15px "Baloo 2", sans-serif;
  /* рамка 1px съедает 1px паддинга — размер кнопки прежний; в светлой теме рамка прозрачна
     и фон виден под ней, так что вид не меняется */
  border: 1px solid var(--cta-border);
  border-radius: 14px;
  padding: 8px 17px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(20, 6, 50, .22);
}
/* стеклянная кнопка поверх фиолетового: лёгкая тень текста для читаемости */
html[data-theme="dark"] .play { text-shadow: 0 1px 2px rgba(20, 6, 50, .45); }
.play:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(20, 6, 50, .22); }
.featured-actions { position: absolute; right: 16px; bottom: 18px; display: flex; gap: 8px; z-index: 2; }
.featured-act {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  background: var(--act-bg);
  box-shadow: 0 3px 0 rgba(20, 6, 50, .22);
}
.featured-act svg { width: 20px; height: 20px; }
.featured-act:focus-visible, .tile-act:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Дни подряд (без монет) ---------- */

.streak {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.streak .fire { flex: 0 0 auto; width: 26px; height: 26px; color: var(--gold-deep); }
.streak .fire svg { width: 100%; height: 100%; }
.streak-text { min-width: 0; }
.streak-text b {
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  display: block;
  line-height: 1.1;
}
.streak-text span { font-size: 12.5px; color: var(--hint); }
.streak .days { margin-left: auto; display: flex; gap: 5px; flex: 0 0 auto; }
.streak .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }
.streak .dot.on { background: var(--gold); border-color: var(--gold); }

/* ---------- Плитки игр ---------- */

.rail {
  display: flex;
  gap: 13px;
  overflow-x: auto;
  margin: 0 -18px;
  padding: 2px 18px 6px;
  scrollbar-width: none;
}
.rail[hidden] { display: none; }
.rail::-webkit-scrollbar { display: none; }
.rail .tile { flex: 0 0 128px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.tile { cursor: pointer; border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; display: block; }
.tile .art {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--violet);
  box-shadow: 0 5px 0 var(--lip), var(--shadow-sm);
}
.tile:active .art { transform: translateY(4px); box-shadow: 0 1px 0 var(--lip), var(--shadow-sm); transition: transform .08s; }
.tile .art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(90px 60px at 76% 8%, var(--gloss-tile), transparent 70%);
}
.tile .art-img { width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.tile .art.is-placeholder .art-img { width: 54%; height: 54%; object-fit: contain; }
.tile .name {
  display: block;
  margin-top: 9px;
  font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}
/* игра «Скоро» (soon в games-config.json) */
.tile .soon-chip { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); margin: 0; z-index: 1; }
.tile.is-soon .art-img { filter: grayscale(.7) brightness(.8); }
.tile.is-soon .name { color: var(--hint); }
/* прогресс «продолжить» */
.tile .bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 5px; border-radius: 3px; background: var(--progress-track); z-index: 1; }
.tile .bar i { display: block; height: 100%; border-radius: 3px; background: var(--progress-fill); }

/* обёртка плитки: кнопка игры + маленькие кнопки-действия поверх арта */
.tile-box { position: relative; min-width: 0; }
.tile-box .tile { width: 100%; }
.rail .tile-box { flex: 0 0 128px; }
.tile-act {
  position: absolute;
  top: 7px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(20, 6, 50, .38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.tile-act svg { width: 17px; height: 17px; }
.tile-fav { right: 7px; }
.tile-share { left: 7px; }
.tile-fav svg, .featured-act.fav svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.tile-fav[aria-pressed="true"], .featured-act.fav[aria-pressed="true"] { background: var(--gold); color: #3a2500; box-shadow: 0 2px 0 var(--gold-deep); }
.tile-fav[aria-pressed="true"] svg, .featured-act.fav[aria-pressed="true"] svg { fill: currentColor; }
.tile-act:active, .featured-act:active { transform: scale(.92); }

.empty { color: var(--hint); font-size: 15px; text-align: center; padding: 40px 0; }
.empty[hidden] { display: none; }

/* ---------- Разделы «Игры» ---------- */

.section-card {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 14px;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  box-shadow: 0 5px 0 var(--lip), var(--shadow-sm);
}
.section-card:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--lip), var(--shadow-sm); transition: transform .08s; }
.section-card .ic {
  flex: 0 0 54px;
  height: 54px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, .12);
}
.section-card .ic svg { width: 27px; height: 27px; }
.ic-solo { background: var(--violet); }
.ic-multi { background: #E5476F; }
.section-card .tx { flex: 1; display: flex; flex-direction: column; }
.section-card .tx b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; font-size: 17px; display: block; }
.section-card .tx span { font-size: 12.5px; color: var(--hint); }
.chip { font: 800 11px "Inter"; background: var(--gold); color: #3a2500; padding: 5px 11px; border-radius: 999px; margin-left: auto; flex: 0 0 auto; }
.arrow { color: var(--hint); opacity: .6; flex: 0 0 auto; }
.arrow svg { width: 18px; height: 18px; display: block; }

/* ---------- Скоро (мультиплеер) ---------- */

.stub { text-align: center; padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.stub .badge {
  width: 82px;
  height: 82px;
  border-radius: 26px;
  background: var(--violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 var(--violet-deep), 0 14px 26px rgba(109, 40, 217, .32);
}
.stub .badge svg { width: 40px; height: 40px; }
.stub h3 { margin: 0; font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; font-size: 21px; }
.stub p { margin: 0; color: var(--hint); font-size: 13.5px; max-width: 25ch; line-height: 1.5; }

/* ---------- Профиль (без монет) ---------- */

.prof { display: flex; align-items: center; gap: 15px; margin: 10px 0 20px; }
.prof .av {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  background: var(--violet);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 27px "Baloo 2", sans-serif;
  box-shadow: 0 6px 0 var(--violet-deep), 0 12px 22px rgba(109, 40, 217, .32);
}
.prof .av { flex: 0 0 auto; overflow: hidden; }
.prof .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prof .av.has-photo { background: var(--surface-2); }
.prof-text { min-width: 0; }
.prof-text b, .prof-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prof b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; font-size: 20px; display: block; }
.prof span { font-size: 13px; color: var(--hint); }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px 8px; text-align: center; box-shadow: var(--shadow-sm); }
.stat b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 800; font-size: 21px; display: block; }
.stat.gold b { color: var(--gold-deep); }
.stat span { font-size: 11px; color: var(--hint); }

.stat b.stat-text { font-size: 14px; line-height: 31px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }

.row-note { font-size: 12px; color: var(--hint); }

/* ---------- Уровень / квест / ачивки ---------- */

.level {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.level-badge {
  flex: 0 0 52px;
  height: 52px;
  border-radius: 17px;
  background: var(--gold);
  color: #3a2500;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 24px "Baloo 2", sans-serif;
  box-shadow: 0 4px 0 var(--gold-deep);
}
.level-body { flex: 1; min-width: 0; }
.level-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.level-top b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; font-size: 17px; }
.level-top > span { font: 700 12px "Inter", sans-serif; color: var(--violet); }
html[data-theme="dark"] .level-top > span { color: var(--gold); }
.level-bar, .quest-bar { height: 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 7px 0 5px; }
.level-bar i, .quest-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--violet); transition: width .4s ease; }
.level-hint { font-size: 11.5px; color: var(--hint); }

.quest {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.quest-ic { flex: 0 0 42px; height: 42px; border-radius: 14px; background: var(--surface-2); color: var(--violet); display: flex; align-items: center; justify-content: center; }
.quest-ic svg { width: 22px; height: 22px; }
.quest-body { flex: 1; min-width: 0; }
.quest-body b { font: 600 14px "Inter", sans-serif; }
.quest-bar { margin-bottom: 0; }
.quest-count { font: 800 17px "Baloo 2", sans-serif; color: var(--hint); flex: 0 0 auto; }
.quest.done .quest-ic { background: var(--gold); color: #3a2500; }
.quest.done .quest-bar i { background: var(--gold); }
.quest.done .quest-count { color: var(--gold-deep); }

.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ach {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ach-ic {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.ach-ic svg { width: 22px; height: 22px; }
.ach b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; font-size: 15px; line-height: 1.15; }
.ach-desc { font-size: 11.5px; color: var(--hint); line-height: 1.35; }
.ach-state { margin-top: 5px; font: 700 11px "Inter", sans-serif; color: var(--hint); }
.ach:not(.on) b, .ach:not(.on) .ach-ic { opacity: .7; }
.ach.on .ach-ic { background: var(--violet); color: #fff; box-shadow: 0 4px 0 var(--violet-deep); }
.ach.on .ach-state { color: var(--violet); }
html[data-theme="dark"] .ach.on .ach-state { color: var(--gold); }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-sm); }
.list button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 16px;
  font: 600 14.5px "Inter";
  color: var(--ink);
  cursor: pointer;
}
.list button:last-child { border-bottom: 0; }
.list button:active { background: var(--surface-2); }
.list svg { width: 20px; height: 20px; color: var(--violet); flex: 0 0 auto; }
.list .arrow { margin-left: auto; }
.switch-label { flex: 1; }
.switch {
  position: relative;
  flex: 0 0 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background .18s;
}
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 2px 4px rgba(20, 6, 50, .25);
  transition: transform .18s;
}
[aria-checked="true"] > .switch { background: var(--violet); border-color: var(--violet); }
[aria-checked="true"] > .switch i { transform: translateX(18px); }
.demo-chip {
  margin-left: auto;
  flex: 0 0 auto;
  font: 700 10.5px "Inter", sans-serif;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--hint);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  padding: 3px 8px;
  border-radius: 999px;
}

/* ---------- Лидеры недели (демо) ---------- */

.leaders {
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.leaders[hidden] { display: none; }
.leader { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 14px; }
.leader + .leader { margin-top: 2px; }
.leader-rank {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 14px "Baloo 2", sans-serif;
  color: var(--hint);
  background: var(--surface-2);
}
.leader-av {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 800 15px "Baloo 2", sans-serif;
  color: #fff;
  background: var(--violet);
}
.leader-name { flex: 1; min-width: 0; font: 600 14px "Inter", sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-pts { flex: 0 0 auto; font: 800 15px "Baloo 2", sans-serif; }
.leader-pts small { font: 600 11px "Inter", sans-serif; color: var(--hint); margin-left: 3px; }
.leader.top1 .leader-rank { background: var(--gold); color: #3a2500; box-shadow: 0 3px 0 var(--gold-deep); }
.leader.top2 .leader-rank { background: #C9CBD6; color: #2c2f3a; box-shadow: 0 3px 0 #9A9DAB; }
.leader.top3 .leader-rank { background: #E0A071; color: #3d1f08; box-shadow: 0 3px 0 #B0703F; }
.leader.top1 { background: rgba(255, 176, 32, .12); }
.leader.me { background: var(--surface-2); outline: 2px solid var(--violet); outline-offset: -2px; }
.leader.me .leader-name { font-weight: 700; }
.leaders-gap { text-align: center; color: var(--hint); font-size: 13px; line-height: 1; padding: 2px 0 6px; letter-spacing: 2px; }

/* ---------- О проекте ---------- */

.about-empty,
.about {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  min-height: 96px;
  box-shadow: var(--shadow-sm);
}
.about { padding: 16px 18px; font-size: 13.5px; line-height: 1.5; color: var(--hint); }
.about p { margin: 0 0 6px; }
.about p:last-child { margin-bottom: 0; }
.about-lead { color: var(--ink); font-size: 14.5px; }
.about-lead b { font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 800; font-size: 16px; color: var(--violet); }
html[data-theme="dark"] .about-lead b { color: var(--gold); }
/* Плейсхолдеры для правки — заметны, чтобы не забыть заменить */
.todo-fill { color: var(--violet); background: var(--surface-2); border-radius: 6px; padding: 0 5px; font-weight: 600; }
html[data-theme="dark"] .todo-fill { color: var(--gold); }

/* ---------- Таб-бар ---------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--tabbar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  gap: 6px;
  z-index: 50;
}
.tab {
  flex: 1;
  border: 0;
  background: none;
  cursor: pointer;
  height: 48px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--hint);
  font: 700 11px "Inter";
  transition: background .15s, color .15s;
}
.tab-icon { width: 23px; height: 23px; }
.tab[aria-selected="true"] { background: var(--violet); color: #fff; box-shadow: 0 4px 12px rgba(109, 40, 217, .38); }

/* ---------- Онбординг (подсказки первого запуска) ---------- */

.coach { position: fixed; inset: 0; z-index: 100; }
.coach[hidden] { display: none; }
.coach-hole {
  position: fixed;
  border-radius: 20px;
  box-shadow: 0 0 0 9999px rgba(12, 5, 28, .68);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  pointer-events: none;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease, border-radius .25s ease;
}
.coach-bubble {
  position: fixed;
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 16px 14px;
  box-shadow: 0 5px 0 var(--lip), var(--shadow);
  transition: top .25s ease, left .25s ease;
  animation: coach-pop .22s ease;
}
@keyframes coach-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.coach-arrow {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  transform: rotate(45deg);
}
.coach-bubble.below .coach-arrow { top: -9px; border-right: 0; border-bottom: 0; }
.coach-bubble.above .coach-arrow { bottom: -9px; border-left: 0; border-top: 0; }
.coach-step { display: block; font: 700 11px "Inter", sans-serif; color: var(--violet); letter-spacing: .4px; margin-bottom: 4px; }
html[data-theme="dark"] .coach-step { color: var(--gold); }
.coach-title { display: block; font-family: "Baloo 2", -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 800; font-size: 18px; line-height: 1.15; }
.coach-text { margin: 6px 0 14px; font-size: 13.5px; line-height: 1.45; color: var(--hint); }
.coach-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-skip { border: 0; background: none; color: var(--hint); font: 600 13.5px "Inter", sans-serif; padding: 8px 4px; cursor: pointer; border-radius: 10px; }
.coach-next {
  border: 0;
  background: var(--violet);
  color: #fff;
  font: 800 15px "Baloo 2", sans-serif;
  padding: 8px 18px;
  border-radius: 13px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--violet-deep);
}
.coach-next:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--violet-deep); }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  background: var(--toast-bg);
  color: var(--toast-fg);
  font: 600 13.5px "Inter", sans-serif;
  padding: 11px 16px;
  border-radius: 14px;
  /* рамка через inset-тень: размер тоста не меняется, в светлой теме она прозрачна */
  box-shadow: inset 0 0 0 1px var(--toast-border), var(--shadow);
  z-index: 120;
  animation: fade .2s ease;
  text-align: center;
}
.toast[hidden] { display: none; }

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

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .coach-hole, .coach-bubble { transition: none; animation: none; }
  .toast { animation: none; }
  .level-bar i, .quest-bar i, .switch, .switch i { transition: none; }
  .coach-next:active,
  .tile-act:active,
  .featured-act:active { transform: none; }
  .featured:active,
  .play:active,
  .tile:active .art,
  .section-card:active {
    transform: none;
    transition: none;
  }
}
/* body.playing ставится из app.js на время игры */
body.playing .topbar,
body.playing .tabbar { display: none; }

body.playing .content { padding: 0; }

.screen-play {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;                 /* поля вокруг игры — чёрные, а не в цвет темы */
  z-index: 20;
}

.screen-play[hidden] { display: none; }

/* Узкая полоска с выходом. Держим её КРОМЕ рамки, а не поверх: иначе
   перекрывала бы интерфейс игры, а он у каждой игры свой. */
.play-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(0, 0, 0, .88);
  color: #fff;
}

.play-back {
  border: 0;
  border-radius: 9px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.play-back:active { background: rgba(255, 255, 255, .26); }

.play-title {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, .85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Контейнер рамки: сама <iframe> создаётся в hub-bridge.js под каждую игру
   и удаляется при выходе, поэтому размеры заданы контейнеру. */
.play-stage {
  flex: 1 1 auto;
  width: 100%;
  background: #000;
}

.play-stage[hidden] { display: none; }

.play-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.play-error {
  margin: 0;
  padding: 24px 20px;
  color: rgba(255, 255, 255, .75);
  font-size: 15px;
  text-align: center;
}

.play-error[hidden] { display: none; }
