/* =========================================================
   Пиксель Фокус — токены дизайн-системы и базовые элементы
   NES 8-bit, тёплая ретро-палитра
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
  --bg-deep:       #2b1d2a;
  --bg-mid:        #3d2b3a;
  --bg-soft:       #5a3a52;

  --tomato:        #e84a5f;
  --tomato-dark:   #a8243a;
  --tomato-light:  #ff847c;

  --cream:         #fecea8;
  --cream-dark:    #e0a878;

  --leaf:          #99b898;
  --leaf-dark:     #5d8a6e;

  --sky:           #6fa3ef;
  --sky-dark:      #3b6bb0;

  --night:         #1a1224;
  --ink:           #1a0f18;

  /* Единый шрифт интерфейса — VT323. Пиксельный эффект «больших цифр»
     достигается за счёт большого размера (как в Gemini-референсе),
     а не отдельной гарнитурой Press Start 2P. */
  --pix-display: 'VT323', monospace;
  --pix-body:    'VT323', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-deep);
  font-family: var(--pix-body);
  color: var(--cream);
  -webkit-font-smoothing: none;
  font-smooth: never;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  overflow-x: hidden;
}

canvas, svg, img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ============= Каркас приложения ============= */

.app-root {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  position: relative;
  background: radial-gradient(ellipse at top, #3d2b3a 0%, #2b1d2a 60%, #1a1224 100%);
  overflow: hidden;
}

/* Звёздное поле (3 слоя параллакса) */
.bg-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-stars-layer {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  image-rendering: pixelated;
}
/* Бесшовная прокрутка достигается анимацией background-position
   ровно на ширину одной плитки паттерна — repeat бесшовно
   подставляет следующую копию. Период = ширина плитки. */
.bg-stars-layer.l1 {
  background-image:
    radial-gradient(2px 2px at 20px 30px, #5a3a52 50%, transparent 51%),
    radial-gradient(2px 2px at 80px 90px, #6f4863 50%, transparent 51%),
    radial-gradient(2px 2px at 130px 50px, #5a3a52 50%, transparent 51%),
    radial-gradient(2px 2px at 180px 120px, #6f4863 50%, transparent 51%),
    radial-gradient(2px 2px at 60px 160px, #5a3a52 50%, transparent 51%);
  background-size: 220px 200px;
  animation: bg-stars-drift-l1 90s linear infinite;
  opacity: 0.7;
}
.bg-stars-layer.l2 {
  background-image:
    radial-gradient(2px 2px at 40px 60px, #fecea8 50%, transparent 51%),
    radial-gradient(3px 3px at 140px 110px, #ff847c 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 180px, #fecea8 50%, transparent 51%),
    radial-gradient(2px 2px at 200px 40px, #ffb3ad 50%, transparent 51%);
  background-size: 260px 240px;
  animation: bg-stars-drift-l2 50s linear infinite;
  opacity: 0.55;
}
.bg-stars-layer.l3 {
  background-image:
    radial-gradient(3px 3px at 70px 80px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 220px 160px, #cfd9ff 50%, transparent 51%),
    radial-gradient(3px 3px at 320px 60px, #fff 50%, transparent 51%);
  background-size: 380px 260px;
  animation:
    bg-stars-drift-l3 28s linear infinite,
    bg-stars-twinkle 1.4s steps(2) infinite;
}
/* Сдвиг кратен background-size → паттерн «склеивается» сам с собой */
@keyframes bg-stars-drift-l1 {
  from { background-position: 0 0; }
  to   { background-position: -220px 0; }
}
@keyframes bg-stars-drift-l2 {
  from { background-position: 0 0; }
  to   { background-position: -260px 0; }
}
@keyframes bg-stars-drift-l3 {
  from { background-position: 0 0; }
  to   { background-position: -380px 0; }
}
@keyframes bg-stars-twinkle {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.4; }
}

.bg-mountains {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 80px;
  pointer-events: none;
  opacity: 0.4;
  z-index: 0;
}

/* Основной экран лежит над фоном.
   Квадратные пропорции 920×920 — как у винтажных ЭЛТ-мониторов.
   Если контент не помещается — внутренний скролл. */
.app-screen {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  height: 920px;
  overflow: hidden;
  background: var(--bg-mid);
  box-shadow:
    0 0 0 4px var(--ink),
    0 0 0 8px var(--cream),
    0 0 0 12px var(--ink),
    0 12px 0 12px rgba(0,0,0,0.4);
  padding: 20px 24px 18px;
  display: flex;
  flex-direction: column;
}
/* На мобильных растягиваем приложение на всю высоту экрана и
   делаем содержимое flex-распределяемым, чтобы всё уместилось
   без вертикального скролла. */
@media (max-width: 720px) {
  html, body { min-height: 0; }
  .app-root { padding: 0; min-height: 100vh; }
  .app-screen {
    height: 100vh;
    min-height: 0;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 12px;
    box-shadow: none;
  }

  /* Шапка-окно: одна строка, компактные размеры */
  .title-bar {
    flex-wrap: nowrap;
    font-size: 11px;
    gap: 3px;
    margin: -10px -12px 8px;
    padding: 4px 6px;
    letter-spacing: 0;
  }
  .title-bar .tb-left {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    font-size: 11px;
  }
  .title-bar .tb-right { font-size: 11px; gap: 3px; flex: 0 0 auto; }
  .tb-clock { font-size: 11px; letter-spacing: 0; }
  .crt-toggle { font-size: 9px; padding: 2px 3px; margin-right: 1px; gap: 2px; letter-spacing: 0; }
  .crt-toggle-led { width: 5px; height: 5px; }

  /* Табы делим поровну на 4, чтоб все умещались без скролла */
  .screen-tabs {
    margin: -8px -12px 10px;
    padding: 6px 6px 0;
    gap: 3px;
  }
  .screen-tab {
    flex: 1 1 0;
    font-size: 13px;
    padding: 6px 4px;
    text-align: center;
    letter-spacing: 0;
    min-width: 0;
  }
  .screen-tab.active::before { margin-right: 3px; }

  /* Контейнер вкладки растягивается, элементы внутри сжимаются */
  .col { gap: 8px; }
  .section-head { margin-bottom: 4px; }

  /* Карта-уровень: ниже, чтоб освободить место */
  .cycle-map { height: 150px; flex: 0 0 auto; }

  /* Таймер: занимает оставшееся место, шрифт пропорционально */
  .timer-stage { gap: 8px; flex: 1 1 auto; min-height: 0; }
  .timer-frame {
    padding: 26px 14px 22px;
    min-height: 0;
    height: auto;
    overflow: visible;
    flex: 1 1 auto;
  }
  .timer-clock { font-size: clamp(140px, 38vw, 200px); letter-spacing: 4px; }
  .timer-phase-tag { font-size: 24px; padding: 8px 18px; }
  .timer-round { font-size: 28px; }

  /* Контролы: СТАРТ по центру (ПРОПУСТИТЬ, СТАРТ, СБРОС).
     Старт большой с текстом; пропустить и сброс — только иконки. */
  .controls-row { gap: 6px; margin-top: 6px; flex: 0 0 auto; align-items: stretch; }
  .controls-row .pix-btn:nth-child(1) { order: 2; }
  .controls-row .pix-btn:nth-child(2) { order: 1; }
  .controls-row .pix-btn:nth-child(3) { order: 3; }
  .pix-btn { padding: 8px 10px; font-size: 14px; }
  .pix-btn-primary {
    flex: 1 1 auto;
    font-size: 18px;
    padding: 10px 14px;
  }
  .pix-btn-compact {
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 20px;
  }
  .pix-btn-compact .pix-btn-label { display: none; }
  .pix-btn-compact .pix-btn-icon { font-size: 22px; }
  .stats-bar { gap: 6px; margin: 4px 0 0; flex: 0 0 auto; }
  .stat-card { padding: 6px 4px; }
  .stat-card-label { font-size: 12px; margin-bottom: 2px; }
  .stat-card-value { font-size: 16px; }

  /* Баннер уведомлений мельче */
  .perm-banner { padding: 6px 10px; margin-bottom: 6px; }
  .perm-banner .perm-text { font-size: 14px; }
  .perm-banner .pix-btn { padding: 6px 8px; font-size: 12px; }

}

/* Шапка-окно */
.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--tomato-dark);
  margin: -20px -24px 16px;
  padding: 8px 14px;
  border-bottom: 4px solid var(--ink);
  font-family: var(--pix-display);
  font-size: 26px;
  color: var(--cream);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.title-bar .tb-left { display: flex; align-items: center; gap: 10px; }
.title-bar .tb-right { display: flex; align-items: center; gap: 8px; font-size: 22px; color: var(--cream-dark); }
.tb-clock {
  font-family: var(--pix-display);
  font-size: 26px;
  color: var(--cream);
  letter-spacing: 1px;
  text-shadow: 0 2px 0 var(--ink);
}
.tb-clock-colon { animation: pix-blink 1s steps(1) infinite; padding: 0 1px; }
.title-bar .tb-dot {
  width: 12px; height: 12px;
  background: var(--cream);
  box-shadow:
    inset -3px -3px 0 0 var(--cream-dark),
    inset 3px 3px 0 0 #fff;
}
.title-bar .tb-dot.r { background: var(--tomato-light); box-shadow: inset -3px -3px 0 0 var(--tomato-dark), inset 3px 3px 0 0 #fff; }
.title-bar .tb-dot.g { background: var(--leaf); box-shadow: inset -3px -3px 0 0 var(--leaf-dark), inset 3px 3px 0 0 #c5e0c0; }

/* ============= Кнопки ============= */
.pix-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--tomato);
  color: var(--cream);
  font-family: var(--pix-display);
  font-size: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 0;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset -4px -4px 0 0 var(--tomato-dark),
    inset 4px 4px 0 0 var(--tomato-light),
    0 4px 0 0 var(--ink);
  transition: transform 0.05s ease;
  user-select: none;
}
.pix-btn:hover { filter: brightness(1.1); }
.pix-btn:active {
  transform: translateY(4px);
  box-shadow:
    inset -4px -4px 0 0 var(--tomato-dark),
    inset 4px 4px 0 0 var(--tomato-light),
    0 0 0 0 var(--ink);
}
.pix-btn.secondary {
  background: var(--bg-soft);
  box-shadow:
    inset -4px -4px 0 0 #3d2b3a,
    inset 4px 4px 0 0 #7a5172,
    0 4px 0 0 var(--ink);
}
.pix-btn.leaf {
  background: var(--leaf);
  color: var(--ink);
  box-shadow:
    inset -4px -4px 0 0 var(--leaf-dark),
    inset 4px 4px 0 0 #c5e0c0,
    0 4px 0 0 var(--ink);
}

/* ============= Утилиты и анимации ============= */
.col { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.label-tiny {
  font-family: var(--pix-display);
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cream-dark);
}

@keyframes pix-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes pix-bob-tiny {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes pix-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes pix-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes step-walk {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@keyframes flag-wave {
  0%, 100% { transform: skewX(0deg); }
  50%      { transform: skewX(-8deg); }
}
@keyframes toast-slide-in {
  0%   { transform: translateX(120%); opacity: 0; }
  60%  { transform: translateX(-8px); opacity: 1; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes screen-fade-in {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: screen-fade-in 0.35s steps(6) forwards; }

/* ============= Вкладки (Таймер / Пресеты) ============= */
.screen-tabs {
  display: flex;
  gap: 4px;
  margin: -16px -24px 16px;
  padding: 10px 14px 0;
  background: var(--bg-deep);
  border-bottom: 4px solid var(--ink);
}
.screen-tab {
  font-family: var(--pix-display);
  font-size: 18px;
  letter-spacing: 1px;
  padding: 10px 14px;
  background: var(--bg-mid);
  color: var(--cream-dark);
  cursor: pointer;
  position: relative;
  text-transform: uppercase;
  border-top: 4px solid var(--ink);
  border-left: 4px solid var(--ink);
  border-right: 4px solid var(--ink);
  border-bottom: 0;
  margin-bottom: -4px;
  transition: all 0.1s;
}
.screen-tab:hover { color: var(--cream); background: var(--bg-soft); }
.screen-tab.active {
  background: var(--bg-mid);
  color: var(--cream);
  z-index: 2;
  margin-bottom: -8px;
  padding-bottom: 14px;
}
.screen-tab.active::before {
  content: '►';
  margin-right: 6px;
  color: var(--tomato-light);
}

/* ============= Заголовки секций ============= */
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}
.section-head-bar {
  flex: 1;
  height: 4px;
  background: var(--ink);
  box-shadow: 0 4px 0 0 rgba(0,0,0,0.2);
}
.section-head h2 {
  font-family: var(--pix-display);
  font-size: 20px;
  color: var(--cream);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 3px 0 var(--ink);
}

/* ============= Карта-уровень (CycleMap) ============= */
.cycle-map {
  position: relative;
  width: 100%;
  height: 220px;
  background: linear-gradient(to bottom, #6fa3ef 0%, #6fa3ef 60%, #99b898 60%, #5d8a6e 100%);
  box-shadow:
    inset -4px -4px 0 0 #1a0f18,
    inset 4px 4px 0 0 #8fb8f5,
    0 0 0 4px #1a0f18;
  overflow: hidden;
  /* Замкнутый stacking-контекст: погодные слои с z-index не вылезают
     за пределы карты (иначе они позиционируются от .app-screen
     и могут перекрывать таймер). */
  isolation: isolate;
  /* плавный переход цвета неба между секундами */
  transition: background 1s linear;
}

/* Затемнение земли ночью */
.cm-ground-darken {
  position: absolute;
  left: 0; right: 0;
  top: 60%; bottom: 0;
  background: #000;
  pointer-events: none;
  transition: opacity 1s linear;
  z-index: 1;
}

/* Звёздное поле в небе карты — видны только ночью */
.cm-night-stars {
  position: absolute;
  inset: 0 0 40% 0; /* только небо */
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 30px 18px,  #fff      50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90px 50px,  #cfd9ff   50%, transparent 51%),
    radial-gradient(2px   2px   at 150px 28px, #fff      50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 200px 70px, #fecea8   50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60px 90px,  #fff      50%, transparent 51%),
    radial-gradient(2px   2px   at 240px 14px, #fff      50%, transparent 51%);
  background-size: 280px 130px;
  background-repeat: repeat;
  animation: cm-night-twinkle 1.6s steps(2) infinite;
  transition: opacity 1.5s linear;
  z-index: 0;
}
@keyframes cm-night-twinkle {
  0%, 100% { filter: brightness(1.0); }
  50%      { filter: brightness(0.6); }
}

/* Солнце */
.cm-sun {
  position: absolute;
  width: 28px; height: 28px;
  background: #fecea8;
  pointer-events: none;
  z-index: 1;
  transform: translate(-50%, 0);
  box-shadow:
    inset -3px -3px 0 0 #e0a878,
    inset 3px 3px 0 0 #fff,
    0 0 16px 6px rgba(254, 206, 168, 0.55);
  transition: top 1s linear, left 1s linear, box-shadow 1s linear, opacity 1.6s ease-in-out;
}
.cm-sun::before, .cm-sun::after {
  /* пиксельные «лучи» */
  content: '';
  position: absolute;
  background: rgba(254, 206, 168, 0.7);
  pointer-events: none;
}
.cm-sun::before {
  width: 4px; height: 36px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
.cm-sun::after {
  width: 36px; height: 4px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}

/* Луна */
.cm-moon {
  position: absolute;
  width: 24px; height: 24px;
  background: #cfd9ff;
  pointer-events: none;
  z-index: 1;
  transform: translate(-50%, 0);
  box-shadow:
    inset -3px -3px 0 0 #99b8d8,
    inset 3px 3px 0 0 #fff,
    0 0 0 2px #1a0f18,
    0 0 14px 4px rgba(207, 217, 255, 0.45);
  transition: top 1s linear, left 1s linear, opacity 1.6s ease-in-out;
}
.cm-moon::before, .cm-moon::after {
  /* пиксельные «кратеры» */
  content: '';
  position: absolute;
  background: #99b8d8;
  pointer-events: none;
}
.cm-moon::before { width: 4px; height: 4px; top: 6px;  left: 6px; }
.cm-moon::after  { width: 3px; height: 3px; top: 14px; left: 14px; }

/* Облака — бесшовные, разных форм */
.cm-cloud {
  position: absolute;
  pointer-events: none;
  background: #fff;
  z-index: 2;
  /* Старт за левым краем, финиш за правым → никаких прыжков */
  animation-name: cm-cloud-fly;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  /* Сохраняем масштаб, заданный из JSX через CSS-переменную */
  transform: scale(var(--cloud-scale, 1));
  transition: opacity 2s linear;
}
@keyframes cm-cloud-fly {
  from { left: -120px; }
  to   { left: calc(100% + 40px); }
}

/* Форма «sm» — маленький пухлый клубок */
.cm-cloud-sm {
  width: 28px; height: 10px;
  box-shadow:
    -6px 0 0 0 #fff, 6px 0 0 0 #fff,
    0 -6px 0 0 #fff,
    -10px -2px 0 0 #fff, 10px -2px 0 0 #fff;
}
/* Форма «md» — средний (как было) */
.cm-cloud-md {
  width: 60px; height: 16px;
  box-shadow:
    -8px 0 0 0 #fff, 8px 0 0 0 #fff,
    0 -8px 0 0 #fff,
    -16px -2px 0 0 #fff, 16px -2px 0 0 #fff;
}
/* Форма «lg» — большой пушистый */
.cm-cloud-lg {
  width: 80px; height: 20px;
  box-shadow:
    -12px 0 0 0 #fff, 12px 0 0 0 #fff,
    -8px -10px 0 0 #fff, 8px -10px 0 0 #fff,
    0 -16px 0 0 #fff,
    -22px -4px 0 0 #fff, 22px -4px 0 0 #fff;
}
/* Форма «xl» — длинный «слоистый» */
.cm-cloud-xl {
  width: 110px; height: 12px;
  box-shadow:
    -14px 0 0 0 #fff, 14px 0 0 0 #fff,
    -28px 0 0 0 #fff, 28px 0 0 0 #fff,
    -8px -8px 0 0 #fff, 14px -8px 0 0 #fff;
}

.cm-path {
  position: absolute;
  bottom: 48px; left: 12%; right: 12%;
  height: 8px;
  background: #3d2b3a;
  box-shadow: inset 0 2px 0 0 #1a0f18, inset 0 -2px 0 0 #5a3a52;
  z-index: 6;
}
.cm-path-fill {
  position: absolute; inset: 0;
  background: #e84a5f;
  box-shadow: inset 0 -2px 0 0 #a8243a, inset 0 2px 0 0 #ff847c;
  transition: width 0.2s linear;
  width: 0;
}
.cm-dash {
  position: absolute; top: -6px;
  width: 4px; height: 4px;
  background: #fecea8;
  transform: translateX(-50%);
  opacity: 0.6;
}

.cm-node {
  position: absolute;
  bottom: 50px;
  transform: translateX(-50%);
  z-index: 7;
}
.cm-node-icon {
  width: 44px; height: 56px;
  background: #fecea8;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
  box-shadow:
    inset -3px -3px 0 0 #e0a878,
    inset 3px 3px 0 0 #fff,
    0 0 0 3px #1a0f18;
  transition: transform 0.3s steps(4);
  position: relative;
}
.cm-node.active .cm-node-icon {
  background: #ff847c;
  box-shadow:
    inset -3px -3px 0 0 #a8243a,
    inset 3px 3px 0 0 #ffb3ad,
    0 0 0 3px #1a0f18,
    0 0 0 7px #fecea8;
  animation: pix-pulse 0.8s steps(4) infinite;
}
.cm-node.done .cm-node-icon {
  background: #99b898;
  box-shadow:
    inset -3px -3px 0 0 #5d8a6e,
    inset 3px 3px 0 0 #c5e0c0,
    0 0 0 3px #1a0f18;
}
.cm-node-num {
  position: absolute; top: -10px; right: -10px;
  font-family: var(--pix-display);
  font-size: 16px;
  color: #1a0f18;
  background: #fecea8;
  padding: 3px 4px;
  box-shadow: 0 0 0 2px #1a0f18;
}
.cm-node-label {
  position: absolute; bottom: -20px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--pix-display);
  font-size: 14px;
  color: #fecea8;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #1a0f18;
  white-space: nowrap;
}
.cm-node.active .cm-node-label { color: #ff847c; }
/* Спрайт выбранного героя внутри чекпоинта работы — центрируем
   и подгоняем по размеру 44×56 без переполнения. */
.cm-node-icon { display: flex; align-items: center; justify-content: center; }
.cm-node-char {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.cm-flag {
  position: absolute; top: 4px; right: 4px;
  font-family: var(--pix-display);
  font-size: 20px; color: #1a0f18;
}
.cm-walker {
  position: absolute;
  bottom: 56px;
  transform: translateX(-50%);
  pointer-events: none;
  transition: left 0.2s linear;
  z-index: 8;
}
.cm-walker-sprite { animation: step-walk 0.4s steps(2) infinite; }
.cm-walker-sprite.paused { animation-play-state: paused; }
.cm-walker-shadow {
  width: 24px; height: 4px;
  margin: 2px auto 0;
  background: rgba(0,0,0,0.4);
  border-radius: 50%;
}
.cm-finish {
  position: absolute;
  bottom: 52px; right: 6%;
  width: 4px; height: 60px;
  z-index: 7;
}
.cm-flag-pole { position: absolute; inset: 0; background: #1a0f18; }
.cm-flag-cloth {
  position: absolute;
  top: 4px; left: 4px;
  width: 20px; height: 14px;
  background: #e84a5f;
  box-shadow: inset -2px -2px 0 0 #a8243a, inset 2px 2px 0 0 #ff847c;
  animation: flag-wave 1.2s steps(4) infinite;
  transform-origin: left center;
}

/* ============= Таймер ============= */
.timer-stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.timer-frame {
  background: #1a1224;
  padding: 28px 20px;
  height: 300px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  box-shadow:
    inset -4px -4px 0 0 #000,
    inset 4px 4px 0 0 #3d2b3a,
    0 0 0 4px #1a0f18;
}
/* Свой таймер: контента больше (+/− кнопки, поля МИН/СЕК), поэтому
   фрейм растягивается под содержимое и не клипает badge / round-текст. */
.timer-frame-simple {
  height: auto;
  min-height: 360px;
  overflow: visible;
}
.timer-phase-tag {
  font-family: var(--pix-display);
  font-size: 24px;
  letter-spacing: 1px;
  padding: 10px 18px;
  background: #e84a5f;
  color: #fecea8;
  text-transform: uppercase;
  box-shadow: 0 0 0 3px #1a0f18, 0 4px 0 3px #1a0f18;
}
.timer-phase-tag.break { background: #99b898; color: #1a0f18; }
.timer-phase-tag.long  { background: #6fa3ef; color: #fecea8; }
.timer-clock {
  font-family: var(--pix-display);
  /* Большой VT323 даёт «пиксельный» эффект, как в Gemini-референсе.
     Размер масштабируется от ширины окна, чтобы строка «25:00»
     не вылезала за пределы рамки на мобильных. */
  font-size: clamp(100px, 18vw, 160px);
  letter-spacing: clamp(2px, 0.8vw, 6px);
  color: #fecea8;
  text-shadow: 0 4px 0 #1a0f18, 0 8px 0 rgba(0,0,0,0.3);
  line-height: 1;
  max-width: 100%;
}
.timer-clock .colon { animation: pix-blink 1s steps(1) infinite; }
.timer-clock .colon.paused { animation: none; opacity: 1; }
.timer-round {
  font-family: var(--pix-body);
  font-size: 26px;
  color: #e0a878;
  letter-spacing: 1px;
  text-align: center;
}
/* Стили таймера для мобильных собраны в общем @media 720px ниже,
   чтобы не было конфликтов специфичности. */

.controls-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============= Простой таймер ============= */
.simple-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.simple-input-block {
  display: grid;
  grid-template-columns: auto;
  grid-template-rows: auto auto auto auto;
  gap: 6px;
  align-items: center;
  justify-items: center;
}
.simple-input-btn {
  width: 64px;
  height: 48px;
  font-family: var(--pix-display);
  font-size: 32px;
  line-height: 1;
  background: var(--bg-soft);
  color: var(--cream);
  font-family: var(--pix-display);
  font-size: 14px;
  border: 0;
  cursor: pointer;
  box-shadow:
    inset -3px -3px 0 0 #3d2b3a,
    inset 3px 3px 0 0 #7a5172,
    0 3px 0 0 var(--ink);
  transition: transform 0.05s ease;
  user-select: none;
}
.simple-input-btn:hover { filter: brightness(1.1); }
.simple-input-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset -3px -3px 0 0 #3d2b3a,
    inset 3px 3px 0 0 #7a5172,
    0 0 0 0 var(--ink);
}
.simple-input-field {
  width: 220px;
  height: 120px;
  background: #1a0f18;
  color: #fecea8;
  font-family: var(--pix-display);
  font-size: clamp(64px, 12vw, 110px);
  text-align: center;
  border: 0;
  outline: 0;
  padding: 0 8px;
  box-shadow:
    inset 3px 3px 0 0 #000,
    inset -3px -3px 0 0 #3d2b3a,
    0 0 0 3px var(--ink);
  text-shadow: 0 3px 0 #1a0f18;
  -moz-appearance: textfield;
}
.simple-input-field::-webkit-outer-spin-button,
.simple-input-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.simple-input-label {
  font-family: var(--pix-display);
  font-size: 22px;
  color: var(--cream-dark);
  letter-spacing: 1px;
  margin-top: 4px;
}
.simple-input-colon {
  font-family: var(--pix-display);
  font-size: clamp(64px, 12vw, 110px);
  color: #fecea8;
  text-shadow: 0 3px 0 #1a0f18;
  align-self: center;
  margin-top: -28px;
}
.simple-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.simple-preset-btn {
  padding: 10px 14px;
  font-size: 18px;
}

/* ============= Карточки статистики ============= */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0 0;
}
.stat-card {
  background: var(--bg-deep);
  padding: 8px 8px 6px;
  text-align: center;
  box-shadow:
    inset -3px -3px 0 0 #1a0f18,
    inset 3px 3px 0 0 #5a3a52,
    0 0 0 3px var(--ink);
}
.stat-card-label {
  font-family: var(--pix-display);
  font-size: 14px;
  color: var(--cream-dark);
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.stat-card-value {
  font-family: var(--pix-display);
  font-size: 20px;
  color: var(--tomato-light);
  text-shadow: 0 2px 0 var(--ink);
  line-height: 1.1;
}

/* ============= NES-картриджи ============= */
.cart-rack {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-top: 16px;
}
@media (max-width: 720px) {
  .cart-rack { grid-template-columns: repeat(2, 1fr); }
}
.cart {
  cursor: pointer;
  transition: transform 0.15s steps(2);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cart:hover { transform: translateY(-6px); }
.cart-selected { transform: translateY(-12px); }
.cart-selected::after {
  content: '▼';
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--pix-display);
  font-size: 14px;
  color: #fecea8;
  animation: pix-bob-tiny 0.6s steps(2) infinite;
}
.cart-top {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  position: relative;
}
.cart-label {
  background: #fecea8;
  width: 100%;
  padding: 8px 6px;
  text-align: center;
  box-shadow:
    inset -2px -2px 0 0 #e0a878,
    inset 2px 2px 0 0 #fff,
    0 0 0 2px #1a0f18;
}
.cart-label-row {
  height: 4px;
  background: #1a0f18;
  margin: 3px 0;
}
.cart-label-title {
  font-family: var(--pix-display);
  font-size: 16px;
  color: #1a0f18;
  letter-spacing: 1px;
  margin: 6px 0;
}
.cart-label-sub {
  font-family: var(--pix-body);
  font-size: 18px;
  color: #a8243a;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.cart-label-time {
  font-family: var(--pix-display);
  font-size: 14px;
  color: #5a3a52;
  letter-spacing: 1px;
  margin: 2px 0 6px;
}
.cart-connector {
  width: 80%;
  height: 22px;
  background: #1a0f18;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px;
  box-shadow: inset 2px 2px 0 0 #5a3a52;
}
.cart-pin {
  width: 4px; height: 14px;
  background: #cdb89a;
  box-shadow: inset -1px 0 0 0 #8a7a5e;
}

/* ============= Слот картриджа ============= */
.slot-machine {
  background: #1a0f18;
  padding: 18px;
  margin-bottom: 24px;
  position: relative;
  box-shadow:
    inset -4px -4px 0 0 #000,
    inset 4px 4px 0 0 #3d2b3a,
    0 0 0 4px #1a0f18;
}
.slot-machine-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.slot-machine-title {
  font-family: var(--pix-display);
  font-size: 18px;
  color: #fecea8;
  letter-spacing: 1px;
}
.slot-led-row { display: flex; gap: 6px; }
.slot-led {
  width: 8px; height: 8px;
  background: #3a5a40;
  box-shadow: inset -1px -1px 0 0 #1a2a20;
}
.slot-led.on {
  background: #99b898;
  box-shadow: inset -1px -1px 0 0 #5d8a6e, 0 0 6px #99b898;
}
.slot-window {
  background: #2b1d2a;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow:
    inset 4px 4px 0 0 #1a0f18,
    inset -4px -4px 0 0 #3d2b3a;
  overflow: hidden;
  gap: 24px;
}
.slot-glow {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(232,74,95,0.25) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: pix-shimmer 3s linear infinite;
  pointer-events: none;
}
.slot-loaded-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.slot-loaded-name {
  font-family: var(--pix-display);
  font-size: 14px;
  color: #fecea8;
  letter-spacing: 2px;
  text-shadow: 0 2px 0 #1a0f18;
}
.slot-loaded-stats {
  font-family: var(--pix-body);
  font-size: 22px;
  color: #ff847c;
  letter-spacing: 2px;
  line-height: 1;
}
.slot-loaded-times {
  font-family: var(--pix-display);
  font-size: 16px;
  color: #99b898;
  letter-spacing: 1px;
}
.slot-desc {
  margin-top: 10px;
  font-family: var(--pix-body);
  font-size: 18px;
  color: #fecea8;
  letter-spacing: 1px;
}
.cart-rack-hint {
  margin-top: 12px;
  font-family: var(--pix-body);
  font-size: 18px;
  color: #e0a878;
  text-align: center;
  letter-spacing: 1px;
}

/* ============= In-app баннер уведомления (fallback при отказе ОС) ============= */
.toast-inapp {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 360px;
  background: rgba(32, 32, 36, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 16px;
  box-shadow:
    0 12px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 0 rgba(255,255,255,0.06);
  animation: toast-slide-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
  font-family: 'Segoe UI', sans-serif;
  color: #fff;
  z-index: 100;
}
.toast-inapp-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.toast-inapp-app-icon {
  width: 24px; height: 24px;
  background: #e84a5f;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset -1px -1px 0 0 #a8243a,
    inset 1px 1px 0 0 #ff847c;
  border-radius: 2px;
}
.toast-inapp-app-name { font-size: 20px; font-weight: 600; color: #ddd; }
.toast-inapp-time { font-size: 18px; color: #888; margin-left: auto; }
.toast-inapp-close {
  font-size: 14px; color: #888; cursor: pointer;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0;
}
.toast-inapp-body { display: flex; gap: 12px; }
.toast-inapp-thumb {
  width: 64px; height: 64px;
  background: #2b1d2a;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.toast-inapp-text { flex: 1; min-width: 0; }
.toast-inapp-title { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.toast-inapp-msg { font-size: 13px; color: #bbb; line-height: 1.35; }
.toast-inapp-meta { font-size: 18px; color: #888; margin-top: 6px; }
.toast-inapp-actions { display: flex; gap: 8px; margin-top: 12px; }
.toast-inapp-btn {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  font-family: 'Segoe UI', sans-serif;
  font-size: 20px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.toast-inapp-btn:hover { background: rgba(255,255,255,0.1); }
.toast-inapp-btn.primary { background: #4178b8; border-color: #4178b8; }
.toast-inapp-btn.primary:hover { background: #5a8fd0; }

/* Плашка статуса разрешений на уведомления */
.perm-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--bg-deep);
  box-shadow:
    inset -3px -3px 0 0 #1a0f18,
    inset 3px 3px 0 0 #5a3a52,
    0 0 0 3px var(--ink);
  font-family: var(--pix-body);
  font-size: 18px;
  color: var(--cream);
}
.perm-banner .perm-text { flex: 1; line-height: 1.2; }
.perm-banner .pix-btn { padding: 8px 12px; font-size: 16px; }

/* =========================================================
   Случайные фоновые события на карте «Фокус»
   - .weather-heavy на корне карты гасит солнце/облака/звёзды
     через прозрачность (плавный переход уже на самих элементах)
   - .weather-fx — корневой контейнер слоя ивента
   - phase: entering | active | leaving управляет fade-in/out слоя
   ========================================================= */
.cycle-map.weather-heavy .cm-sun,
.cycle-map.weather-heavy .cm-moon,
.cycle-map.weather-heavy .cm-cloud,
.cycle-map.weather-heavy .cm-night-stars {
  opacity: 0 !important;
}

/* Грозовая «тяжесть» неба — мягкий тёмный оверлей */
.cycle-map.weather-heavy::after {
  content: '';
  position: absolute;
  inset: 0 0 40% 0;
  background: rgba(20, 15, 30, 0.45);
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 1.6s ease-in-out;
}
.cycle-map.weather-heavy.weather-phase-entering::after,
.cycle-map.weather-heavy.weather-phase-active::after { opacity: 1; }

.weather-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Слой ивентов — над небом/облаками (z 1–2), но строго ниже
     дорожки (6), чекпоинтов (7), финиша (7) и ходока (8). */
  z-index: 5;
  transition: opacity 1.5s ease-in-out;
}
.weather-fx.entering { opacity: 0; }
.weather-fx.active   { opacity: 1; }
.weather-fx.leaving  { opacity: 0; }

/* ======= Дождь ======= */
.weather-cloud-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(40,30,55,0.85) 0%, rgba(60,50,75,0.55) 80%, transparent 100%);
}
.weather-rain-drop {
  position: absolute;
  width: 1px; height: 7px;
  background: linear-gradient(to bottom, transparent, #cfd9ff);
  animation: weather-rain-fall 0.7s linear infinite;
}
@keyframes weather-rain-fall {
  from { transform: translate(0, -20px); opacity: 0; }
  10%  { opacity: 1; }
  to   { transform: translate(-12px, 220px); opacity: 0; }
}

/* ======= Гроза ======= */
.weather-lightning-flash {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  animation: weather-flash 5.5s steps(1) infinite;
}
@keyframes weather-flash {
  0%, 96%, 100% { background: rgba(255,255,255,0); }
  97%           { background: rgba(255,255,255,0.6); }
  98%           { background: rgba(255,255,255,0); }
  99%           { background: rgba(255,255,255,0.4); }
}
.weather-lightning-bolt {
  position: absolute;
  top: 8%; left: 55%;
  width: 6px; height: 70px;
  background: #fff8c0;
  clip-path: polygon(40% 0, 100% 35%, 55% 35%, 100% 70%, 30% 100%, 70% 60%, 0 60%, 50% 30%, 0 30%);
  filter: drop-shadow(0 0 8px #ffd76b);
  opacity: 0;
  animation: weather-bolt-show 5.5s steps(1) infinite;
}
@keyframes weather-bolt-show {
  0%, 96%, 100% { opacity: 0; }
  97%, 98%      { opacity: 1; }
}

/* ======= Радуга ======= */
.weather-rainbow {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 240px; height: 120px;
  pointer-events: none;
}
.weather-rainbow svg { width: 100%; height: 100%; }
.weather-rainbow path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: weather-rainbow-draw 1.8s steps(40, end) forwards;
}
.weather-rainbow path:nth-child(1) { animation-delay: 0.00s; }
.weather-rainbow path:nth-child(2) { animation-delay: 0.12s; }
.weather-rainbow path:nth-child(3) { animation-delay: 0.24s; }
.weather-rainbow path:nth-child(4) { animation-delay: 0.36s; }
.weather-rainbow path:nth-child(5) { animation-delay: 0.48s; }
.weather-rainbow path:nth-child(6) { animation-delay: 0.60s; }
.weather-rainbow path:nth-child(7) { animation-delay: 0.72s; }
@keyframes weather-rainbow-draw {
  to { stroke-dashoffset: 0; }
}

/* ======= Стая птиц ======= */
.weather-flock {
  position: absolute;
  top: 18%; left: -20%;
  width: 140px; height: 30px;
  animation: weather-flock-move 9s linear forwards;
}
@keyframes weather-flock-move {
  from { left: -20%; top: 18%; }
  to   { left: 110%; top: 12%; }
}
.weather-bird {
  position: absolute;
  width: 10px; height: 6px;
  animation: weather-wing-flap 0.45s steps(2) infinite;
}
.weather-bird::before, .weather-bird::after {
  content: '';
  position: absolute;
  top: 0;
  width: 5px; height: 2px;
  background: #1a0f18;
}
.weather-bird::before { left: 0;  transform-origin: right center; }
.weather-bird::after  { left: 5px; transform-origin: left center;  }
@keyframes weather-wing-flap {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(0.4); }
}

/* ======= Бабочки ======= */
.weather-butterfly {
  position: absolute;
  width: 12px; height: 8px;
  animation: weather-butterfly-drift 5s ease-in-out infinite;
}
.weather-butterfly .wing {
  position: absolute;
  width: 5px; height: 8px;
  top: 0;
  animation: weather-butterfly-flap 0.18s steps(2) infinite;
}
.weather-butterfly .wing.l { left: 0;   background: #e84a5f; transform-origin: right center; }
.weather-butterfly .wing.r { left: 7px; background: #ff847c; transform-origin: left center;  }
.weather-butterfly .body {
  position: absolute;
  left: 5px; top: 1px;
  width: 2px; height: 6px;
  background: #1a0f18;
}
@keyframes weather-butterfly-flap {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(0.25); }
}
@keyframes weather-butterfly-drift {
  0%   { left: 5%;  top: 60%; }
  25%  { left: 28%; top: 50%; }
  50%  { left: 50%; top: 65%; }
  75%  { left: 75%; top: 52%; }
  100% { left: 95%; top: 60%; }
}
.weather-butterfly.b2 { animation-delay: -1.5s; animation-duration: 6.5s; }
.weather-butterfly.b2 .wing.l { background: #99b898; }
.weather-butterfly.b2 .wing.r { background: #c5e0c0; }
.weather-butterfly.b3 { animation-delay: -3.2s; animation-duration: 5.8s; }
.weather-butterfly.b3 .wing.l { background: #cfa3ef; }
.weather-butterfly.b3 .wing.r { background: #e6c8ff; }

/* ======= Светлячки ======= */
.weather-firefly {
  position: absolute;
  width: 3px; height: 3px;
  background: #fff8a0;
  box-shadow: 0 0 6px 2px rgba(255,248,160,0.7);
  animation:
    weather-firefly-drift 5s ease-in-out infinite,
    weather-firefly-blink 1.6s steps(2) infinite;
}
@keyframes weather-firefly-drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(20px, -10px); }
  50%  { transform: translate(40px, 5px); }
  75%  { transform: translate(20px, -8px); }
  100% { transform: translate(0, 0); }
}
@keyframes weather-firefly-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

/* ======= Кролик ======= */
.weather-bunny-stage {
  position: absolute;
  bottom: 22px; left: -20px;
  animation: weather-bunny-cross 8s linear forwards;
}
@keyframes weather-bunny-cross {
  from { left: -20px; }
  to   { left: 110%; }
}
.weather-bunny-hop { animation: weather-bunny-hop 0.55s ease-in-out infinite; }
@keyframes weather-bunny-hop {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ======= Падающая звезда ======= */
.weather-shoot {
  position: absolute;
  top: 8%; left: 5%;
  width: 60px; height: 2px;
  background: linear-gradient(90deg, transparent, #fff8c0 60%, #fff);
  box-shadow: 0 0 8px 1px rgba(255,255,255,0.6);
  transform: rotate(20deg);
  animation: weather-shoot-fly 1.2s ease-in forwards;
}
@keyframes weather-shoot-fly {
  0%   { opacity: 0; transform: translate(0, 0)      rotate(20deg); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translate(160px, 70px) rotate(20deg); }
}

/* ======= Метеоры ======= */
.weather-meteor {
  position: absolute;
  width: 50px; height: 2px;
  background: linear-gradient(90deg, transparent, #ff847c 60%, #fff);
  box-shadow: 0 0 8px 1px rgba(255,200,160,0.55);
  transform: rotate(25deg);
  opacity: 0;
  animation: weather-meteor-fly 4s linear forwards;
}
@keyframes weather-meteor-fly {
  0%   { opacity: 0; transform: translate(0, 0)        rotate(25deg); }
  6%   { opacity: 1; }
  30%  { opacity: 0; transform: translate(140px, 80px) rotate(25deg); }
  100% { opacity: 0; transform: translate(140px, 80px) rotate(25deg); }
}

/* ======= Воздушный шар ======= */
.weather-balloon-stage {
  position: absolute;
  top: 25%; left: -10%;
  animation: weather-balloon-float 18s linear forwards;
}
@keyframes weather-balloon-float {
  from { left: -10%; }
  to   { left: 110%; }
}
.weather-balloon-bob { animation: weather-balloon-bob 2.4s ease-in-out infinite; }
@keyframes weather-balloon-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* ======= Самолёт ======= */
.weather-plane-stage {
  position: absolute;
  top: 18%; left: -10%;
  animation: weather-plane-fly 12s linear forwards;
}
@keyframes weather-plane-fly {
  from { left: -10%; }
  to   { left: 110%; }
}
.weather-contrail {
  position: absolute;
  top: 4px; right: 100%;
  width: 80px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.85));
  filter: blur(0.5px);
}

/* ======= НЛО ======= */
.weather-ufo {
  position: absolute;
  top: 28%; left: -8%;
  animation: weather-ufo-zigzag 11s ease-in-out forwards;
}
@keyframes weather-ufo-zigzag {
  0%   { left: -8%;  top: 28%; }
  20%  { left: 25%;  top: 18%; }
  35%  { left: 25%;  top: 18%; }
  36%  { left: 60%;  top: 35%; }
  55%  { left: 60%;  top: 35%; }
  56%  { left: 40%;  top: 22%; }
  75%  { left: 40%;  top: 22%; }
  100% { left: 110%; top: 30%; }
}
.weather-ufo-lights {
  position: absolute;
  bottom: 0; left: 0;
  animation: weather-ufo-blink 0.4s steps(2) infinite;
}
@keyframes weather-ufo-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ======= Цветочная поляна ======= */
.weather-flower {
  position: absolute;
  bottom: 8px;
  transform-origin: bottom center;
  transform: scaleY(0);
  animation: weather-flower-bloom 0.6s ease-out forwards;
}
@keyframes weather-flower-bloom {
  0%   { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

/* ======= Лист на ветру ======= */
.weather-leaf-fly {
  position: absolute;
  top: 30%; left: -10%;
  animation: weather-leaf-drift 8s linear forwards;
}
@keyframes weather-leaf-drift {
  0%   { left: -10%; top: 30%; transform: rotate(0deg);   }
  25%  {             top: 40%; transform: rotate(180deg); }
  50%  {             top: 28%; transform: rotate(360deg); }
  75%  {             top: 50%; transform: rotate(540deg); }
  100% { left: 110%; top: 38%; transform: rotate(720deg); }
}

/* =========================================================
   Анимации ходьбы персонажей.
   Каждый класс walk-* — отдельный «характер» движения.
   Применяется к спрайту героя (walker, hero-strip, hero-card,
   hero-cell). Объявления идут после `.cm-walker-sprite`,
   поэтому при равной специфичности побеждают эти правила.
   ========================================================= */
@keyframes ch-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.walk-bob { animation: ch-bob 0.4s steps(2) infinite; }

@keyframes ch-march {
  0%   { transform: translateY(0)    rotate(-3deg); }
  50%  { transform: translateY(-2px) rotate(3deg);  }
  100% { transform: translateY(0)    rotate(-3deg); }
}
.walk-march { animation: ch-march 0.5s steps(2) infinite; }

@keyframes ch-prowl {
  0%, 100% { transform: translateY(2px) scaleX(1);    }
  50%      { transform: translateY(0)   scaleX(1.05); }
}
.walk-prowl { animation: ch-prowl 0.45s steps(3) infinite; }

@keyframes ch-stomp {
  0%   { transform: translateY(0) skewX(0); }
  25%  { transform: translateY(-2px) skewX(-2deg); }
  50%  { transform: translateY(0) skewX(0); }
  75%  { transform: translateY(-2px) skewX(2deg); }
  100% { transform: translateY(0) skewX(0); }
}
.walk-stomp { animation: ch-stomp 0.6s steps(4) infinite; }

@keyframes ch-float {
  0%, 100% { transform: translateY(0)   rotate(-2deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}
.walk-float { animation: ch-float 1.2s ease-in-out infinite; }

@keyframes ch-bounce {
  0%, 100% { transform: translateY(0)   scaleY(1);    }
  40%      { transform: translateY(-8px) scaleY(1.05); }
  60%      { transform: translateY(-8px) scaleY(1.05); }
  80%      { transform: translateY(0)    scaleY(0.92); }
}
.walk-bounce { animation: ch-bounce 0.8s steps(5) infinite; }

@keyframes ch-dash {
  0%, 100% { transform: translateX(0);    opacity: 1;   }
  25%      { transform: translateX(-2px); opacity: 0.7; }
  50%      { transform: translateX(0);    opacity: 1;   }
  75%      { transform: translateX(2px);  opacity: 0.7; }
}
.walk-dash { animation: ch-dash 0.35s steps(4) infinite; }

@keyframes ch-squish {
  0%, 100% { transform: translateY(0)   scale(1, 1);     }
  50%      { transform: translateY(-2px) scale(0.92, 1.1); }
  75%      { transform: translateY(2px)  scale(1.08, 0.9); }
}
.walk-squish { animation: ch-squish 0.6s steps(4) infinite; }

@keyframes ch-hover {
  0%, 100% { transform: translateY(0)   translateX(0); }
  25%      { transform: translateY(-3px) translateX(1px); }
  50%      { transform: translateY(-5px) translateX(0); }
  75%      { transform: translateY(-3px) translateX(-1px); }
}
.walk-hover { animation: ch-hover 1.4s ease-in-out infinite; }

@keyframes ch-thump {
  0%, 100% { transform: translateY(0) scaleY(1); }
  20%      { transform: translateY(-3px) scaleY(1.04); }
  40%      { transform: translateY(0) scaleY(1); }
  50%      { transform: translateY(2px) scaleY(0.96); }
  60%      { transform: translateY(0) scaleY(1); }
}
.walk-thump { animation: ch-thump 0.9s steps(5) infinite; }

/* На паузе walker замирает — это правило перебивает любой walk-* */
.cm-walker-sprite.paused { animation-play-state: paused; }

/* =========================================================
   Hero-card (большая карточка активного героя на вкладке «Герой»)
   ========================================================= */
.hero-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  background: var(--night);
  padding: 14px;
  margin: 0 0 10px;
  position: relative;
  box-shadow:
    inset -3px -3px 0 0 var(--ink),
    inset 3px 3px 0 0 var(--bg-mid),
    0 0 0 3px var(--ink);
}
.hero-card::before {
  content: '◤ HERO ◥';
  position: absolute;
  top: -10px; left: 16px;
  font-family: var(--pix-display);
  font-size: 18px;
  color: var(--cream);
  background: var(--ink);
  padding: 4px 8px;
  letter-spacing: 1px;
}
.hero-card-stage {
  position: relative;
  height: 130px;
  background:
    linear-gradient(to bottom,
      #6fa3ef 0%, #6fa3ef 65%,
      #99b898 65%, #5d8a6e 100%);
  box-shadow:
    inset -2px -2px 0 0 var(--ink),
    inset 2px 2px 0 0 #8fb8f5,
    0 0 0 2px var(--ink);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}
.hero-card-sprite {
  position: relative;
  z-index: 2;
  margin-bottom: 14px;
}
.hero-card-shadow {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px; height: 5px;
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  z-index: 1;
}
.hero-card-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.hero-card-meta {
  font-family: var(--pix-display);
  font-size: 18px;
  color: var(--leaf);
  letter-spacing: 1px;
}
.hero-card-name {
  font-family: var(--pix-display);
  font-size: 22px;
  color: var(--cream);
  text-shadow: 0 4px 0 var(--ink);
  letter-spacing: 1px;
}
.hero-card-desc {
  font-family: var(--pix-body);
  font-size: 22px;
  color: var(--tomato-light);
  line-height: 1.2;
}
.hero-card-anim {
  font-family: var(--pix-display);
  font-size: 16px;
  color: var(--leaf);
  background: var(--ink);
  padding: 6px 10px;
  align-self: flex-start;
  margin-top: 6px;
  letter-spacing: 2px;
}

/* =========================================================
   Сетка 4×4 для выбора героя
   ========================================================= */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.hero-cell {
  position: relative;
  background: var(--bg-deep);
  padding: 6px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow:
    inset -2px -2px 0 0 var(--ink),
    inset 2px 2px 0 0 var(--bg-mid),
    0 0 0 2px var(--ink);
  transition: transform 0.1s, background 0.1s;
}
.hero-cell:hover { background: var(--bg-mid); }
.hero-cell.selected {
  background: var(--bg-mid);
  transform: translateY(-3px);
  box-shadow:
    inset -2px -2px 0 0 var(--ink),
    inset 2px 2px 0 0 var(--bg-soft),
    0 0 0 3px var(--cream),
    0 0 0 5px var(--ink);
}
.hero-cell-stage {
  width: 100%;
  height: 64px;
  background: linear-gradient(to bottom, #4a3650 0%, var(--bg-deep) 100%);
  box-shadow: inset 0 0 0 1px var(--ink);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  overflow: hidden;
}
.hero-cell-sprite {
  position: relative;
}
.hero-cell-name {
  font-family: var(--pix-display);
  font-size: 16px;
  color: var(--cream);
  text-align: center;
  letter-spacing: 1px;
}
.hero-cell-check {
  position: absolute;
  top: -6px; right: -6px;
  width: 22px; height: 22px;
  background: var(--leaf);
  color: var(--ink);
  font-family: var(--pix-display);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--ink);
}
.hero-tip {
  margin-top: 8px;
  text-align: center;
  font-family: var(--pix-body);
  font-size: 18px;
  color: var(--cream-dark);
  letter-spacing: 1px;
}

/* На мобильных все 16 героев должны помещаться в один экран —
   оставляем 4 колонки × 4 ряда, ужимаем карточку и ячейки. */
@media (max-width: 720px) {
  .hero-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .hero-card {
    grid-template-columns: 110px 1fr;
    gap: 10px;
    padding: 8px;
    margin: 0 0 6px;
  }
  .hero-card::before { font-size: 14px; padding: 3px 6px; }
  .hero-card-stage { height: 100px; }
  .hero-card-sprite { margin-bottom: 8px; }
  .hero-card-meta { font-size: 14px; }
  .hero-card-name { font-size: 18px; }
  .hero-card-desc { font-size: 16px; }
  .hero-card-anim { font-size: 12px; padding: 4px 6px; margin-top: 4px; }
  .hero-cell { padding: 4px 2px 4px; gap: 3px; }
  .hero-cell-stage { height: 50px; padding-bottom: 2px; }
  .hero-cell-name { font-size: 11px; letter-spacing: 0; }
  .hero-cell-check { width: 18px; height: 18px; font-size: 10px; top: -4px; right: -4px; }
  .hero-tip { font-size: 14px; margin-top: 4px; }
}

/* =========================================================
   CRT-шейдеры. Включаются классом `crt-on` на <body>.
   Слои-overlay'и получают видимость через каскад этого класса.
   Все слои pointer-events:none, лежат поверх контента.
   ========================================================= */

/* Все CRT-слои скрыты по умолчанию, активируются классом crt-on на body */
.crt-layer { display: none; }
body.crt-on .crt-layer { display: block; }

/* 1. Сканлайны — 2px тёмные + 2px пропуск, период 4px (Gemini-стиль) */
.crt-scanlines {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9990;
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,0),
    rgba(255,255,255,0) 50%,
    rgba(0,0,0,0.22) 50%,
    rgba(0,0,0,0.22)
  );
  background-size: 100% 4px;
}

/* 2. Анимированный шум (текстура заполняется через JS canvas) */
.crt-noise {
  position: fixed;
  top: -100%; left: -100%; right: -100%; bottom: -100%;
  pointer-events: none;
  z-index: 9991;
  opacity: 0.10;
  animation: crt-noise-anim 0.2s infinite linear;
  background-repeat: repeat;
}
@keyframes crt-noise-anim {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 3%); }
  40%  { transform: translate(3%, -3%); }
  60%  { transform: translate(-3%, -3%); }
  80%  { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* 3. Виньетка — затемнение углов экрана */
.crt-vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9992;
  background: radial-gradient(
    ellipse at center,
    rgba(0,0,0,0) 50%,
    rgba(0,0,0,0.55) 100%
  );
  box-shadow: inset 0 0 120px rgba(0,0,0,0.65);
}

/* 4. Блик выпуклого стекла */
.crt-glass-glare {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9993;
  background: radial-gradient(
    ellipse 150% 100% at 50% 0%,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0) 40%
  );
}

/* 5. VHS-полоса. Запускается рандомно из JS — добавлением класса
   .playing. Один прогон ~1.5 c, паузы 5–25 c между запусками. */
.crt-vhs {
  position: fixed;
  left: 0; right: 0;
  height: 10%;
  pointer-events: none;
  z-index: 9994;
  background: rgba(255,255,255,0.05);
  top: -20%;
  opacity: 0;
}
.crt-vhs.playing {
  animation: crt-vhs-roll 1.5s linear forwards;
}
@keyframes crt-vhs-roll {
  0%   { top: -20%; opacity: 0; }
  15%  { opacity: 0.5; }
  100% { top: 110%; opacity: 0; }
}

/* 6. Хроматическая аберрация — SVG-фильтр применяется к .app-screen */
body.crt-on .app-screen {
  filter: url(#crt-rgb-shift);
}

/* Тумблер ЭЛТ-полос в title-bar */
.crt-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--pix-display);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--cream-dark);
  background: transparent;
  border: 0;
  padding: 4px 8px;
  cursor: pointer;
  text-transform: uppercase;
  margin-right: 10px;
}
.crt-toggle:hover { color: var(--cream); }
.crt-toggle-led {
  width: 8px; height: 8px;
  background: var(--bg-mid);
  box-shadow: 0 0 0 1px var(--ink);
}
.crt-toggle.on .crt-toggle-led {
  background: var(--leaf);
  box-shadow: 0 0 0 1px var(--ink), 0 0 6px var(--leaf);
}
.crt-toggle.on { color: var(--cream); }

/* =========================================================
   Мобильные оверрайды для простого таймера (вкладка «Таймер»).
   Идут в конце файла, чтобы перебить базовые .simple-input-*
   правила, объявленные позже моего основного @media-блока.
   ========================================================= */
@media (max-width: 720px) {
  .simple-input-row { gap: 8px; padding: 4px 0; }
  .simple-input-field {
    width: 120px;
    height: 90px;
    font-size: clamp(50px, 14vw, 72px);
  }
  .simple-input-colon {
    font-size: clamp(50px, 14vw, 72px);
    margin-top: -18px;
  }
  .simple-input-btn { width: 52px; height: 38px; }
  .simple-input-label { font-size: 16px; }
  .simple-presets { gap: 6px; }
  .simple-preset-btn { padding: 7px 10px; font-size: 14px; }

  /* Тумблеры ЭЛТ/ЗВУК — компактные, чтобы шапка с заголовком уместилась */
  .crt-toggle {
    font-size: 10px;
    padding: 2px 4px;
    margin-right: 2px;
    gap: 3px;
    letter-spacing: 0;
  }
  .crt-toggle-led { width: 5px; height: 5px; }
}
