/* ===================== Путь Сёгуна ===================== */
:root {
  --bg-0: #0b0a0d;
  --bg-1: #161119;
  --paper: #f4e9d6;
  --muted: rgba(244, 233, 214, .58);
  --gold: #e7c05a;
  --gold-soft: #f6dfa0;
  --gold-deep: #b8882f;
  --ember: #d5622f;
  --crimson: #c0392b;
  --line: rgba(231, 192, 90, .22);
  --card: rgba(255, 255, 255, .05);
  --card-2: rgba(16, 13, 20, .78);
  --ok: #6fd08c;
  --vh: 1vh;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; }

body {
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--paper);
  background: var(--bg-0);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.sprite-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ===================== задник ===================== */
.backdrop {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: #050403;
}

/* нарисованная сцена: луна по центру вверху, пагода справа, сосны и фонари по краям */
/* Кадр смещён так, чтобы центр луны пришёлся на печать 将:
   позиция выверена по центроиду свечения, а не на глаз. */
.scene {
  position: absolute; inset: 0;
  background: url("assets/bg/menu.jpg") 73% top / cover no-repeat;
}

/* Затемнение под интерфейс. Луну не трогаем — вырезаем её из шторки
   радиальным просветом, иначе она гаснет вместе с фоном. */
.scene-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(44% 15% at 50% 14%, transparent 0%, rgba(5, 4, 3, .22) 80%, rgba(5, 4, 3, .38) 100%),
    linear-gradient(180deg, rgba(5, 4, 3, .06) 0%, rgba(5, 4, 3, .26) 32%, rgba(5, 4, 3, .44) 60%, rgba(5, 4, 3, .56) 100%),
    radial-gradient(130% 80% at 50% 48%, transparent 44%, rgba(0, 0, 0, .38) 100%);
  transition: opacity .5s ease;
}
/* на игровом поле и в списках фон уходит дальше, чтобы не спорить с фишками:
   расфокус плюс приглушение — сцена читается как глубина, а не как рисунок */
body[data-screen="game"] .scene { filter: brightness(.42) saturate(.75) blur(3px); transform: scale(1.04); }
body[data-screen="game"] .scene-shade,
body[data-screen="map"] .scene-shade,
body[data-screen="awards"] .scene-shade { opacity: 1.35; }
body[data-screen="map"] .scene, body[data-screen="awards"] .scene { filter: brightness(.7) saturate(.85); }

/* сэйгайха — волны у самого низа, почти растворённые в фоне */
.seigaiha {
  position: absolute; inset: 0; z-index: 1; opacity: .07;
  background-image:
    radial-gradient(circle at 50% 100%, transparent 32%, rgba(231, 192, 90, .85) 33%, transparent 34%),
    radial-gradient(circle at 50% 100%, transparent 22%, rgba(231, 192, 90, .7) 23%, transparent 24%),
    radial-gradient(circle at 50% 100%, transparent 12%, rgba(231, 192, 90, .55) 13%, transparent 14%);
  background-size: 56px 28px;
  mask-image: linear-gradient(180deg, transparent 78%, rgba(0, 0, 0, .95));
  -webkit-mask-image: linear-gradient(180deg, transparent 78%, rgba(0, 0, 0, .95));
}

.motes i {
  position: absolute; left: var(--x); top: var(--y); width: 3px; height: 3px; border-radius: 50%;
  background: rgba(245, 214, 150, .85);
  box-shadow: 0 0 6px rgba(240, 200, 130, .7);
  animation: mote var(--t) ease-in-out var(--d) infinite;
}
@keyframes mote {
  0%, 100% { transform: translate(0, 0); opacity: 0; }
  30% { opacity: .7; }
  50% { transform: translate(10px, -22px); opacity: .45; }
  70% { opacity: .25; }
}

.petals i {
  position: absolute; top: -6%; left: var(--x);
  width: calc(9px * var(--s, 1)); height: calc(9px * var(--s, 1)); opacity: 0;
  background: radial-gradient(circle at 38% 32%, #ffe1ec, #e8899f 70%, #c9647c);
  border-radius: 62% 8% 62% 8%;
  filter: drop-shadow(0 0 5px rgba(255, 200, 215, .3));
  animation: petal var(--t) linear var(--d) infinite;
}
@keyframes petal {
  0% { transform: translate(0, -10vh) rotate(0deg); opacity: 0; }
  8% { opacity: .5; }
  85% { opacity: .34; }
  100% { transform: translate(16vw, 112vh) rotate(540deg); opacity: 0; }
}

/* ===================== каркас ===================== */
#app { position: relative; z-index: 1; height: 100%; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: fade .3s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.btn {
  padding: 13px 22px; border-radius: 14px; font-size: 16px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--paper);
  transition: transform .12s, background .2s, box-shadow .2s;
}
.btn:active { transform: scale(.96); }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep));
  color: #251a06; border-color: rgba(255, 240, 200, .5);
  box-shadow: 0 6px 22px rgba(231, 192, 90, .28), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-big { font-size: 19px; padding: 16px 34px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-size: 18px; background: var(--card); border: 1px solid var(--line); color: var(--paper);
}
.icon-btn.muted { opacity: .45; }

