/* ==========================================================================
   You get one click.
   Near black, warm amber light, one object on the screen.
   ========================================================================== */

:root {
  --bg: #060505;
  --fg: #f8f6f1;
  --muted: #9d968b;
  --dim: #8f887d;
  --gold: #ffc44d;
  --gold-deep: #f0a020;
  --warn: #ffa183;

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }
.no-script { position: fixed; inset: 40% 20px auto; text-align: center; z-index: 4; background: var(--bg); }

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Moving light ----------------------------------------------------------
   Five soft amber fields: one behind the button, one in each corner. They
   drift on different clocks so the background never repeats visibly.
   -------------------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #040303;
}

.glow {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

.glow--core {
  left: 50%;
  top: 46%;
  width: 58vmax;
  height: 58vmax;
  margin: -29vmax 0 0 -29vmax;
  background: radial-gradient(
    circle,
    rgba(255, 168, 36, 0.16) 0%,
    rgba(255, 132, 12, 0.06) 38%,
    rgba(255, 120, 0, 0) 64%
  );
  animation: drift-core 23s ease-in-out infinite;
}

.glow--tl {
  top: -15vmax;
  left: -13vmax;
  width: 42vmax;
  height: 42vmax;
  background: radial-gradient(circle, rgba(255, 199, 84, 0.32) 0%, rgba(255, 199, 84, 0.13) 34%, rgba(255, 199, 84, 0) 72%);
  animation: drift-a 27s ease-in-out infinite;
}

.glow--tr {
  top: -18vmax;
  right: -15vmax;
  width: 46vmax;
  height: 46vmax;
  background: radial-gradient(circle, rgba(255, 134, 18, 0.3) 0%, rgba(255, 134, 18, 0.12) 34%, rgba(255, 134, 18, 0) 72%);
  animation: drift-b 33s ease-in-out infinite;
}

.glow--bl {
  bottom: -18vmax;
  left: -15vmax;
  width: 46vmax;
  height: 46vmax;
  background: radial-gradient(circle, rgba(255, 158, 28, 0.28) 0%, rgba(255, 158, 28, 0.11) 34%, rgba(255, 158, 28, 0) 72%);
  animation: drift-b 29s ease-in-out infinite reverse;
}

.glow--br {
  bottom: -15vmax;
  right: -13vmax;
  width: 40vmax;
  height: 40vmax;
  background: radial-gradient(circle, rgba(255, 214, 116, 0.26) 0%, rgba(255, 214, 116, 0.1) 34%, rgba(255, 214, 116, 0) 72%);
  animation: drift-a 25s ease-in-out infinite reverse;
}

@keyframes drift-core {
  0%,
  100% {
    transform: translate3d(-3%, -2%, 0) scale(1);
  }
  50% {
    transform: translate3d(3%, 3%, 0) scale(1.12);
  }
}

@keyframes drift-a {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(7vmax, 5vmax, 0) scale(1.14);
  }
}

@keyframes drift-b {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1.1);
  }
  50% {
    transform: translate3d(-6vmax, -5vmax, 0) scale(0.94);
  }
}

/* A pool of darkness under the text so the corners can stay bright. */
.vignette {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150vmax;
  height: 110vmax;
  margin: -55vmax 0 0 -75vmax;
  background: radial-gradient(
    closest-side,
    rgba(4, 3, 3, 0.72) 0%,
    rgba(4, 3, 3, 0.5) 34%,
    rgba(4, 3, 3, 0) 74%
  );
}

/* Layout ---------------------------------------------------------------- */

.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 4.4vh, 46px);
  padding: clamp(52px, 8.5vh, 96px) 24px clamp(100px, 13vh, 148px);
  text-align: center;
}

.views {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(300px, 46vh, 500px);
  width: 100%;
}

.view {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 620px;
}

.view--active {
  display: flex;
  animation: view-in 620ms var(--ease) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Type ------------------------------------------------------------------ */

.headline {
  margin: 0 0 clamp(30px, 5.6vh, 60px);
  font-size: clamp(2.2rem, min(8.4vw, 8vh), 4.6rem);
  font-weight: 800;
  line-height: 0.94;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  background: linear-gradient(178deg, #ffffff 10%, #d6cdba 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.warning {
  margin: clamp(28px, 5vh, 50px) 0 0;
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  color: var(--muted);
  letter-spacing: 0.01em;
}

.hint {
  margin: 18px 0 0;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}

.notice {
  margin: 14px 0 0;
  min-height: 20px;
  max-width: 34ch;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warn);
}

.notice:empty {
  margin: 0;
  min-height: 0;
}

/* The button ------------------------------------------------------------ */

.button-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(176px, min(54vw, 31vh), 268px);
  height: clamp(176px, min(54vw, 31vh), 268px);
}

