  :root {
    --bg: #1d1c18;
    --fg: #f1efe4;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: var(--ib, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --bg: #0b0b0a; --fg: #f1efe4; }
  }
  :root[data-theme="dark"] { --bg: #0b0b0a; --fg: #f1efe4; }
  html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
  html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  canvas {
    display: block;
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
  }
  svg.ic { width: 1.1em; height: 1.1em; flex: none; display: block; }
  #snd, #top, #boardClose, #pad button { display: flex; align-items: center; justify-content: center; }
  #top { gap: 6px; }
  button { cursor: pointer; }
  button:disabled { cursor: default; }
  #boardHead .bh { display: flex; align-items: center; gap: 8px; }
  #pad button svg.ic { width: 1.25em; height: 1.25em; stroke-width: 2.6; }
  #top {
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: calc(var(--ib, 0px) + 10px);
    height: 44px; padding: 0 14px;
    border: 0; border-radius: 10px;
    background: none;
    color: #f2d23a;
    font: bold 20px "Courier New", monospace;
    z-index: 5;
    display: none;
  }
  body.ctl #top { bottom: calc(var(--ib, 0px) + 146px); }
  [hidden] { display: none !important; }
  /* «Похвастаться» и «В историю» (VK, Одноклассники): в Telegram вместо них главная кнопка площадки */
  #actions {
    position: fixed;
    left: 50%; transform: translateX(-50%);
    bottom: calc(var(--ib, 0px) + 60px);
    display: none; gap: 10px;
    z-index: 5;
  }
  body.ctl #actions { bottom: calc(var(--ib, 0px) + 196px); }
  #share, #story {
    height: 44px; padding: 0 18px;
    border-radius: 10px;
    font: bold 16px "Courier New", monospace;
    white-space: nowrap;
    display: none; align-items: center; justify-content: center;
  }
  #share { border: 0; background: #c42f2a; color: #fff; }
  #story { border: 2px solid #f2d23a; background: rgba(0,0,0,.45); color: #f2d23a; }
  #top:focus-visible, #boardClose:focus-visible, #share:focus-visible, #story:focus-visible,
  #support:focus-visible, #community:focus-visible, #boardTabs button:focus-visible { outline: 2px solid #f2d23a; outline-offset: 2px; }
  /* вызов друга: плашка вверху заставки и экрана конца */
  #challenge {
    position: fixed; left: 50%; transform: translateX(-50%);
    top: calc(var(--it, 0px) + 64px);
    max-width: min(92vw, 360px); box-sizing: border-box; padding: 6px 12px;
    border: 1px solid #f2d23a; border-radius: 10px;
    background: rgba(0,0,0,.6); color: #f2d23a;
    font: bold 14px "Courier New", monospace; text-align: center; overflow-wrap: anywhere;
    pointer-events: none; z-index: 4;
    display: none;
  }
  #challenge.open { display: block; }
  /* возрастной знак справа внизу и ссылки слева друг под другом; посередине остаётся кнопка «Топ» */
  #legal {
    position: fixed; left: 10px; right: 10px;
    bottom: calc(var(--ib, 0px) + 12px);
    display: none; align-items: center; justify-content: space-between;
    pointer-events: none; z-index: 5;
  }
  body.ctl #legal { bottom: calc(var(--ib, 0px) + 150px); }
  #legalLinks { display: flex; flex-direction: column; align-items: flex-start; }
  #age {
    margin-left: auto;   /* справа, даже когда ссылок нет */
    padding: 2px 8px; border: 1.5px solid rgba(255,255,255,.6); border-radius: 6px;
    color: rgba(255,255,255,.85); font: bold 13px "Courier New", monospace;
    text-shadow: 1px 1px 0 rgba(0,0,0,.9);
  }
  #support, #community {
    -webkit-appearance: none; appearance: none; pointer-events: auto;
    min-height: 24px; padding: 2px 6px; border: 0; background: transparent !important;
    color: rgba(255,255,255,.7); font: 13px "Courier New", monospace; text-decoration: underline;
    text-shadow: 1px 1px 0 rgba(0,0,0,.9);
  }
  /* пояснение к возрастному знаку при самом первом запуске */
  #ageNote {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: calc(var(--ib, 0px) + 56px);
    max-width: min(88vw, 340px); box-sizing: border-box; padding: 8px 12px;
    border-radius: 10px; background: rgba(0,0,0,.78); color: #f1efe4;
    font: 13px "Courier New", monospace; text-align: center;
    z-index: 6; display: none;
  }
  #ageNote.open { display: block; }
  body.ctl #ageNote { bottom: calc(var(--ib, 0px) + 190px); }
  #board {
    position: fixed; inset: 0; z-index: 10;
    display: none;
    background: rgba(0,0,0,.82);
    align-items: center; justify-content: center;
  }
  #board.open { display: flex; }
  #revive {
    position: fixed; inset: 0; z-index: 11;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.78);
  }
  #revive.open { display: flex; }
  #reviveBox {
    width: min(86vw, 340px); padding: 20px 18px;
    display: flex; flex-direction: column; gap: 12px; text-align: center;
    background: #1d1c18; border: 2px solid #f2d23a; border-radius: 12px;
    font-family: "Courier New", monospace; color: #f1efe4;
  }
  #reviveTitle { font-weight: bold; font-size: 22px; color: #f2d23a; }
  #reviveText { font-size: 14px; line-height: 1.4; }
  #reviveYes, #reviveNo { -webkit-appearance: none; appearance: none; font: bold 17px "Courier New", monospace; border-radius: 10px; min-height: 46px; }
  #reviveYes { display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: #f2d23a; color: #1d1c18; }
  #reviveNo { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #f1efe4; font-size: 15px; }
  #reviveYes:disabled, #reviveNo:disabled { opacity: .5; }
  /* приз: окно победителя и строка над таблицей */
  #prize {
    position: fixed; inset: 0; z-index: 11;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.78);
  }
  #prize.open { display: flex; }
  #prizeBox {
    width: min(86vw, 340px); padding: 20px 18px;
    display: flex; flex-direction: column; gap: 12px; text-align: center;
    background: #1d1c18; border: 2px solid #f2d23a; border-radius: 12px;
    font-family: "Courier New", monospace; color: #f1efe4;
  }
  #prizeTitle { font-weight: bold; font-size: 22px; color: #f2d23a; }
  #prizeText { font-size: 14px; line-height: 1.4; }
  #prizeCode { font: bold 26px "Courier New", monospace; letter-spacing: 2px; color: #f2d23a; -webkit-user-select: text; user-select: text; }
  #prizeWrite, #prizeRules, #prizeClose { -webkit-appearance: none; appearance: none; font: bold 16px "Courier New", monospace; border-radius: 10px; min-height: 44px; }
  #prizeWrite { border: 0; background: #f2d23a; color: #1d1c18; }
  #prizeRules, #prizeClose { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #f1efe4; font-size: 14px; }
  #boardPrize { margin: 8px 14px 0; padding: 8px 10px; border: 1px solid rgba(242,210,58,.5); border-radius: 8px; background: rgba(242,210,58,.08); font-size: 12px; line-height: 1.45; }
  #boardPrizeRules { -webkit-appearance: none; appearance: none; padding: 0; border: 0; background: none; color: #f2d23a; font: bold 12px "Courier New", monospace; text-decoration: underline; }
  #boardBox {
    width: min(92vw, 380px); max-height: 86vh;
    display: flex; flex-direction: column;
    background: #1d1c18; border: 2px solid #f2d23a; border-radius: 12px;
    font-family: "Courier New", monospace; color: #f1efe4;
  }
  #boardHead { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-weight: bold; font-size: 18px; color: #f2d23a; }
  #boardClose { border: 0; background: none; color: #fff; font-size: 22px; width: 36px; height: 36px; }
  #boardTabs { display: flex; padding: 0 14px; gap: 4px; }
  #boardTabs button {
    -webkit-appearance: none; appearance: none; flex: 1;
    padding: 8px 4px; border: 0; border-bottom: 2px solid rgba(255,255,255,.15); background: transparent;
    color: #a8a597; font: bold 14px "Courier New", monospace;
  }
  #boardTabs button[aria-selected="true"] { color: #f2d23a; border-bottom-color: #f2d23a; }
  #boardInfo { padding: 8px 14px 0; font-size: 12px; color: #a8a597; text-align: center; min-height: 14px; }
  #boardInfo:empty { display: none; }
  #boardList { overflow-y: auto; touch-action: pan-y; padding: 0 14px 12px; font-size: 14px; }
  #boardMe { padding: 0 14px 12px; font-size: 14px; border-top: 1px solid rgba(242,210,58,.35); }
  #boardMe:empty { display: none; }
  .row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
  .row .n { width: 34px; color: #a8a597; }
  .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row .sc { color: #f2d23a; }
  .row.me { background: rgba(242,210,58,.14); }
  .msg { padding: 18px 0; text-align: center; color: #a8a597; }
  /* объяснение перед запросом разрешения на друзей */
  .ask { display: flex; flex-direction: column; gap: 12px; padding: 18px 0 6px; text-align: center; }
  .ask p { margin: 0; font-size: 14px; line-height: 1.4; }
  .ask button { -webkit-appearance: none; appearance: none; min-height: 46px; border-radius: 10px; font: bold 17px "Courier New", monospace; }
  .ask .yes { border: 0; background: #f2d23a; color: #1d1c18; }
  .ask .no { border: 1px solid rgba(255,255,255,.35); background: transparent; color: #f1efe4; font-size: 15px; }
  .ask button:focus-visible { outline: 2px solid #f2d23a; outline-offset: 2px; }
  #snd {
    position: fixed;
    right: 10px;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    width: 40px; height: 40px;
    border: 0; border-radius: 10px;
    background: none;
    color: #fff;
    font-size: 22px;
    z-index: 5;
  }
  /* без плашки: на телефонах кнопка по умолчанию рисуется с фоном, сбрасываем всё явно */
  #snd, #top {
    -webkit-appearance: none; appearance: none;
    background: transparent !important; background-color: transparent !important;
    box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  #snd svg, #top svg { filter: drop-shadow(1px 1px 0 rgba(0,0,0,.9)) drop-shadow(0 0 3px rgba(0,0,0,.6)); }
  #top span { text-shadow: 1px 1px 0 rgba(0,0,0,.9), 0 0 3px rgba(0,0,0,.6); }
  #snd:focus-visible { outline: 2px solid #f2d23a; outline-offset: 2px; }
  /* схема «кнопки»: внизу отдельная панель, игра поднята над ней */
  body.ctl { box-sizing: border-box; padding-bottom: 136px; }
  #panelbg, #pad { display: none; }
  body.ctl #panelbg, body.ctl #pad { display: block; }
  #panelbg {
    box-sizing: border-box;
    position: fixed; left: 0; right: 0; bottom: 0;
    height: calc(136px + var(--ib, 0px));
    background: linear-gradient(to top, rgba(8,8,7,.98), rgba(14,14,12,.92));
    border-top: 1px solid rgba(255,255,255,.14);
    z-index: 3;
    pointer-events: none;
  }
  #pad button {
    position: fixed;
    bottom: calc(var(--ib, 0px) + 34px);
    width: 72px; height: 72px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.3);
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.78);
    font-size: 28px;
    font-weight: bold;
    padding: 0;
    z-index: 4;
    touch-action: none;
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  }
  #pad button.on { background: rgba(255,255,255,.26); color: #fff; border-color: rgba(255,255,255,.7); }
  #bL { left: 16px; }
  #bR { left: 102px; }
  #bG {
    right: 18px;
    bottom: calc(var(--ib, 0px) + 18px) !important;
    width: 104px !important; height: 104px !important;
    font-size: 16px !important;
    color: rgba(255,226,120,.9) !important;
    border-color: rgba(242,210,58,.55) !important;
    background: rgba(242,210,58,.10) !important;
  }
  #bG.on { background: rgba(242,210,58,.38) !important; border-color: #f2d23a !important; color: #fff !important; }
  /* «Сдача тары» (docs/TARA.md): кнопка магазина вверху по центру (слева REC, справа звук), подсказка и окно. Элементов нет, пока
     возможность выключена: их создаёт services/meta.js */
  #shop {
    -webkit-appearance: none; appearance: none;
    position: fixed; left: 50%; transform: translateX(-50%);
    top: calc(var(--it, 0px) + 8px);
    height: 40px; padding: 0 8px; gap: 6px;
    display: none; align-items: center; justify-content: center;
    border: 0; border-radius: 10px;
    background: transparent !important; background-color: transparent !important;
    color: #f2d23a; font: bold 17px "Courier New", monospace;
    z-index: 5;
  }
  #shop.locked { color: #a8a597; }
  #shop svg { filter: drop-shadow(1px 1px 0 rgba(0,0,0,.9)) drop-shadow(0 0 3px rgba(0,0,0,.6)); }
  #shop .lb { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1; }
  #shop i { font: bold 10px "Courier New", monospace; letter-spacing: .5px; color: #f1efe4; }
  #shop b { display: flex; align-items: center; gap: 4px; }
  #shop .coin { width: 13px; height: 13px; }
  #shop i, #shop span { text-shadow: 1px 1px 0 rgba(0,0,0,.9), 0 0 3px rgba(0,0,0,.6); }
  /* есть что купить: кнопка слегка пульсирует, чтобы её заметили */
  #shop.dot { animation: shopPulse 1.6s ease-in-out infinite; }
  @keyframes shopPulse { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.09); } }
  @media (prefers-reduced-motion: reduce) { #shop.dot { animation: none; } }
  #shop.dot::after {
    content: ''; position: absolute; top: 1px; right: -5px;
    width: 10px; height: 10px; box-sizing: border-box;
    border: 1.5px solid #1d1c18; border-radius: 50%; background: #e5312b;
  }
  #shopHint {
    position: fixed; left: 50%; transform: translateX(-50%);
    top: calc(var(--it, 0px) + 54px);
    max-width: min(88vw, 320px); box-sizing: border-box; padding: 8px 12px;
    border-radius: 10px; background: rgba(0,0,0,.82); color: #f1efe4;
    font: 13px "Courier New", monospace; text-align: center;
    pointer-events: none; z-index: 6; display: none;
  }
  #shopHint.open { display: block; }
  #shopWin {
    position: fixed; inset: 0; z-index: 10;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,.82);
  }
  #shopWin.open { display: flex; }
  #shopWin canvas { position: static; transform: none; }   /* общее правило для canvas ставит игровое поле по центру экрана */
  #shopBox {
    width: min(94vw, 380px); max-height: 92vh; box-sizing: border-box;
    display: flex; flex-direction: column;
    background: #1d1c18; border: 2px solid #f2d23a; border-radius: 12px;
    font-family: "Courier New", monospace; color: #f1efe4;
  }
  #shopHead { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 14px; }
  #shopTitle { font-weight: bold; font-size: 18px; color: #f2d23a; }
  #shopClose { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: none; color: #fff; font-size: 22px; }
  #shopStage { display: flex; gap: 8px; padding: 0 12px 8px; }
  #shopTalk { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
  #shopWho { display: flex; align-items: center; gap: 8px; }
  #shopSeller { width: 56px; height: 56px; flex: none; border-radius: 8px; }
  #shopBal .lbl { font-size: 10px; color: #a8a597; }
  #shopBal .big { font-size: 15px; font-weight: bold; color: #f2d23a; }
  #shopSay { padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,.08); font-size: 12px; line-height: 1.35; }
  #shopFit { width: 88px; height: 116px; flex: none; border-radius: 8px; }
  #shopTabs { display: flex; padding: 0 12px; gap: 2px; }
  #shopTabs button {
    -webkit-appearance: none; appearance: none; flex: 1 1 auto;
    min-height: 44px; padding: 0 4px; border: 0; border-bottom: 2px solid rgba(255,255,255,.15); background: transparent;
    color: #a8a597; font: bold 14px "Courier New", monospace;
  }
  #shopTabs button[aria-selected="true"] { color: #f2d23a; border-bottom-color: #f2d23a; }
  #shopList { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 0 12px 12px; min-height: 0; }
  #shopList .it { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.08); }
  #shopList .it.tried { background: rgba(242,210,58,.1); }
  #shopList .try { display: block; flex: none; width: 48px; height: 48px; padding: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; background: none; overflow: hidden; }
  #shopList .try canvas { display: block; }
  #shopList .tx { flex: 1; min-width: 0; }
  #shopList .nm { font-size: 13px; font-weight: bold; overflow-wrap: anywhere; }
  #shopList .pr { font-size: 12px; color: #a8a597; }
  #shopList .on .pr { color: #9fd08a; }
  #shopList .more { font-size: 11px; color: #ff9a5a; }
  #shopList .act {
    -webkit-appearance: none; appearance: none; flex: none;
    min-width: 78px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px;
    background: #f2d23a; color: #1d1c18; font: bold 13px "Courier New", monospace;
  }
  #shopList .act.wear { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #f1efe4; }
  #shopList .act[aria-disabled="true"] { background: rgba(255,255,255,.1); color: #a8a597; }
  #shop:focus-visible, #shopClose:focus-visible, #shopTabs button:focus-visible, #shopList .try:focus-visible, #shopList .act:focus-visible { outline: 2px solid #f2d23a; outline-offset: 2px; }