/* ===================== главный экран ===================== */
.screen-home { align-items: center; justify-content: center; overflow-y: auto; }
.home-inner {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 420px;
  padding: clamp(10px, 3vh, 26px) 22px clamp(14px, 3vh, 28px);
  text-align: center;
}

/* ---- печать на фоне луны (луна нарисована на самой сцене) ---- */
.hero {
  position: relative; display: grid; place-items: center;
  width: 100%; height: clamp(132px, 21vh, 186px);
  margin-bottom: clamp(0px, .8vh, 8px);
}

.hero-seal {
  position: relative; z-index: 2; margin-top: 12px; /* совмещение с центром луны */
  width: clamp(80px, 22vw, 104px); aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(158deg, #c8352c 0%, #a52720 52%, #7e1a15 100%);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, .5),
    0 0 26px rgba(200, 53, 44, .3),
    inset 0 1px 0 rgba(255, 190, 170, .35),
    inset 0 -2px 6px rgba(70, 12, 10, .6);
  animation: seal-in .8s cubic-bezier(.2, 1.5, .4, 1) .35s both;
}
/* потёртость краски на оттиске */
.hero-seal::before {
  content: ''; position: absolute; inset: 0; border-radius: 16px; opacity: .3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='90' height='90' filter='url(%23s)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.hero-seal span {
  font-family: 'Yu Mincho', 'Hiragino Mincho ProN', 'MS Mincho', serif;
  font-size: clamp(48px, 13.5vw, 64px); line-height: 1; color: #fdf6ea;
  text-shadow: 0 2px 6px rgba(60, 8, 6, .6);
}
/* тонкая внутренняя обводка оттиска, как на настоящей печати */
.hero-seal::after {
  content: ''; position: absolute; inset: 6px; border-radius: 10px;
  border: 1.5px solid rgba(255, 226, 210, .3);
}
@keyframes seal-in { from { transform: scale(.6) rotate(-10deg); opacity: 0; } }

/* ---- название ---- */
.home-title {
  /* кириллица в японских минчо обычно без засечек — ставим Georgia первой,
     она даёт нужный «каллиграфический» контраст штриха и в русском тексте */
  font-family: Georgia, 'Times New Roman', 'Yu Mincho', serif;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  line-height: .92; letter-spacing: .04em;
  animation: title-in .9s ease .5s both;
}
/* золото по золотой луне не читается — кладём под буквы мягкую тень */
.home-title::before {
  content: ''; position: absolute; z-index: -1;
  left: -14%; right: -14%; top: -18%; bottom: -14%;
  background: radial-gradient(60% 58% at 50% 50%, rgba(6, 4, 3, .82) 0%, rgba(6, 4, 3, .45) 55%, transparent 78%);
  filter: blur(6px);
}
.home-title span {
  background: linear-gradient(178deg, #fff8e6 6%, #f4dfae 42%, #d0a751 82%, #ab7c30 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .85)) drop-shadow(0 4px 18px rgba(0, 0, 0, .6));
}
.home-title .t-1 { font-size: clamp(40px, 12.5vw, 56px); }
.home-title .t-2 { font-size: clamp(34px, 10.6vw, 48px); letter-spacing: .1em; margin-top: -.06em; }
@keyframes title-in { from { opacity: 0; transform: translateY(10px); } }

.home-tagline {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 300px; margin: clamp(8px, 1.6vh, 14px) 0 0;
  color: rgba(226, 206, 172, .62);
  font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase;
  animation: title-in .9s ease .62s both;
}
.home-tagline::before, .home-tagline::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(231, 192, 90, .38), transparent);
}

/* ---- статистика ---- */
.home-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px;
  width: 100%; margin: clamp(12px, 2vh, 20px) 0 clamp(13px, 2.2vh, 22px);
  animation: title-in .9s ease .72s both;
}
.stat {
  position: relative; padding: 11px 6px 10px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, rgba(48, 33, 28, .72), rgba(20, 14, 12, .82));
  border: 1px solid rgba(231, 192, 90, .2);
  box-shadow: inset 0 1px 0 rgba(255, 225, 180, .08), inset 0 0 22px rgba(231, 192, 90, .05);
}
.stat b {
  display: block; font-size: 21px; line-height: 1.1; font-weight: 600;
  color: #f2dda8; text-shadow: 0 0 16px rgba(231, 192, 90, .28);
}
.stat span {
  display: block; margin-top: 3px;
  font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: rgba(226, 206, 172, .5);
}

