/* ==========================================================================
   ОХОТА ЗА СОКРОВИЩАМИ — визуальный стиль «полевой набор кладоискателя»
   Пергамент, дерево, латунь и сургуч. Кнопки объёмные, но при нажатии
   не сдвигаются: «вдавливание» рисуется светом и тенью.
   ========================================================================== */

:root {
  /* Фон и дерево */
  --bg-0: #120c07;
  --bg-1: #1b130c;
  --bg-2: #261a10;
  --wood-1: #8a5a32;
  --wood-2: #6a4223;
  --wood-3: #452914;
  --wood-4: #2c190b;

  /* Пергамент и чернила */
  --parch-1: #f6e9c8;
  --parch-2: #ead7a8;
  --parch-3: #d3b77b;
  --parch-edge: #a9874f;
  --ink: #3b2614;
  --ink-soft: #6f5233;
  --ink-faint: rgba(59, 38, 20, 0.18);

  /* Металл и камни */
  --gold-1: #ffe08a;
  --gold-2: #f2b33d;
  --gold-3: #b9761c;
  --gold-4: #7a4a0d;
  --emerald-1: #7be3a0;
  --emerald-2: #2fb569;
  --emerald-3: #17773f;
  --emerald-4: #0c4a26;
  --crimson-1: #ff8a75;
  --crimson-2: #e04b37;
  --crimson-3: #9e2a1d;
  --crimson-4: #5e150d;
  --sky-1: #8fd7ff;
  --sky-2: #3ba3e6;
  --sky-3: #1f6aa8;
  --sky-4: #113f67;
  --stone-1: #b8b0a0;
  --stone-2: #8a8274;
  --stone-3: #5b554b;
  --stone-4: #36322c;
  --arcane-1: #c7a6ff;
  --arcane-2: #8b5cf6;
  --arcane-3: #4c2a91;

  /* Текст на тёмном */
  --text: #f6e7c9;
  --muted: #bda580;

  /* Совместимость со старыми переменными */
  --accent: var(--gold-2);
  --accent-2: var(--gold-3);
  --border: #4a3420;
  --card: var(--bg-2);
  --red: var(--crimson-2);
  --green: var(--emerald-2);

  --font-ui: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: "Kelly Slab", "Rubik", Georgia, serif;
  --font-hand: "Caveat", "Comic Sans MS", cursive;

  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font: 400 15px/1.45 var(--font-ui);
  background-color: var(--bg-1);
  /* Тёмная кожа экспедиционного планшета с горизонталями карты */
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 196, 102, 0.10), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.6), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='360' viewBox='0 0 360 360'%3E%3Cg fill='none' stroke='%23c9a46a' stroke-opacity='0.06' stroke-width='1.2'%3E%3Cpath d='M-20 80c60-40 120 30 190-10s130 20 210-15'/%3E%3Cpath d='M-20 120c70-35 130 35 200-5s120 25 200-10'/%3E%3Cpath d='M-20 200c50-30 110 40 180 5s140 15 220-20'/%3E%3Cpath d='M-20 240c60-25 120 45 190 10s130 10 210-25'/%3E%3Cpath d='M-20 300c80-40 140 30 210-5s110 30 190 0'/%3E%3Cellipse cx='250' cy='150' rx='38' ry='22'/%3E%3Cellipse cx='250' cy='150' rx='18' ry='9'/%3E%3C/g%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.07 0 0 0 0 0.04 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

body.in-dungeon {
  background-color: #0e0c12;
}

button { font-family: inherit; }

a { color: var(--gold-1); }

.muted { color: var(--muted); }
.small { font-size: 12px; }

.ico {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: none;
}

[hidden] { display: none !important; }

/* ==========================================================================
   ИГРОВЫЕ КНОПКИ
   ========================================================================== */

.gbtn,
.btn {
  --face-top: #9c6a3f;
  --face-bot: #6e4524;
  --lip: #3f2410;
  --edge: #2a160a;
  --label: #fff1d6;
  --glow: 255, 200, 120;

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px 4px;
  border: 2px solid var(--edge);
  border-radius: 13px;
  background: linear-gradient(180deg, var(--face-top) 0%, var(--face-bot) 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.38),
    inset 0 -5px 0 var(--lip),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.35);
  color: var(--label);
  font: 800 15px/1.1 var(--font-ui);
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition: filter 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

/* Блик на верхней грани */
.gbtn::after,
.btn::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 3px;
  height: 38%;
  border-radius: 10px 10px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.gbtn .ico,
.btn .ico {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4));
}

.gbtn:hover,
.btn:hover {
  filter: brightness(1.1) saturate(1.08);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -5px 0 var(--lip),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 6px 18px rgba(var(--glow), 0.35);
}

/* Нажатие: грань «уходит» внутрь, сама кнопка не двигается */
.gbtn:active,
.btn:active,
.gbtn.pressed {
  filter: brightness(0.92);
  background: linear-gradient(180deg, var(--face-bot) 0%, var(--face-top) 100%);
  box-shadow:
    inset 0 5px 8px rgba(0, 0, 0, 0.38),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18),
    0 1px 0 rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.3);
}

.gbtn:active::after,
.btn:active::after,
.gbtn.pressed::after { opacity: 0.25; }

.gbtn:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--gold-1);
  outline-offset: 3px;
}

.gbtn:disabled,
.btn:disabled,
.gbtn[aria-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.75) brightness(0.8);
  opacity: 0.7;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    inset 0 -5px 0 var(--lip),
    0 3px 0 rgba(0, 0, 0, 0.45);
}

/* Загрузка: бегущие полосы поверх лица кнопки */
.gbtn.loading::before,
.btn.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.16) 0 10px, transparent 10px 20px);
  background-size: 28px 28px;
  animation: btn-loading 0.7s linear infinite;
  pointer-events: none;
}

@keyframes btn-loading { to { background-position: 28px 0; } }

/* Цвета */
.gbtn-gold,
.btn.primary,
.btn.btn-primary,
.season-legend-btn,
.celebration-btn {
  --face-top: #ffd877;
  --face-bot: #e59a24;
  --lip: #a8600f;
  --edge: #5c3205;
  --label: #3d2104;
  --glow: 255, 196, 70;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
}

.gbtn-emerald {
  --face-top: #6fdc96;
  --face-bot: #229b55;
  --lip: #11683a;
  --edge: #083d21;
  --label: #f2fff6;
  --glow: 90, 230, 150;
}

.gbtn-crimson,
.btn.danger {
  --face-top: #ff8a72;
  --face-bot: #d23e2b;
  --lip: #8e2416;
  --edge: #4d0f07;
  --label: #fff3ef;
  --glow: 255, 110, 90;
}

.gbtn-sky {
  --face-top: #86d4ff;
  --face-bot: #2f8fd8;
  --lip: #1b5d96;
  --edge: #0b3256;
  --label: #f2fbff;
  --glow: 120, 200, 255;
}

