:root {
  --tg-bg: var(--tg-theme-bg-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --tg-section-bg: var(--tg-theme-section-bg-color, #ffffff);
  --tg-text: var(--tg-theme-text-color, #000000);
  --tg-hint: var(--tg-theme-hint-color, #8e8e93);
  /* Hardcoded, not driven by --tg-theme-link-color — same reasoning as
     --tg-button below: Telegram's live theme would otherwise win over this
     fallback and override the bot's own accent blue. */
  --tg-link: #0098ea;
  /* Hardcoded, not driven by --tg-theme-button-color — Telegram's live
     theme almost always supplies its own button_color, which would
     otherwise win over this fallback and silently override the bot's own
     accent blue. */
  --tg-button: #0098ea;
  --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-separator: rgba(60, 60, 67, 0.29);
  --win: #34c759;
  --lose: #ff3b30;

  /* Dock tokens — ported from the Figma redesign (node 1:39/1:40, "Empty"
     screen) as a fixed brand look, not a Telegram-theme-driven one: same
     hex regardless of data-theme/data-appearance (see the removed dark-mode
     overrides below and the deleted data-appearance ones — this is the one
     place those two systems no longer apply). */
  --dock-glass: #330002;
  --dock-glass-shadow: 0 0 15px rgba(255, 212, 0, .3);
  /* No separate glass rim in the Figma dock (its "border" is the same hex
     as the fill, so it doesn't actually read as a line) — kept as a no-op
     shadow instead of removing the var, since .tabbar__pill chains it into
     a comma-separated box-shadow list. */
  --dock-glass-rim: 0 0 0 0 transparent;
  --dock-selection: #4b030a;
  --dock-label: rgba(255, 255, 255, .6);
  --dock-accent: #ff1c42;
  --dock-h: calc(78px + max(25px, env(safe-area-inset-bottom, 0px)));

  /* Segmented tab control (e.g. "Что выпадет?" 1-6 picker): light mode shows
     a white track with a grey active pill, matching the quick-amount chips. */
  --segment-track-bg: #ffffff;
  --segment-active-bg: rgba(118, 118, 128, 0.12);
}

:root[data-theme="dark"] {
  /* --dock-* intentionally not overridden here anymore — the dock is now a
     fixed brand look (see the :root block above), the same in light and
     dark Telegram themes. */

  /* Dark mode: active tab uses the exact same chip tone as the 50/100/250/500
     quick-amount buttons (rgba(118, 118, 128, 0.12), same as light mode). */
  --segment-track-bg: rgba(118, 118, 128, 0.16);
  --segment-active-bg: rgba(118, 118, 128, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Same press-scale feedback as the dock's own + button (originally
   .searchbtn-only) — applied to every <button> in the app so all of them
   get the same "slight grow while held" feel. */
button {
  transition: transform 0.15s ease;
}
button:active {
  transform: scale(1.1);
}
/* Dock tabs (Комнаты/Турниры/Подарки/Профиль) opt out — their own sliding
   highlight pill already carries the feedback, so the scale on top of that
   read as busy/conflicting. The dock's own + button is a plain button, not
   a .tab, so it's unaffected. */
/* Any tab/segmented-control button — dock tabs, PVP/Royal and other
   .segment pickers, the filter menu, Профиль/История — none of them should
   grow on tap; their own active/sliding-pill state is already the
   feedback. */
.tab:active,
.segment:active,
.sel-menu__item:active {
  transform: none;
}
/* Full-width buttons (Готов, Отменить, Создать комнату, Пригласить игрока,
   …) — scaling a 100%-wide button UP overflows the viewport on either
   side. Shrink slightly instead, same press-feedback idea without the
   overflow. */
.play-btn:active {
  transform: scale(0.97);
}
/* Every button inside a modal sheet (close/menu icons, Наш канал,
   Закрыть, Войти, etc. — .modal-sheet covers all of them, .play-btn
   included) or on the active room/game screen (#page-game — Готов, the
   ready-countdown/roll button) shrinks on press instead of the app-wide
   default grow — a modal/room already feels tight on screen, so a button
   growing toward its edges read as off rather than as feedback. */
.modal-sheet button:active,
#page-game button:active {
  transform: scale(0.97);
}
/* Dock's own "+" (create room), the toolbar's wallet/TON-connect pill
   (#modesCreateBtn — blue, diamond icon), and the filter icon next to it —
   same shrink-on-press as everything above instead of the app-wide
   default grow. */
#modesCreateBtn:active,
#modesFilterBtn:active {
  transform: scale(0.97);
}
/* Same thin iOS-style inset stroke as the Профиль row icons / dock + button
   (see .ann-settings-icon) — every button across the room flow (create →
   wait → active game → result), the "Войти" chip on a room/match card, and
   Турниры'/Подарки' "Наш канал"/"Закрыть" pair. Supersedes the older,
   narrower #confirmCreateRoomBtn-only version of this rule — Пригласить
   игрока (both copies: the create sheet's and the wait sheet's) is back on
   it now too. */
#gameActionBar .play-btn {
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.35);
}

html, body {
  margin: 0;
  /* Every direct child in here (#pages, .tabbar, …) is position:fixed, so
     html/body's own box collapses to 0 height with nothing to size it —
     harmless as long as nothing but solid native Telegram chrome colors
     (see syncChrome() in app.js) needed to show through it, but the
     radial-gradient background below paints into that 0-height box and
     was invisible until this line gave it something to actually cover. */
  height: 100%;
  /* The document itself never scrolls — #pages below is the actual scroll
     container. Telegram's own native header shows a hairline shadow under
     itself whenever the *document* scrolls away from the top (that's how
     it signals "there's more above, scrolled under the header"); mini-apps
     that don't see this keep document.scrollTop pinned at 0 by scrolling an
     inner element instead, same as here. */
  overflow: hidden;
  /* Hardcoded, not var(--tg-secondary-bg) — fixed brand backdrop, the same
     regardless of Telegram's live theme or the in-app light/dark-gray/black
     appearance setting (see :root[data-appearance=...] below, which no
     longer drives the page backdrop). Solid black base — the actual red
     glow/vignette is the .bg-glow layer (see below), 1:1 off Figma node
     1:5's own Ellipse 31114/31115/31116/31117, same as its own black base
     fill underneath those. */
  background: #000000;
  color: var(--tg-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* The viewport meta's user-scalable=no isn't always honored by the
     WKWebView Telegram embeds on iOS — this is the part that actually
     blocks the two-finger pinch gesture there. Still allows normal one-
     finger scroll/pan (pan-x pan-y), just not the zoom gesture itself. */
  touch-action: pan-x pan-y;
}

/* 1:1 port of Figma node 1:5's background glow (Ellipse 31114/31116/31117 +
   the 31115 vignette) — same fill colors, opacity, size, rotation and
   position as those four nodes, reconstructed with filter:blur()/
   radial-gradient instead of shipping them as downloaded raster/SVG assets.
   Sits once at the body level (fixed, behind every page) rather than
   per-screen, matching the "fixed brand everywhere" background decision. */
.bg-glow {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Высота и все «vh» ниже — от --app-h (самая большая высота окна за
     сессию, см. lockAppHeight), а не от живого вьюпорта: клавиатура
     сжимает вьюпорт, и фон не должен двигаться/менять масштаб. */
  height: var(--app-h, 100vh);
  --u: calc(var(--app-h, 100vh) / 100);
  /* No z-index (not -1): a negative z-index on a fixed element with no
     positioned/transformed ancestor escapes to the ROOT stacking context,
     where it paints *behind* html/body's own canvas-propagated background
     — i.e. invisible behind the solid black fill above, regardless of
     paint order. Markup order alone is enough instead: this is the first
     child of <body>, so every other fixed-position element (#pages,
     .tabbar, …) naturally stacks above it without needing a z-index war. */
  overflow: hidden;
  pointer-events: none;
}

.bg-glow__blob {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  opacity: 0.61;
}

/* All sizes/offsets below are Figma's own px values converted to vh — its
   485x874 reference frame only ever matched one specific phone height, so
   raw px (or vw, which tracks the wrong axis here) put the top/bottom blobs
   at the wrong depth into frame on any other screen height: on a taller
   phone than Figma's frame, a fixed px offset lands much closer to center
   than it should, and the composition reads as a flat, edge-to-edge wash
   instead of a glow concentrated mid-screen with dark top/bottom corners.
   vh scales every one of these together with the offsets, keeping the same
   proportions Figma's frame had regardless of actual device height. */

/* Ellipse 31114 — the big center blob. */
.bg-glow__blob--center {
  width: calc(64.6 * var(--u));
  height: calc(60.3 * var(--u));
  background: #700204;
  filter: blur(calc(11.4 * var(--u)));
  transform: translate(-50%, -50%) rotate(5.83deg);
}

/* Ellipse 31117 — bleeds in from just above the frame's top edge. */
.bg-glow__blob--top {
  width: calc(68.9 * var(--u));
  height: calc(40.7 * var(--u));
  background: #be0104;
  filter: blur(calc(8.6 * var(--u)));
  transform: translate(-50%, calc(-50% - calc(53.5 * var(--u)))) rotate(-0.51deg);
}

/* Ellipse 31116 — mirrors --top, bleeding in from just below the bottom edge. */
.bg-glow__blob--bottom {
  width: calc(68.9 * var(--u));
  height: calc(40.7 * var(--u));
  background: #be0104;
  filter: blur(calc(8.6 * var(--u)));
  transform: translate(-50%, calc(-50% + calc(56.1 * var(--u)))) rotate(-0.51deg);
}

/* Ellipse 31115 — a radial-gradient vignette (transparent center fading to
   black), not a blurred fill, so no filter:blur() needed here. */
.bg-glow__vignette {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(124.1 * var(--u));
  height: calc(114 * var(--u));
  opacity: 0.61;
  background: radial-gradient(ellipse at center, transparent 49.3%, #000000 100%);
  transform: translate(-50%, -50%) rotate(5.83deg);
}

#pages {
  /* Anchored straight to the real viewport edges (same technique already
     used by .sheet-overlay/.modal-overlay below) instead of height:100%,
     which chains through html → body and can undershoot the actual window
     in some Telegram clients (seen on Desktop) — leaving a gap at the
     bottom that exposes Telegram's own window background behind the app.
     height is var(--app-h) rather than part of `inset: 0` specifically so
     the on-screen keyboard opening doesn't shrink it: --app-h is locked to
     the tallest height seen so far (see lockAppHeight() in app.js, ported
     from @the_nfts_bot's own --app-h), so the keyboard just overlays the
     bottom of the page instead of the whole layout squeezing up to make
     room for it. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-h, 100vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* contain, not none: stops the drag from chaining up to the document
     (document.scrollTop must stay pinned at 0 — see the html/body comment
     above) without also killing #pages' own native elastic rubber-band at
     its top/bottom edges the way `none` does. Same property gfts-bot's own
     inner scrollers use for the same reason (see its
     #collectionOverlay .modal-sheet__scroll rule) — this is the browser's
     real bounce, not a hand-rolled one. */
  overscroll-behavior-y: contain;
  /* requestFullscreen() (app.js) hides Telegram's own header, so the status
     bar/notch area that header used to clear is now ours to avoid —
     --tg-content-safe-area-inset-top is the client's own reserved amount
     (notch + its floating fullscreen close/minimize controls), 0 outside
     fullscreen; env() covers plain-browser testing the same way the bottom
     padding below already does. */
  padding-top: calc(16px + max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px)));
  padding-bottom: var(--dock-h);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#pages::-webkit-scrollbar { display: none; }

/* Комнаты' own content is sized to exactly fill the viewport — any scroll
   on this page is just rubber-band bounce from the extra safe-area padding
   #pages picked up for fullscreen (see padding-top above), not real
   overflow content. Locked only while this page is the active one; every
   other page keeps #pages' normal scroll. */
#pages:has(> #page-modes.active) {
  overflow: hidden;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Турниры/Подарки stubs — vertically centered content instead of the
   normal top-of-scroll block layout every other page uses. Higher
   specificity (3 classes) than the plain .page.active rule above, which it
   needs to override just the one declaration (display). */
.page-stub.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--app-h, 100vh) - 16px - var(--dock-h));
}

/* Small drifting dice scattered behind Комнаты's own content — originally
   Турниры' placeholder-page decoration, moved here once Турниры/Подарки
   became small popup sheets (#tournamentsSheet/#giftsSheet) instead of full
   pages with room for a background field. Same idea as Telegram's own
   gift/QR share screens (a loose field of icons slowly bobbing in place),
   just monochrome and dim instead of a bold colored icon, since this is
   decoration, not the page's actual content. Fixed (not absolute) so it
   spans the *real* viewport instead of just #page-modes's own box, which
   stops short of the dock (its min-height explicitly subtracts
   var(--dock-h)) — this way dice actually drift the full screen, including
   behind the dock's translucent glass, rather than leaving empty space
   above it. Still sits under the dock's own z-index:20, so the dock stays
   on top, and behind #page-modes's own foreground content (room list,
   toolbar — see the z-index:1 rule below). */
.bg-float-layer {
  /* height var(--app-h), not inset:0 — same reasoning as #pages above: each
     star's inline top/left is a % of this box, so an inset:0 box that
     shrinks with the keyboard scrambles every star's position the instant
     it opens. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-h, 100vh);
  pointer-events: none;
  z-index: 0;
}

.bg-float {
  position: absolute;
  aspect-ratio: 1;
  color: rgba(255, 255, 255, 0.14);
  /* linear, not ease-in-out — these rise at a steady pace like real
     bubbles, rather than accelerating/decelerating between keyframes the
     way the old in-place wiggle wanted. */
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  transform: rotate(var(--r, 0deg));
}

:root[data-theme="light"] .bg-float {
  color: rgba(0, 0, 0, 0.1);
}

/* Bubbles-in-a-bottle: each dice rises in a straight shot from its own
   (randomized, see index.html) spawn point to well above the top of the
   screen, then snaps back to that same spawn point to loop — same
   per-element desync trick as before (random duration + negative delay),
   just a rise instead of an in-place wiggle. Three variants with slightly
   different left/right wobble at the midpoint (picked per element via
   animation-name inline) so the field doesn't read as every dice rising
   in a perfectly straight, identical line. -1800px comfortably clears any
   phone/tablet viewport's height even starting near the bottom.
   */
