:root {
  /* Лента: тёмная сцена, игра — главный объект; платформа — тонкая медовая обвязка вокруг неё */
  --ink: #0f1016;
  --ink-2: #171922;
  --ink-3: #232634;
  --line: #2f3343;
  --text: #f3f0e8;
  --muted: #9c9eac;
  --honey: #ffb43a;
  --honey-ink: #261800;
  --scrim: rgb(5 6 10 / 0.6);
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:is(button, a, input):focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }

/* --- Каркас --------------------------------------------------------------- */
.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding-top: env(safe-area-inset-top, 0px);
}
@supports (height: 100dvh) { .app { height: 100dvh; } }

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}
.logo-mark {
  /* Знак «Вьюшка»: бобина с лентой. Рисунок — inline-SVG в разметке страницы,
     цвет берётся из currentColor, поэтому за знаком ходить в сеть не нужно. */
  width: 19px;
  height: 19px;
  flex: none;
  color: var(--honey);
}
.topbar-sub { color: var(--muted); font-size: 13px; }
.topbar-btn,
.icon-btn {
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.topbar-btn { padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.topbar-add { background: var(--honey); border-color: var(--honey); color: var(--honey-ink); }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; }
#report-open { margin-left: auto; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.icon-btn .off,
.icon-btn[aria-pressed="false"] .on { display: none; }
.icon-btn[aria-pressed="false"] .off { display: block; }
.topbar-btn:hover,
.icon-btn:hover { border-color: var(--honey); }
@media (max-width: 440px) { .topbar-sub { display: none; } }
@media (max-width: 400px) { .add-word { display: none; } }

/* Сердечко любимых: кольцо копит доступ — 3 игры из ленты, и любимую можно сыграть снова */
.fav-btn { position: relative; }
.icon-btn .fav-ring {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  transform: rotate(-90deg);
  fill: none;
}
.fav-ring circle {
  stroke: var(--honey);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.4s ease-out;
}
.fav-btn.is-ready { color: var(--honey); border-color: transparent; }
.fav-btn.is-ready .fav-heart { animation: pop 0.4s ease-out; }

/* --- Лента ---------------------------------------------------------------- */
.feed {
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.card {
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  justify-content: center;
}
.card-inner {
  width: min(100%, 460px);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px calc(4px + env(safe-area-inset-bottom, 0px));
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  background: var(--ink-2);
  isolation: isolate;
}
.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: radial-gradient(120% 80% at 50% 30%, hsl(var(--hue) 45% 22%), var(--ink-2));
  transition: opacity 0.25s;
}
.cover.is-gone { opacity: 0; pointer-events: none; }
.cover-title { font-family: var(--font-display); font-weight: 800; font-size: 28px; }
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--honey);
  animation: spin 0.8s linear infinite;
}

