* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  /* Ensure body takes up full viewport height on mobile */
  height: 100vh;
  background: radial-gradient(circle at top, #e8f3ff, #cfd9e7 55%, #b7c1cf 100%);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: #0f1419;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 120%, rgba(0, 0, 0, 0.15), transparent 55%);
}

/* Prefer modern viewport units to avoid mobile browser chrome issues */
@supports (height: 100svh) {
  body,
  .stage {
    height: 100svh;
    min-height: 100svh;
  }
}

.x-button {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 28px;
  background: #0f1419;
  color: #ffffff;
  text-decoration: none;
  transition: left 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              top 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.12s ease;
  cursor: pointer;
  box-shadow: 0 32px 45px rgba(15, 20, 25, 0.3);
}

.x-button.is-instant {
  transition: none !important;
}

.x-button:active {
  transform: scale(0.96) translateY(3px);
  box-shadow: 0 18px 24px rgba(15, 20, 25, 0.28);
}

.x-logo {
  width: 52px;
  height: 52px;
  filter: brightness(0) invert(1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.tap-counter {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  bottom: clamp(20px, 6vh, 48px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.85);
  color: #f1f5f9;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  box-shadow: 0 18px 30px rgba(15, 20, 25, 0.35);
}

.tap-counter__value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.intro-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.52);
  backdrop-filter: blur(6px);
  color: #f8fafc;
  font-size: clamp(1.3rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 10;
  opacity: 1;
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
}

.intro-overlay__message {
  margin: 0;
  padding: 1.8rem 3rem;
  border-radius: 28px;
  background: rgba(15, 20, 25, 0.85);
  box-shadow: 0 24px 48px rgba(15, 20, 25, 0.45);
  text-align: center;
}

.intro-overlay.is-hidden {
  opacity: 0;
  transform: translateY(-20px);
}

.intro-overlay__sub {
  display: block;
  margin-top: 0.8rem;
  font-size: clamp(1rem, 2.2vw, 1.4rem);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.04em;
  color: rgba(226, 232, 240, 0.88);
}

.redirect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 20, 25, 0.35);
  backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}

.redirect-overlay:not([hidden]) {
  opacity: 1;
  pointer-events: all;
}

.redirect-overlay__content {
  text-align: center;
  padding: 2rem 3rem;
  border-radius: 28px;
  background: rgba(15, 20, 25, 0.9);
  box-shadow: 0 24px 48px rgba(15, 20, 25, 0.5);
  min-width: min(400px, 85vw);
}

.redirect-overlay__message {
  margin: 0 0 1.5rem 0;
  color: #f8fafc;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.redirect-overlay__progress {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.redirect-overlay__progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0ea5e9, #06b6d4, #10b981);
  border-radius: 999px;
  animation: progress-fill 3000ms linear forwards;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.6);
}

.redirect-overlay__sub {
  margin: 0 0 1rem 0;
  color: rgba(226, 232, 240, 0.9);
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.redirect-overlay__url {
  margin: 0;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: rgba(96, 165, 250, 0.95);
  font-size: clamp(0.8rem, 1.8vw, 0.95rem);
  font-weight: 500;
  font-family: "Monaco", "Menlo", "Consolas", monospace;
  word-break: break-all;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@keyframes progress-fill {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

.signature {
  position: absolute;
  bottom: clamp(16px, 5vh, 48px);
  left: clamp(18px, 5vw, 60px);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(15, 20, 25, 0.75);
  text-decoration: none;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(15, 20, 25, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.signature:hover,
.signature:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(15, 20, 25, 0.24);
  color: #0f1419;
}

.signature:focus-visible {
  outline: 2px solid rgba(15, 20, 25, 0.6);
  outline-offset: 3px;
}


.portrait-wall {
  position: absolute;
  bottom: clamp(24px, 8vh, 80px);
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 18px;
  width: min(520px, 70vw);
  pointer-events: none;
  z-index: 20;
}

.portrait {
  position: relative;
  width: 100%;
  margin: 0;
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(15, 20, 25, 0.22);
  box-shadow: 0 18px 36px rgba(15, 20, 25, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: rgba(15, 20, 25, 0.55);
  transition: transform 420ms ease, opacity 320ms ease;
  transform: scale(1);
  opacity: 0.92;
}

.portrait.is-active img {
  transform: scale(1.04);
  opacity: 1;
}

.portrait--x,
.portrait--bluesky,
.portrait--insta-threads,
.portrait--news {
  grid-column: auto;
}

@media (max-width: 768px) {
  html, body {
    height: 100%;
    min-height: 100%;
    overflow: hidden; /* prevent any scrolling on small screens */
  }

  .portrait-wall {
    bottom: clamp(20px, 6vh, 60px);
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: min(420px, 90vw);
  }

  .portrait {
    border-radius: 16px;
    box-shadow: 0 12px 24px rgba(15, 20, 25, 0.26);
  }
}

@media (max-width: 480px) {
  .x-button {
    width: 90px;
    height: 90px;
  }

  .x-logo {
    width: 46px;
    height: 46px;
  }

  .tap-counter {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    bottom: clamp(16px, 5vh, 40px);
  }

  .intro-overlay__message {
    padding: 1.4rem 2.1rem;
  }

  .intro-overlay__sub {
    margin-top: 0.6rem;
  }

  .signature {
    font-size: 0.85rem;
    padding: 0.45rem 0.85rem;
    top: auto;
    bottom: clamp(12px, 4vh, 32px);
    left: 50%;
    transform: translateX(-50%);
  }

  .portrait-wall {
    top: clamp(12px, 3vh, 24px);
    bottom: auto;
    left: 0;
    right: 0;
    margin-left: auto;
    margin-right: auto;
    transform: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: min(360px, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px));
    max-width: 360px;
  }

  .portrait {
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(15, 20, 25, 0.24);
  }
}

.flyer {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--size, 56px);
  height: var(--size, 56px);
  transform: translate(var(--start-x, 0px), var(--start-y, 0px)) rotate(var(--angle, 0deg))
    scale(var(--scale, 1));
  animation: flyer-move var(--duration, 6200ms) linear forwards;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.flyer::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.5), 0 12px 24px rgba(15, 20, 25, 0.25);
}

.flyer--spark::before {
  background: radial-gradient(circle at 30% 30%, #ffffff, #ffdd57 60%, rgba(255, 115, 0, 0.7) 100%);
}

.flyer--bubble::before {
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.95), rgba(96, 165, 250, 0.85) 55%, rgba(14, 116, 205, 0.6) 100%);
  border-radius: 48% 52% 55% 45% / 45% 50% 55% 50%;
}

.flyer--logo {
  border-radius: 24px;
  pointer-events: auto;
}

.flyer--logo::before {
  content: none;
}

.flyer__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  color: #ffffff;
  font-weight: 600;
  font-size: calc(var(--size, 64px) * 0.36);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  box-shadow: 0 18px 32px rgba(15, 20, 25, 0.28);
}

