/* Оформление «Ниндзя и Подземелья».
   Правила, из-за которых интерфейс не наезжает сам на себя:
   • экран — это абсолютный слой, видим ровно один (.screen--active);
   • у каждого экрана колоночный flex: шапка, растяжимая середина, подвал;
   • середина всегда с min-height: 0, иначе flex не даст ей сжаться и
     содержимое вылезет за пределы вьюпорта;
   • всё прокручиваемое лежит в .scroll и только в нём. */

:root {
  --bg: #0d1017;
  --bg-2: #151a24;
  --panel: #1b2130;
  --panel-2: #232b3d;
  --line: #313b52;
  --text: #eef2fb;
  --muted: #9aa6c0;
  --gold: #ffd257;
  --accent: #8be0ff;
  --danger: #ff5d5d;
  --good: #7ee081;
  --radius: 14px;
  --tap: 46px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Полоса живой сцены внизу главного экрана. Столько же отступа снизу
     получает содержимое меню, иначе кнопки встанут поверх героя. */
  --scene-h: clamp(84px, 14vh, 130px);
}

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

/* Атрибут hidden обязан побеждать любой display из классов: без !important
   .btn { display: inline-flex } перебивает браузерное [hidden] и скрытые
   кнопки продолжают показываться. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

img {
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-drag: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background:
    radial-gradient(120% 80% at 50% 0%, #1b2436 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

.screen--active {
  display: flex;
}

/* ------------------------------- загрузка ------------------------------- */

.boot {
  margin: auto;
  padding: 24px;
  text-align: center;
  max-width: 420px;
}

.boot__title,
.menu__title {
  margin: 0 0 12px;
  font-size: clamp(28px, 8vw, 46px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 3px 0 #7a5a12, 0 6px 18px rgba(0, 0, 0, 0.6);
}

.boot__title span,
.menu__title span {
  display: block;
  font-size: 0.5em;
  color: var(--text);
  text-shadow: 0 2px 0 #10131c;
  letter-spacing: 0.24em;
}

.boot__bar {
  height: 12px;
  border-radius: 999px;
  background: #0a0d14;
  border: 2px solid var(--line);
  overflow: hidden;
}

.boot__bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), #ffb03a);
  transition: width 0.25s ease;
}

.boot__hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* -------------------------------- шапки --------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 58px;
  background: rgba(13, 16, 23, 0.7);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.topbar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.topbar__spacer {
  flex: 1 1 auto;
}

.icon-btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:active {
  transform: translateY(1px);
}

.purse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 38px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.purse__icon {
  width: 18px;
  height: 18px;
}

/* ------------------------------ главное меню ---------------------------- */

/* Живая сцена лежит слоем ниже содержимого меню и не ловит нажатия. */
.screen--menu {
  background:
    radial-gradient(140% 90% at 50% -10%, #24304a 0%, transparent 55%),
    linear-gradient(180deg, #131824, #0b0e15);
}

.menu-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.screen--menu .topbar,
.screen--menu .menu {
  position: relative;
  z-index: 1;
}

.screen--menu .topbar {
  background: linear-gradient(180deg, rgba(10, 13, 20, 0.9), rgba(10, 13, 20, 0.35));
  border-bottom-color: rgba(49, 59, 82, 0.6);
  backdrop-filter: blur(4px);
}

.menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px var(--scene-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  /* Если содержимое всё-таки не влезло, нижняя строка растворяется, а не
     обрезается по линии. Когда влезло — растворяется пустой отступ. */
  -webkit-mask-image: linear-gradient(180deg, #000 calc(100% - 30px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 calc(100% - 30px), transparent 100%);
}

/* Колоночный flex по умолчанию сжимает элементы, когда содержимое не влезает,
   и текст внутри кнопки оказывается обрезан. Прокручиваемым спискам сжатие
   не нужно вовсе: они и так прокручиваются. */
.menu > *,
.scroll > *,
.battlepanel > * {
  flex-shrink: 0;
}

.menu__sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* Разделитель с сюрикеном под заголовком. */
.menu__rule {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: -8px 0 -4px;
}

.menu__rule i {
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 210, 87, 0.55), transparent);
}

.menu__rule img {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  opacity: 0.9;
}

.menu__hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(38, 47, 68, 0.92), rgba(22, 28, 41, 0.92));
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.35);
  max-width: 420px;
  width: 100%;
  text-align: left;
}

.menu__hero img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--panel-2);
  flex: 0 0 auto;
}

.menu__hero b {
  display: block;
  font-size: 16px;
}

.menu__hero small {
  color: var(--muted);
  font-size: 13px;
}

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

.menu__grid {
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* Полоска достижений: сухие цифры, но экран перестаёт быть пустым. */
.menu__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 420px;
}

.menu__stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(20, 25, 37, 0.88);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.menu__stats b {
  color: var(--text);
}

