@import url("https://fonts.googleapis.com/css2?family=Kurale&family=Nunito:wght@400;600;700;800&display=swap");

/* ============================================================
   Playtalia — «Сказочная книга», гамма «Ясный день»
   По мотивам светлых книжных иллюстраций к сказкам: сливочный фон, синие чернила,
   лазурь неба, киноварь, солнечное золото. Вышивка — красная с тёмной обводкой,
   как на русском рушнике и румынской рубашке ie.
   Шрифты: Kurale — заголовки, Nunito — текст и интерфейс.
   Тема: сайт всегда светлый; ночная тема включается кнопкой
   (js/platform.js ставит <html data-theme="dark">).
   Контраст текста проверен: все пары не ниже 4.5:1.
   ============================================================ */

:root {
  --paper: #fff6e3;        /* тёплый сливочный */
  --paper-2: #ffffff;      /* белый лист */
  --ink: #1c2a4a;          /* синие чернила */
  --ink-muted: #4f5d7a;
  --accent: #d2372a;       /* киноварь: кнопки, ссылки */
  --accent-ink: #ffffff;
  --sky: #1a62aa;          /* лазурь: выбранное */
  --sky-tint: #dcebff;
  --gold: #f2a41c;         /* солнце: значки, акценты */
  --green: #1d7f46;        /* луг: пройдено, жанры */
  --border: #f0dcb5;
  --chip: #fde4b5;         /* медовые плашки: фильтры, кнопки, поиск */
  --chip-hover: #fbd48c;
  --stitch: #d2372a;       /* вышивка */
  --stitch-2: #1c2a4a;     /* обводка вышивки */
  --shadow: 0 1px 2px rgba(28, 42, 74, 0.06), 0 12px 28px -12px rgba(120, 70, 10, 0.28);
  --shadow-lift: 0 2px 4px rgba(28, 42, 74, 0.08), 0 24px 44px -16px rgba(120, 70, 10, 0.38);
  /* небо сверху переходит в тёплый луговой свет */
  --page-gradient:
    radial-gradient(900px 420px at 88% -120px, rgba(255, 214, 102, 0.55), transparent 70%),
    linear-gradient(180deg, #cfe7ff 0, #e6f2ff 220px, #fff6e3 640px);
  --font-head: "Kurale", "Palatino Linotype", Georgia, serif;
  --font-body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 18px;

  --backdrop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  --toggle-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 14.5A8.5 8.5 0 0 1 9.5 4a8.5 8.5 0 1 0 10.5 10.5z'/%3E%3C/svg%3E");
}

/* Ночная сказка (только по кнопке): фиолетово-синее небо с сиянием, звёзды, золото лампы */
:root[data-theme="dark"] {
  --paper: #1a1442;
  --paper-2: #2a2263;
  --ink: #fbf1dc;
  --ink-muted: #c4b9e6;
  --accent: #ffbe3d;
  --accent-ink: #2a1700;
  --sky: #7cc4ff;
  --sky-tint: #353083;
  --gold: #ffd166;
  --green: #74e0a4;
  --border: #3d3484;
  --chip: #352c78;
  --chip-hover: #443a99;
  --stitch: #ff6b57;
  --stitch-2: #fbf1dc;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 32px -12px rgba(5, 0, 30, 0.8);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 26px 48px -16px rgba(5, 0, 30, 0.9);
  --page-gradient:
    radial-gradient(1100px 560px at 12% -160px, rgba(140, 90, 255, 0.45), transparent 70%),
    radial-gradient(900px 500px at 100% -80px, rgba(40, 140, 255, 0.35), transparent 70%),
    linear-gradient(180deg, #1d1650 0, #1a1442 700px);
  --backdrop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cg fill='%23fff3d6'%3E%3Ccircle cx='20' cy='30' r='1.2' opacity='.7'/%3E%3Ccircle cx='140' cy='18' r='.8' opacity='.5'/%3E%3Ccircle cx='220' cy='90' r='1.4' opacity='.6'/%3E%3Ccircle cx='90' cy='120' r='.9' opacity='.4'/%3E%3Ccircle cx='180' cy='190' r='1.1' opacity='.55'/%3E%3Ccircle cx='40' cy='220' r='.8' opacity='.45'/%3E%3Ccircle cx='250' cy='240' r='.9' opacity='.4'/%3E%3C/g%3E%3C/svg%3E");
  --toggle-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4.5'/%3E%3Cpath d='M12 1.5v4M12 18.5v4M1.5 12h4M18.5 12h4M4.6 4.6l2.8 2.8M16.6 16.6l2.8 2.8M4.6 19.4l2.8-2.8M16.6 7.4l2.8-2.8' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ---------- База ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--backdrop), var(--page-gradient);
  background-repeat: repeat, no-repeat;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  /* viewport-fit=cover: на iPhone страница доходит до краёв экрана — отступаем от выреза и строки состояния
     (в приложении с экрана «Домой» строка состояния прозрачная и лежит поверх страницы) */
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
  letter-spacing: 0.005em;
}

p { margin: 0; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

img { max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* ---------- Шапка ---------- */

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px 24px;
  flex-wrap: wrap;
  padding: 22px 0 46px;
  margin-bottom: 32px;
}

/* рушник под шапкой */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  background:
    linear-gradient(var(--stitch-2), var(--stitch-2)) top / 100% 2px no-repeat,
    linear-gradient(var(--stitch-2), var(--stitch-2)) bottom / 100% 2px no-repeat;
}

.site-header::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  height: 14px;
  background: var(--stitch);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='14'%3E%3Cpath d='M12 0h2v2h-2zM10 2h2v2h-2zM14 2h2v2h-2zM8 4h2v2H8zM16 4h2v2h-2zM6 6h2v2H6zM12 6h2v2h-2zM18 6h2v2h-2zM8 8h2v2H8zM16 8h2v2h-2zM10 10h2v2h-2zM14 10h2v2h-2zM12 12h2v2h-2zM0 4h2v2H0zM0 6h2v2H0zM0 8h2v2H0zM2 6h2v2H2zM22 6h2v2h-2z'/%3E%3C/svg%3E") left center / 24px 14px repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='14'%3E%3Cpath d='M12 0h2v2h-2zM10 2h2v2h-2zM14 2h2v2h-2zM8 4h2v2H8zM16 4h2v2h-2zM6 6h2v2H6zM12 6h2v2h-2zM18 6h2v2h-2zM8 8h2v2H8zM16 8h2v2h-2zM10 10h2v2h-2zM14 10h2v2h-2zM12 12h2v2h-2zM0 4h2v2H0zM0 6h2v2H0zM0 8h2v2H0zM2 6h2v2H2zM22 6h2v2h-2z'/%3E%3C/svg%3E") left center / 24px 14px repeat-x;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-head);
  font-size: 1.9rem;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