.gbtn-stone,
.btn.secondary {
  --face-top: #a39b8b;
  --face-bot: #6a6357;
  --lip: #433e36;
  --edge: #24211c;
  --label: #fffaf0;
  --glow: 230, 220, 200;
}

.gbtn-wood,
.btn.ghost {
  --face-top: #9c6a3f;
  --face-bot: #6e4524;
  --lip: #3f2410;
  --edge: #2a160a;
  --label: #fff1d6;
}

/* Размеры */
.gbtn-sm { min-height: 38px; padding: 0 12px 3px; font-size: 13px; border-radius: 11px; }
.gbtn-sm .ico { width: 18px; height: 18px; }
.gbtn-icon { width: 46px; padding: 0 0 4px; }
.gbtn-full,
.btn.full { width: 100%; }

/* Простые текстовые ссылки (подвал) */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--font-ui);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.link-btn .ico { width: 16px; height: 16px; }
.link-btn:hover { color: var(--gold-1); background: rgba(255, 220, 150, 0.06); }
.link-btn:active { color: var(--gold-2); background: rgba(255, 220, 150, 0.12); }
.link-btn:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }

/* ==========================================================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ========================================================================== */

.gamebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(90deg, #5a371c 0 3px, #5f3b1e 3px 7px, #55331a 7px 11px),
    var(--wood-3);
  border-bottom: 3px solid var(--wood-4);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 10px 24px rgba(0, 0, 0, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.5));
}

.brand-name {
  font: 400 22px/1 var(--font-title);
  color: var(--gold-1);
  text-shadow: 0 2px 0 #3a1f08, 0 0 12px rgba(255, 190, 90, 0.25);
  white-space: nowrap;
}

.season-left { position: relative; }

.season-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 2px solid #2a160a;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3e2b8, #d9bd82);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 #b08d4f, 0 2px 0 rgba(0, 0, 0, 0.5);
  color: var(--ink);
  font: 700 14px var(--font-ui);
  cursor: pointer;
  transition: filter 0.12s;
}
.season-chip:hover { filter: brightness(1.05); }
.season-chip:active { filter: brightness(0.92); box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(0, 0, 0, 0.5); }
.season-chip:focus-visible { outline: 3px solid var(--gold-1); outline-offset: 2px; }
.season-icon { font-size: 18px; }
.map-hash { font: 600 12px ui-monospace, Menlo, monospace; color: var(--ink-soft); }

.season-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 60;
  min-width: 240px;
  padding: 12px 14px;
  border: 2px solid var(--parch-edge);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--parch-1), var(--parch-2));
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  white-space: pre-line;
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}
.season-tooltip.show { opacity: 1; visibility: visible; }

.gamebar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 220, 150, 0.2);
  color: var(--parch-1);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 70;
  min-width: 220px;
  padding: 6px;
  border: 2px solid var(--parch-edge);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--parch-1), var(--parch-2));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}
.dropdown-menu.show { opacity: 1; visibility: visible; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 700 14px var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.dropdown-item:hover { background: rgba(110, 70, 30, 0.12); }
.dropdown-item:active { background: rgba(110, 70, 30, 0.22); }
.dropdown-item:focus-visible { outline: 2px solid var(--gold-3); outline-offset: -2px; }
.dropdown-item.off { color: var(--ink-soft); }
.dropdown-item.off .dropdown-icon { opacity: 0.5; }
.dropdown-icon { display: inline-flex; color: var(--wood-2); }

/* ==========================================================================
   HUD
   ========================================================================== */

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 1100px;
  margin: 14px auto 0;
  padding: 0 12px;
}

.hud-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px 0 6px;
  border: 2px solid #120b05;
  border-radius: 999px;
  background: linear-gradient(180deg, #3b2817, #24170c);
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.15), 0 2px 0 rgba(0, 0, 0, 0.5);
  font: 800 16px var(--font-ui);
  color: var(--parch-1);
}

.hud-item b { font-weight: 800; }

.hud-ico {
  width: 30px;
  height: 30px;
  padding: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe8a6, #c98d2c 70%, #8a5714);
  color: #4a2b07;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 1px 0 rgba(0, 0, 0, 0.5);
}

