:root {
  --nav: #123a86;
  --panel-top: #4a6fd6;
  --panel-bot: #2f4db0;
  --accent: #2f8dff;
  --accent2: #7b5cff;
  --gold: #ffd23d;
  --green: #38cf6c;
  --orange: #ff9f2e;
  --pink: #ff6bcb;
  --txt: #f0f6ff;
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}

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

html, body {
  height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  font-family: 'Baloo 2', system-ui, -apple-system, sans-serif;
  color: var(--txt);
  background-color: #2270ef;
  background-image:
    radial-gradient(circle at 50% 6%, #7cbcff 0%, rgba(124,188,255,0) 46%),
    linear-gradient(180deg, #2f8dff 0%, #2270ef 50%, #1550c8 100%);
  background-attachment: fixed;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#bg {
  position: fixed;
  top: calc(-1 * var(--safe-top));
  bottom: calc(-1 * var(--safe-bottom));
  left: calc(-1 * var(--safe-left));
  right: calc(-1 * var(--safe-right));
  background-color: #1550c8;
  background-image:
    radial-gradient(circle at 50% 6%, #7cbcff 0%, rgba(124,188,255,0) 46%),
    linear-gradient(180deg, #2f8dff 0%, #2270ef 45%, #1550c8 100%);
  z-index: -2;
}
#vignette {
  position: fixed;
  top: calc(-1 * var(--safe-top));
  bottom: calc(-1 * var(--safe-bottom));
  left: 0; right: 0;
  background: radial-gradient(120% 85% at 50% 42%, transparent 58%, rgba(8,28,88,0.28) 100%);
  z-index: -1;
  pointer-events: none;
}

/* ---------- Основной каркас ---------- */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding:
    var(--safe-top)
    var(--safe-right)
    0
    var(--safe-left);
}

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 2px;
  flex-shrink: 0;
}
.stat {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, rgba(28,42,86,0.85), rgba(10,18,44,0.85));
  border: 1px solid rgba(140, 175, 255, 0.35);
  border-radius: 999px;
  padding: 5px 14px 5px 8px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.18);
}
.stat span { line-height: 1; }
#coinStat { margin-left: auto; }
.icon { width: 26px; height: 26px; object-fit: contain;  }
.mini { width: 18px; height: 18px; vertical-align: -3px; object-fit: contain;  }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(140, 175, 255, 0.35);
  background: linear-gradient(180deg, rgba(30,44,90,0.9), rgba(12,20,48,0.9));
  color: var(--txt);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 6px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform .12s cubic-bezier(.2,1.6,.4,1), box-shadow .12s;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
.icon-btn img { width: 24px; height: 24px; object-fit: contain; display: block; margin: 0 auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

#scoreWrap { text-align: center; padding: 0 0 2px; flex-shrink: 0; }
#scoreVal {
  display: inline-block;
  font-size: clamp(40px, 13vw, 64px);
  font-weight: 900;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 2px rgba(30,60,140,0.35);
  text-shadow: 0 4px 0 rgba(0,0,0,0.28), 0 0 26px rgba(120,180,255,0.55);
  will-change: transform;
}
#scoreVal.bump { animation: scorePop .42s cubic-bezier(.2,1.7,.4,1); }
@keyframes scorePop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4) translateY(-2px);
         color: #fff2b0;
         text-shadow: 0 4px 0 rgba(0,0,0,.28), 0 0 40px rgba(255,222,90,0.95); }
  60%  { transform: scale(0.94); }
  100% { transform: scale(1); }
}

#game {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  touch-action: none;
}

/* ---------- Оверлеи и панели ---------- */
.overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  background: rgba(4, 8, 22, 0.72);
  backdrop-filter: blur(6px);
  z-index: 10;
  overflow-y: auto;
  animation: fadeIn .25s ease;
}
.overlay.show { display: flex; }
.panel { margin: auto; }