/* знак — раскрытая книга сказок со значком «играть» (favicon.svg) */
.logo-mark {
  flex: none;
  width: 42px;
  height: 42px;
  background: url("../favicon.svg") center / contain no-repeat;   /* тот же знак, что и у вкладки */
  transition: transform 0.4s ease;
}

.logo:hover .logo-mark { transform: rotate(-6deg) scale(1.06); }

.site-nav { display: flex; gap: 4px; }

.site-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover { background: var(--chip); }

.site-nav a[aria-current="page"] {
  color: var(--sky);
  background: var(--sky-tint);
}

/* выбор языка: компактная «таблетка» с родным названием языка */
.lang-select {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 34px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--chip) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2355627a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") right 14px center / 11px no-repeat;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.lang-select:hover { background-color: var(--chip-hover); }
.lang-select option { color: #1f2d48; background: #ffffff; }

.theme-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chip);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.theme-toggle::before {
  content: "";
  width: 20px;
  height: 20px;
  background: var(--ink);
  -webkit-mask: var(--toggle-icon) center / contain no-repeat;
  mask: var(--toggle-icon) center / contain no-repeat;
}

.theme-toggle:hover { background: var(--chip-hover); }

/* ---------- Общие компоненты ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, #000);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000); }

.btn-ghost {
  background: var(--chip);
  color: var(--ink);
}

.btn-ghost:hover { background: var(--chip-hover); }

.btn-small { padding: 7px 15px; font-size: 0.9rem; font-weight: 700; }

.panel {
  background: var(--paper-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
}
/* соседние панели не слипаются */
.panel + .panel { margin-top: 22px; }

.section-title {
  font-size: clamp(1.6rem, 3.2vw, 2rem);
  margin: 0 0 6px;
}

.section-lead {
  color: var(--ink-muted);
  margin-bottom: 20px;
}