.flyer__logo-img {
  display: block;
  width: 62%;
  height: 62%;
  object-fit: contain;
}

/* Ensure Threads SVG renders white on dark background */
.flyer--logo-threads .flyer__logo-img {
  filter: brightness(0) invert(1);
}

.flyer__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.flyer__link span[aria-hidden="true"] {
  line-height: 1;
}

.flyer__link--bluesky {
  background: linear-gradient(135deg, #0ea5e9, #0369a1);
}

.flyer__link--threads {
  background: linear-gradient(135deg, #2b2b2b, #141414);
  font-size: calc(var(--size, 64px) * 0.3);
}

.flyer__link--facebook {
  background: linear-gradient(135deg, #1877f2, #0a58ca);
}

.flyer__link--instagram {
  background: radial-gradient(circle at 20% 20%, #fdf497 0%, #fdf497 10%, #fd5949 45%, #d6249f 70%, #285aeb 100%);
  font-size: calc(var(--size, 64px) * 0.3);
}

.flyer__link--foxnews {
  background: linear-gradient(135deg, #0a1744, #1d2f6f);
  font-size: calc(var(--size, 64px) * 0.3);
}

.flyer__link--cnn {
  background: linear-gradient(135deg, #cc0000, #8b0000);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--bbc {
  background: linear-gradient(135deg, #1c1c1c, #000000);
  font-size: calc(var(--size, 64px) * 0.34);
}

.flyer__link--welt {
  background: linear-gradient(135deg, #1b4965, #224870);
  font-size: calc(var(--size, 64px) * 0.38);
  letter-spacing: 0.02em;
}

.flyer__link--elpais {
  background: linear-gradient(135deg, #0c3b4c, #1a6c7c);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--elmundo {
  background: linear-gradient(135deg, #0f3f5f, #115b7c);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--nytimes {
  background: linear-gradient(135deg, #111111, #2e2e2e);
  font-size: calc(var(--size, 64px) * 0.28);
  letter-spacing: 0.04em;
}

.flyer__link--washingtonpost {
  background: linear-gradient(135deg, #101820, #2f3e51);
  font-size: calc(var(--size, 64px) * 0.28);
  letter-spacing: 0.05em;
}

.flyer__link--thetimes {
  background: linear-gradient(135deg, #0a223d, #143a63);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--theguardian {
  background: linear-gradient(135deg, #00406d, #006ca6);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--lemonde {
  background: linear-gradient(135deg, #14365c, #2f5c89);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--lefigaro {
  background: linear-gradient(135deg, #0d3a73, #1660aa);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--corriere {
  background: linear-gradient(135deg, #1f2f39, #304c5d);
  font-size: calc(var(--size, 64px) * 0.32);
}

.flyer__link--repubblica {
  background: linear-gradient(135deg, #1b4f72, #2575a9);
  font-size: calc(var(--size, 64px) * 0.32);
}

@keyframes flyer-move {
  0% {
    transform: translate(var(--start-x), var(--start-y)) rotate(var(--angle)) scale(var(--scale));
    opacity: 0;
  }
  6% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--end-x), var(--end-y)) rotate(calc(var(--angle) + var(--spin, 0deg))) scale(var(--scale));
    opacity: 0;
  }
}