/* ---- главная кнопка: золотая пластина в двойной раме ---- */
.btn-play {
  position: relative; width: 100%; padding: 17px 24px 16px; border-radius: 14px; overflow: hidden;
  background:
    /* тушевые горы у левого края и ветка у правого — как роспись по золоту */
    radial-gradient(70% 120% at 12% 118%, rgba(120, 84, 24, .34) 0 42%, transparent 62%),
    radial-gradient(48% 90% at 92% 108%, rgba(150, 66, 66, .2) 0 46%, transparent 66%),
    linear-gradient(180deg, #fbeec4 0%, #e9cd8c 34%, #cfa14c 70%, #b0812f 100%);
  color: #2a1a06;
  box-shadow:
    0 14px 32px rgba(150, 104, 34, .34),
    0 2px 0 rgba(110, 76, 22, .85),
    inset 0 1px 0 rgba(255, 252, 238, .9),
    inset 0 -3px 9px rgba(130, 88, 26, .42);
  transition: transform .14s, box-shadow .24s, filter .24s;
  animation: title-in .9s ease .82s both;
}
/* внутренняя рамка с засечками в углах */
.btn-play::before {
  content: ''; position: absolute; inset: 6px; border-radius: 9px; pointer-events: none;
  border: 1px solid rgba(96, 62, 16, .42);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 224, .35);
}
.btn-play::after {
  content: ''; position: absolute; inset: 0; opacity: .18; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23g)'/%3E%3C/svg%3E");
}
.btn-play:active { transform: translateY(2px) scale(.995); box-shadow: 0 6px 16px rgba(180, 128, 44, .26), inset 0 1px 0 rgba(255, 251, 235, .7); }

/* роспись внутри кнопки: горы у левого края, ветка сакуры у правого */
.play-art {
  position: absolute; inset: 0; width: 100%; height: 100%;
  color: rgba(92, 58, 16, .5); pointer-events: none;
}
.art-hills path { fill: rgba(96, 62, 16, .46); }
.art-hills .art-snow { fill: rgba(255, 248, 226, .5); }
.art-branch { color: rgba(72, 42, 12, .62); }
.art-blossoms circle { fill: rgba(178, 72, 72, .52); }
.btn-play-label {
  position: relative; z-index: 1; display: block;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 25px; font-weight: 700; letter-spacing: .06em;
  text-shadow: 0 1px 0 rgba(255, 248, 226, .6);
}
.btn-play-sub {
  position: relative; z-index: 1; display: block; margin-top: 1px;
  font-size: 11.5px; letter-spacing: .16em;
  text-transform: uppercase; color: rgba(42, 26, 6, .6);
}

/* ---- вторичные кнопки ---- */
.home-secondary {
  display: flex; flex-direction: column; gap: 9px; width: 100%;
  margin-top: 10px; animation: title-in .9s ease .9s both;
}
.btn-ink {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 13px 15px; border-radius: 13px; overflow: hidden; text-align: left;
  background: linear-gradient(180deg, rgba(38, 27, 23, .74), rgba(13, 9, 8, .84));
  border: 1px solid rgba(231, 192, 90, .26);
  color: #ece0c9; transition: transform .14s, border-color .24s, box-shadow .24s;
}
/* вторая, внутренняя рамка — тот же приём, что и на золотой кнопке */
.btn-ink::before {
  content: ''; position: absolute; inset: 4px; border-radius: 9px; pointer-events: none;
  border: 1px solid rgba(231, 192, 90, .14);
}
.btn-ink:active { transform: scale(.985); }
.btn-ink:hover { border-color: rgba(231, 192, 90, .46); box-shadow: 0 6px 22px rgba(0, 0, 0, .35); }