/* Домашний экран — яркий синий, без тёмного затемнения */
#menu {
  background: linear-gradient(180deg, rgba(47,133,255,0.86), rgba(23,86,205,0.92));
  backdrop-filter: blur(3px);
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.panel {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bot));
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 28px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(6,22,78,0.6), inset 0 2px 0 rgba(255,255,255,0.35), inset 0 -8px 24px rgba(10,26,80,0.35);
  animation: pop .42s cubic-bezier(.2,1.5,.35,1);
}
@keyframes pop {
  0% { transform: translateY(30px) scale(.8); opacity: 0; }
  60% { transform: translateY(0) scale(1.03); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.menu-panel { padding-top: 12px; }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

/* ---------- Логотип BLOCK BLAST (CSS) ---------- */
.game-logo { position: relative; margin: -6px 0 6px; animation: floaty 3.5s ease-in-out infinite; }
.logo-crown {
  position: absolute; top: -34px; left: 50%;
  width: 62px; height: 62px;
  transform: translateX(-88px) rotate(-16deg);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
  z-index: 3;
}
.logo-row {
  display: flex; justify-content: center; gap: 2px;
  font-weight: 800; line-height: 0.86;
  paint-order: stroke fill;
  -webkit-text-stroke: 7px #ffffff;
}
.logo-block { font-size: clamp(42px, 16vw, 62px); }
.logo-block span { color: var(--c); text-shadow: 0 7px 0 rgba(0,0,0,0.18), 0 9px 12px rgba(0,0,0,0.28); }
.logo-block span:nth-child(odd) { transform: rotate(-4deg); }
.logo-block span:nth-child(even) { transform: rotate(4deg); }
.logo-blast {
  font-size: clamp(48px, 18vw, 70px);
  margin-top: 2px;
  -webkit-text-stroke: 8px #ffffff;
}
.logo-blast span {
  background: linear-gradient(180deg, #ffffff 0%, #cdeaff 28%, #56a6ff 62%, #2f79e6 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #2f79e6;
  text-shadow: 0 6px 0 #17539c, 0 8px 0 #123f78, 0 11px 14px rgba(0,0,0,0.4);
}
.logo-sub {
  font-size: 13px; font-weight: 800; letter-spacing: 3px;
  color: #cfe6ff; margin-top: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.35);
}

.menu-stats {
  display: flex; justify-content: center; gap: 18px;
  font-size: 15px; margin-bottom: 18px; opacity: 0.95;
}
.menu-stats b { color: var(--gold); }

/* ---------- Кнопки (объёмные, «игровые») ---------- */
.btn {
  --btnShadow: rgba(0,0,0,0.3);
  --btnTop: #5aa0ff;
  --btnBot: #2f6fe0;
  position: relative;
  display: block;
  width: 100%;
  border: none;
  border-radius: 22px;
  padding: 16px 18px;
  margin: 10px 0;
  font-family: inherit;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.3px;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, var(--btnTop), var(--btnBot));
  text-shadow: 0 2px 3px rgba(0,0,0,0.25);
  box-shadow: 0 7px 0 var(--btnShadow), 0 12px 22px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.35);
  transition: transform .12s cubic-bezier(.2,1.6,.4,1), box-shadow .12s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
/* верхний глянец */
.btn::before {
  content: '';
  position: absolute; left: 8%; right: 8%; top: 5px; height: 34%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0));
  pointer-events: none; z-index: -1;
}
/* пробегающий блик */
.btn::after {
  content: '';
  position: absolute; top: -20%; left: -70%;
  width: 45%; height: 140%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg);
  animation: btnShine 4s ease-in-out infinite;
  pointer-events: none; z-index: -1;
}
@keyframes btnShine {
  0%, 60% { left: -70%; }
  85%, 100% { left: 130%; }
}
.btn > * { position: relative; z-index: 2; }
.btn:active {
  transform: translateY(6px) scale(0.99);
  box-shadow: 0 1px 0 var(--btnShadow), 0 4px 10px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.35);
}
.btn.big { font-size: 25px; padding: 19px; border-radius: 24px; }

