/* Шрифты (SIL Open Font License, лежат в public/fonts вместе с OFL.txt):
   Cinzel — римские капители, как гравировка на старых звёздных атласах;
   Jost — геометрический гротеск в духе Futura (ею набрана табличка Apollo 11 на Луне). */
@font-face {
  font-family: 'Cinzel';
  src: url('../fonts/cinzel-latin.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('../fonts/jost-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Jost';
  src: url('../fonts/jost-italic-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --serif: 'Cinzel', Georgia, "Times New Roman", serif;
  --sans: 'Jost', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --bg: #03050d;
  --panel: rgba(11, 17, 38, 0.86);
  --panel-border: rgba(140, 170, 255, 0.18);
  --text: #e9edff;
  --muted: #9aa6d1;
  --accent: #6ee7ff;
  --gold: #ffd166;
  --amber: #e8b45c;
  --primary: #4f6bff;
  --primary-hover: #6680ff;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; }

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: radial-gradient(ellipse 75% 75% at 50% 40%, #0c1533 0%, #03050d 100%);
}
#sky.dragging { cursor: grabbing; }
/* WebGL-слой с панорамой Млечного Пути и звёздами — под canvas с линиями и подписями */
#skyGL {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  background: var(--bg);
}
body.gl-sky #sky { background: transparent; }

.hidden { display: none !important; }

/* --- Верхняя панель --- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 18px;
  background: linear-gradient(to bottom, rgba(3, 5, 13, 0.9), rgba(3, 5, 13, 0));
  pointer-events: none;
  z-index: 5;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  text-shadow: 0 0 18px rgba(232, 180, 92, 0.25);
}
.brand-mark { width: 13px; height: 17px; fill: var(--amber); flex: none; filter: drop-shadow(0 0 5px rgba(232, 180, 92, 0.55)); }
/* название в шапке — кнопка «в главное меню» */
button.brand { background: none; border: 0; padding: 0; margin: 0; color: inherit; cursor: pointer; }
button.brand:hover .brand-text { color: #fff4dc; }

/* --- Главное меню: при каждом входе, за ним — 3D-Млечный Путь (menugalaxy.js) --- */
.menu { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 48px 16px 24px;
  background: radial-gradient(ellipse at 50% 40%, #0c1431 0%, #03050d 70%); overflow-y: auto; }
.menu-galaxy { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s ease; }
.menu-galaxy.on { opacity: 1; }
.menu-here { position: fixed; left: 0; top: 0; display: flex; align-items: center; gap: 7px; margin: -5px 0 0 -5px; pointer-events: none;
  color: var(--amber); font-size: 10.5px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; text-shadow: 0 0 8px #000; }
.menu-here i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--amber); box-shadow: 0 0 10px rgba(232, 180, 92, 0.8); }
/* бегущая строка о небе сегодня (как сводка погоды у аэропорта) */
.menu-ticker { position: fixed; top: 0; left: 0; right: 0; height: 28px; overflow: hidden; background: rgba(4, 7, 18, 0.72);
  border-bottom: 1px solid rgba(232, 180, 92, 0.22); padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.menu-ticker-run { display: inline-block; white-space: nowrap; padding-left: 100%; line-height: 28px; color: #e9d7b0;
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; animation: ticker var(--ticker-s, 40s) linear infinite; }
@keyframes ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .menu-ticker-run { animation: none; padding-left: 16px; }
}
.menu-panel { position: relative; width: min(440px, 100%); padding: 26px 24px 18px; text-align: center; border-radius: 22px;
  background: rgba(8, 12, 30, 0.72); border: 1px solid rgba(140, 160, 230, 0.18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(232, 180, 92, 0.06); animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.menu-panel .kicker.caps { margin: 0; color: var(--amber); }
.menu-title { margin: 4px 0 6px; font-size: 52px !important; line-height: 1.1; filter: drop-shadow(0 0 22px rgba(232, 180, 92, 0.3)); }
.menu-lead { margin: 0 0 6px; color: #dfe3f2; font-size: 16px; line-height: 1.4; }
.menu-day { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.menu-day b { color: var(--amber); font-weight: 600; }
.menu-panel .quick-steps { text-align: left; margin: 0 4px 16px; }
.menu-play { font-size: 17px; padding: 14px 16px; }
.menu-note { margin: 8px 0 0; color: #f0d9a8; font-size: 14px; }
.menu-panel #mAlt { margin-top: 10px; }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.menu-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 64px; padding: 9px 6px;
  border-radius: 12px; border: 1px solid var(--panel-border); background: rgba(16, 24, 56, 0.55); color: var(--text); cursor: pointer; font: inherit; }
.menu-item b { font-size: 14px; font-weight: 600; }
.menu-item small { color: var(--muted); font-size: 11px; line-height: 1.25; }
.menu-item:hover:not(.locked) { border-color: rgba(232, 180, 92, 0.5); }
.menu-item.locked { opacity: 0.55; cursor: default; }
.menu-item.locked small::before { content: ''; display: inline-block; width: 7px; height: 8px; margin-right: 4px; vertical-align: -1px;
  border: 1.3px solid currentColor; border-radius: 1.5px; box-shadow: 0 -3px 0 -1.3px currentColor; }
.menu-stats { margin: 14px 0 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.menu-stats b { color: var(--text); font-weight: 600; }
.menu-foot { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.menu-foot a, .menu-foot .link-btn { color: var(--muted); font-weight: 400; font-size: 12.5px; }
/* «How to play» и архив, открытые из меню, — поверх него; подсказки-тосты тоже видны над меню */
.overlay.over-menu { z-index: 45; }
.menu-open .toast { z-index: 50; }
@media (max-width: 420px) {
  .menu { padding: 40px 12px 16px; align-items: flex-start; }
  .menu-panel { padding: 20px 16px 14px; }
  .menu-title { font-size: 42px !important; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); }
}
.wordmark {
  font-family: var(--serif);
  font-size: 40px !important;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: linear-gradient(180deg, #fff4dc 10%, #e8b45c 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.caps { text-transform: uppercase; letter-spacing: 0.22em; font-size: 11px; font-weight: 600; color: var(--amber); }
.meta {
  margin-left: auto;
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.meta .score { color: var(--text); font-weight: 600; }

.dots { display: flex; gap: 5px; align-items: center; }
.dots span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px dashed rgba(154, 166, 209, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dots span.current { border: 1.5px solid var(--amber); box-shadow: 0 0 0 3px rgba(232, 180, 92, 0.18); }
.dots span.filled { border: none; }
.dots .grade-icon { display: block; }
.grade-icon { flex: none; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex: none;
}
.icon-btn:hover { border-color: rgba(140, 170, 255, 0.45); }
/* первый день — в шапке только главное; открытое после первой головоломки мягко подсвечено */
body.first-day #galaxyBtn, body.first-day #atlasBtn { display: none; }
.icon-btn.new { border-color: rgba(232, 180, 92, 0.75); color: var(--amber); animation: newGlow 1.6s ease-in-out 4; }
@keyframes newGlow { 50% { box-shadow: 0 0 0 4px rgba(232, 180, 92, 0.22), 0 0 16px rgba(232, 180, 92, 0.4); } }
.sound-btn { display: flex; align-items: center; justify-content: center; }
.sound-btn .cross { display: none; }
.sound-btn.muted { color: var(--muted); }
.sound-btn.muted .wave { display: none; }
.sound-btn.muted .cross { display: inline; }

/* --- Карточки --- */
.card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 16px 14px;
  z-index: 4;
}
.question { top: calc(64px + env(safe-area-inset-top)); pointer-events: none; }
.question .hint { pointer-events: auto; }
.q-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.badge { color: var(--gold); font-weight: 600; }
.kicker { color: var(--muted); font-size: 13px; margin-top: 6px; }
.question h1 { margin: 4px 0 0; font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: 0.03em; }
.hint { margin: 8px 0 0; color: var(--accent); font-size: 14px; line-height: 1.4; }
/* «Trace the constellation»: схема фигуры справа от названия и счёт найденных звёзд */
.q-shape { float: right; margin: 8px 0 2px 12px; padding: 4px; border: 1px solid var(--panel-border); border-radius: 10px; line-height: 0; }
.q-shape .ln line { stroke: rgba(232, 180, 92, 0.75); stroke-width: 1.2; stroke-linecap: round; }
.q-shape .st circle { fill: #f4f6ff; }
.trace-status { margin: 6px 0 0; color: var(--amber); font-size: 13px; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.question .hint { clear: both; }

.result { bottom: calc(16px + env(safe-area-inset-bottom)); }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.grade { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: 0.04em; }
.points { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.r-name { margin-top: 6px; font-weight: 600; color: var(--gold); }
.r-dist { color: var(--muted); font-size: 14px; margin-top: 2px; }
.fact { margin: 10px 0 12px; line-height: 1.45; font-size: 15px; }
/* «How to find it» — путь от звезды-ориентира, янтарный, как пунктир на карте */
.route { margin: -4px 0 12px; padding: 8px 10px; border-left: 2px solid var(--amber); background: rgba(232, 180, 92, 0.07);
  border-radius: 0 8px 8px 0; font-size: 14px; line-height: 1.4; color: #f1d7a6; }
.route b { color: var(--amber); font-weight: 600; }

/* --- Карточка объекта --- */
.info {
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-height: 64vh;
  overflow-y: auto;
  padding: 16px 18px 6px;
  z-index: 6;
}
.info-head { display: flex; gap: 16px; align-items: center; padding-right: 22px; }
#infoPortrait { flex: none; display: block; border-radius: 50%; box-shadow: 0 0 0 1px rgba(232, 180, 92, 0.12), 0 8px 24px rgba(0, 0, 0, 0.45); }
.info-title { min-width: 0; }
.info-title h2 {
  margin: 3px 0 8px;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
}
.info-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.info-stats span {
  font-size: 12.5px;
  background: rgba(232, 180, 92, 0.09);
  border: 1px solid rgba(232, 180, 92, 0.28);
  border-radius: 999px;
  padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}
.close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.close-btn:hover { color: var(--text); background: rgba(140, 170, 255, 0.1); }
.link-btn {
  display: block;
  background: none;
  border: none;
  padding: 0 0 12px;
  color: var(--amber);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.credit { margin: -4px 0 12px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.credit a, .credits a { color: var(--muted); }
.credits { margin-top: 14px; font-size: 12px; color: var(--muted); }
.credits summary { cursor: pointer; }
.credits ul { padding-left: 16px; margin: 6px 0 0; line-height: 1.45; }

/* --- Переключатель подписей (Expert-режим) --- */
.setting {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
}
.setting .txt { flex: 1; font-size: 14px; font-weight: 600; }
.setting small { display: block; margin-top: 2px; font-weight: 400; font-size: 12px; color: var(--muted); }
.switch input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 12px;
  background: rgba(140, 170, 255, 0.25);
  cursor: pointer;
  transition: background 0.15s;
}
.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.switch input:checked { background: var(--amber); }
.switch input:checked::after { left: 21px; }

/* --- Sky Atlas --- */
.atlas-modal { position: relative; width: min(600px, 100%); }
.atlas-bar { height: 4px; border-radius: 2px; background: rgba(140, 170, 255, 0.12); overflow: hidden; margin: 2px 0 6px; }
.atlas-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.4s; }
.atlas-section h3 {
  display: flex;
  justify-content: space-between;
  margin: 18px 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
}
.atlas-section h3 span { color: var(--muted); letter-spacing: 0.05em; font-variant-numeric: tabular-nums; }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 12px 8px; }
.atlas-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}
.atlas-tile:hover .nm { color: var(--amber); }
.atlas-tile.locked { cursor: default; color: rgba(154, 166, 209, 0.55); }
.atlas-tile .lock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px dashed rgba(232, 180, 92, 0.28);
  font-family: var(--serif);
  font-size: 22px;
  color: rgba(232, 180, 92, 0.4);
}
.atlas-line { margin: 12px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.link-btn.inline { display: inline; padding: 0; }

/* --- Полноэкранный просмотр: 3D-глобус и фото --- */
#infoPortrait.clickable { cursor: zoom-in; }
/* 3D-модель звезды или планеты — поверх рисунка; клики проходят к рисунку под ней */
.portrait-wrap { position: relative; flex: none; line-height: 0; }
#infoPortrait3d { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; }
.info-actions { display: flex; gap: 8px; margin: -2px 0 12px; }
.info-actions .btn { flex: 1; font-family: var(--sans); }
.info-actions .wiki-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding-left: 18px; padding-right: 18px; text-decoration: none; }
.info-actions #infoView.hidden + .wiki-btn { flex: 1; }
.wiki-btn svg { opacity: 0.75; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, #0c1533 0%, #02030a 100%);
  overflow: hidden;
}
.viewer-stage { position: absolute; inset: 0; }
#vGlobe, #vStar { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.viewer-head {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 24px;
  background: linear-gradient(to bottom, rgba(2, 3, 10, 0.85), rgba(2, 3, 10, 0));
  pointer-events: none;
}
.viewer-head > * { pointer-events: auto; }
.viewer-head h2 { margin: 2px 0 0; font-family: var(--serif); font-size: 30px; }
.viewer-panel {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(380px, calc(100% - 32px));
  max-height: 46vh;
  overflow-y: auto;
  padding: 14px 16px 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 15px;
  line-height: 1.5;
}
.viewer-panel p { margin: 0 0 10px; }
.viewer-panel h3 { margin: 4px 0 6px; font-family: var(--serif); font-size: 20px; color: var(--amber); }
#vGlobe.panning, #vStar.panning { cursor: move; }
#vGlobe:active, #vStar:active { cursor: grabbing; }

/* --- Карта Галактики --- */
.galaxy { position: fixed; inset: 0; z-index: 28; background: #02030a; overflow: hidden; }
#gCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#gCanvas:active { cursor: grabbing; }
.g-labels { position: absolute; inset: 0; pointer-events: none; }
.g-label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  color: rgba(225, 232, 255, 0.82);
  font: 400 12px var(--sans);
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
  pointer-events: auto;
  cursor: pointer;
  margin-top: -8px;
}
.g-label[hidden] { display: none; }
/* подпись у правого края — слева от точки (точка остаётся на месте объекта) */
.g-label.flip { flex-direction: row-reverse; }
.g-label.flip .dot { margin-left: 0; margin-right: -2.5px; }
.g-label.flip[data-kind='here'] .dot { margin-left: 0; margin-right: -4.5px; }
/* не влезает ни справа, ни слева — подпись под точкой */
.g-label.below { flex-direction: column; gap: 4px; margin-top: -2.5px; }
.g-label.below .dot { margin-left: 0; }
.g-label.below[data-kind='here'] { margin-top: -4.5px; }
.g-label.below[data-kind='here'] .dot { margin-left: 0; }
.g-label .dot { width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; flex: none; }
.g-label:hover .txt, .g-label.active .txt { color: #fff; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(232, 180, 92, 0.6); }
.g-label.active .dot { box-shadow: 0 0 0 3px rgba(232, 180, 92, 0.35), 0 0 10px currentColor; }
.g-label[data-kind='arm'] { color: rgba(170, 190, 255, 0.7); font: italic 400 13px var(--sans); letter-spacing: 0.08em; }
.g-label[data-kind='arm'] .dot { display: none; }
.g-label[data-kind='galaxy'], .g-label[data-kind='major'] { color: #f2d49b; font: 600 12px var(--serif); letter-spacing: 0.14em; text-transform: uppercase; }
.g-label[data-kind='here'] { color: var(--amber); font-weight: 600; }
.g-label[data-kind='here'] .dot { width: 9px; height: 9px; margin-left: -4.5px; background: var(--amber); box-shadow: 0 0 0 4px rgba(232, 180, 92, 0.25), 0 0 14px var(--amber); }
.g-label[data-kind='planet'] { color: #ffffff; font-weight: 500; }
.g-label[data-kind='star'] { color: rgba(205, 220, 255, 0.85); font-size: 11.5px; }
.g-label[data-kind='exo'] { color: #7fe6d2; font-size: 11.5px; }
.g-label[data-kind='dso'] { color: #f3b8d6; }
.g-scale { position: absolute; left: 18px; bottom: calc(70px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 12px; pointer-events: none; }
.g-scale .bar { height: 6px; border: 1.5px solid rgba(232, 226, 214, 0.7); border-top: none; margin-bottom: 4px; transition: width 0.15s; }
.g-help { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(62px + env(safe-area-inset-bottom)); margin: 0; color: rgba(154, 166, 209, 0.75); font-size: 12px; white-space: nowrap; pointer-events: none; }
.g-jump {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: calc(100% - 24px);
  overflow-x: auto;
}
.g-jump button {
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 13px var(--sans);
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
}
.g-jump button:hover { background: rgba(232, 180, 92, 0.16); color: #fff; }
.g-panel { bottom: calc(72px + env(safe-area-inset-bottom)); padding-top: 16px; }
.g-panel h3 { font-size: 24px; margin-right: 26px; }
.g-panel .info-stats { margin: 4px 0 10px; }
.g-panel p { white-space: pre-line; color: #e3e8ff; }
.g-panel .btn { margin-bottom: 12px; }
.g-panel.enter > * { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.g-panel.enter > :nth-child(3) { animation-delay: 0.08s; }
.g-panel.enter > :nth-child(4) { animation-delay: 0.16s; }
.g-panel.enter > :nth-child(5) { animation-delay: 0.26s; }
@media (max-width: 700px) {
  .g-help { display: none; }
  .g-jump { gap: 2px; padding: 4px; }
  .g-jump button { padding: 8px 7px; font-size: 11.5px; letter-spacing: 0.02em; }
  .g-scale { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .g-panel { max-height: 46vh; }
}

/* --- Starship: полёт на корабле (explore.js) --- */
.ship { position: fixed; inset: 0; z-index: 29; background: #000; overflow: hidden; }
#shipCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.s-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.s-label {
  position: absolute;
  left: 0;
  top: -8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: none;
  color: rgba(225, 232, 255, 0.85);
  font: 400 12px var(--sans);
  line-height: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 8px #000;
  cursor: pointer;
  pointer-events: auto;
}
.s-label[hidden] { display: none; }
.s-label.flip { flex-direction: row-reverse; }
.s-label.flip .dot { margin-left: 0; margin-right: -2.5px; }
/* над / под точкой: текст уходит вверх/вниз, точка остаётся на объекте */
.s-label[data-mode='above'] .txt { transform: translateY(-17px); }
.s-label[data-mode='below'] .txt { transform: translateY(17px); }
.s-label .dot { width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; flex: none; }
.s-label:hover .txt, .s-label.active .txt { color: #fff; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(232, 180, 92, 0.6); }
.s-label.active { color: var(--amber); }
.s-label.active .dot { box-shadow: 0 0 0 3px rgba(232, 180, 92, 0.35), 0 0 10px currentColor; }
.s-label[data-kind='planet'] { color: #fff; font-weight: 500; }
.s-label[data-kind='moon'] { color: rgba(235, 238, 250, 0.88); font-size: 11.5px; }
.s-label[data-kind='local-star'], .s-label[data-kind='sun'] { color: #f2d49b; font-weight: 600; }
.s-label[data-kind='stop'] { color: rgba(205, 220, 255, 0.75); font-size: 11.5px; }
.s-label[data-kind='exo'] { color: #7fe6d2; font-size: 11.5px; }
.s-label[data-kind='marker'] { color: rgba(190, 215, 240, 0.8); font-size: 11.5px; }
.ship-head { flex-wrap: wrap; }
.ship-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ship-tools .btn { padding: 9px 14px; font-size: 13px; }
.ship-tools .on { border-color: rgba(232, 180, 92, 0.65); color: var(--amber); }
.ship-hud { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); text-align: center; pointer-events: none; text-shadow: 0 1px 4px #000, 0 0 10px #000; }
.ship-speed { font: 600 22px var(--sans); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.ship-tline { font-size: 13px; color: rgba(225, 232, 255, 0.82); min-height: 18px; font-variant-numeric: tabular-nums; }
.ship-auto { display: none; margin-top: 6px; pointer-events: auto; border: 1px solid rgba(232, 180, 92, 0.5); background: rgba(232, 180, 92, 0.14); color: var(--amber); border-radius: 999px; padding: 5px 12px; font: 600 11px var(--sans); letter-spacing: 0.16em; text-transform: uppercase; cursor: pointer; }
.ship-auto.on { display: inline-block; }
/* «куда дальше»: ближайшее неоткрытое место — одно нажатие, и это цель */
.ship-next { display: inline-block; margin-top: 6px; pointer-events: auto; border: 1px solid rgba(127, 230, 210, 0.45); background: rgba(10, 30, 40, 0.55); color: #a7f0e2; border-radius: 999px; padding: 5px 14px; font: 500 12.5px var(--sans); cursor: pointer; }
.ship-next:hover { border-color: rgba(127, 230, 210, 0.8); color: #fff; }
.ship-next.hidden { display: none; }
.ship-throttle {
  position: absolute;
  right: 18px;
  top: 50%;
  width: 34px;
  height: min(260px, 36vh);
  transform: translateY(-50%);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  border-radius: 17px;
  overflow: hidden;
  touch-action: none;
  cursor: ns-resize;
}
.ship-throttle i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, rgba(232, 180, 92, 0.9), rgba(246, 207, 135, 0.5)); }
.ship-throttle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-90deg); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(233, 237, 255, 0.75); pointer-events: none; text-shadow: 0 1px 2px #000; }
.ship-boost {
  display: none;
  position: absolute;
  right: 8px;
  top: calc(50% + min(130px, 18vh) + 14px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(232, 180, 92, 0.5);
  background: var(--panel);
  color: var(--amber);
  font: 600 11px var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  touch-action: none;
}
.ship-boost.on { background: rgba(232, 180, 92, 0.35); color: #1c1305; }
@media (pointer: coarse) { .ship-boost { display: block; } }
.ship-target { left: 16px; right: auto; bottom: calc(78px + env(safe-area-inset-bottom)); padding-top: 16px; }
.ship-target h3, .ship-panel h3 { font-size: 22px; margin-right: 26px; }
.ship-target .info-stats { margin: 4px 0 10px; }
.ship-target p { white-space: pre-line; color: #e3e8ff; font-size: 14px; }
.ship-target .btn, .ship-panel .btn { margin-bottom: 10px; }
.ship-panel { top: calc(92px + env(safe-area-inset-top)); bottom: auto; right: 64px; max-height: calc(100% - 190px); padding-top: 16px; }
.ship-panel p { color: #e3e8ff; font-size: 14px; }
.ship-note { margin-top: -4px !important; color: var(--muted) !important; font-size: 13px !important; }
.ship-list { list-style: none; margin: 0 0 10px; padding: 0; }
.ship-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 10px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(140, 170, 255, 0.12);
  color: var(--text);
  padding: 8px 2px;
  font: inherit;
  cursor: pointer;
}
.ship-list button:hover .n { color: var(--amber); }
.ship-list .n { font-weight: 600; }
.ship-list .d { color: var(--amber); font-variant-numeric: tabular-nums; font-size: 13px; }
.ship-list .k { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.ship-tasks { list-style: none; margin: 0 0 10px; padding: 0; }
.ship-tasks li { position: relative; padding: 5px 0 5px 24px; font-size: 14px; }
.ship-tasks li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 11px; height: 11px; border: 1.5px solid rgba(232, 180, 92, 0.6); border-radius: 50%; }
.ship-tasks li.done { color: var(--muted); }
.ship-tasks li.done::before { background: var(--amber); border-color: var(--amber); }
.ship-stats { font-size: 13px !important; color: var(--muted) !important; }
.ship-found-h { margin: 12px 0 6px; font-size: 10.5px; }
.ship-found { margin-bottom: 6px; }
.ship-found span { font-size: 12px; padding: 2px 9px; }
.ship-toast {
  position: absolute;
  left: 50%;
  top: calc(96px + env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 32px);
  padding: 10px 20px;
  background: var(--panel);
  border: 1px solid rgba(232, 180, 92, 0.38);
  border-radius: 18px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
  pointer-events: none;
}
.ship-toast b { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--amber); }
.ship-toast span { font-size: 14px; }
.ship-toast.pop { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.ship-stick { position: absolute; left: -60px; top: -60px; width: 120px; height: 120px; border: 1.5px solid rgba(232, 180, 92, 0.45); border-radius: 50%; pointer-events: none; }
.ship-stick i { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgba(232, 180, 92, 0.35); }
.ship-pointer { position: absolute; left: 0; top: 0; pointer-events: none; color: var(--amber); font-size: 12px; text-shadow: 0 1px 3px #000; }
.ship-pointer i { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; background: var(--amber); clip-path: polygon(0 0, 100% 50%, 0 100%, 28% 50%); }
.ship-pointer span { position: absolute; left: 0; top: 14px; transform: translateX(-50%); white-space: nowrap; }
.ship-boosting .ship-speed { color: #bfe4ff; text-shadow: 0 0 12px rgba(120, 190, 255, 0.7), 0 1px 4px #000; }
.ship-badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font: 700 10px var(--sans); letter-spacing: 0.18em; vertical-align: middle; color: #0c1530; background: #9fd3ff; }

/* обучение первого полёта — подсказка держится, пока игрок не сделает шаг */
.ship-coach { position: absolute; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 120px); padding: 9px 18px; border: 1px solid rgba(232, 180, 92, 0.55); border-radius: 999px; background: rgba(12, 18, 44, 0.82); color: #f6e4bf; font-size: 14px; text-align: center; pointer-events: none; box-shadow: 0 0 24px rgba(232, 180, 92, 0.16); animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
/* фото с корабля */
.ship-photo { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 3, 10, 0.78); }
.photo-box { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; max-height: 100%; animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.photo-box img { max-width: min(960px, 100%); max-height: calc(100vh - 140px); border-radius: 10px; border: 1px solid rgba(232, 180, 92, 0.4); box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.photo-actions .btn { flex: none; min-width: 110px; }
.ship-flash { position: absolute; inset: 0; z-index: 5; background: #fff; pointer-events: none; animation: flash 0.45s ease-out forwards; }
@keyframes flash { from { opacity: 0.75; } to { opacity: 0; } }

/* ангар: карточки кораблей с их 3D-портретом на «посадочной площадке» */
.ship-hangar { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2, 3, 10, 0.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.hangar-box { position: relative; width: min(880px, 100%); max-height: 100%; overflow-y: auto; padding: 20px 22px 18px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55); animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hangar-box h3 { margin: 4px 0 4px; font-family: var(--serif); font-size: 26px; color: var(--amber); }
.hangar-note { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.hangar-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hangar-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px 16px;
  text-align: center;
  font: inherit;
  color: var(--text);
  background: radial-gradient(circle at 50% 36%, rgba(80, 110, 200, 0.26), rgba(6, 10, 26, 0.15) 64%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.2s;
}
.hangar-card:hover { border-color: rgba(232, 180, 92, 0.6); transform: translateY(-2px); }
.hangar-card.current { border-color: rgba(232, 180, 92, 0.85); box-shadow: 0 0 0 1px rgba(232, 180, 92, 0.25), 0 0 34px rgba(232, 180, 92, 0.14); }
.hangar-pic { position: relative; width: 100%; aspect-ratio: 1; }
/* посадочная площадка под кораблём — тонкий янтарный эллипс, как на листе атласа */
.hangar-pic::before { content: ''; position: absolute; left: 14%; right: 14%; bottom: 17%; height: 15%; border-radius: 50%; border: 1px solid rgba(232, 180, 92, 0.38); background: radial-gradient(ellipse, rgba(232, 180, 92, 0.2), transparent 70%); }
.hangar-pic img { position: relative; width: 100%; height: 100%; object-fit: contain; transition: transform 0.25s; }
.hangar-card:hover .hangar-pic img { transform: scale(1.05) rotate(-2deg); }
.hangar-info { display: flex; flex-direction: column; align-items: center; }
.hangar-name { font-family: var(--serif); font-size: 19px; letter-spacing: 0.14em; text-transform: uppercase; color: #f2d49b; }
.hangar-text { margin-top: 4px; min-height: 38px; font-size: 13.5px; line-height: 1.4; color: #cfd6f0; }
.hangar-tag { margin-top: 12px; padding: 6px 14px; border: 1px solid rgba(232, 180, 92, 0.5); border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--amber); }
.hangar-card.current .hangar-tag { background: rgba(232, 180, 92, 0.2); }
.hangar-list { grid-template-columns: repeat(4, 1fr); }
/* характеристики корабля: четыре строки по пять делений */
.hangar-stats { display: grid; grid-template-columns: auto auto; gap: 3px 8px; margin-top: 8px; font-size: 11px; color: var(--muted); align-items: center; }
.hangar-stats span { text-align: right; letter-spacing: 0.06em; }
.hangar-stats i { display: flex; gap: 2px; }
.hangar-stats i b { width: 9px; height: 5px; border-radius: 2px; background: rgba(140, 160, 230, 0.22); }
.hangar-stats i b.on { background: var(--amber); }
.hangar-role { font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
/* корабль поддержавших игру */
.hangar-card.supporter { border-color: rgba(232, 180, 92, 0.45); background: linear-gradient(180deg, rgba(232, 180, 92, 0.08), rgba(11, 17, 38, 0.6)); }
.hangar-card.locked .hangar-pic img { filter: saturate(0.6) brightness(0.8); }
.hangar-support { width: 100%; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.hangar-support .btn { width: 100%; padding: 9px 10px; font-size: 13px; }
.hangar-support input { width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--panel-border);
  background: rgba(4, 7, 18, 0.7); color: var(--text); font: inherit; font-size: 12px; }
.hangar-msg { font-size: 12px; color: var(--muted); min-height: 1em; }
.hangar-msg.ok { color: var(--amber); }
.hangar-msg.bad { color: #ff9b8a; }
@media (max-width: 1000px) and (min-width: 701px) { .hangar-list { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 700px) {
  .hangar-box { padding: 16px 14px 14px; }
  .hangar-box h3 { font-size: 22px; }
  .hangar-list { grid-template-columns: 1fr; gap: 10px; }
  .hangar-card { flex-direction: row; gap: 10px; padding: 6px 12px 6px 4px; text-align: left; }
  .hangar-pic { width: 112px; flex: none; }
  .hangar-info { align-items: flex-start; }
  .hangar-text { min-height: 0; }
  .hangar-tag { margin-top: 8px; }
  .ship-head h2 { font-size: 20px; }
  .ship-tools .btn { padding: 7px 10px; font-size: 12px; }
  .ship-tools .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .ship-hud { bottom: auto; top: calc(128px + env(safe-area-inset-top)); }
  .ship-speed { font-size: 18px; }
  .ship-toast { top: calc(178px + env(safe-area-inset-top)); }
  .ship-throttle { right: 10px; top: 46%; height: 30vh; }
  .ship-boost { top: calc(46% + 15vh + 12px); right: 6px; }
  /* справа оставлено место для полосы тяги и кнопки Boost — карточка их не закрывает */
  .ship-target, .ship-panel { left: 12px; right: 76px; width: auto; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); max-height: 40vh; }
  .ship-panel { max-height: 62vh; }
}

/* --- Рассказ о месте: фото с медленным «наездом», заголовок и текст появляются по очереди --- */
.viewer-panel { transition: width 0.35s ease, border-color 0.35s, box-shadow 0.35s; }
.viewer.story .viewer-panel {
  width: min(440px, calc(100% - 32px));
  max-height: min(72vh, 640px);
  border-color: rgba(232, 180, 92, 0.32);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(232, 180, 92, 0.08), 0 0 40px rgba(232, 180, 92, 0.08);
}
.v-story-photo { margin: -14px -16px 12px; }
.v-story-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background: linear-gradient(110deg, #0d1633 30%, #18244a 50%, #0d1633 70%) 0 0 / 300% 100%;
}
.v-story-photo.loading .v-story-frame { animation: shimmer 1.4s linear infinite; }
.v-story-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(11, 17, 38, 0) 55%, rgba(11, 17, 38, 0.85) 100%);
  pointer-events: none;
}
.v-story-frame img { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: 60% 40%; }
.v-story.enter .v-story-frame img { animation: kenburns 16s ease-out both; }
.v-story-photo figcaption { margin: 6px 16px 0; font-size: 11px; }
.v-story-body .caps { letter-spacing: 0.18em; font-size: 10.5px; }
.v-story-body h3 {
  margin: 6px 0 8px;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #fff1d6 0%, #e8b45c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.v-story-body p { font-size: 15.5px; line-height: 1.55; color: #e3e8ff; }
.v-story-body .link-btn { padding: 2px 0 12px; }
.v-story.enter .v-story-photo { animation: photo-in 0.9s ease both; }
.v-story.enter .v-story-body > * { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.v-story.enter .v-story-body > :nth-child(1) { animation-delay: 0.25s; }
.v-story.enter .v-story-body > :nth-child(2) { animation-delay: 0.38s; }
.v-story.enter .v-story-body > :nth-child(3) { animation-delay: 0.55s; }
.v-story.enter .v-story-body > :nth-child(4) { animation-delay: 0.75s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes photo-in { from { opacity: 0; filter: blur(8px) brightness(1.4); } to { opacity: 1; filter: none; } }
@keyframes kenburns { from { transform: scale(1.16) translate(2%, 1%); } to { transform: scale(1.02) translate(0, 0); } }
@keyframes shimmer { to { background-position: -300% 0; } }
@media (prefers-reduced-motion: reduce) {
  .v-story.enter .v-story-frame img, .v-story.enter .v-story-photo, .v-story.enter .v-story-body > * { animation: none; }
}
.v-help { color: var(--muted); font-size: 13px; }
.v-spots { position: absolute; inset: 0; pointer-events: none; }
.v-marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  pointer-events: auto;
}
/* метка — кольцо с прозрачной серединой, чтобы не закрывать то, на что она указывает */
.v-marker::before {
  content: '';
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.v-marker .dot {
  position: absolute;
  left: -12px;
  top: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #e8b45c;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s, box-shadow 0.15s;
}
.v-marker:hover .dot, .v-marker:focus-visible .dot { transform: scale(1.15); }
.v-marker .lbl {
  position: absolute;
  left: 17px;
  top: -10px;
  white-space: nowrap;
  font: 500 12px var(--sans);
  color: #f3ece0;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.v-marker.flip .lbl { left: auto; right: 17px; }
.v-marker:hover .lbl, .v-marker.active .lbl { opacity: 1; }
.v-marker.active .dot {
  border-color: #ffd58f;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(232, 180, 92, 0.35), 0 0 14px rgba(232, 180, 92, 0.6);
}
.v-photo { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
/* слой «живого» снимка: лёгкий наклон за мышью и медленное «дыхание» (viewer.js, PhotoView.tilt) */
.v-photo-tilt { position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform; }
.v-photo-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.v-photo-inner img {
  display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none;
  /* края снимка мягко растворяются в фоне — без жёсткого чёрного прямоугольника на тёмно-синем */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent), linear-gradient(180deg, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent), linear-gradient(180deg, transparent, #000 6%, #000 94%, transparent);
  mask-composite: intersect;
}
/* у снимка тёмные края (звезда или туманность на чёрном) — чёрный фон растворяется овалом;
   --fade-start ставит viewer.js (edgeFade): сразу за самим объектом и за всеми метками */
.v-photo-inner img.dark-edge {
  -webkit-mask-image: radial-gradient(ellipse closest-side, #000 var(--fade-start, 75%), transparent 100%);
  mask-image: radial-gradient(ellipse closest-side, #000 var(--fade-start, 75%), transparent 100%);
}
.v-photo-spots { position: absolute; inset: 0; }
.v-photo-spots .v-marker { transform: scale(var(--inv, 1)); transform-origin: 0 0; }
@media (max-width: 700px) {
  .viewer-panel { left: 16px; right: 16px; width: auto; max-height: 38vh; }
  .viewer.story .viewer-panel { width: auto; max-height: 56vh; }
  .v-story-frame { aspect-ratio: 16 / 8; }
  .v-story-body h3 { font-size: 21px; }
  .v-story-body p { font-size: 14.5px; }
  .viewer-head h2 { font-size: 24px; }
  .v-marker .lbl { display: none; }
  .v-marker.active .lbl { display: block; }
}

/* --- Кнопки --- */
.actions {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  width: min(520px, calc(100% - 32px));
  z-index: 4;
}
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, opacity 0.15s, box-shadow 0.2s, filter 0.15s;
}
/* главная кнопка — фирменный янтарь, как свет звезды */
.btn.primary {
  flex: 1;
  color: #1c1305;
  background: linear-gradient(180deg, #f6cf87 0%, #e8b45c 55%, #d49a43 100%);
  border-color: rgba(255, 226, 170, 0.6);
  box-shadow: 0 6px 22px rgba(232, 180, 92, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 6px 28px rgba(232, 180, 92, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.btn.primary:disabled {
  color: rgba(233, 237, 255, 0.7);
  background: rgba(232, 180, 92, 0.14);
  border-color: rgba(232, 180, 92, 0.35);
  box-shadow: none;
  cursor: default;
}
.btn.ghost { background: var(--panel); border-color: var(--panel-border); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn.ghost:hover:not(:disabled) { border-color: rgba(140, 170, 255, 0.45); }
.btn.ghost:disabled { opacity: 0.5; cursor: default; }
.btn.wide { width: 100%; display: block; }
a.btn { text-align: center; text-decoration: none; box-sizing: border-box; }
.btn.wide + .btn.wide { margin-top: 10px; }

.zoom {
  position: fixed;
  right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
}

/* --- Окна --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 13, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modal {
  width: min(460px, 100%);
  max-height: calc(100% - 16px);
  overflow-y: auto;
  background: rgba(11, 17, 38, 0.97);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
}
.modal h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 22px; letter-spacing: 0.05em; }
.modal { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(232, 180, 92, 0.06); }
.lead { color: var(--muted); margin: 0 0 12px; }
.rules { margin: 0 0 16px; padding-left: 18px; line-height: 1.5; font-size: 15px; }
.rules li { margin-bottom: 6px; }
/* три шага на первом экране: номера — янтарные кружки, как метки на карте */
.quick-steps { list-style: none; counter-reset: step; margin: 4px 0 18px; padding: 0; font-size: 15px; line-height: 1.4; }
.quick-steps li { counter-increment: step; display: flex; align-items: baseline; gap: 10px; margin: 0 0 9px; }
.quick-steps li > span { flex: 1; }
.quick-steps li::before {
  content: counter(step); flex: 0 0 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(232, 180, 92, 0.6);
  color: var(--amber); font-size: 12px; font-weight: 600; line-height: 21px; text-align: center; transform: translateY(-1px);
}
/* Настройки на стартовом экране — свёрнуты в одну строку */
.settings-wrap { margin-top: 12px; font-size: 14px; }
.settings-wrap summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.settings-wrap .settings-note { margin-left: 10px; font-weight: 400; font-size: 12px; }
.settings-wrap .settings-note.on { color: var(--amber); }
.settings-wrap .setting:first-of-type { margin-top: 10px; }
.privacy-line { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.privacy-line a { color: var(--muted); }
.report-link { display: block; margin: 8px 0 0; font-size: 12px; color: var(--muted); }
/* резервная копия прогресса — в настройках, под переключателями */
.setting.backup { cursor: default; flex-wrap: wrap; }
.backup-btns { display: flex; gap: 8px; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
/* знак «Supporter» — поддержал игру (янтарная звёздочка рядом с именем) */
.supporter-badge { display: inline-flex; vertical-align: -2px; margin-left: 5px; }
.supporter-badge svg { fill: var(--amber); filter: drop-shadow(0 0 4px rgba(232, 180, 92, 0.55)); }
.menu-stats .supporter-badge { margin-left: 0; }
/* «Share your result» + «As image» в одну строку */
.share-row { display: flex; gap: 10px; }
.share-row #shareBtn { flex: 1; }
/* предпросмотр картинки результата */
.card-shot { position: relative; text-align: center; }
.card-shot img { display: block; width: 100%; max-height: 62vh; object-fit: contain; border-radius: 12px; margin: 22px 0 14px; }
.card-shot-actions { display: flex; gap: 10px; justify-content: center; }
.card-shot-actions .btn { flex: 1; }
.how-to { margin-top: 14px; font-size: 14px; }
.how-to summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.how-to[open] summary { margin-bottom: 10px; }
.how-to .rules { font-size: 14px; }
/* подсказки про клавиатуру — только там, где есть мышь; «pinch» — только на сенсорных экранах */
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .kbd-only { display: none; }
  .touch-only { display: inline; }
}

.big-score { font-family: var(--serif); font-size: 50px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0 10px; color: #ffe2a8; text-shadow: 0 0 24px rgba(232, 180, 92, 0.35); }
.big-score small { font-family: var(--sans); font-size: 18px; color: var(--muted); font-weight: 500; margin-left: 6px; text-shadow: none; }
.s-list { list-style: none; margin: 0 0 14px; padding: 0; }
.s-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(140, 170, 255, 0.1);
  font-size: 15px;
}
.s-list .emoji { width: 22px; display: flex; justify-content: center; }
.s-list .nm { flex: 1; }
.s-list .pt { font-variant-numeric: tabular-nums; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats div { text-align: center; background: rgba(140, 170, 255, 0.07); border-radius: 12px; padding: 8px 4px; }
.stats b { display: block; font-family: var(--serif); font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11px; color: var(--muted); }
/* серия с заморозками и история очков в итогах дня */
.streak-note { margin: -4px 0 12px; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.4; }
.streak-note b { color: var(--text); font-weight: 600; }
.history { margin: 0 0 14px; padding: 10px 12px 8px; border-radius: 12px; background: rgba(140, 170, 255, 0.05); }
.history-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.history-head .caps { letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; }
#sHistChart svg { display: block; width: 100%; height: auto; overflow: visible; }
.history .bar { fill: #e8b45c; opacity: 0.55; pointer-events: none; }
.history .miss { pointer-events: none; }
.history .bar.now { opacity: 1; }
.history .hit:hover + .bar, .history .hit:focus + .bar { opacity: 0.9; }
.history .hit { fill: transparent; }
.history .miss { fill: rgba(154, 166, 209, 0.35); }
.history .base { stroke: rgba(154, 166, 209, 0.25); stroke-width: 1; }
.history .tick { fill: var(--muted); font-size: 9px; font-family: var(--sans); }
.grades { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.grades .g-icon { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.grades .g-icon svg { flex: none; }
.grades .g-bar { height: 6px; border-radius: 0 3px 3px 0; background: #e8b45c; opacity: 0.75; min-width: 2px; }
.grades .g-n { font-variant-numeric: tabular-nums; color: var(--text); text-align: right; }
.share-text {
  display: block;
  width: 100%;
  margin-top: 10px;
  resize: none;
  background: rgba(140, 170, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  font: 14px/1.4 var(--sans);
}
/* вызов другу и таблица друзей в итогах */
.challenge { display: flex; gap: 8px; margin-top: 10px; }
.challenge .nick { flex: 1; min-width: 0; padding: 0 12px; border: 1px solid var(--panel-border); border-radius: 12px; background: rgba(8, 12, 30, 0.6); color: var(--text); font: 15px var(--sans); }
.challenge .nick::placeholder { color: var(--muted); }
.challenge .btn { flex: none; }
.s-row { display: flex; gap: 8px; margin-top: 10px; }
.s-row .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
.friends { margin: 12px 0 14px; }
.friends-list { list-style: none; margin: 6px 0 0; padding: 0; }
.friends-list li { display: grid; grid-template-columns: 22px 1fr auto 44px; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid rgba(140, 170, 255, 0.12); font-size: 14px; }
.friends-list li.me { color: var(--amber); }
.friends-list .rk { color: var(--muted); font-variant-numeric: tabular-nums; }
.friends-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friends-list .gr { display: flex; gap: 2px; }
.friends-list .pt { text-align: right; font-variant-numeric: tabular-nums; }
.friends-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.next-in { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.next-in span { font-variant-numeric: tabular-nums; color: var(--text); }
/* прицел в центре экрана — для игры с клавиатуры (стрелки + пробел), только во время вопроса */
.kbd-cross { display: none; position: fixed; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; pointer-events: none; z-index: 5; }
.kbd-cross::before, .kbd-cross::after { content: ''; position: absolute; background: rgba(232, 180, 92, 0.85); box-shadow: 0 0 4px #000; }
.kbd-cross::before { left: 12px; top: 0; width: 2px; height: 26px; }
.kbd-cross::after { top: 12px; left: 0; width: 26px; height: 2px; }
body.kbd-aim .kbd-cross { display: block; }
/* архив прошлых головоломок в итогах */
.archive { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--panel-border); }
.archive-title { margin: 0 0 10px; text-align: center; font-size: 13px; color: var(--muted); }
.archive-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-height: 132px; overflow-y: auto; }
.arch {
  display: inline-flex; flex-direction: column; align-items: center; min-width: 52px; padding: 6px 8px;
  border: 1px solid var(--panel-border); border-radius: 10px; color: var(--text); text-decoration: none;
  font-size: 12px; line-height: 1.25; background: rgba(255, 255, 255, 0.02);
}
.arch b { font-weight: 600; font-variant-numeric: tabular-nums; }
.arch span { color: var(--amber); font-variant-numeric: tabular-nums; }
.arch.done span { color: var(--muted); }
.arch:hover { border-color: rgba(232, 180, 92, 0.5); }
.arch.current { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(232, 180, 92, 0.35); }
.arch.today { justify-content: center; color: var(--amber); font-weight: 600; }
.intro-archive { margin-top: 12px; padding-top: 10px; }
.intro-archive summary { cursor: pointer; margin: 0; }
.intro-archive[open] summary { margin-bottom: 10px; }

@media (max-width: 420px) {
  .brand .brand-text { display: none; } /* на узком телефоне в шапке остаётся только значок-булавка */
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(16px + env(safe-area-inset-top));
  background: rgba(20, 28, 60, 0.96);
  border: 1px solid var(--panel-border);
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 20;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  width: max-content;
  max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

@media (max-width: 520px) {
  .topbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .topbar .icon-btn { width: 34px; height: 34px; font-size: 16px; }
  .topbar .icon-btn svg { width: 16px; height: 16px; }
  .dots { gap: 3px; }
  .meta { font-size: 13px; }
  .info-head { gap: 12px; }
  .info-title h2 { font-size: 22px; }
  .brand { font-size: 15px; letter-spacing: 0.05em; }
  .meta #puzzleNo { display: none; }
  .question h1 { font-size: 21px; }
  .zoom { display: none; }
  .stats b { font-size: 18px; }
}

/* самые узкие телефоны (320 px): иначе кнопка «?» уезжает за край экрана */
@media (max-width: 350px) {
  .topbar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .topbar .icon-btn { width: 30px; height: 30px; }
  .meta { font-size: 12px; }
  .dots { gap: 2px; }
}