.ink-icon { display: grid; place-items: center; width: 26px; height: 26px; color: var(--gold); }
.ink-icon svg { width: 100%; height: 100%; }
.ink-label { flex: 1; font-size: 15.5px; letter-spacing: .02em; }
.ink-arrow { font-size: 22px; line-height: 1; color: rgba(231, 192, 90, .55); }
.ink-count {
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: #f0d79b; background: rgba(231, 192, 90, .12);
  border: 1px solid rgba(231, 192, 90, .26);
}
/* кольцо прогресса достижений */
.ink-ring {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(var(--gold) var(--p), rgba(231, 192, 90, .16) 0);
  mask: radial-gradient(circle, transparent 55%, #000 56%);
  -webkit-mask: radial-gradient(circle, transparent 55%, #000 56%);
}

/* ---- переключатели ---- */
.home-toggles {
  display: flex; gap: 9px; width: 100%;
  margin-top: clamp(12px, 2.2vh, 18px); animation: title-in .9s ease .98s both;
}
.switch {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 12px;
  background: rgba(20, 14, 12, .6); border: 1px solid rgba(231, 192, 90, .16);
  color: rgba(226, 206, 172, .55); font-size: 13px;
  transition: color .24s, border-color .24s;
}
.switch.on { color: #efdcb2; border-color: rgba(231, 192, 90, .34); }
.switch-track {
  position: relative; width: 34px; height: 18px; border-radius: 999px; flex: 0 0 auto;
  background: rgba(0, 0, 0, .45); border: 1px solid rgba(231, 192, 90, .2);
  transition: background .24s, border-color .24s;
}
.switch.on .switch-track { background: rgba(231, 192, 90, .2); border-color: rgba(231, 192, 90, .45); }
.switch-track i {
  position: absolute; top: 50%; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  transform: translateY(-50%);
  background: linear-gradient(180deg, #6a5c4a, #40372c);
  transition: left .24s cubic-bezier(.3, 1.4, .5, 1), background .24s, box-shadow .24s;
}
.switch.on .switch-track i {
  left: 18px;
  background: linear-gradient(180deg, #ffeec2, #d3a95a);
  box-shadow: 0 0 10px rgba(231, 192, 90, .6);
}

/* ---- подсказки и сброс ---- */
.home-hints {
  margin-top: clamp(12px, 2.1vh, 20px);
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; line-height: 1.45; color: rgba(226, 206, 172, .46);
  animation: title-in .9s ease 1.06s both;
}
.home-hints p { margin: 0; }
.home-hints b { color: rgba(240, 215, 155, .8); font-weight: 600; }

.reset-link {
  margin-top: clamp(8px, 1.5vh, 14px); padding: 5px 10px;
  font-size: 11.5px; letter-spacing: .04em;
  color: rgba(190, 92, 82, .58); border-bottom: 1px solid rgba(190, 92, 82, .22);
  transition: color .24s, border-color .24s;
}
.reset-link:hover { color: rgba(214, 106, 94, .9); border-color: rgba(214, 106, 94, .45); }

/* ===================== карта ===================== */
.map-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: rgba(11, 10, 13, .7); backdrop-filter: blur(8px);
}
.map-head h2 { flex: 1; font-size: 18px; letter-spacing: .04em; }
.map-stars { color: var(--gold); font-weight: 700; }

.map-scroll { flex: 1; overflow-y: auto; padding: 10px 14px 40px; scrollbar-width: thin; }
.act { margin-bottom: 18px; }
.act-title {
  display: flex; align-items: center; gap: 12px; margin: 18px 4px 12px;
  font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: var(--gold);
}
.act-title::before, .act-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.act-title span { flex: 0 0 auto; }

.act-nodes { display: flex; flex-direction: column; gap: 10px; }
.node {
  position: relative; display: grid; grid-template-columns: 46px 1fr auto;
  align-items: center; row-gap: 2px; column-gap: 12px;
  padding: 11px 14px; text-align: left; width: 90%;
  border-radius: 16px; border: 1px solid rgba(231, 192, 90, .16);
  background: linear-gradient(180deg, rgba(42, 30, 26, .6), rgba(16, 11, 10, .76));
  transition: transform .14s, border-color .2s, box-shadow .2s;
}
.node.side-right { margin-left: auto; }
.node:not(.locked):active { transform: scale(.98); }
.node.locked { opacity: .38; filter: grayscale(.7); }
.node.next {
  border-color: rgba(231, 192, 90, .6);
  box-shadow: 0 0 0 1px rgba(231, 192, 90, .25), 0 8px 30px rgba(231, 192, 90, .16);
  animation: pulse-node 2.4s ease-in-out infinite;
}
@keyframes pulse-node {
  50% { box-shadow: 0 0 0 1px rgba(231, 192, 90, .45), 0 10px 40px rgba(231, 192, 90, .3); }
}
/* Раскладка задана явно: порядок элементов в разметке иначе разносит
   название в колонку звёзд, а цель — под номер. */
.node-no {
  grid-column: 1; grid-row: 1 / span 2;
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  font-size: 19px; font-weight: 700; color: #241a06;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep));
}
.node.locked .node-no { background: linear-gradient(180deg, #4a423c, #2a2422); color: var(--muted); }
.node-name { grid-column: 2; grid-row: 1; font-weight: 600; font-size: 14.5px; text-align: left; }
.node-goal { grid-column: 2; grid-row: 2; font-size: 11.5px; color: var(--muted); text-align: left; }
.node-stars {
  grid-column: 3; grid-row: 1 / span 2;
  display: flex; gap: 2px; font-size: 12px; color: rgba(255, 255, 255, .16);
}
.node-stars i.lit { color: var(--gold); text-shadow: 0 0 10px rgba(231, 192, 90, .6); font-style: normal; }
.node-stars i { font-style: normal; }
.map-end { text-align: center; color: var(--muted); padding: 24px 0 8px; letter-spacing: .3em; }

/* ===================== достижения ===================== */
.award-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 16px; }
.award-stats .stat { min-width: 0; padding: 10px 6px; text-align: center; }
.award-stats .stat b { font-size: 17px; }
.award-stats .stat span { font-size: 9.5px; }

.award-fresh-note {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 14px; font-size: 13px;
  color: var(--gold-soft); background: rgba(231, 192, 90, .1); border: 1px solid var(--line);
}

.award {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 9px; border-radius: 16px;
  background: var(--card-2); border: 1px solid var(--line);
  opacity: .62; transition: opacity .3s, border-color .3s, box-shadow .3s;
}
.award.done { opacity: 1; border-color: rgba(231, 192, 90, .45); }
.award.fresh {
  box-shadow: 0 0 0 1px rgba(231, 192, 90, .45), 0 10px 34px rgba(231, 192, 90, .22);
  animation: award-pop .6s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes award-pop { from { transform: scale(.9); } }

.award-icon {
  width: 48px; height: 48px; display: grid; place-items: center; font-size: 25px;
  border-radius: 14px; background: rgba(255, 255, 255, .05); filter: grayscale(1);
}
.award.done .award-icon {
  filter: none;
  background: linear-gradient(160deg, rgba(231, 192, 90, .3), rgba(184, 136, 47, .18));
  box-shadow: inset 0 0 0 1px rgba(231, 192, 90, .4);
}
.award-body { min-width: 0; }
.award-head { display: flex; align-items: baseline; gap: 8px; }
.award-title { font-weight: 600; font-size: 14.5px; }
.award-reward { font-size: 12px; color: var(--gold); white-space: nowrap; }
.award-desc { font-size: 12px; color: var(--muted); margin: 1px 0 6px; }
.award-track { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.award-track i { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .4s ease; }
.award-count { font-size: 12.5px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.award.done .award-count { color: var(--ok); font-size: 17px; }

/* ===================== реклама ===================== */
.ad-overlay { z-index: 40; }
.ad-panel { position: relative; }
.ad-badge {
  position: absolute; top: 12px; right: 14px; padding: 2px 9px; border-radius: 999px;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line);
}
.ad-art { font-size: 52px; margin: 6px 0 2px; animation: bob-slow 2.4s ease-in-out infinite; }
@keyframes bob-slow { 50% { transform: translateY(-8px) rotate(-4deg); } }
.ad-timer {
  width: 56px; height: 56px; margin: 12px auto 4px; display: grid; place-items: center;
  border-radius: 50%; font-size: 21px; font-weight: 700; color: var(--gold);
  border: 2px solid var(--line);
}
.ad-timer.done { color: var(--ok); border-color: rgba(111, 208, 140, .55); }

/* новые достижения в панели результата */
.panel-achievements { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.panel-ach-title {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px;
}
.ach-line {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 6px;
  border-radius: 12px; background: rgba(231, 192, 90, .1); text-align: left;
  animation: award-pop .5s cubic-bezier(.2, 1.5, .4, 1);
}
.ach-line-icon { font-size: 19px; }
.ach-line-name { flex: 1; font-size: 13px; font-weight: 600; }
.ach-line-reward { font-size: 12px; color: var(--gold); white-space: nowrap; }
.ach-more { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ===================== игровой экран ===================== */
.game-screen { display: flex; flex-direction: column; height: 100%; gap: 8px; padding: 8px 10px 10px; }
.game-screen.shake { animation: shake .36s ease; }
@keyframes shake {
  20% { transform: translate(4px, -2px); } 40% { transform: translate(-5px, 3px); }
  60% { transform: translate(3px, 2px); } 80% { transform: translate(-2px, -1px); }
}

.hud { display: flex; align-items: center; gap: 10px; }
.hud-level { flex: 1; text-align: center; line-height: 1.25; }
.hud-level-no { display: block; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.hud-level-name { font-size: 15px; font-weight: 600; }

.hud-main { display: flex; align-items: center; gap: 12px; }
.moves-box {
  min-width: 74px; padding: 8px 10px; border-radius: 16px; text-align: center;
  background: var(--card-2); border: 1px solid var(--line);
}
.moves-value { font-size: 26px; font-weight: 700; color: var(--gold); line-height: 1; }
.moves-label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.moves-box.low .moves-value { color: #ff8a7a; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .45; } }

.goal-box { flex: 1; display: flex; gap: 8px; justify-content: flex-end; }
.goal-chip {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px;
  border-radius: 14px; background: var(--card-2); border: 1px solid var(--line);
  transition: transform .2s, border-color .3s;
}
.goal-chip.done { border-color: rgba(111, 208, 140, .5); }
.goal-chip.done .goal-count { color: var(--ok); }
.goal-chip.bump { transform: scale(1.12); }
.goal-art { width: 34px; height: 34px; display: grid; place-items: center; }
.goal-art svg { width: 100%; height: 100%; }
.goal-score { font-size: 20px; color: var(--gold); }
.goal-count { font-size: 16px; font-weight: 700; min-width: 18px; text-align: center; }

/* строка задания: что нужно сделать — слева, набранные очки — справа */
.goal-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 6px;
}
.goal-text {
  min-width: 0; flex: 1;
  font-size: 12.5px; line-height: 1.25; color: rgba(226, 206, 172, .78);
}
.score-bar { display: block; }
.score-track {
  position: relative; width: 100%; height: 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line); overflow: visible;
}
.score-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), var(--gold));
  box-shadow: 0 0 14px rgba(231, 192, 90, .5); transition: width .45s ease;
}
/* Звёзды лежат поверх золотой заливки, поэтому золотыми они сливались:
   тёмная обводка отделяет их от шкалы, зажжённые — оранжевые. */
.star-pip {
  position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 19px; line-height: 1;
  color: rgba(214, 198, 170, .42);
  -webkit-text-stroke: 2.5px rgba(24, 13, 6, .9); paint-order: stroke fill;
  transition: color .3s, text-shadow .3s, transform .3s;
}
.star-pip.lit {
  color: #ff9436;
  text-shadow: 0 0 10px rgba(255, 148, 54, .85), 0 0 20px rgba(224, 96, 24, .5);
  transform: translate(-50%, -50%) scale(1.14);
}
.score-value { flex: 0 0 auto; font-weight: 700; font-size: 15px; color: var(--gold-soft); white-space: nowrap; }

/* ---------- доска ---------- */
.board-wrap {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center;
  container-type: size;
}
.board {
  position: relative;
  /* вписываемся и по ширине, и по высоте контейнера, сохраняя пропорции сетки */
  width: min(92cqw, calc(92cqh * var(--cols) / var(--rows)), 480px);
  aspect-ratio: var(--cols) / var(--rows);
  height: auto;
  border-radius: 20px;
  padding: 3px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(231, 192, 90, .08), transparent 60%),
    var(--card-2);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
  touch-action: none;
}
.board::after {
  content: ''; position: absolute; inset: 0; border-radius: 20px; pointer-events: none;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .45);
}
.board.targeting { box-shadow: 0 0 0 2px var(--ember), 0 18px 50px rgba(0, 0, 0, .5); }

.cell-layer, .tile-layer, .block-layer, .fx-layer { position: absolute; inset: 3px; }
.fx-layer { pointer-events: none; z-index: 5; overflow: hidden; border-radius: 16px; }

.cell, .tile, .blocker, .fx {
  position: absolute; top: 0; left: 0;
  width: calc(100% / var(--cols)); height: calc(100% / var(--rows));
  transform: translate3d(calc(var(--gx) * 100%), calc(var(--gy) * 100%), 0);
}
/* Подложка повторяет форму фишки, а не квадрат клетки: круглые фишки
   в скруглённых квадратах читались как несовпадение. */
/* Уменьшение задаём внутри transform, а не свойством scale: отдельное
   свойство применяется снаружи transform и стягивает клетку к углу доски —
   тем сильнее, чем она дальше, отчего подложки уезжают от фишек. */
.cell {
  border-radius: 50%;
  background: rgba(255, 255, 255, .035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .035);
  transform: translate3d(calc(var(--gx) * 100%), calc(var(--gy) * 100%), 0) scale(.9);
}

/* зона доставки фонарей */
.cell.river {
  background: linear-gradient(180deg, rgba(79, 176, 240, .10), rgba(79, 176, 240, .22));
  box-shadow: inset 0 0 0 1px rgba(139, 216, 255, .35), inset 0 0 18px rgba(79, 176, 240, .25);
  animation: river-glow 3s ease-in-out infinite;
}
@keyframes river-glow { 50% { box-shadow: inset 0 0 0 1px rgba(139, 216, 255, .55), inset 0 0 26px rgba(79, 176, 240, .4); } }

.tile {
  display: grid; place-items: center; z-index: 2;
  transition: transform 300ms cubic-bezier(.34, 1.3, .5, 1);
  will-change: transform;
}
.tile.no-anim { transition: none; }
.gem-art { width: 93%; height: 93%; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .55)); pointer-events: none; }

.tile.selected .gem-art { animation: bob .55s ease-in-out infinite; }
@keyframes bob { 50% { transform: scale(1.14) rotate(4deg); } }
.tile.selected::before {
  content: ''; position: absolute; inset: 8%; border-radius: 14px;
  border: 2px solid var(--gold); box-shadow: 0 0 18px rgba(231, 192, 90, .6);
}
.tile.hint .gem-art { animation: hint 1.1s ease-in-out infinite; }
@keyframes hint { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.18) translateY(-4%); } }
.tile.nudge { animation: nudge .32s ease; }
@keyframes nudge { 25% { transform: translate3d(calc(var(--gx)*100% + 8%), calc(var(--gy)*100%), 0); }
                   75% { transform: translate3d(calc(var(--gx)*100% - 8%), calc(var(--gy)*100%), 0); } }