.btn-primary { --btnTop: #6fb2ff; --btnBot: #2f6fe0; --btnShadow: #1c4aa0; }
.btn-secondary { --btnTop: #5aea8d; --btnBot: #22a555; --btnShadow: #157a3a; }
.btn-revive {
  --btnTop: #ffdd55; --btnBot: #f0a012; --btnShadow: #b5720a;
  color: #4a2f00; text-shadow: 0 1px 0 rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-revive small { display: flex; align-items: center; gap: 3px; font-size: 15px; opacity: .9; }

.btn-ghost {
  --btnShadow: rgba(0,0,0,0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 16px;
  padding: 13px;
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.28), 0 6px 14px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.btn-ghost::before { display: none; }
.btn-ghost::after { display: none; }
.btn-ghost:active { transform: translateY(4px) scale(0.99); box-shadow: 0 1px 0 rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-ghost.danger { color: #ff9aa4; }

/* эффект ripple по нажатию */
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleAnim .55s ease-out forwards;
  pointer-events: none; z-index: 3;
}
@keyframes rippleAnim { to { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

/* ---------- Капсульные кнопки с иконкой ---------- */
.btn-play, .btn-continue {
  border-radius: 999px;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 22px;
  font-size: 22px;
}
.btn-play { --btnTop: #62e28d; --btnBot: #24b055; --btnShadow: #17853c; }
.btn-continue { --btnTop: #6fb2ff; --btnBot: #2f6fe0; --btnShadow: #1c4aa0; }
.btn-ic {
  flex: 0 0 auto;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.28);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.45), inset 0 -3px 6px rgba(0,0,0,0.18);
  font-size: 19px;
}
.btn-ic .tri {
  width: 0; height: 0;
  border-left: 15px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  margin-left: 4px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.25));
}
.btn-tx { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.05; }
.btn-tx small { font-size: 12px; font-weight: 700; opacity: 0.85; letter-spacing: .5px; margin-top: 1px; }

/* ---------- Плитки-иконки меню ---------- */
.menu-icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.icon-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 11px 4px 8px;
  border: none; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.07));
  box-shadow: 0 4px 0 rgba(10,26,80,0.4), inset 0 1px 0 rgba(255,255,255,0.28);
  color: #fff; font-family: inherit;
  transition: transform .12s cubic-bezier(.2,1.6,.4,1), box-shadow .12s;
}
.icon-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(10,26,80,0.4), inset 0 1px 0 rgba(255,255,255,0.28); }
.icon-tile .ti { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.icon-tile .tl { font-size: 11px; font-weight: 800; opacity: .95; }
.icon-tile .badge { position: absolute; top: 4px; right: 6px; }
.lang-tile .lang-code {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  font-size: 13px; font-weight: 900; letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 2px 3px rgba(0,0,0,.25);
}

/* ---------- Шапка модалки и крестик ---------- */
.modal-head { display: flex; align-items: center; justify-content: center; position: relative; margin-bottom: 14px; }
.modal-head h2 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.modal-x {
  position: absolute; right: -2px; top: -4px;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(180deg, #ff7a85, #e0505c);
  color: #fff; font-size: 15px; font-weight: 800; font-family: inherit;
  box-shadow: 0 3px 0 #b83b46, inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .12s, box-shadow .12s;
}
.modal-x:active { transform: translateY(2px); box-shadow: 0 1px 0 #b83b46; }

/* ---------- Строки настроек и переключатель ---------- */
.opt-row {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.12);
  border-radius: 16px; padding: 9px 14px; margin: 9px 0;
  font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.opt-ic {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.1));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.opt-ic img { width: 24px; height: 24px; object-fit: contain; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.opt-label { flex: 1; text-align: left; }
.switch {
  -webkit-appearance: none; appearance: none;
  width: 56px; height: 32px; border-radius: 999px; cursor: pointer;
  background: rgba(0,0,0,0.28); position: relative; flex: 0 0 auto;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  transition: background .2s;
}
.switch:checked { background: var(--green); }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: transform .22s cubic-bezier(.3,1.6,.5,1);
}
.switch:checked::after { transform: translateX(24px); }

.volume-row { cursor: default; padding-left: 18px; }
.volume-row .opt-label { flex: 1; font-size: 15px; font-weight: 700; opacity: 0.92; }
.vol-slider {
  -webkit-appearance: none; appearance: none;
  flex: 0 1 130px; width: 130px; height: 8px; border-radius: 999px;
  background: rgba(0,0,0,0.28); outline: none; cursor: pointer;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
}
.vol-slider::-moz-range-thumb {
  width: 22px; height: 22px; border: none; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
}
.volume-row.disabled { opacity: 0.45; pointer-events: none; }

.lang-row { cursor: default; flex-wrap: wrap; gap: 8px; padding: 9px 10px; overflow: hidden; }
.lang-row .opt-label { flex: 1 1 72px; min-width: 0; font-size: 15px; }
.lang-btns { display: flex; gap: 6px; flex: 1 1 140px; min-width: 0; justify-content: flex-end; flex-wrap: wrap; }
.lang-btn {
  border: none; border-radius: 12px; padding: 7px 10px;
  font-family: inherit; font-size: 12px; font-weight: 800;
  background: rgba(0,0,0,0.22); color: rgba(255,255,255,0.85);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
  cursor: pointer; white-space: nowrap; max-width: 100%;
}
.lang-btn.active {
  background: linear-gradient(180deg, #ffe566, #ffc734);
  color: #5a3200;
  box-shadow: 0 2px 0 #c99200, inset 0 1px 0 rgba(255,255,255,0.45);
}

.menu-row { display: flex; gap: 10px; margin-top: 4px; }
.menu-row .btn { margin: 6px 0; }

.pulse { animation: pulseGlow 1.1s ease-in-out infinite; }
@keyframes pulseGlow {
  0%,100% { box-shadow: 0 0 0 rgba(255,217,61,0); }
  50% { box-shadow: 0 0 18px rgba(255,217,61,0.7); }
}

/* ---------- Уровень / XP ---------- */
.stat.level-pill { padding: 4px 12px 4px 6px; font-size: 15px; }
.stat.level-pill b { color: var(--gold); margin-left: 3px; }

/* Верхние показатели в мультяшном стиле: иконка + крупная жёлтая «пузырчатая» цифра */
#topbar .stat {
  gap: 5px;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(20px, 6.5vw, 26px);
  letter-spacing: .5px;
  color: #ffd93d;
  -webkit-text-stroke: 3.5px #5a3200;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(60,30,0,0.4);
}
#topbar .icon {
  width: 34px; height: 34px;
  -webkit-text-stroke: 0;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.35));
}
/* Шестерёнка настроек — чистая иконка без тёмного круга */
#btnSettings {
  width: 42px; height: 42px;
  background: none;
  border: none;
  box-shadow: none;
}
#btnSettings img {
  width: 34px; height: 34px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.4));
}
#highStat { }

