/* «Сказка днём» — визуал по ../../art/STYLE.md (светлая тема по брифу владельца 01.12; отступление от канона mihey-brand-style отмечено в evidence/art/final.md).
   Шрифт: Nunito (SIL OFL 1.1), вариативный, локально: fonts/Nunito-sub.woff2 (с кириллицей). Лицензия: fonts/OFL-Nunito.txt. */

@font-face {
  font-family: 'Nunito';
  src: url('./fonts/Nunito-sub.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --sky-top: #BFE9FF;
  --sky-bot: #EAF8FF;
  --panel: #FFF6E6;
  --panel-edge: #E2CFA8;
  --text: #2B2D42;
  --muted: #5C6378;
  --accent: #6BE6A8;
  --accent-lip: #2EA76A;
  --accent-ink: #1F7A4D;
  --shadow: rgba(43, 45, 66, 0.16);
  --r-lg: 14px;
  --r-md: 12px;
  --r-sm: 10px;
  --r-xs: 9px;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 100%);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  gap: 6px;
}

/* Шапка: название, крупный счёт, рекорд. */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  flex: 0 0 auto;
}

.hud__title {
  font-weight: 800;
  font-size: clamp(15px, 4vw, 19px);
  line-height: 1.2;
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.hud__stats {
  font-size: clamp(12px, 3.2vw, 14px);
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud__stats b {
  color: var(--text);
  font-weight: 800;
  font-size: clamp(20px, 6vw, 28px);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

#best {
  font-size: clamp(14px, 4vw, 18px) !important;
}

.hud__stats b.record {
  animation: record-pulse 1.6s ease-out 1;
  color: var(--accent-ink);
}

@keyframes record-pulse {
  0% { transform: scale(1); }
  20% { transform: scale(1.35); }
  45% { transform: scale(0.95); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.hud__tools {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.chip {
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  background: var(--panel);
  border: 0;
  border-radius: var(--r-xs);
  box-shadow: 0 3px 0 var(--panel-edge), 0 4px 10px var(--shadow);
  padding: 7px 10px;
  min-height: 44px;   /* зона касания ≥44 px */
  min-width: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 70ms ease-out, box-shadow 70ms ease-out;
}

/* Лесенка построек: палатка → … → замок. Закрытые — знак «?». */
.ladder {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
}

.ladder__row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}

.ladder__item {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  min-width: 28px;
  text-align: center;
}

.ladder__item--on {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 2px 0 var(--accent-lip);
}

.ladder__item--next {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-lip);
}

.ladder__item--lock {
  background: rgba(255, 253, 247, 0.5);
  color: var(--muted);
}

.ladder__arrow {
  color: var(--muted);
  font-weight: 800;
}

.ladder__next {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

/* Тряска поля на занятой клетке: короткая, ~110 мс. */
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
#stage.stage--nudge {
  animation: nudge 110ms ease-out 1;
}

/* Сцена «Новая постройка!»: карточка с отскоком, конфетти. Не перехватывает ввод. */
.unlock {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 8;
}

.unlock[hidden] {
  display: none;
}

.unlock__card {
  background: var(--panel);
  border: 3px solid var(--accent-lip);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 14px 22px 12px;
  text-align: center;
  min-width: 180px;
}

.unlock__title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-ink);
}

.unlock__cv {
  display: block;
  width: 96px;
  height: 96px;
  margin: 4px auto 2px;
}

.unlock__name {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.unlock__fx {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 0;
  height: 0;
}

.confetti {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  left: 0;
  top: 0;
  animation: confetti-fall 900ms cubic-bezier(0.2, 0.7, 0.4, 1) var(--d, 0ms) both;
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(calc(var(--x) * 2.2px), 160px) rotate(540deg); opacity: 0; }
}

.unlock--show .unlock__card {
  animation: card-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.chip:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--panel-edge), 0 2px 6px var(--shadow);
}

#stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cv {
  display: block;
  touch-action: none;
  cursor: pointer;
}

