/* ============================================================
   MYO RUNNER — game-only styles
   Site shell (tokens, topbar, footer, background, content-wrap,
   buttons, modals base) comes from site/base.css, site/layout.css,
   site/site-components.css, site/background.css — copied verbatim
   from myu.to. This file ONLY styles the game itself:
   pre-game card, canvas wrap, in-game HUD, overlays, game modals.
   --f-game (Orbitron) is used solely for in-game overlays & HUD.
   ============================================================ */

:root {
  --f-game:   "Orbitron", monospace;
  --c-danger: #f87171;
  --canvas-w: 1100px;
  --hud-h:    38px;
  --touch-sz: 72px;
}

/* ══════════════════════════════════════════════
   OFFLINE STATE (kill-switch выключен)
   ══════════════════════════════════════════════ */
.myo-offline {
  position: relative;
  z-index: 1;
  min-height: calc(100dvh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.myo-offline-card {
  max-width: 460px;
  text-align: center;
  background: var(--c-raised);
  border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.myo-offline-icon { width: 44px; height: 44px; color: var(--c-accent); }
.myo-offline-title { font-size: clamp(20px, 3vw, 26px); font-weight: 800; color: var(--c-text); }
.myo-offline-sub  { font-size: var(--fs-sm); color: var(--c-text-2); line-height: 1.6; }
.myo-offline-sub a { color: var(--c-accent); }

/* ══════════════════════════════════════════════
   APP SHELL — content sits above the live background
   body has class .page-body → padding-top:100px (site layout.css)
   ══════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100dvh - 100px);
  gap: 14px;
  position: relative;
  z-index: 1;            /* above .atm-bg (z:0) and wave canvas (z:0) */
}

body.playing.page-body { padding-top: 0; }

/* Footer above the live backgrounds (atm-bg + wave canvas at z:0) */
.footer, .footer-bottom { position: relative; z-index: 1; }

/* ── Pre-game zone (slides away when playing) ──────────────── */
#pre-game {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  transition: opacity .35s ease, transform .35s ease;
}

.pre-game-main {
  position: relative;
  z-index: 1;
  padding: 24px 0 0;
  display: flex;
  flex-direction: column;
}

/* ── Announcement bar ─────────────────────────────────────── */
#announcement {
  position: relative;
  z-index: 1;
  background: var(--c-raised);
  border-bottom: 1px solid var(--c-stroke);
  padding: 11px 0;
}
.ann-text {
  font-size: var(--fs-sm);
  color: var(--c-text-2);
  line-height: 1.55;
  text-align: center;
}
.ann-brand { color: var(--c-accent); font-weight: 700; }

/* ══════════════════════════════════════════════
   MYO-PROMO — баннер активного челленджа
   ══════════════════════════════════════════════ */
.myo-challenge {
  width: 100%;
  max-width: var(--canvas-w);
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--c-accent-s);
  border: 1px solid var(--c-accent-m);
  border-radius: var(--r-lg);
  padding: 14px 18px;
}
.myo-challenge-ico { width: 26px; height: 26px; color: var(--c-accent); flex: none; }
.myo-challenge-title { font-weight: 800; color: var(--c-text); font-size: 15px; }
.myo-challenge-cond  { font-size: var(--fs-sm); color: var(--c-text-2); margin-top: 2px; }
.myo-challenge-deadline { font-family: var(--f-mono); color: var(--c-muted); }
.myo-challenge-desc  { font-size: 12px; color: var(--c-muted); margin-top: 4px; }

/* ══════════════════════════════════════════════
   GAME CARD  (myu.to card language)
   ══════════════════════════════════════════════ */
