/* Layout: one-screen mobile game column over a night-sky scene; gold for anything you press, glass for panels,
   a neon-edged navy board as the hero object. Single deliberate dark world (no light theme). */
:root {
  /* небо */
  --sky-1: #120D35;
  --sky-2: #241A6E;
  --sky-3: #3B2BA6;
  --sky-4: #5A45CF;
  /* стекло и текст */
  --glass: rgba(255, 255, 255, .08);
  --glass-2: rgba(255, 255, 255, .14);
  --glass-line: rgba(255, 255, 255, .18);
  --fg: #FFFFFF;
  --muted: #B8B1EC;
  --ink: #2A1260;            /* тёмный фиолетовый контур, как у мультяшной графики */
  /* золото */
  --gold-hi: #FFF3A6;
  --gold: #FFC83D;
  --gold-2: #F59E0B;
  --gold-deep: #B45309;
  --gold-ink: #4A2100;
  /* акценты */
  --cyan: #5EDCFF;
  --pink: #FF5FA2;
  --red: #FF4D5E;
  --red-deep: #A3122A;
  --green: #3BE39A;
  --violet: #8B6CFF;
  /* доска */
  --sq-light: #ECEAFF;
  --sq-dark: #262A66;
  --frame: #12143D;
  --coord: #A9A3E8;
  --dot: rgba(255, 200, 61, .9);
  --last: rgba(255, 200, 61, .28);

  --font-display: "Unbounded", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top-inset: max(var(--tg-safe-area-inset-top, 0px), env(safe-area-inset-top, 0px));
  --bottom-inset: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--sky-1); }
body {
  background: transparent; /* под страницей — фиксированное небо .sky; фон html страхует до его отрисовки */
  color: var(--fg); font-family: var(--font-body); font-size: 15px; font-weight: 700;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Небо ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(90% 45% at 50% 0%, rgba(122, 92, 255, .35), transparent 70%),
    radial-gradient(70% 40% at 85% 100%, rgba(255, 95, 162, .22), transparent 70%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 40%, var(--sky-3) 78%, var(--sky-4) 100%);
}
.cloud {
  position: absolute; border-radius: 999px; background: #C9BEFF; opacity: .16; filter: blur(2px);
  box-shadow: 40px -18px 0 6px #C9BEFF, 90px -4px 0 0 #C9BEFF, -36px 4px 0 -4px #C9BEFF;
}
.cloud.c1 { width: 140px; height: 44px; left: -30px; bottom: 60px; }
.cloud.c2 { width: 160px; height: 50px; right: -40px; bottom: 120px; opacity: .12; }
.cloud.c3 { width: 120px; height: 38px; left: 55%; bottom: -10px; opacity: .2; }
.cloud.c4 { width: 110px; height: 34px; left: -20px; top: 22%; opacity: .08; }
.spark { position: absolute; width: var(--s, 10px); height: var(--s, 10px); color: #FFF6C2; animation: twinkle var(--d, 3s) ease-in-out infinite var(--delay, 0s); }
.spark svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 4px rgba(255, 240, 160, .8)); }
.spark.dot { border-radius: 50%; background: #fff; width: 3px; height: 3px; box-shadow: 0 0 6px #fff; }
@keyframes twinkle { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }

.app {
  max-width: 460px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column;
  padding-top: calc(10px + var(--top-inset) + var(--tg-content-safe-area-inset-top, 0px));
  padding-bottom: calc(14px + var(--bottom-inset));
}
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; }