.tip {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  width: max-content; /* без этого блок с left:50% сжимался до половины ширины и подсказка шла в 4 строки */
  max-width: min(94%, 440px);
  background: var(--panel);
  border: 2px solid var(--accent-lip);
  border-radius: var(--r-md);
  box-shadow: 0 4px 12px var(--shadow);
  color: var(--text);
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  z-index: 4;
}

.tip--pick {
  top: auto;
  bottom: 6px;
  border-color: var(--panel-edge);
}

.tip[hidden] {
  display: none;
}

/* Круглые пузыри: склад, «в руке», «следующая». */
.panel {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(10px, 3.5vw, 26px);
  flex: 0 0 auto;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.slot__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.slot__box {
  width: clamp(56px, 16vw, 72px);
  height: clamp(56px, 16vw, 72px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF 0%, var(--panel) 55%, #F3E9D6 100%);
  box-shadow: 0 3px 0 var(--panel-edge), 0 6px 14px var(--shadow);
  cursor: pointer;
  overflow: hidden;
}

.slot__box--hand {
  box-shadow: 0 0 0 4px var(--accent), 0 3px 0 var(--panel-edge), 0 6px 14px var(--shadow);
  cursor: default;
}

.slot__box:disabled {
  opacity: 0.5;
  cursor: default;
}

.slot__box:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--panel-edge), 0 2px 6px var(--shadow);
}

.slot__cv {
  width: 100%;
  height: 100%;
  display: block;
}

/* Въезд постройки в слот после хода: сдвиг справа + fade, 200 мс. Класс ставит main.js. */
@keyframes slot-in {
  from { transform: translateX(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes slot-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.slot__cv--in {
  animation: slot-in 200ms ease-out both;
}

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

.btn {
  position: relative;
  font: inherit;
  font-weight: 800;
  font-size: clamp(13px, 3.4vw, 15px);
  color: var(--text);
  background: var(--panel);
  border: 0;
  border-radius: var(--r-md);
  box-shadow: 0 3px 0 var(--panel-edge), 0 6px 12px var(--shadow);
  padding: 9px 6px;
  min-height: 46px;
  cursor: pointer;
  line-height: 1.2;
  overflow-wrap: anywhere;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Нажатие: сдвиг на 2 px, тень короче (правило STYLE.md, раздел 4). */
.btn:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--panel-edge), 0 2px 6px var(--shadow);
}

/* Реклама: ширина по содержимому, по центру ячейки; значок ролика слева (треугольник «play»). */
.btn--ad {
  justify-self: center;
  width: max-content;
  min-width: 120px;
  padding-left: 30px;
  padding-right: 16px;
  box-shadow: 0 3px 0 var(--accent-lip), 0 6px 12px var(--shadow);
}

.btn--ad::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 9px solid var(--accent-ink);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.btn--ad .badge:empty {
  display: none;
}

.btn--ad:not(:disabled):active {
  box-shadow: 0 1px 0 var(--accent-lip), 0 2px 6px var(--shadow);
}

.btn--used {
  opacity: 0.5;
  box-shadow: none;
}

.badge {
  display: block;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-ink);
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.btn--primary {
  background: var(--accent);
  box-shadow: 0 3px 0 var(--accent-lip), 0 6px 12px var(--shadow);
  padding: 12px 22px;
  min-width: 160px;
}

.btn--primary:not(:disabled):active {
  box-shadow: 0 1px 0 var(--accent-lip), 0 2px 6px var(--shadow);
}

.toast {
  position: absolute;
  left: 50%;
  top: 42%; /* над полем: не закрывает подписи слотов и кнопки */
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  background: var(--panel);
  border: 2px solid var(--accent-lip);
  border-radius: var(--r-md);
  box-shadow: 0 4px 12px var(--shadow);
  color: var(--text);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  z-index: 5;
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 45, 66, 0.35);
  padding: 16px;
  z-index: 10;
}

.modal[hidden] {
  display: none;
}

/* Появление окна: fade + лёгкий scale с перелётом (easeOutBack), 240 мс. */
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes card-in {
  from { opacity: 0; transform: scale(0.9) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.modal:not([hidden]) {
  animation: modal-fade 160ms ease-out both;
}
.modal:not([hidden]) .card {
  animation: card-in 240ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Экран итога (polish2): строка «Лучший результат», отметка «Новый рекорд!» и конфетти поверх окна. */
#overBest {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 16px;
}
.over-record {
  margin: 8px 0 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--accent-ink);
}
.over-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.over-confetti__piece {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 13px;
  border-radius: 2px;
  opacity: 0;
  animation: over-confetti-fall 1.7s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}
@keyframes over-confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift, 0px), 105vh) rotate(560deg); }
}