.divider {
  height: 0;
  margin: 48px 0;
  border: 0;
}

.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--green);
  color: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.site-footer {
  position: relative;
  margin-top: 64px;
  padding-top: 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1.4fr);
  gap: 20px 40px;
  align-items: start;
  padding-bottom: 8px;
}

.footer-brand .logo { font-size: 1.5rem; margin: 0; }
.footer-brand .logo-mark { width: 34px; height: 34px; }
.footer-brand p { margin-top: 6px; }

.footer-nav { display: flex; flex-direction: column; gap: 4px; }
.footer-nav a { color: var(--ink); font-weight: 700; text-decoration: none; padding: 2px 0; }
.footer-nav a:hover { color: var(--accent); }

.footer-notes p + p { margin-top: 6px; }

@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-nav { flex-direction: row; gap: 18px; }
}

.site-footer::before {
  content: "";
  display: block;
  height: 26px;
  margin-bottom: 22px;
  background:
    linear-gradient(var(--stitch-2), var(--stitch-2)) top / 100% 2px no-repeat,
    linear-gradient(var(--stitch-2), var(--stitch-2)) bottom / 100% 2px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='26'%3E%3Cpath fill='%23c8392a' d='M12 6h2v2h-2zM10 8h2v2h-2zM14 8h2v2h-2zM8 10h2v2H8zM16 10h2v2h-2zM6 12h2v2H6zM12 12h2v2h-2zM18 12h2v2h-2zM8 14h2v2H8zM16 14h2v2h-2zM10 16h2v2h-2zM14 16h2v2h-2zM12 18h2v2h-2zM0 10h2v2H0zM0 12h2v2H0zM0 14h2v2H0zM2 12h2v2H2zM22 12h2v2h-2z'/%3E%3C/svg%3E") left center / 24px 26px repeat-x;
}

/* ---------- Главная: заголовок книги ---------- */

.intro { max-width: 640px; margin-bottom: 26px; }

.intro h1 {
  font-size: clamp(2.2rem, 5.6vw, 3.6rem);
  line-height: 1.05;
  text-wrap: balance;
}

.intro h1 em { font-style: normal; color: var(--accent); }

.intro p { margin-top: 12px; color: var(--ink-muted); font-size: 1.08rem; }

/* ---------- Главная: живая обложка ---------- */

.hero { position: relative; }
.hero-stage { position: relative; }

/* заголовок сайта прямо на небе иллюстрации */
.hero-stage .intro {
  position: absolute;
  left: 40px;
  top: 26px;
  max-width: 78%;
  margin: 0;
  pointer-events: none;
}

/* на картинке — только заголовок в одну строку, над крышей избушки */
.hero-stage .intro p { display: none; }

.hero-stage .intro h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  white-space: nowrap;
  color: #1c2a4a;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.9), 0 0 4px rgba(255, 255, 255, 0.8);
}

.hero-stage .intro h1 em { color: #c1301f; }

.hero-stage .intro p {
  max-width: 440px;
  margin-top: 10px;
  color: #26345a;
  font-weight: 600;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.95), 0 0 3px rgba(255, 255, 255, 0.9);
}


.hero-art {
  display: block;
  margin: 0;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: var(--shadow-lift);
  line-height: 0;
  background: #bfe6ff;
}


.hero-art img {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 470;
  object-fit: cover;
  object-position: 30% 100%;
}

/* живая обложка: неподвижная картинка, поверх неё — анимированная (видна, только пока оживает) */
.live-art { position: relative; }
.live-art .live-art-anim { position: absolute; inset: 0; width: 100%; height: 100%; }
.live-art .live-art-anim[hidden] { display: none; }

/* лента сказок на главной: сразу видно несколько сказок, листается сама, стрелками и пальцем */
.strip-wrap { position: relative; min-width: 0; max-width: 100%; }
.strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 36px) / 3);
  gap: 18px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding: 8px 8px 30px; margin: -8px -8px -16px; scrollbar-width: none;   /* поля — чтобы тени карточек не обрезались */
  min-width: 0; max-width: calc(100% + 16px);
}
.strip::-webkit-scrollbar { display: none; }
.strip-card {
  scroll-snap-align: start; display: flex; flex-direction: column;
  background: var(--paper-2); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow-lift);
}
.strip-art { position: relative; display: block; line-height: 0; background: #bfe6ff; }
.strip-art img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: 62% 100%; }
.strip-badge { position: absolute; left: 12px; top: 12px; background: var(--accent); color: var(--accent-ink); line-height: 1.4; }
.strip-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.strip-origin { color: var(--green); font-weight: 800; font-size: 0.85rem; margin: 0; }
.strip-title { font-size: 1.55rem; margin: 0; }
.strip-title a { color: inherit; text-decoration: none; }
.strip-modes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.strip-arrow {
  position: absolute; top: 34%; z-index: 2; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.9); color: #1c2a4a; font-size: 1.6rem; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}
