/* ===== CSS Custom Properties ===== */
:root {
  --glow-color: rgba(0, 212, 255, 0.3);
  --glow-color-strong: rgba(0, 212, 255, 0.6);
  --particle-color: #00d4ff;
  --particle-glow: rgba(0, 212, 255, 0.4);
  --sponge-color: #f0e68c;
  --sponge-dots: rgba(180, 160, 60, 0.5);
  --fill-gradient: linear-gradient(to top, #00ff41 0%, #88ff00 25%, #ffd700 50%, #ff8800 75%, #ff4444 100%);
  --progress-gradient: linear-gradient(90deg, #00ff41, #ffd700, #ff4444);
  --accent-1: #00d4ff;
  --accent-2: #00ff41;
  --warning-glow: rgba(255, 170, 0, 0.4);
  --warning-glow-strong: rgba(255, 100, 0, 0.7);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Base ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* ===== Header ===== */
header {
  text-align: center;
  padding: 24px 16px 8px;
  width: 100%;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

header p {
  font-size: 0.85rem;
  color: #888;
  margin-top: 4px;
}

/* ===== Main ===== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  width: 100%;
  max-width: 400px;
}

/* ===== Sponge ===== */
.sponge-area {
  position: relative;
  width: 220px;
  height: 300px;
  margin: 16px 0;
}

.sponge {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  background-color: var(--sponge-color);
  background-image:
    radial-gradient(circle, var(--sponge-dots) 2px, transparent 2px);
  background-size: 14px 14px;
  overflow: hidden;
  box-shadow: 0 0 20px var(--glow-color);
  transition: box-shadow 0.5s ease, background-color 0.6s ease;
  z-index: 2;
}

.sponge.absorbing {
  animation: pulse-glow 2s ease-in-out infinite;
}

.sponge.warning {
  animation: pulse-warning 1s ease-in-out infinite;
}

.sponge.full {
  box-shadow: 0 0 30px rgba(255, 68, 68, 0.6);
  animation: none;
}

.sponge-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--fill-gradient);
  transition: height 1s ease-in-out;
  opacity: 0.75;
  border-radius: 0 0 24px 24px;
}

.sponge.replacing {
  animation: replace-sponge 0.8s ease-in-out;
}

/* ===== Keyframes ===== */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 20px var(--glow-color);
  }

  50% {
    box-shadow: 0 0 40px var(--glow-color-strong);
  }
}

@keyframes pulse-warning {
  0%,
  100% {
    box-shadow: 0 0 20px var(--warning-glow);
  }

  50% {
    box-shadow: 0 0 45px var(--warning-glow-strong);
  }
}