#game-card {
  width: 100%;
  max-width: var(--canvas-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  background: var(--c-raised);
  border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-xl);
  padding: 20px 24px;
}
.gc-icon {
  width: 100px; height: 100px;
  border-radius: var(--r-xl);
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid var(--c-stroke-s);
  box-shadow: var(--shadow-md);
  align-self: flex-start;
}
.gc-info   { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.gc-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gc-title {
  font-family: var(--f-ui);
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -.02em;
  line-height: 1.15;
}
.gc-badge {
  background: var(--c-accent-s);
  border: 1px solid var(--c-accent-m);
  color: var(--c-accent);
  font-size: 10px;
  font-family: var(--f-mono);
  letter-spacing: .12em;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  text-transform: uppercase;
}
.gc-desc   { font-family: var(--f-ui); font-size: var(--fs-base); color: var(--c-text-2); line-height: 1.6; }
.gc-author { font-size: var(--fs-xs); font-family: var(--f-mono); color: var(--c-muted); letter-spacing: .06em; }

/* Pre-game actions (рейтинг / переименовать) — как было в оригинале */
.gc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.gc-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.gc-actions .btn svg, .gc-actions .btn [data-lucide] { width: 15px; height: 15px; }
.gc-player-tag {
  font-size: var(--fs-xs); font-family: var(--f-mono); color: var(--c-muted);
  letter-spacing: .02em; margin-left: 4px; white-space: nowrap;
}

/* Бейдж «привязан к myu.to» в таблице рекордов */
.lb-nick { display: inline-flex; align-items: center; gap: 6px; }
.lb-linked { width: 14px; height: 14px; color: var(--c-accent); flex-shrink: 0; }

/* Ачивки в таблице рекордов: несколько крупных медалей + «+N» с коллекцией */
.lb-ach { position: relative; display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; color: var(--c-warn); cursor: pointer; vertical-align: middle; }
.lb-ach-ico-inline { width: 26px; height: 26px; object-fit: contain; flex: none; }
.lb-ach-more {
  font-size: 11px; font-family: var(--f-mono); color: var(--c-muted);
  background: var(--c-high); border-radius: var(--r-pill); padding: 2px 7px; line-height: 1;
}
.lb-ach-pop {
  /* fixed, иначе scroll-контейнер таблицы (.board-scroll, overflow) обрезает
     попап. Координаты (top/bottom/left) выставляет _placeAchPop в block6. */
  position: fixed; z-index: 300;
  display: none; flex-direction: column; gap: 12px; min-width: 300px;
  background: var(--c-raised); border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 16px 18px;
  /* Не вылезать за экран: ограничиваем высоту и скроллим коллекцию внутри */
  max-height: min(60vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.lb-ach-pop::-webkit-scrollbar { width: 6px; }
.lb-ach-pop::-webkit-scrollbar-thumb { background: var(--c-stroke-s); border-radius: 999px; }
.lb-ach.open .lb-ach-pop { display: flex; }
.lb-ach-pop-title { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--c-muted); font-family: var(--f-mono); }
.lb-ach-item { display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--c-text); white-space: nowrap; }
.lb-ach-ico { width: 100px; height: 100px; color: var(--c-accent); flex: none; object-fit: contain; }

/* Полученные ачивки на экране Game Over */
.go-achievements { display: none; flex-direction: column; align-items: center; gap: 8px; }
.go-ach-head { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--c-warn); font-family: var(--f-mono); }
.go-ach-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.go-ach-badge {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--c-warn-s); border: 1px solid rgba(251,191,36,.3);
  color: var(--c-warn); border-radius: var(--r-pill); padding: 7px 16px 7px 8px;
  font-size: 13px; font-family: var(--f-mono);
  animation: pulse-rec .65s ease-in-out infinite alternate;
}
.go-ach-ico { width: 30px; height: 30px; object-fit: contain; }

@media (max-width: 640px) {
  #game-card { padding: 16px 18px; gap: 14px; }
  .gc-icon   { width: 80px; height: 80px; border-radius: var(--r-lg); }
  .gc-desc   { font-size: var(--fs-sm); }
}
@media (max-width: 400px) {
  .gc-title { font-size: 19px; }
  .gc-icon  { width: 68px; height: 68px; }
}

