:root {
  --ink: #1d2a6b;
  --ink-soft: rgba(29, 42, 107, .55);
  --paper: #f7f2e4;
  --paper-2: #fbf7ea;
  --rule: rgba(92, 136, 196, .26);
  --margin: rgba(214, 92, 92, .38);
  --gold: #f0bd23;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Без зуму й затримки подвійного тапу (UX-аудит 10-28, Botcraft telegram-ux): усе, що натискають, — manipulation. Це лише
   страховка там, де viewport (user-scalable=no) не вимкнув їх сам. Прокрутки manipulation не забирає: тап із рухом пальця в
   аркуші, що гортається, WebView однаково віддасть прокрутці (L3 10-28) — CSS цього не лікує, перевіряти на живому Android.
   Жести мають своє none, і їхній селектор вужчий: шахта #c, кнопки героя (#pad, #pad-dig, #ctrl), важіль комбо. */
button, a[href], label, summary, select, input, textarea, [role="button"], [data-tip], .wheel-box, .goal, .cr-row { touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  background: #e6dfcc;
  color: var(--ink);
  /* шрифт — Pangolin (власник 2026-10-19 обрав варіант Б із чотирьох: «давай Б»; до того — Caveat). Розміри в CSS
     підібрані під Caveat, а Pangolin ширший (рядок «Покращити шахту»: 7.61 проти 6.44 кегля), тож font-size-adjust
     0.474 тримає ту саму ширину рядка — нічого не переповнюється, а малі літери вищі й читаються легше. */
  font-family: 'Pangolin', 'Segoe Print', 'Comic Sans MS', cursive;
  font-size-adjust: 0.474;
  overscroll-behavior: none;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(29, 42, 107, .12), 0 12px 40px rgba(40, 30, 10, .18);
}

/* ---------- верхня панель: всі дії ---------- */
#panel {
  position: relative;
  z-index: 2;
  padding: 6px 12px 10px 22px;
  background:
    linear-gradient(to right, transparent 13px, var(--margin) 13px, var(--margin) 14.5px, transparent 14.5px),
    repeating-linear-gradient(to bottom, transparent 0 23px, var(--rule) 23px 24px),
    var(--paper);
  border-bottom: 2.5px solid var(--ink);
  border-radius: 0 0 6px 10px / 0 0 3px 5px;
}

.title-row { display: flex; align-items: baseline; gap: 8px; }
h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .5px;
  text-decoration: underline wavy rgba(29, 42, 107, .45);
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
}
.tag { font-size: 16px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  font-size: 16px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 2px;
  touch-action: manipulation;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 6px 0 8px;
}
.stat { display: flex; align-items: center; gap: 4px; min-width: 0; }
.stat img { width: 28px; height: 28px; flex: none; }
.stat b { display: block; font-size: 22px; line-height: .95; white-space: nowrap; }
.stat small { display: block; font-size: 14px; line-height: 1; color: var(--ink-soft); }

.btn {
  font: inherit;
  color: var(--ink);
  background: var(--paper-2);
  border: 2px solid var(--ink);
  border-radius: 255px 14px 225px 12px / 12px 225px 14px 255px;
  box-shadow: 2px 3px 0 rgba(29, 42, 107, .28);
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1.05;
  transition: transform .06s, opacity .15s;   /* box-shadow не анімуємо: це перемальовування, не композитинг */
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translate(1px, 2px); box-shadow: 1px 1px 0 rgba(29, 42, 107, .28); }
.btn:disabled { opacity: .42; cursor: default; }

.btn.wide {
  width: 100%;
  font-size: 24px;
  font-weight: 700;
  padding: 3px 10px 5px;
  background:
    repeating-linear-gradient(-35deg, rgba(240, 189, 35, .0) 0 5px, rgba(240, 189, 35, .28) 5px 6.5px),
    #fff4cf;
}
.btn.wide span { color: #a8740a; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 9px; margin-top: 8px; }
.grid .btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 19px;
  min-height: 48px;
  text-align: left;
}
.grid .lbl { font-weight: 700; }
.grid .btn.span2 { grid-column: span 2; min-height: 44px; }
.cost { display: inline-flex; align-items: center; gap: 3px; font-size: 18px; color: #8a5f06; }
.cost img { width: 17px; height: 17px; }

/* ---------- шахта ---------- */
#view { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#c { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#c:active { cursor: grabbing; }

#note {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%) rotate(-1.2deg);
  background: #fff7d6;
  border: 2px solid var(--ink);
  border-radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
  padding: 3px 12px 4px;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 2px 3px 0 rgba(29, 42, 107, .25);
  pointer-events: none;
}
#b-home { position: absolute; right: 10px; bottom: 76px; font-size: 20px; font-weight: 700; }