@keyframes bg-rise-a {
  0% { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  50% { transform: translate(6px, -700px) rotate(calc(var(--r, 0deg) + 6deg)); }
  100% { transform: translate(-4px, -1800px) rotate(calc(var(--r, 0deg) - 4deg)); }
}

@keyframes bg-rise-b {
  0% { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  50% { transform: translate(-8px, -700px) rotate(calc(var(--r, 0deg) - 8deg)); }
  100% { transform: translate(5px, -1800px) rotate(calc(var(--r, 0deg) + 5deg)); }
}

@keyframes bg-rise-c {
  0% { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  50% { transform: translate(9px, -700px) rotate(calc(var(--r, 0deg) + 10deg)); }
  100% { transform: translate(-7px, -1800px) rotate(calc(var(--r, 0deg) - 7deg)); }
}

#page-modes .rooms-toolbar,
#page-modes #modesOpenSection {
  position: relative;
  z-index: 1;
}

.balance-card {
  margin: 0 16px 12px;
  background: var(--tg-section-bg);
  border-radius: 30px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance-label {
  font-size: 15px;
  color: var(--tg-hint);
}

.balance-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--tg-link);
}

.stage-card {
  margin: 0 16px 12px;
  background: var(--tg-section-bg);
  border-radius: 22px;
  padding: 28px 16px 22px;
  text-align: center;
}

.result-emoji {
  font-size: 64px;
  line-height: 1;
  transition: transform 0.15s;
}

/* Fixed-height box around the game screen's dice stage: the 64px emoji
   placeholder and the 120px lottie it swaps to mid-roll (see
   playDiceLottieIn) are different heights, so #gameRollStage itself used to
   grow/shrink the moment a roll started — the card visibly stretched taller
   right as you clicked "Бросить кубик". Centering both inside a box already
   sized for the taller one keeps the card a constant height throughout. */
.game-roll-visual {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-text {
  margin-top: 10px;
  font-size: 14px;
  color: var(--tg-hint);
  min-height: 18px;
}

.result-text.win { color: var(--win); font-weight: 600; }
.result-text.lose { color: var(--lose); font-weight: 600; }

.section {
  margin: 0 16px 12px;
}

.section-header {
  font-size: 13px;
  font-weight: 400;
  color: var(--tg-hint);
  letter-spacing: 0.2px;
  padding: 0 4px 6px;
}

.segmented {
  position: relative;
  display: flex;
  background: var(--segment-track-bg);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  overflow: hidden;
}

/* Sliding selection pill — same mechanism and easing as the bottom dock's
   .tabbar__sel: a single absolutely-positioned element whose width/position
   are set in JS from the active button's bounding rect, instead of each
   button toggling its own background (which just crossfades in place). */
.segmented__sel {
  position: absolute;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--segment-active-bg);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), width .3s cubic-bezier(.4, 0, .2, 1);
  pointer-events: none;
}

.segment {
  position: relative;
  z-index: 1;
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 999px;
  font-size: 20px;
  padding: 7px 0;
  cursor: pointer;
  color: var(--tg-text);
}

.list-card {
  background: var(--tg-section-bg);
  border-radius: 22px;
  overflow: hidden;
}

.list-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tg-separator);
}

.list-row:last-child {
  border-bottom: none;
}

.quick-row {
  display: flex;
  gap: 8px;
}

.quick {
  flex: 1;
  background: rgba(118, 118, 128, 0.12);
  border: none;
  color: var(--tg-text);
  padding: 8px 0;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.action-area {
  margin: 4px 16px 20px;
}

.play-btn {
  width: 100%;
  background: var(--tg-button);
  color: var(--tg-button-text);
  border: none;
  padding: 14px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.play-btn:disabled {
  opacity: 0.5;
}

/* Stacked play-btns (e.g. roomWaitOverlay's Бросить кубик/Пригласить
   игрока/Отменить комнату) are plain block siblings with no gap of their
   own otherwise — this gives every such pair a little breathing room
   without needing a wrapper on each sheet that uses more than one. */
.play-btn + .play-btn {
  margin-top: 10px;
}

.history-empty {
  padding: 16px;
  text-align: center;
  color: var(--tg-hint);
  font-size: 13px;
}

/* Vertical spacing lives in the margin (not padding) so it's symmetric and
   self-contained — it used to rely on whatever margin-bottom the block above
   happened to have (10-14px) plus its own 8px top padding, with nothing
   matching that below, so the gap above was consistently bigger than below. */
.hint-text {
  margin: 14px 0;
  padding: 0 20px;
  text-align: center;
  color: var(--tg-hint);
  font-size: 12px;
}

/* Floating glass dock — matches the bottom tab bar pattern used by
   nftshniy's Telegram Mini App (blurred pill + sliding selection). */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  /* От зафиксированной высоты окна (--app-h), а не от живого низа вьюпорта: клавиатура
     сжимает вьюпорт, и прижатый к низу док ехал вместе с ним рывками. */
  top: calc(var(--app-h, 100vh) - var(--dock-h));
  height: var(--dock-h);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 60px max(25px, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  transition: transform .3s cubic-bezier(0.32, 0.72, 0, 1), opacity .22s ease;
}

/* Replaces .tabbar for the whole #page-game flow (see showPage()) — same
   fixed-bottom footprint and side padding, just two full-width buttons
   instead of the dock pill. */
.game-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px max(25px, env(safe-area-inset-bottom, 0px));
}

.game-actionbar__buttons {
  display: flex;
  gap: 8px;
}

.game-actionbar .play-btn {
  flex: 1;
  min-width: 0;
  /* line-height:normal (the .play-btn default) sizes off the font's own
     metrics per piece of text — Cyrillic ("Готов") and plain digits ("41")
     land on different line-box heights for the same font-size, so the two
     buttons came out visibly different heights. A fixed line-height makes
     both resolve to the exact same box regardless of their text. */
  line-height: 20px;
  /* These two sit side by side, not stacked — .play-btn + .play-btn's
     margin-top (for vertically-stacked buttons elsewhere) would otherwise
     push the second one down and, since this row stretches to a shared
     height, make it render visibly shorter than the first. */
  margin-top: 0;
}

.play-btn--green {
  background: var(--win);
}

.play-btn--red {
  background: var(--lose);
}

/* Circular player avatars for the ready-up screen — same visual language as
   .tui-cell__avatar, just bigger and laid out in a row instead of a list. */
.game-players {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

/* Transparent to layout — its .game-player children lay out exactly as if
   they were direct children of .game-players (flex item for PVP, absolute
   circle slot for Royal); it exists only so renderGamePlayers can
   re-render them without wiping out #gameCircleDiceSlot, its sibling. */
#gamePlayersInner {
  display: contents;
}

.game-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 64px;
}

.game-player__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.12);
  color: var(--tg-link);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 600;
  position: relative;
}

/* Telegram's own profile photo, laid over the initials acronym that's
   already sitting there underneath — covers it when the photo loads,
   removes itself on error (see renderGamePlayers) so the acronym shows
   through untouched for players with no public photo. */
.game-player__avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* A thin green ring instead of swapping the whole avatar background — reads
   as "confirmed" at a glance without fighting the avatar's own color. */
.game-player--ready .game-player__avatar {
  box-shadow: 0 0 0 2px var(--win);
}

/* Depleting countdown ring — "Готов"/"Бросить кубик" turn clock (see
   avatarRingHtml). Sits just outside the avatar circle (inset -4px) so it
   reads as a ring around it, not a border fighting .game-player--ready's
   own box-shadow ring. pointer-events:none so it never blocks a tap on the
   avatar underneath; -90deg rotation starts the depletion at 12 o'clock
   instead of 3 o'clock (SVG's own 0deg).
   width/height:100% — the SVG carries its own width="60" height="60"
   attributes (sized for the original fixed 52px avatar); as a replaced
   element, position:absolute + inset alone doesn't stretch it past that
   intrinsic size, it only ever matched by coincidence when every avatar
   this ring could appear on happened to be exactly 52px. The duel screen's
   bigger 72px/100px avatars exposed it — the ring stayed a fixed 60px
   regardless, sitting visibly off the actual circle. 100% + the SVG's own
   viewBox scales the ring (and RING_R's circle) to whatever size the
   avatar it's drawn on actually renders at, Royal's 52px included. */
/* The -4px expand/offset lives on this plain div (position:absolute +
   inset:-4px stretches a normal element correctly) — the nested <svg>
   (.game-player__ring-svg) just fills it at width/height:100%, a bare
   percentage with no calc() involved. Doing the expand directly on the
   <svg> itself (inset:-4px + width/height:calc(100% + 8px)) silently
   dropped the +8px in this engine — calc() mixing a percentage with a px
   term doesn't resolve right on an <svg> root here, even though a plain
   percentage measured fine on its own. */
.game-player__ring {
  position: absolute;
  inset: -4px;
  pointer-events: none;
}

/* The containing block for an absolutely positioned child is its
   ancestor's PADDING box, not its border box — Royal's plain avatar
   (no border) has no gap between the two, so inset:-4px above lands 4px
   outside its visible edge like it looks like it should. Duel's avatar
   (.page-game--duel, 4px border added for the Figma identity ring) is 4px
   narrower on the padding side, so that same -4px only clears the border
   exactly, landing right back on the avatar's own visible edge — the ring
   never actually left it. Dropping to -8px here re-adds the border's own
   4px so the ring clears the VISIBLE circle by 4px again, same as Royal. */
.page-game--duel .game-player__ring {
  inset: -8px;
}

.game-player__ring-svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.game-player__ring-fg {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  /* 169.65 = 2π × 27 (the circle's own r, see RING_R/RING_C in app.js) —
     a full, unbroken ring to start, depleted via stroke-dashoffset. */
  stroke-dasharray: 169.65;
  animation: game-ring-deplete var(--ring-duration, 30000ms) linear forwards;
}

.game-player__ring-fg--green {
  stroke: var(--win);
}

.game-player__ring-fg--red {
  stroke: var(--lose);
}

/* Таймер «Готов» (30 с): зелёный → жёлтый при 20 с до конца → красный при 10 с, плавно (≈1 с на переход).
   Цветовая анимация идёт параллельно с убыванием кольца; отрицательный delay (--ring-color-delay) продолжает её
   с реального места при перерисовке. */
.game-player__ring-fg--ready {
  stroke: var(--win);
  animation: game-ring-deplete var(--ring-duration, 30000ms) linear forwards,
             game-ring-color 30000ms linear forwards;
  animation-delay: 0ms, var(--ring-color-delay, 0ms);
}

