/* BGF mobile-app component styles. Tokens live in bgf-colors.css; bitup
 * overrides in bitup-skin.css. After Task 10 cleanup this file holds component
 * skeletons (bottom-nav, chips, badges, chat, toasts, modals, profile bits)
 * that are still used by the cabinet shell. Shell layout itself lives in
 * widgets/app-shell/cabinet-shell.css. */

/* iOS Safari auto-zooms when tapping a focusable field whose computed
 * font-size is < 16px. Force 16px on text inputs at mobile widths to kill
 * the zoom — pinch-zoom of the whole page remains available. Desktop keeps
 * the smaller pixel-art sizes the components set themselves.
 *
 * `!important` is necessary here: many per-page stylesheets (bgf-cabinet.css,
 * bgf-my-games-v3.css, bitup-skin.css, …) target inputs with more specific
 * selectors like `.cab-top .search input` at 13–14px and would win the
 * cascade. Specificity workarounds don't scale across this many call-sites,
 * and 16px on mobile inputs is a well-known iOS-zoom workaround. */
@media (max-width: 768px) {
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input:not([type]),
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Hides text visually but keeps it for assistive tech. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ──────────────── Bottom nav ──────────────── */

.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  /* Taller bar — icons are now the only target; 64px keeps the touch area
   * comfortably above Apple/Material 44–48px minimum guidance. */
  height: 64px;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border-top: 2px solid var(--ink);
  box-shadow: 0 -2px 0 rgb(0 0 0 / 6%);
}

.app-bottom-nav__item {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  text-decoration: none;
}

/* Bare icon — no frame, no shadow. Active state recolours the glyph. */
.app-bottom-nav__icon-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--ink);
}
.app-bottom-nav__item--active {
  color: var(--accent, var(--purple-500));
}
.app-bottom-nav__item--active svg {
  stroke-width: 2.6;
}

/* Numbered unread badge clipped to the top-right corner of the 48×48 icon
 * box. Pixel-art square (no border-radius) with a thin ink border, capped
 * to "9+". The (4px,4px) offset from the corner of the SVG glyph (icon is
 * 32px centred in 48px box → glyph starts at 8px) lands the badge right
 * on the icon's own corner instead of floating in empty padding. */
.app-bottom-nav__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red-500);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
  font-family: var(--font-press);
  font-size: 9px;
  letter-spacing: 0.02em;
  line-height: 1;
}

.app-bottom-nav__accent {
  /* Fill the full grid cell so the 46×46 accent button reads centered.
   * Without width:100% / height:100% the <a> shrinks to content and the
   * button drifts to the cell's left edge. */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.app-bottom-nav__accent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--green-500);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 90ms steps(2), box-shadow 90ms steps(2);
}
/* Per-accent colour variants — CREATE keeps the original green, TABLES gets
 * the purple/pink BGF fill. */
