/* PGG app download landing page. Layer positions are percentages of a 720 x 1580 stage. */
:root {
  --stage-w: min(100vw, max(430px, calc(100vh * 0.5625)));
  --gold: #ffd76a;
  --gold-deep: #d8ae57;
  --cream: #fff4d6;
}

@supports (height: 100dvh) {
  :root {
    --stage-w: min(100vw, max(430px, calc(100dvh * 0.5625)));
  }
}

:root {
  --bar-h: calc(var(--stage-w) * 0.157);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: #050006;
}

body {
  min-height: 100vh;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Top bar: fixed, same width as the stage */
.topbar {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: calc(var(--stage-w) * 0.022);
  width: var(--stage-w);
  height: var(--bar-h);
  padding-right: calc(var(--stage-w) * 0.022);
  background: #000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  transform: translateX(-50%);
}

.topbar-logo {
  flex: none;
  display: block;
  width: var(--bar-h);
  height: var(--bar-h);
  padding: calc(var(--stage-w) * 0.012);
  object-fit: contain;
}

.topbar-text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #fff;
  font-size: calc(var(--stage-w) * 0.036);
  font-style: italic;
  font-weight: 700;
  line-height: 1.25;
}

.topbar-download {
  flex: none;
  width: calc(var(--stage-w) * 0.251);
  height: calc(var(--stage-w) * 0.098);
  padding: 0;
  border: 1px solid #ffeeb0;
  border-radius: calc(var(--stage-w) * 0.022);
  background: linear-gradient(180deg, #fff09e 0%, #ffcf3f 42%, #f29d12 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 3px 0 #9a5200, 0 4px 10px rgba(0, 0, 0, 0.5);
  color: #3a1500;
  font-size: calc(var(--stage-w) * 0.034);
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.topbar-download:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 2px 0 #9a5200;
}

/* Page and blurred fill behind the stage on wide screens */
.page {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #050006;
}

@supports (height: 100dvh) {
  .page {
    min-height: 100dvh;
  }
}

.page::before {
  content: "";
  position: fixed;
  inset: -8%;
  z-index: 0;
  background: url("assets/bg.webp") center top / cover no-repeat;
  filter: blur(14px) saturate(1.12) brightness(0.82);
  transform: scale(1.06);
}

.page::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 0, 6, 0.62), transparent 22%, transparent 78%, rgba(5, 0, 6, 0.62)),
    linear-gradient(180deg, transparent 62%, rgba(5, 0, 6, 0.34));
}

.stage {
  position: relative;
  z-index: 1;
  width: var(--stage-w);
  height: calc(var(--stage-w) * 1580 / 720);
  overflow: hidden;
  background: #050006;
}

.stage img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.stage-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center top;
  animation: stageBaseSettle 1.15s ease both;
}

.poster {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.poster img {
  width: 100%;
  height: auto;
}

.hero-poster {
  left: 0;
  top: 7.2%;
  z-index: 2;
  width: 100%;
  transform-origin: center top;
  animation: heroEnter 0.86s cubic-bezier(0.16, 1, 0.28, 1) both;
}

.games-panel {
  left: 2.5%;
  top: 63%;
  z-index: 2;
  width: 95%;
  padding: 1%;
  overflow: hidden;
  border: 2px solid var(--gold-deep);
  border-radius: 16px;
  background: #240526;
}

.brand-name {
  position: absolute;
  right: 3.2%;
  top: 10%;
  z-index: 6;
  color: #ffe66c;
  font-size: calc(var(--stage-w) * 0.066);
  font-style: italic;
  font-weight: 900;
  line-height: 1.2;
  text-align: right;
  text-shadow: 0 3px 2px #825500;
  white-space: nowrap;
  transform-origin: right center;
  animation: brandEnter 0.62s ease 0.18s both;
}

.popup-img {
  position: absolute;
  left: 0;
  top: 9.7%;
  z-index: 4;
  width: 100%;
  height: auto;
  transform-origin: 50% 43%;
}

.pointer-img {
  position: absolute;
  left: 65.6%;
  top: 57.7%;
  z-index: 9;
  width: 13.33%;
  height: auto;
  pointer-events: none;
  transform-origin: 30% 24%;
}

.receive-hotspot {
  position: absolute;
  left: 27.2%;
  top: 56.35%;
  z-index: 5;
  width: 46%;
  height: 5%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

/* Close button: a transparent tap area of at least 44px, centred on a thin white circle with an
   X drawn in CSS. The circle keeps its original size and position. */
.popup-close {
  --close-ring: calc(var(--stage-w) * 0.067);
  --close-hit: max(44px, var(--close-ring));
  position: absolute;
  left: calc(46.7% + (var(--close-ring) - var(--close-hit)) / 2);
  top: calc(66.6% + (var(--close-ring) - var(--close-hit)) / 2);
  z-index: 8;
  display: grid;
  place-items: center;
  width: var(--close-hit);
  height: var(--close-hit);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.popup-close-ring {
  position: relative;
  display: block;
  width: var(--close-ring);
  height: var(--close-ring);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.28);
}

.popup-close-ring::before,
.popup-close-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52%;
  height: 2px;
  border-radius: 1px;
  background: #fff;
}

.popup-close-ring::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.popup-close-ring::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.popup-close:active {
  transform: scale(0.94);
}

.topbar-download:focus-visible,
.poster:focus-visible,
.receive-hotspot:focus-visible,
.popup-close:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* Dim layer under the popup */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 0.42s ease;
}