.coins-display { color: var(--gold-1); }
.coins-display .hud-ico { color: #fff2b8; background: radial-gradient(circle at 35% 30%, #fff1a8, #f0b53a 60%, #a96a12); }
.coins-display .coin-ico { padding: 2px; }
.coins-display.bump b { animation: coin-bump 0.5s ease; }
@keyframes coin-bump { 30% { color: #fff; text-shadow: 0 0 10px #ffd35a; } }

.pos-sep { opacity: 0.5; margin: 0 1px; }

.pro-status { color: var(--gold-1); }
.pro-status .hud-ico { background: radial-gradient(circle at 35% 30%, #fff3b0, #f2b33d 60%, #a8600f); }

/* Шкала ходов */
.moves-display { padding-right: 8px; }
.moves-meter {
  position: relative;
  width: 132px;
  height: 22px;
  border-radius: 999px;
  background: #120b05;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.moves-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--moves-pct, 100%);
  background: linear-gradient(180deg, #8ee6a8, #2fb569 55%, #1b7f45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: width 0.35s ease;
}
.moves-display.low .moves-fill { background: linear-gradient(180deg, #ffd38a, #f08a2a 55%, #b2520f); }
.moves-display.empty .moves-fill { background: linear-gradient(180deg, #ff9a86, #d23e2b 55%, #8e2416); }
.moves-text {
  position: relative;
  display: block;
  text-align: center;
  font: 800 13px/22px var(--font-ui);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

/* Сердечки */
.lives-display { gap: 2px; padding: 0 10px; }
.heart-svg { width: 26px; height: 24px; overflow: visible; }
.heart-svg .heart-bg { fill: #24170c; stroke: #120b05; stroke-width: 1.6; }
.heart-svg .heart-fill { fill: transparent; }
.heart-svg.full .heart-fill { fill: #ff4b3e; }
.heart-svg.three-quarters .heart-fill { fill: url(#threeQuartersGradient); }
.heart-svg.half .heart-fill { fill: url(#halfGradient); }
.heart-svg.quarter .heart-fill { fill: url(#quarterGradient); }
.heart-svg .heart-fill { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.4)); }
.heart-svg.damaged { animation: heart-hit 0.6s ease; }
.heart-svg.healed { animation: heart-heal 0.8s ease; }
@keyframes heart-hit { 30% { filter: drop-shadow(0 0 8px #ff3b2f) brightness(1.4); } }
@keyframes heart-heal { 40% { filter: drop-shadow(0 0 10px #7be3a0) brightness(1.3); } }

/* ==========================================================================
   РАСКЛАДКА
   ========================================================================== */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(280px, 360px);
  justify-content: center;
  gap: 20px;
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 0 12px 24px;
}

.board-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.side { min-width: 0; }

/* ==========================================================================
   КАРТА В ДЕРЕВЯННОЙ РАМЕ
   ========================================================================== */

.map-frame {
  position: relative;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(0, 0, 0, 0.2)),
    repeating-linear-gradient(0deg, #6e4524 0 4px, #744a27 4px 9px, #68411f 9px 14px),
    var(--wood-2);
  border: 3px solid var(--wood-4);
  box-shadow:
    inset 0 2px 0 rgba(255, 220, 160, 0.25),
    inset 0 -3px 0 rgba(0, 0, 0, 0.35),
    0 6px 0 rgba(0, 0, 0, 0.45),
    0 18px 40px rgba(0, 0, 0, 0.55);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: #e9d8ad;
  box-shadow: 0 0 0 3px #2c190b, inset 0 0 30px rgba(0, 0, 0, 0.35);
  image-rendering: auto;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.rivet {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b6, #d49a36 55%, #6e430d);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.rivet-tl { top: 4px; left: 4px; }
.rivet-tr { top: 4px; right: 4px; }
.rivet-bl { bottom: 4px; left: 4px; }
.rivet-br { bottom: 4px; right: 4px; }

/* Ярлык местности поверх карты */
.biome-info {
  position: absolute;
  top: 22px;
  left: 22px;
  z-index: 3;
  padding: 5px 12px;
  border: 2px solid var(--parch-edge);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--parch-1), var(--parch-2));
  color: var(--ink);
  font: 700 13px var(--font-ui);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Подземелье: каменная рама вместо деревянной */
body.in-dungeon .map-frame {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.3)),
    repeating-linear-gradient(0deg, #4a463f 0 12px, #3e3a34 12px 13px),
    var(--stone-4);
  border-color: #17140f;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.12),
    0 6px 0 rgba(0, 0, 0, 0.5),
    0 0 40px rgba(139, 92, 246, 0.25),
    0 18px 40px rgba(0, 0, 0, 0.6);
}
body.in-dungeon #board { background: #08070b; }
body.in-dungeon .rivet { background: radial-gradient(circle at 35% 30%, #e7d9ff, #8b5cf6 55%, #2d1a5c); }

/* ==========================================================================
   ПРИБОР ПОДСКАЗКИ (тепло / холодно)
   ========================================================================== */

.heat-gauge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 2px solid #120b05;
  border-radius: 14px;
  background: linear-gradient(180deg, #3b2817, #24170c);
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.12), 0 3px 0 rgba(0, 0, 0, 0.5);
}

.heat-scale {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  flex: none;
  width: 150px;
  height: 18px;
  padding: 3px;
  border-radius: 999px;
  background: #120b05;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.7);
}

.heat-scale span {
  border-radius: 3px;
  background: #3a2b1d;
  transition: background 0.3s, box-shadow 0.3s;
}
.heat-scale span:first-child { border-radius: 999px 3px 3px 999px; }
.heat-scale span:last-child { border-radius: 3px 999px 999px 3px; }

/* Сегменты загораются от "ледяного" к "здесь" */
.heat-gauge[data-heat="0"] .heat-scale span:nth-child(-n+1),
.heat-gauge[data-heat="1"] .heat-scale span:nth-child(-n+2),
.heat-gauge[data-heat="2"] .heat-scale span:nth-child(-n+3),
.heat-gauge[data-heat="3"] .heat-scale span:nth-child(-n+4),
.heat-gauge[data-heat="4"] .heat-scale span:nth-child(-n+5),
.heat-gauge[data-heat="5"] .heat-scale span:nth-child(-n+6),
.heat-gauge[data-heat="6"] .heat-scale span:nth-child(-n+7) {
  background: var(--seg);
  box-shadow: 0 0 8px var(--seg), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.heat-scale span:nth-child(1) { --seg: #6fc8ff; }
.heat-scale span:nth-child(2) { --seg: #8fd9f0; }
.heat-scale span:nth-child(3) { --seg: #d6e8a0; }
.heat-scale span:nth-child(4) { --seg: #ffd25a; }
.heat-scale span:nth-child(5) { --seg: #ff9d3a; }
.heat-scale span:nth-child(6) { --seg: #ff5a2a; }
.heat-scale span:nth-child(7) { --seg: #ff2d6a; }

.heat-gauge[data-heat="5"],
.heat-gauge[data-heat="6"] { animation: heat-glow 1.2s ease-in-out infinite; }
@keyframes heat-glow { 50% { box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.12), 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 22px rgba(255, 90, 40, 0.45); } }

.hint {
  flex: 1;
  min-width: 0;
  font: 400 19px/1.2 var(--font-title);
  color: var(--parch-1);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.heat-gauge[data-heat="0"] .hint,
.heat-gauge[data-heat="1"] .hint { color: #a9e2ff; }
.heat-gauge[data-heat="3"] .hint { color: #ffe08a; }
.heat-gauge[data-heat="4"] .hint { color: #ffb35a; }
.heat-gauge[data-heat="5"] .hint,
.heat-gauge[data-heat="6"] .hint { color: #ff8a5a; }

/* ==========================================================================
   ПАНЕЛЬ ПОДЗЕМЕЛЬЯ
   ========================================================================== */

.dungeon-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid #0a0710;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 15% 50%, rgba(139, 92, 246, 0.35), transparent 60%),
    linear-gradient(180deg, #2b2338, #17121f);
  box-shadow: inset 0 1px 0 rgba(220, 200, 255, 0.15), 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 24px rgba(139, 92, 246, 0.2);
  animation: panel-in 0.25s ease;
}
@keyframes panel-in { from { opacity: 0; } }
.dungeon-panel.inside {
  background:
    radial-gradient(ellipse at 15% 50%, rgba(255, 150, 50, 0.3), transparent 60%),
    linear-gradient(180deg, #2a241d, #15110c);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.15), 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 24px rgba(255, 140, 40, 0.15);
}
.dungeon-panel.sealed { filter: grayscale(0.7); }
.dungeon-panel-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 28px;
}
.dungeon-panel-text { flex: 1; min-width: 0; }
.dungeon-panel-title {
  font: 400 19px/1.15 var(--font-title);
  color: #efe3ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dungeon-panel.inside .dungeon-panel-title { color: var(--gold-1); }
.dungeon-panel-sub { font-size: 13px; color: #c9bde0; margin-top: 2px; }
.dungeon-panel.inside .dungeon-panel-sub { color: var(--muted); }
.dungeon-panel-btn { flex: none; min-width: 150px; }

/* ==========================================================================
   УПРАВЛЕНИЕ
   ========================================================================== */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.left-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
}

.left-actions .gbtn { justify-content: flex-start; }

/* Крестовина: каменные клавиши на латунной пластине */
.dpad {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 62px);
  grid-template-rows: repeat(3, 62px);
  grid-template-areas: ". n ." "w c e" ". s .";
  gap: 4px;
  padding: 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #5a3c20 0 30%, transparent 31%),
    radial-gradient(circle at 50% 40%, #6e4a26, #3a2310 70%);
  border: 3px solid #1f1207;
  box-shadow: inset 0 2px 0 rgba(255, 220, 160, 0.2), 0 5px 0 rgba(0, 0, 0, 0.5), 0 12px 24px rgba(0, 0, 0, 0.4);
}
.dpad .row { display: contents; }
/* Компасная роза в центре */
.dpad::after {
  content: "";
  grid-area: c;
  align-self: center;
  justify-self: center;
  width: 34px;
  height: 34px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1l2.6 8.4L23 12l-8.4 2.6L12 23l-2.6-8.4L1 12l8.4-2.6z' fill='%23e8b04a'/%3E%3Cpath d='M12 1l2.6 8.4H9.4z' fill='%23d6402f'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}

.round,
.dkey {
  --face-top: #b2aa99;
  --face-bot: #706a5d;
  --lip: #46413a;
  position: relative;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  padding: 0 0 4px;
  border: 2px solid #1e1b17;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--face-top), var(--face-bot));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -6px 0 var(--lip), 0 3px 0 rgba(0, 0, 0, 0.55);
  color: #fffaf0;
  cursor: pointer;
  transition: filter 0.1s, box-shadow 0.1s, background 0.1s;
}
.dkey .ico { width: 28px; height: 28px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.45)); }
.dkey-n { grid-area: n; }
.dkey-s { grid-area: s; }
.dkey-w { grid-area: w; }
.dkey-e { grid-area: e; }
.dkey-s .ico { transform: rotate(180deg); }
.dkey-w .ico { transform: rotate(-90deg); }
.dkey-e .ico { transform: rotate(90deg); }

.dkey:hover { filter: brightness(1.12); }
.dkey:active,
.dkey.pressed {
  --face-top: #f2c35a;
  --face-bot: #c4801f;
  --lip: #87500d;
  background: linear-gradient(180deg, var(--face-bot), var(--face-top));
  box-shadow: inset 0 5px 8px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.2), 0 1px 0 rgba(0, 0, 0, 0.55);
  color: #3d2104;
}
.dkey:focus-visible { outline: 3px solid var(--gold-1); outline-offset: 2px; }
.dkey:disabled,
.dkey.disabled { filter: grayscale(1) brightness(0.7); cursor: not-allowed; }

body.in-dungeon .dpad {
  background:
    radial-gradient(circle, #2e2840 0 30%, transparent 31%),
    radial-gradient(circle at 50% 40%, #3b3450, #18141f 70%);
}

/* ==========================================================================
   ДНЕВНИК ЭКСПЕДИЦИИ
   ========================================================================== */

.panel {
  padding: 14px;
  border: 2px solid #120b05;
  border-radius: 16px;
  background: linear-gradient(180deg, #3b2817, #24170c);
  box-shadow: inset 0 1px 0 rgba(255, 230, 180, 0.12), 0 4px 0 rgba(0, 0, 0, 0.5);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 4px 2px 10px;
  border: 0;
  background: transparent;
  color: var(--gold-1);
  font: 400 20px var(--font-title);
  text-align: left;
  cursor: pointer;
}
.panel-title:hover { color: #fff0b8; }
.panel-title:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; border-radius: 6px; }
.panel-title .ico { width: 24px; height: 24px; }
.log-arrow { margin-left: auto; font-size: 14px; color: var(--muted); }

.log {
  max-height: 420px;
  margin-bottom: 12px;
  padding: 12px 14px;
  overflow-y: auto;
  border-radius: 8px;
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(59, 38, 20, 0.14) 27px 28px),
    linear-gradient(180deg, var(--parch-1), var(--parch-2));
  box-shadow: inset 0 0 0 1px var(--parch-edge), inset 0 0 24px rgba(120, 80, 30, 0.25);
  color: var(--ink);
  font: 600 19px/28px var(--font-hand);
}
.log .line { padding: 0 2px; }
.log .line:last-child { color: #7a2f12; }
.log a,
.log-shop-link { color: #8a3a12; font-weight: 700; }

/* ==========================================================================
   ПОДВАЛ
   ========================================================================== */

.foot {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 28px;
}

/* ==========================================================================
   ОКНА (пергамент в деревянной раме, закрытие — сургучная печать)
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 6, 3, 0.72);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.modal[aria-hidden="false"],
.modal.visible,
.modal.show { opacity: 1; visibility: visible; }

.modal-dialog,
.modal-content {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 3px solid var(--wood-4);
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.5), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.32 0 0 0 0 0.15 0 0 0 0.14 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23p)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--parch-1), var(--parch-2));
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--parch-edge), inset 0 0 40px rgba(130, 90, 40, 0.3), 0 8px 0 rgba(0, 0, 0, 0.4), 0 24px 60px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.18s ease;
}
.modal[aria-hidden="false"] .modal-dialog,
.modal.visible .modal-content,
.modal.show .modal-content { transform: scale(1); }

.modal-small { max-width: 420px; }
.modal-large { max-width: 720px; }

.modal-head,
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.15)),
    repeating-linear-gradient(90deg, #5a371c 0 3px, #5f3b1e 3px 7px, #55331a 7px 11px);
  border-bottom: 3px solid var(--wood-4);
}

.modal-title,
.modal-head h3,
.modal-header h2,
.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--gold-1);
  font: 400 22px/1.15 var(--font-title);
  text-shadow: 0 2px 0 #2a1406;
}

/* Значок в заголовке окна: латунная бляха */
.modal-title > .ico,
.modal-head h3 > .ico {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 7px;
  border: 2px solid #3d2104;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b6, #e0a23c 60%, #8a5714);
  color: #4a2a06;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 0 rgba(0, 0, 0, 0.45);
}

.rules-section h3 { display: flex; align-items: center; gap: 8px; }
.rules-section h3 .ico { width: 22px; height: 22px; color: var(--gold-3); }
.offline-banner .ico { width: 18px; height: 18px; margin-right: 6px; }

/* Сургучная печать вместо крестика */
.icon-btn,
.modal-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 2px solid #4d0f07;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8a72, #c23423 60%, #7a1a0f);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.3), 0 2px 0 rgba(0, 0, 0, 0.5);
  color: #ffe9e2;
  font: 900 16px var(--font-ui);
  cursor: pointer;
  transition: filter 0.12s, box-shadow 0.12s;
}
.icon-btn:hover,
.modal-close:hover { filter: brightness(1.12); }
.icon-btn:active,
.modal-close:active { filter: brightness(0.9); box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(0, 0, 0, 0.5); }
.icon-btn:focus-visible,
.modal-close:focus-visible { outline: 3px solid var(--gold-1); outline-offset: 2px; }

.modal-body {
  flex: 1;
  padding: 18px 20px;
  overflow-y: auto;
}
.modal-foot,
.modal-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px 18px;
  border-top: 1px dashed rgba(59, 38, 20, 0.3);
  text-align: center;
}
.modal .muted,
.modal-foot .muted { color: var(--ink-soft); font-size: 13px; }
.modal h3, .modal h4 { font-family: var(--font-title); font-weight: 400; color: var(--ink); }

/* Поля ввода на пергаменте */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 700; color: var(--ink); }
.form-control,
.promo-input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid var(--parch-edge);
  border-radius: 10px;
  background: #fffaf0;
  color: var(--ink);
  font: 500 15px var(--font-ui);
  box-shadow: inset 0 2px 4px rgba(120, 80, 30, 0.15);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-control:focus,
.promo-input:focus {
  outline: none;
  border-color: var(--gold-3);
  box-shadow: inset 0 2px 4px rgba(120, 80, 30, 0.15), 0 0 0 3px rgba(242, 179, 61, 0.35);
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.checkbox, .checkbox-label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.checkbox input, .checkbox-label input { width: 18px; height: 18px; accent-color: var(--gold-3); margin-top: 2px; }

.promo-input-group { display: flex; gap: 10px; }
.promo-input { flex: 1; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.promo-message { min-height: 22px; margin-top: 10px; font-weight: 700; }
.promo-message.success { color: var(--emerald-3); }
.promo-message.error { color: var(--crimson-3); }

/* Событие */
.event-dialog { max-width: 460px; }
.event-message {
  margin: 0 0 18px;
  font: 400 19px/1.4 var(--font-title);
  color: var(--ink);
  white-space: pre-line;
  text-align: center;
}
.event-actions { display: flex; flex-direction: column; gap: 10px; }
#btnEventUseItem { --face-top: #6fdc96; --face-bot: #229b55; --lip: #11683a; --edge: #083d21; --label: #f2fff6; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
#btnEventIgnore { --face-top: #ff8a72; --face-bot: #d23e2b; --lip: #8e2416; --edge: #4d0f07; --label: #fff3ef; }

/* Клад найден */
.treasure-dialog,
.reward-dialog { max-width: 420px; text-align: center; overflow: visible; }
.treasure-dialog .modal-body,
.reward-dialog .modal-body { overflow: visible; padding-top: 26px; }
.treasure-celebration,
.reward-celebration { font-size: 34px; animation: float 2s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.treasure-title,
.reward-title { margin: 4px 0 6px; font: 400 28px var(--font-title); color: var(--gold-4); }
.treasure-icon,
.reward-icon {
  display: grid;
  place-items: center;
  width: 110px;
  height: 110px;
  margin: 10px auto;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 120, 0.9), rgba(255, 200, 80, 0) 70%);
  font-size: 64px;
  animation: treasure-shine 2.4s ease-in-out infinite;
}
@keyframes treasure-shine { 50% { filter: drop-shadow(0 0 18px rgba(255, 200, 60, 0.9)); } }
.treasure-name { font: 700 18px var(--font-ui); color: var(--ink); }
.treasure-value,
.reward-amount {
  display: inline-block;
  margin: 10px 0;
  padding: 6px 18px;
  border: 2px solid var(--gold-4);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #f2b33d);
  color: #4a2a06;
  font: 900 24px var(--font-ui);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 2px 0 rgba(0, 0, 0, 0.3);
}
.treasure-value .ico,
.reward-amount .ico { width: 24px; height: 24px; margin-left: 4px; vertical-align: -4px; color: #c98a1c; }

/* Лучи за находкой: медленно вращаются, у пустых сундуков их нет */
.treasure-icon,
.reward-icon { position: relative; isolation: isolate; }
.treasure-icon::before,
.reward-icon::before {
  content: "";
  position: absolute;
  inset: -34px;
  z-index: -1;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 210, 90, 0.55) 0 10deg, rgba(255, 210, 90, 0) 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: rays-spin 14s linear infinite;
}
@keyframes rays-spin { to { transform: rotate(360deg); } }
.treasure-empty .treasure-icon::before,
.treasure-fake .treasure-icon::before,
.treasure-already-found .treasure-icon::before { display: none; }

.treasure-desc,
.reward-reason { margin: 6px 0 16px; color: var(--ink-soft); }
.treasure-actions,
.reward-actions { display: flex; flex-direction: column; gap: 10px; }
.treasure-empty .treasure-icon,
.treasure-fake .treasure-icon,
.treasure-already-found .treasure-icon { filter: grayscale(0.6); animation: none; }

/* Высокая точка */
.high-spot-content p { margin: 0 0 10px; }
.high-spot-question { font-weight: 700; }
.high-spot-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* ==========================================================================
   ЛАВКА И РЮКЗАК
   ========================================================================== */

.store-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 2px solid var(--gold-3);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 224, 138, 0.6), rgba(242, 179, 61, 0.35));
}
.banner-icon { font-size: 28px; }
.banner-content { flex: 1; }
.banner-title { font: 400 18px var(--font-title); }
.banner-desc { font-size: 13px; color: var(--ink-soft); }

.backpack-counter,
.backpack-info,
.backpack-pro-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(110, 70, 30, 0.1);
  border: 1px dashed rgba(59, 38, 20, 0.35);
  font-weight: 700;
}
.backpack-info { flex-direction: column; align-items: flex-start; }
.info-desc, .pro-desc { font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.counter-full { color: var(--crimson-3); }
.pro-icon { font-size: 26px; }

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 2px solid var(--parch-edge);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff6df, #f0dfb6);
  box-shadow: 0 3px 0 rgba(120, 80, 30, 0.35);
}
.store-grid .item { margin-bottom: 0; }
.item .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 18px var(--font-title);
}
.item .title span:first-child {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #fff, #e6cf96);
  border: 2px solid var(--parch-edge);
  font-size: 24px;
}
.item .desc { font-size: 13px; color: var(--ink-soft); flex: 1; }
.item .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0; }
.item .foot .btn { min-height: 40px; padding: 0 14px 3px; font-size: 14px; }
.price {
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe08a, #f2b33d);
  border: 2px solid var(--gold-4);
  color: #4a2a06;
  font: 900 15px var(--font-ui);
  white-space: nowrap;
}
.price-expensive { filter: grayscale(0.5); opacity: 0.75; }
.price-pro { background: linear-gradient(180deg, #e7d9ff, #a98bf0); border-color: var(--arcane-3); color: #2a1458; }
.badge,
.badge-count {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(110, 70, 30, 0.15);
  color: var(--ink-soft);
  font: 700 11px var(--font-ui);
  font-family: var(--font-ui);
}
.badge-count { background: var(--emerald-2); color: #fff; }

/* PRO */
.sub-card { text-align: center; }
.sub-price { margin: 4px 0 14px; }
.price-amount { font: 900 48px var(--font-ui); color: var(--gold-4); }
.price-currency { font: 800 26px var(--font-ui); color: var(--gold-4); }
.price-period { color: var(--ink-soft); }
.sub-title { font: 400 20px var(--font-title); margin-bottom: 8px; }
.sub-list { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; }
.sub-list li { padding: 8px 10px; border-bottom: 1px dashed rgba(59, 38, 20, 0.25); }
.payment-info { margin-top: 10px; }

/* ==========================================================================
   ЖУРНАЛ, РЕЙТИНГ, АРТЕФАКТЫ, ИТОГИ
   ========================================================================== */

.journal-filters { display: flex; gap: 8px; margin-bottom: 12px; }
.filter-btn {
  flex: 1;
  height: 38px;
  border: 2px solid var(--parch-edge);
  border-radius: 10px;
  background: rgba(255, 250, 235, 0.6);
  color: var(--ink);
  font: 700 14px var(--font-ui);
  cursor: pointer;
  transition: background 0.12s;
}
.filter-btn:hover { background: rgba(255, 250, 235, 0.95); }
.filter-btn:active { background: rgba(242, 179, 61, 0.35); }
.filter-btn.active { background: linear-gradient(180deg, #ffe08a, #f2b33d); border-color: var(--gold-4); }
.filter-btn:focus-visible { outline: 2px solid var(--gold-3); outline-offset: 2px; }

.journal-entry,
.leaderboard-item,
.stat-item,
.ticket-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 2px solid rgba(169, 135, 79, 0.6);
  border-radius: 12px;
  background: rgba(255, 250, 235, 0.65);
}
.journal-entry.my-treasure { border-color: var(--gold-3); background: rgba(255, 224, 138, 0.55); }
.journal-icon { font-size: 26px; }
.journal-content { flex: 1; }
.journal-title { font-weight: 700; }
.journal-details { display: flex; gap: 12px; font-size: 13px; color: var(--ink-soft); }

.leaderboard-rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: rgba(110, 70, 30, 0.15);
  font: 900 18px var(--font-ui);
}
.leaderboard-player { flex: 1; min-width: 0; }
.leaderboard-name { font: 400 18px var(--font-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-stats { font-size: 13px; color: var(--ink-soft); }
.leaderboard-treasures { display: flex; align-items: center; gap: 4px; font: 900 18px var(--font-ui); color: var(--gold-4); white-space: nowrap; }
.leaderboard-treasures .ico { width: 20px; height: 20px; }
.leaderboard-stats .ico { width: 14px; height: 14px; margin-right: 2px; vertical-align: -2px; color: var(--gold-3); }
.leaderboard-stats .pro-tag { margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--gold-2, #f2b33d); color: #3d2104; font-weight: 800; font-size: 11px; }
/* Медали первой тройки: металл с выбитым номером */
.top-1 .leaderboard-rank,
.top-2 .leaderboard-rank,
.top-3 .leaderboard-rank { border: 2px solid rgba(0, 0, 0, 0.35); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 2px 0 rgba(0, 0, 0, 0.3); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
.top-1 .leaderboard-rank { background: radial-gradient(circle at 35% 30%, #fff4b8, #e7b33c 55%, #93600f); color: #4a2a06; }
.top-2 .leaderboard-rank { background: radial-gradient(circle at 35% 30%, #ffffff, #c4c6cf 55%, #707482); color: #33353d; }
.top-3 .leaderboard-rank { background: radial-gradient(circle at 35% 30%, #ffe0c2, #cd8a4f 55%, #7b4419); color: #3e1f08; }
.leaderboard-item.top-1 { border-color: #d9a52b; background: linear-gradient(90deg, rgba(255, 215, 100, 0.65), rgba(255, 250, 235, 0.6)); }
.leaderboard-item.top-2 { border-color: #a9a9b3; background: linear-gradient(90deg, rgba(220, 220, 230, 0.7), rgba(255, 250, 235, 0.6)); }
.leaderboard-item.top-3 { border-color: #c47f45; background: linear-gradient(90deg, rgba(232, 168, 110, 0.6), rgba(255, 250, 235, 0.6)); }

.artifacts-stats { display: flex; gap: 12px; margin-bottom: 14px; }
.stats-item { flex: 1; padding: 10px; border-radius: 10px; background: rgba(110, 70, 30, 0.1); text-align: center; }
.stats-label { display: block; font-size: 12px; color: var(--ink-soft); }
.stats-value { font: 900 20px var(--font-ui); }
.artifacts-section { margin-bottom: 14px; }
.artifacts-header { display: flex; justify-content: space-between; padding-bottom: 6px; margin-bottom: 8px; border-bottom: 2px solid; font: 400 17px var(--font-title); }
.artifacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.artifact-card { display: flex; gap: 10px; padding: 10px; border-radius: 10px; border: 2px solid rgba(169, 135, 79, 0.6); background: rgba(255, 250, 235, 0.6); }
.artifact-card.not-found { opacity: 0.55; filter: grayscale(0.8); }
.artifact-icon { font-size: 28px; }
.artifact-name { font-weight: 800; }
.artifact-desc, .artifact-date { font-size: 12px; color: var(--ink-soft); }

.day-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1b6, #e0a23c 60%, #8a5714); color: #4a2a06; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25), 0 2px 0 rgba(0, 0, 0, 0.3); }
.stat-icon .ico { width: 22px; height: 22px; }
.stat-label { font-size: 12px; color: var(--ink-soft); }
.stat-value { font: 900 20px var(--font-ui); }

.empty-state { padding: 22px 10px 10px; text-align: center; color: var(--ink-soft); }
.empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
  border: 2px dashed rgba(122, 74, 13, 0.4);
  border-radius: 50%;
  background: rgba(255, 250, 235, 0.6);
  color: var(--gold-3);
}
.empty-icon .ico { width: 36px; height: 36px; }
.empty-title { font: 400 21px var(--font-title); color: var(--ink); }
.empty-desc { max-width: 320px; margin: 4px auto 0; font-size: 14px; }
.empty-action { margin-top: 14px; }

.rules-section { margin-bottom: 14px; }
.rules-list { padding-left: 18px; }
.auth-info ul { padding-left: 4px; list-style: none; }
.auth-info li { position: relative; padding-left: 28px; margin-bottom: 6px; }
.auth-info li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--emerald-2) url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27%3E%3Cpath fill=%27%23fff%27 d=%27M9.2 15.6L4.8 11.2 2.7 13.3l6.5 6.5L21.3 7.7l-2.1-2.1z%27/%3E%3C/svg%3E") center / 12px no-repeat;
}
.support-menu { display: flex; flex-direction: column; gap: 10px; }
.partnership-info ul { padding-left: 18px; }
.partnership-info li::marker { color: var(--gold-3); }

/* Поддержка: обращения */
.tickets-list { display: flex; flex-direction: column; }
.ticket-item { flex-direction: column; align-items: stretch; cursor: pointer; }
.ticket-item:hover { background: rgba(255, 250, 235, 0.95); }
.ticket-header, .ticket-meta, .ticket-details-header, .reply-header { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.ticket-subject, .ticket-details-title { font-weight: 800; }
.ticket-status { padding: 2px 8px; border-radius: 999px; background: rgba(110, 70, 30, 0.15); font-size: 12px; font-weight: 700; }
.ticket-message, .reply-item { margin: 8px 0; padding: 10px; border-radius: 10px; background: rgba(255, 250, 235, 0.7); }
.reply-admin { border-left: 4px solid var(--emerald-2); }
div.loading { padding: 20px; text-align: center; color: var(--ink-soft); }

/* Реклама */
.ad-container { min-height: 140px; display: grid; place-items: center; border-radius: 10px; background: rgba(110, 70, 30, 0.1); }
.ad-placeholder { text-align: center; }
.ad-icon { color: var(--ink-soft); }
.ad-icon .ico { width: 44px; height: 44px; }
.ad-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Праздник PRO */
.celebration-modal .modal-content { max-width: 440px; text-align: center; }
.celebration-header { padding: 22px 20px 0; }
.celebration-icon { font-size: 54px; }
.celebration-header h2 { margin: 6px 0; font: 400 30px var(--font-title); color: var(--gold-4); }
.celebration-body { padding: 10px 20px; }
.pro-benefits { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; text-align: left; }
.benefit-item { padding: 8px 10px; border-radius: 8px; background: rgba(255, 224, 138, 0.4); }
.pro-timer-container { margin-top: 10px; }
.pro-timer-label { font-size: 13px; color: var(--ink-soft); }
.pro-timer { font: 900 22px var(--font-ui); color: var(--gold-4); }
.celebration-footer { padding: 14px 20px 22px; }
.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 2000; overflow: hidden; }
.confetti-piece { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ==========================================================================
   БЛОКИРОВКА ПОВЕРХ КАРТЫ
   ========================================================================== */

.block-overlay {
  position: absolute;
  inset: 14px;
  z-index: 5;
  display: grid;
  place-items: center;
  /* скрипт включает display: flex - центрируем и в этом случае */
  justify-content: center;
  align-items: center;
  padding: 16px;
  border-radius: 8px;
  background: radial-gradient(ellipse at center, rgba(20, 12, 6, 0.6), rgba(10, 6, 3, 0.88));
  backdrop-filter: blur(2px);
}
.block-content {
  width: 100%;
  max-width: 340px;
  padding: 20px;
  border: 3px solid var(--wood-4);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--parch-1), var(--parch-2));
  box-shadow: inset 0 0 0 2px var(--parch-edge), 0 10px 30px rgba(0, 0, 0, 0.6);
  color: var(--ink);
  text-align: center;
}
.block-icon { font-size: 52px; line-height: 1.1; }
.block-title { margin: 6px 0; font: 400 26px var(--font-title); }
.block-message { color: var(--ink-soft); }
.block-reason { margin-top: 8px; font-size: 13px; color: var(--crimson-3); font-weight: 700; }
.block-timer {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 16px;
  border-radius: 10px;
  background: #24170c;
  color: var(--gold-1);
  font: 900 26px ui-monospace, Menlo, monospace;
  letter-spacing: 0.06em;
}
.block-timer:empty { display: none; }
.block-actions { margin-top: 14px; display: flex; justify-content: center; gap: 10px; }

/* ==========================================================================
   УВЕДОМЛЕНИЯ
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  z-index: 3000;
  max-width: min(92vw, 460px);
  padding: 12px 16px 12px 46px;
  border: 2px solid var(--wood-4);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--parch-1), var(--parch-2));
  box-shadow: inset 0 0 0 2px var(--parch-edge), 0 8px 24px rgba(0, 0, 0, 0.55);
  color: var(--ink);
  font: 700 15px/1.35 var(--font-ui);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.toast[aria-hidden="false"] { opacity: 1; }
.toast::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-top: -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b6, #d49a36 55%, #6e430d);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
.toast-success::before { background: radial-gradient(circle at 35% 30%, #c9ffd9, #2fb569 55%, #0c4a26); }
.toast-error::before { background: radial-gradient(circle at 35% 30%, #ffd2c9, #e04b37 55%, #5e150d); }
.toast-warning::before { background: radial-gradient(circle at 35% 30%, #fff3c4, #f08a2a 55%, #7a3a08); }
.toast-special { background: linear-gradient(180deg, #fff2bf, #f5cf6a); }
.toast-special::before { background: radial-gradient(circle at 35% 30%, #fff, #c7a6ff 55%, #4c2a91); }

.offline-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 2500;
  display: none;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--crimson-3);
  color: #fff;
  font-weight: 700;
  transform: translateX(-50%);
}
.offline-banner.show { display: flex; }

/* ==========================================================================
   СЕЗОННЫЕ ЧАСТИЦЫ (снежинки, листья, лепестки)
   ========================================================================== */

.season-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.season-particle {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 240, 210, 0.5);
  animation: particle-fall linear infinite;
}
body[data-season="autumn"] .season-particle { width: 10px; height: 6px; border-radius: 60% 0; background: rgba(232, 128, 48, 0.55); }
body[data-season="spring"] .season-particle { width: 8px; height: 6px; border-radius: 60% 0; background: rgba(255, 182, 210, 0.55); }
body[data-season="summer"] .season-particle { width: 3px; height: 3px; background: rgba(255, 230, 140, 0.6); box-shadow: 0 0 6px rgba(255, 220, 120, 0.8); }
body[data-season="winter"] .season-particle { background: rgba(240, 248, 255, 0.75); }
body.in-dungeon .season-particle { display: none; }
@keyframes particle-fall { to { transform: translate(40px, 105vh) rotate(360deg); } }

.gamebar, .hud, .layout, .foot { position: relative; z-index: 1; }
.gamebar { z-index: 50; }

/* ==========================================================================
   АДАПТИВ
   ========================================================================== */

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 680px); }
  .log { max-height: 260px; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .gamebar { gap: 8px; padding: 8px 10px; }
  .brand-name { display: none; }
  .season-chip { height: 36px; padding: 0 10px; font-size: 13px; max-width: 46vw; }
  .season-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .map-hash { display: none; }
  .gbtn-icon { width: 42px; }
  .hud { gap: 6px; margin-top: 10px; padding: 0 8px; }
  .hud-item { height: 38px; font-size: 14px; padding-right: 10px; }
  .hud-ico { width: 26px; height: 26px; }
  .moves-meter { width: 96px; }
  .layout { margin-top: 10px; padding: 0 8px 18px; gap: 14px; }
  .map-frame { padding: 9px; border-radius: 14px; }
  .rivet { width: 10px; height: 10px; }
  .rivet-tl, .rivet-tr { top: 2px; } .rivet-bl, .rivet-br { bottom: 2px; }
  .rivet-tl, .rivet-bl { left: 2px; } .rivet-tr, .rivet-br { right: 2px; }
  .biome-info { top: 14px; left: 14px; font-size: 12px; padding: 3px 9px; }
  .block-overlay { inset: 9px; }
  .heat-gauge { flex-direction: column; align-items: stretch; gap: 8px; }
  .heat-scale { width: 100%; }
  .hint { font-size: 17px; text-align: center; }
  .controls { gap: 10px; }
  .left-actions { min-width: 0; flex: 1; }
  .dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
  .round, .dkey { width: 56px; height: 56px; }
  .day-stats { grid-template-columns: 1fr; }
  .modal { padding: 10px; }
}

@media (max-width: 380px) {
  .left-actions .gbtn-label { display: none; }
  .left-actions .gbtn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   ПЛОЩАДКИ (сборка для Яндекс Игр)
   ========================================================================== */

/* Внешние ссылки, промокоды и оплата мимо площадки там запрещены */
body.platform-yandex .no-platform,
body.platform-yandex .season-prizes,
body.platform-yandex .season-agreement { display: none !important; }

/* PRO не продаётся, пока товар не заведён в консоли */
body.no-pro-sale #btnSubscription,
body.no-pro-sale .store-banner,
body.no-pro-sale [data-action="buy-pro"] { display: none !important; }
body.no-platform-auth #btnAuth { display: none !important; }

/* Долгое нажатие не выделяет текст и не открывает меню */
body.platform-yandex {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body.platform-yandex input,
body.platform-yandex textarea {
  -webkit-user-select: text;
  user-select: text;
}

.currency-icon { width: 0.8em; height: 0.8em; vertical-align: -0.05em; }

/* ==========================================================================
   ТЕЛЕФОН: ИГРОВОЙ ЭКРАН БЕЗ ПРОКРУТКИ
   ========================================================================== */

/* Пункты меню, которые нужны только на телефоне */
.menu-mobile { display: none; }
.sheet-close { display: none; }

@media (max-width: 640px) {
  .menu-mobile { display: flex; }

  /* Дневник и подвал уходят в меню шестерёнки */
  .side,
  .foot { display: none; }

  /* Сводка в одну строку: координаты на телефоне не нужны */
  .hud { flex-wrap: nowrap; justify-content: center; }
  .position-display,
  #proStatus { display: none !important; }
  .moves-meter { width: 82px; }

  /* Карта ужимается по высоте экрана, чтобы крестовина оставалась видна.
     Запас под шапку, сводку, прибор тепла и управление ~ 372px */
  .map-frame {
    width: min(100%, calc(100vh - 372px));
    width: min(100%, calc(100dvh - 372px));
    min-width: 240px;
    margin: 0 auto;
  }

  /* Панель подземелья - одной строкой: название и кнопка, без пояснения */
  .dungeon-panel { gap: 10px; padding: 8px 10px; }
  .dungeon-panel-icon { width: 36px; height: 36px; font-size: 20px; border-radius: 10px; }
  .dungeon-panel-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dungeon-panel-sub { display: none; }
  .dungeon-panel-btn { min-width: 0; padding-left: 14px; padding-right: 14px; }
  /* С панелью подземелья карте нужно уступить ещё ~60px */
  .board-card:has(#dungeonPanel:not([hidden])) .map-frame {
    width: min(100%, calc(100vh - 432px));
    width: min(100%, calc(100dvh - 432px));
  }

  /* Прибор тепла - одной строкой */
  .heat-gauge { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; }
  .heat-scale { width: 42%; flex: none; }
  .hint { font-size: 15px; text-align: left; line-height: 1.2; }

  .gamebar { padding-top: 6px; padding-bottom: 6px; }
  .hud { margin-top: 6px; }
  .layout { gap: 10px; margin-top: 6px; padding-bottom: 6px; }
  .board-card { gap: 6px; }
  .dpad { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 3px; padding: 6px; }
  .round, .dkey { width: 46px; height: 46px; }

  /* Имя игрока в шапке не помещается рядом с сезоном и кнопками */
  .user-info { display: none !important; }

  /* Дневник выезжает снизу поверх игры, затемнение - тенью самой панели */
  body.log-sheet .layout { z-index: 60; }
  body.log-sheet .side {
    display: block;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 900;
    max-height: 72vh;
    max-height: 72dvh;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 0 0 100vmax rgba(10, 6, 3, 0.65);
  }
  body.log-sheet .journal-panel { position: relative; }
  body.log-sheet .sheet-close { display: grid; position: absolute; top: 8px; right: 8px; }
  body.log-sheet #logToggle { pointer-events: none; padding-right: 52px; }
  body.log-sheet .log-arrow { display: none; }
}

/* ==========================================================================
   КОМПЬЮТЕР: КАРТА СЛЕВА НА ВСЮ ВЫСОТУ, УПРАВЛЕНИЕ СПРАВА
   ========================================================================== */
/* Окно Яндекс Игр на ноутбуке ~720px в высоту: карта подстраивается под
   высоту, а прибор тепла, подземелье и крестовина стоят рядом, а не под ней */
@media (min-width: 981px) {
  .layout {
    grid-template-columns: auto minmax(300px, 360px);
    grid-template-rows: auto auto auto 1fr;
    align-content: start;
    align-items: start;
    column-gap: 20px;
    row-gap: 12px;
    padding-bottom: 8px;
  }
  .board-card { display: contents; }
  .map-frame {
    grid-column: 1;
    grid-row: 1 / span 4;
    width: min(680px, calc(100vh - 176px));
    min-width: 420px;
  }
  .heat-gauge,
  .dungeon-panel,
  .controls,
  .side { grid-column: 2; }
  .heat-gauge { flex-direction: column; align-items: stretch; gap: 8px; }
  .heat-scale { width: 100%; }
  .dungeon-panel { flex-wrap: wrap; }
  .dungeon-panel-btn { width: 100%; }
  .controls { flex-direction: column; align-items: center; gap: 12px; }
  .left-actions { flex-direction: row; width: 100%; min-width: 0; }
  .left-actions .gbtn { flex: 1; justify-content: center; }
  .dpad { grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); padding: 8px; }
  .round, .dkey { width: 54px; height: 54px; }
  .dungeon-panel { padding: 10px 12px; gap: 8px 10px; }
}

/* На площадке подвала нет: правила и поддержка - в меню шестерёнки */
body.platform-yandex .foot { display: none; }
body.platform-yandex #btnMenuRules,
body.platform-yandex #btnMenuSupport { display: flex; }