.app-bottom-nav__accent--tables .app-bottom-nav__accent-button {
  background: var(--purple-500);
}
.app-bottom-nav__accent:hover .app-bottom-nav__accent-button {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
.app-bottom-nav__accent:active .app-bottom-nav__accent-button {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ──────────────── Bottom nav · v3 (BGF Mobile Nav) ──────────────
 * Ported 1:1 from design/design_system_v3/bgf-bottom-nav.css. Scoped under
 * .app-bottom-nav--v3 so the v1 (bgf-skin) nav above stays untouched
 * (per-version split). 5 slots, pixel-font labels, raised center "Создать"
 * FAB, stepped accent marquee over the active tab, notification gem on Чаты.
 * Accent/danger fall back to BGF v1 purple/red when the bitUp tokens are
 * absent, so the bar renders correctly in every skin. */
.app-bottom-nav--v3 {
  --bn-accent: var(--accent, var(--purple-500));
  --bn-accent-deep: var(--accent-deep, var(--accent, var(--purple-500)));
  --bn-danger: var(--danger, var(--red-500));
  height: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* override the v1 base block's flat shadow with the design's subtle lift */
  box-shadow: 0 -3px 0 rgb(0 0 0 / 5%);
  -webkit-tap-highlight-color: transparent;
}

.app-bottom-nav--v3 .app-bottom-nav__tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 2px 4px;
  background: transparent;
  border: 0;
  color: var(--ink-3, #6c6c6c);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms steps(2), transform 90ms steps(2);
}
.app-bottom-nav--v3 .app-bottom-nav__tab:active {
  transform: translateY(1px);
}

.app-bottom-nav--v3 .app-bottom-nav__icon {
  width: 23px;
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-bottom-nav--v3 .app-bottom-nav__icon svg {
  width: 23px;
  height: 23px;
}

.app-bottom-nav--v3 .app-bottom-nav__label {
  font-family: var(--font-pixel, "Press Start 2P", monospace);
  font-size: 7px;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  color: inherit;
}

/* stepped accent marquee over the active tab */
.app-bottom-nav--v3 .app-bottom-nav__tab::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  width: 26px;
  height: 4px;
  transform: translateX(-50%) scaleX(0);
  background: var(--bn-accent);
  transition: transform 120ms steps(3);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--active {
  color: var(--bn-accent);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--active::before {
  transform: translateX(-50%) scaleX(1);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--active .app-bottom-nav__label {
  color: var(--ink);
}

/* center "Создать" block — raised, sharp, accent */
.app-bottom-nav--v3 .app-bottom-nav__tab--fab {
  justify-content: flex-end;
  padding-bottom: 4px;
}
.app-bottom-nav--v3 .app-bottom-nav__fab-box {
  position: absolute;
  top: -16px;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bn-accent);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 90ms steps(2), box-shadow 90ms steps(2), background 120ms steps(2);
}
.app-bottom-nav--v3 .app-bottom-nav__fab-box svg {
  width: 24px;
  height: 24px;
}
.app-bottom-nav--v3 .app-bottom-nav__tab--fab:hover .app-bottom-nav__fab-box {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--bn-accent-deep);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--fab:active .app-bottom-nav__fab-box {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--fab .app-bottom-nav__label {
  color: var(--ink);
}
.app-bottom-nav--v3 .app-bottom-nav__tab--fab::before {
  display: none;
}

/* notification gem on a tab (Чаты) */
.app-bottom-nav--v3 .app-bottom-nav__badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 8px);
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bn-danger);
  color: #fff;
  font-family: var(--font-pixel, "Press Start 2P", monospace);
  font-size: 7px;
  line-height: 1;
  border: 1.5px solid var(--ink);
}

/* ──────────────── Atoms: Button ──────────────── */

.pixel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--ink);
  font-family: var(--font-press);
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
  transition: transform 90ms steps(2), box-shadow 90ms steps(2);
}
.pixel-btn:disabled {
  cursor: not-allowed;
  background: var(--bg-2) !important;
  color: var(--ink-3) !important;
  box-shadow: 1px 1px 0 var(--ink) !important;
}

.pixel-btn--sm { font-size: 9px; padding: 8px 12px; box-shadow: 2px 2px 0 var(--ink); }
.pixel-btn--md { font-size: 10px; padding: 12px 18px; box-shadow: 3px 3px 0 var(--ink); }
.pixel-btn--lg { font-size: 11px; padding: 14px 22px; box-shadow: 4px 4px 0 var(--ink); }
.pixel-btn--full { width: 100%; }

