/* Тёмная славянская палитра: ночь, болотная зелень и тёплое золото лучины. */
:root {
  --bg: #0b0910;
  --panel: #16121f;
  --panel-2: #1e1929;
  --line: #33294a;
  --gold: #e8b44c;
  --gold-dim: #a37a2c;
  --text: #efe6d8;
  --muted: #9c8fa8;
  --green: #6fbf5a;
  --red: #c8443c;
  --blue: #6fb8e8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: "Georgia", "Times New Roman", serif;
  user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; touch-action: none;
}

#app { position: fixed; inset: 0; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; background: #0b0910; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; }

.hud-top { padding: calc(6px + var(--safe-top)) 8px 0; }
.hud-row { display: flex; align-items: center; gap: 8px; }
.hud-time { font-size: 26px; font-weight: bold; color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 10px #000; letter-spacing: 1px; }
.hud-kills { font-size: 12px; color: var(--muted); text-shadow: 0 1px 2px #000; }
.hud-kills i { font-style: normal; opacity: .7; font-size: 10px; }
.icon-btn {
  margin-left: auto; pointer-events: auto;
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(20,16,28,.72); color: var(--text);
  border: 1px solid var(--line); font-size: 13px; font-weight: bold; letter-spacing: 1px;
}

.xp-bar { position: relative; height: 10px; margin-top: 5px; background: rgba(10,8,16,.8); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7a5cf0, #b98bff); transition: width .12s linear; }
.xp-lv { position: absolute; inset: 0; text-align: center; font-size: 8px; line-height: 10px; color: #fff; text-shadow: 0 1px 1px #000; }

.boss-bar { margin-top: 6px; text-align: center; font-size: 11px; color: #ffbdb8; text-shadow: 0 1px 2px #000; }
.boss-fill-wrap { height: 8px; margin-top: 2px; background: rgba(10,8,16,.85); border: 1px solid #5c2a2a; border-radius: 4px; overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8e2a24, #e0574c); transition: width .15s linear; }

.hud-bottom { padding: 0 8px calc(8px + var(--safe-bottom)); }
.hp-bar { position: relative; height: 14px; background: rgba(10,8,16,.8); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8e2a24, #cf5a4e); transition: width .1s linear; }
.hp-bar span { position: absolute; inset: 0; text-align: center; font-size: 9px; line-height: 14px; color: #fff; text-shadow: 0 1px 1px #000; }
.weapon-row { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.weapon-row img { width: 26px; height: 26px; image-rendering: pixelated; background: rgba(15,12,22,.8); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.weapon-row .slot { position: relative; }
.weapon-row .lv { position: absolute; right: -2px; bottom: -3px; font-size: 9px; background: #0d0b13; border: 1px solid var(--gold-dim); color: var(--gold); border-radius: 4px; padding: 0 3px; }

/* ---------- Экраны ---------- */

/* Выше баннера босса и вспышки: открытый экран должен перекрывать всё поле. */
#screens { position: absolute; inset: 0; display: none; z-index: 35; }
#screens.on { display: block; }

.screen {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  /* Полупрозрачный, чтобы под меню была видна живая ночь с холста;
     градиент к низу — чтобы текст не терялся на светлых участках сцены. */
  background: linear-gradient(180deg, rgba(9,7,14,.62) 0%, rgba(9,7,14,.86) 45%, rgba(9,7,14,.95) 100%);
  padding: calc(16px + var(--safe-top)) 14px calc(20px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.screen.overlay { background: rgba(6,5,10,.88); backdrop-filter: blur(2px); justify-content: center; }
.screen.solid { background: radial-gradient(120% 90% at 50% 0%, #1b1428 0%, #0b0910 70%); }

h1.logo {
  margin: 8px 0 0; font-size: 44px; letter-spacing: 6px; color: var(--gold);
  text-shadow: 0 3px 0 #2a1c0a, 0 0 24px rgba(232,180,76,.35);
}
.subtitle { margin: -6px 0 4px; color: var(--muted); font-size: 13px; letter-spacing: 2px; }
h2 { font-size: 20px; margin: 4px 0; color: var(--gold); letter-spacing: 1px; }
p.hint { color: var(--muted); font-size: 12px; text-align: center; max-width: 380px; margin: 0; line-height: 1.5; }

.btn {
  pointer-events: auto; display: block; width: 100%; max-width: 340px;
  padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--text); font-family: inherit; font-size: 16px; letter-spacing: .5px;
  text-align: center; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--gold-dim); background: linear-gradient(180deg, #3c2c12, #241a0c); color: var(--gold); font-size: 19px; font-weight: bold; }
.btn.ad { border-color: #2f5d3a; background: linear-gradient(180deg, #1c3a25, #12251a); color: #a9e6b6; }
.btn.small { font-size: 13px; padding: 9px 12px; }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; gap: 8px; width: 100%; max-width: 340px; }
.btn-row .btn { max-width: none; }

.card-list { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 420px; }
.card {
  pointer-events: auto; display: flex; gap: 10px; align-items: center; text-align: left;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); cursor: pointer; width: 100%;
  color: var(--text); font-family: inherit;
}
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,180,76,.35) inset; }
.card.locked { opacity: .55; }
.card img { width: 42px; height: 42px; image-rendering: pixelated; flex: none; }
.card .body { flex: 1; min-width: 0; }
.card .name { font-size: 15px; color: var(--gold); }
.card .desc { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.card .price { font-size: 12px; color: var(--gold); white-space: nowrap; }
.card .lv { font-size: 11px; color: var(--blue); }

.hero-strip { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; width: 100%; max-width: 460px; padding-bottom: 6px; align-items: stretch; }
.hero-strip .card { flex-direction: column; align-items: center; min-width: 132px; text-align: center; }
.hero-strip .card .desc { font-size: 10.5px; }
.hero-strip canvas { image-rendering: pixelated; }

.pick-row { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }

.stat-line { display: flex; justify-content: space-between; width: 100%; max-width: 340px; font-size: 14px; padding: 6px 2px; border-bottom: 1px dashed var(--line); }
.stat-line b { color: var(--gold); font-weight: normal; }

.souls { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); font-size: 16px; }
.souls img { width: 18px; height: 18px; image-rendering: pixelated; }

.levelup-cards { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 400px; }
.levelup-cards .card { padding: 12px; }
.levelup-cards .card img { width: 46px; height: 46px; }
.tier { font-size: 10px; color: var(--gold-dim); letter-spacing: 1px; text-transform: uppercase; }
.evo-flash { color: #ffd98a; font-size: 13px; text-align: center; }

#toast {
  position: absolute; left: 50%; bottom: calc(78px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(10,8,16,.92); border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .25s;
  pointer-events: none; max-width: 86%; text-align: center; z-index: 40;
}
#toast.on { opacity: 1; }

.loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100%; }
.loader-bar { width: 200px; height: 6px; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.loader-fill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 340px; }
.result-grid div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.result-grid b { display: block; font-size: 19px; color: var(--gold); font-weight: normal; }
.result-grid span { font-size: 11px; color: var(--muted); }

.tabs { display: flex; gap: 6px; width: 100%; max-width: 420px; }
.tabs button { flex: 1; padding: 8px; font-size: 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-family: inherit; }
.tabs button.on { color: var(--gold); border-color: var(--gold-dim); background: var(--panel-2); }

.ach { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); width: 100%; }
.ach.done { border-color: #2f5d3a; }
.ach .mark { color: var(--green); }
.ach .r { margin-left: auto; color: var(--gold); white-space: nowrap; }

.slider-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 340px; font-size: 13px; }
.slider-row input { flex: 1; }

@media (min-width: 620px) {
  .levelup-cards { flex-direction: row; max-width: 640px; }
  .levelup-cards .card { flex-direction: column; text-align: center; }
  h1.logo { font-size: 56px; }
}

/* ---------- Убранство меню ---------- */

/* Логотип: три слоя тени дают вид тиснения по металлу, свечение дышит. */
h1.logo {
  position: relative;
  text-shadow:
    0 1px 0 #7a5a1c, 0 2px 0 #4a370f, 0 3px 0 #2a1c0a,
    0 5px 14px rgba(0,0,0,.9);
  animation: logo-breathe 5.5s ease-in-out infinite;
}
@keyframes logo-breathe {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(232,180,76,.16)); }
  50%      { filter: drop-shadow(0 0 22px rgba(232,180,76,.42)); }
}

/* Орнаментальный разделитель: две линии и ромб посередине. */
.orn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 330px; margin: 2px 0 4px;
}
.orn::before, .orn::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.orn i {
  width: 7px; height: 7px; transform: rotate(45deg);
  background: var(--gold-dim); box-shadow: 0 0 8px rgba(232,180,76,.5);
}

.souls-panel {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, rgba(60,44,18,.85), rgba(26,20,12,.85));
  color: var(--gold); font-size: 17px; letter-spacing: .5px;
  box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,220,150,.14);
}
.souls-panel img { width: 20px; height: 20px; image-rendering: pixelated; }

/* Кнопки: волосяная золотая линия сверху и подсветка при нажатии. */
.btn {
  position: relative; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
  transition: border-color .15s, transform .08s, box-shadow .15s;
}
.btn.primary {
  box-shadow: 0 3px 16px rgba(232,180,76,.18), inset 0 1px 0 rgba(255,220,150,.2);
}
.btn.primary::after {
  /* Медленный блик по кнопке «В ночь» — единственная анимация,
     которая должна тянуть взгляд на первом экране. */
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,226,160,.13), transparent);
  animation: sheen 4.5s ease-in-out infinite;
}
@keyframes sheen {
  0%   { left: -50%; }
  55%  { left: 120%; }
  100% { left: 120%; }
}
.btn:active { box-shadow: 0 1px 6px rgba(0,0,0,.5); }

.btn.with-icon { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn.with-icon img { width: 20px; height: 20px; image-rendering: pixelated; opacity: .9; }

/* Карточка сообщества: выделяется зелёным, но не спорит с «В ночь». */
.group-card {
  pointer-events: auto; display: flex; align-items: center; gap: 11px; width: 100%; max-width: 340px;
  padding: 11px 13px; border-radius: 12px; text-align: left; cursor: pointer;
  border: 1px solid #3a6d47; color: var(--text); font-family: inherit;
  background: linear-gradient(180deg, rgba(30,62,40,.92), rgba(16,32,22,.92));
  box-shadow: 0 2px 12px rgba(0,0,0,.45), inset 0 1px 0 rgba(160,230,180,.12);
}
.group-card img { width: 36px; height: 36px; image-rendering: pixelated; flex: none; }
.group-card > div:not(.g-reward) { flex: 1; min-width: 0; }
.group-card .g-title { font-size: 15px; color: #b9edc5; }
.group-card .g-desc { font-size: 11.5px; color: #8bb096; line-height: 1.4; margin-top: 2px; }
.group-card .g-reward { margin-left: auto; text-align: right; color: var(--gold); font-size: 13px; white-space: nowrap; }
.group-card.done { border-color: var(--line); background: linear-gradient(180deg, var(--panel-2), var(--panel)); opacity: .7; }

.menu-foot { display: flex; gap: 14px; margin-top: 2px; }
.menu-foot button {
  background: none; border: 0; color: var(--muted); font-family: inherit;
  font-size: 12px; text-decoration: underline dotted; cursor: pointer; padding: 4px;
}

/* Баннер выхода босса: имя проступает и гаснет, не закрывая поле боя. */
#bossIntro {
  position: absolute; left: 0; right: 0; top: 22%;
  text-align: center; pointer-events: none; opacity: 0; z-index: 30;
}
#bossIntro.on { animation: boss-in 2.8s ease-out forwards; }
#bossIntro .b-sub { font-size: 12px; letter-spacing: 5px; color: #d99; text-transform: uppercase; }
#bossIntro .b-name {
  font-size: 34px; color: #f0d9a0; letter-spacing: 2px; margin-top: 2px;
  text-shadow: 0 2px 0 #2a0e0e, 0 0 26px rgba(220,80,60,.7);
}
@keyframes boss-in {
  0%   { opacity: 0; transform: scale(.9); }
  18%  { opacity: 1; transform: scale(1); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}

/* Вспышка на новом уровне — короткая, чтобы не резать глаз в темноте. */
#flash {
  position: absolute; inset: 0; pointer-events: none; z-index: 25;
  background: #fff; opacity: 0;
}
#flash.on { animation: flash-out .34s ease-out forwards; }
@keyframes flash-out {
  0%   { opacity: .34; }
  100% { opacity: 0; }
}

/* Карточки выбора умений: подсветка по типу — оружие тёплое, умения холодные. */
.levelup-cards .card { position: relative; }
.levelup-cards .card[data-kind="weapon"] { border-color: #6b4d22; box-shadow: inset 0 0 22px rgba(232,180,76,.09); }
.levelup-cards .card[data-kind="passive"] { border-color: #3a4570; box-shadow: inset 0 0 22px rgba(120,150,240,.09); }
.levelup-cards .card[data-kind="evo"] { border-color: var(--gold); box-shadow: inset 0 0 26px rgba(232,180,76,.22); }
.levelup-cards .card img { filter: drop-shadow(0 2px 5px rgba(0,0,0,.6)); }

/* Состав билда на паузе: в две колонки, чтобы кнопки не уезжали за экран. */
.build-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px;
  width: 100%; max-width: 420px;
}
.build-list .stat-line { max-width: none; font-size: 13px; padding: 5px 2px; }
@media (max-width: 400px) { .build-list { grid-template-columns: 1fr; } }