@keyframes game-ring-color {
  0%, 31.67% { stroke: var(--win); }
  35%, 65% { stroke: #ffd60a; }
  68.33%, 100% { stroke: var(--lose); }
}

@keyframes game-ring-deplete {
  from {
    stroke-dashoffset: var(--ring-from, 0);
  }
  to {
    stroke-dashoffset: var(--ring-to, 169.65);
  }
}

.game-player__name {
  font-size: 12px;
  color: var(--tg-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-player__status {
  font-size: 11px;
  line-height: 18px;
  color: var(--tg-hint);
}

.game-player--ready .game-player__status {
  color: var(--win);
}

/* Elimination (Royal): a player who's out for the rest of the match, rather
   than just not-ready-yet — dimmed instead of removed, so the row count
   stays stable and you can still see who was in it. */
.game-player--eliminated .game-player__avatar {
  opacity: 0.35;
}

.game-player--eliminated .game-player__name,
.game-player--eliminated .game-player__status {
  opacity: 0.5;
}

.game-player--eliminated .game-player__status {
  color: var(--lose);
}

/* Every multiplayer game screen (room duel or Royal match) uses this same
   circle — 2 fixed seats for a duel, up to 8 for Royal. Players sit on a
   fixed circle (JS sets each --x/--y in renderGamePlayers); #gameRollStage
   gets physically moved into .game-circle-dice-slot (see
   placeGameRollStage) once rather than duplicated, so every bit of
   roll-animation logic keeps working on the exact same element. */
.game-players--circle {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 0 auto;
  flex-wrap: nowrap;
}

/* With the title/mode-label text gone (see renderGameScreen), the circle
   is the card's only content — even, symmetric padding instead of the
   title layout's taller top padding keeps the dice centered in the card,
   not just in the 300x300 circle box sitting inside it. */
/* No card frame — the circle + centered dice sit straight on the page
   background, margin only (keeps #gameStage's own vertical spot in the
   flow so .game-actionbar below doesn't jump). */
.stage-card--circle {
  background: none;
  border-radius: 0;
  padding: 0;
}

/* Centers the whole circle+dice vertically in whatever room is actually
   left below #gameTicker (not just packed against the top like every other
   page's natural top-to-bottom flow) — #gameTopRow stays put at the top as
   an ordinary flex child, #gameStage grows to fill the rest and centers
   its one child (.game-players--circle) inside that.
   .active is required here, not just page-game--circle — an #id selector
   otherwise outranks .page's own `display: none` by specificity alone and
   keeps rendering (bleeding through whatever page you navigate to next)
   even once .active is gone and closeGameScreen() has moved on, since
   nothing clears the page-game--circle class itself when leaving. */
#page-game.active.page-game--circle {
  display: flex;
  flex-direction: column;
  min-height: calc(var(--app-h, 100vh) - 16px - var(--dock-h));
}

#page-game.active.page-game--circle #gameStage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-players--circle .game-player {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  transform: translate(calc(-50% + var(--x, 0px)), calc(-50% + var(--y, 0px)));
}

/* "Ждём"/"Готов" under each seat — redundant now that #gameTicker above
   already announces turns and readiness for the whole table; eliminated
   still reads fine from the dimmed avatar alone. The rolled *value* stays
   visible — that's per-seat information the ticker doesn't carry. */
.game-players--circle .game-player__status {
  display: none;
}

/* An unfilled seat — nobody's joined yet. */
.game-player--waiting .game-player__avatar {
  background: rgba(118, 118, 128, 0.12);
  border: 2px dashed rgba(118, 118, 128, 0.35);
  color: var(--tg-hint);
}

.game-circle-dice-slot {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 180px;
}

/* Same centered spot as .game-circle-dice-slot — the two are never shown
   at once (status is either "starting" or something else entirely), so
   there's no need to keep them apart. */
.game-countdown {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 800;
  color: var(--tg-text);
  pointer-events: none;
}

/* The roll lottie carries a shadow baked into the bottom of its own frame,
   which reads as visual weight low in the box even though the box itself
   sits exactly on the circle's true center (the static 🎲 placeholder has
   no such shadow and needs no nudge) — shift just the animated lottie up
   to look centered against the seats. Scoped to this slot only, not every
   .result-lottie elsewhere (solo Кубик page, room/match overlays), which
   are already correctly centered on their own. */
.game-circle-dice-slot .result-lottie {
  margin-top: -25px;
}

.game-circle-dice-slot .stage-card {
  margin: 0;
  padding: 8px;
  background: none;
}

/* "Бросает Имя..."/"Имя: значение" under the dice is redundant now that
   #gameTicker above already shows the same thing, and kept the dice itself
   from sitting dead-center (the text's own height pulled the visual
   midpoint of the whole block down) — hidden outright so the die alone
   centers in the circle. */
.game-circle-dice-slot .result-text {
  display: none;
}

/* Status ticker + bank pill above the circle — same rounded-pill look as
   the "Название комнаты" search field on Комнаты (.list-card > .list-row),
   just holding plain text instead of an <input>. */
.game-top-row {
  display: flex;
  gap: 8px;
  margin: 0 16px 12px;
}

.game-ticker {
  flex: 1;
  min-width: 0;
  height: 44px;
}

.game-bank-pill {
  /* Width follows its own content (not a fixed box) — the bank can read
     "1" or "10000" depending on the stake, and a fixed width either
     wasted space on short numbers or clipped long ones. Height matches
     .game-ticker exactly — they sit side by side in .game-top-row and used
     to be 3px shorter, visibly uneven next to it. */
  flex: none;
  width: auto;
  height: 44px;
}

.game-ticker .list-row,
.game-bank-pill .list-row {
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.game-bank-pill .list-row {
  padding: 0 12px;
}

.game-bank-pill__icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* Status line ("Ходит Имя" / "Твой ход!" / "Готов") reads left-to-right as
   a running line, not a short centered label like the bank pill next to
   it — left-aligned, with its own slightly wider left inset. */
.game-ticker .list-row {
  justify-content: flex-start;
  padding-left: 18px;
}

.game-ticker__text {
  font-size: 15px;
  color: var(--tg-text);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* While a text/number field is focused, the on-screen keyboard pushes the fixed
   viewport up — hide the dock instead of letting it jump mid-screen. */
.tabbar.keyboard-editing {
  opacity: 0;
  transform: translateY(calc(100% + 12px)); /* уезжает вниз за край окна целиком */
  pointer-events: none;
}

.tabbar__pill {
  position: relative;
  flex: 1;
  display: flex;
  padding: 3px 4px;
  border-radius: 31px;
  overflow: hidden;
  background: var(--dock-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.7);
  backdrop-filter: blur(18px) saturate(1.7);
  box-shadow: var(--dock-glass-shadow), var(--dock-glass-rim);
  pointer-events: auto;
}

.tabbar__sel {
  position: absolute;
  top: 4px;
  left: 0;
  height: 54px;
  border-radius: 28px;
  background: var(--dock-selection);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), width .3s cubic-bezier(.4, 0, .2, 1), background-color .2s, opacity .2s;
}

.tab {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6.5px 8px;
  border: none;
  background: none;
  color: var(--dock-label);
  cursor: pointer;
  transition: color .2s;
}

/* Every tab after the first overlaps its predecessor by 12px — same as
   @the_nfts_bot's own dock. With flex:1 this pulls the row's used width in
   (tabs sit closer together than their own padding box implies), which is
   exactly what moveSelToTab measures off of — the sliding active-pill
   background is sized from each tab's actual rendered rect, so this isn't
   just cosmetic, it's what makes that highlight's width match theirs. */
.tab + .tab {
  margin-left: -12px;
}

.tab--active {
  color: var(--dock-accent);
}

/* Турниры/Подарки still only pop up a "coming soon" sheet on tap — no
   longer dimmed to hint that beforehand (ported dock, all four tabs read
   as equally active, matching Figma). */

.tab__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
}

/* 25x25, all four tabs — ported off Figma's own dock icon spec (Rooms,
   Tournament, Gifs, Profile are all ~25x25 there too). The icon *box*
   (.tab__icon) stays a taller 30px regardless, so every label still sits
   at the same height below it — only the svg inside shrinks, centered by
   the box's own flex centering. */
.tab__icon svg {
  width: 25px;
  height: 25px;
  display: block;
}

.tab__label {
  max-width: 100%;
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Narrow phones — same breakpoint/values as @the_nfts_bot's own dock, so
   tight screens keep the same tab spacing (and the same sliding-pill width
   off of it) they do there. */
@media (max-width: 374px) {
  .tab {
    padding-left: 2px;
    padding-right: 2px;
  }
}

/* Top-up button + deposit bottom sheet */

.topup-btn {
  background: var(--tg-button);
  color: var(--tg-button-text);
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-end;
}

.sheet-overlay.open {
  display: flex;
}

.sheet {
  width: 100%;
  background: var(--tg-secondary-bg);
  border-radius: 28px 28px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
}

/* Ported verbatim from @the_nfts_bot's OWN shipped code (tg.nftshniy.org,
   assets/index-E5g03OrJ.js — the `Dt` row / `jr` badge components under the
   Owners pill's "Open App" gift modal) — every value below (grid ratio,
   padding, font-size/letter-spacing/line-height, colors, badge shape) is
   copied directly from that component's own inline style object, not
   re-derived from a screenshot or a third-party Figma community kit. */
.player-stats-table {
  margin-top: 14px;
  border: 1px solid #dcdce0;
  border-radius: 16px;
  overflow: hidden;
}

.player-stats-row {
  display: grid;
  /* minmax(0, …), not a bare fr: each row is its own independent grid
     container, and a bare fr track still floors at its content's
     min-content width — an unbreakable word like "Поражений" (no spaces to
     wrap on) then forces THAT row's column wider than the others, breaking
     the divider into a zigzag instead of one straight line down the whole
     table. minmax(0, …) removes that content-based floor so every row
     resolves the exact same split regardless of its own text. 1fr/1.3fr
     (not the reference's 0.75fr/2fr) because these labels are Cyrillic
     words (Поражений, Рейтинг) — wider per character than the reference's
     short English labels (Model, Symbol) — while the values here are short
     (numbers, a percent badge), so the split needed to move the other way. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  border-top: 1px solid #dcdce0;
}

.player-stats-row--first {
  border-top: none;
}

.player-stats-row__label,
.player-stats-row__value {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  letter-spacing: -0.31px;
  line-height: 21px;
  color: #000000;
  min-width: 0;
}

.player-stats-row__value {
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.player-stats-row__value > span {
  flex-shrink: 0;
}

.player-stats-row__label {
  /* Solid #efeff0, not rgba(118,118,128,.12) — the_nfts_bot's own code uses
     that rgba, but it only looks right there because THEIR sheet backdrop
     behind it happens to be solid white too. In this app the ancestor
     behind this cell is the live Telegram theme's own secondary-bg (any
     color), so the same rgba composited against it produced a visibly
     different, wrong tint on a real device. Solid = backdrop-independent. */
  background: #efeff0;
  border-right: 1px solid #dcdce0;
}

.player-stats-row__value {
  background: #ffffff;
}

:root[data-theme="dark"] .player-stats-table,
:root[data-theme="dark"] .player-stats-row {
  border-color: #3a3a3e;
}

:root[data-theme="dark"] .player-stats-row__label {
  /* Solid #323236 = rgba(118,118,128,.24) pre-blended over #1c1c1e (this
     row's own --card/value color) — see the comment above the light rule. */
  background: #323236;
  border-right-color: #3a3a3e;
}

:root[data-theme="dark"] .player-stats-row__value {
  background: #1c1c1e;
}

:root[data-theme="dark"] .player-stats-row__label,
:root[data-theme="dark"] .player-stats-row__value {
  color: #ffffff;
}

/* @the_nfts_bot's `jr` component — the inline percentage/link pills (its
   "0,5%", "learn more") — verbatim: background rgba(0,139,255,.1), color
   #008bff, fontSize 12, lineHeight 16px, padding 1px 6px, borderRadius 9,
   same in both themes (no dark-mode override exists for it in their code). */
.player-stats-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 152, 234, 0.1);
  color: #0098ea;
  font-size: 12px;
  line-height: 16px;
  padding: 1px 6px;
  border-radius: 9px;
  letter-spacing: normal;
  white-space: nowrap;
}

.sheet-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
}

/* "Создать игру" modal — ported 1:1 (chrome + animation, not its content)
   from @the_nfts_bot's Owners → Open App sheet (tg.nftshniy.org): the
   slide-up spring, the backdrop fade, and the bottom corner radius that
   matches the actual device's screen corners (via --sheet-bottom-radius,
   computed in app.js — see deviceSheetRadius()). Layered on top of
   .sheet/.sheet-overlay (keeps their padding/list rules), not applied to any
   other sheet in the app. */
.modal-overlay {
  display: flex;
  background: none;
  /* Always display:flex now (not display:none) so the sheet/backdrop can
     transition instead of popping — but that makes this a permanent
     full-viewport box sitting over the whole app. Without this, it swallows
     every click/tap everywhere (the dock, every button) even while visually
     empty and "closed", since pointer-events defaults to auto. .modal-sheet
     and .modal-backdrop explicitly re-enable it for themselves below. */
  pointer-events: none;
}

/* The dimmed scrim fades on its own, separately from the sheet — putting
   opacity on a true ancestor of .modal-sheet instead (as the overlay wrapper
   itself used to be) group-fades every descendant, including the already
   fully-opaque sheet: it would cross-fade in *underneath* its own slide, on
   top of the pure translateY, which reads as the card "materializing"
   mid-air instead of one solid block sliding up/down. .modal-sheet never
   touches opacity — position (on/off screen) is its only state. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.42, 0, 0.58, 1);
}

.modal-overlay.open .modal-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  position: fixed;
  left: 6px;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  pointer-events: auto;
  width: auto;
  max-height: 85vh;
  border-radius: 42px 42px var(--sheet-bottom-radius, 58px) var(--sheet-bottom-radius, 58px);
  padding-top: 78px;
  transform: translateY(calc(100% + 6px));
  transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

/* The negative-Y box-shadow below belongs only to the OPEN sheet. Once
   translateY pushes a closed sheet down by its own height, its top edge
   lands exactly on the viewport's bottom edge — and a box-shadow isn't
   clipped by that transform, so a shadow declared unconditionally on
   .modal-sheet keeps painting 40px of blur bleeding upward INTO the
   visible page the whole time the sheet is closed, under the dock, no
   matter which overlay it belongs to (every .modal-sheet has this, which
   is why it showed up everywhere, in and out of Telegram, light and dark —
   it was never the dock's own shadow). */
.modal-overlay.open .modal-sheet {
  transform: translateY(0);
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
}

/* Same bottom padding + button inset, applied uniformly to every other
   modal sheet in the app that ends in a button — #createRoomSheet above is
   the original; the rest all follow it. */
#playerStatsSheet {
  padding-bottom: max(26px, calc(env(safe-area-inset-bottom) + 10px));
}

#playerStatsCloseBtn2 {
  width: calc(100% - 14px);
  margin-left: 7px;
  margin-right: 7px;
}

#tournamentsPlaceholderLottie,
#giftsPlaceholderLottie {
  margin-bottom: 14px;
}

/* Close (✕) and menu (⋯) — pinned to the sheet's own corners, moving rigidly
   with it as one solid unit. Earlier this used a frosted-glass look
   (translucent layers + backdrop-filter blur) — on WebKit that blur fights a
   fast CSS transform and visibly lags in after the slide settles, instead of
   already being there. Flat, same track color as the segment tabs (white in
   light, that tab-track gray in dark): no blur, no lag, no separate reveal. */
.modal-sheet__close,
.modal-sheet__menu {
  position: absolute;
  top: 16px;
  width: 44px;
  height: 44px;
  z-index: 2;
  border: 0;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  background: var(--segment-track-bg);
  color: var(--tg-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-sheet__close {
  left: 16px;
}

.modal-sheet__menu {
  right: 16px;
}

/* Heart corner button (player-stats modal) liked state — filled red heart,
   same toggle as the "Поставить лайк" button below the table. */
.modal-sheet__menu--liked {
  color: #ff2d55;
}

.modal-sheet__menu--liked svg {
  fill: currentColor;
}

#modeTabs {
  height: 44px;
}

#modeTabs .segment {
  font-size: 15px;
  white-space: nowrap;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dark theme only — the shared --segment-active-bg reads a bit too close to
   the track color here, so just this pill gets a touch more opacity instead
   of changing the token everywhere else that reuses it. */
:root[data-theme="dark"] #modeTabs .segmented__sel {
  background: rgba(118, 118, 128, 0.22);
}

/* Same height/font-size as #modeTabs (PVP/Royal) — Пополнить/Вывести
   otherwise fell back to .segment's own base 20px and a shorter,
   padding-sized height instead of a fixed 44px. */
#balanceTabs {
  height: 44px;
}

#balanceTabs .segment {
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.text-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--tg-text);
  /* 16px, not 15 — iOS Safari/WKWebView auto-zooms the whole page in on
     focus for any input under 16px, regardless of the viewport meta's
     user-scalable=no/maximum-scale=1. That zoom-and-pan is what looked
     like the background (stars, empty-state duck) jumping on focus. */
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.text-input::placeholder {
  color: var(--tg-hint);
}

/* Баланс → Пополнить's amount field — sits left of the text, inside the
   input's own row (not a separate button like .room-name-field's dice
   icon), vertically centered regardless of row height. */
.balance-amount-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* Rounder than the base .list-card (22px) — this card holds just the one
   amount field, not a multi-row list, so it can read softer/pill-like. */
#balanceTabDeposit .list-card,
#balanceTabWithdraw .list-card {
  border-radius: 28px;
}

/* Cell — ported from the TelegramUI kit (telegram-mini-apps-dev/TelegramUI)
   Cell component: before/middle/after slots, same gap/padding logic as its
   --ios variant. Used for every row in Режимы/Комнаты (open rooms, open
   games, the player list inside a match's wait/result sheets). */
.tui-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

/* Комнаты' open-games list rebuilds its whole innerHTML on every 3s poll
   (see renderModesRoomsList) — this marks only the cards that are actually
   new since the last render, so a room that just appeared fades/slides in
   instead of the whole list silently popping between states. */
@keyframes tui-cell-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tui-cell--enter {
  animation: tui-cell-enter 280ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* A room that just closed/filled/got cancelled — fades out in place before
   renderModesRoomsList actually removes it from the list (see
   animateRoomsListOut), instead of it just vanishing the instant the next
   poll notices it's gone. */
@keyframes tui-cell-leave {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}

.tui-cell--leave {
  animation: tui-cell-leave 200ms ease-in both;
  pointer-events: none;
}

/* Inset to where the row's own text starts (16px padding + 36px avatar +
   12px gap) on the left, and the row's 16px padding (where "Войти" ends) on
   the right — instead of a border-bottom, which runs edge to edge across
   the whole card regardless of padding/avatar. Color matches Профиль's own
   .ann-settings-link-row divider exactly, not --tg-separator. */
.tui-cell:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 64px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] .tui-cell:not(:last-child)::after {
  background: rgba(255, 255, 255, 0.08);
}

.tui-cell--compact {
  padding: 10px 16px;
  gap: 10px;
}

/* Avatar with acronym — same treatment as the kit's Avatar.withAcronym:
   secondary-fill circle, link-colored initial, so every room/duel row shows
   *who* it is instead of the same dice emoji repeated down the list. */
.tui-cell__avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.12);
  color: var(--tg-link);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  position: relative;
}

/* Room creator's own Telegram profile photo — same pattern as
   .game-player__avatar-img: overlays the initials acronym already sitting
   underneath, removes itself on load failure so there's never a broken
   image, just the acronym. */
.tui-cell__avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.tui-cell--compact .tui-cell__avatar {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

/* Small mode badge peeking out of the avatar's corner (⚔️ PVP / 👑 Royal) —
   same idea as a Telegram "online" dot. The ring is the card's own
   background color (not the page's), so it reads as a cutout notch in the
   avatar rather than a mismatched outline. */
.tui-cell__mode-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}

.tui-cell__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tui-cell__title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tui-cell__subtitle {
  font-size: 13px;
  color: var(--tg-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Animated 💎 standing in for the word "coins" — sized per modifier to sit
   on each context's own text baseline (room card subtitle / Баланс /
   Royal's create-sheet hint), not one fixed size everywhere. */
.tui-coin-icon {
  display: inline-block;
}

/* Room card subtitle ("Банк N 💎 · name") — 13px text. */
.tui-coin-icon--sm {
  width: 15px;
  height: 15px;
  vertical-align: -3px;
}

/* Баланс (top pill + Профиль's ann-settings-value row) — 17px text. */
.tui-coin-icon--md {
  width: 19px;
  height: 19px;
  vertical-align: -4px;
}

/* Match card title ("PVP · 3 🎲") — stands in for the word
   "броска"/"бросков" next to the roll-count number, same static dice emoji
   as the animated one in the "Проверка броска" sheet (custom_emoji_id
   5388644605841387896), just its still thumbnail instead of the Lottie. */
.tui-dice-emoji {
  display: inline-block;
  width: 15px;
  height: 15px;
  vertical-align: -3px;
}

/* The lottie player's own drawn content sits slightly low within its box —
   flex centering (Баланс page's two balance values) lines up the boxes
   correctly, but the icon still visibly reads a couple px low next to the
   digits, so nudge it up directly on top of that. */
#balanceWalletTon .tui-coin-icon,
#balanceBotCoins .tui-coin-icon {
  position: relative;
  top: -2px;
}

/* Same divider color as Профиль's own row dividers (.ann-settings-row), not
   --tg-separator. */
#balanceDivider {
  background: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] #balanceDivider {
  background: rgba(255, 255, 255, 0.08);
}

