.angel-devil-page .store-layout--catalog-only {
  padding-bottom: 2rem;
}

.ad-root {
  max-width: 56rem;
  margin: 0 auto;
}

.ad-root.legal-card .muted-copy {
  color: var(--text-muted, #666666);
}

.ad-title {
  margin: 0;
}

.ad-form {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.3rem 0.6rem;
  align-items: center;
}

.ad-label {
  font-weight: 600;
  margin: 0;
  font-size: 0.92rem;
}

.ad-form .text-control {
  height: 1.9rem;
  min-height: 1.9rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.ad-form .ad-actions {
  grid-column: 1 / -1;
}

.ad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.55rem;
}

.ad-actions .primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

/* Sit next to each other so Reset is obvious (global .secondary-button is width: 100%). */
.angel-devil-page .ad-actions .primary-button,
.angel-devil-page .ad-actions .secondary-button {
  flex: 1 1 140px;
  width: auto;
  min-width: 0;
  max-width: none;
}

.angel-devil-page .ad-actions .secondary-button {
  color: #2f2b46;
  font-weight: 700;
  border: 1px solid rgba(110, 112, 150, 0.45);
  background: linear-gradient(180deg, #f3f2f8 0%, #dddced 100%);
  text-shadow: none;
}

.angel-devil-page .ad-actions .secondary-button:disabled {
  color: #4f4a67;
  opacity: 0.95;
  background: linear-gradient(180deg, #eceaf7 0%, #d8d5e9 100%);
  border-color: rgba(108, 109, 142, 0.42);
}

.ad-error {
  margin-top: 0.8rem;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 120, 120, 0.46);
  background: rgba(120, 30, 35, 0.15);
  color: #7e131d;
}

.ad-stage {
  position: relative;
  margin-top: 1.2rem;
  width: 100%;
  aspect-ratio: 16 / 13;
  min-height: 520px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 110%, rgba(180, 220, 245, 0.55) 0%, rgba(150, 200, 235, 0) 65%),
    linear-gradient(180deg, #cfeaff 0%, #a5d2f5 45%, #7fb9ea 100%);
  border: 1px solid rgba(120, 170, 215, 0.45);
  isolation: isolate;
}

.ad-sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(2px 2px at 18% 20%, rgba(255, 255, 255, 0.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 32% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(2px 2px at 64% 18%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 80% 26%, rgba(255, 255, 255, 0.4), transparent 60%);
  opacity: 0.55;
}

.ad-cloud {
  position: absolute;
  top: 8%;
  width: 28%;
  height: 8%;
  border-radius: 999px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 80%);
  filter: blur(6px);
}

.ad-cloud--1 {
  left: -6%;
  animation: adCloudDrift 38s linear infinite;
}

.ad-cloud--2 {
  top: 18%;
  left: 30%;
  width: 22%;
  height: 7%;
  opacity: 0.7;
  animation: adCloudDrift 52s linear infinite;
}

.ad-cloud--3 {
  top: 26%;
  left: 60%;
  width: 30%;
  height: 7%;
  opacity: 0.6;
  animation: adCloudDrift 46s linear infinite reverse;
}

.ad-being-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.ad-being {
  position: absolute;
  /* --ad-y is the Y of the BEING'S FEET inside the stage (top: 0 at stage top). */
  top: var(--ad-y, 60%);
  /* Always horizontally centered until --ad-slide / animation moves toward the landing box */
  left: 50%;
  /* Anchor feet on the landing line; horizontal offset from stage center (--ad-slide, set by JS/CSS). */
  transform: translate(calc(-50% + var(--ad-slide, 0px)), -100%);
  width: max-content;
  max-width: none;
  background: none;
  border: none;
  filter: none;
  overflow: visible;
  user-select: none;
  pointer-events: none;
}

.ad-being.is-descending {
  animation: adSlideToTarget var(--ad-desc-duration, 18s)
    cubic-bezier(0.32, 0.05, 0.28, 1) forwards;
}

.ad-being.hidden {
  display: none;
}

.ad-being-float {
  transform: translateY(-720px);
  transform-origin: center bottom;
  will-change: transform;
}

.ad-being-wing-flap {
  transform-origin: 50% 42%;
  will-change: transform;
}

.ad-being.is-descending .ad-being-wing-flap {
  animation: adWingFlap 360ms ease-in-out infinite;
}

/* Much slower descent so the being floats down with suspense (~18s). */
.ad-being-float.is-descending {
  animation: adDescendY var(--ad-desc-duration, 18s) cubic-bezier(0.32, 0.05, 0.28, 1) forwards;
}

.ad-being-float.is-descending .ad-being-img {
  animation: adDescendSway var(--ad-desc-duration, 18s) ease-in-out 1 forwards;
}

/* After landing: smaller, centered on pagoda roof only */
.ad-being.is-perched .ad-being-img {
  width: clamp(64px, 15vw, 100px);
  transform: none;
  animation: none;
}

.ad-being.is-perched .ad-being-wing-flap {
  animation: none;
  transform: none;
}

.ad-being-img {
  display: block;
  width: clamp(120px, 22vw, 200px);
  height: auto;
  user-select: none;
  pointer-events: none;
  vertical-align: top;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.38));
}

