@font-face {
  font-family: "Lemon";
  src: url("/fonts/Lemon-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --demo-sky: linear-gradient(180deg, #51b0f2 0%, #87cbf3 45%, #c6e4f4 100%);
  --ink: #2a1830;
  --pink: #ff5294;
  --card: rgba(255, 255, 255, 0.88);
  --font-display: "Lemon", "Trebuchet MS", sans-serif;
  --font-body: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: #51b0f2;
}

.demo {
  position: relative;
  height: 100svh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.25rem 0.65rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
  gap: 0.22rem;
  background: var(--demo-sky);
  overflow: hidden;
  box-sizing: border-box;
}

.demo.has-theme {
  background: transparent;
}

/* iOS bgLayer - theme wash + motion particles behind all chrome */
.demo__world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.demo > *:not(.demo__world):not(.demo__fx):not(.overlay) {
  position: relative;
  z-index: 1;
}

/* Sits above the board + goal so pop beads can travel into the progress bar */
.demo__fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.demo__top {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: start;
  min-height: 0;
  padding: 0.05rem 0.15rem 0.2rem;
  gap: 0.1rem 0;
}

.demo__back {
  justify-self: start;
  align-self: center;
  z-index: 2;
}

.demo__mute {
  justify-self: end;
  align-self: center;
  z-index: 2;
}

.demo__back,
.demo__mute {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 6px 16px rgba(40, 60, 100, 0.12);
  color: rgba(42, 24, 48, 0.88);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.demo__back:hover,
.demo__mute:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.78);
}

.demo__back span {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  margin-top: -1px;
}

.demo__brand {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: min(220px, calc(100% - 7.5rem));
  pointer-events: none;
  z-index: 1;
  padding-bottom: 0.15rem;
}

.demo__logo {
  height: clamp(40px, 9vw, 52px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(40, 20, 50, 0.12));
}

.demo__stage {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.25;
  text-transform: uppercase;
  color: rgba(42, 24, 48, 0.62);
  white-space: nowrap;
}

.demo__stage-sep {
  opacity: 0.45;
  font-weight: 400;
}

.demo__mute-icon {
  grid-area: 1 / 1;
  width: 1.2rem;
  height: 1.2rem;
  display: block;
  pointer-events: none;
}

/* Only one speaker glyph visible - do not rely on [hidden] alone */
.demo__mute .demo__mute-icon--off,
.demo__mute[aria-pressed="true"] .demo__mute-icon--on {
  display: none !important;
}

.demo__mute[aria-pressed="true"] .demo__mute-icon--off {
  display: block !important;
}

.demo__mute[aria-pressed="false"] .demo__mute-icon--on {
  display: block !important;
}

.demo__mute[aria-pressed="true"] {
  background: rgba(42, 24, 48, 0.78);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(40, 20, 50, 0.22);
}

.demo__hud {
  width: min(520px, 100%);
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
  padding: 0;
  box-sizing: border-box;
}

.pill {
  flex: 1 1 0;
  min-width: 0;
  background: var(--card);
  border-radius: 16px;
  padding: 0.45rem 0.65rem;
  box-shadow: 0 8px 20px rgba(40, 60, 100, 0.12);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.35rem;
}

.pill small {
  width: 100%;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
}

.pill strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
}

.pill em {
  font-style: normal;
  font-size: 0.85rem;
  opacity: 0.55;
}

/* Goal bar - equal air above (HUD) and below (board) */
.demo__goal {
  width: min(520px, 100%);
  flex: 0 0 auto;
  padding: 0 0.1rem;
  margin: 0.5rem 0;
}

.goal-track {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: rgba(107, 26, 61, 0.92);
  border: 1.2px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 2px 6px rgba(40, 60, 100, 0.14),
    inset 0 2px 4px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.goal-track::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 45%;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.32),
    rgba(255, 255, 255, 0)
  );
  pointer-events: none;
}

.goal-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff8cc7 0%, #ffa6d4 55%, #ffeb73 100%);
  box-shadow: 0 0 10px rgba(255, 180, 220, 0.6);
  /* back-out overshoot so the bar lands with a little pop */
  transition: width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.goal-track.is-absorb {
  animation: goal-absorb 0.28s ease-out;
}

@keyframes goal-absorb {
  0% {
    transform: scaleY(1);
    filter: brightness(1);
  }
  35% {
    transform: scaleY(1.5);
    filter: brightness(1.4);
  }
  100% {
    transform: scaleY(1);
    filter: brightness(1);
  }
}

.pill--score.is-pop {
  animation: chip-pop 0.24s ease-out;
}

.pill--score.is-pop strong {
  display: inline-block;
  animation: score-pop 0.24s ease-out;
}

@keyframes chip-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes score-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.34);
    color: var(--pink);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .goal-fill {
    transition: width 0.2s linear;
  }

  .goal-track.is-absorb,
  .pill--score.is-pop,
  .pill--score.is-pop strong {
    animation: none;
  }
}

.demo__board-wrap {
  width: min(520px, 100%);
  /* Size to the board - do not flex-grow or the board floats in empty padding */
  flex: 0 1 auto;
  display: grid;
  place-items: center;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

#board {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  touch-action: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  image-rendering: auto;
}