/* ---------- Кнопки: игровые, с «толщиной» и нажатием ---------- */
.btn {
  --face: linear-gradient(180deg, #7C63F2 0%, #5B43D6 100%);
  --edge: #35238F;
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 50px; padding: 0 18px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .22);
  background: var(--face); color: #fff; font-weight: 900; font-size: 16px; letter-spacing: .01em;
  box-shadow: 0 5px 0 var(--edge), 0 10px 18px rgba(10, 5, 40, .35), inset 0 2px 0 rgba(255, 255, 255, .25);
  text-shadow: 0 2px 0 rgba(20, 10, 60, .35);
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn::after { /* блик сверху */
  content: ""; position: absolute; left: 10px; right: 10px; top: 5px; height: 34%; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0)); pointer-events: none;
}
.btn:active:not([disabled]) { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge), 0 4px 8px rgba(10, 5, 40, .35), inset 0 2px 0 rgba(255, 255, 255, .25); }
.btn.primary {
  --face: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 38%, var(--gold-2) 100%);
  --edge: var(--gold-deep);
  color: var(--gold-ink); border-color: rgba(255, 250, 220, .7); text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.danger { --face: linear-gradient(180deg, #FF7A86 0%, var(--red) 55%, #E2324A 100%); --edge: var(--red-deep); }
.btn.big { min-height: 60px; font-size: 18px; border-radius: 20px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn[disabled] { filter: grayscale(.6) brightness(.8); opacity: .65; cursor: default; }
@media (hover: hover) { .btn:hover:not([disabled]) { filter: brightness(1.07); } }

.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 2px solid var(--glass-line); background: var(--glass-2);
  display: grid; place-items: center; box-shadow: 0 3px 0 rgba(10, 5, 40, .45);
}
.icon-btn svg { width: 20px; height: 20px; }
.actions { display: flex; flex-direction: column; gap: 12px; }
.actions.push { margin-top: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; font-weight: 600; }
.note b { color: var(--gold); }
.label { margin: 0; font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.block { display: flex; flex-direction: column; gap: 10px; }

.topbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; min-height: 44px; }
.topbar .title { text-align: center; font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); letter-spacing: .02em; }
.tg .topbar .back { visibility: hidden; } /* в Telegram назад — системная кнопка */

/* ---------- Стеклянные панели ---------- */
.glass, .profile, .list, .hero-card, .player, .stat, .seg {
  background: linear-gradient(180deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
  border: 2px solid var(--glass-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 10px 24px rgba(8, 4, 30, .28);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ---------- Главная: логотип и сцена ---------- */
.home { gap: 10px; }
.hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding-top: 0; }
.logo {
  position: relative; isolation: isolate; margin: 0; font-family: var(--font-display); font-weight: 900;
  font-size: clamp(46px, 15vw, 62px); line-height: 1.1; letter-spacing: .01em; color: var(--ink);
  filter: drop-shadow(0 10px 14px rgba(10, 4, 40, .45));
}
.logo::before { /* толстая тёмная обводка и «толщина» букв — слой под золотом */
  content: attr(data-text); position: absolute; inset: 0; z-index: -1; color: var(--ink);
  -webkit-text-stroke: 12px var(--ink); text-shadow: 0 7px 0 #1A0A45;
}
/* Когда app.js нарисовал SVG-логотип, текстовая заглушка и её обводка не нужны. */
.logo.svg { filter: none; width: min(100%, 380px); line-height: 0; }
.logo.svg::before { content: none; }
.logo-svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 10px 14px rgba(10, 4, 40, .5)); }
.logo-fill {
  display: block;
  background: linear-gradient(180deg, var(--gold-hi) 12%, var(--gold) 48%, var(--gold-2) 74%, #E07A00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag-pill {
  font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: #3B2BA6;
  padding: 6px 14px; border-radius: 999px; background: linear-gradient(180deg, #FFFFFF, #DCD6FF);
  border: 2px solid #fff; box-shadow: 0 3px 0 #8C7DE0, 0 6px 14px rgba(10, 5, 40, .35);
}
.hero-deco { position: absolute; inset: -6px -8px auto; height: 100%; pointer-events: none; }
.deco { position: absolute; width: var(--w, 28px); animation: float 4s ease-in-out infinite var(--delay, 0s); }
.deco svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 6px rgba(10, 4, 40, .45)); }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-7px) rotate(calc(var(--r, 0deg) + 6deg)); } }

.hero-stage { position: relative; width: 100%; height: 146px; perspective: 560px; margin-top: -26px; pointer-events: none; }
.hero-stage .tilt { position: absolute; left: 50%; top: 0; width: 168px; transform: translateX(-50%) rotateX(50deg); transform-style: preserve-3d; }
.hero-stage .frame { padding: 8px; border-radius: 14px; }
.hero-stage .board .sq { display: grid; place-items: center; }
.hero-stage .disc { width: 76%; height: 76%; --lift: 0 2px 0 var(--edge), 0 3px 4px rgba(0, 0, 0, .35); }
.hero-stage .disc::before { display: none; }
/* Красный король стоит на сцене и не двигается. */
.king-spot { position: absolute; left: 5%; bottom: -2px; width: 128px; }
.king-shadow { position: absolute; left: 14%; right: 14%; bottom: 2px; height: 22px; border-radius: 50%; background: radial-gradient(closest-side, rgba(10, 4, 40, .55), rgba(10, 4, 40, 0)); }
.hero-king { position: relative; display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 10px rgba(10, 4, 40, .45)); }