/* Экран итога: «Ещё раз» — самая крупная кнопка, перезапуск в одно касание. */
#btnNewGame {
  width: 100%;
  min-height: 56px;
  font-size: 18px;
  min-width: 0;
}

/* Атмосфера «сказка днём»: тёплая виньетка по краям и мягкий свет сверху. Не перехватывает клики. */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
body::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 28%);
}
body::after {
  background: radial-gradient(ellipse at 50% 46%, rgba(255, 246, 220, 0) 55%, rgba(120, 72, 30, 0.14) 100%);
}

.card {
  background: var(--panel);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 24px var(--shadow);
  padding: 22px 20px;
  width: min(92vw, 340px);
  text-align: center;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
}

.card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 100%);
  z-index: 20;
}

.loader[hidden] {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 4px solid rgba(43, 45, 66, 0.12);
  border-top-color: var(--accent-lip);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Заглушка рекламы: есть только в dist-local (mock). В боевой сборке блока нет. */
.ad-stub {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #111113;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.ad-stub__label {
  color: #d8d8de;
  font-size: 14px;
  text-align: center;
  padding: 0 16px;
}

.ad-stub__btn {
  font: inherit;
  font-weight: 800;
  color: var(--text);
  background: var(--accent);
  border: 0;
  border-radius: var(--r-md);
  padding: 12px 26px;
  min-width: 180px;
  cursor: pointer;
}

.ad-stub__btn:disabled {
  background: #2a2a2e;
  color: #9a9aa2;
  cursor: default;
}

/* Общая строка «поле + панель»: в портрете и на десктопе она тянется на всё свободное место. */
.body-row {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 420px) {
  .slot__label {
    font-size: 11px;
  }
  .bar {
    gap: 6px;
  }
}

/* Альбом на телефоне (низкая высота): шапка сверху, поле слева, панель и кнопки справа. */
@media (max-height: 500px) and (orientation: landscape) {
  #app {
    flex-direction: column;
  }
  .body-row {
    flex-direction: row;
    gap: 8px;
  }
  #stage {
    flex: 1 1 0;
    min-width: 0;
    height: auto;
  }
  .panel {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 6px;
    width: 124px;
  }
  .slot {
    flex-direction: row;
    justify-content: space-between;
    gap: 6px;
  }
  .slot__label {
    font-size: 11px;
  }
  .slot__box {
    width: 48px;
    height: 48px;
  }
  .bar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 124px;
  }
  .btn {
    min-height: 40px;
    padding: 6px 6px;
    font-size: 12px;
  }
  /* В альбомной колонке кнопки рекламы на всю колонку: max-content тут вылезает за экран. */
  .btn--ad {
    width: 100%;
    min-width: 0;
    padding-left: 22px;
    padding-right: 6px;
    justify-self: stretch;
  }
  .btn--ad::before {
    left: 7px;
  }
}

/* Reduced motion: кручение и пульсация рекорда — без движения. */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
  .hud__stats b.record {
    animation: none;
  }
  /* Окна — только короткий fade, без перелёта масштаба. */
  .modal:not([hidden]) .card {
    animation: modal-fade 160ms ease-out both;
  }
  /* Слоты — без сдвига, только fade. */
  .slot__cv--in {
    animation: slot-fade 160ms ease-out both;
  }
  /* Открытие: без конфетти и отскока, карточка — только fade. */
  .unlock--show .unlock__card {
    animation: modal-fade 160ms ease-out both;
  }
  .confetti {
    display: none;
  }
}