.tile.spin .gem-art { animation: spin .42s ease; }
@keyframes spin { from { transform: rotate(0) scale(.6); } to { transform: rotate(360deg) scale(1); } }
.tile.born .gem-art { animation: born .42s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes born { from { transform: scale(.2) rotate(-40deg); } }
.tile.popping { z-index: 4; animation: pop .3s ease forwards; }
@keyframes pop { 60% { transform: translate3d(calc(var(--gx)*100%), calc(var(--gy)*100%), 0) scale(1.28); }
                 100% { transform: translate3d(calc(var(--gx)*100%), calc(var(--gy)*100%), 0) scale(0); opacity: 0; } }
.tile.delivered { animation: delivered .4s ease forwards; }
@keyframes delivered { to { transform: translate3d(calc(var(--gx)*100%), calc(var(--gy)*100% + 60%), 0) scale(.4); opacity: 0; } }

/* спецэлементы */
.tile.sp-row::after, .tile.sp-col::after {
  content: ''; position: absolute; inset: 12%; border-radius: 10px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .85), transparent);
  mix-blend-mode: screen; animation: sweep 1.6s linear infinite;
}
.tile.sp-col::after { background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .85), transparent); }
@keyframes sweep { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
.tile.sp-row .gem-art, .tile.sp-col .gem-art { filter: drop-shadow(0 0 8px rgba(255, 255, 255, .8)); }

.tile.sp-bomb .gem-art { animation: bomb-throb 1.1s ease-in-out infinite; }
@keyframes bomb-throb { 50% { transform: scale(1.1); filter: drop-shadow(0 0 12px var(--ember)); } }
.tile.sp-bomb::before {
  content: ''; position: absolute; inset: 6%; border-radius: 50%;
  border: 2px dashed rgba(255, 160, 90, .8); animation: rot 3s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.tile.sp-rainbow .gem-art { filter: drop-shadow(0 0 10px #fff) saturate(1.4); }
.omamori {
  position: absolute; inset: 14%; border-radius: 12px; pointer-events: none;
  background: conic-gradient(#ff6b6b, #ffd93d, #6bcb77, #4d96ff, #b06bff, #ff6b6b);
  mix-blend-mode: color-dodge; opacity: .55; animation: rot 4s linear infinite;
}

/* блокеры */
.blocker { z-index: 3; display: grid; place-items: center; pointer-events: none; }
.blocker svg { width: 98%; height: 98%; }
.ice-1 { opacity: .55; }
.ice-2 { opacity: .88; }
.blocker.crack { animation: crack .3s ease; }
@keyframes crack { 40% { transform: translate3d(calc(var(--gx)*100%), calc(var(--gy)*100%), 0) scale(1.12); filter: brightness(1.8); } }
.crate { z-index: 3; }

/* эффекты */
.fx { pointer-events: none; }
.fx-row, .fx-col { z-index: 6; }
.fx-row::after {
  content: ''; position: absolute; top: 30%; left: -900%; width: 2000%; height: 40%;
  background: linear-gradient(90deg, transparent, #fff, var(--gold), #fff, transparent);
  filter: blur(2px); animation: beam .5s ease-out forwards;
}
.fx-col::after {
  content: ''; position: absolute; left: 30%; top: -900%; height: 2000%; width: 40%;
  background: linear-gradient(180deg, transparent, #fff, var(--gold), #fff, transparent);
  filter: blur(2px); animation: beam .5s ease-out forwards;
}
@keyframes beam { from { opacity: 0; transform: scale(.4); } 30% { opacity: 1; } to { opacity: 0; } }

.fx-bomb::after {
  content: ''; position: absolute; inset: -100%; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--gold) 25%, var(--ember) 45%, transparent 70%);
  animation: boom .55s ease-out forwards;
}
.fx-mega::after { inset: -180%; }
@keyframes boom { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.1); opacity: 0; } }

.fx-nova::after {
  content: ''; position: absolute; inset: -400%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(255,215,120,.6) 20%, transparent 60%);
  animation: boom .7s ease-out forwards;
}
.fx-spark::after {
  content: ''; position: absolute; inset: 25%; border-radius: 50%;
  background: radial-gradient(circle, #fff, transparent 70%);
  animation: boom .4s ease-out forwards;
}

.fly { position: absolute; width: 9%; aspect-ratio: 1; z-index: 8; pointer-events: none;
  animation: fly .52s cubic-bezier(.5, -0.4, .7, 1) forwards; }
.fly svg { width: 100%; height: 100%; }
@keyframes fly {
  to { transform: translate(var(--dx), var(--dy)) scale(.35); opacity: 0; }
}

.toast {
  position: absolute; left: 50%; top: 12%; transform: translate(-50%, -14px);
  padding: 9px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap;
  background: rgba(16, 13, 20, .92); border: 1px solid var(--line); color: var(--gold-soft);
  opacity: 0; pointer-events: none; z-index: 9; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- бустеры ---------- */
.booster-bar { display: flex; gap: 8px; }
.booster {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 16px;
  background: var(--card-2); border: 1px solid var(--line); transition: transform .12s, border-color .2s;
}
.booster:active { transform: scale(.95); }
.booster.active { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember), 0 0 22px rgba(213, 98, 47, .35); }
.booster.empty { opacity: .4; }
/* лимит продлений исчерпан — бустер ходов недоступен до конца уровня */
.booster.locked { opacity: .32; filter: grayscale(1); }
.booster.locked .booster-count { background: rgba(255, 255, 255, .18); color: rgba(255, 255, 255, .6); }
.booster-art { font-size: 22px; line-height: 1; }
.booster-name { font-size: 11px; color: var(--muted); }
.booster-count {
  position: absolute; top: -6px; right: 6px; min-width: 20px; padding: 1px 5px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: #241a06;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold-deep));
}

/* ===================== оверлей результата ===================== */
/* Прокручивается подложка, а не панель: печать вынесена за верхний край
   панели отрицательным отступом, и overflow на самой панели срезал её.
   Верхний padding держит запас ровно под этот вынос. */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto; padding: 74px 20px 24px;
  background: rgba(6, 5, 8, .78); backdrop-filter: blur(6px); animation: fade .25s ease;
}
.panel {
  width: min(360px, 100%); padding: 26px 22px 20px; border-radius: 24px; text-align: center;
  margin: auto; flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(32, 24, 38, .96), rgba(14, 11, 18, .98));
  border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
  animation: panel-in .42s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes panel-in { from { transform: scale(.86) translateY(20px); opacity: 0; } }
.panel-seal {
  width: 62px; height: 62px; margin: -50px auto 12px; display: grid; place-items: center;
  font-size: 30px; font-weight: 700; border-radius: 16px;
  background: linear-gradient(160deg, var(--crimson), #7d1f18);
  border: 2px solid rgba(255, 220, 180, .35); box-shadow: 0 10px 30px rgba(192, 57, 43, .4);
}
.panel-title { font-size: 22px; }
.panel-sub { margin: 6px 0 14px; color: var(--muted); font-size: 13.5px; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.big-star {
  font-size: 40px; color: rgba(255, 255, 255, .14);
  animation: star-in .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: var(--d);
}
.big-star.lit { color: var(--gold); text-shadow: 0 0 24px rgba(231, 192, 90, .75); }
@keyframes star-in { from { transform: scale(0) rotate(-90deg); } }
.panel-score { display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.panel-score span { color: var(--muted); font-size: 13px; }
.panel-score strong { font-size: 22px; color: var(--gold); }
.panel-best { margin-top: 8px; font-size: 12px; color: var(--muted); }
.panel-limit {
  margin-top: 12px; padding: 9px 12px; border-radius: 12px;
  font-size: 12px; color: rgba(226, 206, 172, .72);
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
}
.panel-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }

/* ===================== адаптив ===================== */
@media (min-width: 720px) {
  .game-screen, .home-inner { max-width: 520px; margin: 0 auto; width: 100%; }
  .map-scroll { max-width: 620px; margin: 0 auto; width: 100%; }
}
@media (max-height: 680px) {
  .booster-art { font-size: 19px; }
  .moves-value { font-size: 22px; }
}

/* низкие экраны (360×640 и подобные): тот же макет, но плотнее */
@media (max-height: 720px) {
  .home-inner { padding-top: 8px; padding-bottom: 10px; }
  .hero { height: clamp(104px, 17vh, 140px); }
  .home-title .t-1 { font-size: clamp(30px, 9.5vw, 42px); }
  .home-title .t-2 { font-size: clamp(26px, 8.2vw, 36px); }
  .home-tagline { font-size: 10.5px; margin-top: 8px; }
  .home-stats { margin: 12px 0 13px; }
  .stat { padding: 9px 5px 8px; }
  .stat b { font-size: 18px; }
  .btn-play { padding: 13px 20px 12px; }
  .btn-play-label { font-size: 18px; }
  .btn-ink { padding: 11px 14px; }
  .home-toggles { margin-top: 10px; }
  .home-hints { margin-top: 11px; font-size: 11px; gap: 3px; }
  .reset-link { margin-top: 8px; font-size: 11px; }
}
