/* ==========================================================================================
   app.css — design system + shell screens (owner: shell).
   Platform look (§12.1, mockups Main / NickTaken / Invited / Invite): navy surfaces, blue primary, orange accent,
   Unbounded 800 for display type and Golos Text for everything else (self-hosted, assets/fonts/fonts.css).
   Dark-first; light theme via <html data-theme="light">. Board/game styles live in board.css/game.css.

   Token names other stylesheets rely on are kept (--bg, --surface, --surface-2, --accent, --text, --muted, …);
   Gold is retired (§12.1): the old --gold-grad alias and .chip-gold/.badge-gold classes are gone — use --accent-grad,
   .chip-accent and .badge-accent.
   ========================================================================================== */

/* ------------------------------------------------------------------ tokens */
:root,
[data-theme='dark'] {
  color-scheme: dark;
  /* surfaces */
  --bg: #14162b;
  --surface-0: #1b1e3a; /* sunken / quiet tiles */
  --surface: #1e2142; /* cards, rows, inputs */
  --surface-2: #262a50; /* nested controls, segmented track */
  --surface-3: #2a2f5a; /* raised: segmented thumb, pressed */
  --chip-bg: #2c3058; /* chips, disabled button, hairlines inside cards */
  --soon-bg: #181a33; /* "coming soon" tiles */
  --border: #2c3058; /* hairline separators */
  --border-strong: #3a3f6b; /* outlines: secondary buttons, chips */
  --line: #3a3f6b;
  /* text */
  --text: #ffffff;
  --text-2: #b9bed6; /* secondary: labels, hints */
  --muted: #8e94b8; /* tertiary: meta, placeholders */
  --faint: #6f769c; /* decorative only (chevrons, dots) */
  --text-disabled: #9aa0c2;
  /* brand */
  --primary: #2f7bff; /* blue: toggles, focus, selection */
  --primary-strong: #1f63e0; /* blue fills that carry text (≥ 4.5:1 with white) */
  --primary-ink: #ffffff;
  --primary-text: #7faaff; /* links / info text on navy */
  --primary-soft: rgba(47, 123, 255, 0.16);
  --info: #7faaff;
  --info-soft: #a9c6ff;
  --accent: #ff7a2f; /* orange */
  --accent-2: #c9551a; /* deep orange */
  --accent-3: #ff9a5c; /* light orange */
  --accent-ink: #14162b; /* text on orange fills */
  --accent-soft: rgba(255, 122, 47, 0.14);
  --accent-text: #ff9a5c; /* orange text on navy */
  --accent-grad: linear-gradient(180deg, #ff9450 0%, #ff7a2f 55%, #e8641c 100%);
  /* robots */
  --robot-blue: #3a8dff;
  --robot-orange: #ff7a2f;
  --robot-purple: #7b5cff;
  --robot-yellow: #ffc83d;
  /* status */
  --good: #34c77b;
  --good-soft: rgba(52, 199, 123, 0.15);
  --bad: #ff5d5d;
  --bad-soft: rgba(255, 93, 93, 0.15);
  --warn: #ffc83d;
  --warn-soft: rgba(255, 200, 61, 0.15);
  --draw: #8e94b8;
  /* buttons (mockups: primary is white on navy) */
  --btn-primary-bg: #ffffff;
  --btn-primary-ink: #14162b;
  --btn-disabled-bg: #2c3058;
  --btn-disabled-ink: #9aa0c2;
  /* shape */
  --radius: 16px;
  --radius-sm: 12px;
  --radius-md: 14px; /* inputs, rows */
  --radius-lg: 22px;
  --shadow: 0 10px 28px rgba(5, 6, 20, 0.35);
  --shadow-sm: 0 2px 8px rgba(5, 6, 20, 0.25);
  --shadow-lg: 0 20px 52px rgba(5, 6, 20, 0.55);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --focus-ring: 0 0 0 2px var(--primary);
  /* type */
  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --backdrop: rgba(8, 9, 22, 0.66);
  --sk-base: rgba(255, 255, 255, 0.05);
  --sk-shine: rgba(255, 255, 255, 0.1);
  --card-grad: none;
  --hero-grad: radial-gradient(120% 120% at 100% 0%, rgba(47, 123, 255, 0.3) 0%, rgba(47, 123, 255, 0) 55%),
    radial-gradient(90% 90% at 0% 100%, rgba(255, 122, 47, 0.16) 0%, rgba(255, 122, 47, 0) 60%), #1e2142;

  /* Typography scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;
  --fs-4xl: 44px;

  /* Safe areas: device insets + Telegram (fullscreen) insets. */
  --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
  --safe-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
  --safe-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
  --gutter: 20px;
  --page-max: 560px;
}
@media (max-width: 359px) {
  :root {
    --gutter: 16px;
  }
}

/* Light (Telegram light theme): light navy-tinted background, white surfaces, same blue / orange; text ≥ 4.5:1. */
[data-theme='light'] {
  color-scheme: light;
  --bg: #eef0f8;
  --surface-0: #f6f7fc;
  --surface: #ffffff;
  --surface-2: #e6e9f4;
  --surface-3: #dce0ef;
  --chip-bg: #e3e6f2;
  --soon-bg: #f3f4fa;
  --border: #e1e4f0;
  --border-strong: #c9cee3;
  --line: #c9cee3;
  --text: #14162b;
  --text-2: #4a5072;
  --muted: #5b6185;
  --faint: #8a90b0;
  --text-disabled: #575d80;
  --primary: #2f7bff;
  --primary-strong: #1f63e0;
  --primary-ink: #ffffff;
  --primary-text: #1a5ad6;
  --primary-soft: rgba(47, 123, 255, 0.12);
  --info: #1a5ad6;
  --info-soft: #2f7bff;
  --accent: #ff7a2f;
  --accent-2: #c9551a;
  --accent-3: #ff9a5c;
  --accent-ink: #14162b;
  --accent-soft: rgba(255, 122, 47, 0.13);
  --accent-text: #a8400b;
  --good: #147548;
  --good-soft: rgba(20, 117, 72, 0.12);
  --bad: #c42b2b;
  --bad-soft: rgba(196, 43, 43, 0.1);
  --warn: #965700;
  --warn-soft: rgba(255, 200, 61, 0.22);
  --draw: #5b6185;
  --btn-primary-bg: #14162b;
  --btn-primary-ink: #ffffff;
  --btn-disabled-bg: #dfe2ee;
  --btn-disabled-ink: #6a7092;
  --shadow: 0 10px 28px rgba(20, 22, 43, 0.08);
  --shadow-sm: 0 1px 4px rgba(20, 22, 43, 0.07);
  --shadow-lg: 0 20px 52px rgba(20, 22, 43, 0.18);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --backdrop: rgba(20, 22, 43, 0.42);
  --sk-base: rgba(20, 22, 43, 0.05);
  --sk-shine: rgba(20, 22, 43, 0.09);
  --hero-grad: radial-gradient(120% 120% at 100% 0%, rgba(47, 123, 255, 0.18) 0%, rgba(47, 123, 255, 0) 55%),
    radial-gradient(90% 90% at 0% 100%, rgba(255, 122, 47, 0.12) 0%, rgba(255, 122, 47, 0) 60%), #ffffff;
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  /* Portrait-only phone app: no double-tap zoom anywhere (the board and sheet handles set their own touch-action). */
  touch-action: manipulation;
}

body {
  overflow: hidden;
  /* Long words (nicks, robot names) under large system text break inside their box instead of overlapping. */
  overflow-wrap: break-word;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

input,
textarea,
.selectable {
  user-select: text;
  -webkit-user-select: text;
}

/* iOS zooms the page into any focused field whose text is under 16px — keep every field at ≥ 16px. */
input,
select,
textarea {
  font-size: 16px;
}

img {
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

a {
  color: var(--primary-text);
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

.num,
.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Typography helpers */
.t-xs { font-size: var(--fs-xs); }
.t-sm { font-size: var(--fs-sm); }
.t-lg { font-size: var(--fs-lg); }
.t-xl { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
.t-2xl { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 800; line-height: 1.2; }
.t-3xl { font-family: var(--font-display); font-size: var(--fs-3xl); font-weight: 800; line-height: 1.15; }
.t-strong { font-weight: 600; }
.t-display { font-family: var(--font-display); font-weight: 800; }
.text-2 { color: var(--text-2); }

/* ------------------------------------------------------------------ app frame & screens */
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

.screens {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + var(--gutter)) calc(var(--safe-bottom) + 28px)
    calc(var(--safe-left) + var(--gutter));
  background: var(--bg);
  will-change: transform, opacity;
  scrollbar-width: none;
}

.screen::-webkit-scrollbar {
  display: none;
}

body.has-main-button .screen {
  padding-bottom: calc(var(--safe-bottom) + 96px);
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

/* Screen transitions (220 ms) */
.screen-enter {
  opacity: 0;
}
.screen-enter.dir-forward {
  transform: translate3d(32px, 0, 0);
}
.screen-enter.dir-back {
  transform: translate3d(-32px, 0, 0);
}
.screen-enter.dir-replace {
  transform: scale(0.985);
}
.screen-enter.screen-enter-active {
  opacity: 1;
  transform: none;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.screen-leave {
  z-index: 0;
  transition: opacity 200ms var(--ease), transform 220ms var(--ease);
  opacity: 0;
}
.screen-leave.dir-forward {
  transform: translate3d(-18%, 0, 0);
}
.screen-leave.dir-back {
  transform: translate3d(18%, 0, 0);
}
.screen-leave.dir-replace {
  transform: scale(1.01);
}
.screen:not(.screen-leave) {
  z-index: 1;
}

/* Screen header */
.screen-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 2px;
}
.screen-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
}
.screen-subtitle {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}

/* Section label (mockups: 14px / 600 / secondary, sentence case). */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0 -6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}
.section-title .btn {
  margin: -8px -8px -8px 0;
}
/* Shop: a game's group ("Шахматы") above its own sections. */
.shop-group-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.shop-group-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-2);
}
.shop-group-icon .game-mark {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}
.shop-group-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.shop-group-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
}
.shop-group-sub {
  font-size: var(--fs-sm);
  color: var(--text-2);
}