.halo {
  position: absolute;
  inset: -14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 44, 0.4), rgba(255, 176, 44, 0) 62%);
  filter: blur(14px);
  animation: halo-breathe 4.6s ease-in-out infinite;
}

@keyframes halo-breathe {
  0%,
  100% {
    transform: scale(0.94);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.07);
    opacity: 1;
  }
}

.click-button {
  position: relative;
  width: clamp(146px, min(44vw, 25.5vh), 220px);
  height: clamp(146px, min(44vw, 25.5vh), 220px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform 260ms var(--ease);
}

.click-button__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 26%, #fffdf6 0%, #ffeec0 44%, #e6b95f 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 -14px 26px rgba(150, 92, 10, 0.3) inset,
    0 24px 62px rgba(255, 160, 30, 0.42),
    0 0 0 1px rgba(255, 232, 176, 0.24);
  transition:
    transform 260ms var(--ease),
    box-shadow 260ms var(--ease);
}

.click-button__text {
  font-size: clamp(0.95rem, 3.2vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #2a1c05;
  transform: translateX(0.12em);
}

/* A ring that keeps drawing attention to the button. */
.click-button::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 196, 77, 0.55);
  animation: ring-pulse 3.4s var(--ease) infinite;
  pointer-events: none;
}

@keyframes ring-pulse {
  0% {
    transform: scale(0.96);
    opacity: 0.75;
  }
  70% {
    transform: scale(1.24);
    opacity: 0;
  }
  100% {
    transform: scale(1.24);
    opacity: 0;
  }
}

@media (hover: hover) {
  .click-button:hover:not(:disabled) .click-button__face {
    transform: scale(1.035);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 -14px 26px rgba(150, 92, 10, 0.26) inset,
      0 28px 82px rgba(255, 170, 40, 0.62),
      0 0 0 1px rgba(255, 240, 200, 0.34);
  }
}

.click-button:active:not(:disabled) .click-button__face {
  transform: scale(0.94);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 -6px 18px rgba(150, 92, 10, 0.42) inset,
    0 10px 26px rgba(255, 160, 30, 0.38),
    0 0 0 1px rgba(255, 232, 176, 0.2);
}

.click-button:disabled {
  cursor: default;
}

.click-button.is-spent .click-button__face {
  transform: scale(0.9);
  opacity: 0.5;
}

.click-button.is-spent::after {
  animation: none;
  opacity: 0;
}

/* Ripple on the button, made by app.js. */
.ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 226, 160, 0.9);
  pointer-events: none;
  animation: ripple-out 900ms var(--ease) forwards;
}

@keyframes ripple-out {
  from {
    transform: scale(1);
    opacity: 0.9;
  }
  to {
    transform: scale(2.7);
    opacity: 0;
  }
}

/* Confetti -------------------------------------------------------------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  left: 50%;
  top: 50%;
  will-change: transform, opacity;
  animation: confetti-travel var(--dur) cubic-bezier(0.18, 0.62, 0.36, 1) var(--delay) forwards;
}

.confetti-shape {
  display: block;
  width: var(--w);
  height: var(--h);
  background: var(--c);
  border-radius: var(--r);
  animation: confetti-flutter var(--spin) linear var(--delay) infinite;
}

@keyframes confetti-travel {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 0;
  }
  7% {
    opacity: 1;
  }
  32% {
    transform: translate3d(calc(var(--dx) * 0.42), var(--peak), 0);
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--dx), var(--dy), 0);
    opacity: 0;
  }
}

@keyframes confetti-flutter {
  0% {
    transform: rotate(0deg) scaleX(1);
  }
  50% {
    transform: rotate(var(--half-rot)) scaleX(0.25);
  }
  100% {
    transform: rotate(var(--rot)) scaleX(1);
  }
}

/* Spent state ----------------------------------------------------------- */

.done-lead {
  margin: 0;
  font-size: clamp(1rem, 3.4vw, 1.35rem);
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
}