.strip-arrow.prev { left: -14px; }
.strip-arrow.next { right: -14px; }
@media (max-width: 900px) { .strip { grid-auto-columns: calc((100% - 18px) / 2); } }
@media (max-width: 600px) { .strip { grid-auto-columns: 82%; } }
@media (hover: none) { .strip-arrow { display: none; } }

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 24px 40px;
  align-items: start;
}

.hero-plate {
  position: relative;
  margin: -130px 0 0 32px;
  padding: 26px 30px 28px;
  background: var(--paper-2);
  border-radius: 22px;
  box-shadow: var(--shadow-lift);
}

.hero-origin {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--green);
  font-weight: 800;
  font-size: 0.92rem;
}

/* «Новинка» / «Сказка дня» — почему эта сказка на главной */
.hero-badge { background: var(--accent); color: var(--accent-ink); }

.hero-title { font-size: clamp(2.4rem, 6vw, 3.4rem); margin: 2px 0 10px; }

.hero-desc { font-size: 1.06rem; }

.hero-desc::first-letter {
  float: left;
  font-family: var(--font-head);
  font-size: 3.4em;
  line-height: 0.8;
  padding: 6px 8px 0 0;
  color: var(--accent);
}

.hero-actions {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  padding-top: 18px;
}

.hero-actions .btn { font-size: 1.12rem; padding: 13px 36px; }
.hero-best { color: var(--ink-muted); font-weight: 700; }

/* путь по главам: кружки, соединённые пунктирной «дорожкой» */
.hero-route { padding: 30px 8px 0 0; }
.route-title { font-size: 1.45rem; margin-bottom: 16px; }

.route {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.route-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.route-step + .route-step::before {
  content: "";
  position: absolute;
  top: 30px;
  right: calc(50% + 34px);
  width: calc(100% - 68px);
  border-top: 3px dashed color-mix(in srgb, var(--ink) 25%, transparent);
}

.route-step.is-done + .route-step.is-done::before { border-top-style: solid; border-color: var(--green); }

/* портрет зверя главы */
.route-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--paper-2);
  box-shadow: 0 0 0 3px var(--paper-2), 0 0 0 5px color-mix(in srgb, var(--ink) 15%, transparent);
  font-family: var(--font-head);
  font-size: 1.25rem;
  color: var(--ink-muted);
}

.route-dot img { width: 100%; height: 100%; border-radius: 50%; display: block; }

.route-step.is-done .route-dot { box-shadow: 0 0 0 3px var(--paper-2), 0 0 0 5px var(--green); }

.route-check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 800;
  box-shadow: 0 0 0 2px var(--paper-2);
}

/* следующий зверь ждёт Колобка — покачивается */
.route-step.is-next .route-dot {
  box-shadow: 0 0 0 3px var(--paper-2), 0 0 0 5px var(--accent);
  animation: route-bob 1.8s ease-in-out 4;   /* покачается несколько раз и замрёт — без вечной перерисовки */
}

@keyframes route-bob {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-4px) rotate(-4deg); }
}

.route-name { font-weight: 800; font-size: 0.95rem; }
.route-note { margin-top: 16px; color: var(--ink-muted); font-size: 0.95rem; }

/* ---------- Главная: недавние ---------- */

.shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.shelf-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 8px;
  background: var(--paper-2);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.shelf-item:hover { transform: translateY(-2px); }
.shelf-item img { width: 46px; height: 46px; object-fit: cover; border-radius: 50%; }
.shelf-item a { color: var(--ink); font-weight: 800; text-decoration: none; }
.shelf-item a::after { content: ""; position: absolute; inset: 0; border-radius: 999px; }