/* ------------------------------------------------------------------ icons */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), color 0.2s;
}
.icon-btn:active {
  transform: scale(0.92);
  color: var(--text);
}

/* ------------------------------------------------------------------ brand mark */
.brand-logo {
  display: inline-flex;
  flex: none;
  line-height: 0;
}
.brand-logo svg {
  display: block;
}

/* ------------------------------------------------------------------ buttons
   Mockups: primary = white pill-rect with navy Unbounded label (h 56–58, r 16); secondary = outline 1.5 px line colour,
   Golos 600 (h 50); disabled = #2C3058 / #9AA0C2. Light theme inverts the primary (navy with white label). */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%; /* never wider than its column: the label ends with "…" instead */
  min-height: 50px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  transition: transform 0.16s var(--ease), filter 0.2s var(--ease), background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease), opacity 0.2s, color 0.2s;
  touch-action: manipulation;
}
.btn-label {
  min-width: 0; /* a flex item: may shrink, so a label that does not fit ends with "…" instead of being cut */
  overflow: hidden;
  text-overflow: ellipsis;
}
/* A long label that must stay readable on 320 px (e.g. «Сменить тестового игрока»): wraps to a second line. */
.btn.btn-wrap {
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  padding-top: 8px;
  padding-bottom: 8px;
}
.btn.btn-wrap .btn-label {
  overflow: visible;
  text-overflow: clip;
  text-wrap: balance;
}
.btn.btn-wrap > .icon {
  flex: 0 0 auto;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  cursor: default;
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-sm {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  font-size: 15px;
  gap: 8px;
}
.btn-lg {
  min-height: 58px;
  font-size: 18px;
}

.btn-primary {
  color: var(--btn-primary-ink);
  background: var(--btn-primary-bg);
  font-family: var(--font-display);
  font-weight: 800;
}
.btn-primary.btn-sm {
  font-size: 13px;
}
.btn-primary:active:not(:disabled) {
  filter: brightness(0.92);
}
.btn-primary:disabled {
  color: var(--btn-disabled-ink);
  background: var(--btn-disabled-bg);
}
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    filter: brightness(0.95);
  }
  .btn-secondary:hover:not(:disabled),
  .btn-ghost:hover:not(:disabled) {
    background-color: var(--surface-2);
  }
}

.btn-secondary {
  color: var(--text);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
}
.btn-secondary:active:not(:disabled) {
  background: var(--surface-2);
}
.btn-secondary:disabled,
.btn-ghost:disabled,
.btn-danger-ghost:disabled {
  opacity: 0.5;
}

/* Filled blue (e.g. "Turn on" notifications): the darker blue keeps white text at ≥ 4.5:1. */
.btn-blue {
  color: var(--primary-ink);
  background: var(--primary-strong);
}
.btn-blue:active:not(:disabled) {
  filter: brightness(0.92);
}

/* Orange fill with navy label (accent CTA). */
.btn-accent {
  color: var(--accent-ink);
  background: var(--accent);
  font-family: var(--font-display);
  font-weight: 800;
}

.btn-ghost {
  color: var(--primary-text);
  background: transparent;
}
.btn-ghost:active:not(:disabled) {
  background: var(--primary-soft);
}

.btn-danger {
  color: #fff;
  background: #e5484d;
}
.btn-danger-ghost {
  color: var(--bad);
  background: transparent;
}
.btn-danger-ghost:active:not(:disabled) {
  background: var(--bad-soft);
}

.btn.is-busy {
  pointer-events: none;
}
.btn.is-busy > * {
  opacity: 0;
}
.btn.is-busy::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: calc(50% - 10px);
  top: calc(50% - 10px);
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row > .btn {
  flex: 1;
}
.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ------------------------------------------------------------------ cards */
.card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--highlight);
  padding: 16px;
}
[data-theme='light'] .card {
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
.card-flat {
  box-shadow: none;
}
.card-tap {
  display: block;
  width: 100%;
  text-align: left;
  transition: transform 0.18s var(--ease), background-color 0.2s var(--ease);
}
.card-tap:active {
  transform: scale(0.985);
}
.card-pad-0 {
  padding: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------------ list rows */
.list {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
[data-theme='light'] .list {
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  text-align: left;
  position: relative;
  transition: background 0.15s var(--ease);
}
.list-row + .list-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: var(--border);
}
.list-row-tap:active {
  background: var(--surface-2);
}
.list-row-left {
  flex: none;
  display: flex;
  align-items: center;
}
.list-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.list-row-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.list-row-sub {
  font-size: var(--fs-sm);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row-right {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  font-variant-numeric: tabular-nums;
}
.list-row-chevron {
  color: var(--text-2);
  margin-right: -4px;
}

/* ------------------------------------------------------------------ segmented / tabs */
.segmented {
  --seg-index: 0;
  --seg-count: 2;
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface);
}
[data-theme='light'] .segmented {
  background: var(--surface-2);
}
.card .segmented,
.sheet .segmented {
  background: var(--surface-2);
}
.segmented-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--seg-count));
  border-radius: 10px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1.5px var(--primary);
  transform: translateX(calc(100% * var(--seg-index)));
  transition: transform 0.28s var(--ease);
}
[data-theme='light'] .segmented-thumb {
  background: var(--surface);
  box-shadow: var(--shadow-sm), inset 0 0 0 1.5px var(--primary);
}
.segmented-item {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
  color: var(--text-2);
  transition: color 0.2s;
}
.segmented-item > span:last-child {
  min-width: 0;
  max-width: 100%;
}
/* Small phones: tighter segments; an icon sits above its label so a whole word like «Случайно» fits its third. */
@media (max-width: 359px) {
  .segmented-item {
    padding: 4px 6px;
    font-size: 13px;
  }
  .segmented-item:has(> .segmented-icon) {
    flex-direction: column;
    gap: 2px;
  }
}
.segmented-item.active {
  color: var(--text);
}
.segmented-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.segmented-item .segmented-icon .icon {
  opacity: 0.8;
  transition: opacity 0.2s;
}
.segmented-item.active .segmented-icon .icon {
  opacity: 1;
  color: var(--primary-text);
}