/* Полка любимых — карточка ленты без игры: лайкнутые игры плитками */
.shelf {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px 16px 16px;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--honey) 14%, var(--ink-2)), var(--ink-2) 70%);
}
.shelf-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--honey);
}
.shelf h2 { margin: 4px 0 6px; font-family: var(--font-display); font-size: 24px; }
.shelf-note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.4; text-wrap: pretty; }
.shelf-grid {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
.shelf-grid::-webkit-scrollbar { display: none; }
.shelf-tile {
  display: grid;
  align-content: end;
  gap: 4px;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: radial-gradient(120% 90% at 30% 15%, hsl(var(--hue) 50% 30%), var(--ink));
  text-align: left;
  cursor: pointer;
}
.shelf-tile b { font-family: var(--font-display); font-size: 15px; line-height: 1.15; overflow-wrap: anywhere; }
.shelf-tile span { font-size: 12px; color: var(--muted); }
.shelf-tile:hover:not(:disabled) { border-color: hsl(var(--hue) 80% 62%); }
.shelf-tile:disabled { cursor: default; opacity: 0.45; }
.shelf-label { color: var(--muted); font-size: 13px; }
.chip[data-kind="fav"] { background: color-mix(in srgb, var(--honey) 20%, var(--ink-3)); color: var(--honey); }

/* Финальный экран рисует лента, а не игра: одинаковый для всех и с честным подсчётом переходов */
.end {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade 0.2s ease-out;
}
.end-box { width: min(100%, 320px); display: grid; gap: 14px; text-align: center; }
.end-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.end-kicker.is-record { color: var(--honey); }
.end-score { margin: 0; display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.end-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 64px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.end-unit { color: var(--muted); font-size: 16px; }
.end-best { margin: -6px 0 0; color: var(--muted); font-size: 14px; }
.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.end-cta { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.end-cta-note { margin: 0; font-size: 13px; color: var(--muted); }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.btn-small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-primary { background: var(--honey); color: var(--honey-ink); }
.btn-ghost { background: var(--ink-3); border: 1px solid var(--line); }
.btn-cta {
  width: 100%;
  background: transparent;
  border: 1.5px solid hsl(var(--hue) 80% 62%);
  color: hsl(var(--hue) 85% 74%);
}
.btn-cta.is-viewka { border-color: var(--honey); color: var(--honey); }

/* Нижняя панель — зона платформы: здесь работает свайп, во время раунда палец принадлежит игре */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 76px;
  padding: 4px 2px;
}
.meta { flex: 1; min-width: 0; display: grid; gap: 3px; }
.chip {
  justify-self: start;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--ink-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip[data-kind="shared"] { background: var(--honey); color: var(--honey-ink); }
.chip[data-kind="bonus"] { background: color-mix(in srgb, var(--honey) 20%, var(--ink-3)); color: var(--honey); }
/* Под названием нет строки «автор · фишка»: она не влезала. Название открывает визитку игры */
.title-btn {
  justify-self: start;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: -6px;
  padding: 3px 6px;
  background: none;
  border: 0;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}
.title-btn:hover { background: var(--ink-2); }
/* Название в 1–3 слова: длинное переносим на вторую строку, а не режем троеточием */
.title {
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.about-i {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  color: var(--muted);
  font: italic 700 12px/1 Georgia, "Times New Roman", serif;
}
.title-btn:hover .about-i { color: var(--honey); }
.actions { display: flex; }
.act {
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 62px;
  padding: 6px 0;
  background: none;
  border: 0;
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
}
.act svg { width: 24px; height: 24px; fill: currentColor; }
.act:hover { background: var(--ink-2); }
.act[aria-pressed="true"] { color: var(--honey); }
.act[aria-pressed="true"] svg { animation: pop 0.3s ease-out; }
/* На телефоне подписи под значками не помещались и наезжали друг на друга: оставляем значки,
   а подпись — только для экранного диктора */
@media (max-width: 420px) {
  .act { width: 46px; }
  .act span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* --- Поделиться ----------------------------------------------------------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  justify-items: center;
  background: var(--scrim);
}
.sheet {
  width: min(100%, 460px);
  display: grid;
  gap: 12px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding-block: 20px calc(20px + env(safe-area-inset-bottom, 0px));
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  animation: rise 0.22s ease-out;
}
.sheet h3 { margin: 0; font-family: var(--font-display); font-size: 18px; text-wrap: balance; }
.sheet p { margin: 0; color: var(--muted); line-height: 1.45; }
.reasons { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.reasons label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink);
  cursor: pointer;
}
.reasons label:has(input:checked) { border-color: var(--honey); }
.reasons input { accent-color: var(--honey); margin: 0; }
/* Визитка игры: название, автор и фишка целиком — в цвете игры */
.about {
  gap: 8px;
  background: linear-gradient(hsl(var(--hue) 40% 18%), var(--ink-2) 140px);
}
.about-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11.5px;
  font-weight: 600;
}
.about h3 { font-size: 24px; color: hsl(var(--hue) 85% 76%); }
.sheet .about-tagline { margin: 4px 0; color: var(--text); font-size: 18px; line-height: 1.35; text-wrap: pretty; }
.sheet .about-best { font-size: 14px; }
.about-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

.linkrow { display: flex; gap: 8px; }
.linkrow input {
  flex: 1;
  min-width: 0;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text);
  font: 13px/1.2 var(--font-mono);
}

/* --- Кабинет автора -------------------------------------------------------- */
.panel-wrap {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  background: var(--scrim);
}
.panel {
  width: min(100%, 560px);
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  animation: slide 0.22s ease-out;
}
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 10px; }
.panel-head h2 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.panel-head .btn { margin-left: auto; }
.tabs { display: flex; gap: 6px; padding: 0 20px 12px; border-bottom: 1px solid var(--line); }
.tab {
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--ink); border-color: var(--text); }
.panel-body {
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
}
.note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.cycle {
  background: var(--ink);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.45;
}
.cycle b { color: var(--honey); font-variant-numeric: tabular-nums; }
.group-title { margin: 8px 0 0; font-family: var(--font-display); font-size: 15px; }
.panel-add { justify-self: start; text-decoration: none; }
.game-report {
  display: grid;
  gap: 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}
.gr-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.gr-title { margin: 0; font-family: var(--font-display); font-size: 16px; color: hsl(var(--hue) 80% 72%); }
.gr-author { color: var(--muted); font-size: 13px; }
.gr-tag {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.quota { display: grid; gap: 6px; }
.quota-bar { height: 6px; border-radius: 3px; background: var(--ink-3); overflow: hidden; }
.quota-bar > i { display: block; height: 100%; min-width: 3px; background: var(--honey); }
.quota-text { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; margin: 0; }
.metrics div { display: grid; gap: 2px; min-width: 0; }
.metrics dt { font-size: 11.5px; color: var(--muted); }
.metrics dd { margin: 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metrics small { font-size: 12px; font-weight: 500; color: var(--muted); }
@media (max-width: 440px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.spec { display: grid; gap: 10px; }
.spec h3 { margin: 6px 0 0; font-family: var(--font-display); font-size: 15px; }
.spec ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.45; }
.spec pre {
  margin: 0;
  overflow-x: auto;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: 12.5px/1.5 var(--font-mono);
}

/* --- Уведомление ---------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: max-content;
  max-width: min(calc(100vw - 32px), 420px);
  transform: translateX(-50%);
  background: var(--text);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.45);
  animation: toast-rise 0.2s ease-out;
}

@keyframes spin { to { transform: rotate(1turn); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-rise { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop { 50% { transform: scale(1.3); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