.menu__platform {
  margin: 0;
  color: #7c88a4;
  font-size: 12px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.tile-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: 60px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(38, 47, 68, 0.9), rgba(22, 28, 41, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 4px 14px rgba(0, 0, 0, 0.3);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.tile-btn img {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

.tile-btn__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tile-btn:hover {
  border-color: rgba(255, 210, 87, 0.45);
}

.tile-btn__name {
  font-weight: 700;
  font-size: 16px;
}

.tile-btn__hint {
  color: var(--muted);
  font-size: 12px;
}

.tile-btn:active {
  transform: translateY(1px);
}

.banner {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid #47592f;
  background: linear-gradient(135deg, rgba(45, 61, 32, 0.95), rgba(24, 32, 20, 0.95));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.35);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

/* Тонкая бегущая подсветка: баннер награды должен звать нажать. */
.banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, 0.09) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: banner-shine 4.5s ease-in-out infinite;
  pointer-events: none;
}

.banner:disabled::after {
  display: none;
}

@keyframes banner-shine {
  0%, 70% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.banner--accent {
  border-color: #5c4620;
  background: linear-gradient(135deg, rgba(60, 46, 26, 0.95), rgba(34, 27, 17, 0.95));
}

.banner__title {
  font-weight: 700;
  color: var(--gold);
}

.banner__text {
  font-size: 13px;
  color: var(--muted);
}

/* -------------------------------- кнопки -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn--primary {
  background: linear-gradient(180deg, #ffe07d, #e0a327);
  border-color: #8a6410;
  color: #201704;
  box-shadow: 0 6px 20px rgba(255, 180, 60, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn--big {
  min-height: 56px;
  font-size: 18px;
  letter-spacing: 0.03em;
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  background: #3a1d20;
  border-color: #6a2b2b;
  color: #ffb3b3;
}

.btn--tiny {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* ------------------------------ прокрутка ------------------------------- */

.scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.card__icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--panel-2);
  padding: 4px;
}

.card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.card__title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 15px;
}

.card__desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.card__side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 108px;
}

.card--locked {
  opacity: 0.75;
}

.card--active {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 87, 0.35);
}