/* ПК: кнопки наград рядом под панелью, а не по краям половин. */
@media (min-width: 900px) and (min-height: 501px) {
  .bar {
    display: flex;
    justify-content: center;
    gap: 16px;
  }
  /* ПК (polish2): панель справа, поле занимает всю высоту между шапкой и кнопками, а не полосу 450 px. */
  .body-row {
    flex-direction: row;
    gap: 16px;
  }
  #stage {
    flex: 1 1 0;
    min-width: 0;
  }
  .panel {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
    width: 220px;
  }
  .slot {
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }
  /* Кнопки наград на ПК — столбиком справа обычной высоты, а не колонны во всю высоту. */
  .bar {
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    width: 220px;
  }
  .bar .btn {
    flex: 0 0 auto;
  }
}

/* ---- ui2: шапка значками, вторичные кнопки рекламы, подсказка пустого склада ---- */
.chip--icon {
  width: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--text);
}
.chip--icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.hud__tools #btnLang {
  min-width: 44px;
}
/* Реклама — вторичное действие: не спорит с полем и слотами (одна строка, ниже ростом). */
.bar .btn--ad {
  min-height: 40px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: clamp(12px, 3.2vw, 14px);
  background: rgba(255, 246, 230, 0.86);
  box-shadow: 0 2px 0 var(--accent-lip), 0 3px 8px var(--shadow);
}
.bar .btn--ad .badge {
  font-size: 10px;
  margin-top: 1px;
  opacity: 0.85;
}
/* Пустой склад: пунктирное кольцо и «+», чтобы было видно, что сюда можно отложить. */
.slot__box {
  position: relative;
}
.slot__plus {
  display: none;
}
.slot__box--empty {
  background: rgba(255, 246, 230, 0.55);
  box-shadow: inset 0 0 0 2px rgba(92, 99, 120, 0.35);
  outline: 2px dashed rgba(46, 167, 106, 0.55);
  outline-offset: -8px;
}
.slot__box--empty .slot__plus {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent-ink);
  opacity: 0.7;
  pointer-events: none;
}

/* ---- ui3: ПК — одна собранная колонка справа: карточка «рука/склад/дальше» и под ней награды ---- */
@media (min-width: 900px) and (min-height: 501px) {
  .body-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: 1fr auto auto 1fr;
    column-gap: 24px;
    row-gap: 14px;
  }
  #stage { grid-column: 1; grid-row: 1 / span 4; }
  .panel {
    grid-column: 2; grid-row: 2;
    width: auto;
    display: grid;
    grid-template-columns: 1fr 1.35fr 1fr;
    align-items: end;
    gap: 10px;
    padding: 18px 14px 16px;
    background: rgba(255, 246, 230, 0.9);
    border-radius: 22px;
    box-shadow: 0 4px 0 var(--panel-edge), 0 14px 30px var(--shadow);
  }
  .slot { flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; }
  .slot--hand { order: 2; }
  .panel .slot:first-child { order: 1; }
  .panel .slot:last-child { order: 3; }
  .slot__label { font-size: 14px; }
  .slot__box { width: 74px; height: 74px; }
  .slot__box--hand { width: 104px; height: 104px; }
  .bar {
    grid-column: 2; grid-row: 3;
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .bar .btn--ad { width: 100%; min-height: 52px; font-size: 15px; justify-self: stretch; }
  .hud__title { font-size: 26px; }
  .chip { min-height: 48px; }
  .chip--icon { width: 48px; }
}
@media (min-width: 900px) and (min-height: 501px) {
  #app { padding: 16px 24px 20px; }
  #stage { border-radius: 28px; overflow: hidden; box-shadow: 0 4px 0 var(--panel-edge), 0 18px 40px var(--shadow); }
}