/* ══════════════════════════════════════════════
   PORTRAIT PLAY BUTTON
   ══════════════════════════════════════════════ */
#portrait-play-wrap {
  display: none;
  width: 100%;
  max-width: var(--canvas-w);
  margin: 0 auto;
  padding: 16px 0 0;
}
#portrait-play-btn {
  width: 100%;
  background: var(--c-accent);
  color: #fff;
  border: none;
  padding: 16px;
  font-family: var(--f-game);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: filter var(--t-fast), transform var(--t-fast);
  animation: blink-cta 1.3s ease-in-out infinite;
}
#portrait-play-btn:hover  { filter: brightness(1.1); }
#portrait-play-btn:active { transform: scale(.97); }

body.portrait-lock #game-wrap          { display: none; }
body.portrait-lock #portrait-play-wrap { display: block; }

/* ══════════════════════════════════════════════
   GAME WRAP + CANVAS
   ══════════════════════════════════════════════ */
#game-wrap {
  position: relative;
  width: 100%;
  max-width: var(--canvas-w);
  margin: 0 auto;
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow:
    0 0 0 1px var(--c-stroke-s),
    var(--shadow-lg),
    0 0 80px rgba(229,56,59,.04);
  transition: transform .35s cubic-bezier(.4,0,.2,1),
              border-radius .35s ease,
              box-shadow .35s ease;
  transform-origin: 0 0;
}
#gc { display: block; width: 100%; height: auto; image-rendering: auto; }

/* ── Playing mode — game goes fullscreen ──────────────────── */
body.playing { overflow: hidden; background: #000; }
body.playing .topbar  { display: none; }
body.playing .footer,
body.playing .footer-bottom { display: none; }
body.playing .atm-bg  { display: none; }
body.playing #pre-game {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
}
body.playing #game-wrap {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  border-radius: 0;
  box-shadow: none;
  max-width: none;
  margin: 0;
  transform: none !important;
}
body.playing #gc { display: block; width: 100%; height: 100%; image-rendering: auto; }

/* ══════════════════════════════════════════════
   IN-GAME HUD  (over canvas — game feel)
   ══════════════════════════════════════════════ */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  pointer-events: none;
  z-index: 30;
}
body.playing #hud {
  top: 3.33vh;
  height: 10.95vh;
  padding: 0 clamp(10px, 1.5vw, 28px);
}
body.playing .hud-btn {
  width:  calc(10.95vh - 4px);
  height: calc(10.95vh - 4px);
  max-width: 54px; max-height: 54px;
  min-width: 28px; min-height: 28px;
  font-size: clamp(13px, 1.3vw, 22px);
  border-radius: clamp(6px, 0.5vw, 10px);
}
body.playing #hud-player { font-size: clamp(11px, 1vw, 16px); }

#hud-left, #hud-right { display: flex; align-items: center; gap: 4px; pointer-events: auto; }

#hud-player {
  font-size: 12px;
  color: rgba(255,255,255,.55);
  letter-spacing: 1px;
  font-family: var(--f-mono);
  white-space: nowrap;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
#hud-player:hover  { color: var(--c-accent); border-color: var(--c-accent-m); background: var(--c-accent-s); }
#hud-player:active { color: var(--c-accent); }

.hud-sep {
  display: inline-block;
  width: 1px; height: 18px;
  background: rgba(255,255,255,.15);
  margin: 0 4px;
  flex-shrink: 0;
}

