* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-touch-callout: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070d;
  font-family: "Rubik", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: #fff;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

#app {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #1a2440 0%, #0a0e1a 70%);
}

@media (min-width: 700px), (orientation: landscape) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(ellipse at 50% 0%, rgba(47, 128, 237, 0.16), transparent 42%),
      radial-gradient(ellipse at 50% 100%, rgba(245, 166, 35, 0.12), transparent 46%),
      #05070d;
  }

  #app {
    width: min(100vw, calc(100dvh * 9 / 16));
    height: min(100dvh, calc(100vw * 16 / 9));
    margin: auto;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.65);
  }
}

.ic {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  fill: currentColor;
}

h1,
h2,
h3,
.btn,
.screen-title,
.tab,
.buy-btn,
.hud-item b,
.lvl-cell,
.logo,
.pause-sub b,
.new-badge {
  font-family: "Russo One", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0.4px;
}

/* ===================== ЭКРАНЫ ===================== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% 0%, #1a2440 0%, #0a0e1a 70%);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.screen::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ===================== TOPBAR ===================== */
.topbar {
  width: 100%;
  max-width: 520px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, rgba(30, 19, 9, 0.96), rgba(15, 10, 5, 0.96));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(214, 164, 74, 0.4);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  border-radius: 0 0 14px 14px;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-btn {
  background: linear-gradient(180deg, #3a2513, #20140a);
  border: 1px solid rgba(214, 164, 74, 0.55);
  color: #f3ddb0;
  border-radius: 13px;
  padding: 0 14px;
  font-size: clamp(14px, 3.8vw, 16px);
  font-weight: 700;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 225, 150, 0.3),
    inset 0 -2px 3px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.18s, transform 0.1s, background 0.18s;
}

.back-btn:hover {
  background: linear-gradient(180deg, #472e18, #281a0d);
}

.back-btn:active {
  transform: scale(0.95);
}

.back-arrow {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}

.back-btn:hover .back-arrow {
  transform: translateX(-3px);
}

.coin-badge {
  background: linear-gradient(180deg, #3a2513, #20140a);
  border: 1px solid rgba(240, 200, 110, 0.6);
  border-radius: 24px;
  padding: 0 14px 0 10px;
  font-weight: 800;
  font-size: clamp(14px, 3.8vw, 17px);
  color: #ffe9b0;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  flex-shrink: 0;
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 225, 150, 0.3),
    inset 0 -2px 3px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.coin-spin {
  display: inline-flex;
  animation: coinSpin 4s linear infinite;
}

@keyframes coinSpin {
  0%,
  100% {
    transform: scaleX(1);
  }
  50% {
    transform: scaleX(0.25);
  }
}

/* ===================== ГЛАВНОЕ МЕНЮ ===================== */
.menu-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#menuFx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#menu > *:not(.menu-bg) {
  position: relative;
  z-index: 1;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.4;
  animation: orbDrift 10s ease-in-out infinite;
  z-index: 0;
}

.orb-gold {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #f5a623, transparent 70%);
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.5;
}

.orb-blue {
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, #2f80ed, transparent 70%);
  bottom: 5%;
  left: -80px;
  animation-delay: 3s;
}

.orb-purple {
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, #8e2de2, transparent 70%);
  bottom: -70px;
  right: -70px;
  animation-delay: 6s;
}

@keyframes orbDrift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(25px, -20px) scale(1.08);
  }
  66% {
    transform: translate(-20px, 15px) scale(0.95);
  }
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(5, 8, 15, 0.6) 100%);
}

.logo-ball-8 {
  width: clamp(70px, 19vw, 96px);
  height: clamp(70px, 19vw, 96px);
  margin: 6vh auto 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #4a4a4a 0%, #1a1a1a 30%, #000 90%);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.6),
    inset -8px -10px 20px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(80, 80, 80, 0.3);
  position: relative;
  animation: ballFloat 3.4s ease-in-out infinite;
  z-index: 1;
}

.logo-ball-8::after {
  content: "8";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 50%;
  color: #111;
  font-weight: 800;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Russo One", sans-serif;
}

@keyframes ballFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-5deg);
  }
  50% {
    transform: translateY(-16px) rotate(5deg);
  }
}

