:root {
  --bg-1: #101a54;
  --bg-2: #1e2d8f;
  --bg-3: #5d2eea;
  --card: rgba(255, 255, 255, 0.14);
  --card-strong: rgba(255, 255, 255, 0.2);
  --border: rgba(255, 255, 255, 0.2);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.82);
  --accent: #ffd54a;
  --accent-2: #ff7b54;
  --green: #50e3a4;
  --blue: #4dc9ff;
  --shadow: 0 20px 60px rgba(10, 14, 40, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(
      circle at 20% 20%,
      rgba(255, 213, 74, 0.18),
      transparent 20%
    ),
    radial-gradient(
      circle at 80% 30%,
      rgba(77, 201, 255, 0.18),
      transparent 24%
    ),
    radial-gradient(
      circle at 50% 80%,
      rgba(255, 123, 84, 0.18),
      transparent 22%
    ),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.55;
}

body::before {
  width: 300px;
  height: 300px;
  left: -60px;
  top: 80px;
  background: rgba(255, 213, 74, 0.28);
  animation: floatBlob 10s ease-in-out infinite;
}

body::after {
  width: 360px;
  height: 360px;
  right: -100px;
  bottom: 40px;
  background: rgba(77, 201, 255, 0.25);
  animation: floatBlob 12s ease-in-out infinite reverse;
}

@keyframes floatBlob {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.06);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.container {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 32px));
  margin: 28px auto 40px;
}

.hidden {
  display: none !important;
}

.card {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: linear-gradient(180deg, var(--card-strong), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow);
}

.auth-card {
  max-width: 460px;
  margin: 80px auto;
  padding: 30px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 10px;
}

h2 {
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  margin-bottom: 6px;
}

h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.subtitle,
.small,
.message {
  color: var(--muted);
}

.message {
  min-height: 24px;
  font-weight: 600;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0 18px;
}

.tab,
button,
input {
  border: 0;
  border-radius: 18px;
  font: inherit;
}

input {
  width: 100%;
  background: rgba(8, 12, 35, 0.45);
  color: var(--text);
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  outline: none;
  transition: 0.2s ease;
}

input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

input:focus {
  transform: translateY(-1px);
  border-color: rgba(255, 213, 74, 0.8);
  box-shadow: 0 0 0 4px rgba(255, 213, 74, 0.16);
}

button {
  cursor: pointer;
  color: white;
  font-weight: 800;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px) scale(0.985);
}

.tab {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.tab.active {
  background: linear-gradient(135deg, #4dc9ff, #5d7cff);
  box-shadow: 0 10px 30px rgba(77, 201, 255, 0.24);
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#authSubmit,
.upgrade-actions button,
.secondary,
#clickButton {
  position: relative;
  overflow: hidden;
}

#authSubmit::before,
.upgrade-actions button::before,
.secondary::before,
#clickButton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 20%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 80%
  );
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}

#authSubmit:hover::before,
.upgrade-actions button:hover::before,
.secondary:hover::before,
#clickButton:hover::before {
  transform: translateX(120%);
}

#authSubmit {
  margin-top: 4px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #ffd54a, #ff9a3d);
  color: #1b1740;
  box-shadow: 0 16px 35px rgba(255, 154, 61, 0.35);
}

button.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  padding: 14px 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -25px;
  top: -25px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.stat span {
  display: block;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.stat strong {
  display: block;
  position: relative;
  z-index: 1;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.click-zone {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  text-align: center;
  position: sticky;
  top: 20px;
}

.click-zone {
  position: relative;
  overflow: visible;
}

#clickButton {
  position: relative;
  isolation: isolate;
  transform-origin: center;
}

#clickButton {
  width: 100%;
  min-height: 320px;
  border-radius: 36px;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #1e1a42;
  background: radial-gradient(
      circle at 30% 30%,
      rgba(255, 255, 255, 0.45),
      transparent 28%
    ),
    linear-gradient(135deg, #ffd54a 0%, #ff9a3d 45%, #ff5f6d 100%);
  box-shadow: 0 24px 55px rgba(255, 112, 89, 0.35),
    inset 0 -8px 0 rgba(0, 0, 0, 0.15);
}

#clickButton:hover {
  transform: translateY(-3px) scale(1.01);
}

#clickButton:active {
  transform: scale(0.98);
}

#clickButton.clicked {
  animation: clickPulse 220ms ease;
}

@keyframes clickPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.96);
  }
  70% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

.click-burst {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  pointer-events: none;
  z-index: 5;
}

.click-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 24px rgba(255, 213, 74, 0.55);
  animation: ringExpand 520ms ease-out forwards;
}

@keyframes ringExpand {
  0% {
    transform: scale(0.4);
    opacity: 0.95;
  }
  100% {
    transform: scale(5.5);
    opacity: 0;
  }
}

.click-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  margin-top: -5px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 6;
  opacity: 0.95;
  animation: particleFly 700ms cubic-bezier(0.12, 0.8, 0.2, 1) forwards;
}

.click-particle.star {
  width: 12px;
  height: 12px;
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 92%,
    50% 70%,
    21% 92%,
    32% 57%,
    2% 35%,
    39% 35%
  );
}

@keyframes particleFly {
  0% {
    transform: translate(0, 0) scale(0.7);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.2);
    opacity: 0;
  }
}

.click-float {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 7;
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: white;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 0 18px rgba(255, 213, 74, 0.45);
  animation: floatScore 850ms ease-out forwards;
}