.done-ordinal {
  margin: 10px 0 0;
  font-size: clamp(3.4rem, 17vw, 8rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(174deg, #fff8e6 6%, #ffc44d 104%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 14px 50px rgba(255, 168, 40, 0.42));
  animation: ordinal-in 900ms var(--ease) both;
  max-width: 100%;
  white-space: nowrap;
}

/* Painted with its own colour on purpose: `opacity` here would create a
   compositing group and lose the parent's clipped gradient, which made the
   character disappear entirely. */
.done-ordinal__hash {
  color: rgba(255, 214, 130, 0.62);
  font-size: 0.58em;
  font-weight: 600;
  letter-spacing: 0;
  padding-right: 0.04em;
}

@keyframes ordinal-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.done-note {
  margin: clamp(28px, 5vh, 44px) 0 0;
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  color: var(--muted);
}

/* With the click spent, the number owns the middle of the screen. */
body.is-done .stage {
  padding-top: clamp(100px, 13vh, 148px);
}

/* Centred with left/right rather than a transform, because `.live` already
   runs a transform animation of its own. */
body.is-done .live {
  position: fixed;
  left: 0;
  right: 0;
  bottom: clamp(94px, 12vh, 132px);
  margin: 0;
  z-index: 2;
}

/* Error ----------------------------------------------------------------- */

.error-message {
  margin: 0 0 30px;
  max-width: 34ch;
  font-size: clamp(0.95rem, 2.8vw, 1.05rem);
  line-height: 1.6;
  color: var(--muted);
}

.error-message strong {
  color: var(--fg);
  font-weight: 600;
}

.ghost-button {
  padding: 13px 26px;
  border: 1px solid rgba(255, 226, 160, 0.28);
  border-radius: 4px;
  background: rgba(255, 196, 77, 0.07);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 200ms var(--ease),
    border-color 200ms var(--ease),
    transform 200ms var(--ease);
}

.ghost-button:hover {
  background: rgba(255, 196, 77, 0.14);
  border-color: rgba(255, 226, 160, 0.55);
}

.ghost-button:active {
  transform: scale(0.97);
}

/* Live global counter --------------------------------------------------- */

.live {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  animation: view-in 700ms var(--ease) both;
}

.live__value {
  font-size: clamp(1.6rem, 5.4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.live__label,
.corner__label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--dim);
}

/* Corners --------------------------------------------------------------- */

.corners {
  position: fixed;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 34px);
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
  /* Keeps the corners readable if a very short viewport pushes the main
     content down behind them. */
  background: linear-gradient(to top, rgba(6, 5, 5, 0.94) 42%, rgba(6, 5, 5, 0));
}

.corner {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: auto;
}

.corner--brand {
  align-items: flex-end;
  text-align: right;
}

.corner__value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(248, 246, 241, 0.84);
}

.corner__link {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 196, 77, 0.5);
  padding-bottom: 1px;
  transition:
    color 200ms var(--ease),
    border-color 200ms var(--ease);
}

.corner__link:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* Loading spinner ------------------------------------------------------- */

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 226, 160, 0.16);
  border-top-color: rgba(255, 196, 77, 0.85);
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* Accessibility --------------------------------------------------------- */

:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 6px;
  border-radius: 4px;
}

.click-button:focus-visible {
  outline-offset: 10px;
}

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

/* Mobile ---------------------------------------------------------------- */

@media (max-width: 600px) {
  .stage {
    padding: clamp(48px, 7vh, 72px) 20px clamp(126px, 18vh, 168px);
    gap: clamp(20px, 3.6vh, 34px);
  }

  body.is-done .stage {
    padding-top: clamp(126px, 18vh, 168px);
  }

  body.is-done .live {
    bottom: clamp(124px, 17vh, 156px);
  }

  .corners {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }

  .corner,
  .corner--brand {
    align-items: center;
    text-align: center;
  }

  .corner--brand {
    flex-direction: row;
    gap: 7px;
  }
}

/* Short viewports: scale the experience down so the fixed corners never
   collide with the centre of the page. */
@media (max-height: 720px) {
  .stage {
    padding-top: 44px;
    padding-bottom: 124px;
    gap: 20px;
  }

  body.is-done .stage {
    padding-top: 124px;
  }

  body.is-done .live {
    bottom: 118px;
  }

  .views {
    min-height: 0;
  }

  .headline {
    margin-bottom: 26px;
    font-size: clamp(1.9rem, 6.2vw, 3rem);
  }

  .button-shell {
    width: clamp(156px, 40vw, 210px);
    height: clamp(156px, 40vw, 210px);
  }

  .click-button {
    width: clamp(132px, 33vw, 172px);
    height: clamp(132px, 33vw, 172px);
  }

  .warning {
    margin-top: 22px;
  }

  .live__value {
    font-size: 1.45rem;
  }

  .done-ordinal {
    font-size: clamp(2.8rem, 13vw, 5.6rem);
  }

  .done-note {
    margin-top: 22px;
  }
}

/* Motion ---------------------------------------------------------------- */

/* On landscape phones, keep the result and total in document flow. */
@media (max-height: 540px) {
  body.is-done .stage { padding-top: 44px; padding-bottom: 124px; }
  body.is-done .live { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .glow,
  .halo,
  .click-button::after {
    animation: none;
  }

  .halo {
    opacity: 0.85;
  }

  .click-button::after {
    opacity: 0.6;
  }
}