.ad-being--angel .ad-being-img {
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.38)) drop-shadow(0 0 20px rgba(255, 240, 200, 0.45));
}

.ad-being--devil .ad-being-img {
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, 0.38)) drop-shadow(0 0 20px rgba(255, 90, 90, 0.42));
}

.ad-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 0.75rem 0.85rem 1rem;
  background: linear-gradient(180deg, rgba(127, 185, 234, 0) 0%, rgba(80, 145, 200, 0.25) 100%);
  z-index: 2;
}

.ad-box {
  position: relative;
  overflow: visible;
  min-height: 150px;
  --ad-roof-h: 2.15rem;
  /* Roof lives in top padding so labels stay fully readable */
  padding: 2.35rem 0.75rem 0.95rem;
  border-radius: 12px;
  border: 2px solid rgba(165, 42, 42, 0.55);
  background:
    linear-gradient(90deg, rgba(184, 134, 11, 0.22) 0, rgba(184, 134, 11, 0.08) 5px, transparent 6px) 0 0 / 100% 100% no-repeat,
    linear-gradient(270deg, rgba(184, 134, 11, 0.22) 0, rgba(184, 134, 11, 0.08) 5px, transparent 6px) 100% 0 / 100% 100% no-repeat,
    linear-gradient(180deg, #f4fbff 0%, #d8ecf7 42%, #9ec9e8 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #173d5e;
  box-shadow:
    0 6px 14px rgba(40, 80, 120, 0.25),
    inset 0 -6px 0 rgba(120, 74, 36, 0.22);
  transition: transform 240ms ease, box-shadow 240ms ease, border-color 240ms ease;
}

/* Pagoda-style upturned eaves + tier hint (does not use ::after — reserved for land flash) */
.ad-box::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2.15rem;
  pointer-events: none;
  z-index: 0;
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 248, 220, 0.55) 0%, transparent 65%) 50% 0.12rem / 34% 0.42rem no-repeat,
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, transparent 40%) 0 100% / 100% 45% no-repeat,
    linear-gradient(180deg, #c93a3a 0%, #8f1e1e 52%, #c9a227 52%, #c9a227 56%, #6d1414 56%, #4a0d0d 100%);
  clip-path: polygon(
    0% 100%,
    0% 58%,
    6% 48%,
    44% 14%,
    50% 6%,
    56% 14%,
    94% 48%,
    100% 58%,
    100% 100%
  );
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.18));
}

.ad-ground .ad-box:nth-child(1)::before {
  background:
    linear-gradient(180deg, rgba(255, 248, 220, 0.55) 0%, transparent 65%) 50% 0.12rem / 34% 0.42rem no-repeat,
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, transparent 40%) 0 100% / 100% 45% no-repeat,
    linear-gradient(180deg, #b91c1c 0%, #7f1d1d 52%, #d4af37 52%, #d4af37 56%, #5c1010 56%, #3d0a0a 100%);
}

.ad-ground .ad-box:nth-child(2)::before {
  background:
    linear-gradient(180deg, rgba(220, 255, 235, 0.5) 0%, transparent 65%) 50% 0.12rem / 34% 0.42rem no-repeat,
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, transparent 40%) 0 100% / 100% 45% no-repeat,
    linear-gradient(180deg, #1b6b3d 0%, #0f3d24 52%, #c9a227 52%, #c9a227 56%, #0a2e18 56%, #061f10 100%);
}

.ad-ground .ad-box:nth-child(3)::before {
  background:
    linear-gradient(180deg, rgba(255, 235, 200, 0.55) 0%, transparent 65%) 50% 0.12rem / 34% 0.42rem no-repeat,
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, transparent 40%) 0 100% / 100% 45% no-repeat,
    linear-gradient(180deg, #b45309 0%, #7c2d12 52%, #e8c547 52%, #e8c547 56%, #4a1a0a 56%, #301008 100%);
}