/* Royal's create-sheet hint ("Банк N 💎, победитель заберёт…") — 12px
   .hint-text. */
.tui-coin-icon--xs {
  width: 14px;
  height: 14px;
  vertical-align: -3px;
}

.tui-cell__trailing {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Placeholder — ported from the kit's Placeholder: centered icon + title +
   description, used wherever a list has nothing to show instead of one line
   of gray text. */
.tui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 36px 24px;
}

/* Комнаты page heading — ported from Figma node 1:30. */
.modes-page-title {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
  color: #ffffff;
}

/* Комнаты' own empty-state title/desc — ported from Figma nodes 1:29/1:31,
   scoped to this one page (not .tui-empty's own defaults, shared with other
   empty states app-wide — e.g. empty transaction history — that this isn't
   meant to touch). */
#page-modes .tui-empty__title {
  font-size: 20px;
  font-weight: 700;
  line-height: 26px;
  color: #ffffff;
}

#page-modes .tui-empty__desc {
  font-size: 16px;
  font-weight: 300;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.5);
  max-width: 260px;
}

/* Yellow CTA — ported from Figma nodes 1:73/1:74. No click handler yet
   (see app.js) — purely the port's visual piece for now. */
.modes-empty-create-btn {
  margin-top: 6px;
  width: 216px;
  height: 54px;
  border: none;
  border-radius: 100px;
  background: #efc319;
  color: #000000;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
  cursor: pointer;
}

/* Новая комната — ported 1:1 off Figma node 18:172. */
/* «Новая комната» — модалка (как «Победитель»): затемнение + центр. Высота от
   --app-h (не от живого вьюпорта), чтобы клавиатура не пересаживала карточку. */
.create-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-h, 100vh);
  z-index: 30; /* над доком (20), под «Победителем» (40) */
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.create-modal.open {
  display: flex;
}

.create-modal .create-card {
  width: 88%;
  max-width: 409px;
  margin: 0;
}

.create-card {
  padding: 20px 20px 24px;
  margin-bottom: 20px;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}

.create-card__label {
  margin: 24px 0 10px;
  font-size: 12px;
  color: #ffffff;
  text-align: center;
}

/* Child combinator, not a bare :first-child — "Количество игроков" is also
   its own parent's (#matchPlayersBlock) first child, so the bare selector
   zeroed its top margin too, leaving it stuck straight to Дуэль/Арена with
   no gap. Scoping to direct children of .create-card means only "Режим
   игры" (the actual first label in the card) matches. */
.create-card > .create-card__label:first-child {
  margin-top: 0;
}

/* Two independent pills, not the shared .segmented sliding-highlight
   mechanism — Figma's own Дуэль/Арена are each their own bordered button
   (87x41/88x41), not one evenly-flexed shared track, so this skips
   positionSegSel entirely (see selectCreateMode in app.js) and just
   toggles each button's own background directly. */
.create-mode-toggle {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.create-mode-btn {
  padding: 10px 20px;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 100px;
  background: #260102;
  color: #ffffff;
  font-size: 14px;
  font-weight: 510;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
  cursor: pointer;
}

.create-mode-btn.active {
  background: #efc319;
  color: #260102;
  box-shadow: 0 0 7.5px rgba(255, 212, 0, 0.3), 0 0 10px rgba(255, 212, 0, 0.15);
}

.create-players-row .coef-chip {
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
}

.create-players-row .coef-chip.active {
  background: #efc319;
  color: #260102;
  box-shadow: 0 0 7.5px rgba(255, 212, 0, 0.3), 0 0 10px rgba(255, 212, 0, 0.15);
}

.create-bet-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.create-bet-display svg {
  flex: none;
}

.create-bet-value {
  width: auto;
  max-width: 160px;
  padding: 0;
  border: none;
  outline: none;
  box-shadow: none;
  background: none;
  color: #ffffff;
  font-size: 60px;
  font-weight: 700;
  /* Ширину по тексту задаёт JS (fitRoomBetInput); сам текст — по центру поля. */
  text-align: center;
  -moz-appearance: textfield;
}

.create-bet-value:focus {
  outline: none;
  box-shadow: none;
}

.create-bet-value::-webkit-outer-spin-button,
.create-bet-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.create-bet-divider {
  width: 194px;
  height: 1px;
  margin: 10px auto 16px;
  /* Figma «Line 34»: жёлтый #FFCB00, 50%, затухает к краям (0% / 22% / 75% / 100%) */
  background: linear-gradient(90deg, rgba(255, 203, 0, 0) 0%, rgba(255, 203, 0, 0.5) 22%, rgba(255, 203, 0, 0.5) 75%, rgba(255, 203, 0, 0) 100%);
}

.create-bet-chips {
  display: flex;
  gap: 12px;
}

.create-bet-chip {
  flex: 1;
  padding: 10px 0;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 100px;
  background: #260102;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
  cursor: pointer;
}

.create-submit-btn {
  display: block;
  margin: 24px auto 0;
}

.tui-empty__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(118, 118, 128, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

/* Комнаты' empty state only — same 110px footprint the old duck lottie
   had, but a bare emoji glyph, no background chip, same treatment as the
   app's other large dice emoji (.result-emoji). */
.tui-empty__emoji {
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  line-height: 1;
}

/* Комнаты' empty state — no card box, centered in the full page height via
   justify-content:center. Комнаты normally has the toolbar in flow above
   the list, which would throw that centering off, so the toolbar is taken
   out of flow (position:absolute, same technique as #modeTabs elsewhere in
   this file) only while the page is actually empty — the toolbar's own
   static-flow position (and #modesOpenSection's normal margin) is untouched
   whenever rooms-empty isn't set, so the non-empty list layout stays exactly
   as it was. */
#page-modes.active {
  position: relative;
  display: flex;
  flex-direction: column;
  /* var(--app-h), not a raw 100vh: 100vh tracks the live (keyboard-shrunk)
     viewport, so centering off it re-centers this whenever the keyboard
     opens anywhere in the app. */
  min-height: calc(var(--app-h, 100vh) - 16px - var(--dock-h));
}

#page-modes.rooms-empty .rooms-toolbar {
  position: absolute;
  top: 50px;
  left: 16px;
  right: 16px;
  margin: 0;
}

/* Search/filters/online-badge/"+" only make sense once at least one game
   is actually open — while the list is genuinely empty (not just "no
   matches for this filter", which keeps the header so the filter can be
   changed) this goes back to the plain centered "Комнаты" + illustration
   look from before the Figma redesign. */
#page-modes.rooms-empty .modes-title-row {
  justify-content: center;
}

#page-modes.rooms-empty .modes-page-title--rooms {
  text-align: center;
}

#page-modes.rooms-empty .modes-online-badge,
#page-modes.rooms-empty .modes-create-btn,
#page-modes.rooms-empty .modes-search,
#page-modes.rooms-empty .modes-filter-row {
  display: none;
}

html[data-platform="desktop"] #page-modes.rooms-empty .rooms-toolbar {
  top: 0;
}

#page-modes.rooms-empty {
  justify-content: center;
}

/* Nudge "ОТКРЫТЫЕ ИГРЫ" right relative to the room-card below it, same offset
   Профиль's "Аккаунт" label has from its pg-card (pg-section__header's 16px
   left padding vs pg-card's flush-left edge) — .section-header's shared 4px
   default stays untouched everywhere else that reuses the class. */
#modesOpenSection .section-header {
  padding-left: 16px;
}

#page-modes.rooms-empty #modesOpenSection {
  /* .section's own 12px bottom margin would otherwise count toward the flex
     item's margin box and throw justify-content:center off-center by half
     of it (6px) — zero out both margins so this centers exactly like
     Турниры's unmarginated .tui-empty does. */
  margin: 0;
}

#modesRoomsList[data-state="empty-rooms"] {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.tui-empty__title {
  font-size: 15px;
  font-weight: 600;
}

.tui-empty__desc {
  font-size: 13px;
  color: var(--tg-hint);
  line-height: 1.4;
  max-width: 230px;
}

.result-lottie {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  display: none;
}

.result-lottie.active {
  display: block;
}

/* Bet input row */

.bet-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bet-input {
  flex: 1;
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.bet-input::-webkit-outer-spin-button,
.bet-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.max-btn {
  flex: none;
  background: var(--tg-button);
  color: var(--tg-button-text);
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  /* Row padding is 12px top / 16px right — nudge right by the 4px
     difference so the button sits the same distance from both edges. */
  margin-right: -4px;
}

/* Coefficient chips */

.coef-row {
  display: flex;
  gap: 6px;
}

.coef-chip {
  flex: 1;
  min-width: 0;
  background: rgba(118, 118, 128, 0.12);
  border: none;
  color: var(--tg-text);
  padding: 10px 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.coef-chip.active {
  background: var(--tg-button);
  color: var(--tg-button-text);
}

/* "Создать игру" sheet only — bet presets and format chips at the same 44px
   row height as the ✕/PVP-На вылет/? row and the room-name field above them. */
#targetTabs .coef-chip,
#matchPlayersTabs .coef-chip {
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* "1 бросок"/"3 броска"/"5 бросков" run noticeably longer than the old
   "Бо1"/"Бо3"/"Бо5" labels — keep each on one line instead of wrapping
   inside its pill. */
#targetTabs .coef-chip {
  font-size: 13px;
  white-space: nowrap;
  padding: 0 2px;
}

/* Bottom-sheet overlays reuse page-level blocks (.stage-card, .list-card) but
   the sheet itself already has 16px horizontal padding — stop those blocks
   from adding their own margin on top of it, and always leave breathing room
   before whatever follows (another block or the sheet's closing button). */
.sheet .stage-card {
  margin-left: 0;
  margin-right: 0;
}

.sheet .list-card {
  margin-bottom: 14px;
}

/* Button hierarchy — ported from nftshniy's Fill/Bezeled set. .play-btn stays
   Fill (primary, solid) by default; .play-btn--secondary is Bezeled (tinted,
   low-emphasis) for dismissive actions like "Закрыть"/"Отменить" that sit
   alone in a sheet, so the one actually-proactive action on screen keeps the
   strongest visual weight. */
.play-btn--secondary {
  background: rgba(0, 122, 255, 0.12);
  color: var(--tg-link);
}

:root[data-theme="dark"] .play-btn--secondary {
  background: rgba(10, 132, 255, 0.18);
}

/* История now reuses Комнаты's own .tui-cell row (same 36px avatar, same
   mode badge, same inset divider) instead of its own bespoke 28px-avatar
   row — only the trailing slot differs (amount + status, stacked and
   right-aligned, instead of a badge + "Войти" button). */
.history-row--checkable {
  cursor: pointer;
}

.history-cell__trailing {
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
}

.history-row__amount {
  font-size: 15px;
  font-weight: 600;
}

.history-row__amount.win { color: var(--win); }
.history-row__amount.lose { color: var(--tg-text); }

.history-row__status {
  font-size: 12px;
  color: var(--tg-hint);
  margin-top: 1px;
}

/* Select field — ported from nftshniy's Playground SELECT control: a rounded
   list-card row with a native <select> and a chevron, used wherever a range
   of choices is too wide for a stepper (e.g. up to 24 tournament players). */

/* Комнаты toolbar — round filter/create buttons, sitting above the
   open-games list on the same page. Pushed down (margin-top) to clear the
   fullscreen status-bar/notch area on phones — desktop/web never goes
   fullscreen (see app.js), so the override below keeps it near the top
   there, same as before fullscreen existed. */
.rooms-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  /* 18px — the actual gap between Figma's Balance pill and Avatar nodes
     (left:405 minus the pill's own right edge at 252+135=387). */
  gap: 18px;
  margin: 50px 16px 12px;
}

html[data-platform="desktop"] .rooms-toolbar {
  margin-top: 0;
}

/* Balance pill + Avatar — ported from Figma nodes 1:75/1:85. */
.modes-balance-pill {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 46px;
  padding: 10px 18px;
  border: none;
  border-radius: 100px;
  background: #2d0000;
  cursor: pointer;
}

.modes-balance-pill__ton {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modes-balance-pill__ton svg {
  display: block;
  flex: none;
}

.modes-balance-pill__sum {
  font-size: 14px;
  font-weight: 700;
  line-height: 17px;
  color: #ffffff;
  white-space: nowrap;
}

.modes-balance-pill__divider {
  flex: none;
  width: 1px;
  height: 26px;
  background: rgba(255, 203, 0, 0.5);
}

.modes-balance-pill__plus {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 9px #ffd500);
}

.modes-avatar-btn {
  flex: none;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #efc319;
  border-radius: 100px;
  background: none;
  cursor: pointer;
  /* box-shadow вместо filter:drop-shadow — filter создаёт отдельный композитный слой, который
     на iOS мигал/подсвечивался рамкой при нажатии на соседнюю кнопку (пилюлю баланса). */
  box-shadow: 0 4px 10px rgba(255, 213, 0, 0.35);
}

.modes-avatar-btn__img {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  object-fit: cover;
  border: 4px solid #330002;
  border-radius: 29.5px;
}

.sel-menu__item--active {
  color: var(--tg-link);
  font-weight: 600;
}

.pg-section {
  display: flex;
  flex-direction: column;
}

/* A pg-section used standalone on a page (not nested in a .pg-list, which
   already supplies its own 16px side padding + 12px inter-section gap) needs
   that same spacing applied directly. */
.page > .pg-section {
  margin: 0 16px 12px;
}

.pg-section__header {
  height: 40px;
  padding: 16px 16px 8px;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 16px;
  text-transform: uppercase;
  color: var(--tg-hint);
}

/* Floating dropdown menu — ported from nftshniy's "SELECT" control on
   web.nftshniy.org/Playground: a rounded floating panel, no dividers, each
   row a plain text button. */
.sel-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
}

.sel-menu-overlay.open {
  display: block;
}

.sel-menu {
  position: absolute;
  min-width: 160px;
  background: var(--tg-section-bg);
  border-radius: 20px;
  box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.05), 0 32px 64px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.sel-menu__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  line-height: 22px;
  color: var(--tg-text);
  background: transparent;
  border: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

/* Inset divider (16px from each edge, same as .tui-cell's own row divider)
   instead of a full-bleed border — leaves breathing room from the menu's
   rounded corners. */
.sel-menu__item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] .sel-menu__item:not(:last-child)::after {
  background: rgba(255, 255, 255, 0.08);
}

/* Reserves its own width always (even hidden) so the label doesn't shift
   left/right when the checkmark appears/disappears on the active item. */
.sel-menu__check {
  flex: none;
  width: 16px;
  color: var(--tg-link);
  opacity: 0;
}

.sel-menu__item--active .sel-menu__check {
  opacity: 1;
}

.sel-menu__item--danger {
  color: var(--lose);
}

/* Switch — their demo only ever renders the "on" state (a static div with
   the knob pinned right); this adds the real off state so it can work as an
   actual toggle, using the same 51×31/27×27 sizing and shadow. */