h1.logo {
  margin-top: 18px;
  font-size: clamp(26px, 7.5vw, 42px);
  text-align: center;
  line-height: 1.05;
  padding: 0 8px;
  word-break: break-word;
  background: linear-gradient(180deg, #fff8d6 0%, #ffd24a 30%, #f5a623 60%, #c76d00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 14px rgba(245, 166, 35, 0.6)) drop-shadow(0 2px 0 rgba(0, 0, 0, 0.4));
  animation: logoPulse 2.5s ease-in-out infinite;
  letter-spacing: 2px;
}

@keyframes logoPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.035);
  }
}

.menu-buttons {
  width: min(90vw, 340px);
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row .btn {
  flex: 1;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 0;
  border: none;
  border-radius: 16px;
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: linear-gradient(180deg, #2f80ed, #1a5cc4);
  box-shadow: 0 6px 0 #0e3c85, 0 10px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #0e3c85, 0 4px 10px rgba(0, 0, 0, 0.4);
}

.btn.big {
  padding: 20px 0;
  font-size: clamp(18px, 5vw, 22px);
  width: 100%;
}

.btn.sm {
  padding: 12px 0;
  font-size: clamp(13px, 3.5vw, 15px);
}

.btn.gold {
  background: linear-gradient(180deg, #ffb63d, #e0810a);
  box-shadow: 0 6px 0 #9c5a03, 0 10px 20px rgba(0, 0, 0, 0.4);
}

.btn.gold:active {
  box-shadow: 0 2px 0 #9c5a03;
}

.btn.green {
  background: linear-gradient(180deg, #3ecf6b, #1d9e46);
  box-shadow: 0 6px 0 #12602b, 0 10px 20px rgba(0, 0, 0, 0.4);
}

.btn.green:active {
  box-shadow: 0 2px 0 #12602b;
}

.btn.red {
  background: linear-gradient(180deg, #ef5350, #c62828);
  box-shadow: 0 6px 0 #7f1616;
}

.btn.red:active {
  box-shadow: 0 2px 0 #7f1616;
}

.btn.purple {
  background: linear-gradient(180deg, #9b51e0, #6a1bb8);
  box-shadow: 0 6px 0 #4a0e85, 0 10px 20px rgba(0, 0, 0, 0.4);
}

.btn.purple:active {
  box-shadow: 0 2px 0 #4a0e85;
}

.btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: sheen 3.2s infinite;
  pointer-events: none;
}

@keyframes sheen {
  0% {
    left: -80%;
  }
  45% {
    left: 130%;
  }
  100% {
    left: 130%;
  }
}

.menu-footer {
  margin-top: auto;
  padding: 14px 0 18px;
  display: flex;
  justify-content: center;
  width: 100%;
}

/* ===== Кнопка политики конфиденциальности ===== */
.btn-privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  padding: 11px 16px;
  border-radius: 11px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #9aa5bd;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.15s;
  font-family: "Rubik", sans-serif;
}

.btn-privacy:hover,
.btn-privacy:active {
  border-color: #6ee7ff;
  color: #6ee7ff;
  background: rgba(110, 231, 255, 0.06);
}

.btn-privacy .ic {
  flex-shrink: 0;
}

/* ===================== ВЫБОР УРОВНЯ ===================== */
.total-stars {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, #33210f, #1c1108);
  border: 1px solid rgba(240, 205, 120, 0.45);
  color: #ffe9b0;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 225, 150, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.lvl-scroll-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin-top: 18px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.lvl-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding-bottom: 20px;
}

.fog-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  pointer-events: none;
  z-index: 5;
  background: linear-gradient(
    180deg,
    rgba(10, 14, 26, 0) 0%,
    rgba(10, 14, 26, 0.4) 25%,
    rgba(10, 14, 26, 0.75) 55%,
    rgba(10, 14, 26, 0.95) 80%,
    #0a0e1a 100%
  );
}

.fog-lock-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(160, 175, 210, 0.6);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  pointer-events: none;
  animation: fogHintPulse 2.5s ease-in-out infinite;
}

@keyframes fogHintPulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.9;
  }
}