#xpRow {
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px 2px;
  font-size: 11px; font-weight: 700; opacity: 0.9;
  flex-shrink: 0;
}
#levelBadge {
  display: flex; align-items: center; gap: 2px;
  background: rgba(4, 14, 44, 0.55);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px; padding: 3px 11px 3px 6px;
  font-size: 12px; color: #fff; white-space: nowrap;
}
#levelBadge b { color: var(--gold); margin-left: 2px; }
.lvl-star { width: 15px; height: 15px; object-fit: contain; }
#xpText { min-width: 50px; text-align: right; color: rgba(255,255,255,0.9); }
#xpBar {
  flex: 1; height: 9px; border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow: hidden; border: 1px solid rgba(255,255,255,0.1);
}
#xpFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--pink));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2,1,.3,1);
  box-shadow: 0 0 10px rgba(255,180,80,0.6);
}

/* ---------- Стрик-метр ---------- */
#streakMeter {
  position: absolute;
  right: 12px;
  top: calc(72px + env(safe-area-inset-top, 0px));
  display: none;
  flex-direction: column; align-items: center;
  z-index: 5; pointer-events: none;
}
#streakMeter.show { display: flex; animation: streakPop .3s cubic-bezier(.2,1.5,.4,1); }
#streakMeter img {
  width: calc(42px * var(--cscale, 1));
  height: calc(42px * var(--cscale, 1));
  filter: drop-shadow(0 0 calc(8px * var(--cscale, 1)) rgba(255,70,140,0.9));
  animation: heartBeat .6s ease-in-out infinite;
  transition: width .25s cubic-bezier(.2,1.6,.4,1), height .25s cubic-bezier(.2,1.6,.4,1);
}
#streakMeter span {
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 900; font-size: 22px; color: #fff;
  -webkit-text-stroke: 3px #a01050; paint-order: stroke fill;
  text-shadow: 0 2px 6px rgba(0,0,0,.5); margin-top: -8px;
}
@keyframes heartBeat { 0%,100%{transform:scale(1)} 25%{transform:scale(1.18)} 40%{transform:scale(1)} 60%{transform:scale(1.1)} }
@keyframes streakPop { from{transform:scale(0.4);opacity:0} to{transform:scale(1);opacity:1} }
@keyframes flameWobble { from{transform:rotate(-5deg) scale(1)} to{transform:rotate(5deg) scale(1.1)} }