.hud-btn {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.75);
  cursor: pointer;
  border-radius: 6px;
  width: 30px; height: 30px;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1;
}
.hud-btn:hover  { background: var(--c-accent-s); border-color: var(--c-accent); color: #fff; }
.hud-btn.active { background: var(--c-accent-m); border-color: var(--c-accent); color: #fff; }
.hud-btn.muted  { opacity: .45; }
.hud-btn svg, .hud-btn [data-lucide] { width: 1.05em; height: 1.05em; }

#help-btn      { font-family: var(--f-game); font-size: 12px; font-weight: 700; }

/* ══════════════════════════════════════════════
   TOUCH CONTROLS
   ══════════════════════════════════════════════ */
#touch-controls {
  position: absolute;
  bottom: 12px; left: 0; right: 0;
  display: none;
  justify-content: space-between;
  padding: 0 16px;
  pointer-events: none;
  z-index: 10;
}
body.has-touch #touch-controls { display: flex; }

.touch-btn {
  pointer-events: auto;
  width: var(--touch-sz); height: var(--touch-sz);
  border-radius: 50%;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.8);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background .12s, border-color .12s, transform .08s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.touch-btn:active { background: var(--c-accent-s); border-color: var(--c-accent); transform: scale(.93); }
.touch-icon  { width: 22px; height: 22px; line-height: 1; }
.touch-icon svg { width: 100%; height: 100%; }
.touch-label { font-size: 9px; letter-spacing: 1px; opacity: .6; font-family: var(--f-mono); }

/* ══════════════════════════════════════════════
   OVERLAYS (inside #game-wrap — game feel)
   ══════════════════════════════════════════════ */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8,8,18,.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
  z-index: 20;
}
.overlay.active { opacity: 1; pointer-events: auto; }

.ov-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 32px 24px;
}

.ctrl-hint {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--c-muted);
  font-size: 12px;
  letter-spacing: .4px;
}
.ctrl-hint span { display: flex; align-items: center; gap: 5px; }

kbd {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--c-text-2);
}

.start-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--c-accent);
  letter-spacing: 3px;
  font-family: var(--f-game);
  text-shadow: 0 0 22px var(--c-accent);
  animation: blink-cta 1.3s ease-in-out infinite;
}
.start-cta svg { width: 1em; height: 1em; }
@keyframes blink-cta { 0%,100%{opacity:1} 50%{opacity:.2} }

.pause-title {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-game);
  font-size: clamp(20px, 3.5vw, 32px);
  letter-spacing: 4px;
  color: var(--c-text);
}
.pause-title svg { width: .8em; height: .8em; }
.pause-hint { font-size: 13px; color: var(--c-muted); letter-spacing: .4px; }

.gameover-title {
  font-family: var(--f-game);
  font-size: clamp(22px, 4vw, 38px);
  letter-spacing: 4px;
  color: var(--c-danger);
  text-shadow: 0 0 24px rgba(248,113,113,.5);
}

.new-record {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--c-warn);
  letter-spacing: 2px;
  animation: pulse-rec .65s ease-in-out infinite alternate;
  font-family: var(--f-game);
}
.new-record svg { width: 1em; height: 1em; }
@keyframes pulse-rec { from{opacity:.55} to{opacity:1} }
.new-record.hidden { display: none; }

.score-row   { display: flex; align-items: baseline; gap: 12px; }
.score-label { font-size: 11px; color: var(--c-muted); letter-spacing: 2.5px; font-family: var(--f-mono); }
.score-val   { font-family: var(--f-game); font-size: clamp(34px,6vw,44px); font-weight: 700; color: #fff; }

.go-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }

.unreg-record {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--c-warn-s);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--c-warn);
  letter-spacing: .4px;
  font-family: var(--f-mono);
}
.unreg-record svg { width: 1.05em; height: 1.05em; flex-shrink: 0; }
.unreg-record.hidden { display: none; }