/* ---------- лоадер: папір у лінійку поверх гри до першого стабільного кадру (зникає лише opacity) ---------- */
#boot {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-bottom: 12vh;
  background:
    linear-gradient(to right, transparent 13px, var(--margin) 13px, var(--margin) 14.5px, transparent 14.5px),
    repeating-linear-gradient(to bottom, transparent 0 23px, var(--rule) 23px 24px),
    var(--paper);
  transition: opacity .4s ease-out;
  touch-action: none;
}
#boot.off, .boot-off #boot { opacity: 0; pointer-events: none; }
.boot-helmet { width: 124px; height: auto; overflow: visible; }
.boot-glow { opacity: .35; animation: boot-glow 1.6s ease-in-out infinite alternate; }
.boot-title {
  /* «Subterra Empire» (назва з 10-27) — 377 px при 64px, удвічі довша за «Шахтери»: на 360 рвалась на два рядки під
     лівий край. Кегль від ширини екрана, рядок один; 46px — для WebView без min() */
  font-size: 46px;
  font-size: min(64px, 14.5vw);
  white-space: nowrap;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .5px;
  text-decoration: underline wavy rgba(29, 42, 107, .45);
  text-underline-offset: 8px;
  text-decoration-thickness: 2px;
  transform: rotate(-2deg);
}
.boot-sub { margin-top: 10px; font-size: 22px; color: var(--ink-soft); }
.boot-again { margin-top: 14px; font-size: 22px; padding: 6px 18px; }   /* «Перезапустити» (index.html: запобіжник) */
.boot-sub .d { animation: boot-dot 1.2s infinite; opacity: .15; }
.boot-sub .d:nth-child(2) { animation-delay: .2s; }
.boot-sub .d:nth-child(3) { animation-delay: .4s; }
@keyframes boot-dot { 0%, 20% { opacity: .15; } 50% { opacity: 1; } 100% { opacity: .15; } }
@keyframes boot-glow { from { opacity: .15; } to { opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  #boot { transition: none; }
  .boot-glow, .boot-sub .d { animation: none; opacity: .6; }
}

@media (max-height: 640px) {
  h1 { font-size: 28px; }
  .grid .btn { min-height: 40px; font-size: 17px; }
  .btn.wide { font-size: 21px; }
}

/* ---------- кнопки героя (hero.js): ледь помітні, «ручкою», ліворуч унизу ---------- */
#pad { position: absolute; left: 10px; bottom: 14px; z-index: 3; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none; }
#pad .pad-row, #pad .pad-lad { display: flex; gap: 10px; }
#pad .pad-lad { flex-direction: column; gap: 8px; opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
#pad.ladder .pad-lad { opacity: 1; visibility: visible; }
#pad .pb {
  pointer-events: auto; width: 46px; height: 46px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); background: rgba(251, 247, 234, .55);
  border: 2px solid var(--ink); border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%;
  box-shadow: 1px 2px 0 rgba(29, 42, 107, .2);
  opacity: .42; transition: opacity .15s, transform .06s;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#pad.manual .pb { opacity: .62; }
#pad .pb.on { opacity: .95; transform: scale(.93); }
#pad .pb.off { visibility: hidden; }
#pad .pb svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* кнопка «копати» (hero.js): праворуч унизу, з'являється, коли поруч є що копати */
#pad-dig { position: absolute; right: 10px; bottom: 14px; z-index: 3; opacity: 0; visibility: hidden; transform: scale(.85); transition: opacity .2s, visibility .2s, transform .2s; }
#pad-dig.show { opacity: 1; visibility: visible; transform: none; }
#pad-dig .pb {
  pointer-events: auto; width: 54px; height: 54px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); background: rgba(255, 244, 207, .6);
  border: 2px solid var(--ink); border-radius: 48% 52% 50% 46% / 52% 46% 54% 48%;
  box-shadow: 1px 2px 0 rgba(29, 42, 107, .2);
  opacity: .5; transition: opacity .15s, transform .06s;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#pad-dig.manual .pb { opacity: .7; }
#pad-dig .pb.on { opacity: .95; transform: scale(.93); }
#pad-dig .pb svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }

