/* ARARA gameplay identity and optional AdsGram block.
   Loaded after the legacy clicker styles so the uploaded character is the
   single source of truth for the tap screen. */

/* Disable the previous WebP character that was painted through ::after. */
.tap-button::after {
  content: none !important;
  display: none !important;
  background: none !important;
}

.tap-button__arara {
  position: absolute;
  z-index: 3;
  width: auto;
  max-width: none;
  height: 108%;
  left: 50%;
  bottom: 1%;
  object-fit: contain;
  object-position: 50% 100%;
  opacity: 0;
  visibility: hidden;
  translate: -50% 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 50% 82%;
  filter:
    saturate(1.08)
    contrast(1.04)
    drop-shadow(0 14px 16px rgba(0, 0, 0, .58))
    drop-shadow(0 0 15px rgba(126, 54, 225, .32));
  transition: opacity .16s ease, filter .1s ease;
  backface-visibility: hidden;
}

.tap-button.has-arara-avatar .tap-button__arara {
  opacity: 1;
  visibility: visible;
}

/* Hide all previous character experiments only after the uploaded PNG loaded. */
.tap-button.has-arara-avatar .tap-button__character,
.tap-button.has-arara-avatar .tap-button__hannya {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* The old stylesheet hid the fallback unconditionally. Restore it until the
   uploaded PNG has decoded, so the pedestal is never empty. */
.tap-button:not(.has-arara-avatar) .tap-button__character--idle {
  opacity: 1 !important;
  visibility: visible !important;
}

.tap-button:not(.has-arara-avatar) .tap-button__character--tap {
  opacity: 0 !important;
  visibility: hidden !important;
}

.tap-button:not(.has-arara-avatar).is-tapping .tap-button__character--idle {
  opacity: 1 !important;
  visibility: visible !important;
}

.tap-button:not(.has-arara-avatar).is-tapping .tap-button__character--tap {
  opacity: 1 !important;
  visibility: visible !important;
}

.tap-button.is-tapping .tap-button__arara {
  animation: arara-character-hit .24s cubic-bezier(.14, .78, .28, 1.32) both;
  filter:
    saturate(1.26)
    contrast(1.1)
    brightness(1.16)
    drop-shadow(0 17px 18px rgba(0, 0, 0, .6))
    drop-shadow(0 0 22px rgba(255, 208, 70, .72))
    drop-shadow(0 0 32px rgba(151, 58, 236, .68));
}

@keyframes arara-character-hit {
  0% { transform: scale(1) rotate(0); }
  32% { transform: translateY(8px) scale(.93) rotate(-1.1deg); }
  68% { transform: translateY(-5px) scale(1.045) rotate(.7deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Short comic-book word above ARARA on every accepted-looking tap. */
.tap-comic-word {
  position: fixed;
  z-index: 260;
  min-width: 92px;
  padding: 7px 14px 8px;
  border: 2px solid #f4c34e;
  border-radius: 13px 18px 12px 17px;
  background: linear-gradient(155deg, #19091f 0%, #3e1538 55%, #110716 100%);
  box-shadow:
    0 4px 0 #09030d,
    0 0 0 2px rgba(19, 5, 24, .9),
    0 0 20px rgba(245, 195, 78, .4),
    0 0 30px rgba(119, 49, 215, .35);
  color: #fff1ad;
  font-size: clamp(18px, 5.4vw, 25px);
  font-weight: 950;
  line-height: 1;
  letter-spacing: .035em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #5a1d24, 0 0 9px rgba(255, 222, 101, .48);
  white-space: nowrap;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: arara-comic-pop .64s cubic-bezier(.12, .78, .24, 1) both;
}

.tap-comic-word::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  left: 50%;
  bottom: -8px;
  border-right: 2px solid #f4c34e;
  border-bottom: 2px solid #f4c34e;
  background: #17091c;
  transform: translateX(-50%) rotate(45deg);
}

@keyframes arara-comic-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 14px) rotate(var(--comic-rotation, -2deg)) scale(.52);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, 0) rotate(var(--comic-rotation, -2deg)) scale(1.08);
  }
  65% {
    opacity: 1;
    transform: translate(calc(-50% + var(--comic-drift, 0px)), -7px) rotate(var(--comic-rotation, -2deg)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--comic-drift, 0px)), -22px) rotate(var(--comic-rotation, -2deg)) scale(.9);
  }
}

/* Existing +1 popup now represents the farmed resource explicitly. */
.tap-pop {
  min-width: 96px !important;
  font-size: 18px !important;
  letter-spacing: .025em;
  white-space: nowrap;
}

/* Optional AdsGram interstitial block. It stays hidden until ADSGRAM_BLOCK_ID
   is returned by /api/ads-config. */
.adsgram-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 15px 15px 14px;
  border: 1px solid rgba(241, 192, 72, .28);
  border-radius: 15px;
  background:
    linear-gradient(105deg, rgba(16, 14, 20, .96), rgba(31, 20, 34, .96)),
    repeating-linear-gradient(135deg, transparent 0 12px, rgba(255,255,255,.018) 12px 13px);
  box-shadow: inset 0 1px rgba(255,255,255,.055), 0 14px 30px rgba(0,0,0,.22);
}

.adsgram-card[hidden] { display: none !important; }

.adsgram-card::before {
  content: "AD";
  position: absolute;
  right: -4px;
  top: -13px;
  color: rgba(245, 199, 82, .055);
  font-size: 72px;
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.adsgram-card__copy {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.adsgram-card__copy > span {
  color: #d8ae49;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.adsgram-card__copy strong {
  margin-top: 4px;
  color: #fff5d1;
  font-size: 13px;
}

.adsgram-card__copy small {
  margin-top: 5px;
  color: #968d9b;
  font-size: 9px;
  line-height: 1.45;
}

.adsgram-card__button {
  position: relative;
  z-index: 1;
  min-width: 112px;
  min-height: 39px;
  padding: 0 13px;
  border: 1px solid #f2c558;
  border-radius: 10px;
  background: linear-gradient(180deg, #f4cf6c, #b87520);
  box-shadow: inset 0 1px rgba(255,255,255,.55), 0 6px 16px rgba(0,0,0,.28);
  color: #1d0d08;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.adsgram-card__button:active { transform: translateY(1px) scale(.98); }
.adsgram-card__button:disabled { opacity: .58; cursor: wait; }

.adsgram-card__status {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  min-height: 12px;
  margin-top: -3px;
  color: #857c89;
  font-size: 8px;
}

.adsgram-card__status.is-success { color: #9ed4a8; }
.adsgram-card__status.is-error { color: #e69a91; }

@media (max-width: 390px) {
  .tap-button__arara { height: 104%; }
  .adsgram-card { grid-template-columns: 1fr; }
  .adsgram-card__button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tap-button.is-tapping .tap-button__arara,
  .tap-comic-word {
    animation: none !important;
  }
}