@keyframes replace-sponge {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  40% {
    transform: scale(0.5) rotate(10deg);
    opacity: 0;
  }

  60% {
    transform: scale(0.5) rotate(-10deg);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pop-in {
  0% {
    transform: scale(0);
  }

  70% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

/* ===== Particles ===== */
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--particle-color);
  box-shadow: 0 0 6px var(--particle-color), 0 0 12px var(--particle-glow);
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.particle.active {
  animation: fly-to-sponge var(--duration) var(--delay) ease-in infinite;
}

.particle.paused {
  animation: none;
  opacity: 0;
}

@keyframes fly-to-sponge {
  0% {
    opacity: 0;
    transform: translate(var(--start-x), var(--start-y)) scale(1);
  }

  15% {
    opacity: 0.9;
  }

  85% {
    opacity: 0.7;
    transform: translate(0, 0) scale(0.4);
  }

  100% {
    opacity: 0;
    transform: translate(0, 0) scale(0);
  }
}

/* ===== Status Section ===== */
.status-section {
  width: 100%;
  text-align: center;
  margin-top: 20px;
}

.progress-bar-container {
  width: 100%;
  height: 12px;
  background: #2a2a4a;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--progress-gradient);
  border-radius: 6px;
  transition: width 1s ease-in-out;
}

.percent-text {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.status-text {
  font-size: 0.95rem;
  color: #aaa;
  min-height: 1.4em;
  transition: color 0.3s;
}

.status-text.warning {
  color: #ffaa00;
  font-weight: 600;
}

.status-text.danger {
  color: #ff4444;
  font-weight: 700;
}

/* ===== Stats ===== */
.stats {
  display: flex;
  gap: 24px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: #666;
}

.stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Buy Button ===== */
.buy-button {
  margin-top: 24px;
  padding: 16px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: #28a745;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s, transform 0.4s, background 0.2s;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}

.buy-button.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.buy-button:active {
  background: #1e7e34;
  transform: scale(0.97);
}

/* ===== Price Label ===== */
.price-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 4px;
}

/* ===== Footer ===== */
footer {
  padding: 16px;
  text-align: center;
  font-size: 0.7rem;
  color: #555;
  width: 100%;
}

footer a {
  color: #00d4ff;
  text-decoration: none;
}

.version-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  font-size: 0.65rem;
  color: #00d4ff;
  letter-spacing: 0.5px;
}

.level-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  font-size: 0.65rem;
  color: var(--accent-1);
  letter-spacing: 0.5px;
  transition: color 0.4s, border-color 0.4s, background 0.4s;
}

/* ===== Info Button ===== */
.info-button {
  position: absolute;
  top: 20px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #00d4ff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
}

.info-button:hover {
  background: rgba(0, 212, 255, 0.15);
  transform: scale(1.1);
}

/* ===== Info Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 25, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: linear-gradient(145deg, #1e1e3a, #2a2a4e);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  transform: translateY(30px) scale(0.95);
  transition: transform 0.35s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 212, 255, 0.08);
}

.modal-overlay.visible .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content h2 {
  font-size: 1.3rem;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #00d4ff, #00ff41);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-content p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #bbb;
  margin-bottom: 12px;
}

.modal-content .highlight-box {
  background: rgba(0, 255, 65, 0.08);
  border: 1px solid rgba(0, 255, 65, 0.2);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
}

.modal-content .highlight-box .big-percent {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #00ff41, #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-content .highlight-box p {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: #aaa;
}

.modal-close-button {
  margin-top: 16px;
  padding: 10px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.modal-close-button:active {
  transform: scale(0.96);
}

/* ===== Payment Overlay ===== */
.payment-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 25, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.payment-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.payment-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 212, 255, 0.2);
  border-top: 4px solid #00d4ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

.payment-overlay p {
  color: #ccc;
  font-size: 1rem;
}

.payment-success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: pop-in 0.4s ease;
}

/* ===== Update Banner ===== */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #00d4ff, #00ff41);
  color: #1a1a2e;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 2000;
  transform: translateY(-100%);
  transition: transform 0.4s ease;
  cursor: pointer;
}

.update-banner.visible {
  transform: translateY(0);
}

/* ===== Level-Up Banner ===== */
.levelup-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(145deg, #1e1e3a, #2a2a4e);
  border: 2px solid var(--accent-1);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 60px var(--particle-glow);
  max-width: 320px;
  width: 85%;
}

.levelup-banner.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.levelup-banner .levelup-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  animation: pop-in 0.4s ease;
}

.levelup-banner .levelup-title {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.levelup-banner .levelup-desc {
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.5;
}

/* ===== Install Banner ===== */
.install-banner {
  display: none;
  padding: 12px 16px;
  background: #2a2a4a;
  border-radius: 10px;
  margin-top: 16px;
  text-align: center;
  font-size: 0.85rem;
  width: 100%;
}

.install-banner.visible {
  display: block;
}

.install-button {
  margin-top: 8px;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #00d4ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.install-button:active {
  background: #00b8d9;
}

/* ===== Responsive ===== */
@media (min-width: 768px) {
  header h1 {
    font-size: 2.2rem;
  }

  .sponge-area {
    width: 260px;
    height: 350px;
  }

  .percent-text {
    font-size: 2.4rem;
  }
}