/* ══════════════════════════════════════════════
   OVERLAY / GAME BUTTONS  (mirror site .btn language)
   ══════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--c-accent);
  color: #fff;
  border: none;
  padding: 10px 26px;
  font-family: var(--f-ui);
  font-size: var(--fs-base);
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: filter var(--t-fast), transform var(--t-fast);
}
.btn-primary:hover  { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.96); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent;
  color: var(--c-text-2);
  border: 1px solid var(--c-stroke-s);
  padding: 10px 26px;
  font-family: var(--f-ui);
  font-size: var(--fs-base);
  font-weight: 500;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.btn-ghost:hover { border-color: var(--c-accent); color: var(--c-text); background: var(--c-accent-s); }
.btn-primary svg, .btn-ghost svg { width: 1em; height: 1em; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* Кнопки в оверлеях всегда на тёмной подложке (rgba(8,8,18,.82)) — фиксированные
   светлые цвета независимо от темы, иначе в светлой теме текст становится тёмным
   на тёмном фоне и нечитаем. */
.overlay .btn-ghost {
  color: rgba(255,255,255,.72);
  border-color: rgba(255,255,255,.22);
  background: transparent;
}
.overlay .btn-ghost:hover {
  color: #fff;
  border-color: var(--c-accent);
  background: rgba(229,56,59,.16);
}

/* ══════════════════════════════════════════════
   GAME MODALS  (own show/hide via .hidden — block6 JS)
   styled to match site .modal language using tokens
   ══════════════════════════════════════════════ */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  animation: fade-in .18s ease;
}
.modal-back.hidden { display: none; }
@keyframes fade-in { from{opacity:0} to{opacity:1} }

.modal-box {
  background: var(--c-raised);
  border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-xl);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: slide-up .18s ease;
  /* Не вылезать за экран при длинном содержимом (рейтинг, длинные формы).
     32px = вертикальный padding .modal-back (16px сверху + снизу). */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.modal-wide { max-width: 540px; }
@keyframes slide-up { from{transform:translateY(12px);opacity:0} to{transform:translateY(0);opacity:1} }

.modal-box h3 {
  font-family: var(--f-ui);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--c-text);
}
.modal-sub { font-family: var(--f-ui); font-size: var(--fs-sm); color: var(--c-text-2); line-height: 1.55; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.modal-box input[type=text] {
  background: var(--c-base);
  border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--c-text);
  font-family: var(--f-mono);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color var(--t-base), box-shadow var(--t-base);
  width: 100%;
}
.modal-box input[type=text]:focus { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-s); }

.modal-box textarea {
  background: var(--c-base);
  border: 1px solid var(--c-stroke-s);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--c-text);
  font-family: var(--f-ui);
  font-size: var(--fs-base);
  outline: none;
  width: 100%;
  resize: vertical;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.modal-box textarea:focus { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-s); }
/* В форме поддержки поля идут столбиком с воздухом */
#modal-support .modal-box, #modal-link .modal-box { gap: 12px; }
/* Поля внутри #support-form — своя обёртка, поэтому gap модалки до них не доходит:
   задаём вертикальный воздух между инпутами/textarea/кнопками тут. */
#support-form { display: flex; flex-direction: column; gap: 12px; }

/* override base.css .field-err (max-height:0) — game reveals errors via textContent */
.field-err { font-size: 12px; color: var(--c-danger); min-height: 16px; max-height: none; overflow: visible; margin-top: 0; font-family: var(--f-ui); }
.modal-row { display: flex; gap: 10px; flex-wrap: wrap; }