@keyframes floatScore {
  0% {
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -58%) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -170%) scale(1);
    opacity: 0;
  }
}

.click-zone.shake-lite {
  animation: shakeLite 180ms ease;
}

@keyframes shakeLite {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-2px);
  }
  50% {
    transform: translateX(2px);
  }
  75% {
    transform: translateX(-1px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #clickButton.clicked,
  .click-ring,
  .click-particle,
  .click-float,
  .click-zone.shake-lite {
    animation: none !important;
  }
}

#clickFeedback {
  margin-top: 14px;
  font-size: 1rem;
  font-weight: 700;
}

.upgrades-zone {
  height: 700px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.upgrades-zone h3 {
  flex: 0 0 auto;
  margin-bottom: 16px;
}

#upgradesList {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#upgradesList::-webkit-scrollbar {
  width: 10px;
}

#upgradesList::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

#upgradesList::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

#upgradesList::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.34);
}

.upgrade-item,
.leaderboard-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: rgba(7, 11, 34, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 16px;
  transition: transform 0.18s ease, background 0.18s ease,
    border-color 0.18s ease;
}

.upgrade-item:hover,
.leaderboard-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 213, 74, 0.3);
}

.upgrade-info strong,
.leaderboard-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.04rem;
}

.upgrade-info span,
.leaderboard-item span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
}

.upgrade-actions {
  min-width: 140px;
  text-align: right;
}

.upgrade-actions button {
  margin-top: 8px;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #50e3a4, #19b9ff);
  color: #11203b;
  box-shadow: 0 12px 28px rgba(25, 185, 255, 0.22);
}

#leaderboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-item {
  border-radius: 18px;
}

.leaderboard-item:first-child {
  background: linear-gradient(
    135deg,
    rgba(255, 213, 74, 0.22),
    rgba(255, 255, 255, 0.08)
  );
  border-color: rgba(255, 213, 74, 0.45);
}

.click-icon {
  width: min(220px, 62%);
  height: auto;
  display: block;
  margin: 0 auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.18));
}

.tab,
#authSubmit,
.secondary {
  animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 980px) {
  .stats-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .click-zone,
  .upgrades-zone {
    min-height: auto;
  }

  #clickButton {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 20px, 1200px);
    margin: 20px auto 28px;
  }

  .card {
    padding: 18px;
    border-radius: 22px;
  }

  .auth-card {
    margin: 30px auto;
    padding: 22px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .upgrade-item,
  .leaderboard-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .upgrade-actions {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

  .upgrade-actions button {
    width: 100%;
  }
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.rank-badge.bump {
  animation: rankBadgePop 420ms ease;
}

@keyframes rankBadgePop {
  0% {
    transform: scale(0.92);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.rank-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.rank-badge-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.lb-left,
.lb-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-currency {
  margin-bottom: 0px !important;
}

.lb-right {
  margin-left: auto;
  text-align: right;
}

.lb-rank-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rank-badge.rank-fer {
  background: linear-gradient(
    135deg,
    rgba(120, 132, 150, 0.35),
    rgba(185, 195, 210, 0.18)
  );
}
.rank-badge.rank-bronze {
  background: linear-gradient(
    135deg,
    rgba(181, 98, 44, 0.42),
    rgba(255, 177, 122, 0.18)
  );
}
.rank-badge.rank-argent {
  background: linear-gradient(
    135deg,
    rgba(144, 162, 185, 0.42),
    rgba(232, 242, 255, 0.18)
  );
}
.rank-badge.rank-or {
  background: linear-gradient(
    135deg,
    rgba(204, 151, 20, 0.42),
    rgba(255, 217, 91, 0.18)
  );
}
.rank-badge.rank-platinium {
  background: linear-gradient(
    135deg,
    rgba(53, 155, 175, 0.42),
    rgba(143, 243, 255, 0.18)
  );
}
.rank-badge.rank-diamant {
  background: linear-gradient(
    135deg,
    rgba(71, 100, 219, 0.42),
    rgba(142, 197, 255, 0.18)
  );
}
.rank-badge.rank-master {
  background: linear-gradient(
    135deg,
    rgba(127, 52, 206, 0.42),
    rgba(200, 140, 255, 0.18)
  );
}
.rank-badge.rank-primal {
  background: linear-gradient(
      135deg,
      rgba(255, 91, 145, 0.42),
      rgba(255, 138, 168, 0.18)
    ),
    radial-gradient(circle at 30% 30%, rgba(255, 214, 74, 0.2), transparent 50%);
}

.rank-unlock-fx {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 0.08),
    rgba(5, 8, 24, 0.4)
  );
}

.rank-unlock-card {
  min-width: min(520px, calc(100% - 32px));
  max-width: 620px;
  padding: 30px 24px;
  border-radius: 28px;
  text-align: center;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.32);
  animation: rankUnlockShow 1600ms ease forwards;
}

.rank-unlock-card h3 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  letter-spacing: -0.04em;
}

.rank-unlock-card p {
  margin: 0;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.88);
}

.rank-unlock-card .big-rank {
  display: inline-block;
  margin: 12px 0 14px;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

@keyframes rankUnlockShow {
  0% {
    opacity: 0;
    transform: scale(0.75) translateY(20px);
  }
  18% {
    opacity: 1;
    transform: scale(1.03) translateY(0);
  }
  78% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.96) translateY(-8px);
  }
}

.click-cta {
  display: block;
  max-width: 280px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 800;
  color: rgba(30, 26, 66, 0.9);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

#clickButton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