/* ---------- Обучение ---------- */
#tutorial { position: absolute; inset: 0; z-index: 8; pointer-events: none; display: none; }
#tutorial.show { display: block; }
#tutPill {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,230,140,0.95));
  color: #4a2800;
  font-weight: 900; font-size: 15px;
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  white-space: nowrap;
  animation: pop .28s cubic-bezier(.2,1.6,.4,1);
}
#tutHand {
  position: absolute;
  width: 48px; height: 48px; object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.5));
  animation: handMove 1.2s ease-in-out infinite;
  display: none;
}
@keyframes handMove { 0%,100%{ transform: translate(-50%, 0) } 50%{ transform: translate(-50%, -14px) } }

/* ---------- Миссии ---------- */
.rank-line { font-size: 15px; font-weight: 800; color: var(--gold); margin: 4px 0 8px; }
.badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
  background: #ff4d5e; color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 800; padding: 0 5px; vertical-align: 1px;
}
.badge:empty { display: none; }
.mission-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.mission-item {
  background: rgba(255,255,255,0.06);
  border-radius: 14px; padding: 12px; text-align: left;
  display: flex; align-items: center; gap: 12px;
}
.mission-item.done { background: rgba(60,220,116,0.15); border: 1px solid rgba(60,220,116,0.4); }
.mission-item .em { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; }
.mission-item .em img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.reward .ok, .status .ok { color: var(--green); font-weight: 900; font-size: 18px; }
.mission-item .body { flex: 1; }
.mission-item .body .t { font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.m-progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; }
.m-progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; }
.mission-item .reward { font-size: 13px; font-weight: 800; color: var(--gold); white-space: nowrap; display: flex; align-items: center; gap: 3px; }
.mission-item .reward img { width: 16px; height: 16px;  }
.mission-item.done .reward { color: var(--green); }

/* ---------- Баннер уровня ---------- */
#levelupBanner {
  position: fixed; left: 50%; top: 42%;
  transform: translate(-50%,-50%) scale(0.5);
  z-index: 40; text-align: center; opacity: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 30%, rgba(60,90,180,0.35), rgba(10,16,40,0.9));
  border: 2px solid var(--gold);
  border-radius: 26px; padding: 24px 40px;
  box-shadow: 0 0 60px rgba(255,200,60,0.5);
}
#levelupBanner.show { animation: luShow 2.2s ease forwards; }
@keyframes luShow {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.4) rotate(-6deg); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.1) rotate(2deg); }
  25% { transform: translate(-50%,-50%) scale(1) rotate(0); }
  80% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
}
#levelupBanner img { width: 64px; height: 64px;  animation: floaty 1.5s ease-in-out infinite; }
#levelupBanner .lu-title { font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 0 20px rgba(255,200,60,.8); }
#levelupBanner .lu-title span { color: var(--gold); }
#levelupBanner .lu-rank { font-size: 18px; font-weight: 800; color: var(--gold); margin: 2px 0 6px; }
#levelupBanner .lu-reward { display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 18px; font-weight: 800; }
#levelupBanner .lu-reward img { width: 24px; height: 24px; animation: none; }