.demo__help {
  width: min(520px, 100%);
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.25;
  color: rgba(42, 24, 48, 0.78);
}

.demo__powers {
  width: min(520px, 100%);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.28rem;
  padding: 0;
  margin: 0;
  z-index: 7;
}

.power-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: 56px;
  padding: 0.28rem 0.2rem 0.22rem;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(40, 60, 100, 0.12);
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.power-slot img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

.power-slot__count {
  position: absolute;
  top: 4px;
  right: 6px;
  min-width: 1.15rem;
  padding: 0.05rem 0.28rem;
  border-radius: 999px;
  background: rgba(42, 24, 48, 0.88);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.power-slot__label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}

.power-slot:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 82, 148, 0.55);
}

.power-slot.is-armed {
  border-color: #ff5294;
  box-shadow:
    0 0 0 2px rgba(255, 82, 148, 0.35),
    0 10px 20px rgba(40, 60, 100, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.power-slot.is-locked {
  opacity: 0.42;
  filter: grayscale(0.85);
  cursor: not-allowed;
}

.power-slot.is-empty:not(.is-locked) {
  opacity: 0.72;
}

.power-slot:disabled {
  cursor: not-allowed;
}

.demo.is-placing .demo__board-wrap {
  outline: 2px dashed rgba(255, 82, 148, 0.55);
  outline-offset: 4px;
  border-radius: 12px;
}

.demo__disclaimer {
  width: min(520px, 100%);
  flex: 0 0 auto;
  margin: 0;
  text-align: center;
  font-size: 0.65rem;
  line-height: 1.3;
  color: rgba(42, 24, 48, 0.62);
}

.demo .app-store-soon-row {
  flex: 0 0 auto;
}

/* Desktop only - free vertical space for a larger board on phones */
@media (max-width: 720px) {
  .demo .app-store-soon-row {
    display: none;
  }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(12, 10, 20, 0.55);
  backdrop-filter: blur(6px);
}

.overlay.hidden {
  display: none;
}

.overlay__card {
  width: min(420px, 100%);
  text-align: center;
  padding: 1.6rem 1.25rem 1.35rem;
  border-radius: 28px;
  background: #12121a;
  color: #f6f2f7;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.overlay__card img {
  margin: 0 auto 0.85rem;
  display: block;
  border-radius: 22px;
}

.overlay__card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 400;
}

.overlay__card p {
  margin: 0.7rem 0 0;
  color: rgba(246, 242, 247, 0.78);
  line-height: 1.45;
  font-size: 0.95rem;
}

.overlay__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-top: 1.25rem;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 0;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1rem;
  cursor: pointer;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}

.btn--primary {
  background: linear-gradient(180deg, #ff6aa3 0%, #ff5294 42%, #f26bb8 100%);
  border: 2.4px solid #c73a72;
  box-shadow:
    0 12px 24px rgba(242, 89, 140, 0.35),
    inset 0 -7px 0 rgba(120, 20, 60, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn--primary::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 46%;
  height: 58%;
  border-radius: 0 999px 0 70%;
  background: radial-gradient(
    ellipse 90% 80% at 88% 18%,
    rgba(255, 252, 245, 0.98) 0%,
    rgba(255, 250, 240, 0.72) 28%,
    rgba(255, 255, 255, 0.18) 52%,
    transparent 72%
  );
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 1;
}

.btn--primary::after {
  content: "";
  position: absolute;
  top: 16%;
  right: 11%;
  width: 0.85rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.95);
  transform: rotate(-32deg);
  box-shadow: 0 0 6px 1px rgba(255, 252, 245, 0.7);
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 2;
}

.btn--ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}

.btn--ghost::before,
.btn--ghost::after {
  display: none;
}

.btn--secondary {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.btn--secondary::before,
.btn--secondary::after {
  display: none;
}

@media (max-width: 520px) {
  .demo {
    padding: 0.28rem 0.5rem calc(0.28rem + env(safe-area-inset-bottom, 0px));
    gap: 0.28rem;
  }

  .demo__top {
    padding-bottom: 0.28rem;
  }

  .demo__logo {
    height: clamp(30px, 7vw, 40px);
  }

  .demo__stage {
    font-size: 0.64rem;
    line-height: 1.3;
  }

  .demo__brand {
    gap: 0.3rem;
  }

  .demo__hud {
    gap: 0.35rem;
  }

  .pill {
    padding: 0.22rem 0.4rem;
    border-radius: 10px;
    gap: 0.1rem 0.25rem;
    box-shadow: 0 4px 12px rgba(40, 60, 100, 0.1);
  }

  .pill small {
    font-size: 0.55rem;
    letter-spacing: 0.05em;
  }

  .pill strong {
    font-size: 0.95rem;
    line-height: 1.05;
  }

  .pill em {
    font-size: 0.72rem;
  }

  .demo__goal {
    margin: 0.28rem 0;
  }

  .goal-track {
    height: 10px;
  }

  .demo__help {
    font-size: 0.68rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

@media (max-height: 720px) {
  .demo__help {
    display: none;
  }
}