.pg-switch {
  flex: none;
  position: relative;
  width: 51px;
  height: 31px;
  border-radius: 100px;
  background: rgba(118, 118, 128, 0.32);
  transition: background 0.2s;
}

.pg-switch__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.pg-switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 100px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: left 0.2s;
}

.pg-switch:has(.pg-switch__input:checked) {
  background: var(--tg-link);
}

.pg-switch:has(.pg-switch__input:checked) .pg-switch__knob {
  left: 22px;
}

/* Ported 1:1 (style + content — content gets swapped for real cube-bot
   settings later) from nftshniy.ru's own "Основные настройки" panel,
   opened by tapping the account avatar there — see
   /var/www/anonned.ru/nftshniy-search.html (#ann-settings-panel) on
   31.56.39.235. Classes keep their ann- prefix from the source rather than
   being renamed, so this stays a straightforward diff against the original
   if it's ever re-synced. Position/sizing is adapted to live inside this
   app's own #page-ann-settings .page instead of being its own
   absolutely-positioned full-screen overlay. */
/* Rescaled to this app's own type scale (17px row text, 28px row icons,
   13px hint/footer text — see .pg-row__title/.pg-row__icon/
   .pg-section__footer) instead of the source site's own, noticeably
   bigger one (22-23px text, 36px icons) — ported 1:1 verbatim at first,
   but next to the rest of the app it read as oversized. */
#ann-settings-panel {
  padding: 16px 16px 24px;
}

.ann-settings-group {
  /* Live Telegram theme token (same one .balance-card and everything else
     in the app already uses) instead of our own hardcoded light/dark
     colors gated behind the data-theme attribute — that JS-driven switch
     wasn't firing reliably (cards were rendering fully transparent,
     blending into the page backdrop instead of standing out as their own
     card, per a user-reported Telegram Desktop screenshot), while
     var(--tg-section-bg) tracks Telegram's actual live color directly and
     needs no JS state to get right. */
  background: var(--tg-section-bg);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
}
.ann-settings-styled-group,
#ann-settings-main-group { border-radius: 25px; }

/* Gap between the ported Wallet/bot header and the first settings card —
   used to be the "Основные настройки" title's own margin-bottom, which
   doubled as this spacing; removing that title element collapsed the gap
   along with it, so it's restored here directly instead. */
#ann-settings-main-group { margin-top: 28px; }

.ann-settings-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
}

.ann-settings-row:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 54px;
  right: 16px;
  bottom: 0;
  height: 1px;
}

:root[data-theme="dark"] .ann-settings-row:not(:last-child)::after { background: rgba(255, 255, 255, .08); }
:root[data-theme="light"] .ann-settings-row:not(:last-child)::after { background: rgba(0, 0, 0, .08); }
/* 62px = 16 (row padding-left) + -1 (icon's own margin-left) + 32 (icon
   width) + 10 (row gap) + 5 (label's own margin-left) — the exact point
   the label text itself starts at with the current icon size/offsets. */
#ann-settings-main-group .ann-settings-row:not(:last-child)::after,
.ann-settings-styled-group .ann-settings-row:not(:last-child)::after { left: 62px; }

.ann-settings-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: Inter, system-ui, sans-serif;
  /* Thin inset stroke, the way iOS's own app icons get a subtle edge
     highlight on top of a flat color fill — box-shadow (not border) so it
     doesn't add to the icon's box size or push the label over. */
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.35);
}

.ann-settings-icon svg { width: 20px; height: 20px; display: block; }

.ann-settings-styled-group .ann-settings-icon,
#ann-settings-main-group .ann-settings-icon { margin-left: -1px; }

.ann-settings-label {
  flex: 1;
  font-size: 15px;
  font-family: Inter, system-ui, sans-serif;
  color: var(--tg-text);
}

.ann-settings-value {
  font-size: 15px;
  font-family: Inter, system-ui, sans-serif;
  color: #8a8a8a;
}

.ann-settings-chevron {
  flex: none;
  color: #8a8a8a;
  display: flex;
  align-items: center;
}

.ann-settings-copy-btn {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  color: var(--tg-link);
  cursor: pointer;
}

:root[data-theme="light"] .ann-settings-chevron { color: #CBCBCB; }

.ann-settings-helper {
  margin: -10px 4px 20px 20px;
  font-size: 13px;
  line-height: 17px;
  color: #8a8a8a;
  font-family: Inter, system-ui, sans-serif;
}

.profile-hero-avatar-wrap { position: relative; width: 95px; height: 95px; }
.profile-hero-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 180px;
  height: 180px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ===== Комнаты — Rooms list redesign (Figma node 23:1420) ===== */

.modes-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 16px;
}

.modes-page-title.modes-page-title--rooms {
  margin: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modes-online-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
}

.modes-online-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #efc319;
}

.modes-create-btn {
  flex: none;
  width: 39px;
  height: 39px;
  border: none;
  border-radius: 50%;
  background: #efc319;
  color: #260102;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.3);
  cursor: pointer;
}

.modes-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 12px;
  margin: 0 16px 16px;
  border-bottom: 1px solid rgba(255, 245, 200, 0.15);
}

.modes-search__icon {
  flex: none;
  color: rgba(255, 255, 255, 0.4);
}

.modes-search__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  color: #ffffff;
  font-size: 17px;
  font-weight: 300;
}

.modes-search__input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.modes-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 20px;
  overflow-x: auto;
}

.modes-filter-chip {
  flex: none;
  white-space: nowrap;
}

.modes-sort-btn {
  flex: none;
  width: 44px;
  height: 41px;
  padding: 0;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 100px;
  background: #260102;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
  cursor: pointer;
}

/* The open-games card itself — same glowing-red-card treatment as
   .create-card on "Новая комната" (Figma uses the one card spec
   everywhere), applied here via the ID so .list-card's plain theme
   defaults stay untouched for every other list in the app. */
#modesRoomsList {
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}

/* Bigger, glow-ringed avatar (Figma: 51px, 4px #330002 border) just for
   room/match rows — .tui-cell__avatar's own 36px default stays untouched
   for История/Баланс/player-list rows that share the same base class. */
#modesRoomsList .tui-cell__avatar {
  width: 51px;
  height: 51px;
  font-size: 18px;
  border: 4px solid #330002;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
}

/* Divider inset follows the bigger avatar (16px pad + 51px avatar + 12px
   gap), same idea as .tui-cell's own 64px default for the 36px avatar. */
#modesRoomsList .tui-cell:not(:last-child)::after {
  left: 79px;
}

/* No mode-badge overlay here (Figma conveys mode via the subtitle text,
   not a corner emoji) — scoped so История/player-list rows keep theirs. */
#modesRoomsList .tui-cell__mode-badge {
  display: none;
}

.room-price {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.room-price__icon {
  flex: none;
}

/* ===== Game_duel — room-duel game screen redesign (Figma node 1:196) =====
   Scoped entirely under .page-game--duel (kind==="room" only, see
   renderGameScreen) — Royal/Бо3/Бо5 matches keep the original
   .page-game--circle layout untouched below this block. */

.game-toolbar,
.game-duel-header,
.game-bank-pill__label,
.game-duel-table,
.game-duel-status {
  display: none;
}

.page-game--duel .game-toolbar {
  display: flex;
}

.page-game--duel .game-duel-header {
  display: block;
  text-align: center;
  margin: 0 16px 16px;
}

.game-duel-title {
  margin: 0 0 4px;
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
}

.game-duel-subtitle {
  font-size: 16px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.5);
}

.page-game--duel #gameTicker {
  display: none;
}

.page-game--duel .game-top-row {
  justify-content: center;
  margin: 0 16px 20px;
}

.page-game--duel .game-bank-pill {
  height: 43px;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}

/* Figma's own 163x43 pill (node 2:579) breaks down to: 26px left pad,
   label, 13px gap, 22x18 icon, 6px gap, number, 19px right pad — kept as
   padding/gaps rather than the literal 163px width so a longer bet number
   still fits instead of clipping (same reasoning the base .game-bank-pill
   rule already gives for staying width:auto). */
.page-game--duel .game-bank-pill .list-row {
  padding: 0 19px 0 26px;
  gap: 13px;
}

.page-game--duel .game-bank-pill__icon {
  width: 22px;
  height: 18px;
  margin-right: -7px;
}

.page-game--duel .game-bank-pill__label {
  display: inline;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.page-game--duel #gameStage {
  margin: 0;
  background: none;
  border-radius: 0;
  padding: 0;
  text-align: initial;
}

/* Burgundy table ring (Table.json, exported as a still PNG — it's a single
   frame, not animated, so a plain <img> gets the same result without a
   lottie renderer). Normal-flow block, not absolutely positioned — its
   rendered height becomes .game-players' own height (position:relative
   below), which is what every percentage position in this block is
   relative to. 101.24%/-0.62% = Figma's own 491px ring on a 485px frame,
   kept as a ratio instead of literal px so it scales to any phone width. */
.page-game--duel .game-duel-table {
  display: block;
  width: 101.24%;
  margin-left: -0.62%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.page-game--duel .game-players {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  flex-wrap: nowrap;
}

.page-game--duel #gamePlayersInner .game-player {
  position: absolute;
  width: auto;
  margin: 0;
  gap: 4px;
}

/* Opponent (or the empty waiting seat) — top-right, per Figma node 2:586
   (seat X259 W175 → center 346.5/485 = 71.4%). */
.page-game--duel #gamePlayersInner .game-player:nth-child(1) {
  left: 71.4%;
  top: 6.1%;
  width: 14.9%;
  transform: translateX(-50%);
}

/* You — bottom-center, bigger avatar, per Figma node 2:596. Always last in
   gamePlayersList() for kind==="room", so this is always your own seat. */
.page-game--duel #gamePlayersInner .game-player:nth-child(2) {
  left: 50%;
  top: 73.7%;
  width: 20.6%;
  transform: translateX(-50%);
}

.page-game--duel .game-player__avatar {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  box-sizing: border-box;
}

/* Dark ring — skipped for an empty seat, which keeps its own dashed
   placeholder border (.game-player--waiting) instead. */
.page-game--duel .game-player:not(.game-player--waiting) .game-player__avatar {
  border: 4px solid #330002;
}

/* Gold identity ring — you only, same token as every other "this is you"
   avatar in the app (.modes-avatar-btn). A box-shadow ring, not a second
   border, so it still clips to the circle correctly. */
.page-game--duel #gamePlayersInner .game-player:nth-child(2) .game-player__avatar {
  box-shadow: 0 0 0 1px #efc319, 0 4px 10px rgba(255, 213, 0, 0.35);
}

.page-game--duel #gamePlayersInner .game-player:nth-child(1) .game-player__avatar {
  font-size: 22px;
}

.page-game--duel #gamePlayersInner .game-player:nth-child(2) .game-player__avatar {
  font-size: 30px;
}

.page-game--duel .game-player__name {
  margin-top: 2px;
  /* 14px по запросу 2026-11-13 (было фигмовские 16) — вместе с ареной */
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.page-game--duel #gamePlayersInner .game-player:nth-child(2) .game-player__name {
  font-size: 22px;
}

.page-game--duel .game-player__status {
  display: none;
}

/* Center dice — Figma node 1:235, percentages off the same .game-players
   box the table ring/avatars use. The Dice-loader/Dice-result-N-glow
   lotties (assets/lottie/dice/) already bake their own glow in, no extra
   box-shadow needed here. */
/* Центр ВИДИМОГО кубика в кадрах Game_arena/Game_duel — на 45% высоты
   стола, не в геометрическом центре (померено флуд-филлом по пикселям
   кадра 1:447: видимый куб 91×99px с центром на 45.0%, прежние 37% были
   центром 190px-бокса вместе с несимметричным свечением). Ширина 20% ≈
   фигмовские 18.7% видимого куба. Запрошено пользователем 2026-11-13
   («как на экране Арена») — вернув кубик выше, статус-текст вернулся на
   фигмовские 59.5% и перестал липнуть к нижней аватарке. */
.page-game--duel .game-circle-dice-slot {
  left: 50%;
  top: 45%;
  width: 20%;
  transform: translate(-50%, -50%);
}

.page-game--duel .game-circle-dice-slot .stage-card {
  padding: 0;
}

/* .game-roll-visual's own 120px is a fixed footprint sized for the other
   (non-duel) dice contexts that reuse #gameRollStage — here the slot is a
   percentage width (28% of the table), so a fixed px height stopped it
   being square and threw the dice off the slot's own true center (flex
   centering only centers within ITS box, which .game-circle-dice-slot's
   top/left already center on the table — a non-square box there just
   moves the visual middle of the square image inside it). auto lets it
   track the same width-driven aspect-ratio:1 the image itself uses. */
.page-game--duel .game-roll-visual {
  height: auto;
}

/* Figma's own dice (node 1:235) is a single static image, not an
   animation — #gameRollEmoji already shows/hides itself exactly when
   needed (visible by default, hidden the moment an actual roll's lottie
   plays — see playDiceLottieIn), so this just swaps what it displays
   while idle instead of adding any new show/hide logic of its own. */
.page-game--duel .result-emoji {
  width: 100%;
  aspect-ratio: 1;
  font-size: 0;
  /* -v2 filename, not a query string — this asset has no
     app.js/style.css-style BUILD_VERSION cache-busting of its own, and
     Cache-Control: max-age=86400 on it means any in-place content swap
     under the same name stays stale in a client's cache for up to a day
     (this bit a real user once already — see cube.md). Bump the suffix
     again next time this specific file's content changes. */
  background-image: url('assets/dice-idle-static-v2.webp');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  /* Same drop-shadow Figma applies to this frame (node 1:235) — a plain
     box-shadow, not baked into the image, so it stays crisp at any size. */
  filter: drop-shadow(0px 8px 10px rgba(0, 0, 0, 0.5)) drop-shadow(0px 0px 40px rgba(255, 212, 0, 0.5));
}

/* "Ваш ход"/"Ходит Имя" (Figma node 1:248) — mirrors #gameTickerText, see
   setGameTicker(). */
.page-game--duel .game-duel-status {
  display: block;
  position: absolute;
  left: 50%;
  top: 59.5%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 700;
  color: #efc319;
  white-space: nowrap;
}

/* Every action-bar button in duel mode uses the same gold/dark pair as the
   rest of this redesign (.create-mode-btn etc.), not Telegram's stock
   blue/green/red — Готов and "Бросить кубик" are both the one primary gold
   action, Отменить/the ready-countdown digit are the secondary dark pill.
   .game-actionbar is a sibling of #page-game, not a descendant (stands in
   for the dock outside the page stack) — renderGameScreen toggles this
   same class on it directly, see app.js. */
.game-actionbar.page-game--duel .play-btn {
  flex: none;
  width: 216px;
  max-width: 90%;
  margin: 0 auto;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
}

.game-actionbar.page-game--duel .play-btn:not(.play-btn--red):not(.play-btn--secondary) {
  background: #efc319;
  color: #000000;
}

.game-actionbar.page-game--duel .play-btn--red,
.game-actionbar.page-game--duel .play-btn--secondary {
  background: #260102;
  color: #ffffff;
  border: 2px solid rgba(255, 245, 200, 0.15);
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
}