/* ---------- Главная: жанры и поиск ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 26px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 8px; }

.tab {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.tab:hover { background: var(--chip-hover); }

.tab[aria-pressed="true"] {
  background: var(--sky);
  color: var(--paper-2);
}

.tab-count { margin-left: 6px; font-weight: 600; opacity: 0.6; }

.search { flex: 0 1 260px; }

.search input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  border: 0;
  border-radius: 999px;
  background: var(--chip) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E") 14px center / 17px no-repeat;
  color: var(--ink);
  font: inherit;
}

.search input::placeholder { color: var(--ink-muted); }
.search input:focus-visible { outline-offset: 1px; border-radius: 999px; }

/* ---------- Главная: карточки ---------- */

.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 34px 26px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
}

.card-art {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card-art img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card-art .badge { position: absolute; left: 12px; top: 12px; line-height: 1.5; }

.card:hover .card-art,
.card:focus-within .card-art {
  transform: translateY(-6px) rotate(-1deg);
  box-shadow: var(--shadow-lift);
}

.card-body { padding: 14px 4px 0; display: flex; flex-direction: column; flex: 1; }
.card-title { font-size: 1.55rem; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; }
.card-meta { color: var(--green); font-size: 0.86rem; font-weight: 800; margin-top: 2px; }
.card-desc { color: var(--ink-muted); font-size: 0.97rem; margin-top: 6px; flex: 1; }

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.92rem;
  color: var(--ink-muted);
  font-weight: 700;
}

/* полки по происхождению — чуть отличаются от полок по действию (зелёный текст) */
.tab.tab-source { color: var(--green); }
.tab.tab-source[aria-pressed="true"] { color: #fff; }
/* золотая звёздочка своей, новой сказки */
.own-star {
  position: absolute; right: 12px; bottom: 10px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold); color: #fff; font-size: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* страшилка: пометка «немножко страшно» в левом нижнем углу обложки */
.spooky-badge {
  position: absolute; left: 12px; bottom: 10px;
  padding: 3px 10px; border-radius: 999px;
  background: #3a1f4a; color: #ffe66a; font-weight: 700; font-size: 0.8rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* значки режимов на карточке: подсказка, что внутри можно смотреть, играть, только играть и без конца */
.card-modes { display: flex; gap: 6px; margin-top: 10px; }
.card-mode {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--paper-2); border: 1px solid var(--border);
  font-size: 0.8rem; line-height: 1; color: var(--ink);
}
.card-mode { position: relative; z-index: 2; text-decoration: none; width: 32px; height: 32px; font-size: 0.95rem; }
.card-mode:hover, .card-mode:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; outline: none; }
/* четыре кнопки режимов на обложке главной */
.hero-modes { gap: 8px; }
.hero-modes .btn { font-size: 0.98rem; padding: 9px 16px; }

/* ленточка-закладка «избранное» */
.fav {
  position: absolute;
  top: -4px;
  right: 18px;
  z-index: 2;
  width: 28px;
  height: 40px;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--paper-2) 70%, transparent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  cursor: pointer;
  transition: height 0.2s ease, background-color 0.2s ease;
}

.fav:hover { background: color-mix(in srgb, var(--stitch) 55%, var(--paper-2)); }
.fav[aria-pressed="true"] { height: 54px; background: var(--stitch); }
.fav:focus-visible { outline: none; background: var(--gold); }

/* будущие сказки — карандашный набросок */
.card.is-soon .card-art { box-shadow: none; outline: 2px dashed var(--border); outline-offset: -2px; }
.card.is-soon .card-art img { opacity: 0.9; }
/* ночью набросок — светлые линии на тёмной бумаге, чтобы не перебивать настоящую игру */
:root[data-theme="dark"] .card.is-soon .card-art img { filter: invert(0.92) hue-rotate(195deg) saturate(0.7); opacity: 0.75; }
.card.is-soon:hover .card-art { transform: none; }
.card.is-soon .card-title { color: var(--ink-muted); }
.card.is-soon .card-meta { color: var(--ink-muted); }
.soon-label {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.5;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-muted);
  border-radius: var(--radius);
  background: var(--chip);
}

/* ---------- Адаптив ---------- */