/* ------------------------------------------------------------------ chips & badges */
/* Mockup chips: h 34, r 17, #2C3058, 14px / 600. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 17px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--chip-bg);
  white-space: nowrap;
}
.chip .icon {
  color: var(--text-2);
}
.chip-accent {
  color: var(--text);
  background: var(--chip-bg);
}
.chip-emoji {
  font-size: 14px;
  line-height: 1;
}
/* Colour discs (white / black / random) — drawn, never emoji. */
.chip-disc {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.chip-disc.is-w {
  background: radial-gradient(circle at 35% 30%, #ffffff, #e4e6f0 70%);
  box-shadow: inset 0 0 0 1px rgba(20, 22, 43, 0.35);
}
.chip-disc.is-b {
  background: radial-gradient(circle at 35% 30%, #4a4f74, #0e1022 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.chip-disc.is-r {
  background: linear-gradient(90deg, #f4f5fb 50%, #12142a 50%);
  box-shadow: inset 0 0 0 1px rgba(142, 148, 184, 0.7);
}
[data-theme='light'] .chip-disc.is-b {
  box-shadow: inset 0 0 0 1px rgba(20, 22, 43, 0.5);
}

/* Provisional rating mark: a small round "?" after the number. */
.rating-val {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.rating-prov {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 14px;
  height: 14px;
  margin-left: 3px;
  border-radius: 50%;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  background: var(--surface-2);
  color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  -webkit-text-fill-color: currentColor;
  cursor: help;
}

/* Rank coins (leaderboard top 3) — CSS, so they look identical on every OS. 1st = robot yellow. */
.rank-medal {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #14162b;
  background: radial-gradient(circle at 35% 30%, #fff3c4 0%, #ffc83d 50%, #e0a21c 100%);
  box-shadow: inset 0 -1.5px 0 rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.rank-medal-2 {
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d3d7ea 50%, #9ea4c4 100%);
}
.rank-medal-3 {
  background: radial-gradient(circle at 35% 30%, #ffd2b4 0%, #ff9a5c 50%, #c9551a 100%);
}
.rank-medal-lg {
  width: 32px;
  height: 32px;
  font-size: 14px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-muted {
  color: var(--text-2);
  background: var(--chip-bg);
}
.badge-accent {
  color: var(--accent-ink);
  background: var(--accent);
}
.badge-primary {
  color: var(--primary-ink);
  background: var(--primary-strong);
}
.badge-good {
  color: var(--good);
  background: var(--good-soft);
}
.badge-bad {
  color: var(--bad);
  background: var(--bad-soft);
}
.badge-warn {
  color: var(--warn);
  background: var(--warn-soft);
}
.badge-premium {
  width: 18px;
  height: 18px;
  padding: 0;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.badge-premium svg {
  fill: currentColor;
}

/* Pulsing "Твой ход" badge (blue: it is the call to act). */
.badge-turn {
  position: relative;
  color: var(--primary-ink);
  background: var(--primary-strong);
  box-shadow: 0 0 0 0 rgba(47, 123, 255, 0.55);
  animation: turn-pulse 1.8s var(--ease) infinite;
}
@keyframes turn-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 123, 255, 0.55);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(47, 123, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(47, 123, 255, 0);
  }
}

.color-dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(20, 22, 43, 0.4);
}
.color-w {
  background: linear-gradient(180deg, #ffffff, #d9dcea);
}
.color-b {
  background: linear-gradient(180deg, #3d4268, #0e1022);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* ------------------------------------------------------------------ switch (mockup: 52 × 32, knob 26, blue when on) */
.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  cursor: pointer;
}
.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-track {
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--border-strong);
  transition: background 0.25s var(--ease);
  position: relative;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(8, 9, 22, 0.3);
  transition: transform 0.28s var(--ease-spring);
}
.switch-input:checked + .switch-track {
  background: var(--primary);
}
.switch-input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}
.switch-input:focus-visible + .switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Invisible 44 px hit area around the 32 px track. */
.switch::after {
  content: '';
  position: absolute;
  inset: -6px -4px;
}

/* ------------------------------------------------------------------ avatar (§12.3: photo or robot, never a letter) */
.avatar {
  position: relative;
  display: inline-flex;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: #161616; /* the robots' own backdrop, so loading and fallback look the same */
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}
.avatar.avatar-blank img {
  visibility: hidden;
}
.avatar-premium {
  overflow: visible;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
.avatar-premium img {
  border-radius: 50%;
}
.avatar-initials {
  display: none;
}
.avatar-silhouette {
  display: block;
  width: 100%;
  height: 100%;
}
.avatar-silhouette svg {
  width: 100%;
  height: 100%;
}

/* Avatar picker (onboarding / invite / profile sheet). */
.avatar-picker {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.avatar-option {
  --av-size: 58px;
  position: relative;
  width: var(--av-size);
  height: var(--av-size);
  flex: none;
  padding: 0;
  border-radius: 50%;
  background: #161616;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease);
}
.avatar-option:active {
  transform: scale(0.93);
}
.avatar-option-face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
}
.avatar-option-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-option.is-photo {
  background: var(--surface-2);
}
.avatar-option.is-missing {
  opacity: 0.55;
}
.avatar-option.selected {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text);
}
/* A plain row of avatars (onboarding, invite): the circles shrink together on narrow phones instead of the last one
   sliding off the screen. */
.avatar-picker > .avatar-option {
  flex: 0 1 var(--av-size);
  width: auto;
  height: auto;
  min-width: 0;
  aspect-ratio: 1;
  align-self: center;
}
.sheet .avatar-option.selected,
.card .avatar-option.selected,
.onb-invite .avatar-option.selected {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}
.avatar-picker.with-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 8px;
}
.avatar-option-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}
.avatar-option-name {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
}
.avatar-option-sub {
  margin-top: 2px;
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-2);
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.player-chip-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-chip-rating {
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* Game marks (knight / robot) for rows and badges. */
.game-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-3);
}
.game-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.game-mark-chess {
  background: #262a50;
}

/* ------------------------------------------------------------------ spinner & skeleton */
.spinner {
  display: inline-block;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.center-spinner {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.sk {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--sk-base) 0%, var(--sk-shine) 40%, var(--sk-base) 80%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}
.sk-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
}
.sk-line {
  height: 12px;
}
.sk-line-sm {
  height: 10px;
  margin-top: 8px;
}
.sk-block {
  height: 120px;
  border-radius: var(--radius);
}
.skeleton-list {
  background: var(--surface);
  border-radius: var(--radius);
}
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.skeleton-row + .skeleton-row {
  border-top: 1px solid var(--border);
}
.sk-lines {
  flex: 1;
}

/* ------------------------------------------------------------------ empty states */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 28px 20px;
}
.empty-art {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--primary-text);
  margin-bottom: 6px;
}
.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-wrap: balance;
}
.empty-text {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.45;
  max-width: 300px;
}
.empty .btn {
  margin-top: 10px;
}
.empty-card {
  background: var(--surface);
  border-radius: var(--radius);
}
[data-theme='light'] .empty-card {
  box-shadow: 0 0 0 1px var(--border);
}

/* ------------------------------------------------------------------ overlays: sheet & modal */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  pointer-events: none;
}
.overlay.open,
.overlay.closing {
  pointer-events: auto;
}
.overlay.closing {
  pointer-events: none;
}
.backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.26s var(--ease);
}
.overlay.open .backdrop {
  opacity: 1;
}

.overlay-sheet {
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: var(--page-max);
  /* --kb: on-screen keyboard height (ui.sheet, visualViewport) — the sheet rides above it. */
  margin-bottom: var(--kb, 0px);
  max-height: calc(100% - var(--safe-top) - 40px - var(--kb, 0px));
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--border);
  transform: translateY(100%);
  transition: transform 0.32s var(--ease), margin-bottom 0.2s var(--ease), max-height 0.2s var(--ease);
  touch-action: pan-y;
}
[data-theme='light'] .sheet {
  background: var(--bg);
}
/* With the keyboard up the bottom safe area is covered anyway. */
.overlay.has-kb .sheet-footer {
  padding-bottom: 12px;
}
.overlay.open .sheet {
  transform: translateY(0);
}
.sheet.dragging {
  transition: none;
}
.sheet-handle {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  cursor: grab;
  touch-action: none;
}
.sheet-handle span {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 16px 6px 24px;
  touch-action: none;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.sheet-close {
  width: 44px;
  height: 44px;
  margin-right: -6px;
  border-radius: 50%;
  background: transparent;
}
.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 24px calc(var(--safe-bottom) + 20px);
}
/* Optional sticky footer (primary action stays visible; the body scrolls above it). */
.sheet.has-footer .sheet-body {
  padding-bottom: 12px;
}
.sheet-footer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 24px calc(var(--safe-bottom) + 14px);
  background: var(--bg);
  box-shadow: 0 -1px 0 var(--border);
}
/* Smallest phones: narrower sheet sides and button padding, so «Отправить в Telegram» fits without "…". */
@media (max-width: 340px) {
  .sheet-body,
  .sheet-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .sheet-header {
    padding-left: 16px;
  }
  .sheet .btn {
    padding-inline: 14px;
  }
}

.overlay-modal {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 24px 20px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg), inset 0 1px 0 var(--border);
  transform: scale(0.94);
  opacity: 0;
  transition: transform 0.24s var(--ease-spring), opacity 0.2s var(--ease);
}
.overlay.open .modal {
  transform: none;
  opacity: 1;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}
.modal-body {
  margin-top: 8px;
  color: var(--text-2);
  text-align: center;
}
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

/* ------------------------------------------------------------------ toast */
.toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 20px);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}
body.has-main-button .toast-host {
  bottom: calc(var(--safe-bottom) + 90px);
}
/* Play screens: lift toasts above the move strip + toolbar (58px + 40px, see game.css --gm-actions-h /
   --gm-strip-h, which are scoped to .gm-screen and so cannot be used here) and let taps pass through,
   so a toast never swallows a tap meant for Resign / Draw / Flip. */
body.in-game .toast-host {
  bottom: calc(var(--safe-bottom) + 58px + 40px + 12px);
}
body.in-game .toast {
  pointer-events: none;
}
/* …except actionable toasts (e.g. “a new game has started — tap to open”), which sit above the toolbar. */
body.in-game .toast.toast-action {
  pointer-events: auto;
}
@media (max-height: 640px) {
  body.in-game .toast-host {
    bottom: calc(var(--safe-bottom) + 52px + 34px + 12px);
  }
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(42, 47, 90, 0.97);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  transition: transform 0.3s var(--ease-spring), opacity 0.22s var(--ease);
  pointer-events: auto;
}
[data-theme='light'] .toast {
  background: rgba(20, 22, 43, 0.94);
}
.toast.show {
  transform: none;
  opacity: 1;
}
.toast.hide {
  transform: translateY(8px);
  opacity: 0;
}
.toast-good .icon {
  color: #34c77b;
}
.toast-bad .icon {
  color: #ff9a5c;
}