/* Figma shows exactly one button, always — "Отменить"/the ready-countdown
   digit (#gameReadyTimer) is dropped entirely, not just restyled, same as
   duel. It was never the only way to cancel anyway: Telegram's own system
   Back button already does the exact same server cancel for both rooms
   and matches (see handleSystemBack in app.js), so nothing is actually
   lost. !important because updateGameActionBar sets this element's
   display inline on every render. */
.game-actionbar.page-game--duel #gameReadyTimer,
.game-actionbar.page-game--circle #gameReadyTimer {
  display: none !important;
}

.page-game--duel .game-bank-pill #gameBankPillText {
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
}

/* ===== Game_arena — Royal/Бо3/Бо5 match screen redesign (Figma node
   1:258) ===== Scoped entirely under .page-game--circle (kind !== "room",
   see renderGameScreen) — shares the toolbar/header/bank-pill/table/dice
   chrome with the Game_duel block above (same values, reused as-is where
   Figma's own measurements came out identical), differs only in how
   players sit around the table: a variable-size ring of opponents (see
   positionCirclePlayers in app.js) plus one fixed "me" seat at the
   bottom, instead of two fixed duel slots. */

.page-game--circle .game-toolbar {
  display: flex;
}

.page-game--circle .game-duel-header {
  display: block;
  text-align: center;
  margin: 0 16px 16px;
}

.page-game--circle #gameTicker {
  display: none;
}

.page-game--circle .game-top-row {
  justify-content: center;
  margin: 0 16px 20px;
}

.page-game--circle .game-bank-pill {
  height: 43px;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}

.page-game--circle .game-bank-pill .list-row {
  padding: 0 19px 0 26px;
  gap: 13px;
}

.page-game--circle .game-bank-pill__icon {
  width: 22px;
  height: 18px;
  margin-right: -7px;
}

.page-game--circle .game-bank-pill__label {
  display: inline;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

/* Cancels the old plain-circle screen's own centering (#page-game.active
   .page-game--circle above) — that rule stretches #page-game to fill the
   leftover height below the header and centers #gameStage inside it,
   which made sense when the circle had no table image and was free-
   floating. Now that this screen has the same table image as Game_duel,
   that same centering just floats the table at an inconsistent height
   instead of sitting right under the header like Game_duel's own
   (static, non-flex) layout — same selector, so same specificity,
   override wins by appearing later in the file. */
#page-game.active.page-game--circle {
  display: block;
  min-height: 0;
}

#page-game.active.page-game--circle #gameStage {
  flex: initial;
  display: block;
  align-items: initial;
  justify-content: initial;
}

/* Same burgundy table ring image as Game_duel, same ratio (Figma's own
   491px ring on this screen's identical 485px frame). */
.page-game--circle .game-duel-table {
  display: block;
  width: 101.24%;
  margin-left: -0.62%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.page-game--circle .game-players {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  flex-wrap: nowrap;
}

/* Seats sit AROUND the table oval, 1:1 with Figma Game_arena (1:447/1:258),
   not in one row: the 4-opponent frame places two seats on the top arc
   (centers 32.9%/71.4%, top 6.1% — seat Y256 vs table Y226 H491) and two on
   the sides lower down (centers 11.86%/90.2%, top 26.1% — seat Y354).
   Counts Figma doesn't draw (1-3, 5-7) keep those measured anchor points
   and, for 6-7, add intermediate pairs on the same ellipse the four
   anchors lie on (a=41.9% b=40.1% around the table center — derived from
   the two measured anchor pairs, not invented).
   ponytail: 5-7-opponent spots are an extrapolation along that ellipse —
   if the designer ever draws real frames for them, re-measure.
   14.9% seat width = 72px opponent avatar on the 485px frame. Each count
   below (positionCirclePlayers sets data-opponents) gives nth-child(1..N)
   its own left/top, ordered left-to-right.
   ВАЖНО: каждое правило скоуплено под .page-game--circle — data-opponents
   ставится и на дуэли, и без префикса правило "1 соперник → left 50%"
   по равной специфичности (но ниже в файле) перебивало duel-овское
   71.4%, из-за чего соперник на Дуэли стоял по центру (реальный баг,
   замеченный пользователем 2026-11-13). */
.page-game--circle #gamePlayersInner .game-player {
  position: absolute;
  left: 50%;
  top: 6.1%;
  width: 14.9%;
  margin: 0;
  gap: 4px;
  /* translateX only, like both of Game_duel's own seats — top is the
     wrapper's TOP edge, not its center (see Game_duel's identical rule). */
  transform: translateX(-50%);
}

/* 1 opponent (Бо3/Бо5 to-2) — top center. */
.page-game--circle #gamePlayersInner[data-opponents="1"] .game-player:nth-child(1) { left: 50%; }

/* 2 — the Figma top-arc pair. */
.page-game--circle #gamePlayersInner[data-opponents="2"] .game-player:nth-child(1) { left: 32.9%; }
.page-game--circle #gamePlayersInner[data-opponents="2"] .game-player:nth-child(2) { left: 71.4%; }

/* 3 — top center + the Figma side pair. */
.page-game--circle #gamePlayersInner[data-opponents="3"] .game-player:nth-child(1) { left: 11.86%; top: 26.1%; }
.page-game--circle #gamePlayersInner[data-opponents="3"] .game-player:nth-child(2) { left: 50%; }
.page-game--circle #gamePlayersInner[data-opponents="3"] .game-player:nth-child(3) { left: 90.2%; top: 26.1%; }

/* 4 — the exact Figma Game_arena layout. */
.page-game--circle #gamePlayersInner[data-opponents="4"] .game-player:nth-child(1) { left: 11.86%; top: 26.1%; }
.page-game--circle #gamePlayersInner[data-opponents="4"] .game-player:nth-child(2) { left: 32.9%; }
.page-game--circle #gamePlayersInner[data-opponents="4"] .game-player:nth-child(3) { left: 71.4%; }
.page-game--circle #gamePlayersInner[data-opponents="4"] .game-player:nth-child(4) { left: 90.2%; top: 26.1%; }

/* 5-7 соперников — равные угловые шаги по тому же эллипсу якорей
   (a≈41.9%, b≈40.1%, центр y 49.9%), дуга растянута на все ±90° —
   крайние места на горизонтальной середине овала («сделай расстояние
   ещё побольше», 2026-11-13): 5 мест — 0°/±45°/±90° (хорда ~31%),
   6 — ±18°/±54°/±90° (~25%), 7 — 0°/±30°/±60°/±90° (~21%). Аватар
   14.9% — зазор между соседями ~6-16%. */
.page-game--circle #gamePlayersInner[data-opponents="5"] .game-player:nth-child(1) { left: 8.1%; top: 42.45%; }
.page-game--circle #gamePlayersInner[data-opponents="5"] .game-player:nth-child(2) { left: 20.4%; top: 14.1%; }
.page-game--circle #gamePlayersInner[data-opponents="5"] .game-player:nth-child(3) { left: 50%; top: 2.4%; }
.page-game--circle #gamePlayersInner[data-opponents="5"] .game-player:nth-child(4) { left: 79.6%; top: 14.1%; }
.page-game--circle #gamePlayersInner[data-opponents="5"] .game-player:nth-child(5) { left: 91.9%; top: 42.45%; }

/* 6-7: вторая добавка расстояния (2026-11-13) — дуга продлена ниже
   середины овала, до ±102°: 6 мест — ±20.4°/±61.2°/±102° (хорда ~28.6%),
   7 — 0°/±34°/±68°/±102° (~24%). */
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(1) { left: 9%; top: 50.8%; }
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(2) { left: 13.3%; top: 23.1%; }
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(3) { left: 35.4%; top: 4.85%; }
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(4) { left: 64.6%; top: 4.85%; }
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(5) { left: 86.7%; top: 23.1%; }
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player:nth-child(6) { left: 91%; top: 50.8%; }

.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(1) { left: 9%; top: 50.8%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(2) { left: 11.15%; top: 27.4%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(3) { left: 26.6%; top: 9.2%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(4) { left: 50%; top: 2.4%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(5) { left: 73.4%; top: 9.2%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(6) { left: 88.85%; top: 27.4%; }
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player:nth-child(7) { left: 91%; top: 50.8%; }

/* В тесных 6-7-местных раскладках широкая (240%) подпись соседних мест
   налезала бы на соседа — там имя остаётся в пределах полутора сидений. */
.page-game--circle #gamePlayersInner[data-opponents="6"] .game-player .game-player__name,
.page-game--circle #gamePlayersInner[data-opponents="7"] .game-player .game-player__name {
  max-width: 130%;
}

/* "Me" — never on the opponents' row, always fixed bottom-center with a
   bigger avatar, at the same 73.7% height and 20.6% width Game_duel uses
   for its own "you" seat (100px avatar on this screen's identical 485px
   frame). */
.page-game--circle #gamePlayersInner .game-player--me {
  left: 50%;
  width: 20.6%;
  top: 73.7%;
  /* Same fix as the opponent rule above — Game_duel's own "you" seat
     (nth-child(2)) is translateX(-50%) only. */
  transform: translateX(-50%);
}

/* 1:1 copy of Game_duel's own avatar treatment (dark ring on every
   opponent, gold ring only on "me") — the previous version gave every
   seat the same thin gold stroke instead, which read as its own separate
   look rather than Arena/Royal just being Duel with more seats. */
.page-game--circle .game-player__avatar {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  box-sizing: border-box;
}

.page-game--circle .game-player:not(.game-player--waiting) .game-player__avatar {
  border: 4px solid #330002;
}

.page-game--circle #gamePlayersInner .game-player--me .game-player__avatar {
  box-shadow: 0 0 0 1px #efc319, 0 4px 10px rgba(255, 213, 0, 0.35);
}

.page-game--circle #gamePlayersInner .game-player:not(.game-player--me) .game-player__avatar {
  font-size: 22px;
}

.page-game--circle #gamePlayersInner .game-player--me .game-player__avatar {
  font-size: 30px;
}

.page-game--circle .game-player__name {
  margin-top: 2px;
  /* 14px по запросу 2026-11-13 (было фигмовские 16) — вместе с дуэлью */
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  /* В Figma подпись места шире аватара (узел имени W175 при аватаре 72) —
     даём имени выходить за seat-обёртку (14.9%) до тех же ~36% ширины
     кадра, прежде чем включится многоточие из базового правила; flex-
     колонка сиденья центрирует и слишком широкий элемент сама. */
  max-width: 240%;
}

/* Имя крайнего бокового места может высунуться за край экрана (в Figma
   кадр сам клипует, Clip content) — повторяем это на странице, иначе
   появился бы горизонтальный скролл. */
#page-game.page-game--circle {
  overflow: hidden;
}

.page-game--circle #gamePlayersInner .game-player--me .game-player__name {
  font-size: 22px;
}

/* Border above adds 4px of padding-box the ring's own inset:-4px (base
   rule) now has to clear, same fix Game_duel needed for the same reason
   (see .page-game--duel .game-player__ring) — without this the countdown
   ring sits flush on the avatar's own edge instead of outside it. */
.page-game--circle .game-player__ring {
  inset: -8px;
}

/* Same slot as Game_duel, same final 20% width — NOT Figma's literal
   measured 39.18% (190px/485px frame) this was ported at originally. At
   that size the dice's own bottom edge (~69.6% of the table) overlapped
   .game-player--me (top:73.7%, reused verbatim from Game_duel, same spot
   the duel screen's own dice already shares without conflict at 20%) —
   confirmed by measuring both boxes live, not guessed. Matching Game_duel's
   already-working number sidesteps re-deriving new avatar/status math for
   this screen's own geometry from scratch. */
/* top 45% — центр видимого кубика в кадре 1:447, см. комментарий у
   .page-game--duel .game-circle-dice-slot. */
.page-game--circle .game-circle-dice-slot {
  left: 50%;
  top: 45%;
  width: 20%;
  transform: translate(-50%, -50%);
}

.page-game--circle .game-circle-dice-slot .stage-card {
  padding: 0;
}

.page-game--circle .game-roll-visual {
  height: auto;
}

.page-game--circle .result-emoji {
  width: 100%;
  aspect-ratio: 1;
  font-size: 0;
  background-image: url('assets/dice-idle-static-v2.webp');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0px 8px 10px rgba(0, 0, 0, 0.5)) drop-shadow(0px 0px 40px rgba(255, 212, 0, 0.5));
}

/* "Ходит Имя"/"Ожидаем игроков" (Figma node 1:258) — mirrors
   #gameTickerText, see setGameTicker(). 59.5% — фигмовская позиция текста
   (узел Y518 при столе Y226 H491), вернулась вместе с кубиком на 45%. */
.page-game--circle .game-duel-status {
  display: block;
  position: absolute;
  left: 50%;
  top: 59.5%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 700;
  color: #efc319;
  white-space: nowrap;
}

/* Same gold/dark button pair as Game_duel's action bar — and, same as
   duel, exactly one button on screen, never "Готов"+"Отменить" side by
   side (see #gameReadyTimer below). */
.game-actionbar.page-game--circle .play-btn {
  flex: none;
  width: 216px;
  max-width: 90%;
  margin: 0 auto;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
}

.game-actionbar.page-game--circle .play-btn:not(.play-btn--red):not(.play-btn--secondary) {
  background: #efc319;
  color: #000000;
}

.game-actionbar.page-game--circle .play-btn--red,
.game-actionbar.page-game--circle .play-btn--secondary {
  background: #260102;
  color: #ffffff;
  border: 2px solid rgba(255, 245, 200, 0.15);
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
}

.page-game--circle .game-bank-pill #gameBankPillText {
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Финал игры — модалка «Победитель» (Figma 1:344, Game_finish) ----------
   Карточка 409×442 на кадре 485×874: отступ сверху 164/874=18.76%, бока по
   38/485 — т.е. ширина 84.33%. Фон/рамка/свечение — тот же spec, что у
   .create-card, только радиус 20 (узел Back). Всё внутри — фиксированные px
   из макета (заголовок 30, имя 18, банк 30, кнопка 216×54, подпись 12). */
.game-finish-overlay {
  position: fixed;
  inset: 0;
  z-index: 40; /* над доком (20) и экраном */
  display: none;
  background: rgba(0, 0, 0, 0.6);
  padding-top: 18.76vh;
}

.game-finish-overlay.open {
  display: block;
}

/* На мобилках (fullscreen + верхняя safe-area) фиксированные 18.76vh от
   макета визуально задирают карточку выше середины — там она просто
   центрируется по вертикали (запрос 2026-11-13). Десктоп остаётся на
   фигмовском отступе. data-platform ставится синхронно в <head>, тот же
   флаг, что у mobile-only верхних отступов. */
html[data-platform="mobile"] .game-finish-overlay {
  padding-top: 0;
}

html[data-platform="mobile"] .game-finish-overlay.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-finish-card {
  width: 84.33%;
  max-width: 409px;
  margin: 0 auto;
  padding: 48px 30px 35px;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
  text-align: center;
}

.game-finish-card__title {
  font-size: 30px;
  line-height: 26px;
  font-weight: 700;
  color: #ffffff;
}

