:root {
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Inter", "Heebo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #f8fafc;
  text-align: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;

  background: linear-gradient(-45deg, #0b1120, #1e1b4b, #1e293b, #2e1065, #0b1120);
  background-size: 400% 400%;
  animation: gradientShift 45s ease infinite;
  transition: background 0.6s ease;
}

body.celebrating {
  background: linear-gradient(-45deg, #ff5e5e, #ffd93d, #6bff6b, #5ec8ff, #c07bff, #ff8bd1);
  background-size: 400% 400%;
  animation: gradientShift 6s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Ambient background decoration: blobs, rings, streak, particles.
   Always stays behind content (z-index: 0) and never intercepts clicks. */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.22;
  will-change: transform;
}

.blob-a {
  width: 46vmax;
  height: 46vmax;
  top: -14vmax;
  left: -10vmax;
  background: radial-gradient(circle, #6366f1, transparent 70%);
  animation: blobFloatA 34s ease-in-out infinite;
}

.blob-b {
  width: 40vmax;
  height: 40vmax;
  bottom: -16vmax;
  right: -8vmax;
  background: radial-gradient(circle, #ec4899, transparent 70%);
  animation: blobFloatB 40s ease-in-out infinite;
}

.blob-c {
  width: 34vmax;
  height: 34vmax;
  bottom: 10%;
  left: 12%;
  background: radial-gradient(circle, #38bdf8, transparent 70%);
  opacity: 0.16;
  animation: blobFloatC 46s ease-in-out infinite;
}

@keyframes blobFloatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vw, 8vh) scale(1.12); }
}

@keyframes blobFloatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-7vw, -6vh) scale(1.08); }
}

@keyframes blobFloatC {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5vw, -7vh) scale(1.1); }
}

.ring {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.ring-a {
  width: 60vmin;
  height: 60vmin;
  top: -18vmin;
  right: -16vmin;
  animation: ringSpin 110s linear infinite;
}

.ring-b {
  width: 42vmin;
  height: 42vmin;
  bottom: -14vmin;
  left: -12vmin;
  animation: ringSpin 90s linear infinite reverse;
}

@keyframes ringSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.streak {
  position: absolute;
  top: -20%;
  left: -30%;
  width: 160%;
  height: 140%;
  background: linear-gradient(120deg, transparent 42%, rgba(255, 255, 255, 0.035) 50%, transparent 58%);
  animation: streakDrift 32s ease-in-out infinite;
}

@keyframes streakDrift {
  0%, 100% { transform: translate(-4%, -3%) rotate(0deg); }
  50% { transform: translate(4%, 3%) rotate(1.5deg); }
}

.particles {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--rgb), 0.9), rgba(var(--rgb), 0) 70%);
  opacity: var(--opacity);
  animation: particleDrift var(--dur) ease-in-out var(--delay) infinite;
  will-change: transform, opacity;
}

@keyframes particleDrift {
  0%, 100% { transform: translate(0, 0); opacity: var(--opacity); }
  50% { transform: translate(var(--drift), calc(var(--rise) * -1)); opacity: calc(var(--opacity) * 1.5); }
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.emoji-rain {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}

.emoji-particle {
  position: absolute;
  top: -10vh;
  animation-name: emojiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes emojiFall {
  0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(115vh) rotate(360deg); opacity: 0.85; }
}

.mascot {
  position: fixed;
  bottom: 8%;
  font-size: clamp(3rem, 10vw, 6rem);
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.35));
}

.mascot.walk {
  left: 5%;
  animation: mascotWalk 5s ease-in-out infinite alternate, mascotHop 0.6s ease-in-out infinite;
}

.mascot.spin {
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  animation: mascotSpin 2.2s ease-in-out infinite;
}

@keyframes mascotWalk {
  0% { left: 5%; }
  100% { left: 78%; }
}

@keyframes mascotHop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-18px) rotate(-8deg); }
}

@keyframes mascotSpin {
  0%, 100% { transform: translateX(-50%) rotate(0deg) scale(1); }
  50% { transform: translateX(-50%) rotate(360deg) scale(1.3); }
}

main {
  position: relative;
  z-index: 2;
}