/* One light sweep when the page opens */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 7;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 21%, rgba(255, 255, 255, 0.2) 34%, transparent 47%);
  transform: translateX(-62%);
  animation: stageShine 1.35s ease 0.35s both;
}

.stage.popup-open::after {
  opacity: 1;
}

.stage.popup-open .poster {
  pointer-events: none;
}

.stage.popup-waiting .popup-img,
.stage.popup-waiting .pointer-img,
.stage.popup-waiting .popup-close,
.stage.popup-waiting .receive-hotspot {
  opacity: 0;
  pointer-events: none;
}

.stage.popup-waiting .popup-img {
  transform: translateY(7.5%) scale(0.82);
  filter: blur(8px) brightness(0.88);
}

.stage.popup-open .popup-img {
  animation: popupEnter 0.78s cubic-bezier(0.15, 1.08, 0.22, 1) both, popupFloat 3.4s ease-in-out 1.05s infinite;
}

.stage.popup-open .pointer-img {
  animation: pointerEnter 0.34s ease 0.78s both, pointerTap 1.38s ease-in-out 1.16s infinite;
}

.stage.popup-open .popup-close-ring {
  animation: popupControlEnter 0.42s ease 0.5s both, closeFloat 3.4s ease-in-out 1.05s infinite;
}

.stage.popup-open .receive-hotspot {
  animation: popupControlEnter 0.42s ease 0.58s both, ctaPulse 1.55s ease-in-out 1.15s infinite;
}

.stage.popup-closed .popup-img,
.stage.popup-closed .pointer-img,
.stage.popup-closed .popup-close,
.stage.popup-closed .receive-hotspot {
  display: none;
}

/* Download card */
.dl-prompt {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}

.dl-prompt[hidden] {
  display: none;
}

/* Under the top bar, used while the popup is up and a bottom card would cover its buttons */
.dl-prompt.is-top {
  top: calc(var(--bar-h) + 8px);
  bottom: auto;
}

.dl-card {
  position: relative;
  width: min(420px, 100%);
  padding: 16px 14px 14px;
  border: 2px solid var(--gold-deep);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(58, 14, 70, 0.98), rgba(30, 6, 36, 0.98));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  color: #fff;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dl-prompt.is-top .dl-card {
  transform: translateY(-16px);
}

.dl-prompt.is-open .dl-card {
  opacity: 1;
  transform: none;
}

.dl-card.is-flash {
  animation: dlFlash 1s ease 1;
}

.dl-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #d9c7e0;
  cursor: pointer;
}

.dl-close:hover,
.dl-close:focus-visible {
  background: rgba(255, 215, 106, 0.12);
  color: var(--gold);
}

.dl-close svg {
  width: 20px;
  height: 20px;
}

.dl-message {
  margin: 0 30px 12px 0;
  color: var(--cream);
  font-size: 0.95rem;
  line-height: 1.45;
}

.dl-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.dl-step {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  text-align: center;
}

.dl-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 215, 106, 0.55);
  border-radius: 12px;
  background: rgba(20, 2, 26, 0.75);
  color: var(--gold);
}