.game-finish-card__avatar-line {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.game-finish-card__line {
  flex: 1;
  height: 1px;
  opacity: 0.5;
}

.game-finish-card__line--left {
  background: linear-gradient(90deg, transparent, #efc319);
}

.game-finish-card__line--right {
  background: linear-gradient(270deg, transparent, #efc319);
}

/* Аватар победителя — фото поверх инициала-фолбэка (тот же приём, что
   .game-player__avatar), золотое кольцо 1px + свечение как в макете. */
.game-finish-card__avatar {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #330002;
  box-shadow: 0 0 0 1px #efc319, 0 0 15px rgba(255, 212, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
}

.game-finish-card__avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-finish-card__name {
  margin-top: 10px;
  font-size: 18px;
  line-height: 26px;
  font-weight: 700;
  color: #ffffff;
}

.game-finish-card__bank {
  margin-top: 6px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
}

/* Та же жёлтая пилюля 216×54, что .modes-empty-create-btn — продублирована,
   а не пошарена классом: у той свой margin-top и контекст пустого списка. */
.game-finish-card__btn {
  margin-top: 41px;
  width: 216px;
  height: 54px;
  border: none;
  border-radius: 100px;
  background: #efc319;
  color: #000000;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
  cursor: pointer;
}

.game-finish-card__check {
  display: block;
  margin: 20px auto 0;
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 12px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
}

/* ---------- Game_arena 1:1 (Figma 1:447/1:258) — свободные места, бейджи
   бросков и декор. ---------- */

/* «Свободно» (узел 1:490): тёмный круг вместо серого пунктирного, золотой
   «+» 22px (узел 1:492, EFC319 + мягкое свечение), подпись «Свободно» тем
   же 16px bold, что имена (узел 1:495). С 2026-11-13 тот же стиль и на
   Дуэли (запрос пользователя); тап по месту открывает нативное
   телеграм-приглашение (см. обработчик #gamePlayersInner в app.js). */
/* Точные тени из Фигмы (сняты с узлов 2026-11-13, не на глаз):
   - сам тёмный круг (узел 1:491, «seat»): Drop shadow X0 Y0 Blur 15
     Spread 0, FFD400 30% → box-shadow вокруг круга;
   - «+» (узел 1:492): Drop shadow X0 Y0 Blur 9, FFD400 100%. */
.page-game--duel .game-player--waiting .game-player__avatar,
.page-game--circle .game-player--waiting .game-player__avatar {
  background: #330002;
  border: 4px solid #330002;
  color: #efc319;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
}

/* Подпись «Свободно» мельче имён игроков — 14px по запросу 2026-11-13
   (заодно целиком влезает в 130%-ограничение тесных 7-8-местных
   раскладок, без «Свобо…»). */
/* .game-player.game-player--waiting — чтобы сравняться по специфичности с
   130%-ограничением тесных раскладок (id + 4 класса-уровня, у того
   [data-opponents] тоже класс-уровень) и победить порядком в файле. */
.page-game--circle #gamePlayersInner .game-player.game-player--waiting .game-player__name {
  font-size: 14px;
  /* На 14px слово целиком ~62-78px — чуть шире 130%-ограничения тесных
     раскладок; у «Свободно» подпись статичная, ей можно 150% (87px). */
  max-width: 150%;
}

.page-game--duel .game-player--waiting .game-player__avatar svg,
.page-game--circle .game-player--waiting .game-player__avatar svg {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 0 9px #ffd400);
}

/* Бейдж выпавшего числа (Figma 1:301 на Game_arena 1:258 и 2:588 на
   Game_duel 1:196 — геометрия идентична): белый мини-кубик 16×16 r3 с
   тёмно-красными пипсами, по центру сразу под именем — те самые
   assets/dice-points/N.svg, экспортированные из этой же Фигмы. С
   2026-11-13 показывается на ОБОИХ игровых экранах, «цифра вместо
   аватара» убрана совсем (см. renderGamePlayers). */
.game-player__points {
  width: 16px;
  height: 16px;
  display: block;
  margin: 1px auto 0;
}

/* ---------- Кубик броска = кубику покоя (запрос 2026-11-13: «при броске
   кубик намного меньше, чем в стоке»). В lottie Dice-result-N-glow кубик
   покоя занимает лишь 48.1% холста 512×512 и сидит в точке (57.9%, 69.6%)
   — свечение и запас под прыжки запечены в композицию, а статичный
   dice-idle-static-v2.png обрезан по альфе и заполняет слот целиком,
   отсюда и разница ~вдвое. Контейнер лотти растягивается на слот и
   масштабируется так, чтобы кубик последнего кадра был ровно размером
   слота и в его центре (замерено флуд-филлом по last frame номиналов 3 и
   5 — позиция покоя у них одинаковая). Это же делает ненужным старый хак
   margin-top:-25px (вес тени) — здесь margin обнулён, центр теперь по
   замеру. Только игровые экраны: сольный «Кубик» и «Проверка броска»
   остаются на базовом .result-lottie 120px. */
.page-game--duel .result-lottie,
.page-game--circle .result-lottie {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  margin: 0;
  transform: translate(-7.9%, -19.6%) scale(2.079);
  transform-origin: 57.9% 69.6%;
}

/* Холодный старт: «Комнаты» не показывается, пока не загружены первый список
   и init() — см. maybeRevealModes в app.js. Плавающий фон остаётся видимым. */
#page-modes > :not(.bg-float-layer) {
  transition: opacity 0.2s ease;
}
#page-modes.modes-loading > :not(.bg-float-layer) {
  opacity: 0;
  pointer-events: none;
}

/* ===== Профиль и Баланс — палитра редизайна (тёмно-красный + золото) =====
   Раньше брали тему Telegram (синеватые карточки, синий акцент, цветные
   плитки иконок). Токены переопределены на самих страницах, поэтому всё
   внутри (карточки, строки, кнопки, тумблеры) перекрашивается разом;
   ниже — только то, что токенами не покрывается (рамки, плитки иконок,
   жёлтые кнопки/табы, захардкоженные серые). Значения — те же, что у
   .create-card / .create-mode-btn / .modes-empty-create-btn. */
#page-profile,
#page-balance {
  --tg-section-bg: #260102;
  --tg-text: #ffffff;
  --tg-hint: rgba(255, 255, 255, 0.6);
  --tg-link: #efc319;
  --tg-button: #efc319;
  --tg-button-text: #000000;
  --tg-separator: rgba(255, 245, 200, 0.12);
  --segment-track-bg: #260102;
  --segment-active-bg: #efc319;
}

/* Карточки */
#page-profile .ann-settings-group,
#page-balance .list-card {
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}

/* Разделители строк */
#page-profile .ann-settings-row:not(:last-child)::after,
#page-balance #balanceDivider,
#page-balance .tui-cell:not(:last-child)::after {
  background: rgba(255, 245, 200, 0.1);
}

/* Плитки иконок — вместо фиолетового/синего/зелёного/оранжевого */
#page-profile .ann-settings-icon {
  background: #330002 !important;
  box-shadow: inset 0 0 0 1px rgba(255, 245, 200, 0.15);
}
#page-profile .ann-settings-icon svg {
  stroke: #efc319;
}

/* Серые значения/шевроны/подсказки */
#page-profile .ann-settings-value,
#page-profile .ann-settings-chevron,
#page-profile .ann-settings-helper {
  color: rgba(255, 255, 255, 0.6);
}

/* Тумблеры */
#page-profile .pg-switch {
  background: rgba(255, 255, 255, 0.2);
}
#page-profile .pg-switch:has(.pg-switch__input:checked) {
  background: #efc319;
}

/* Баланс: сегменты Пополнить/Вывести/Транзакции */
#page-balance .segmented {
  border: 2px solid rgba(255, 245, 200, 0.15);
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.15);
}
#page-balance .segmented__sel {
  box-shadow: 0 0 7.5px rgba(255, 212, 0, 0.3);
}
#page-balance .segment.active {
  color: #260102;
}

/* Кнопки — жёлтые, как «Создать комнату» */
#page-balance .play-btn {
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
  font-weight: 700;
}
#page-balance .play-btn--secondary {
  background: #330002;
  border: 2px solid rgba(255, 245, 200, 0.15);
  color: #efc319;
  box-shadow: none;
}

/* Синяя галочка у имени — в золото (hue-rotate синего ≈217° → ≈45°) */
#page-profile img[src*="bi-verified"] {
  filter: hue-rotate(200deg) saturate(1.2) brightness(1.2);
}

/* Аватарка в шапке игры не кликабельна */
#gameAvatarBtn { pointer-events: none; }

/* Клавиатура: порт @gfts_app (html.keyboard-native-flow) — на время фокуса
   в поле #pages выходит из position:fixed в обычный поток, iOS сам
   ресайзит страницу под клавиатуру (см. app.js, KEYBOARD_RELEASE_SETTLE_MS). */
html.keyboard-native-flow,
html.keyboard-native-flow body {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: none;
}
html.keyboard-native-flow #pages {
  position: relative;
  inset: auto;
  width: 100%;
  /* --app-h (зафиксированная высота окна), а не 100%: иначе при клавиатуре страница
     сжимается и всё, что центрировано по вертикали (заставка «Комнат»: кубик,
     заголовок, подзаголовок за окном «Создать комнату»), уезжает вверх. */
  height: var(--app-h, 100%);
}

/* Заголовки заглушек Турниры/Подарки: --tg-text в светлой теме Telegram = чёрный, на фиксированном тёмном фоне не виден */
#page-tournaments .tui-empty__title,
#page-gifts .tui-empty__title { color: #ffffff; }

/* Заставка «Комнат» — Frame 2147238387 из Figma (кубик «CC», без чёрного круга; viewBox
   обрезан по кубику) вместо эмодзи 🎲; блок 110×110, по высоте 110. */
.tui-empty__dice {
  height: 110px;
  width: auto;
  display: block;
}

/* Пустое состояние «Комнат»: заголовка над картинкой нет. */
#page-modes.rooms-empty .modes-title-row {
  display: none;
}

/* Плавающие кубики фона — Frame 2147238388 из Figma (кубик с точками, без чёрного
   круга), одна общая картинка вместо 100 инлайновых SVG; белый контур на 14%. */
.bg-float svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #fff;
  opacity: 0.14;
}

/* Экран «Дуэль»: фоновые кубики статичные (замораживаются на текущем кадре),
   на остальных экранах (Арена, Комнаты, …) продолжают подниматься. */
body:has(#page-game.active.page-game--duel) .bg-float {
  animation-play-state: paused;
}

/* Игровой экран подгоняется под высоту окна: --game-fit / --game-fit-gap
   выставляет fitGameScreen() (app.js). Без переменных = масштаб 1, ничего
   не меняется. */
#page-game.active {
  transform: scale(var(--game-fit, 1));
  transform-origin: top center;
  margin-bottom: var(--game-fit-gap, 0px);
}

/* Комнаты: страница ровно по высоте окна (между safe-area сверху и доком
   снизу), шапка (баланс, заголовок, поиск, чипы) стоит на месте, а список
   комнат прокручивается внутри себя — раньше при 5+ комнатах хвост списка
   уходил под док и был недоступен (прокрутка страницы выключена). Паддинги
   секции оставляют место для свечения карточки, которое иначе обрезалось бы
   границей прокручиваемого блока. */
#page-modes.active {
  height: 100%;
  min-height: 0;
}

#page-modes.active:not(.rooms-empty) #modesOpenSection {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 6px 16px 24px;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* Шапка (баланс, заголовок, поиск, чипы) не сжимается, когда комнат много: сжималась
   только она (overflow-x у чипов делал min-height 0) — чипы под поиском становились
   узкими и обрезанными. */
#page-modes.active .rooms-toolbar,
#page-modes.active .modes-title-row,
#page-modes.active .modes-search,
#page-modes.active .modes-filter-row {
  flex: none;
}

/* Окно списка комнат (Figma 1:1): фиксируется по высоте свободного места, внутри — прокрутка. */
.rooms-card {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rooms-card > #modesRoomsList {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.rooms-card > #modesRoomsList::-webkit-scrollbar {
  display: none;
}
/* Скролл-индикатор: трек 3px, #FFCB00 15%, отступ 24px сверху/снизу и 10px справа (центр). */
.rooms-scrollbar {
  position: absolute;
  top: 24px;
  bottom: 24px;
  right: 8.5px;
  width: 3px;
  border-radius: 3px;
  background: rgba(255, 203, 0, 0.15);
  pointer-events: none;
}
.rooms-scrollbar > i {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 74px;
  border-radius: 3px;
  background: linear-gradient(to bottom, rgba(255, 203, 0, 0) 0%, #ffcb00 22%, #ffcb00 75%, rgba(255, 203, 0, 0) 100%);
  opacity: 0.5;
  will-change: transform;
}
#modesOpenSection:has(#modesRoomsList[data-state="empty-rooms"]) .rooms-scrollbar,
#modesOpenSection:has(#modesRoomsList[data-state="empty-filtered"]) .rooms-scrollbar {
  display: none;
}

#page-modes #modesOpenSection::-webkit-scrollbar {
  display: none;
}

/* Цвета не зависят от темы Telegram и от «Оформления»: фон приложения фиксированно
   тёмный, тексты и заголовки белые, карточки тёмно-бордовые. */
:root,
:root[data-theme] {
  --tg-bg: #000000;
  --tg-secondary-bg: #000000;
  --tg-text: #ffffff;
  --tg-hint: rgba(255, 255, 255, 0.6);
  --tg-section-bg: #260102;
  --tg-separator: rgba(255, 245, 200, 0.12);
}

/* Баланс: без подписей «БАЛАНС»/«Кошелёк не подключён»; контент начинается на той же
   высоте, что баланс-пилюля и аватар на «Комнатах» (тот же отступ, что у
   .rooms-toolbar: 50px на телефонах, 0 на десктопе). */
#page-balance > .pg-section {
  margin-top: 50px;
}

html[data-platform="desktop"] #page-balance > .pg-section {
  margin-top: 0;
}

/* Старые шторки (.modal-overlay) всегда display:flex и стоят за краем экрана
   (transform), поэтому при смене размера окна при запуске (fullscreen, safe-area)
   их анимация могла на миг показать их края. Закрытые — невидимы; visibility
   выключается после анимации закрытия, а не мгновенно. */
.modal-overlay:not(.open) {
  visibility: hidden;
  transition: visibility 0s linear 0.4s;
}
.modal-overlay.open {
  visibility: visible;
  transition: none;
}

/* Баланс: вкладки Пополнить/Вывести/Транзакции — плашка короче и без задержки
   цвета текста (раньше плашка ехала 0.3с, а цвет менялся сразу — выглядело как
   рябь/запаздывание); подсказка браузеру про плавную анимацию. */
#page-balance .segmented__sel {
  /* Анимируем ТОЛЬКО transform (идёт на композиторе, плавно на 120 Гц); ширина — фиксированная
     треть (3 равные вкладки), раньше анимация width заставляла браузер пересчитывать вёрстку
     каждый кадр и плашка двигалась «как на 60 Гц». */
  width: calc((100% - 12px) / 3) !important;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
#page-balance .segment {
  transition: color 0.3s ease;
}

/* Баланс-пилюля и аватар на «Комнатах»: без рамок фокуса/подсветки при нажатии;
   пилюля при нажатии не растёт на аватар, а слегка сжимается (как остальные
   кнопки тулбара). */