.icon-btn {
  background: none;
  border: 1px solid var(--c-stroke-s);
  color: var(--c-muted);
  cursor: pointer;
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--c-text); border-color: var(--c-text-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* ── Leaderboard ── */
.board-loading { text-align:center; color:var(--c-muted); padding:20px 0; font-size:var(--fs-sm); font-family:var(--f-mono); }
#board-table { width:100%; border-collapse:collapse; font-size:var(--fs-base); font-family:var(--f-ui); }
#board-table.hidden { display:none; }
/* Рейтинг: шапка модалки и подпись закреплены, листается только список рекордов.
   modal-box не скроллим (overflow:hidden), вместо него — .board-scroll. */
#modal-board .modal-box { overflow: hidden; }
.board-scroll { overflow-y: auto; min-height: 0; flex: 0 1 auto; margin: 0 -6px; padding: 0 6px; }
#board-table thead th { position: sticky; top: 0; z-index: 1; background: var(--c-raised); }
#board-table th {
  text-align:left; padding:6px 12px;
  font-size:10px; letter-spacing:.1em; text-transform:uppercase;
  color:var(--c-muted); border-bottom:1px solid var(--c-stroke);
  font-family:var(--f-mono);
}
#board-table td { padding:9px 12px; border-bottom:1px solid var(--c-stroke); }
#board-table tr:last-child td { border-bottom:none; }
#board-table tr.me td { color:var(--c-accent); }
.my-rank { font-size:12px; color:var(--c-muted); padding-top:10px; letter-spacing:.02em; font-family:var(--f-mono); }
.my-rank.hidden { display:none; }
.board-note { font-size:11px; color:var(--c-muted); border-top:1px solid var(--c-stroke); padding-top:10px; font-family:var(--f-ui); }

/* ── Help modal ── */
.help-content { display:flex; flex-direction:column; gap:14px; }
.help-section h4 {
  font-size:10px; letter-spacing:.1em; text-transform:uppercase;
  color:var(--c-muted); margin-bottom:8px; font-family:var(--f-mono);
}
.help-section--gap { margin-top:12px; }
.help-device { font-size:12px; color:var(--c-text-2); letter-spacing:.02em; margin-bottom:8px; font-family:var(--f-mono); }
.help-table { width:100%; border-collapse:collapse; font-size:var(--fs-sm); font-family:var(--f-ui); }
.help-table td { padding:5px 8px; }
.help-table td:first-child { white-space:nowrap; padding-right:16px; }
.rename-current { color:var(--c-accent); font-family:var(--f-mono); font-size:12px; }

/* ══════════════════════════════════════════════
   SETTINGS MODAL
   ══════════════════════════════════════════════ */
.modal-settings-box { max-width:520px; gap:18px; padding:32px; }
.modal-settings-box .modal-head h3 { font-size:18px; font-weight:700; }
.settings-row--toggle { display:flex; align-items:center; gap:12px; padding:4px 0; }

.settings-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--c-high);
  border: 1px solid var(--c-stroke-s);
  color: var(--c-text);
  border-radius: var(--r-pill);
  padding: 8px 18px 8px 14px;
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.settings-toggle:hover { border-color:var(--c-accent); color:var(--c-accent); }
.settings-toggle--off  { background:var(--c-accent-s); border-color:var(--c-accent-m); color:var(--c-accent); }
.settings-toggle svg   { width:16px; height:16px; }

.settings-divider { height:1px; background:var(--c-stroke); margin:4px 0; }
.settings-sliders { display:flex; flex-direction:column; gap:16px; transition:opacity .2s; }
.settings-row { display:flex; align-items:center; gap:12px; }
.settings-label {
  flex: 1;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--f-ui);
}
.settings-row--toggle .settings-label { font-size:15px; }
.settings-val { width:44px; text-align:right; font-size:13px; font-weight:600; color:var(--c-text-2); font-family:var(--f-mono); flex-shrink:0; }

input[type=range].settings-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
  --val: 1;
  background: linear-gradient(
    to right,
    var(--c-accent) 0%,
    var(--c-accent) calc(var(--val) * 100%),
    var(--c-stroke-s) calc(var(--val) * 100%),
    var(--c-stroke-s) 100%
  );
  transition: opacity .2s;
}
input[type=range].settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width:18px; height:18px; border-radius:50%;
  background:var(--c-accent); border:2px solid rgba(255,255,255,.25);
  box-shadow:0 0 8px var(--c-accent-m); cursor:pointer;
  transition:transform var(--t-fast), box-shadow var(--t-fast);
}
input[type=range].settings-slider::-webkit-slider-thumb:hover { transform:scale(1.15); box-shadow:0 0 14px var(--c-accent-m); }
input[type=range].settings-slider::-moz-range-thumb {
  width:18px; height:18px; border-radius:50%;
  background:var(--c-accent); border:2px solid rgba(255,255,255,.25); cursor:pointer;
}
input[type=range].settings-slider::-moz-range-track { height:4px; border-radius:var(--r-pill); background:var(--c-stroke-s); }