.pixel-btn--primary   { background: var(--green-500);  color: #fff; }
.pixel-btn--secondary { background: var(--surface);    color: var(--ink); }
.pixel-btn--purple    { background: var(--purple-500); color: #fff; }
.pixel-btn--danger    { background: var(--red-500);    color: #fff; }
.pixel-btn--accent    { background: var(--yellow-500); color: var(--ink); }
.pixel-btn--ghost     { background: transparent;       color: var(--ink); box-shadow: none; }

.pixel-btn:not(:disabled):hover { transform: translate(-1px, -1px); }
.pixel-btn:not(:disabled):active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ──────────────── Atoms: Chip ──────────────── */

.pixel-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  font-family: var(--font-press);
  font-size: 9px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 0;
  transition: transform 90ms steps(2), box-shadow 90ms steps(2);
}
.pixel-chip--active {
  background: var(--green-500);
  color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  transform: translate(-1px, -1px);
}

.pixel-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: var(--bg-2, var(--surface));
  color: var(--ink-2);
  border: 2px solid var(--ink);
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ──────────────── Atoms: Avatar ──────────────── */

.pixel-avatar {
  position: relative;
  display: inline-block;
}
.pixel-avatar__inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-press);
  letter-spacing: 0.02em;
  border: 2px solid var(--ink);
  box-sizing: border-box;
}
.pixel-avatar__host {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 42%;
  aspect-ratio: 1;
  background: var(--yellow-500);
  color: var(--ink);
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}
.pixel-avatar__unread {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: var(--red-500);
  border: 2px solid var(--ink);
}

/* ──────────────── Atoms: Status badge ──────────────── */

.pixel-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 2px solid var(--ink);
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}
.pixel-badge--open      { background: #C8EFB0; color: #156A2C; }
.pixel-badge--filling   { background: #FFE082; color: #A87514; }
.pixel-badge--full      { background: #FCD8D6; color: #9F1A1F; }
.pixel-badge--cancelled { background: var(--bg-2); color: var(--ink-2); text-decoration: line-through; }
.pixel-badge--pending   { background: #ECDDF6; color: #4D2380; }
.pixel-badge--yours     { background: var(--purple-500); color: #fff; }

/* ──────────────── Card surfaces ──────────────── */

.pixel-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  border-radius: 0;
}
.pixel-card--yours {
  background: var(--purple-100, #ECDDF6);
}
.pixel-card--cancelled {
  opacity: 0.7;
}

.pixel-card__title {
  margin: 0;
  font-family: var(--font-press);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
}

.pixel-card__meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 12px;
}
.pixel-card__meta-dot {
  width: 3px;
  height: 3px;
  background: var(--ink-3);
}

.pixel-card__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.pixel-card__seats {
  font-family: var(--font-press);
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--green-700, var(--green-500));
}
.pixel-card__seats--yours { color: var(--purple-700, var(--purple-500)); }
.pixel-card__seats span { font-size: 12px; color: var(--ink-3); }

.pixel-stack-avatars {
  display: flex;
}
.pixel-stack-avatars > * {
  margin-left: -6px;
}
.pixel-stack-avatars > *:first-child {
  margin-left: 0;
}
.pixel-stack-avatars__empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-2);
  border: 2px dashed var(--ink);
  color: var(--ink-3);
  font-family: var(--font-press);
  font-size: 10px;
  margin-left: -6px;
  box-sizing: border-box;
}

/* ──────────────── Section heading & filters ──────────────── */

.app-section-heading {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-section-heading__eyebrow {
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.app-section-heading__title {
  margin: 0;
  font-family: var(--font-press);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
}

.app-filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px 4px;
}
.app-filter-bar::-webkit-scrollbar {
  display: none;
}

/* ──────────────── Empty state ──────────────── */

.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  background: var(--surface);
  border: 2px dashed var(--ink-3);
  text-align: center;
  color: var(--ink-2);
}
.app-empty__title {
  margin: 0;
  font-family: var(--font-press);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
}

/* ──────────────── Participant row (table detail) ──────────────── */

.participant-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--ink-3);
}
.participant-row:last-child {
  border-bottom: 0;
}

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

.participant-row__name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-row__tag {
  display: inline-block;
  padding: 2px 6px;
  background: var(--purple-100);
  color: var(--purple-700);
  font-family: var(--font-press);
  font-size: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
}