.lvl-cell {
  width: 56px;
  height: 56px;
  border-radius: 11px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  background: linear-gradient(180deg, #3a2614 0%, #241609 60%, #1a0f06 100%);
  border: 1px solid rgba(214, 164, 74, 0.55);
  box-shadow:
    0 3px 0 #120a04,
    0 6px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 225, 150, 0.3),
    inset 0 -2px 4px rgba(0, 0, 0, 0.6);
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s;
  animation: cellIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cellIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lvl-cell:not(.locked):hover {
  transform: translateY(-2px);
  border-color: rgba(255, 220, 140, 0.85);
}

.lvl-cell:not(.locked):active {
  transform: translateY(1px) scale(0.95);
}

.lvl-num {
  font-size: 18px;
  line-height: 1;
  color: #fdf3d8;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.lvl-cell.locked {
  background: linear-gradient(180deg, #2b3242 0%, #1a2030 60%, #12161f 100%);
  border-color: rgba(255, 255, 255, 0.13);
  color: #5d6780;
  cursor: default;
}

.lvl-sub {
  font-size: 7px;
  letter-spacing: 1px;
  color: #5d6780;
  font-weight: 700;
  font-family: "Rubik", sans-serif;
}

.lvl-cell.new-unlock {
  border-color: #ffd54f;
  animation:
    unlockIn 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both,
    unlockPulse 1.7s ease-in-out 0.8s infinite;
}

@keyframes unlockIn {
  from {
    transform: scale(0.3) rotate(-10deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.16) rotate(3deg);
    opacity: 1;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

@keyframes unlockPulse {
  0%,
  100% {
    box-shadow:
      0 3px 0 #120a04,
      0 6px 10px rgba(0, 0, 0, 0.5),
      0 0 0 0 rgba(255, 213, 79, 0.5);
  }
  50% {
    box-shadow:
      0 3px 0 #120a04,
      0 6px 10px rgba(0, 0, 0, 0.5),
      0 0 20px 5px rgba(255, 213, 79, 0.45);
  }
}

.new-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: linear-gradient(180deg, #ff7a5c, #d92626);
  color: #fff;
  font-size: 6.5px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 5px 1px;
  border-radius: 0 10px 0 8px;
}

.stars {
  display: flex;
  gap: 2px;
}

/* ===================== ОБЩИЕ ===================== */
.screen-title {
  margin-top: 20px;
  font-size: clamp(20px, 5.5vw, 26px);
  font-weight: 800;
  color: #ffe9c0;
  text-shadow: 0 2px 10px rgba(255, 180, 60, 0.3);
  text-align: center;
  padding: 0 8px;
}

/* ===================== МАГАЗИН ===================== */
.tabs {
  display: flex;
  gap: 6px;
  margin: 18px 0 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.tab {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: clamp(12px, 3.5vw, 14px);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.14);
}

.tab.active {
  background: rgba(47, 128, 237, 0.35);
  border-color: #2f80ed;
}

.shop-list {
  width: 100%;
  max-width: 440px;
  padding: 10px 4px 90px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
  animation: itemIn 0.3s ease both;
}

@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.shop-item.equipped {
  border-color: #3ecf6b;
  box-shadow: 0 0 14px rgba(62, 207, 107, 0.25);
}

.item-preview {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  color: #8ab4ff;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-info b {
  font-size: clamp(14px, 3.8vw, 16px);
  display: block;
}

.item-info small {
  color: #9aa5bd;
  font-size: 12px;
}

.pwr-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  margin-top: 6px;
  overflow: hidden;
}

.pwr-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #3ecf6b, #f5d523, #ef5350);
}

.aim-hint {
  display: block;
  margin-top: 3px;
  color: #8ab4ff !important;
  font-size: 10px !important;
}

.buy-btn {
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  font-weight: 800;
  font-size: clamp(12px, 3.4vw, 14px);
  color: #fff;
  background: linear-gradient(180deg, #ffb63d, #e0810a);
  box-shadow: 0 3px 0 #9c5a03;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.buy-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.buy-btn.equip {
  background: linear-gradient(180deg, #3ecf6b, #1d9e46);
  box-shadow: 0 3px 0 #12602b;
}

.buy-btn.owned {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.ball-vis {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

/* ===================== ИГРА ===================== */
#game {
  background: #0a0e1a;
  padding: 0;
  overflow: hidden;
}

#gameWrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

#hud {
  width: 100%;
  max-width: 520px;
  display: flex;
  gap: 8px;
  padding: 10px 10px 8px;
  flex-shrink: 0;
}

.hud-item {
  flex: 1;
  min-width: 0;
  height: 50px;
  border-radius: 13px;
  border: 1px solid rgba(214, 164, 74, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: linear-gradient(180deg, #34220f 0%, #211509 55%, #150d05 100%);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 225, 150, 0.28),
    inset 0 -2px 4px rgba(0, 0, 0, 0.6);
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.hud-item small {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #d8b478;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.hud-item b {
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fdf3d8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.hud-home {
  cursor: pointer;
}

.hud-home b {
  font-size: 20px;
  color: #ffd98c;
}

.hud-home:active {
  transform: scale(0.94);
}

#cvWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cv {
  touch-action: none;
  display: block;
}

#powerWrap {
  width: min(90vw, 380px);
  margin: 8px 0 12px;
  flex-shrink: 0;
}

#powerLbl {
  font-size: 12px;
  color: #9aa5bd;
  text-align: center;
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: 1px;
}

#powerBar {
  height: 18px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  position: relative;
}

#powerFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3ecf6b, #f5d523, #ff8a3d, #ef5350);
  border-radius: 9px;
  transition: width 0.05s linear;
}

#powerCap {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 8px #fff;
}

/* ===================== МОДАЛКИ / ОВЕРЛЕИ ===================== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 18, 0.75);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.overlay.show {
  display: flex;
}

.modal {
  width: min(85vw, 340px);
  max-width: 100%;
  background: linear-gradient(180deg, #222c48, #141b30);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 22px;
  padding: 26px 20px;
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

@keyframes popIn {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal h2 {
  font-size: clamp(20px, 6vw, 26px);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.modal p {
  color: #aab4cc;
  font-size: 15px;
  margin-bottom: 16px;
}

.modal .btn {
  width: 100%;
  margin: 8px 0;
  padding: 14px 0;
  font-size: 17px;
}

.win-title {
  background: linear-gradient(180deg, #ffe89a, #f5a623);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lose-title {
  color: #ef5350;
}

.pause-title {
  color: #8ab4ff;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(110, 160, 255, 0.55);
}

.pause-sub {
  color: #9aa5bd;
  font-size: 14px;
  margin-bottom: 18px;
}

.pause-sub b {
  color: #ffd54f;
}

.stars-row {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 8px 0 12px;
}

.star-pop {
  display: inline-block;
  animation: starPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes starPop {
  from {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.gold-txt {
  color: #ffd54f;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.final-crown {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  animation: floatCrown 3s ease-in-out infinite;
}

@keyframes floatCrown {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

.final-title {
  background: linear-gradient(180deg, #fff8d6, #ffd24a, #f5a623);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: clamp(20px, 6vw, 26px);
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 8px rgba(245, 166, 35, 0.5));
}

.final-sub {
  color: #ffd54f;
  font-weight: 700;
}

/* ===================== ИНТРО-ПЛАШКА ===================== */
.intro-card {
  width: min(82vw, 330px);
  max-width: 100%;
  background: linear-gradient(180deg, #1c2748, #0e1428);
  border: 1px solid rgba(110, 160, 255, 0.4);
  border-radius: 22px;
  padding: 26px 20px;
  text-align: center;
  box-shadow:
    0 0 40px rgba(110, 160, 255, 0.25),
    0 20px 60px rgba(0, 0, 0, 0.6);
  animation: introIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes introIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.intro-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: #8ab4ff;
}

.intro-title {
  font-size: 22px;
  margin-bottom: 8px;
  color: #fff;
}

.intro-text {
  color: #aab4cc;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 16px;
}

.intro-card .btn {
  width: 100%;
  margin-top: 14px;
}

/* ===================== REWARD POPUP ===================== */
#rewardPopup {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
}

#rewardPopup.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.rp-card {
  background: linear-gradient(180deg, rgba(34, 44, 72, 0.96), rgba(16, 22, 40, 0.96));
  border: 1px solid rgba(255, 213, 79, 0.35);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rp-icon {
  display: flex;
  justify-content: center;
}

.rp-title {
  font-weight: 800;
}

.rp-reward {
  color: #ffd54f;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===================== TOAST ===================== */
#toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  display: none;
  z-index: 80;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}