/* Цвета берутся из темы Telegram; запасные — на случай открытия в браузере. */
:root {
  --fb-bg: #ffffff;
  --fb-bg2: #f0f2f5;
  --fb-text: #14171a;
  --fb-hint: #7d858f;
  --fb-link: #2a7bd4;
  --fb-btn: #2a7bd4;
  --fb-btn-text: #ffffff;
  --fb-danger: #d93a3a;
  --fb-sep: rgba(0, 0, 0, .08);
  --gold: #d9a400;
  --silver: #8f9aa6;
  --bronze: #b7703d;
  /* серии графиков: проверенная палитра, свои шаги для тёмной темы */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
}
:root[data-theme="dark"] {
  --fb-bg: #1c2733;
  --fb-bg2: #111a23;
  --fb-text: #eef2f5;
  --fb-hint: #8796a6;
  --fb-link: #62aaf0;
  --fb-btn: #3e8fdd;
  --fb-sep: rgba(255, 255, 255, .08);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
}
:root {
  --bg: var(--tg-section-bg-color, var(--tg-bg-color, var(--fb-bg)));
  --bg2: var(--tg-secondary-bg-color, var(--fb-bg2));
  --text: var(--tg-text-color, var(--fb-text));
  --hint: var(--tg-hint-color, var(--fb-hint));
  --link: var(--tg-link-color, var(--fb-link));
  --btn: var(--tg-button-color, var(--fb-btn));
  --btn-text: var(--tg-button-text-color, var(--fb-btn-text));
  --accent: var(--tg-accent-text-color, var(--btn));
  --danger: var(--tg-destructive-text-color, var(--fb-danger));
  --sep: var(--fb-sep);
  --fill: rgba(128, 138, 150, .16);
  --btn-soft: var(--tg-btn-soft, rgba(42, 123, 212, .14));
  --radius: 14px;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg2);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }

#view {
  padding: 12px 12px calc(var(--tabs-h) + var(--safe-b) + 16px);
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---- нижние вкладки ---- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg);
  border-top: 1px solid var(--sep);
}
#tabs button {
  flex: 1; border: 0; background: none; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--hint);
}
#tabs button .ico { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .75; }
#tabs button { position: relative; min-width: 0; }
#tabs button > span:not(.ico):not(.badge-count) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
#tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }
#tabs.six button { font-size: 10px; letter-spacing: -.3px; }
#tabs.six button > span:not(.ico):not(.badge-count) { padding: 0; }
#tabs .badge-count {
  position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 17px;
}
#tabs button[aria-current="page"] .ico { filter: none; opacity: 1; }

/* ---- общие блоки ---- */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.card.flush { padding: 0; overflow: hidden; }
h1 { font-size: 22px; margin: 4px 2px 10px; line-height: 1.2; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--hint); margin: 18px 4px 6px; }
.hint { color: var(--hint); font-size: 13px; }
.muted { color: var(--hint); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 16px;
  background: var(--btn); color: var(--btn-text); font-weight: 600;
  min-height: 44px;
}
.btn.block { display: flex; width: 100%; }
.btn.ghost { background: transparent; color: var(--link); }
.btn.soft { background: var(--btn-soft); color: var(--accent); }
.btn:active { opacity: .75; }
.btn[disabled] { opacity: .5; }
.icon-btn {
  border: 0; background: var(--fill);
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.icon-btn:active { opacity: .7; }

.seg {
  display: flex; background: var(--fill);
  border-radius: 11px; padding: 3px; margin-bottom: 10px;
}
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px;
  font-size: 14px; color: var(--text); min-height: 36px;
}
.seg button[aria-pressed="true"] { background: var(--bg); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: 18px; padding: 7px 13px; font-size: 14px;
  background: var(--bg); color: var(--text); white-space: nowrap;
}
.card .chip { background: var(--bg2); }
.chip[aria-pressed="true"], .card .chip[aria-pressed="true"] { background: var(--btn); color: var(--btn-text); font-weight: 600; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 12px; padding: 0 12px; margin-bottom: 10px;
}
.search input {
  flex: 1; border: 0; outline: 0; background: none; padding: 12px 0; font-size: 16px; min-width: 0;
}
.search input::-webkit-search-cancel-button, .search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search .clear { border: 0; background: none; color: var(--hint); font-size: 18px; padding: 6px; }