.pips {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.pips i {
  width: 16px;
  height: 6px;
  border-radius: 3px;
  background: #2c3448;
}

.pips i.on {
  background: var(--gold);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.tag--gold {
  color: #201704;
  background: var(--gold);
  border-color: #8a6410;
}

.tag--good {
  color: #0f2113;
  background: var(--good);
  border-color: #2f6b39;
}

.section-title {
  margin: 12px 0 2px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #0a0d14;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-top: 6px;
}

.progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #4aa8d8);
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  min-height: var(--tap);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.switch {
  flex: 0 0 auto;
  width: 62px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0a0d14;
  position: relative;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch[aria-checked="true"] {
  background: #33421f;
  border-color: #526b2b;
}

.switch[aria-checked="true"]::after {
  transform: translateX(28px);
  background: var(--good);
}

/* ---------------------------------- бой --------------------------------- */

.screen--game {
  display: none;
}

.screen--game.screen--active {
  display: flex;
  flex-direction: column;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(13, 16, 23, 0.82);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.hud__vitals {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud__row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hud__relics {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 92px;
  justify-content: flex-end;
}

.hud__relics img {
  width: 22px;
  height: 22px;
}

.bar {
  position: relative;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0a0d14;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7ee081, #4bb45a);
  transition: width 0.2s ease;
}

.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.chip--gold {
  color: var(--gold);
}

/* На телефоне экран вдвое выше поля 11×9. Поэтому поле держит свою пропорцию
   и отдаёт остаток панели боя — иначе половина экрана была бы пустым фоном.
   В альбомной ориентации и на низких окнах панель прячется, а поле забирает
   всё место. */
.board {
  position: relative;
  flex: 0 1 auto;
  width: 100%;
  aspect-ratio: 11 / 9;
  min-height: 0;
  min-width: 0;
  display: flex;
}

.battlepanel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: rgba(10, 13, 20, 0.35);
}

.battlepanel__hero {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}

.battlepanel__hero img {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--panel);
  flex: 0 0 auto;
}

.battlepanel__hero b {
  color: var(--text);
}

.battlepanel__relics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.battlepanel__relics span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.battlepanel__relics img {
  width: 18px;
  height: 18px;
}

.battlepanel__enemies {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.battlepanel__enemies div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
}

.battlepanel__enemies img {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.battlepanel__enemies b {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.battlepanel__enemies i {
  flex: 0 0 auto;
  font-style: normal;
  color: var(--muted);
}

.battlepanel__enemies i.danger {
  color: #ff8a8a;
}

.battlepanel__hint {
  margin: auto 0 0;
  /* Справа внизу может стоять крестовина движения — оставляем ей место. */
  padding: 6px 150px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #6d7995;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Поле держит пропорцию 11×9, поэтому на высоких экранах над ним и под ним
   остаётся место. Оно занято сводкой боя и журналом — так экран не выглядит
   полупустым, а игрок видит, что происходит, не отвлекаясь от поля. */
.board__status {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.board__status span {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.7);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.board__log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  line-height: 1.35;
}

.board__log p {
  margin: 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(10, 13, 20, 0.7);
  border: 1px solid var(--line);
  color: var(--muted);
}

.board__log p.warn {
  color: #ffc46b;
}

.board__log p.good {
  color: var(--good);
}

.board__log p.boss {
  color: #ff9a8a;
}

.board__toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.9);
  border: 1px solid var(--line);
  font-size: 13px;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
}

.board__targeting {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.92);
  border: 1px solid var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

.actionbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 10px;
  background: rgba(13, 16, 23, 0.86);
  border-top: 1px solid var(--line);
}

.skills {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* Квадратная пропорция кнопки печати задавала ей ширину от высоты и на узких
   экранах кнопки наезжали друг на друга поверх сетки. Высота задаётся явно,
   ширину определяет колонка сетки. */
.skill {
  position: relative;
  height: clamp(44px, 13vw, 64px);
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}

/* Строка сетки должна быть определённой, иначе проценты у картинки считаются
   от её собственного размера и иконка вылезает за кнопку. */
.skill {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.skill img,
.round-btn img {
  width: 62%;
  height: 62%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.skill--empty {
  opacity: 0.35;
  cursor: default;
}

.skill--armed {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 224, 255, 0.35);
}

.skill--cooling img {
  opacity: 0.3;
}

.skill__cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 2px 4px #000;
}

.skill__key {
  position: absolute;
  top: 2px;
  left: 5px;
  font-size: 10px;
  color: var(--muted);
}

.actionbar__side {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.round-btn {
  position: relative;
  width: clamp(44px, 13vw, 56px);
  height: clamp(44px, 13vw, 56px);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.round-btn__count {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 2px #000;
}

.round-btn:disabled {
  opacity: 0.4;
}

.dpad {
  position: absolute;
  right: 10px;
  bottom: calc(92px + var(--safe-bottom));
  width: 138px;
  height: 138px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  opacity: 0.85;
  pointer-events: auto;
}

.dpad__btn {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(27, 33, 48, 0.9);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.dpad__btn--up {
  grid-column: 2;
  grid-row: 1;
}

.dpad__btn--left {
  grid-column: 1;
  grid-row: 2;
}

.dpad__btn--right {
  grid-column: 3;
  grid-row: 2;
}

.dpad__btn--down {
  grid-column: 2;
  grid-row: 3;
}

/* ------------------------------- модалка -------------------------------- */

.modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal__box {
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1c2333, #141924);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal__title {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--gold);
  text-align: center;
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.modal__text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.choice:active {
  transform: translateY(1px);
}

.choice img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.choice__body {
  flex: 1 1 auto;
  min-width: 0;
}

.choice__name {
  font-weight: 700;
  font-size: 15px;
}

.choice__desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid div {
  padding: 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.stat-grid b {
  display: block;
  font-size: 18px;
  color: var(--text);
}

/* -------------------------------- тосты --------------------------------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.94);
  border: 1px solid var(--line);
  font-size: 14px;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
}

.toast[hidden] {
  display: none;
}

/* ------------------------------ адаптация ------------------------------- */

@media (min-width: 720px) {
  /* Четыре колонки в сетке разделов не помещаются: колонка меню шире 420 px
     не растягивается, и подписи вроде «Постоянные улучшения» обрезаются.
     Две колонки одинаково хорошо выглядят и на телефоне, и на планшете. */
  .scroll {
    padding: 18px max(18px, calc((100% - 720px) / 2)) 30px;
  }

  .skills {
    max-width: 420px;
  }

  .actionbar {
    justify-content: center;
  }
}

@media (orientation: landscape), (max-height: 620px) {
  .board {
    flex: 1 1 auto;
    aspect-ratio: auto;
  }

  .battlepanel {
    display: none;
  }
}

/* Невысокое окно — обычное дело во фрейме ВКонтакте на компьютере. Меню
   ужимается, чтобы поместиться целиком: прокрутка на главном экране выглядит
   поломкой, а не задумкой. */
@media (max-height: 780px) {
  :root {
    --scene-h: clamp(62px, 10vh, 92px);
  }

  .menu {
    gap: 8px;
  }

  .menu__title {
    margin: 0 0 4px;
    font-size: clamp(24px, 7vw, 34px);
  }

  .menu__rule,
  .menu__sub {
    display: none;
  }

  .tile-btn {
    min-height: 52px;
  }

  .banner {
    padding: 9px 14px;
  }

  .menu__hero {
    padding: 8px 14px;
  }

  .menu__hero img {
    width: 40px;
    height: 40px;
  }

  .btn--big {
    min-height: 50px;
  }
}

/* Узкий или очень низкий экран: подписи разделов уводят вёрстку в прокрутку,
   а названия «Логово», «Клан», «Лавка», «Свитки» понятны и без них. */
@media (max-width: 360px), (max-height: 640px) {
  .tile-btn__hint {
    display: none;
  }

  .menu__hero small {
    display: none;
  }

  :root {
    --scene-h: clamp(56px, 9vh, 80px);
  }
}

@media (max-height: 560px) {
  .menu__title {
    font-size: clamp(22px, 6vw, 32px);
  }

  .menu__hero {
    display: none;
  }

  .skill {
    height: clamp(40px, 11vw, 48px);
  }

  .round-btn {
    width: clamp(40px, 11vw, 48px);
    height: clamp(40px, 11vw, 48px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