/* ------------------------------------------------------------------ connection banner */
.net-banner {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 8px);
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-sm);
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - var(--safe-top) - 24px));
  opacity: 0;
  visibility: hidden;
  transition: transform 0.35s var(--ease), opacity 0.25s var(--ease), visibility 0s linear 0.35s;
  pointer-events: none;
  white-space: nowrap;
}
.net-banner.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  transition: transform 0.35s var(--ease), opacity 0.2s var(--ease), visibility 0s;
}
.net-banner .spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-color: rgba(20, 22, 43, 0.25);
  border-top-color: #14162b;
}
.net-banner.ok {
  background: var(--primary-strong);
  color: #fff;
}
/* Play screens show the connection state in their own header badge. */
body.in-game .net-banner {
  display: none;
}

/* ------------------------------------------------------------------ browser fallbacks for Telegram UI */
.tg-fallback-back {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 10px);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), inset 0 0 0 1.5px var(--border-strong);
}
.tg-fallback-back.visible {
  display: inline-flex;
}
body.browser-back .screen {
  padding-top: calc(var(--safe-top) + 60px);
}
.tg-fallback-main {
  position: fixed;
  left: calc(var(--safe-left) + 16px);
  right: calc(var(--safe-right) + 16px);
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 80;
  max-width: calc(var(--page-max) - 32px);
  margin: 0 auto;
  display: none;
}
.tg-fallback-main.visible {
  display: flex;
}

/* ------------------------------------------------------------------ splash / notice */
.splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.splash.hidden {
  opacity: 0;
  visibility: hidden;
}

/* Portrait only (owner decision): a phone held sideways gets a full-screen «Поверни телефон вертикально».
   Shows only on touch devices with a short, clearly wide viewport (≥ 3:2 — a phone on its side is ~2:1), so desktop
   browsers / Telegram Desktop never see it. An UPRIGHT phone whose web view the keyboard or split screen squeezed
   (~1:1 … 1.35:1) never matches, and when tg.js knows the device is upright (html[data-device-orient='portrait'],
   from screen.orientation — the keyboard never changes it) the overlay is off whatever the viewport's shape. */
.rotate-lock {
  display: none;
}
@media (orientation: landscape) and (max-height: 520px) and (min-aspect-ratio: 3/2) and (hover: none),
  (orientation: landscape) and (max-height: 520px) and (min-aspect-ratio: 3/2) and (pointer: coarse) {
  html:not([data-device-orient='portrait']) .rotate-lock {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 24px);
    text-align: center;
    color: var(--text);
    background: var(--hero-grad);
    background-color: var(--bg);
    touch-action: none;
  }
  html:not([data-device-orient='portrait']) #app,
  html:not([data-device-orient='portrait']) .splash {
    visibility: hidden;
  }
}
.rotate-lock-icon {
  width: 88px;
  height: 88px;
  margin-bottom: 6px;
  color: var(--text);
}
.rotate-lock-icon .rl-arrow {
  stroke: var(--accent);
}
.rotate-lock-icon .rl-phone {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: rl-turn 2.4s var(--ease) infinite;
}
@keyframes rl-turn {
  0%,
  20% {
    transform: rotate(-90deg);
  }
  55%,
  100% {
    transform: rotate(0deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-lock-icon .rl-phone {
    animation: none;
  }
}
.rotate-lock-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
  text-wrap: balance;
}
.rotate-lock-sub {
  max-width: 420px;
  font-size: var(--fs-md);
  color: var(--text-2);
}
html[lang='en'] .rotate-lock [lang='ru'],
html:not([lang='en']) .rotate-lock [lang='en'] {
  display: none;
}
.splash-logo {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  animation: splash-bob 1.6s var(--ease) infinite;
}
.splash-logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 14px 30px rgba(47, 123, 255, 0.25));
}
.splash-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
}
.splash-bar {
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.splash-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 2px;
  background: var(--primary);
  animation: splash-bar 1.1s var(--ease) infinite;
}
@keyframes splash-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
@keyframes splash-bar {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(260%);
  }
}

.notice {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 24px 8px;
}
.notice .empty-art {
  width: 88px;
  height: 88px;
  font-size: 44px;
}
.notice-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
}
.notice-text {
  color: var(--text-2);
  max-width: 320px;
  line-height: 1.45;
}
.notice .btn {
  min-width: min(240px, 100%);
  margin-top: 8px;
}

/* ==========================================================================================
   Screens
   ========================================================================================== */

[hidden] {
  display: none !important;
}

/* Field label above inputs / groups (mockups: 14px / 600 / secondary). */
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

/* ------------------------------------------------------------------ home (showcase) */
.home-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
}
.home-header-me {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: var(--radius-md);
  transition: transform 0.15s var(--ease);
}
.home-header-me:active {
  transform: scale(0.98);
}
.home-header-text {
  min-width: 0;
}
.home-hello {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
}
.home-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}
.home-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge-vsplus {
  height: 20px;
  padding: 0 7px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  flex: none;
}
.brand-mark {
  flex: none;
  border-radius: 50%;
  line-height: 0;
  transition: transform 0.15s var(--ease);
}
.brand-mark:active {
  transform: scale(0.94);
}

.showcase-games {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Game tiles. Live: art strip on top (mini board / knight), name in Unbounded, tagline, «Играть» + rating. */
.game-tile {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.game-tile:active {
  transform: scale(0.985);
}
.game-tile.is-live {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--primary);
}
[data-theme='light'] .game-tile.is-live {
  box-shadow: inset 0 0 0 2px var(--primary), var(--shadow-sm);
}
.game-tile-art {
  position: relative;
  display: block;
  height: 112px;
  margin: 2px 2px 0;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  background: #14162b;
}
.game-tile-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 16px 16px;
  min-width: 0;
}
.game-tile-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-text);
}
.game-tile-title {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
}
.game-tile-text {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}
.game-tile-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.game-tile-cta {
  pointer-events: none;
  padding: 0 22px;
}
.game-tile-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--chip-bg);
}
.game-tile-chip .icon {
  color: var(--robot-yellow);
}
[data-theme='light'] .game-tile-chip .icon {
  color: var(--warn);
}

/* Game art: chess = navy mini-board strip (one blue and one orange square) + the brand knight. */
.game-art {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-art-chess {
  background: radial-gradient(70% 90% at 80% 50%, rgba(47, 123, 255, 0.28), rgba(47, 123, 255, 0) 70%), #14162b;
}
.mini-strip {
  display: grid;
  grid-template-columns: repeat(7, 22px);
  grid-template-rows: repeat(2, 22px);
  border-radius: 4px;
  overflow: hidden;
}
.mini-strip-sq.is-light {
  background: #2a2f5a;
}
.mini-strip-sq.is-dark {
  background: #1b1e3a;
}
.mini-strip-sq.is-blue {
  background: #2f7bff;
}
.mini-strip-sq.is-orange {
  background: #ff7a2f;
}
.game-art-knight {
  position: absolute;
  right: 14px;
  bottom: -6px;
  width: 92px;
  height: 92px;
  filter: drop-shadow(0 10px 18px rgba(5, 6, 20, 0.55));
  animation: hero-float 5s ease-in-out infinite;
}
.game-art-knight .piece-svg {
  width: 100%;
  height: 100%;
}
.game-art-escape {
  justify-content: flex-start;
  padding-left: 14px;
  background: #141414;
}
.exit-sign {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 3px;
  background: #16c45a;
  box-shadow: 0 0 16px rgba(22, 196, 90, 0.5);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* "Coming soon" tiles (mockup Invite: muted card, «скоро» orange pill). */
.game-tiles-soon {
  display: grid;
  gap: 10px;
}
.game-tile.is-soon {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  background: var(--soon-bg);
  box-shadow: inset 0 0 0 1.5px var(--chip-bg);
  color: var(--text-disabled);
}
.game-tile-soon-art {
  position: relative;
  flex: none;
  width: 92px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
}
.game-tile.is-soon .game-tile-body {
  flex: 1;
  min-width: 0;
  padding: 0;
  gap: 2px;
}
/* The «скоро» pill sits in the tile's corner (as in the Invite mockup) instead of taking a whole column:
   only the name line keeps room for it, so the tagline gets the full width (2 lines, not 4, at 320 px). */
.game-tile.is-soon > .soon-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}
.game-tile.is-soon .game-tile-name {
  padding-right: 60px;
}
@media (max-width: 360px) {
  /* 320 px: a slightly narrower art keeps «Побег вдвоём» on one line next to the pill */
  .game-tile.is-soon {
    gap: 12px;
  }
  .game-tile-soon-art {
    width: 78px;
  }
  .game-tile-soon-art .game-art-escape {
    justify-content: center;
    padding-left: 0;
  }
}
.game-tile-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-disabled);
}
.game-tile.is-soon .game-tile-text {
  margin-top: 0;
  font-size: var(--fs-sm);
  color: var(--text-disabled);
}
/* A "soon" game opened as a test Mini App (TEST_APPS): tappable, full-contrast text, blue «тест» pill. */
.game-tile.is-soon.is-test {
  box-shadow: inset 0 0 0 1.5px var(--primary);
  color: var(--text);
}
.game-tile.is-soon.is-test .game-tile-name {
  color: var(--text);
}
.game-tile.is-soon.is-test .game-tile-text {
  color: var(--text-2);
}
.game-tile.is-soon.is-test > .soon-badge {
  background: var(--primary-strong);
  color: var(--primary-ink);
}
.soon-badge {
  flex: none;
  align-self: flex-start;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
}