@media (max-width: 760px) {
  body { font-size: 16px; }
  .page { padding: 0 16px 32px; }
  .site-header { padding: 16px 0 40px; margin-bottom: 24px; }
  .logo { font-size: 1.6rem; }
  .logo-mark { width: 36px; height: 36px; }
  .hero-art { border-radius: 18px; }
  /* шире кадр и сдвиг к центру: герои на обложках стоят в середине и справа */
  .hero-art img { aspect-ratio: 2 / 1; object-position: 60% 100%; }
  /* шапка в две строки: логотип, язык и тема сверху, разделы во всю ширину ниже */
  .site-header { gap: 10px 8px; }
  .logo { margin-right: auto; }
  .lang-select { order: 2; }
  .theme-toggle { order: 3; }
  .site-nav { order: 4; flex-basis: 100%; justify-content: space-between; }
  .site-nav a { white-space: nowrap; }
  /* на телефоне заголовок стоит над иллюстрацией, а не на ней */
  .hero-stage { display: flex; flex-direction: column; }
  .hero-stage .intro { position: static; max-width: none; margin-bottom: 18px; order: -1; }
  .route-dot { width: 52px; height: 52px; }
  .route-step + .route-step::before { top: 25px; right: calc(50% + 29px); width: calc(100% - 58px); }
  .hero-stage .intro p { display: block; }
  .hero-stage .intro h1 { white-space: normal; font-size: clamp(2rem, 8vw, 2.6rem); }
  .hero-stage .intro h1, .hero-stage .intro p,
  :root[data-theme="dark"] .hero-stage .intro h1, :root[data-theme="dark"] .hero-stage .intro p { text-shadow: none; color: var(--ink); }
  .hero-stage .intro p { color: var(--ink-muted); font-weight: 400; }
  .hero-stage .intro h1 em { color: var(--accent); }
  .hero-row { grid-template-columns: 1fr; }
  .hero-plate { margin: -14px 12px 0; padding: 20px 20px 22px; }
  .hero-route { padding: 4px 12px 0; }
  .search { flex-basis: 100%; }
  .panel { padding: 20px; }
}

@media (max-width: 420px) {
  .site-nav { gap: 0; }
  .site-nav a { padding: 7px 9px; font-size: 0.95rem; }
  .games { grid-template-columns: 1fr; }
}

/* сенсорные экраны: все кнопки не меньше 48 px, чтобы детские пальцы попадали с первого раза */
@media (pointer: coarse) {
  .tab, .btn, .btn-small, .site-nav a, .search input { min-height: 48px; }
  .lang-select, .theme-toggle { height: 48px; min-width: 48px; }
  .tab, .site-nav a { display: inline-flex; align-items: center; }
  .fav { width: 36px; height: 48px; }
  .fav[aria-pressed="true"] { height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .card:hover .card-art, .card:focus-within .card-art, .shelf-item:hover, .btn-primary:hover { transform: none; }
}

/* сердечко «Понравилось» на карточке каталога */
.card-foot .like {
  position: relative;
  z-index: 2;   /* над ссылкой, растянутой на всю карточку */
  border: 0;
  background: none;
  padding: 4px 8px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: var(--ink-muted);
  cursor: pointer;
}
.card-foot .like:hover { background: var(--chip); }
.card-foot .like[aria-pressed="true"] { color: #d2372a; }

/* «Лучшие игроки недели» на главной */
.leaders { margin: 8px 0 36px; }
.leaders-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; padding: 0; list-style: none; }
.leaders-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--card, #fff);
  box-shadow: var(--shadow-soft, 0 2px 8px rgba(0, 0, 0, 0.08));
  font-weight: 700;
}
.leaders-list li.is-me { outline: 2px solid var(--accent); }
.nick-ava { display: inline-flex; flex: none; line-height: 0; }
.nick-ava svg { border-radius: 50%; box-shadow: 0 0 0 2px #f2c87a; }
.leaders-medal { font-size: 1.3rem; }
.leaders-stars { color: var(--ink-muted); }
.leaders-more { font-weight: 700; color: var(--accent); }

/* украшение на аватарке ника: наряд-значок в уголке (размер задаёт Igroteka.avatar) */
.nick-ava { position: relative; }
.nick-ava .nick-look { position: absolute; right: -14%; bottom: -14%; width: 50%; height: 50%; line-height: 0; }
.nick-ava .nick-look svg { width: 100% !important; height: 100% !important; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0, 0, 0, 0.25); }
/* золотая рамка аватарки — у тех, кто купил «Набор друга сказок» */
.nick-ava.is-gold > svg { box-shadow: 0 0 0 2px #f6c430, 0 0 0 4px #c98a10, 0 0 6px 4px rgba(246, 196, 48, 0.55); }