/* ---------- Game Over ---------- */
.go-title { font-size: 30px; color: #ff8a95; margin-bottom: 6px; }
.record-badge {
  display: none;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-weight: 900;
  font-size: clamp(26px, 8vw, 36px);
  letter-spacing: .5px;
  line-height: 1;
  background: linear-gradient(180deg, #fff3b0 0%, #ffd93d 45%, #ff9f1c 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ffd93d;
  -webkit-text-stroke: 4px #7a3e00;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(122,62,0,0.3);
  margin: 0 auto 12px;
  padding: 0 8px;
  letter-spacing: 1px;
  width: fit-content;
}
.record-badge.show {
  display: flex; align-items: center; gap: 8px;
  animation: recordPop .5s cubic-bezier(.2,1.8,.4,1), recordFloat 1.8s ease-in-out .5s infinite;
}
.record-badge img {
  width: 30px; height: 30px; object-fit: contain;
  -webkit-text-stroke: 0;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
  animation: crownWobble 1.4s ease-in-out infinite;
}
@keyframes recordPop { 0%{transform:scale(0)} 70%{transform:scale(1.15)} 100%{transform:scale(1)} }
@keyframes recordFloat { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
@keyframes crownWobble { 0%,100%{transform:rotate(-8deg)} 50%{transform:rotate(8deg)} }
@keyframes shine { from{filter:brightness(1)} to{filter:brightness(1.25)} }
.go-score { margin: 10px 0; }
.go-score .lbl { font-size: 14px; opacity: .7; }
.go-score .val { font-size: 56px; font-weight: 800; color: #fff; text-shadow: 0 0 24px rgba(120,180,255,.5); }
.go-sub { display: flex; justify-content: center; gap: 18px; margin-bottom: 12px; font-size: 15px; }
.go-sub b { color: var(--gold); }

/* ---------- Ежедневная награда ---------- */
.modal-title { font-size: 24px; margin-bottom: 6px; }
.modal-text { font-size: 14px; opacity: .8; margin-bottom: 16px; }
.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.daily-cell {
  border-radius: 14px;
  padding: 10px 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 12px;
}
.daily-cell .d { opacity: .7; }
.daily-cell .amt { font-weight: 800; color: var(--gold); font-size: 15px; }
.daily-cell img { width: 22px; height: 22px; display: block; margin: 3px auto;  }
.daily-cell.claimed { opacity: .45; background: rgba(60,220,116,0.12); border-color: rgba(60,220,116,0.4); }
.daily-cell.today { border-color: var(--gold); box-shadow: 0 0 16px rgba(255,217,61,.5); transform: scale(1.05); }

/* ---------- Достижения ---------- */
.ach-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; max-height: 46vh; overflow-y: auto; }
.ach-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 14px; padding: 10px 12px; text-align: left;
}
.ach-item.done { background: rgba(60,220,116,0.14); border: 1px solid rgba(60,220,116,0.35); }
.ach-item .em { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; }
.ach-item .em img { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.ach-item:not(.done) .em img { filter: grayscale(1) brightness(.7); opacity: .55; }
.ach-item .info { flex: 1; }
.ach-item .info .t { font-weight: 800; font-size: 15px; }
.ach-item .info .d { font-size: 12px; opacity: .7; }
.ach-item .status { font-size: 20px; width: 24px; text-align: center; }

/* ---------- Настройки ---------- */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.06);
  border-radius: 14px; padding: 14px 16px; margin: 8px 0;
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.toggle-row input { width: 48px; height: 28px; -webkit-appearance: none; appearance: none; background: rgba(255,255,255,0.2); border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; }
.toggle-row input:checked { background: var(--green); }
.toggle-row input::after { content:''; position:absolute; top:3px; left:3px; width:22px; height:22px; border-radius:50%; background:#fff; transition: transform .2s; }
.toggle-row input:checked::after { transform: translateX(20px); }

/* ---------- Тосты ---------- */
#toasts { position: fixed; top: 70px; left: 0; right: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: linear-gradient(180deg, #fff2a8, #ffd93d 55%, #ffa41b);
  color: #5a2a00; font-weight: 900; font-size: 15px;
  padding: 11px 20px; border-radius: 999px;
  border: 3px solid #fff;
  box-shadow: 0 8px 22px rgba(0,0,0,.4), inset 0 2px 0 rgba(255,255,255,.5);
  animation: toastIn .35s cubic-bezier(.2,1.7,.4,1), toastOut .4s ease 2.4s forwards;
}
@keyframes toastIn { from{transform:translateY(-20px) scale(.85);opacity:0} to{transform:translateY(0) scale(1);opacity:1} }
@keyframes toastOut { to{transform:translateY(-20px);opacity:0} }

/* ---------- Монетизация: магазин и реклама ---------- */
.menu-icons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.btn-revive-ad {
  background: linear-gradient(180deg, #7cffb2, #3ddc74 55%, #1e9c4c);
  color: #0a3d20;
  box-shadow: 0 4px 0 #157a3a, inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-revive-ad small { opacity: .85; font-size: 12px; }

.shop-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; max-height: 42vh; overflow: auto; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.12); border-radius: 16px; padding: 10px 12px;
}
.shop-item.owned { opacity: .65; }
.shop-item .em { width: 44px; height: 44px; display: grid; place-items: center; }
.shop-item .em img { width: 36px; height: 36px; object-fit: contain; }
.shop-item .body { flex: 1; min-width: 0; }
.shop-item .t { font-weight: 800; font-size: 16px; }
.shop-item .d { font-size: 13px; opacity: .85; margin-top: 2px; }
.shop-buy {
  border: none; border-radius: 12px; padding: 10px 12px;
  font-family: inherit; font-weight: 800; font-size: 13px;
  background: linear-gradient(180deg, #ffe566, #ffc734);
  color: #5a3200; box-shadow: 0 3px 0 #c99200; cursor: pointer;
}
.shop-buy:disabled { background: rgba(255,255,255,.2); color: #fff; box-shadow: none; }
.shop-no-ads {
  text-align: center; font-weight: 800; color: #7cffb2;
  background: rgba(61,220,116,.15); border-radius: 12px; padding: 8px; margin-bottom: 8px;
}

.ad-banner-mock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: 52px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,.15), rgba(0,0,0,.35));
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,.7);
  pointer-events: none;
}