.game-row-game {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}
/* The game label gives way first: colour, speed and time control always stay visible. */
.showcase-games .game-row-meta {
  min-width: 0;
  max-width: 100%;
}
.showcase-games .game-row-meta > :not(.game-row-game) {
  flex-shrink: 0;
}
.game-row-game-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar-wrap {
  position: relative;
  display: inline-flex;
}
.avatar-game-badge {
  position: absolute;
  right: -4px;
  bottom: -3px;
  display: flex;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}

/* Quick tiles (Профиль / Магазин / О приложении; Рейтинг / Стиль). Tones from the robot palette. */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.quick-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.quick-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.quick-tile {
  --tone: var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 4px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: transform 0.16s var(--ease);
}
[data-theme='light'] .quick-tile {
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
.quick-tile:active {
  transform: scale(0.95);
}
.tone-blue {
  --tone: var(--robot-blue);
}
.tone-orange {
  --tone: var(--robot-orange);
}
.tone-purple {
  --tone: var(--robot-purple);
}
.tone-yellow {
  --tone: var(--robot-yellow);
}
.quick-tile-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tone);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--tone) 18%, transparent);
}
[data-theme='light'] .quick-tile-icon {
  color: color-mix(in srgb, var(--tone) 70%, #14162b);
}
.quick-tile.is-row {
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  min-height: 64px;
  font-size: 15px;
}
.quick-tile.is-row .quick-tile-icon {
  width: 36px;
  height: 36px;
  flex: none;
}
.quick-tile.is-row .quick-tile-label {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.quick-tile-chevron {
  color: var(--text-2);
}

/* ------------------------------------------------------------------ chess hub */
.chess-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
}
.chess-emblem {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #262a50;
}
.chess-head-text {
  flex: 1;
  min-width: 0;
}
.chess-head-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.chess-head-sub {
  margin-top: 2px;
  font-size: var(--fs-sm);
  line-height: 1.3;
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.rating-pill {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: var(--chip-bg);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rating-pill .icon {
  color: var(--robot-yellow);
}
[data-theme='light'] .rating-pill .icon {
  color: var(--warn);
}
.rating-pill::after {
  content: '';
  position: absolute;
  inset: -2px 0;
}

/* Hero «Играть с другом». */
.hero-card {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  min-height: 176px;
  padding: 20px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  border-radius: var(--radius-lg);
  text-align: left;
  background: var(--hero-grad);
  box-shadow: inset 0 0 0 2px var(--primary);
  transition: transform 0.2s var(--ease);
}
[data-theme='light'] .hero-card {
  box-shadow: inset 0 0 0 2px var(--primary), var(--shadow-sm);
}
.hero-card:active {
  transform: scale(0.985);
}
/* A tap on a quick chip should not press the whole card (ignored where :has is unsupported). */
.hero-card:has(.hero-chip:active) {
  transform: none;
}
.hero-card:focus-visible {
  box-shadow: inset 0 0 0 2px var(--primary), 0 0 0 3px var(--primary-soft);
}
.hero-kicker,
.hero-title,
.hero-text,
.hero-cta,
.hero-quick {
  position: relative;
  z-index: 1;
}
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--primary-text);
}
.hero-kicker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}
.hero-title {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  max-width: 62%;
}
.hero-text {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
  max-width: 58%;
}
.hero-cta {
  margin-top: 16px;
  pointer-events: none;
}
.hero-quick {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.hero-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--chip-bg);
  transition: transform 0.15s var(--ease), background 0.15s;
}
/* One tap creates a challenge: a 44 px tall hit area around the 36 px chip. */
.hero-chip::after {
  content: '';
  position: absolute;
  inset: -4px -3px;
}
.hero-chip:active {
  transform: scale(0.94);
  background: var(--surface-3);
}
.hero-chip.is-last {
  box-shadow: inset 0 0 0 1.5px var(--primary);
}
.hero-chip.is-busy {
  opacity: 0.55;
  pointer-events: none;
}
.hero-chip-icon {
  display: inline-flex;
  color: var(--kind-color, var(--primary-text));
}
.hero-art {
  position: absolute;
  right: -10px;
  bottom: -16px;
  width: 160px;
  height: 160px;
  filter: drop-shadow(0 12px 22px rgba(5, 6, 20, 0.45));
  transform: rotate(-8deg);
  animation: hero-float 5s ease-in-out infinite;
  pointer-events: none;
}
.hero-art .piece-svg {
  width: 100%;
  height: 100%;
}
.hero-glow {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 123, 255, 0.35), transparent 65%);
  pointer-events: none;
}
[data-theme='light'] .hero-art {
  filter: drop-shadow(0 10px 18px rgba(20, 22, 43, 0.25));
}
@keyframes hero-float {
  0%,
  100% {
    transform: rotate(-8deg) translateY(0);
  }
  50% {
    transform: rotate(-5deg) translateY(-6px);
  }
}
.game-art-knight {
  transform: rotate(-8deg);
}

.ai-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
}
.ai-card-art {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--robot-blue);
  background: color-mix(in srgb, var(--robot-blue) 18%, transparent);
}
.seek-card-art {
  color: var(--robot-orange);
  background: color-mix(in srgb, var(--robot-orange) 18%, transparent);
}
[data-theme='light'] .ai-card-art {
  color: var(--primary-text);
}
[data-theme='light'] .seek-card-art {
  color: var(--accent-text);
}
.ai-card-body {
  flex: 1;
  min-width: 0;
}
.ai-card-title {
  font-size: 17px;
  font-weight: 700;
}
.ai-card-sub {
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.35;
}