main::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(85vw, 640px);
  height: min(70vw, 420px);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(99, 102, 241, 0.28), rgba(139, 92, 246, 0.12) 45%, transparent 72%);
  filter: blur(50px);
  z-index: -1;
  pointer-events: none;
  animation: centerGlowPulse 9s ease-in-out infinite;
}

@keyframes centerGlowPulse {
  0%, 100% { opacity: 0.75; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

h1 {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 800;
  margin: 0 0 2rem;
  background: linear-gradient(90deg, #93c5fd, #c4b5fd, #f9a8d4, #93c5fd);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleShine 6s linear infinite;
}

@keyframes titleShine {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.countdown {
  position: relative;
  z-index: 1;
  display: flex;
  gap: clamp(0.75rem, 4vw, 2rem);
  flex-wrap: wrap;
  justify-content: center;
}

.countdown::before {
  content: "";
  position: absolute;
  inset: -2rem -1.5rem;
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: 2rem;
  z-index: -1;
  pointer-events: none;
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
}

.unit span {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: inline-block;
  animation: breathe 2.4s ease-in-out infinite;
  text-shadow: 0 0 24px rgba(148, 163, 253, 0.35);
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

#seconds.tick {
  animation: breathe 2.4s ease-in-out infinite, tickFlash 0.6s ease;
}

@keyframes tickFlash {
  0% { color: #fbbf24; text-shadow: 0 0 22px #fbbf24; }
  100% { color: inherit; text-shadow: 0 0 24px rgba(148, 163, 253, 0.35); }
}

.unit label {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.funny-message {
  position: relative;
  margin: 2.25rem auto 0;
  max-width: min(88vw, 30rem);
  width: max-content;
  padding: 0.85rem 1.35rem;
  font-family: "Heebo", "Rubik", "Inter", sans-serif;
  font-size: clamp(0.88rem, 2.3vw, 1rem);
  font-weight: 500;
  line-height: 1.55;
  color: rgba(236, 240, 255, 0.88);
  text-align: center;
  direction: rtl;

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.1rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);

  opacity: 1;
  transform: scale(1) translateY(0);
  transition: opacity 350ms cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.funny-message::before {
  content: "";
  position: absolute;
  top: -0.4rem;
  left: 50%;
  width: 0.8rem;
  height: 0.8rem;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.2rem 0 0 0;
}

.funny-message.is-hidden {
  opacity: 0;
  transform: scale(0.9) translateY(8px);
  transition: opacity 250ms ease, transform 250ms ease;
}

.celebration {
  position: relative;
  z-index: 7;
}

.done-message {
  margin-top: 0;
  font-size: clamp(2.5rem, 10vw, 5.5rem);
  font-weight: 800;
  animation: celebrateText 1.1s ease-in-out infinite, titleShine 3s linear infinite;
  background: linear-gradient(90deg, #fde68a, #fca5a5, #a5f3fc, #fde68a);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@keyframes celebrateText {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50% { transform: scale(1.1) rotate(1deg); }
}

.hidden {
  display: none;
}

.icon-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.5);
  color: #f8fafc;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(15, 23, 42, 0.8);
  transform: rotate(45deg);
}

.settings-panel {
  position: fixed;
  top: 4rem;
  right: 1rem;
  z-index: 10;
  width: min(90vw, 20rem);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.75rem;
  padding: 1.25rem;
  text-align: left;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.settings-panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.settings-panel label {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0.75rem 0 0.25rem;
}

.settings-panel input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  font-size: 0.95rem;
}

.settings-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn-primary, .btn-plain {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary:disabled, .btn-plain:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: #6366f1;
  color: white;
}

.btn-primary:hover {
  background: #4f46e5;
}

.btn-plain {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

.btn-plain:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-link {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  color: #f8fafc;
}

.settings-error {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: #fca5a5;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  body,
  .blob,
  .ring,
  .streak,
  .particle,
  main::before,
  h1,
  .unit span {
    animation: none !important;
  }

  .funny-message,
  .funny-message.is-hidden {
    transition: none !important;
  }
}

@media (max-width: 640px) {
  .blob {
    filter: blur(50px);
  }
}