/* ---- монеты, магазин, умения (skins) ---- */
.coins {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-weight: 800; color: var(--text);
  background: var(--panel); border: 0; border-radius: 999px;
  padding: 3px 10px 3px 6px; min-height: 28px; cursor: pointer;
  box-shadow: 0 2px 0 var(--panel-edge);
}
.coins__ico {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF2B0, #FFC93C 60%, #D99A12);
  box-shadow: inset 0 0 0 2px #B97F0C;
}
.coins--bump { animation: coin-bump 380ms ease-out; }
@keyframes coin-bump { 40% { transform: scale(1.18); } }
.bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.btn--pow { min-height: 46px; padding: 6px 2px; font-size: clamp(11px, 3vw, 13px); }
.btn--pow .badge { margin-top: 1px; font-size: 11px; }
.btn--pow.btn--armed { outline: 3px solid var(--accent-lip); }
.btn--pow.btn--has { box-shadow: 0 3px 0 var(--accent-lip), 0 6px 12px var(--shadow); }
.card--shop { width: min(92vw, 380px); }
.shop__coins { font-weight: 800; margin: 0 0 8px; }
.shop__rows { display: grid; gap: 8px; margin-bottom: 12px; }
.shop__row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; text-align: left; }
.shop__row b { font-size: 14px; }
.shop__row .btn { min-height: 40px; padding: 6px 10px; font-size: 13px; }
@media (min-width: 900px) and (min-height: 501px) {
  .bar { grid-template-columns: 1fr; }
  .btn--pow { min-height: 52px; font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .coins--bump { animation: none; }
}

/* Телефон, портрет: поле важнее рамок — боковые отступы приложения уменьшены, поле почти во всю ширину (phone, 02.12). */
@media (max-width: 480px) and (orientation: portrait) {
  #app {
    padding: max(6px, env(safe-area-inset-top)) max(3px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(3px, env(safe-area-inset-left));
    gap: 4px;
  }
}

/* Тема площадки: море на весь экран под интерфейсом, без рамки вокруг поля. Канвас у темы прозрачный. */
html[data-theme='pirate'] body { background: #2E8FA0 url('bg/pirate-portrait.webp') center / cover no-repeat; }
html[data-theme='harbor'] body { background: #4F6E80 url('bg/harbor-portrait.webp') center / cover no-repeat; }
@media (min-aspect-ratio: 1/1) {
  html[data-theme='pirate'] body { background-image: url('bg/pirate-wide.webp'); }
  html[data-theme='harbor'] body { background-image: url('bg/harbor-wide.webp'); }
}
@media (min-width: 900px) and (min-height: 501px) {
  html[data-theme='pirate'] #stage, html[data-theme='harbor'] #stage { box-shadow: none; border-radius: 0; overflow: visible; }
}
/* подписи слотов и шапка поверх моря: светлая плашка, чтобы читались */
html[data-theme='pirate'] .slot__label, html[data-theme='harbor'] .slot__label {
  background: var(--panel); color: var(--text); padding: 1px 8px; border-radius: 999px; box-shadow: 0 1px 4px var(--shadow);
}

/* ---- ui4 (02.12): интерфейс поверх моря — плашки, иконки умений, цена с монеткой ---- */
.hud { background: rgba(255, 246, 230, 0.92); border-radius: 18px; padding: 6px 8px 6px 14px;
  box-shadow: 0 3px 0 var(--panel-edge), 0 8px 20px var(--shadow); }
.hud__stats { color: var(--muted); }
.hud__stats .dot { display: none; }
.hud__stats > span:not(.dot):not(.coins) { display: inline-flex; flex-direction: column; align-items: center;
  line-height: 1; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; gap: 2px; }
.hud__stats > span > span { order: 2; }
.hud__stats { gap: 14px; align-items: center; }
.coins { min-height: 40px; padding: 4px 14px 4px 8px; font-size: 18px; background: #FFFDF7;
  box-shadow: 0 3px 0 #D99A12, 0 4px 10px var(--shadow); }
.coins__ico { width: 22px; height: 22px; }
.hud__tools .chip { background: #FFFDF7; }
.ladder { align-self: center; background: rgba(255, 246, 230, 0.88); border-radius: 16px; padding: 6px 10px;
  box-shadow: 0 2px 0 var(--panel-edge), 0 6px 16px var(--shadow); max-width: 100%; }
.ladder__item--lock { background: rgba(92, 99, 120, 0.12); }
.ladder__next { color: var(--text); }
.btn--pow { display: grid; justify-items: center; align-content: center; gap: 2px; padding: 6px 4px 7px;
  background: rgba(255, 253, 247, 0.95); white-space: nowrap; overflow-wrap: normal; }
.pow__ico { width: 22px; height: 22px; color: var(--accent-ink); }
.btn--pow .badge { display: inline-flex; align-items: center; gap: 3px; margin: 0; font-size: 12px; color: var(--text); }
.btn--pow .badge--price::before { content: ''; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF2B0, #FFC93C 60%, #D99A12); box-shadow: inset 0 0 0 1.5px #B97F0C; }
.btn--pow.btn--has .badge { color: var(--accent-ink); }
.btn--pow.btn--armed { background: var(--accent); }
#rescue .card { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(92vw, 360px); }
#rescue .card h2 { margin: 0; }
#rescue .card p { margin: 0 0 4px; color: var(--muted); }
#rescue .btn--ad { width: auto; justify-self: stretch; }
#rescue #btnRescueEnd { background: transparent; box-shadow: none; color: var(--muted); min-height: 40px; }
@media (max-width: 480px) and (orientation: portrait) {
  .hud { padding: 4px 6px 4px 10px; }
  .hud__title { flex: 0 0 auto; }
  .hud__tools { width: 100%; justify-content: flex-start; }
}
@media (min-width: 900px) and (min-height: 501px) {
  .btn--pow { grid-template-columns: 26px 1fr auto; justify-items: start; text-align: left; padding: 8px 14px; gap: 10px; }
  .pow__ico { width: 24px; height: 24px; }
}
@media (max-width: 480px) and (max-height: 780px) and (orientation: portrait) {
  .hud { padding: 2px 4px 2px 8px; border-radius: 14px; }
  .coins { min-height: 34px; font-size: 16px; }
  .ladder { padding: 3px 6px; border-radius: 12px; }
  .ladder__next { display: none; }
  .btn--pow { padding: 4px 2px 5px; gap: 0; }
  .pow__ico { width: 18px; height: 18px; }
}

/* ---- ui5 (02.12): тематическая шкурка интерфейса — дерево и пергамент (пираты), крашеные доски (гавань).
   Приём из казуальных наборов: толстая «губа» снизу, блик сверху, нажатие опускает кнопку. ---- */
html[data-theme] {
  --wood: #8A5A2E; --wood-d: #5E3A1A; --wood-l: #B07A45;
  --parch: #F6E7C4; --parch-d: #D9BE88; --ink: #3B2412; --gold: #FFC93C;
  --grain: repeating-linear-gradient(90deg, rgba(0,0,0,.05) 0 2px, transparent 2px 9px, rgba(255,255,255,.04) 9px 11px, transparent 11px 17px);
}
html[data-theme='harbor'] { --wood: #3F6E8C; --wood-d: #24465C; --wood-l: #6A96B2; --parch: #EEF3F2; --parch-d: #B9CBCF; --ink: #1E3340; }
/* шапка — доска с пергаментными окошками */
html[data-theme] .hud { background: var(--grain), linear-gradient(180deg, var(--wood-l), var(--wood) 55%, var(--wood-d));
  box-shadow: inset 0 0 0 2px var(--wood-d), inset 0 4px 0 rgba(255,255,255,.25), 0 4px 0 var(--wood-d), 0 10px 22px rgba(0,0,0,.35); }
html[data-theme] .hud__title { color: #FFF4DC; text-shadow: 0 2px 0 var(--wood-d), 0 0 1px var(--wood-d); letter-spacing: .02em; }
html[data-theme] .hud__stats { color: #F3DDB3; }
html[data-theme] .hud__stats > span:not(.dot):not(.coins) { background: var(--parch); color: var(--ink); padding: 4px 9px; border-radius: 10px;
  box-shadow: inset 0 -2px 0 var(--parch-d); }
html[data-theme] .coins { background: var(--parch); color: var(--ink); box-shadow: inset 0 -2px 0 var(--parch-d), 0 0 0 2px var(--gold); }
html[data-theme] .hud__tools .chip { background: var(--parch); color: var(--ink); box-shadow: inset 0 -2px 0 var(--parch-d), 0 2px 0 var(--wood-d); }
/* лесенка — свиток */
html[data-theme] .ladder { background: linear-gradient(180deg, #FFF6DE, var(--parch)); 
  box-shadow: inset 0 0 0 2px var(--parch-d), inset 0 0 0 4px rgba(255,255,255,.5), 0 3px 0 var(--parch-d), 0 8px 18px rgba(0,0,0,.28); }
html[data-theme] .ladder__next { color: var(--ink); }
/* кнопки — толстые, с губой и бликом */
html[data-theme] .btn { border: 2px solid var(--wood-d); color: var(--ink);
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,0) 45%), var(--parch);
  box-shadow: 0 4px 0 var(--wood-d), 0 8px 14px rgba(0,0,0,.28); transition: transform .08s, box-shadow .08s; }
html[data-theme] .btn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-d), 0 3px 6px rgba(0,0,0,.25); }
html[data-theme] .btn--primary { color: #fff; text-shadow: 0 2px 0 #1F7A4D;
  background: linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0) 45%), #3FBF7F; border-color: #1F7A4D; box-shadow: 0 4px 0 #1F7A4D, 0 8px 14px rgba(0,0,0,.28); }
html[data-theme] .btn--ad { background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0) 45%), var(--gold); border-color: #B97F0C; box-shadow: 0 4px 0 #B97F0C, 0 8px 14px rgba(0,0,0,.28); }
html[data-theme] .btn--pow { background: var(--grain), linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,0) 45%), var(--parch); }
html[data-theme] .pow__ico { color: var(--wood-d); filter: drop-shadow(0 1px 0 rgba(255,255,255,.7)); }
html[data-theme] .btn--pow.btn--has { box-shadow: 0 4px 0 var(--wood-d), 0 0 0 3px var(--gold), 0 8px 14px rgba(0,0,0,.28); }
html[data-theme] .btn--pow.btn--armed { background: linear-gradient(180deg, rgba(255,255,255,.45), rgba(255,255,255,0) 45%), #6BE6A8; }
/* окна — пергамент в деревянной раме */
html[data-theme] .modal .card { background: linear-gradient(180deg, #FFF6DE, var(--parch)); color: var(--ink);
  border: 6px solid var(--wood); outline: 2px solid var(--wood-d); outline-offset: -2px;
  box-shadow: inset 0 0 0 2px var(--parch-d), 0 6px 0 var(--wood-d), 0 18px 40px rgba(0,0,0,.45); }
html[data-theme] .modal .card h2 { color: var(--wood-d); font-weight: 900; text-shadow: 0 2px 0 rgba(255,255,255,.7); }
html[data-theme] #rescue #btnRescueEnd { border: 0; box-shadow: none; background: transparent; color: var(--wood-d); text-decoration: underline; }
/* лоток «склад / в руке / дальше» — та же доска */
html[data-theme] .slot__box { background: radial-gradient(circle at 50% 40%, #FFF6DE, var(--parch)); 
  box-shadow: inset 0 0 0 2px var(--wood-d), inset 0 -3px 0 var(--parch-d), 0 3px 0 var(--wood-d); }
html[data-theme] .slot__box--hand { box-shadow: inset 0 -3px 0 var(--parch-d), 0 0 0 3px var(--gold), 0 3px 0 var(--wood-d); }
html[data-theme] .slot__label { background: var(--wood); color: #FFF4DC; box-shadow: 0 2px 0 var(--wood-d); }
html[data-theme] .panel { background: var(--grain), linear-gradient(180deg, var(--wood-l), var(--wood) 60%, var(--wood-d)); 
  box-shadow: inset 0 0 0 2px var(--wood-d), inset 0 4px 0 rgba(255,255,255,.25), 0 4px 0 var(--wood-d), 0 10px 22px rgba(0,0,0,.35); }

/* выход из партии в меню паузы — ссылка, не третья кнопка */
.btn--link, html[data-theme] .btn--link { border: 0; box-shadow: none; background: transparent; color: inherit; text-decoration: underline; opacity: .8; }