.home-games {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.game-row-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.game-row-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 16px;
  white-space: nowrap;
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.game-row-time.urgent {
  color: var(--accent-text);
  font-weight: 700;
}
.game-row-time .game-row-clock {
  display: none;
}
.game-row-time.with-clock .game-row-clock {
  display: inline-flex;
}
.game-row-time .diff-up,
.game-row-time .diff-down,
.game-row-time .diff-zero {
  font-size: var(--fs-sm);
}
.diff-zero {
  color: var(--text-2);
  font-weight: 700;
}
.game-row-sep {
  color: var(--faint);
}
.game-row-meta-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-group-label {
  margin: 4px 0 -4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}
.result-win {
  color: var(--good);
}
.result-loss {
  color: var(--bad);
}
.result-draw {
  color: var(--draw);
}
.diff-up {
  color: var(--good);
  font-weight: 700;
}
.diff-down {
  color: var(--bad);
  font-weight: 700;
}
.show-more {
  display: flex;
  justify-content: center;
}

/* ------------------------------------------------------------------ «Позвать друга» sheet (mockup Invite) */
.invite-sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.invite-sheet > .field-label:not(:first-child) {
  margin-top: 8px;
}
.invite-games {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.invite-game {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  text-align: left;
  background: var(--surface);
  transition: transform 0.15s var(--ease);
}
.invite-game.is-selected {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.invite-game.is-soon {
  background: var(--soon-bg);
  box-shadow: inset 0 0 0 1.5px var(--chip-bg);
  color: var(--text-disabled);
}
.invite-game:active {
  transform: scale(0.97);
}
.invite-game-art {
  position: relative;
  display: block;
  height: 62px;
  margin: 2px 2px 0;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
}
.invite-game.is-soon .invite-game-art {
  margin: 1.5px 1.5px 0;
}
.invite-game-art .mini-strip {
  grid-template-columns: repeat(7, 13px);
  grid-template-rows: repeat(2, 13px);
  border-radius: 2px;
}
.invite-game-art .game-art-chess {
  background: #14162b;
}
.invite-game-name {
  padding: 10px 12px 12px;
  font-size: 16px;
  font-weight: 700;
}
.invite-game .soon-badge {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* Settings card: Время ›, На рейтинг [switch], Твой цвет [segmented]. */
.settings-card {
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
[data-theme='light'] .settings-card {
  box-shadow: 0 0 0 1px var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 16px;
  text-align: left;
  font-size: 16px;
}
.settings-row-tap:active {
  background: var(--surface-2);
}
.settings-row-label {
  flex: 1;
  min-width: 0;
}
.settings-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-row-body .settings-row-label {
  flex: none;
}
.settings-row-sub {
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--text-2);
}
.settings-row-value {
  color: var(--text-2);
  white-space: nowrap;
}
.settings-row-chevron {
  color: var(--text-2);
  transition: transform 0.25s var(--ease);
}
.settings-row.is-open .settings-row-chevron {
  transform: rotate(180deg);
}
.settings-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 14px;
}
.settings-sep {
  height: 1px;
  margin: 0 16px;
  background: var(--border);
}
.tc-panel {
  padding: 4px 16px 16px;
  animation: fade-up 0.25s var(--ease) both;
}
.tc-group + .tc-group {
  margin-top: 14px;
}
.tc-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}
.tc-kind-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--kind-color, var(--text-2));
  background: var(--surface-2);
  background: color-mix(in srgb, var(--kind-color, var(--text-2)) 18%, transparent);
}
.tc-kind-bullet { --kind-color: var(--robot-yellow); }
.tc-kind-blitz { --kind-color: var(--robot-orange); }
.tc-kind-rapid { --kind-color: var(--good); }
.tc-kind-classical { --kind-color: var(--robot-purple); }
.tc-kind-daily { --kind-color: var(--robot-blue); }
[data-theme='light'] .tc-kind-bullet { --kind-color: var(--warn); }
[data-theme='light'] .tc-kind-blitz { --kind-color: var(--accent-text); }
[data-theme='light'] .tc-kind-daily { --kind-color: var(--primary-text); }
.tc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.tc-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 60px;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  text-align: center;
  overflow-wrap: break-word;
  background: var(--surface-2);
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.tc-option:active {
  transform: scale(0.95);
}
.tc-option-main,
.tc-option-sub {
  max-width: 100%; /* centred flex items: let a long value wrap inside the tile instead of spilling out */
}
.tc-option-main {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.tc-option-sub {
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.tc-option.selected {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.tc-option.wide {
  grid-column: span 3;
  flex-direction: row;
  gap: 10px;
  min-height: 50px;
}
.tc-option.wide .tc-option-main {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
}
.picker-colors .segmented-item {
  font-size: 13px;
}

/* ------------------------------------------------------------------ lobby: "Ты VS ?" */
.lobby {
  gap: 18px;
}
.lobby-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}
.lobby-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
}
.lobby-title .dots {
  display: inline-flex;
  gap: 1px;
  margin-left: 1px;
}
.lobby-title .dots > span {
  animation: dot-blink 1.4s ease-in-out infinite;
}
.lobby-title .dots > span:nth-child(2) {
  animation-delay: 0.2s;
}
.lobby-title .dots > span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes dot-blink {
  0%,
  80%,
  100% {
    opacity: 0.15;
  }
  40% {
    opacity: 1;
  }
}
.lobby-text {
  color: var(--text-2);
  font-size: 15px;
  line-height: 1.45;
}
.lobby-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 22px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
}
[data-theme='light'] .lobby-vs {
  box-shadow: 0 0 0 1px var(--border);
}
.lobby-vs-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.lobby-vs-side .avatar {
  box-shadow: 0 0 0 2px var(--line);
}
.lobby-vs-name {
  font-size: 14px;
  font-weight: 600;
}
.lobby-vs-mark {
  margin-bottom: 26px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-2);
}
.lobby-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
}
.lobby-slot-core {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px dashed var(--line);
  background: var(--surface-2);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-2);
}
.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: ring 2.4s var(--ease) infinite;
}
.pulse-ring:nth-child(2) {
  animation-delay: 1.2s;
}
@keyframes ring {
  0% {
    transform: scale(0.95);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}
.lobby-expires {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.dev-hint {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text);
  font-size: var(--fs-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dev-hint code {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  word-break: break-all;
  color: var(--text-2);
}

/* ------------------------------------------------------------------ challenge (mockup Invited, for players who are in) */
.challenge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 20px 20px;
  margin-top: 8px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
  animation: fade-up 0.42s var(--ease) both;
}
.challenge-title {
  max-width: 100%;
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
@media (max-width: 359px) {
  .challenge-title {
    font-size: 19px;
  }
}
.challenge-card .chips {
  margin-top: 16px;
}
.challenge-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

/* Shared "A VS B" block (onboarding invite + challenge). */
.onb-vs {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
}
.onb-vs-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 120px;
  border-radius: var(--radius-md);
}
button.onb-vs-side:active {
  transform: scale(0.97);
}
.onb-vs-ava {
  display: inline-flex;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--line);
}
.onb-vs-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.onb-vs-rating {
  margin-top: -6px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.onb-vs-mark {
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-2);
}

/* ------------------------------------------------------------------ profile */
.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding-top: 8px;
}
.profile-ava {
  position: relative;
  display: inline-flex;
  margin-bottom: 4px;
  border-radius: 50%;
}
.profile-ava .avatar {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--line);
}
.profile-ava .avatar.avatar-premium {
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}
.profile-ava.is-editable {
  transition: transform 0.15s var(--ease);
}
.profile-ava.is-editable:active {
  transform: scale(0.96);
}
.profile-ava-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--btn-primary-ink);
  background: var(--btn-primary-bg);
  box-shadow: 0 0 0 3px var(--bg);
}
.profile-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
/* A long nick never pushes the profile wider than the screen: it ends with "…" like the home header. */
.profile-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-name > :not(.profile-name-text) {
  flex: none;
}
@media (max-width: 359px) {
  .profile-name {
    font-size: 21px;
  }
}
.profile-username {
  color: var(--text-2);
  font-size: var(--fs-sm);
  margin-top: -4px;
}
.rating-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 4px 16px;
}
.rating-big {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.rating-big .rating-prov {
  width: 20px;
  height: 20px;
  margin-left: 6px;
  font-size: 13px;
  align-self: flex-start;
  margin-top: 2px;
}
.rating-label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 600;
}
.rating-hint {
  grid-column: 1 / -1;
  margin-top: 8px;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.rating-hint .icon {
  color: var(--primary-text);
}
.spark {
  width: 100%;
  height: 72px;
  overflow: visible;
}
.spark-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  animation: draw 1.1s var(--ease) forwards;
}
.spark-minmax {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.stat {
  min-width: 0;
  text-align: center;
  overflow-wrap: break-word;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  margin-top: 2px;
  hyphens: auto;
  -webkit-hyphens: auto;
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: 600;
}
.stat-good .stat-value {
  color: var(--good);
}
.stat-bad .stat-value {
  color: var(--bad);
}

.wdl-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
  gap: 2px;
  margin: 12px 0 8px;
}
.wdl-bar > span {
  height: 100%;
  transform-origin: left;
  animation: grow 0.8s var(--ease) both;
}
.wdl-w {
  background: var(--good);
}
.wdl-d {
  background: var(--draw);
}
.wdl-l {
  background: var(--bad);
}
@keyframes grow {
  from {
    transform: scaleX(0);
  }
}
.wdl-legend {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.wdl-legend b {
  color: var(--text);
}
.wdl-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.wdl-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  background: var(--draw);
}
.wdl-key-w .wdl-swatch {
  background: var(--good);
}
.wdl-key-l .wdl-swatch {
  background: var(--bad);
}
.wdl-pct {
  color: var(--text-2);
}
.card-title {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-title .muted {
  font-weight: 600;
  font-size: var(--fs-sm);
}

/* Settings groups (profile account card, shop "Игра"). */
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setting-row .setting-icon {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-text);
  background: var(--primary-soft);
  transition: color 0.2s, background 0.2s;
}
.setting-row .setting-icon.is-off {
  color: var(--text-2);
  background: var(--surface-2);
}
.setting-row .setting-icon.setting-ava {
  background: none;
}
.setting-row .setting-body {
  flex: 1;
  min-width: 0;
}
.setting-row .setting-sub {
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.35;
}
.settings-group {
  display: flex;
  flex-direction: column;
  padding-top: 4px;
  padding-bottom: 4px;
}
.settings-group .setting-row {
  position: relative;
  padding: 12px 0;
}
.setting-row.setting-row-choice {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.setting-row-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.setting-row-choice .setting-seg {
  margin-left: 52px;
}
.setting-seg .segmented-item {
  min-height: 44px;
  padding: 0 6px;
  font-size: var(--fs-sm);
}
@media (max-width: 359px) {
  .setting-row-choice .setting-seg {
    margin-left: 0;
  }
}
.settings-group .setting-row + .setting-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 52px;
  right: 0;
  height: 1px;
  background: var(--border);
}
.account-nick {
  margin: 1px 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-card .btn-sm,
.setting-row .btn-sm {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
}
/* Account rows (avatar, nick): on narrow phones / large system text the «Изменить» button drops under the text
   instead of squeezing it into a sliver. */
.account-card > .setting-row {
  flex-wrap: wrap;
  row-gap: 8px;
}
.account-card > .setting-row > .setting-body {
  flex: 1 1 7.5em;
}
.account-card > .setting-row > .btn-sm {
  margin-left: auto;
}
.profile-lang-seg {
  margin-left: 52px;
}
.account-notify .account-notify-btn {
  align-self: flex-start;
  margin-left: 52px;
  padding: 0 18px;
}
@media (max-width: 359px) {
  .profile-lang-seg,
  .account-notify .account-notify-btn {
    margin-left: 0;
  }
}
.report-row {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}
.avatar-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 4px 0 8px;
}
.avatar-sheet-picker.is-busy {
  opacity: 0.6;
  pointer-events: none;
}
.nick-sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 4px;
}