.ad-box-tag {
  position: relative;
  z-index: 1;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #305f87;
  margin-bottom: 0.25rem;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.ad-box-text {
  position: relative;
  z-index: 1;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  word-break: break-word;
  max-width: 100%;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.ad-box-pad {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 70%;
  height: 8px;
  transform: translateX(-50%);
  z-index: 1;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 80%);
  filter: blur(2px);
}

.ad-box.is-target {
  transform: translateY(-3px);
  border-color: rgba(245, 200, 90, 0.95);
  box-shadow:
    0 10px 22px rgba(40, 80, 120, 0.35),
    0 0 18px rgba(255, 215, 120, 0.55),
    inset 0 -6px 0 rgba(120, 74, 36, 0.22);
}

.ad-box.is-target.is-devil {
  border-color: rgba(220, 80, 80, 0.95);
  box-shadow:
    0 10px 22px rgba(40, 80, 120, 0.35),
    0 0 18px rgba(255, 110, 110, 0.55),
    inset 0 -6px 0 rgba(120, 74, 36, 0.22);
}

.ad-box.is-landed::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140%;
  height: 140%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 2;
  background: radial-gradient(closest-side, rgba(255, 230, 170, 0.55), rgba(255, 230, 170, 0) 70%);
  animation: adLandFlash 900ms ease-out forwards;
  pointer-events: none;
}

.ad-box.is-landed.is-devil::after {
  background: radial-gradient(closest-side, rgba(255, 130, 110, 0.55), rgba(255, 130, 110, 0) 70%);
}

.ad-status {
  margin: 0.9rem 0 0;
}

.ad-result {
  margin: 0.25rem 0 0;
  font-weight: 700;
  font-size: 1.05rem;
  color: #1f4267;
}

.ad-result.is-angel {
  color: #8a5a10;
}

.ad-result.is-devil {
  color: #9a1a22;
}

@keyframes adCloudDrift {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(140%);
  }
}

@keyframes adDescendY {
  0% {
    transform: translateY(-720px) scale(0.78);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  93% {
    transform: translateY(-10px) scale(0.97);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Random sway only through mid-descent; final segment is glide to box from center → no spoilers */
@keyframes adDescendSway {
  0% {
    transform: translateX(0) rotate(0deg);
  }
  12% {
    transform: translateX(var(--ad-sx1, -24px)) rotate(var(--ad-sr1, -10deg));
  }
  26% {
    transform: translateX(var(--ad-sx2, 28px)) rotate(var(--ad-sr2, 12deg));
  }
  40% {
    transform: translateX(var(--ad-sx3, -20px)) rotate(var(--ad-sr3, -8deg));
  }
  54% {
    transform: translateX(var(--ad-sx4, 22px)) rotate(var(--ad-sr4, 9deg));
  }
  66% {
    transform: translateX(var(--ad-sx5, -14px)) rotate(var(--ad-sr5, -6deg));
  }
  70%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
}

@keyframes adWingFlap {
  0% {
    transform: rotate(0deg) scaleX(1);
  }
  45% {
    transform: rotate(-2.4deg) scaleX(0.94);
  }
  100% {
    transform: rotate(0deg) scaleX(1);
  }
}

/* Glide from horizontal center toward landing box feet position (runs on .ad-being, same duration as vertical fall). */
@keyframes adSlideToTarget {
  0%,
  71% {
    transform: translate(calc(-50% + 0px), -100%);
  }
  100% {
    transform: translate(calc(-50% + var(--ad-slide-end, 0px)), -100%);
  }
}

@keyframes adLandFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

@media (max-width: 640px) {
  .ad-stage {
    aspect-ratio: auto;
    min-height: 640px;
  }

  /* Keep three ground boxes in one row (same as desktop); narrow columns need tighter type */
  .ad-ground {
    gap: 0.45rem;
    padding: 0.65rem 0.45rem 0.85rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ad-box {
    min-height: 108px;
    --ad-roof-h: 1.65rem;
    padding: 1.85rem 0.32rem 0.72rem;
  }

  .ad-box::before {
    height: 1.65rem;
    clip-path: polygon(
      0% 100%,
      0% 62%,
      7% 50%,
      45% 16%,
      50% 8%,
      55% 16%,
      93% 50%,
      100% 62%,
      100% 100%
    );
  }

  .ad-box-tag {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
  }

  .ad-box-text {
    font-size: 0.8rem;
    line-height: 1.25;
  }

  .ad-form {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ad-cloud,
  .ad-being.is-descending,
  .ad-being-float.is-descending,
  .ad-being-float.is-descending .ad-being-img,
  .ad-being.is-descending .ad-being-wing-flap {
    animation: none !important;
  }

  .ad-being.is-descending {
    transform: translate(calc(-50% + var(--ad-slide-end, 0px)), -100%);
  }

  .ad-being-float.is-descending {
    transform: translateY(0);
    opacity: 1;
  }

  .ad-box.is-landed::after {
    animation: none !important;
    opacity: 0;
  }
}