.modes-balance-pill,
.modes-avatar-btn {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.modes-balance-pill,
.modes-avatar-btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
/* Нажатие пилюли — без transform (масштаб соседа заставлял iOS перерисовывать слой рядом
   стоящей аватарки с её свечением), обратная связь — лёгкое затемнение. */
.modes-balance-pill:active {
  transform: none;
  opacity: 0.8;
}

/* Экран «Арена» (page-game--circle): из 100 плавающих кубиков остаётся 20 —
   каждый пятый; на остальных экранах без изменений. */
body:has(#page-game.active.page-game--circle) .bg-float:not(:nth-child(even)) {
  display: none;
}

/* Кнопка действия на игровых экранах появляется плавно (проигрывается каждый раз,
   когда она снова становится видимой после display:none). */
@keyframes game-btn-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
#gameReadyBtn {
  animation: game-btn-in 0.22s ease-out both;
}

/* Док не виден, пока приложение не готово (см. revealApp в app.js): иначе его плашка
   вкладки прыгала при загрузке; проявляется вместе со страницей (transition у .tabbar). */
html:not(.app-ready) .tabbar {
  opacity: 0;
}

/* Фон (свечение и плавающие кубики) проявляется вместе со страницей и доком, а не раньше:
   пока клиент Telegram пересчитывает размер окна при запуске, фон (от --app-h) дёргался. */
.bg-glow,
.bg-float-layer {
  transition: height 0.3s ease;
}
/* Фон виден сразу, без ожидания (раньше был скрыт до bg-ready/app-ready → при перезагрузке через
   меню Telegram экран был чёрным, пока не придут данные). Скачок размеров при смене окна на старте
   сглаживается transition'ами ниже (.bg-glow__blob). */
/* Если размер окна всё же меняется позже (поворот, смена размера окна на десктопе), пятна
   свечения плавно подстраиваются, а не прыгают. */
.bg-glow__blob,
.bg-glow__vignette {
  transition: width 0.3s ease, height 0.3s ease, transform 0.3s ease, filter 0.3s ease;
}

/* Кубиков 40 (в разметке оставлены только они; Арена — каждый чётный = 20). */

/* Кнопка-аватарка (шапка Комнат и игры): никакой реакции на нажатие/фокус — ни масштаба
   (глобальное button:active { scale(1.1) }), ни подсветки. Жёлтая рамка и свечение статичны. */
.modes-avatar-btn,
.modes-avatar-btn:active,
.modes-avatar-btn:focus,
.modes-avatar-btn:focus-visible {
  transform: none;
  transition: none;
  outline: none;
  opacity: 1;
  border: 1px solid #efc319;
  box-shadow: 0 4px 10px rgba(255, 213, 0, 0.35);
  -webkit-tap-highlight-color: transparent;
}
.modes-avatar-btn:active .modes-avatar-btn__img {
  filter: none;
  opacity: 1;
}

/* «Новая комната»: плавное появление — затемнение проявляется, карточка слегка всплывает
   снизу с лёгким увеличением. Играет каждый раз при открытии (display:none → flex). */
.create-modal.open {
  animation: create-modal-bg 0.25s ease-out both;
}
.create-modal.open .create-card {
  animation: create-card-in 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes create-modal-bg {
  from { background: rgba(0, 0, 0, 0); }
  to { background: rgba(0, 0, 0, 0.6); }
}
@keyframes create-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Закрытие — то же самое в обратную сторону (app.js: createDetailPage.close). */
.create-modal.open.closing {
  animation: create-modal-bg-out 0.25s ease-in both;
  pointer-events: none;
}
.create-modal.open.closing .create-card {
  animation: create-card-out 0.26s cubic-bezier(0.4, 0, 0.8, 0.6) both;
}
@keyframes create-modal-bg-out {
  from { background: rgba(0, 0, 0, 0.6); }
  to { background: rgba(0, 0, 0, 0); }
}
@keyframes create-card-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(18px) scale(0.94); }
}
@media (prefers-reduced-motion: reduce) {
  .create-modal.open,
  .create-modal.open .create-card { animation: none; }
}

/* «Победитель»: та же анимация появления/закрытия, что у «Новой комнаты». */
.game-finish-overlay.open {
  animation: create-modal-bg 0.25s ease-out both;
}
.game-finish-overlay.open .game-finish-card {
  animation: create-card-in 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.game-finish-overlay.open.closing {
  animation: create-modal-bg-out 0.25s ease-in both;
  pointer-events: none;
}
.game-finish-overlay.open.closing .game-finish-card {
  animation: create-card-out 0.26s cubic-bezier(0.4, 0, 0.8, 0.6) both;
}
@media (prefers-reduced-motion: reduce) {
  .game-finish-overlay.open,
  .game-finish-overlay.open .game-finish-card { animation: none; }
}

/* Тестовая (демо) карточка комнаты — без нажатия. */
.tui-cell--demo { cursor: default; pointer-events: none; }

/* Строки списка комнат 1:1 с Figma «Rooms» (Frame 2147238384): отступы карточки 20px по бокам и
   16px сверху/снизу (+2px рамка), строка 51px + по 16px до и после разделителя (шаг 83px);
   разделитель — 1px, градиент #FFCB00 0/22/75/100% = α0/1/1/0, opacity 50%, от левого края
   строки, чуть короче строки (350 из 369); блок цены — левое выравнивание в фиксированной
   колонке (как в макете цены не «прыгают» вправо), шеврон 9×16 у правого края с отступом 20px. */
#modesRoomsList {
  padding: 16px 0;
}
#modesRoomsList .tui-cell {
  padding: 16px 20px;
}
#modesRoomsList .tui-cell:not(:last-child)::after {
  left: 20px;
  right: 39px;
  height: 1px;
  background: linear-gradient(to right, rgba(255, 203, 0, 0) 0%, #ffcb00 22%, #ffcb00 75%, rgba(255, 203, 0, 0) 100%);
  opacity: 0.5;
}
#modesRoomsList .tui-cell__trailing {
  gap: 0;
}
#modesRoomsList .room-price {
  width: 105px;
  justify-content: flex-start;
}
/* демо-карточки показывают шеврон так же, как настоящие (только не нажимаются) */

/* Чипы Все/Дуэль/Арена/сортировка: у ряда overflow-x:auto → браузер принудительно обрезает и по
   вертикали (overflow-y тоже становится auto), и свечение (box-shadow) чипов упиралось в границу
   ряда — получалась «квадратная рамка» вокруг свечения. Даём ряду внутренний запас под свечение
   (padding), а внешние отступы компенсируем отрицательным margin — раскладка не меняется. */
#page-modes .modes-filter-row {
  margin: -16px 0 4px;
  padding: 16px 16px;
  scrollbar-width: none;
}
#page-modes .modes-filter-row::-webkit-scrollbar {
  display: none;
}


/* Фон-свечение без картинок и без filter:blur. После сворачивания бота iOS выбрасывает декодированные
   картинки и слои с размытием и возвращает их секундами: «тёмные эллипсы и кубики проявляются не
   сразу» (в @cube_zeus_bot, где такого нет, фон — обычные векторные элементы). Поэтому: свечение —
   чистые CSS-градиенты (рисуются мгновенно как обычный контент), кубики — inline-SVG через <use>
   (symbol #fd в index.html), а не <img>. Параметры те же, что у Figma-блобов: размытие (σ) заменено
   радиальным градиентом с гауссовым спадом на расширенном на 2σ боксе. */
.bg-glow { background: #000; }
.bg-glow__blob { display: block; }
.bg-glow__blob--center {
  width: calc(110.2 * var(--u));
  height: calc(105.9 * var(--u));
  background: radial-gradient(closest-side, #700204 0%, #700204 38%, rgba(112, 2, 4, 0.5) 58%, rgba(112, 2, 4, 0.16) 79%, rgba(112, 2, 4, 0) 100%);
  filter: none;
}
.bg-glow__blob--top,
.bg-glow__blob--bottom {
  /* верх/низ — вытянутые эллипсы шире экрана: профиль гауссова спада по вертикали (градиент) × по
     горизонтали (mask) — как у настоящего размытого эллипса, а не радиальный «пузырь». */
  width: calc(103.3 * var(--u));
  height: calc(75.1 * var(--u));
  background: linear-gradient(to bottom, rgba(190, 1, 4, 0) 0%, rgba(190, 1, 4, 0.16) 11.4%, rgba(190, 1, 4, 0.5) 23%, #be0104 34.4%, #be0104 65.6%, rgba(190, 1, 4, 0.5) 77%, rgba(190, 1, 4, 0.16) 88.6%, rgba(190, 1, 4, 0) 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.16) 8.3%, rgba(0, 0, 0, 0.5) 16.7%, #000 25%, #000 75%, rgba(0, 0, 0, 0.5) 83.3%, rgba(0, 0, 0, 0.16) 91.7%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, rgba(0, 0, 0, 0.16) 8.3%, rgba(0, 0, 0, 0.5) 16.7%, #000 25%, #000 75%, rgba(0, 0, 0, 0.5) 83.3%, rgba(0, 0, 0, 0.16) 91.7%, transparent 100%);
  filter: none;
}
.bg-glow__vignette { display: block; }

/* ТОЧНЕЕ (2026-11-15): радиальный градиент с гауссовым (erf) спадом, посчитанный по настоящему размытому
   эллипсу Figma — сохраняет форму «затемнённых эллипсов» (края полос изгибаются к углам), которой не
   было у линейных полос. Подобрано по эталонному рендеру с filter:blur (среднее отклонение ≈1.3/255). */
.bg-glow__blob--center {
  width: calc(113.5 * var(--u));
  height: calc(105.9 * var(--u));
  background: radial-gradient(closest-side, rgba(112, 2, 4, 1) 0%, rgba(112, 2, 4, 0.977) 13.9%, rgba(112, 2, 4, 0.933) 24.6%, rgba(112, 2, 4, 0.841) 35.4%, rgba(112, 2, 4, 0.691) 46.2%, rgba(112, 2, 4, 0.500) 56.9%, rgba(112, 2, 4, 0.309) 67.7%, rgba(112, 2, 4, 0.159) 78.5%, rgba(112, 2, 4, 0.067) 89.2%, rgba(112, 2, 4, 0.000) 100.0%);
  filter: none;
}
.bg-glow__blob--top,
.bg-glow__blob--bottom {
  width: calc(114.4 * var(--u));
  height: calc(71.3 * var(--u));
  background: radial-gradient(closest-side, rgba(190, 1, 4, 1) 0%, rgba(190, 1, 4, 0.977) 8.4%, rgba(190, 1, 4, 0.933) 19.8%, rgba(190, 1, 4, 0.841) 31.3%, rgba(190, 1, 4, 0.691) 42.7%, rgba(190, 1, 4, 0.500) 54.2%, rgba(190, 1, 4, 0.309) 65.6%, rgba(190, 1, 4, 0.159) 77.1%, rgba(190, 1, 4, 0.067) 88.5%, rgba(190, 1, 4, 0.000) 100.0%);
  -webkit-mask-image: none;
  mask-image: none;
  filter: none;
}

/* Арена: два верхних места (2 и 4 соперника) стояли несимметрично — правое 71.4% (как у соперника на
   Дуэли), левое 32.9% (в макете 82.9 vs 103.5px от оси). Теперь левое — зеркально правому: 100 − 71.4 = 28.6%.
   Боковые места (11.86% / 90.2% при 3–4 соперниках) уже симметричны (11.86 + 88.14). */
.page-game--circle #gamePlayersInner[data-opponents="2"] .game-player:nth-child(1) { left: 28.6%; }
.page-game--circle #gamePlayersInner[data-opponents="4"] .game-player:nth-child(2) { left: 28.6%; }

/* Экран «сначала примите условия» (app.js showVerifyGate) — поверх всего. */
.verify-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #000;
}
.verify-gate__card {
  width: 100%;
  max-width: 360px;
  padding: 28px 24px;
  text-align: center;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 24px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
}
.verify-gate__title { font-size: 22px; font-weight: 700; color: #fff; }
.verify-gate__text { margin-top: 12px; font-size: 15px; line-height: 1.4; color: rgba(255, 255, 255, 0.7); }
.verify-gate__btn {
  margin-top: 22px;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 100px;
  background: #efc319;
  color: #260102;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* История (Профиль → История) в стиле остального бота: карточка как у списка комнат, аватары с тёмным
   кольцом и свечением, градиентные разделители, золотые суммы. Заголовок «История ставок» убран — список
   начинается там же, где первый блок на странице Кошелька (16px от верха). */
#history {
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 30px;
  box-shadow: 0 0 20px rgba(255, 212, 0, 0.15);
  /* верхний/нижний отступ первой/последней строки = левому (20px): 4px карточки + 16px строки */
  padding: 4px 0;
}
#history .tui-cell {
  padding: 16px 20px;
}
#history .tui-cell__avatar {
  width: 51px;
  height: 51px;
  font-size: 22px;
  background: #2d0000 !important;
  border: 4px solid #330002;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.3);
}
#history .tui-cell__mode-badge {
  display: none;
}
#history .tui-cell:not(:last-child)::after {
  left: 20px;
  right: 39px;
  height: 1px;
  background: linear-gradient(to right, rgba(255, 203, 0, 0) 0%, #ffcb00 22%, #ffcb00 75%, rgba(255, 203, 0, 0) 100%);
  opacity: 0.5;
}
#history .history-row__amount {
  font-size: 18px;
  font-weight: 700;
}
#history .history-row__amount.win { color: #efc319; }
#history .history-row__amount.lose { color: #ffffff; }
#history .history-row__status {
  color: rgba(255, 255, 255, 0.5);
}
#history .history-empty {
  padding: 24px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
}

/* История: контент начинается на той же высоте, что на экране Кошелька (там #page-balance > .pg-section
   сдвинут на 50px — на уровень баланс-пилюли и аватара «Комнат»; на десктопе 0). */
#page-history > .pg-section {
  margin-top: 50px;
}
html[data-platform="desktop"] #page-history > .pg-section {
  margin-top: 0;
}

#history .history-row__status:empty { display: none; }

/* «Победитель»: две кнопки — «Продолжить» (жёлтая) и «В меню» (контурная). */
.game-finish-card__btn--secondary {
  margin-top: 12px;
  background: transparent;
  border: 2px solid rgba(255, 245, 200, 0.25);
  color: #ffffff;
  box-shadow: none;
}
.game-finish-card__btn:disabled { opacity: 0.6; }

/* Жёлтый «+» (39px) стоял правым краем вровень с аватаркой (48px) → его центр был на 4.5px правее центра
   аватарки. Сдвигаем на (48 − 39) / 2, чтобы центры совпали. */
#page-modes .modes-title-row .modes-create-btn {
  margin-right: calc((48px - 39px) / 2);
}

/* Статус под «Пополнить»/«Вывести» (app.js setWalletStatus): ожидание со спиннером → «готово» с галочкой. */
.wallet-status {
  margin-top: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #260102;
  border: 2px solid rgba(255, 245, 200, 0.15);
  border-radius: 20px;
  box-shadow: 0 0 15px rgba(255, 212, 0, 0.12);
}
.wallet-status[hidden] { display: none; }
.wallet-status__title { font-size: 15px; font-weight: 700; color: #fff; }
.wallet-status__sub { margin-top: 2px; font-size: 13px; color: rgba(255, 255, 255, 0.6); }
.wallet-status__spinner {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 203, 0, 0.25);
  border-top-color: #ffcb00;
  animation: wallet-status-spin 0.8s linear infinite;
}
.wallet-status__check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #efc319;
  color: #260102;
  font-size: 14px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}
@keyframes wallet-status-spin { to { transform: rotate(360deg); } }