/* ------------------------------------------------------------------ leaderboard */
.podium {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: end;
  gap: 8px;
  padding-top: 10px;
}
.podium-place {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  min-width: 0;
  transition: transform 0.15s var(--ease);
}
.podium-place:active {
  transform: scale(0.97);
}
.podium-place .avatar {
  box-shadow: 0 0 0 2px var(--line);
}
.podium-1 .avatar {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--robot-yellow);
}
.podium-name {
  font-weight: 700;
  font-size: var(--fs-sm);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.podium-rating {
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.podium-step {
  width: 100%;
  border-radius: 16px 16px 6px 6px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
  background: var(--surface);
}
.podium-1 .podium-step {
  height: 86px;
  background: linear-gradient(180deg, rgba(47, 123, 255, 0.32), rgba(47, 123, 255, 0.06)), var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--primary);
}
.podium-2 .podium-step {
  height: 64px;
}
.podium-3 .podium-step {
  height: 50px;
}
.lb-rank {
  width: 28px;
  flex: none;
  text-align: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.lb-rank.medal {
  display: inline-grid;
  place-items: center;
}
.lb-alone {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-alone-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
}
.lb-row .list-row-left {
  gap: 10px;
}
.lb-rating {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.lb-wdl {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.lb-row.me {
  background: var(--primary-soft);
}
.lb-row.me::after {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.lb-me-sticky {
  position: sticky;
  bottom: 8px;
  z-index: 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg), inset 0 0 0 1.5px var(--primary);
  animation: rise 0.35s var(--ease) both;
}
@keyframes rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}

/* ------------------------------------------------------------------ shop / appearance */
.beta-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--good);
  font-weight: 600;
}
.beta-banner .icon {
  color: var(--good);
}
.beta-banner small {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  color: var(--text-2);
  font-size: var(--fs-sm);
}
/* Board themes and piece sets: ONE vertical list of full-width rows — the app is portrait-only and never scrolls
   sideways, so a row (preview · name + state · check / price) fits any phone and any system text size. */
.theme-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.theme-card {
  --tc-preview: 84px;
  position: relative;
  display: grid;
  grid-template-columns: var(--tc-preview) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
  padding: 10px 14px 10px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: transform 0.16s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}
[data-theme='light'] .theme-card {
  box-shadow: 0 0 0 1px var(--border);
}
.theme-card:active {
  transform: scale(0.98);
}
.theme-card.selected,
[data-theme='light'] .theme-card.selected {
  background: linear-gradient(var(--primary-soft), var(--primary-soft)), var(--surface);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.theme-card .mini-board {
  width: 100%;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 3px 10px rgba(5, 6, 20, 0.28);
}
.theme-card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.theme-card-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.theme-card-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: var(--fs-sm);
  line-height: 1.3;
  color: var(--text-2);
}
.theme-card-sub .icon {
  flex: none;
}
.theme-card.selected .theme-card-sub {
  color: var(--primary-text);
  font-weight: 600;
}
.theme-card-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.theme-radio {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--border-strong);
}
.theme-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  animation: pop 0.3s var(--ease-spring);
}
@keyframes pop {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
}
/* Piece set: the eight-piece strip on top, the name row under it. */
.theme-card.piece-card {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  padding: 10px 14px 12px 10px;
}
.piece-card .piece-set-row {
  grid-column: 1 / -1;
}
.piece-card .theme-card-text {
  padding-left: 4px;
}
@media (max-width: 359px) {
  .theme-card {
    --tc-preview: 68px;
    gap: 12px;
    padding-right: 12px;
  }
}
.price-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
}
.mini-board {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  padding: 4px;
  background: var(--mb-frame, #262a50);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 4px 12px rgba(5, 6, 20, 0.3);
}
.mini-board-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.mb-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mb-sq .piece-svg {
  width: 92%;
  height: 92%;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}
.mb-sq.last::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--mb-last);
}
.mb-sq.dot::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--mb-dot);
}
.mini-board.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, transparent 40%, rgba(8, 9, 22, 0.4));
}
.piece-set-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border-radius: 12px;
  overflow: hidden;
}
.piece-set-sq {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: #c3c9e6;
}
.piece-set-sq.is-dark {
  background: #5a619e;
}
.piece-set-row .piece-svg {
  width: 88%;
  height: 88%;
  max-width: 38px;
  max-height: 38px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

/* VS+ card: navy with the brand's blue / orange light, white CTA. */
.premium-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-lg);
  color: #fff;
  background: radial-gradient(110% 120% at 100% 0%, rgba(255, 122, 47, 0.42), rgba(255, 122, 47, 0) 55%),
    radial-gradient(90% 100% at 0% 100%, rgba(47, 123, 255, 0.4), rgba(47, 123, 255, 0) 60%), #1e2142;
  box-shadow: inset 0 0 0 2px var(--accent);
}
.premium-card > * {
  position: relative;
}
.premium-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
}
.premium-title .icon {
  color: #ff9a5c;
}
.premium-perks {
  list-style: none;
  padding: 0;
  margin: 14px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #dfe2f2;
  font-size: 15px;
}
.premium-perks li {
  display: flex;
  align-items: center;
  gap: 10px;
}
.premium-perks .icon {
  color: #7faaff;
}
.premium-active {
  color: #ffc83d;
  font-weight: 700;
  font-size: var(--fs-sm);
}
.premium-card .btn-primary {
  color: #14162b;
  background: #ffffff;
}

/* Device prefs that act on the board through CSS (Оформление → Игра). */
html[data-coords='off'] .cb-coord {
  display: none;
}
html[data-legal='off'] .cb-dest::after {
  display: none;
}
html[data-legal='off'] .cb-hover.cb-is-dest {
  box-shadow: none;
  background: rgba(255, 255, 255, 0.08);
}
html[data-legal='off'] .cb-hover.cb-touch.cb-is-dest::before {
  background: rgba(0, 0, 0, 0.18);
}

/* ------------------------------------------------------------------ about */
.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 18px 0 6px;
}
.about-hero .splash-logo {
  animation: none;
}
.about-version {
  color: var(--text-2);
  font-size: var(--fs-xs);
}
.prose {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prose p {
  color: var(--text-2);
}
.prose ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-2);
}
.credit {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.credit-title {
  font-weight: 700;
}
.credit-text {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
/* Long source URLs wrap instead of widening the page on 320 px phones. */
.credit a {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.about-games {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.about-game {
  display: flex;
  align-items: center;
  gap: 12px;
}
.about-game-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  border-radius: 50%;
  overflow: hidden;
}
.about-game.is-soon .about-game-icon {
  opacity: 0.6;
}
.about-game-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.about-game-name {
  font-weight: 700;
}
.about-game-text {
  font-size: var(--fs-sm);
  color: var(--text-2);
}
/* Live games are tappable rows (→ the game's hub). */
button.about-game {
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-md);
  transition: transform 0.15s var(--ease);
}
button.about-game:active {
  transform: scale(0.98);
}
button.about-game:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}
.about-game-chevron {
  display: inline-flex;
  flex: none;
  margin-left: -4px;
  color: var(--text-2);
}

/* ------------------------------------------------------------------ devlogin */
.dev-users {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.dev-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}
[data-theme='light'] .dev-user {
  box-shadow: 0 0 0 1px var(--border);
}
.dev-user:active {
  transform: scale(0.96);
}
.dev-user.last {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.dev-user-name {
  font-weight: 700;
  font-size: 16px;
}
.dev-user-id {
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-family: var(--mono);
}
.dev-user.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* ------------------------------------------------------------------ onboarding (mockups Main / NickTaken / Invited)
   One screen: brand header on top, the middle scrolls only when it must (short phones), the main button and
   its footnote stay pinned to the bottom. */
.screen-onboarding {
  overflow: hidden;
  padding: calc(var(--safe-top) + 20px) calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 20px) calc(var(--safe-left) + 24px);
}
.onb {
  height: 100%;
  min-height: 0;
  gap: 0;
}
.onb-brand {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.onb-brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
}
.onb-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  /* room for focus rings and the selected-avatar ring */
  margin: 0 -6px;
  padding: 0 6px 4px;
}
.onb-scroll::-webkit-scrollbar {
  display: none;
}
.onb-title {
  margin-top: clamp(14px, 3.4vh, 30px);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
}
.onb-lead {
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-2);
  text-wrap: balance;
}
.onb-avatars {
  margin-top: clamp(16px, 3vh, 26px);
}
.onb-avatars .avatar-picker {
  margin-top: 12px;
  padding: 0 5px;
}
.onb-hint {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}
.onb .nick-field {
  margin-top: clamp(16px, 3vh, 26px);
}
.onb-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: clamp(14px, 2.6vh, 22px);
}
.onb-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  padding-top: 12px;
}
.onb-submit {
  min-height: 58px;
}
.onb-footnote {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-2);
}
.onb-footnote:empty {
  display: none;
}
.onb-promise {
  margin: 0 0 16px;
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-2);
  text-wrap: balance;
}
.onb-error {
  margin-bottom: 10px;
  color: var(--bad);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* Invited: "Max VS Ты" card with an orange frame. */
.onb-invite {
  margin-top: clamp(16px, 3.4vh, 28px);
  padding: 22px 20px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: fade-up 0.42s var(--ease) both;
}
.onb-invite.is-loading {
  box-shadow: inset 0 0 0 2px var(--border-strong);
}
.onb-invite-loading {
  margin-top: 14px;
  font-size: 14px;
}
.onb-invite-title {
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.onb-invite-chips {
  margin-top: 16px;
}
.onb[data-mode='invited'] .nick-field {
  margin-top: clamp(18px, 3.4vh, 28px);
}
.onb-avatar-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.onb-avatar-inline .field-label {
  flex: 1;
  min-width: 0;
}
.avatar-picker.is-compact {
  gap: 10px;
  justify-content: flex-end;
}
.avatar-picker.is-compact .avatar-option.selected {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}
.onb[data-mode='invited'] .toggle-row {
  margin-top: 20px;
}

/* Rows of the form: language select (a native <select> over the row) and the notify switch. */
.select-row,
.toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 16px;
}
[data-theme='light'] .select-row,
[data-theme='light'] .toggle-row {
  box-shadow: 0 0 0 1px var(--border);
}
.select-row {
  height: 56px;
  padding: 0 16px;
}
.select-row:focus-within {
  box-shadow: 0 0 0 2px var(--primary);
}
.select-row-icon,
.toggle-row-icon {
  color: var(--text-2);
}
.select-row-label {
  flex: 1;
  min-width: 0;
}
.select-row-value {
  color: var(--text-2);
}
.select-row-chevron {
  color: var(--text-2);
}
.select-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* no zoom on iOS focus */
  -webkit-appearance: none;
  appearance: none;
}
.toggle-row {
  min-height: 64px;
  gap: 10px;
  padding: 10px 14px 10px 16px;
}
.toggle-row-body {
  flex: 1;
  min-width: 0;
}
.toggle-row-sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-2);
}