.list .item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border: 0; background: none; text-align: left;
  border-bottom: 1px solid var(--sep);
}
.list .item:last-child { border-bottom: 0; }
.list .item:active { background: var(--fill); }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 15px;
}
.item .title { font-weight: 600; }
.item .sub { color: var(--hint); font-size: 13px; }

.empty { text-align: center; padding: 28px 16px; color: var(--hint); }
.empty .big { font-size: 40px; margin-bottom: 6px; }

.spinner {
  width: 26px; height: 26px; margin: 30px auto; border-radius: 50%;
  border: 3px solid var(--fill); border-top-color: var(--btn);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { text-align: center; padding: 22px 16px; }
.error .msg { margin: 6px 0 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  background: rgba(20, 24, 28, .92); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}

/* ---- расписание ---- */
.topbar { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.topbar .title { font-size: 19px; font-weight: 700; line-height: 1.2; }
.topbar .sub { color: var(--hint); font-size: 13px; }

.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.weeknav .range { flex: 1; text-align: center; }
.weeknav .range b { display: block; font-size: 15px; }
.weeknav .range span { font-size: 12px; color: var(--hint); }

.days { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days button {
  flex: 1 0 44px; border: 0; background: var(--bg); border-radius: 12px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--hint);
}
.days button b { font-size: 16px; color: var(--text); }
.days button.off b { color: var(--hint); font-weight: 500; }
.days button.today { background: var(--btn); color: var(--btn-text); }
.days button.today b { color: var(--btn-text); }

.day { scroll-margin-top: 12px; }
.day .dhead { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px 4px; }
.day .dhead b { font-size: 15px; }
.day .dhead .badge { font-size: 11px; background: var(--btn); color: var(--btn-text); border-radius: 8px; padding: 1px 7px; }
.day .none { padding: 4px 14px 14px; color: var(--hint); font-size: 14px; }

.lesson { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.lesson:first-of-type { border-top: 0; }
.lesson .time { flex: none; width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.lesson .time b { display: block; font-size: 15px; }
.lesson .time span { font-size: 12px; color: var(--hint); }
.lesson .body { flex: 1; min-width: 0; border-left: 3px solid var(--kind, var(--btn)); padding-left: 10px; }
.lesson .subj { font-weight: 600; }
.lesson .meta { font-size: 13px; color: var(--hint); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.lesson .meta .room { color: var(--text); font-weight: 600; }
.lesson .who { font-size: 13px; margin-top: 3px; }
.lesson .who a { text-decoration: none; font-weight: 500; }
.lesson .groups { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.lesson .groups span {
  font-size: 12px; background: var(--fill);
  border-radius: 7px; padding: 2px 7px;
}
.lesson .note { font-size: 12px; color: var(--danger); margin-top: 3px; font-style: italic; }
.lesson .dir { font-size: 12px; color: var(--hint); margin-top: 3px; }

.lesson .meta .room-link {
  border: 0; background: var(--btn-soft); color: var(--accent); font: inherit; font-weight: 700;
  border-radius: 7px; padding: 0 6px; margin: -1px 0;
}

/* полоса дней: всегда сверху, день меняется одним нажатием */
.daybar {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -12px 8px; padding: 8px 12px 6px;
  background: var(--bg2);
  box-shadow: 0 6px 10px -10px rgba(0, 0, 0, .35);
}
.dayhead { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.dayhead .icon-btn { width: 36px; height: 36px; flex: none; }
.dayhead .dayname {
  flex: 1; min-width: 0; border: 0; background: none; padding: 0; text-align: center; color: var(--text);
}
.dayhead .dayname b { display: block; font-size: 16px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dayhead .dayname span { display: block; font-size: 12px; color: var(--hint); }
.dayhead .mode-btn {
  flex: none; border: 0; border-radius: 10px; padding: 0 10px; height: 36px;
  background: var(--btn-soft); color: var(--accent); font-size: 13px; font-weight: 600;
}
.strip { display: flex; gap: 5px; }
.strip button {
  flex: 1 1 0; min-width: 0; border: 0; background: var(--bg); border-radius: 12px; padding: 5px 0 6px;
  display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--hint); position: relative;
  min-height: 48px;
}
.strip button b { font-size: 16px; color: var(--text); line-height: 1.2; }
.strip button i { position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--btn); }
.strip button.off b { color: var(--hint); font-weight: 500; }
.strip button.today { box-shadow: inset 0 0 0 2px var(--btn); }
.strip button[aria-selected="true"] { background: var(--btn); color: var(--btn-text); }
.strip button[aria-selected="true"] b { color: var(--btn-text); }
.strip button[aria-selected="true"] i { background: var(--btn-text); }
.sched-body .day { scroll-margin-top: calc(var(--daybar-h, 100px) + 8px); }
.sched-body .day .none { padding: 16px 14px; }
.slide-l { animation: slideL .2s ease-out; }
.slide-r { animation: slideR .2s ease-out; }
@keyframes slideL { from { transform: translateX(24px); opacity: .3; } }
@keyframes slideR { from { transform: translateX(-24px); opacity: .3; } }

/* ---- карта ---- */
.campus svg { display: block; width: 100%; height: auto; }
.campus text, .campus circle { pointer-events: none; }
.campus path[data-k]:not([data-k="other"]) { cursor: pointer; }
.cm-terr { stroke: var(--hint); opacity: .7; }
.cm-other { fill: #e2e6eb; }
.cm-bld { fill: #4a8fe0; }
.cm-canteen { fill: #f5b82e; }
.cm-archive { fill: #aab3bd; }
.cm-hot { fill: #ff8a1f; animation: cmPulse 1.3s ease-in-out infinite; }
@keyframes cmPulse { 50% { fill: #ffc266; } }
.cm-label { fill: #fff; }
.cm-entr { fill: #5fb33c; }
.cm-entr-label { fill: var(--hint); font-size: 14px; }
.cm-canteen-label { fill: #c98a00; font-size: 13px; }
:root[data-theme="dark"] .cm-other { fill: #243140; }
:root[data-theme="dark"] .cm-bld { fill: #3e7fcc; }
:root[data-theme="dark"] .cm-archive { fill: #56626f; }
:root[data-theme="dark"] .cm-entr { fill: #b6f23a; }
.bld-info { padding: 10px 14px 12px; font-size: 14px; border-top: 1px solid var(--sep); }
.now-card { padding: 2px 0; }
.now-card + .now-card { border-top: 1px solid var(--sep); margin-top: 10px; padding-top: 10px; }
.now-card .now-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
.now-card .subj { font-weight: 700; font-size: 16px; margin: 2px 0; }
.now-card .where { font-size: 14px; }
.now-card.on-map .where::before { content: "📍 "; }
.list .item.place .num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--btn-soft); color: var(--accent);
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.list .item.place .walk { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.list .item.place .walk b { display: block; font-size: 15px; }
.list .item.place .walk span { font-size: 12px; color: var(--hint); }
.places-actions { flex-wrap: wrap; margin-bottom: 10px; }
.places-actions .btn { flex: 1 1 auto; }
.attribution { font-size: 11px; }
.form textarea, .card textarea {
  width: 100%; border: 1px solid var(--sep); border-radius: 12px; padding: 10px 12px;
  background: var(--bg2); font: inherit; font-size: 16px; resize: vertical; outline: 0; color: var(--text);
}
.field textarea:focus { border-color: var(--btn); }
.ymap iframe { display: block; width: 100%; height: 300px; border: 0; border-radius: var(--radius); margin-bottom: 10px; background: var(--fill); }
.room-help { display: flex; gap: 16px; align-items: center; }
.big-room { display: flex; font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.big-room .d1 { color: #4a8fe0; }
.big-room .d2 { color: #f5a623; }
.big-room .d3 { color: #5fb33c; }

/* ---- отзывы и фото ---- */
.avatar.photo { object-fit: cover; background: var(--fill); }
.teacher-head { align-items: flex-start; }
.teacher-head .avatar { flex: none; }
.rating-line { border: 0; background: none; padding: 2px 0 0; color: var(--text); font-size: 13px; text-align: left; }
.stars { color: #f5a623; letter-spacing: 1px; }
.mini-rating { color: #d98e00; font-size: 13px; font-weight: 700; white-space: nowrap; }
.photo-card .teacher-photo { display: block; max-width: 180px; max-height: 220px; border-radius: 14px; margin-bottom: 10px; object-fit: cover; }
.rating-summary { display: flex; align-items: center; gap: 14px; }
.big-rating { font-size: 40px; font-weight: 800; line-height: 1; }
.rating-summary .stars { font-size: 20px; }
.review { padding: 12px 14px; border-bottom: 1px solid var(--sep); }
.review:last-child { border-bottom: 0; }
.review-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.review-text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-actions { display: flex; gap: 14px; margin-top: 6px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--hint); font-size: 13px; }
.link-btn.danger { color: var(--danger); }
.review-form .form-title { font-weight: 700; margin-bottom: 8px; }
.review-form textarea {
  width: 100%; border: 1px solid var(--sep); border-radius: 12px; padding: 10px 12px;
  background: var(--bg2); font: inherit; font-size: 16px; resize: vertical; outline: 0;
}
.review-form textarea:focus { border-color: var(--btn); }
.review-form .counter { text-align: right; margin: 2px 2px 8px; }
.review-form .note { color: var(--danger); font-size: 13px; margin-bottom: 6px; }
.star-pick { display: flex; gap: 4px; margin-bottom: 10px; }
.star-pick button { border: 0; background: none; font-size: 32px; line-height: 1; padding: 2px; color: #f5a623; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--btn); }
.walk-big b { font-size: 18px; }

/* ---- выбор группы ---- */
.pick-intro { text-align: center; }
.pick-intro .big { font-size: 36px; }
.pick-intro .title { font-weight: 700; font-size: 17px; margin: 4px 0 2px; }
.step-head { display: flex; align-items: baseline; gap: 10px; }
.step-head h2 { flex: 1; }
.group-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.group-grid .chip { font-weight: 600; }
.chip.chip-action { background: var(--btn-soft); color: var(--accent); font-weight: 600; }
.item-card { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; text-align: left; color: var(--text); }
.item-card .title { font-weight: 600; }
.item-card .sub { color: var(--hint); font-size: 13px; }
.group-row { flex-wrap: wrap; }

/* ---- к кому обратиться ---- */
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.room-tag { flex: none; font-size: 12px; font-weight: 700; color: var(--accent); background: var(--btn-soft); border-radius: 8px; padding: 2px 7px; }
.unit-card .unit-title { border: 0; background: none; padding: 0 0 8px; font-weight: 700; font-size: 16px; color: var(--text); text-align: left; }
.unit-card .about { margin-bottom: 10px; }
.unit-card .about .label, .stat-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--hint); margin-bottom: 3px; }
.contacts { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--sep); padding-top: 10px; }
.unit-card .about + .contacts { margin-top: 0; }
.crow { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; overflow-wrap: anywhere; }
.crow .ci { flex: none; width: 20px; text-align: center; }
.link-btn.accent { color: var(--accent); font-weight: 600; text-align: left; }
.staff-photo { display: block; max-width: 200px; max-height: 240px; border-radius: 14px; margin: 0 auto 10px; object-fit: cover; }
.is-hidden { opacity: .55; }
.mod-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mod-strip .hint { flex: 1 0 100%; }
.danger-text { color: var(--danger) !important; }
.role-card { font-size: 14px; }

/* ---- админка ---- */
.admin-head { display: flex; align-items: center; gap: 10px; }
.admin-head h1 { margin-right: auto; }
.role-pill { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--btn-soft); border-radius: 9px; padding: 3px 9px; }
.role-pill.small { font-size: 10px; padding: 1px 6px; }
.chip .count { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.sub-chips .chip { font-size: 13px; padding: 6px 11px; }
.mod-card .mod-subj { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.mod-card .mod-subj .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--hint); letter-spacing: .03em; }
.mod-card .note { color: var(--danger); font-size: 13px; margin-top: 4px; }
.mod-card .hint { margin-top: 3px; }
.mod-actions { flex-wrap: wrap; margin-top: 10px; }
.mod-actions .btn { min-height: 38px; padding: 8px 14px; }
.mod-card.done { opacity: .7; }
.mod-photo { flex: none; width: 96px; height: 116px; border-radius: 12px; overflow: hidden; background: var(--fill); display: flex; align-items: center; justify-content: center; }
.mod-photo img { width: 100%; height: 100%; object-fit: cover; }
.mod-photo .spinner { margin: 0; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.team-row { align-items: flex-start; flex-wrap: wrap; }
.team-actions { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 0 100%; padding-left: 52px; }
.log-row { background: var(--bg); padding: 10px 14px; border-bottom: 1px solid var(--sep); }
.log-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.log-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-size: 13px; }
.log-text { margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }
.log-text.muted { color: var(--hint); }
.broadcast-preview b { display: block; margin-bottom: 6px; }

/* ---- статистика ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tiles.small { margin: 4px 0 12px; }
.tile { background: var(--bg); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat-card .tile { background: var(--bg2); }
.tile-label { font-size: 12px; color: var(--hint); }
.tile-value { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tiles.small .tile-value { font-size: 18px; }
.tile-sub { font-size: 11px; color: var(--hint); }
.stat-card .stat-title { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.stat-sub { margin: 12px 0 6px; }
.viz-wrap { position: relative; touch-action: pan-y; }
.viz { display: block; width: 100%; height: auto; overflow: visible; }
.viz-grid { stroke: var(--sep); stroke-width: 1; }
.viz-tick { fill: var(--hint); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-end { fill: var(--text); font-size: 11px; font-weight: 600; }
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { stroke: none; opacity: .1; }
.viz-dot { stroke: var(--bg); stroke-width: 2; }
.viz-cross { stroke: var(--hint); stroke-width: 1; }
.viz-bar { fill: var(--s1); }
.viz-bar.on { fill: var(--s2); }
.viz-line.s1, .key.s1 { stroke: var(--s1); }
.viz-line.s2, .key.s2 { stroke: var(--s2); }
.viz-line.s3, .key.s3 { stroke: var(--s3); }
.viz-area.s1, .viz-dot.s1 { fill: var(--s1); }
.viz-area.s2, .viz-dot.s2 { fill: var(--s2); }
.viz-area.s3, .viz-dot.s3 { fill: var(--s3); }
.key { display: inline-block; width: 14px; height: 0; border-top: 3px solid; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.key.s1 { border-color: var(--s1); }
.key.s2 { border-color: var(--s2); }
.key.s3 { border-color: var(--s3); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.viz-tip {
  position: absolute; z-index: 3; pointer-events: none; background: var(--bg); color: var(--text);
  border: 1px solid var(--sep); border-radius: 10px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.18);
  white-space: nowrap;
}
.viz-tip-row { margin-top: 2px; }
.barlist { display: flex; flex-direction: column; gap: 5px; }
.bl-row { display: grid; grid-template-columns: minmax(0, 42%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bl-track { height: 10px; background: var(--fill); border-radius: 5px; overflow: hidden; }
.bl-fill { height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.bl-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 28px; text-align: right; }
.heat { display: grid; grid-template-columns: 22px repeat(24, 1fr); gap: 2px; margin-top: 12px; }
.heat-h, .heat-d { font-size: 10px; color: var(--hint); text-align: center; line-height: 14px; }
.heat-d { text-align: left; line-height: 16px; }
.heat-c { height: 16px; border-radius: 3px; background: var(--fill); position: relative; overflow: hidden; }
.heat-c::after { content: ""; position: absolute; inset: 0; background: var(--s1); opacity: var(--a, 0); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.plain, table.cohort, .viz-table table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.plain th, table.plain td, .viz-table th, .viz-table td, table.cohort th, table.cohort td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--sep); white-space: nowrap; }
table.plain th:first-child, table.plain td:first-child, .viz-table th:first-child, .viz-table td:first-child, table.cohort td:first-child, table.cohort th:first-child { text-align: left; white-space: normal; }
table.plain th, .viz-table th, table.cohort th { color: var(--hint); font-weight: 600; font-size: 12px; }
table.cohort caption { text-align: left; font-size: 12px; color: var(--hint); margin-bottom: 6px; }
table.cohort td.cc { position: relative; z-index: 0; }
table.cohort td.cc::before { content: ""; position: absolute; inset: 1px; z-index: -1; border-radius: 4px; background: var(--s1); opacity: calc(var(--a, 0) * .6); }
.viz-table { margin-top: 8px; }
.viz-table summary { font-size: 13px; color: var(--accent); cursor: pointer; padding: 4px 0; }

/* ---- игры ---- */
.game-card { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--bg); border-radius: var(--radius); margin-bottom: 10px; width: 100%; border: 0; text-align: left; }
.game-card:active { opacity: .85; }
.game-card canvas { flex: none; width: 76px; height: 76px; border-radius: 18px; }
.game-card .title { font-weight: 700; font-size: 16px; }
.game-card .desc { font-size: 13px; color: var(--hint); margin: 2px 0 6px; }
.game-card .stats { font-size: 13px; }
.game-card .stats b { color: var(--accent); }

#game-layer {
  position: fixed; inset: 0; z-index: 30; background: #0d1520;
  touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden;
}
#game-layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: flex-start; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 10px 0;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.hud .hud-btn {
  pointer-events: auto; border: 0; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(0, 0, 0, .35); color: #fff; font-size: 18px; backdrop-filter: blur(6px);
}
.hud .score { flex: 1; text-align: center; font-weight: 800; font-size: 28px; line-height: 40px; }
.hud .side { min-width: 40px; text-align: right; font-size: 13px; line-height: 1.25; padding-top: 3px; }

.panel-wrap {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: safe center; justify-content: center;
  background: rgba(5, 10, 18, .55); padding: 20px; animation: fade .18s ease-out; overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel {
  width: 100%; max-width: 360px; background: var(--bg); color: var(--text); border-radius: 20px;
  padding: 20px 18px 16px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.35);
  animation: pop .22s cubic-bezier(.2, 1.4, .5, 1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.panel .ptitle { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.panel .pbig { font-size: 44px; font-weight: 800; color: var(--accent); line-height: 1.1; margin: 6px 0; }
.panel .stars { font-size: 34px; letter-spacing: 4px; margin: 4px 0; }
.panel .plines { color: var(--hint); font-size: 14px; margin-bottom: 14px; }
.panel .plines div { margin: 3px 0; }
.panel .plines .good { color: #27a35a; font-weight: 600; }
.panel .pbtns { display: flex; flex-direction: column; gap: 8px; }
.panel .levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0 14px; }
.panel .levels button {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: var(--btn-soft);
  color: var(--text); font-weight: 700; font-size: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.panel .levels button small { font-size: 10px; letter-spacing: 1px; color: var(--gold); }
.panel .levels button[disabled] { opacity: .35; }

/* ---- рейтинг ---- */
.brow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--sep); }
.brow:last-child { border-bottom: 0; }
.brow.me { background: var(--btn-soft); }
.brow .place { flex: none; width: 30px; text-align: center; font-weight: 700; color: var(--hint); font-variant-numeric: tabular-nums; }
.brow .place.m1, .brow .place.m2, .brow .place.m3 { font-size: 20px; }
.brow .name { font-weight: 600; }
.brow .aff { font-size: 12px; color: var(--hint); }
.brow .pts { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; }
.brow .ban { border: 0; background: none; color: var(--danger); font-size: 16px; padding: 4px; }
.pinned { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 8px); box-shadow: 0 4px 18px rgba(0,0,0,.15); }

/* ---- профиль ---- */
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 13px; color: var(--hint); margin: 0 2px 4px; }
.field input {
  width: 100%; border: 1px solid var(--sep); border-radius: 12px; padding: 11px 12px; background: var(--bg2); font-size: 16px; outline: 0;
}
.field input:focus { border-color: var(--btn); }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--sep); }
.toggle:last-child { border-bottom: 0; }
.toggle .grow small { display: block; color: var(--hint); font-size: 12px; }
.switch { position: relative; flex: none; width: 50px; height: 30px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: rgba(128, 138, 150, .45); transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + i { background: #34c759; }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 2px solid var(--btn); outline-offset: 2px; }
.preview { display: flex; align-items: center; gap: 12px; }
.noscript { padding: 20px; text-align: center; }

/* телефон боком: окно шире и ниже, уровни в два ряда */
@media (max-height: 500px) and (orientation: landscape) {
  .panel-wrap { padding: 10px; }
  .panel { max-width: 560px; padding: 12px 16px 10px; }
  .panel .ptitle { font-size: 18px; }
  .panel .pbig { font-size: 34px; margin: 2px 0; }
  .panel .stars { font-size: 26px; margin: 0; }
  .panel .plines { margin-bottom: 8px; }
  .panel .levels { grid-template-columns: repeat(6, 1fr); margin: 6px 0 8px; }
  .panel .levels button { aspect-ratio: auto; padding: 6px 0; }
  .panel .pbtns { flex-direction: row; }
  .panel .pbtns .btn { min-height: 38px; padding: 8px 12px; }
}

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