.dl-icon svg {
  width: 22px;
  height: 22px;
}

.dl-step-text {
  color: #e2d3e8;
  font-size: 0.74rem;
  line-height: 1.3;
}

.dl-again {
  position: relative;
  width: 100%;
  min-height: 46px;
  padding: 10px 18px;
  overflow: hidden;
  border: 0;
  border-radius: 38px;
  background: linear-gradient(180deg, #fff09e 0%, #ffcf3f 42%, #f29d12 100%);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.35);
  color: #3a1500;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.dl-again:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.dl-again.is-waiting {
  cursor: default;
  filter: saturate(0.35) brightness(0.8);
}

.dl-again.is-waiting::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  background: rgba(58, 21, 0, 0.55);
  transform-origin: left;
  animation: dlWait var(--dl-wait, 8s) linear forwards;
}

@media (max-width: 380px) {
  .dl-card {
    padding: 14px 12px 12px;
  }

  .dl-message {
    font-size: 0.9rem;
  }

  .dl-step-text {
    font-size: 0.7rem;
  }
}

@keyframes dlWait {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes dlFlash {
  0%,
  100% {
    border-color: var(--gold-deep);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
    filter: none;
  }

  35% {
    border-color: #fff3b8;
    box-shadow: 0 0 0 3px rgba(255, 215, 106, 0.85), 0 0 30px rgba(255, 215, 106, 0.7), 0 16px 36px rgba(0, 0, 0, 0.5);
    filter: brightness(1.15);
  }
}

@keyframes popupEnter {
  0% {
    opacity: 0;
    transform: translateY(8%) scale(0.78) rotate(-1.8deg);
    filter: blur(8px) brightness(0.86);
  }

  62% {
    opacity: 1;
    transform: translateY(-1.2%) scale(1.035) rotate(0.35deg);
    filter: blur(0) brightness(1.08);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
    filter: blur(0) brightness(1);
  }
}

@keyframes heroEnter {
  from {
    opacity: 0;
    transform: translateY(3%) scale(1.025);
    filter: blur(5px) brightness(0.9);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) brightness(1);
  }
}

@keyframes brandEnter {
  from {
    opacity: 0;
    transform: translateY(-18%) scale(0.92);
    filter: blur(3px) brightness(0.92);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) brightness(1);
  }
}

@keyframes stageBaseSettle {
  from {
    transform: scale(1.025);
    filter: saturate(0.92) brightness(0.92);
  }

  to {
    transform: scale(1);
    filter: saturate(1) brightness(1);
  }
}

@keyframes stageShine {
  0% {
    opacity: 0;
    transform: translateX(-62%);
  }

  18%,
  62% {
    opacity: 0.72;
  }

  100% {
    opacity: 0;
    transform: translateX(62%);
  }
}

@keyframes popupFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-0.9%) scale(1.006);
  }
}

@keyframes popupControlEnter {
  from {
    opacity: 0;
    transform: translateY(10%) scale(0.86);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes closeFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-35%) scale(1.006);
  }
}

@keyframes pointerEnter {
  from {
    opacity: 0;
    transform: translate(8%, 10%) scale(0.82) rotate(-12deg);
    filter: blur(2px) brightness(0.95);
  }

  to {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(-8deg);
    filter: blur(0) brightness(1);
  }
}

@keyframes pointerTap {
  0%,
  44%,
  100% {
    transform: translate(0, 0) scale(1) rotate(-8deg);
    filter: brightness(1);
  }

  56% {
    transform: translate(2%, 2.5%) scale(0.86) rotate(-8deg);
    filter: brightness(0.96);
  }

  70% {
    transform: translate(-1%, -1%) scale(1.08) rotate(-8deg);
    filter: brightness(1.1);
  }
}

@keyframes ctaPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.045);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-bg,
  .hero-poster,
  .brand-name,
  .stage::before,
  .stage.popup-open .popup-img,
  .stage.popup-open .pointer-img,
  .stage.popup-open .popup-close-ring,
  .stage.popup-open .receive-hotspot {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .stage::before {
    opacity: 0;
  }

  .dl-prompt .dl-card,
  .dl-prompt.is-top .dl-card {
    transform: none;
  }

  .dl-again.is-waiting::after {
    display: none;
  }
}