@media (max-width:480px) {
  .modal-settings-box { padding:22px 18px; gap:14px; }
  .settings-label { font-size:13px; }
  .settings-row   { flex-wrap:wrap; gap:8px; }
  .settings-row .settings-val    { order:2; }
  .settings-row .settings-slider { order:3; flex:0 0 100%; height:6px; }
  input[type=range].settings-slider::-webkit-slider-thumb { width:24px; height:24px; }
  input[type=range].settings-slider::-moz-range-thumb     { width:24px; height:24px; }
}

/* ══════════════════════════════════════════════
   ROTATE MODAL
   ══════════════════════════════════════════════ */
.modal-rotate-box { max-width:340px; align-items:center; text-align:center; gap:20px; padding:36px 28px; }
.rotate-hint { font-family:var(--f-ui); font-size:clamp(15px,4vw,18px); font-weight:600; color:var(--c-text); line-height:1.35; }
.rotate-sub  { font-size:12px; color:var(--c-muted); font-family:var(--f-mono); }
.rotate-anim-wrap { width:140px; height:140px; flex-shrink:0; }
.rotate-svg { width:100%; height:100%; overflow:visible; }

@keyframes ra-phone-anim {
  0%  { opacity:0; transform:rotate(0deg);   }
  7%  { opacity:1; transform:rotate(0deg);   }
  48% { opacity:1; transform:rotate(0deg);   }
  56% { opacity:1; transform:rotate(-90deg); }
  70% { opacity:0; transform:rotate(-90deg); }
  99% { opacity:0; transform:rotate(-90deg); }
  100%{ opacity:0; transform:rotate(0deg);   }
}
@keyframes ra-arc-anim {
  0%  { stroke-dashoffset:100; opacity:0; }
  21% { stroke-dashoffset:100; opacity:0; }
  22% { stroke-dashoffset:100; opacity:1; }
  42% { stroke-dashoffset:0;   opacity:1; }
  49% { stroke-dashoffset:0;   opacity:0; }
  100%{ stroke-dashoffset:0;   opacity:0; }
}
@keyframes ra-head-anim {
  0%{opacity:0} 41%{opacity:0} 42%{opacity:1} 49%{opacity:0} 100%{opacity:0}
}
.ra-phone { transform-box:fill-box; transform-origin:center; animation:ra-phone-anim 3.4s ease-in-out infinite; }
.ra-arc   { animation:ra-arc-anim  3.4s ease-in-out infinite; }
.ra-head  { animation:ra-head-anim 3.4s ease-in-out infinite; }

/* ══════════════════════════════════════════════
   RESPONSIVE — game content
   ══════════════════════════════════════════════ */
@media (max-width: 640px) {
  .pre-game-main { padding: 20px 0 24px; }
  .ctrl-hint { flex-direction:column; gap:6px; align-items:center; }
  .modal-box { padding:20px 16px; }
  .go-btns   { flex-direction:column; align-items:stretch; width:100%; }
  .go-btns .btn-primary,
  .go-btns .btn-ghost   { text-align:center; }
  :root { --touch-sz: 64px; }
}
@media (max-width: 400px) { :root { --touch-sz: 58px; } }

@supports (padding: env(safe-area-inset-bottom)) {
  body.playing #touch-controls { bottom: calc(12px + env(safe-area-inset-bottom)); }
}
