:root {
  --bg1: #07111f;
  --bg2: #11253f;
  --ink: #f7f9ff;
  --accent: #ffb703;
  --accent-2: #8ecae6;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 183, 3, 0.22), transparent 38%),
    radial-gradient(circle at 85% 0%, rgba(142, 202, 230, 0.22), transparent 40%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.game-shell {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 72px 16px 16px;
}

.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  gap: 6px;
  width: min(560px, calc(100vw - 32px));
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  padding: 12px 16px;
  backdrop-filter: blur(8px);
}

.menu-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  width: fit-content;
  z-index: 40;
}

.menu-button {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(6, 18, 31, 0.92);
  color: #f8fbff;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  min-width: 240px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(4, 13, 23, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
}

.menu-wrap.open .menu-dropdown {
  display: grid;
  gap: 6px;
}

.menu-dropdown a {
  color: #f8fbff;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 700;
}

.menu-dropdown a:hover {
  background: rgba(255, 183, 3, 0.16);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.topbar p {
  margin: 0;
  opacity: 0.9;
}

.counter {
  font-weight: 700;
  color: var(--accent);
}

.power-status {
  font-weight: 700;
  font-size: 0.95rem;
  color: #b8cee4;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(2, 48, 71, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  width: fit-content;
}

.power-status.active {
  color: #fff2a5;
  background: linear-gradient(120deg, rgba(255, 183, 3, 0.46), rgba(251, 133, 0, 0.4));
  border-color: rgba(255, 239, 140, 0.75);
}

.power-orb {
  position: fixed;
  width: 88px;
  height: 88px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.2) 38%, transparent 42%),
    conic-gradient(from 40deg, #ffb703, #fb8500, #ff006e, #3a86ff, #ffb703);
  box-shadow:
    0 0 0 6px rgba(255, 183, 3, 0.2),
    0 0 40px rgba(255, 183, 3, 0.75),
    0 0 80px rgba(58, 134, 255, 0.45);
  cursor: pointer;
  z-index: 25;
  animation: orbPulse 0.75s ease-in-out infinite alternate;
}

@keyframes orbPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.9) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.15) rotate(10deg);
  }
}

.image-field {
  position: fixed;
  inset: 0;
  overflow: hidden;
  perspective: 950px;
}

.image-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  border: none;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55);
  transform-style: preserve-3d;
  transform: var(--base-transform);
  transition: filter 0.12s ease;
  animation: chaosWobble var(--wobble-speed, 1.7s) var(--wobble-delay, 0s) ease-in-out infinite alternate;
  touch-action: manipulation;
}

.image-btn:hover {
  filter: brightness(1.2);
}

.image-btn img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  -webkit-user-drag: none;
  pointer-events: none;
}

.image-btn.flying {
  animation: flyAway 550ms cubic-bezier(0.15, 0.82, 0.2, 1) forwards;
}

@keyframes chaosWobble {
  0% {
    transform: var(--base-transform) translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: var(--base-transform) translate3d(12px, -10px, 0) rotate(8deg) scale(1.06);
  }
}

@keyframes flyAway {
  0% {
    transform: var(--base-transform) translate3d(0, 0, 0) scale(1);
    opacity: 1;
    filter: blur(0px);
  }
  45% {
    opacity: 1;
  }
  100% {
    transform: var(--base-transform) translate3d(var(--tx), var(--ty), 780px) rotate(var(--rot)) scale(3.2);
    opacity: 0;
    filter: blur(2px);
  }
}

.win-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 9, 18, 0.68);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 30;
}

.win-screen.show {
  opacity: 1;
  pointer-events: auto;
}

.win-card {
  text-align: center;
  background: linear-gradient(140deg, #ffe082, #ffb703);
  color: #2b1a00;
  border-radius: 24px;
  padding: 26px 22px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
  min-width: min(88vw, 420px);
}

.win-card h2 {
  margin: 0 0 18px;
  font-size: clamp(1.6rem, 5vw, 3rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.reset-btn {
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 800;
  padding: 16px 28px;
  border: none;
  border-radius: 14px;
  background: #023047;
  color: #f8fbff;
  cursor: pointer;
  min-width: 210px;
}

body.clicker-mode {
  overflow: auto;
}

.clicker-shell {
  min-height: 100%;
  padding: 16px;
  display: grid;
  gap: 18px;
}

.clicker-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.clicker-panel,
.shop-panel,
.stats-panel {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  padding: 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.3);
}

.clicker-panel {
  display: grid;
  gap: 16px;
}

.score-big {
  font-size: clamp(1.8rem, 5vw, 3.4rem);
  font-weight: 800;
  color: #ffd166;
}

.score-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.score-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.special-power-status {
  width: fit-content;
}

.special-power-status.active {
  color: #fff4b3;
  border-color: rgba(255, 209, 102, 0.9);
  background: linear-gradient(120deg, rgba(255, 209, 102, 0.28), rgba(255, 183, 3, 0.22));
}

.dog-click-area {
  display: grid;
  place-items: center;
  min-height: 420px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 183, 3, 0.18), transparent 35%),
    radial-gradient(circle at 70% 80%, rgba(142, 202, 230, 0.18), transparent 38%),
    rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
}

.golden-dog-button {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  padding: 0;
  cursor: pointer;
  z-index: 5;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.2) 40%, transparent 44%),
    conic-gradient(from 15deg, #ffd166, #ffb703, #fb8500, #ffd166);
  box-shadow:
    0 0 0 6px rgba(255, 209, 102, 0.2),
    0 0 26px rgba(255, 183, 3, 0.7);
  animation: goldenDogPulse 0.75s ease-in-out infinite alternate;
}

@keyframes goldenDogPulse {
  0% {
    transform: scale(0.92) rotate(0deg);
  }
  100% {
    transform: scale(1.08) rotate(10deg);
  }
}

.dog-button {
  width: min(72vw, 320px);
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 28px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.42);
  transition: transform 0.08s ease;
}

.dog-button:active {
  transform: scale(0.96);
}

.dog-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
}

.floating-points {
  position: absolute;
  font-weight: 800;
  color: #fff1a8;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  animation: floatPoints 0.7s ease-out forwards;
  pointer-events: none;
}

@keyframes floatPoints {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.8);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-46px) scale(1.05);
  }
}

.shop-panel h2,
.stats-panel h2 {
  margin: 0 0 14px;
}

.shop-list {
  display: grid;
  gap: 12px;
}

.shop-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.shop-item button,
.soft-button {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
  color: #06202e;
  background: linear-gradient(120deg, #ffd166, #ffb703);
}

.reset-side {
  justify-self: end;
  width: fit-content;
  max-width: 100%;
  white-space: nowrap;
}

.shop-item button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-tile {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.clicker-side {
  display: grid;
  gap: 18px;
}

@media (max-width: 680px) {
  .game-shell,
  .clicker-shell {
    padding-top: 84px;
  }

  .topbar {
    width: calc(100vw - 24px);
    margin: 6px;
  }

  .menu-wrap {
    top: 10px;
    right: 10px;
  }

  .menu-dropdown {
    min-width: 210px;
  }

  .clicker-layout {
    grid-template-columns: 1fr;
  }

  .reset-side {
    justify-self: stretch;
    font-size: 0.82rem;
    padding: 10px 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