/* ---------- Маскоты ---------- */
.mascot { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 8px 10px rgba(10, 4, 40, .5)); animation: bob 2.6s ease-in-out infinite; }
.m2 .mascot { animation-delay: -1.3s; }
.mascot .arm-wave { transform-box: view-box; transform-origin: 14px 58px; animation: wave 1.1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes wave { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-22deg); } }

/* ---------- Профиль, списки ---------- */
.profile { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 20px; }
.ava {
  width: 42px; height: 42px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  background: linear-gradient(180deg, #9C86FF, #6C4FE6); color: #fff; font-weight: 900; font-size: 17px;
  border: 3px solid var(--gold); box-shadow: 0 3px 0 var(--gold-deep);
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava.sm { width: 34px; height: 34px; font-size: 14px; border-width: 2px; box-shadow: 0 2px 0 var(--gold-deep); }
.ava.wait { background: rgba(255, 255, 255, .06); border: 3px dashed var(--glass-line); color: var(--muted); box-shadow: none; }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pname { font-weight: 900; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psub { font-size: 12.5px; color: var(--muted); font-weight: 700; min-height: 1.2em; }
.rating-chip {
  display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 900; font-size: 16px;
  padding: 6px 12px 6px 8px; border-radius: 999px; color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 50%, var(--gold-2)); box-shadow: 0 3px 0 var(--gold-deep);
}
.rating-chip::before { content: ""; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFF6C2, var(--gold) 55%, var(--gold-deep)); box-shadow: inset 0 0 0 2px rgba(180, 83, 9, .6); }

.list { display: flex; flex-direction: column; border-radius: 20px; overflow: hidden; }
.list:empty { display: none; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: left; border: 0; background: none; border-top: 1px solid rgba(255, 255, 255, .1); }
.item:first-child { border-top: 0; }
button.item:active { background: rgba(255, 255, 255, .06); }
.item .right { text-align: right; font-variant-numeric: tabular-nums; font-weight: 900; }
.item.me { background: linear-gradient(90deg, rgba(255, 200, 61, .22), rgba(255, 200, 61, .04)); }
.item .place {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%;
  font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px;
}
.item .place.p1 { background: linear-gradient(180deg, #FFF3A6, #FFC83D 50%, #F59E0B); color: var(--gold-ink); box-shadow: 0 2px 0 var(--gold-deep); }
.item .place.p2 { background: linear-gradient(180deg, #FFFFFF, #C9CCE0); color: #3B3F5C; box-shadow: 0 2px 0 #7C809E; }
.item .place.p3 { background: linear-gradient(180deg, #FFD3A8, #E0894A); color: #4A1F00; box-shadow: 0 2px 0 #8A4310; }
.pill { display: inline-block; font-size: 11px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: var(--muted); white-space: nowrap; }
.pill.go { background: linear-gradient(180deg, var(--gold-hi), var(--gold)); color: var(--gold-ink); box-shadow: 0 2px 0 var(--gold-deep); animation: nudge 1.6s ease-in-out infinite; }
.pill.win { background: rgba(59, 227, 154, .16); color: var(--green); }
.pill.loss { background: rgba(255, 77, 94, .16); color: #FF8A95; }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.plus { color: var(--green); }
.minus { color: #FF8A95; }
.empty-state { padding: 26px 16px; text-align: center; color: var(--muted); font-weight: 700; }

.rules { color: var(--muted); font-size: 13.5px; line-height: 1.5; font-weight: 600; padding: 0 4px; }
.rules summary { cursor: pointer; font-weight: 900; color: #fff; }
.rules ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.rules li::marker { color: var(--gold); }
.rules b { color: #fff; }
.rules-sub { margin: 12px 0 0; font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
/* Номер версии лежит в самом низу экрана и не сдвигает кнопки вверх. */
.version { margin: auto 0 0; padding-top: 6px; text-align: center; font-size: 11.5px; font-weight: 700; color: rgba(184, 177, 236, .55); }
.offline-note { display: flex; flex-direction: column; gap: 10px; }
a.btn { text-decoration: none; }

/* ---------- Плашка «нет связи» ---------- */
.netbar {
  position: fixed; left: 50%; top: calc(10px + var(--top-inset) + var(--tg-content-safe-area-inset-top, 0px)); z-index: 40;
  transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: linear-gradient(180deg, #FF7A86, var(--red)); color: #fff; font-weight: 900; font-size: 13px;
  box-shadow: 0 3px 0 var(--red-deep), 0 8px 18px rgba(8, 4, 30, .45); white-space: nowrap;
}
.netbar .spinner { width: 14px; height: 14px; border-width: 2.5px; border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
.item .when { display: block; font-size: 11.5px; font-weight: 800; color: var(--muted); margin-top: 3px; text-align: right; font-variant-numeric: tabular-nums; }
.item .when.low { color: #FF8A95; }

/* ---------- Переключатели ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 5px; border-radius: 18px; }
.seg button { min-height: 44px; border: 0; border-radius: 13px; background: none; font-weight: 900; font-size: 14px; color: var(--muted); transition: background .15s, color .15s; }
.seg button[aria-checked="true"] {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 45%, var(--gold-2)); color: var(--gold-ink);
  box-shadow: 0 3px 0 var(--gold-deep);
}

.setup-mascots { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 150px; }
.setup-mascots > div { width: 118px; }

/* ---------- Лобби ---------- */
.lobby-body { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.hero-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 26px 18px; border-radius: 24px; }
.hero-card h2 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 21px; line-height: 1.2; text-wrap: balance; }
.hero-card p { margin: 0; color: var(--muted); line-height: 1.45; text-wrap: balance; font-weight: 700; }
.versus { display: flex; align-items: center; gap: 10px; }
.versus .vs {
  font-family: var(--font-display); font-weight: 900; font-size: 28px; font-style: italic; color: var(--gold);
  -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 4px 0 var(--ink); transform: rotate(-8deg);
}
.versus .side { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 104px; }
.versus .side .nm { font-weight: 900; font-size: 14px; max-width: 104px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.versus .side .rt { font-size: 12.5px; color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 900; }
.versus .ava { width: 66px; height: 66px; font-size: 26px; border-width: 4px; box-shadow: 0 4px 0 var(--gold-deep), 0 0 0 6px rgba(255, 200, 61, .15); }
.versus .ava.wait { box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { font-size: 12.5px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid var(--glass-line); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; font-size: 13.5px; }

/* ---------- Доска ---------- */
.frame {
  position: relative; padding: 20px; border-radius: 20px; width: 100%;
  background: linear-gradient(180deg, #1B1E52, var(--frame));
  border: 2px solid rgba(140, 120, 255, .55);
  box-shadow:
    0 0 0 2px rgba(10, 8, 40, .8),
    0 0 22px rgba(124, 99, 242, .55),
    0 0 44px rgba(94, 220, 255, .18),
    0 14px 30px rgba(6, 3, 25, .55),
    inset 0 0 0 4px rgba(255, 200, 61, .0);
}
.frame::before { /* золотая окантовка вокруг поля */
  content: ""; position: absolute; inset: 14px; border-radius: 8px; border: 2px solid rgba(255, 200, 61, .75);
  box-shadow: 0 0 8px rgba(255, 200, 61, .35); pointer-events: none;
}
.board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden; }
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; }
.sq.l { background: var(--sq-light); }
.sq.d { background: linear-gradient(145deg, #2C3175, var(--sq-dark)); }
.sq.last::before, .sq.trail::before { content: ""; position: absolute; inset: 0; background: var(--last); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(255, 200, 61, .42); box-shadow: inset 0 0 0 2px rgba(255, 220, 120, .9); }
.sq.tgt { cursor: pointer; }
.sq.tgt::after { content: ""; position: absolute; inset: 35%; border-radius: 50%; background: var(--dot); box-shadow: 0 0 10px rgba(255, 200, 61, .9); animation: pulse-dot 1.2s ease-in-out infinite; }
.sq.tgt.cap::after { inset: 8%; background: transparent; border: 3px solid var(--pink); box-shadow: 0 0 12px rgba(255, 95, 162, .9), inset 0 0 8px rgba(255, 95, 162, .5); animation: none; }
.sq.mine { cursor: pointer; }
@keyframes pulse-dot { 0%, 100% { transform: scale(1); } 50% { transform: scale(.8); } }

.pieces { position: absolute; inset: 0; pointer-events: none; }
.piece {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; display: grid; place-items: center;
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
  transition: transform .26s cubic-bezier(.3, .7, .25, 1), opacity .25s;
  animation: appear .25s ease-out;
}
.disc {
  --base: #F3E7CC; --hi: #FFFFFF; --rim: #D9C29A; --edge: #A88C5E; --ring: rgba(150, 115, 60, .35); --ring-hi: rgba(255, 255, 255, .9);
  --lift: 0 4px 0 var(--edge), 0 7px 10px rgba(0, 0, 20, .5);
  position: relative; width: 80%; height: 80%; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, var(--rim) 60%, transparent 86%),
    radial-gradient(circle at 34% 26%, var(--hi), var(--base) 62%);
  box-shadow: var(--lift), inset 0 -3px 4px rgba(0, 0, 0, .12), inset 0 2px 2px rgba(255, 255, 255, .7);
  transition: transform .15s, box-shadow .15s;
}
.disc::before { /* желобок с бликом, как на настоящей шашке */
  content: ""; position: absolute; inset: 17%; border-radius: 50%;
  border: 2px solid var(--ring); box-shadow: 0 1px 0 var(--ring-hi), inset 0 1px 0 var(--ring-hi);
}
.disc::after { /* глянцевый блик */
  content: ""; position: absolute; left: 16%; top: 9%; width: 46%; height: 26%; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .8), rgba(255, 255, 255, 0) 70%);
  transform: rotate(-24deg); pointer-events: none;
}
.b .disc, .b.disc {
  --base: #2B2B45; --hi: #7272A6; --rim: #3D3D62; --edge: #07071A; --ring: rgba(0, 0, 0, .45); --ring-hi: rgba(150, 150, 220, .35);
}
.b .disc::after, .b.disc::after { background: radial-gradient(ellipse at center, rgba(200, 200, 255, .55), rgba(255, 255, 255, 0) 70%); }
.taken-row .mini .disc::after, .hero-stage .disc::after { display: none; }
.crown { display: none; position: absolute; inset: 24%; width: 52%; height: 52%; color: var(--gold); filter: drop-shadow(0 1px 0 var(--gold-deep)) drop-shadow(0 0 4px rgba(255, 200, 61, .7)); }
.king .crown { display: block; }
.piece.sel { z-index: 2; }
.piece.sel .disc { transform: translateY(-6%) scale(1.08); box-shadow: 0 5px 0 var(--edge), 0 12px 18px rgba(0, 0, 20, .5), 0 0 16px rgba(255, 200, 61, .75); }
.piece.taken { opacity: .3; }
.piece.taken .disc { transform: scale(.8); }
.piece.gone { opacity: 0; }
.piece.gone .disc { transform: scale(1.4); }
.piece.must .disc { animation: must 1.2s ease-in-out infinite; }
@keyframes must { 50% { box-shadow: var(--lift), 0 0 0 4px var(--pink), 0 0 14px var(--pink); } }
@keyframes appear { from { opacity: 0; } }

.coords { position: absolute; display: grid; color: var(--coord); font-size: 10px; font-weight: 900; text-align: center; pointer-events: none; }
.coords.files { left: 20px; right: 20px; bottom: -1px; height: 20px; line-height: 20px; grid-template-columns: repeat(8, 1fr); }
.coords.ranks { top: 20px; bottom: 20px; left: 0; width: 20px; grid-template-rows: repeat(8, 1fr); align-items: center; }

/* ---------- Экран партии ---------- */
.game { gap: 10px; }
.status { text-align: center; }
.status #status-title { display: block; font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--gold); text-shadow: 0 2px 0 var(--ink); letter-spacing: .01em; }
.status small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 800; margin-top: 3px; min-height: 1em; font-variant-numeric: tabular-nums; }

.player { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 18px; transition: border-color .2s, box-shadow .2s; }
.player.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px rgba(255, 200, 61, .35), inset 0 1px 0 rgba(255, 255, 255, .18); }
.player .pname { font-size: 15px; }
.player .psub { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.player.active .psub { color: var(--gold); }
.player .psub.low { color: #FF8A95; animation: nudge .8s ease-in-out infinite; }
.avatar { width: 32px; height: 32px; flex: none; display: grid; place-items: center; }
.avatar > div { width: 100%; height: 100%; display: grid; place-items: center; }
.avatar .disc { width: 100%; height: 100%; --lift: 0 2px 0 var(--edge), 0 3px 5px rgba(0, 0, 20, .4); }
.psub.thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.taken-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 900; font-size: 14px; color: var(--gold); }
.taken-row .stack { display: flex; }
.taken-row .mini { width: 13px; height: 13px; margin-left: -5px; display: block; }
.taken-row .mini:first-child { margin-left: 0; }
.taken-row .mini .disc { width: 100%; height: 100%; display: block; --lift: 0 1px 0 var(--edge); }
.taken-row .mini .disc::before { display: none; }

.stage { position: relative; display: flex; justify-content: center; }
.stage .frame { width: min(100%, calc(100vh - 340px), 520px); width: min(100%, calc(100dvh - 340px - var(--top-inset) - var(--bottom-inset)), 520px); min-width: 260px; }
.toast, .gtoast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96); z-index: 5;
  background: linear-gradient(180deg, #FFFFFF, #E4DEFF); color: var(--ink); padding: 11px 18px; border-radius: 16px;
  font-weight: 900; font-size: 14.5px; box-shadow: 0 4px 0 #8C7DE0, 0 12px 24px rgba(8, 4, 30, .45);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; white-space: nowrap;
}
.gtoast { position: fixed; top: auto; bottom: calc(24px + var(--bottom-inset)); transform: translate(-50%, 0) scale(.96); z-index: 30; max-width: calc(100% - 32px); white-space: normal; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.gtoast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.log { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; font-variant-numeric: tabular-nums; font-size: 13px; min-height: 34px; align-items: center; }
.log::-webkit-scrollbar { display: none; }
.log .pair { display: flex; gap: 6px; flex: none; align-items: center; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); }
.log .n { color: var(--muted); }
.log .mv { font-weight: 900; }
.log .mv.cur { color: var(--gold); }
.log .empty { color: var(--muted); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.controls .btn { min-height: 50px; font-size: 15px; }

/* ---------- История ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 12px 6px; border-radius: 18px; text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 800; }

/* ---------- Итог партии ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; background: rgba(8, 4, 30, .6);
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(16px + var(--bottom-inset)) max(16px, env(safe-area-inset-left, 0px));
  animation: fade .2s ease-out; overflow: hidden;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; width: 100%; max-width: 440px; border-radius: 28px; padding: 70px 22px 22px; margin-top: 70px;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  background: linear-gradient(180deg, #4B37C2, #2B1F86); border: 3px solid rgba(255, 255, 255, .3);
  box-shadow: 0 8px 0 #1A1158, 0 24px 50px rgba(5, 2, 25, .6), inset 0 2px 0 rgba(255, 255, 255, .25);
  animation: rise .35s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes rise { from { transform: translateY(40px) scale(.95); opacity: 0; } }
.res-mascot { position: absolute; left: 50%; top: -86px; width: 140px; transform: translateX(-50%); }
.sheet h2 {
  margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 900; letter-spacing: .01em; text-wrap: balance;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 50%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 var(--ink));
}
.sheet.lose h2 { background: linear-gradient(180deg, #FFFFFF, #CFC8FF); -webkit-background-clip: text; background-clip: text; }
.sheet p { margin: 0; color: #DCD6FF; line-height: 1.45; font-weight: 700; }
.sheet .delta { align-self: center; color: var(--gold-ink); font-weight: 900; font-size: 16px; font-variant-numeric: tabular-nums; padding: 6px 14px; border-radius: 999px; background: linear-gradient(180deg, var(--gold-hi), var(--gold)); box-shadow: 0 3px 0 var(--gold-deep); }
.sheet .delta.neg { color: #fff; background: linear-gradient(180deg, #FF7A86, var(--red)); box-shadow: 0 3px 0 var(--red-deep); }
.sheet .row2 { margin-top: 6px; }

.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -40px; width: var(--w, 14px); animation: fall var(--d, 2.6s) cubic-bezier(.3, .1, .6, 1) forwards var(--delay, 0s); }
.confetti i svg { width: 100%; height: auto; display: block; }
@keyframes fall { to { transform: translate(var(--x, 0), 110vh) rotate(var(--rot, 540deg)); } }

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

/* ---------- v1.2: ничья, уровни бота, итог, личные встречи ---------- */
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 14px; box-shadow: 0 4px 0 var(--edge), 0 6px 12px rgba(10, 5, 40, .3), inset 0 2px 0 rgba(255, 255, 255, .25); }
.btn.sm::after { top: 4px; border-radius: 10px; }
.controls.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.controls.three .btn { padding: 0 8px; font-size: 14.5px; }

.draw-bar {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 18px; text-align: center;
  background: linear-gradient(180deg, rgba(255, 200, 61, .26), rgba(255, 200, 61, .1)); border: 2px solid rgba(255, 220, 120, .7);
  box-shadow: 0 0 18px rgba(255, 200, 61, .3); animation: rise .3s cubic-bezier(.2, 1.3, .4, 1);
}
.draw-text { font-weight: 900; font-size: 15px; }
.draw-bar .row2 { gap: 10px; }

.res-stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
.res-stats:empty { display: none; }
.res-stats .stat { padding: 10px 4px; border-radius: 16px; }
.res-stats .stat b { font-size: 18px; }
.res-stats .stat span { display: block; line-height: 1.25; margin-top: 2px; }

.sheet.pick { padding: 22px; margin-top: 0; gap: 14px; max-height: calc(100dvh - 32px - var(--bottom-inset)); overflow-y: auto; overscroll-behavior: contain; }
.sheet.pick h2 { font-size: 24px; }
.levels { display: flex; flex-direction: column; gap: 10px; }
.level {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px 10px 10px; text-align: left; border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05)); border: 2px solid var(--glass-line);
  box-shadow: 0 4px 0 rgba(10, 5, 40, .45); transition: transform .08s, box-shadow .08s;
}
.level:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10, 5, 40, .45); }
.level.cur { border-color: var(--gold); box-shadow: 0 4px 0 var(--gold-deep), 0 0 16px rgba(255, 200, 61, .3); }
.level .psub { white-space: normal; line-height: 1.35; }
.level-art { flex: none; width: 54px; }
.level-art .mascot { animation: none; }
/* «Двойник»: две одинаковые шашки, одна чуть позади */
.level-art.twin { position: relative; height: 56px; }
.level-art.twin .mascot { position: absolute; width: 40px; bottom: 0; }
.level-art.twin .mascot:first-child { left: 0; bottom: 10px; opacity: .55; transform: scaleX(-1); }
.level-art.twin .mascot:last-child { right: 0; }

.item.rival { gap: 10px; }
.item .score {
  flex: none; font-family: var(--font-display); font-weight: 900; font-size: 16px; font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); white-space: nowrap;
}
.item .score.win { color: var(--green); background: rgba(59, 227, 154, .14); }
.item .score.loss { color: #FF8A95; background: rgba(255, 77, 94, .14); }
.item.rival .btn { width: auto; flex: none; }

/* Выбор уровня: кружок-отметка справа, у выбранного — золотой с галочкой */
.level .check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--glass-line); background: rgba(255, 255, 255, .06); }
.level.cur .check {
  border-color: var(--gold-deep); background: linear-gradient(180deg, var(--gold-hi), var(--gold)) center / 100% no-repeat;
  box-shadow: 0 2px 0 var(--gold-deep);
  -webkit-mask: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A2100' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E"), linear-gradient(180deg, var(--gold-hi), var(--gold));
  background-size: 70%, 100%; background-position: center; background-repeat: no-repeat;
}

/* ---------- Реакции в партии с другом (v1.3) ---------- */
.player { position: relative; z-index: 10; } /* пузыри и ряд реакций — поверх доски, но под окнами (z 20) */
.react-btn {
  flex: none; width: 40px; height: 40px; padding: 4px 5px 2px; border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06)); border: 2px solid var(--glass-line);
  box-shadow: 0 3px 0 rgba(10, 5, 40, .45); transition: transform .08s, opacity .2s;
}
.react-btn:active { transform: translateY(2px); }
.react-btn .mascot { animation: none; filter: none; }
.react-btn.wait { opacity: .45; }
.react-btn[aria-expanded="true"] { border-color: var(--gold); }

.react-tray {
  position: absolute; right: 6px; bottom: calc(100% + 8px); z-index: 6;
  display: flex; gap: 4px; padding: 6px; border-radius: 20px;
  background: var(--sky-3); border: 2px solid var(--glass-line); box-shadow: 0 10px 24px rgba(8, 4, 30, .55);
  animation: tray-in .16s ease-out;
}
.react-tray[hidden] { display: none; }
.react-opt { width: 44px; height: 44px; padding: 5px; border-radius: 14px; background: rgba(255, 255, 255, .08); transition: transform .08s; }
.react-opt:active { transform: scale(.9); background: rgba(255, 255, 255, .18); }
.react-opt svg { display: block; width: 100%; height: 100%; }
.react-opt .mascot { animation: none; filter: none; }
@keyframes tray-in { from { transform: translateY(8px) scale(.96); opacity: 0; } }

/* Пузырь: у верхней карточки — под ней (на доску), у своей — над ней */
.react-bubble {
  position: absolute; left: 10px; z-index: 5; pointer-events: none;
  display: flex; align-items: center; gap: 6px; padding: 4px 14px 4px 4px; border-radius: 999px;
  background: #FFF6D8; color: var(--ink); font-weight: 900; font-size: 15px; white-space: nowrap;
  border: 2px solid var(--ink); box-shadow: 0 6px 16px rgba(8, 4, 30, .5);
}
.react-bubble[hidden] { display: none; }
#top-bubble { top: calc(100% - 6px); }
#bot-bubble { bottom: calc(100% - 6px); }
.react-bubble .ricon { width: 34px; height: 34px; flex: none; }
.react-bubble .ricon svg { display: block; width: 100%; height: 100%; }
.react-bubble .mascot { animation: none; filter: none; }
.react-bubble.pop { animation: bubble 3s ease-out forwards; }
@keyframes bubble {
  0% { transform: translateY(6px) scale(.6); opacity: 0; }
  8% { transform: translateY(0) scale(1.08); opacity: 1; }
  14% { transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .react-bubble.pop { animation: none; } }

/* ---------- v1.3: достижения и рекорды ---------- */
.stats.records { grid-template-columns: repeat(3, 1fr); }
.stats.records .stat span { display: block; line-height: 1.25; margin-top: 2px; }
.awards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.award {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 9px; border-radius: 18px;
  background: var(--glass); border: 2px solid var(--glass-line); color: var(--muted); font: inherit;
  font-size: 12px; font-weight: 800; line-height: 1.2; text-align: center; transition: transform .15s, border-color .15s;
}
.award .medal { width: 46px; height: auto; }
.award.got { color: var(--fg); background: linear-gradient(180deg, rgba(255, 200, 61, .2), rgba(255, 200, 61, .05)); border-color: rgba(255, 220, 120, .45); }
.award.sel { border-color: var(--gold); box-shadow: 0 0 14px rgba(255, 200, 61, .35); }
.award:active { transform: scale(.96); }
.medal.locked { filter: grayscale(1) brightness(.75); opacity: .45; }
.award-info { margin: 0; min-height: 2.9em; color: var(--muted); font-size: 13.5px; line-height: 1.45; font-weight: 700; text-align: center; }

.res-awards { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.res-awards-label { width: 100%; font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-hi); }
.award-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 220, 120, .55); animation: rise .45s cubic-bezier(.2, 1.3, .4, 1) .3s backwards;
}
.award-chip .medal { width: 30px; height: auto; }
.award-chip b { font-weight: 900; font-size: 14px; }
.empty-state .btn { display: flex; width: auto; margin: 14px auto 0; padding: 0 22px; }
#rating-tabs { flex: none; }
