* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  /* pan-y (а не none), чтобы вложенные списки могли прокручиваться на тач-экранах.
     Прокрутку самой страницы всё равно блокирует обработчик touchmove в game.js. */
  touch-action: pan-y;
  overscroll-behavior: none;
  background: #7fd8c9;
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Иконка монеты ----------
   Рисуется средствами CSS, чтобы не зависеть от эмодзи 🪙 (U+1FA99),
   который не отображается частью системных шрифтов ("сломанный шрифт"). */
.coin-ico {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  vertical-align: -0.16em;
  flex: none;
  position: relative;
  background: radial-gradient(circle at 35% 30%, #ffe884 0%, #f7cb46 45%, #e2a521 100%);
  box-shadow:
    inset 0 0 0 0.1em rgba(255, 255, 255, 0.5),
    inset 0 -0.14em 0.16em rgba(150, 92, 0, 0.4),
    0 1px 1px rgba(0, 0, 0, 0.18);
}

.coin-ico::after {
  content: '';
  position: absolute;
  inset: 26%;
  border-radius: 50%;
  border: 0.09em solid rgba(150, 92, 0, 0.35);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Мягкая виньетка поверх 3D-сцены */
#ui::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(20, 30, 60, 0.16) 100%);
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
}

.hud-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: rgba(255, 255, 255, 0.9);
  color: #444;
  font-weight: 800;
  font-size: clamp(13px, 2.2vh, 18px);
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

#progressWrap {
  flex: 1;
  height: 14px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.12);
}

#progressBar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #ff5c8a;
  transition: width 0.12s linear;
}

.hud-buttons {
  position: absolute;
  top: calc(56px + env(safe-area-inset-top, 0px));
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.icon-btn {
  pointer-events: auto;
  width: clamp(40px, 6.5vh, 52px);
  height: clamp(40px, 6.5vh, 52px);
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: clamp(18px, 3vh, 24px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active { transform: scale(0.92); }

#hint {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-weight: 700;
  font-size: clamp(14px, 2.4vh, 20px);
  padding: 10px 22px;
  border-radius: 999px;
  white-space: nowrap;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.07); }
}

/* ---------- Оверлеи ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 40, 0.55);
  pointer-events: auto;
  z-index: 10;
}

#loadingScreen {
  background: linear-gradient(160deg, #6ecfbf, #4aa8d8);
  z-index: 50;
}

.loading-inner {
  text-align: center;
  color: #fff;
}

.game-logo {
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  margin-bottom: 26px;
}

.game-logo span { color: #ff5c8a; }

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border: 5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

#loadingText {
  font-size: clamp(14px, 2.4vh, 18px);
  font-weight: 600;
}

/* ---------- Панели ---------- */
.panel {
  background: #fff;
  border-radius: 22px;
  padding: clamp(18px, 4vh, 32px) clamp(20px, 5vw, 40px);
  width: min(86vw, 380px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vh, 16px);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  color: #444;
  font-size: clamp(14px, 2.2vh, 17px);
}

.panel-title {
  font-size: clamp(20px, 3.6vh, 28px);
  font-weight: 900;
}

.win-title { color: #2fbf71; }
.fail-title { color: #e84a5f; }

.stars {
  font-size: clamp(26px, 5vh, 40px);
  color: #ffc93c;
  letter-spacing: 6px;
}

.fail-emoji { font-size: clamp(30px, 6vh, 48px); }

.reward-row b { color: #ff5c8a; font-size: 1.25em; }

/* ---------- Кнопки ---------- */
.btn {
  pointer-events: auto;
  border: none;
  border-radius: 999px;
  width: 100%;
  padding: clamp(12px, 2vh, 16px) 18px;
  font-size: clamp(15px, 2.4vh, 19px);
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active { transform: scale(0.96); }

.btn-main {
  background: #2fbf71;
  color: #fff;
  box-shadow: 0 4px 0 #1f9457;
}

.btn-ad {
  background: #ffb400;
  color: #6b4b00;
  box-shadow: 0 4px 0 #cc8f00;
}

.btn-secondary {
  background: #e9ecf2;
  color: #555;
  box-shadow: 0 4px 0 #c5cbd8;
}

.ad-ico {
  background: #fff;
  color: #ffb400;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex: none;
}

/* Конкретный размер награды на кнопке ×3 — чтобы было очевидно, что именно получит игрок */
.x3-reward {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 900;
  flex: none;
}

.x3-reward b { color: #6b4b00; }

/* ---------- Таблица лидеров ---------- */
.panel-lb { width: min(92vw, 420px); }

.lb-list {
  width: 100%;
  overflow-y: auto;
  max-height: 46vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f2f4f8;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: clamp(13px, 2vh, 16px);
  text-align: left;
}

.lb-row.me {
  background: #ffe3ec;
  border: 2px solid #ff5c8a;
}

.lb-rank {
  width: 34px;
  flex: none;
  font-weight: 900;
  color: #888;
}

.lb-rank.top1 { color: #f5a623; }
.lb-rank.top2 { color: #9aa5b1; }
.lb-rank.top3 { color: #c47f3d; }

.lb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  background: #d6dbe6;
  object-fit: cover;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score { font-weight: 900; color: #444; }

.lb-auth {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.lb-loading, .lb-empty {
  padding: 20px 0;
  color: #999;
}

/* ---------- Магазин скинов ---------- */
.badge-coin { color: #b8860b; }

.shop-coins {
  font-weight: 900;
  color: #b8860b;
  font-size: clamp(15px, 2.4vh, 19px);
}

.shop-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  overflow-y: auto;
  max-height: 46vh;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.skin-card {
  pointer-events: auto;
  border: 2px solid transparent;
  background: #f2f4f8;
  border-radius: 14px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(12px, 1.9vh, 15px);
  font-weight: 700;
  color: #555;
}

.skin-card:active { transform: scale(0.96); }

.skin-card.selected {
  border-color: #2fbf71;
  background: #e8f8ee;
}

.skin-swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.15), 0 2px 5px rgba(0, 0, 0, 0.15);
}

.skin-price { font-size: 0.9em; color: #888; }
.skin-card.selected .skin-price { color: #2fbf71; }

@media (max-height: 450px) {
  .shop-grid { max-height: 34vh; }
}

/* ---------- Тост ---------- */
#toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  background: rgba(20, 24, 40, 0.85);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: clamp(13px, 2.2vh, 16px);
  z-index: 60;
  white-space: nowrap;
  animation: toastIn 0.25s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Ландшафтная ориентация на низких экранах ---------- */
@media (max-height: 450px) {
  .panel { gap: 8px; padding: 14px 22px; }
  .stars { font-size: 22px; }
  .fail-emoji { font-size: 26px; }
  .lb-list { max-height: 36vh; }
}