.participant-row__meta {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-2);
}

/* ── Chat ───────────────────────────────────────────── */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 56px - 64px); /* topbar + bottomnav */
  margin: -12px -12px 0;
  background: var(--bg);
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-divider {
  align-self: center;
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 4px 10px;
  margin: 6px 0 2px;
}

.chat-sys {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  background: var(--surface-2, #f3efe6);
  padding: 4px 10px;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  text-transform: uppercase;
}

.chat-sys__sep { opacity: 0.5; }
.chat-sys__actor { color: var(--ink); }

.chat-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-msg--mine {
  flex-direction: row-reverse;
}

.chat-msg__col {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}

.chat-msg__bubble {
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-msg__bubble--mine {
  background: var(--green-500);
  color: #fff;
}

.chat-msg__bubble--pending {
  opacity: 0.6;
}

.chat-msg__author {
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.chat-msg__body {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg__time {
  font-family: var(--font-press);
  font-size: 8px;
  color: var(--ink-3);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

.chat-msg--mine .chat-msg__time {
  text-align: right;
}

.chat-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 2px solid var(--ink);
}

.chat-composer__input {
  flex: 1;
  resize: none;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 20px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  outline: none;
  max-height: 120px;
  min-height: 40px;
}

.chat-composer__input:disabled {
  opacity: 0.6;
}

.chat-composer__send {
  width: 44px;
  height: 44px;
  background: var(--green-500);
  color: #fff;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-composer__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-composer__send:not(:disabled):active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ── Unread indicators ──────────────────────────────── */
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--red-500);
  border: 2px solid var(--ink);
  border-radius: 0;
  flex-shrink: 0;
}

.unread-dot--inline {
  margin-left: 6px;
  vertical-align: middle;
}

.app-bottom-nav__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.unread-dot--nav {
  position: absolute;
  top: -4px;
  right: -6px;
}

/* ── Typing indicator ───────────────────────────────── */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 6px;
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  background: transparent;
  min-height: 18px;
}

.chat-typing__dots {
  display: inline-flex;
  gap: 3px;
}

.chat-typing__dots i {
  width: 4px;
  height: 4px;
  background: var(--ink-2);
  animation: chat-typing-blink 1.2s infinite ease-in-out;
}

.chat-typing__dots i:nth-child(2) { animation-delay: 0.2s; }
.chat-typing__dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes chat-typing-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* ── Presence bar ───────────────────────────────────── */
.chat-presence {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-presence__dot {
  width: 6px;
  height: 6px;
  background: var(--green-500);
  flex-shrink: 0;
}

.chat-presence__label {
  color: var(--ink-3);
}

.chat-presence__names {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Connection banner ──────────────────────────────── */
.chat-conn {
  padding: 6px 14px;
  font-family: var(--font-press);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-align: center;
  border-bottom: 2px solid var(--ink);
  background: var(--yellow-500);
  color: var(--ink);
}

.chat-conn--failed,
.chat-conn--unavailable,
.chat-conn--disconnected {
  background: var(--red-500);
  color: #fff;
}

.app-empty--error {
  border-color: var(--red-500);
}
.app-empty__title--error {
  color: var(--red-500);
}
.app-empty--loading {
  border-style: dashed;
  opacity: 0.85;
}

/* ── Toast stack (F3 realtime / BGF Notifications v3) ─────────
   Self-contained tone palette so toasts render identically across
   every skin (BGF v1, bitUp-soft v3, bitUp). Mirrors
   design/design_system_v3/notifications-v3.css. ───────────────── */

.app-toast-stack {
  /* tone tokens — local so the stack never depends on the active skin */
  --t-surface:    #FBFAF5;
  --t-surface-2:  #F3F1E8;
  --t-ink:        #1a1820;
  --t-ink-2:      #5A5760;
  --t-ink-3:      #8A8794;
  --t-border-strong: #A19D90;
  --t-shadow:        rgba(26, 24, 32, 0.18);
  --t-shadow-strong: rgba(26, 24, 32, 0.30);
  /* Pixel face for eyebrow/buttons. NO Press Start 2P in the chain — it has
     zero Cyrillic glyphs, so the browser falls back per-character and mixes
     fonts mid-word («смОтреть»). VT323 has full Cyrillic and renders evenly. */
  --t-pixel: "VT323", "Pixelify Sans", monospace;
  --t-body:  "Inter", "Onest", system-ui, -apple-system, sans-serif;

  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 9999;
  width: min(372px, calc(100vw - 24px));
  pointer-events: none;
}

.app-toast {
  --tone:      var(--t-ink-2);
  --tone-tint: rgba(26, 24, 32, 0.06);
  --tone-700:  #3A3742;
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 11px;
  align-items: start;
  width: 100%;
  padding: 11px 11px 13px;
  background: var(--t-surface);
  border: 1.5px solid var(--t-ink);
  border-radius: 2px;
  box-shadow: 2.5px 2.5px 0 var(--t-shadow);
  color: var(--t-ink);
  text-align: left;
  font: inherit;
  overflow: hidden;
  animation: app-toast-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.app-toast[role='button'] { cursor: pointer; }

@keyframes app-toast-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: none; }
}

@media (min-width: 480px) {
  .app-toast { animation-name: app-toast-in-right; }
  @keyframes app-toast-in-right {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
  }
}

.app-toast--success { --tone: #4FA266; --tone-tint: rgba(80,162,100,0.16);  --tone-700: #347A4D; }
.app-toast--danger  { --tone: #CC4650; --tone-tint: rgba(204,70,80,0.16);   --tone-700: #9B2A33; }
.app-toast--warning { --tone: #E8B23C; --tone-tint: rgba(232,178,60,0.20);  --tone-700: #B3801F; }
.app-toast--info    { --tone: #5A5760; --tone-tint: rgba(26,24,32,0.06);    --tone-700: #3A3742; }

/* tone rail on the left edge */
.app-toast__rail {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--tone);
}

/* icon chip */
.app-toast__icon {
  width: 32px; height: 32px;
  margin-left: 3px;
  display: flex; align-items: center; justify-content: center;
  background: var(--tone);
  color: #fff;
  border: 1.5px solid var(--t-ink);
  border-radius: 2px;
  box-shadow: 1.5px 1.5px 0 var(--t-shadow-strong);
  flex-shrink: 0;
}
.app-toast--warning .app-toast__icon { color: var(--t-ink); }

.app-toast__body { min-width: 0; padding-top: 1px; }

.app-toast__eyebrow {
  font-family: var(--t-pixel);
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tone-700);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.app-toast--info .app-toast__eyebrow { color: var(--t-ink-3); }
.app-toast__rt { color: var(--t-ink-3); letter-spacing: 0.10em; }
.app-toast__live-dot {
  width: 6px; height: 6px;
  background: var(--tone);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--tone-tint);
  animation: app-toast-pulse 1.4s ease-in-out infinite;
}
@keyframes app-toast-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.app-toast__title {
  font-family: var(--t-body);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--t-ink);
}

.app-toast__hint {
  font-family: var(--t-body);
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.45;
  letter-spacing: 0;
  color: var(--t-ink-2);
}

/* action buttons */
.app-toast__actions { display: flex; gap: 8px; margin-top: 10px; }
.app-toast__btn {
  /* Body font, NOT pixel. Pixel faces (Pixelify Sans / VT323 / Press Start 2P)
     render Cyrillic unevenly — buttons carry real sentence-case words, so they
     must use the legible body font. Pixel face stays only on the short
     ALL-CAPS eyebrow. */
  font-family: var(--t-body);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0;
  padding: 7px 13px;
  border: 1.5px solid var(--t-ink);
  border-radius: 2px;
  background: var(--tone);
  color: #fff;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--t-shadow);
  transition: transform 90ms steps(2, end), box-shadow 90ms steps(2, end);
}
.app-toast--warning .app-toast__btn { color: var(--t-ink); }
.app-toast__btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0; }
.app-toast__btn--ghost {
  background: var(--t-surface);
  color: var(--t-ink-2);
  box-shadow: 1.5px 1.5px 0 var(--t-shadow);
}
.app-toast__btn--ghost:active { background: var(--t-surface-2); color: var(--t-ink); }

/* close */
.app-toast__close {
  width: 22px; height: 22px;
  margin-top: -1px; margin-right: -2px;
  display: flex; align-items: center; justify-content: center;
  background: var(--t-surface-2);
  border: 1.5px solid var(--t-border-strong);
  border-radius: 50%;
  color: var(--t-ink-3);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 100ms, color 100ms, border-color 100ms;
}
.app-toast__close:active { background: #CC4650; color: #fff; border-color: var(--t-ink); }

/* timer bar (auto-dismiss progress) */
.app-toast__timer {
  position: absolute;
  left: 5px; right: 0; bottom: 0;
  height: 3px;
  background: var(--tone);
  transform-origin: left center;
  animation: app-toast-countdown 5000ms linear forwards;
}
.app-toast:has(.app-toast__actions) .app-toast__timer {
  animation-duration: 7000ms;
}
.app-toast:hover .app-toast__timer { animation-play-state: paused; }
@keyframes app-toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ============ Modal overlay (game-picker etc) ============ */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
}

@media (min-width: 480px) {
  .app-modal-backdrop {
    align-items: center;
  }
}

.app-modal {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
}

.game-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.game-picker__header {
  padding-bottom: 4px;
  border-bottom: 2px solid var(--ink);
}

.game-picker__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 2px;
}

.game-picker__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.game-picker__item:hover {
  background: var(--surface, #fff);
}

.game-picker__item--active {
  background: var(--green-100, #d8f5cf);
  box-shadow: 0 0 0 var(--ink);
  transform: translate(2px, 2px);
}

.game-picker__item-title {
  font-family: var(--font-press);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.game-picker__item-meta {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-2);
}

/* "На модерации" inline tag — reused wherever a pending (not-yet-approved)
 * game appears in a list/picker (GamePicker rows, AddGameModal results). */
.game-mod-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  font-family: var(--font-press, 'Press Start 2P', monospace);
  font-size: 7px;
  letter-spacing: 0.04em;
  vertical-align: middle;
  color: var(--yellow-700, #7a5b00);
  background: var(--warning-tint, #fff3d6);
  border: 1px solid var(--warning, #e0a800);
  border-radius: 2px;
  white-space: nowrap;
}

.game-picker__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 2px solid var(--ink);
}

/* ---- Profile nav (links from profile to sub-pages) ---- */
.profile-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  color: var(--ink);
}

.profile-nav__link:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.profile-nav__label {
  font-family: var(--font-press);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-nav__hint {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-2);
}

/* ============ Recap (post-game) ============ */
.recap-hero {
  background: var(--yellow-500);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recap-hero--with-winner {
  background: var(--green-500);
}

.recap-hero__eyebrow {
  font-family: var(--font-press);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
  opacity: 0.7;
}

.recap-hero__title {
  font-family: var(--font-press);
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
}

.recap-hero__meta {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.recap-hero__winner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding: 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.recap-hero__crown {
  font-family: var(--font-press);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.recap-hero__winner-name {
  font-family: var(--font-press);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  margin-top: 2px;
}

.recap-leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.recap-leaderboard__row {
  display: grid;
  grid-template-columns: 110px auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}

.recap-leaderboard__place {
  font-family: var(--font-press);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}

.recap-leaderboard__name {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.recap-cta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--yellow-500);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-press);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.recap-cta:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}