.ad-mock-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.72);
  display: grid; place-items: center;
}
.ad-mock-box {
  width: min(320px, 88vw); background: #1a2744; border-radius: 20px;
  padding: 24px 20px; text-align: center; color: #fff;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.ad-mock-tag {
  display: inline-block; background: #ffd93d; color: #5a3200;
  font-weight: 900; font-size: 12px; padding: 4px 10px; border-radius: 8px; margin-bottom: 12px;
}
.ad-mock-bar {
  height: 8px; background: rgba(255,255,255,.15); border-radius: 999px; overflow: hidden; margin: 14px 0 8px;
}
.ad-mock-bar span { display: block; height: 100%; background: linear-gradient(90deg, #3ddc74, #26d0ce); transition: width .1s linear; }
.ad-mock-box small { opacity: .65; font-size: 11px; }

#menu .menu-panel { padding-bottom: 64px; }

.shop-table-title {
  margin: 16px 0 8px; font-size: 15px; font-weight: 900;
  text-align: left; opacity: .95;
}
.shop-rank-summary {
  font-size: 13px; font-weight: 700; opacity: .88; margin: 0 0 8px; line-height: 1.4;
}
.coin-table-wrap {
  overflow: auto; border-radius: 14px;
  background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.12);
  margin-bottom: 10px;
}
.coin-table {
  width: 100%; border-collapse: collapse; font-size: 13px; font-weight: 700;
}
.coin-table th, .coin-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08);
}
.coin-table th { font-size: 11px; text-transform: uppercase; opacity: .75; letter-spacing: .04em; }
.coin-table tr:last-child td { border-bottom: none; }
.coin-table tr.current { background: rgba(255,217,61,.18); }
.coin-table tr.current td { color: #ffe98a; }
.coin-table tr.done { opacity: .55; }
.coin-table tr.best { background: rgba(61,220,116,.12); }
.coin-table .stars { color: #ffd93d; white-space: nowrap; }
.coin-table .best-tag {
  display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 6px;
  background: #3ddc74; color: #0a3d20; font-size: 10px; font-weight: 900;
}
.coin-table .status { text-align: right; color: #7cffb2; font-weight: 900; }
.coin-table .mini { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }

#shopModal .panel { max-height: 92vh; overflow-y: auto; }

body.showcase-mode #topbar { position: relative; }

/* showcaseCaption оставлен в разметке, но в режиме записи не показывается */
