:root {
  --bg: #12162a;
  --bg-2: #1c2140;
  --gold: #ffcf4a;
  --gold-2: #f0a91b;
  --text: #f4f6ff;
  --muted: #9aa3c7;
  --danger: #ff5a5f;
  --ok: #58d68d;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% -10%, #2b3160 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 70%);
}

/* ---------- HUD ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  font-variant-numeric: tabular-nums;
}

.hud__score {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 12px rgba(255, 207, 74, 0.25);
}

.hud__coin {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe89a, var(--gold-2));
  color: #7a4b00;
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.hud__lives {
  display: flex;
  gap: 5px;
  font-size: 18px;
  line-height: 1;
}

.hud__lives .heart { filter: drop-shadow(0 2px 4px rgba(255, 90, 95, 0.5)); }
.hud__lives .heart--dead { filter: grayscale(1); opacity: 0.35; }

.hud__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.hud__best span { color: var(--gold); }

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.1s ease;
}

.icon-btn:active { transform: scale(0.94); }
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

.hud__user {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 207, 74, 0.6);
  flex: 0 0 auto;
}

.hud__user img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Игровое поле ---------- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 10px calc(10px + var(--safe-bottom));
  display: flex;
  touch-action: none;
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #101430 0%, #0b0e1f 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 20px 50px rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: none;
}

/* ---------- Оверлеи ---------- */

.overlay {
  position: absolute;
  inset: 10px 10px calc(10px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: var(--radius);
  background: rgba(8, 10, 24, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Плотный фон для экранов, которые показываются поверх других (обучение) */
.overlay--dark { background: rgba(8, 10, 24, 0.9); }

.panel {
  width: min(100%, 340px);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pop {
  from { transform: translateY(10px) scale(0.96); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.logo {
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(180deg, #fff3c4 0%, var(--gold) 45%, var(--gold-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 207, 74, 0.35));
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.panel__title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

.panel__score {
  font-size: clamp(44px, 14vw, 64px);
  font-weight: 900;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 6px 28px rgba(255, 207, 74, 0.3);
  font-variant-numeric: tabular-nums;
}

.panel__meta { color: var(--muted); font-size: 14px; }
.panel__meta b { color: var(--text); }
.panel__hint { min-height: 18px; font-size: 13px; color: var(--ok); }
.panel__hint--error { color: var(--danger); }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 15px 26px;
  font-size: 17px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  max-width: 280px;
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: translateY(1px) scale(0.99); }

.btn--primary {
  color: #3a2500;
  background: linear-gradient(180deg, #ffe08a 0%, var(--gold) 55%, var(--gold-2) 100%);
  box-shadow: 0 10px 24px rgba(255, 207, 74, 0.28), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.btn--primary:hover { filter: brightness(1.05); }

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.btn--ghost:hover { background: rgba(255, 255, 255, 0.13); }

/* ---------- Ссылки-кнопки и обучение ---------- */

.panel__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin-top: 2px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 6px 2px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover { color: var(--text); }
.link-btn:disabled { opacity: 0.5; cursor: default; }

.steps {
  margin: 0;
  padding-left: 20px;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: grid;
  gap: 8px;
}

.steps b { color: var(--gold); }

/* ---------- Тост ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(26px + var(--safe-bottom));
  transform: translate(-50%, 12px);
  background: rgba(20, 25, 50, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  max-width: 90%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.toast--show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .stage { max-width: 560px; width: 100%; margin: 0 auto; align-self: center; }
}

/* Отладочный режим (?autostart=1): без анимаций, чтобы скриншоты были стабильны */
.no-anim *, .no-anim *::before, .no-anim *::after {
  transition: none !important;
  animation: none !important;
}