/* ------------------------------------------------------------------ nick field (onboarding + profile sheet) */
.nick-field {
  display: flex;
  flex-direction: column;
}
.nick-field .field-label + .nick-box {
  margin-top: 8px;
}
.nick-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--border-strong);
  cursor: text;
  transition: box-shadow 0.2s var(--ease);
}
[data-theme='light'] .nick-box {
  background: var(--surface);
}
.nick-box:focus-within,
.nick-field[data-status='ok'] .nick-box {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.nick-field[data-status='bad'] .nick-box {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.nick-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
}
.nick-input::placeholder {
  color: var(--muted);
  font-weight: 500;
}
.nick-input:focus-visible {
  outline: none;
}
.nick-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-2);
}
.nick-field[data-status='ok'] .nick-pill {
  color: var(--primary-text);
}
.nick-field[data-status='bad'] .nick-pill {
  color: var(--accent-text);
}
.nick-pill-icon {
  display: inline-flex;
}
.nick-dot-spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.nick-line {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}
.nick-line[data-kind='bad'] {
  margin-top: 10px;
  font-size: 14px;
  color: var(--accent-text);
}
.nick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.nick-chips:empty {
  display: none;
}
.nick-chip {
  max-width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  animation: fade-up 0.3s var(--ease) both;
  transition: transform 0.15s var(--ease);
}
.nick-chip:active {
  transform: scale(0.95);
}

/* Short phones: tighten the vertical rhythm so the form still fits; below that only the middle scrolls. */
@media (max-height: 760px) {
  .onb-title {
    font-size: 24px;
  }
  .onb-lead {
    margin-top: 8px;
    font-size: 15px;
  }
  .onb-invite {
    padding: 16px 16px 16px;
  }
  .onb-invite-title {
    margin-top: 12px;
    font-size: 19px;
  }
  .onb-invite-chips {
    margin-top: 12px;
  }
  .onb-promise {
    margin-bottom: 10px;
    font-size: 14px;
  }
  .onb-footnote {
    margin-top: 10px;
  }
}
@media (max-height: 680px) {
  .screen-onboarding {
    padding-top: calc(var(--safe-top) + 14px);
    padding-bottom: calc(var(--safe-bottom) + 14px);
  }
  .onb-invite .avatar {
    width: 52px !important;
    height: 52px !important;
  }
}
@media (max-width: 360px) {
  .screen-onboarding {
    padding-left: calc(var(--safe-left) + 16px);
    padding-right: calc(var(--safe-right) + 16px);
  }
  .onb-avatars .avatar-option {
    --av-size: 50px !important;
  }
  .avatar-picker.is-compact {
    gap: 6px;
  }
  .avatar-picker.is-compact .avatar-option {
    --av-size: 38px !important;
  }
}

/* ------------------------------------------------------------------ entrance stagger */
.stagger > * {
  animation: fade-up 0.42s var(--ease) both;
}
.stagger > *:nth-child(2) { animation-delay: 0.04s; }
.stagger > *:nth-child(3) { animation-delay: 0.08s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; }
.stagger > *:nth-child(5) { animation-delay: 0.16s; }
.stagger > *:nth-child(6) { animation-delay: 0.2s; }
.stagger > *:nth-child(n + 7) { animation-delay: 0.24s; }
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ------------------------------------------------------------------ responsive */
/* Phones: the avatar badge already names the game, and next to a status badge the text label would only
   squeeze out the time control ("Шах…"), so it shows on wider screens only. */
@media (max-width: 440px) {
  .game-row-game {
    display: none;
  }
}
@media (max-width: 400px) {
  .quick-tile {
    padding-left: 2px;
    padding-right: 2px;
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  :root {
    --gutter: 16px;
  }
  .hero-art {
    width: 112px;
    height: 112px;
    right: -24px;
    bottom: -16px;
  }
  .hero-glow {
    width: 110px;
    height: 110px;
  }
  .hero-title {
    font-size: 20px;
  }
  .hero-quick {
    gap: 5px;
  }
  .hero-chip {
    gap: 4px;
    padding: 0 9px 0 7px;
    font-size: 13px;
  }
  .quick-grid {
    gap: 8px;
  }
  .quick-tile {
    font-size: 11px;
  }
  .quick-tile.is-row {
    font-size: 14px;
    gap: 8px;
    padding-left: 10px;
  }
  /* two row tiles side by side at 320 px: the decorative chevron gives way so «Рейтинг» isn't cut to «Рейти…» */
  .quick-tile.is-row .quick-tile-chevron {
    display: none;
  }
  .chess-emblem {
    width: 42px;
    height: 42px;
  }
  /* 320 px: «Шахматы» (Unbounded) ran under the rating pill — a tighter pill and gap give the title its ~118 px */
  .chess-head {
    gap: 10px;
  }
  .chess-head .rating-pill {
    gap: 4px;
    padding: 0 10px;
  }
  .chess-head-title {
    font-size: 18px;
  }
  /* next to the rating pill the tagline only had ~110 px and ended in "и с…"; the showcase tile already says it */
  .chess-head-sub {
    display: none;
  }
  .game-tile-title {
    font-size: 21px;
  }
  .game-art-knight {
    width: 76px;
    height: 76px;
  }
  .mini-strip {
    grid-template-columns: repeat(7, 18px);
    grid-template-rows: repeat(2, 18px);
  }
  .tc-option-main {
    font-size: 15px;
  }
  .lobby-vs {
    gap: 14px;
  }
  .invite-game-name {
    font-size: 14px;
  }
  /* the «скоро» pill (top-right) would sit on the EXIT sign in a 130 px tile: the sign drops to the art's bottom */
  .invite-game-art .game-art-escape {
    align-items: flex-end;
    padding-bottom: 9px;
  }
  .avatar-picker.with-labels {
    gap: 14px 4px;
  }
  .avatar-picker.with-labels .avatar-option {
    --av-size: 64px !important;
  }
}
@media (min-width: 700px) {
  .screen {
    padding-top: calc(var(--safe-top) + 24px);
  }
}

/* ------------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .badge-turn {
    animation: none;
    box-shadow: 0 0 0 2px rgba(47, 123, 255, 0.45);
  }
  .screen-enter,
  .screen-leave {
    transform: none !important;
  }
}

/* Long CTA labels in Unbounded ("Отправить в Telegram") use the mockup's 16 px; 14 px on narrow phones. */
.sheet-footer .btn-primary.btn-lg,
.lobby-actions .btn-primary.btn-lg {
  font-size: 16px;
}
@media (max-width: 360px) {
  .btn-lg {
    font-size: 16px;
  }
  .sheet-footer .btn-primary.btn-lg,
  .lobby-actions .btn-primary.btn-lg {
    font-size: 14px;
    padding: 0 14px;
  }
}
