/* Effects & overlays: toasts, banners, countdown pops, confetti, reward pops, dialogs, pet hatch. */

.fx-layer { position: absolute; inset: 0; z-index: 20; overflow: hidden; pointer-events: none; }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--sat) + 176px * var(--u));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
@media (max-width: 720px) and (orientation: portrait) { .toasts { top: calc(var(--sat) + 210px); } }
.toast {
  max-width: 92vw;
  padding: 8px 18px;
  font: 700 calc(20px * var(--u)) / 1.2 var(--font);
  text-align: center;
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
  background: rgba(16, 22, 32, .72);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  animation: toast-in .3s cubic-bezier(.2, 1.5, .4, 1) both;
}
.toast.good { background: linear-gradient(180deg, #8af296, #2fc449); }
.toast.bad { background: linear-gradient(180deg, #ff8089, #e02435); }
.toast.out, .banner.out { animation: fade-out .35s ease forwards; }
@keyframes toast-in { from { transform: translateY(-14px) scale(.85); opacity: 0; } }
@keyframes fade-out { to { transform: translateY(-10px); opacity: 0; } }

/* ---------------------------------------------------------------- banners & countdown */
.banner {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 94vw;
  translate: -50% -50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  animation: banner-in .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes banner-in { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.banner-title {
  font: 700 calc(66px * var(--u)) / 1.02 var(--font);
  color: #fff;
  -webkit-text-stroke: .2em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .08em 0 var(--ink);
  overflow-wrap: anywhere;
}
.banner.bad .banner-title { color: #ff5a64; }
.banner.good .banner-title { color: #7ef08d; }
.banner.win .banner-title { color: #ffd84d; font-size: calc(78px * var(--u)); }
.banner-sub { font: 700 calc(26px * var(--u)) / 1.2 var(--font); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.banner.win::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  background: repeating-conic-gradient(rgba(255, 226, 110, .45) 0 10deg, transparent 10deg 20deg);
  border-radius: 50%;
  -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%);
  mask: radial-gradient(circle, #000 18%, transparent 68%);
  animation: spin 9s linear infinite;
}

.count-pop {
  position: absolute;
  left: 50%;
  top: 42%;
  translate: -50% -50%;
  font: 700 calc(150px * var(--u)) / 1 var(--font);
  color: #ffd84d;
  -webkit-text-stroke: .16em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .06em 0 var(--ink);
  animation: count-pop .95s ease-out both;
}
@keyframes count-pop {
  0% { transform: scale(2.2); opacity: 0; }
  20% { transform: scale(1); opacity: 1; }
  75% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.7); opacity: 0; }
}

/* ---------------------------------------------------------------- confetti & reward pop */
.confetti { position: absolute; inset: 0; overflow: hidden; }
.confetti i { position: absolute; top: -24px; border-radius: 2px; animation-name: confetti-fall; animation-timing-function: cubic-bezier(.3, .2, .6, 1); animation-fill-mode: both; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 112vh) rotate(var(--rot)); } }

.reward-pop {
  position: absolute;
  translate: -50% -100%;
  font: 700 36px / 1 var(--font);
  white-space: nowrap;
  color: #7ef08d;
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  animation: reward-rise 1.9s ease-out both;
}
@keyframes reward-rise {
  0% { transform: translateY(10px) scale(.5); opacity: 0; }
  15% { transform: translateY(0) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(-90px) scale(1); opacity: 0; }
}

/* ---------------------------------------------------------------- dialogs */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 16, 32, .5);
  pointer-events: auto;
  animation: fade-in .2s ease both;
}
.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(420px, 100%);
  padding: 22px 20px 20px;
  text-align: center;
  color: var(--ink);
  background: radial-gradient(circle at 16% 15%, #fff 0 6px, transparent 7px), radial-gradient(circle at 86% 26%, #fff9 0 13px, transparent 14px), linear-gradient(145deg, #fff8ce, #e4edff 48%, #f3dcff);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 7px 0 var(--ink), 0 20px 40px rgba(0, 0, 0, .3);
  animation: panel-in .3s cubic-bezier(.2, 1.4, .4, 1) both;
}
.overlay.leaving { animation: fade-out .18s ease-in forwards; pointer-events: none; }
.overlay.leaving .overlay-card { animation: popup-exit .18s ease-in forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes popup-exit { to { opacity: 0; transform: translateY(14px) scale(.9); } }
.choice-list { display: grid; gap: 7px; width: 100%; max-height: min(60dvh, 460px); overflow: auto; padding: 5px; }
.choice-list .btn { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; width:100%; min-height:49px; padding:7px 10px; white-space:normal; line-height:1.15; }
.choice-list .btn small { font:600 12px/1.2 var(--font); opacity:.9; text-wrap:balance; }
.overlay-title { font: 700 30px / 1.1 var(--font); }
.confirm-details { display: grid; gap: 9px; width: 100%; margin: 7px 0 10px; text-align: left; }
.confirm-detail { display: grid; gap: 2px; padding: 10px 14px; border: 2px solid #29304b22; border-radius: 14px; background: #ffffffb8; }
.confirm-detail.prominent { background: linear-gradient(110deg, #efe1ff, #fff3d1); border-color: #b76bff77; }
.confirm-detail.gold { background:#fff4d5; border-color:#e7bb59; }
.confirm-detail.green { background:#e2fae7; border-color:#6bc78c; }
.confirm-detail.purple { background:#f0e7ff; border-color:#b690ea; }
.confirm-detail.red { background:#ffe9eb; border-color:#ee929a; }
.confirm-detail.gold .confirm-detail-label { color:#aa6a1f; }
.confirm-detail.green .confirm-detail-label { color:#23824c; }
.confirm-detail.red .confirm-detail-label { color:#b9394c; }
.confirm-detail-label { color: #7454a5; font: 800 11px / 1.1 var(--font); letter-spacing: .11em; }
.confirm-detail-text { color: #2d3550; font: 700 16px / 1.28 var(--font); }
.confirm-detail.prominent .confirm-detail-text { font-size: 24px; }
.overlay-text { margin: 0; font: 600 16px / 1.4 var(--font); color: #4a5563; }
.overlay-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.overlay-emoji { font-size: 44px; line-height: 1; }
.overlay.busy .overlay-card { width: auto; min-width: 250px; }
.spinner { width: 58px; height: 58px; border: 7px solid #d6e4f5; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }

/* ---------------------------------------------------------------- pet hatch */
.overlay.hatch {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(circle at 50% 55%, rgba(60, 30, 110, .6), rgba(5, 8, 20, .88));
}
.hatch-title { font: 700 calc(38px * var(--u)) / 1 var(--font); text-align: center; }
.hatch-stage { position: relative; display: grid; place-items: center; width: min(340px, 90vw); height: 400px; }
.hatch-rays {
  position: absolute;
  inset: -90px;
  background: repeating-conic-gradient(color-mix(in srgb, var(--rc) 60%, transparent) 0 9deg, transparent 9deg 18deg);
  -webkit-mask: radial-gradient(circle, #000 12%, transparent 62%);
  mask: radial-gradient(circle, #000 12%, transparent 62%);
  opacity: 0;
  transition: opacity .4s;
  animation: spin 12s linear infinite;
}
.hatch.revealed .hatch-rays { opacity: 1; }
.hatch.revealed::after { content: ''; position: absolute; inset: 0; background: #fff; pointer-events: none; animation: flash .6s ease-out forwards; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }
.hatch-block {
  display: grid;
  place-items: center;
  width: 172px;
  height: 172px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--bc) 55%, white) 0%, var(--bc) 50%, color-mix(in srgb, var(--bc) 72%, black) 100%);
  border: 6px solid var(--ink);
  border-radius: 28px;
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, .4), inset 0 -10px 0 rgba(0, 0, 0, .2), 0 9px 0 var(--ink);
  animation: block-drop .55s cubic-bezier(.3, 1.5, .5, 1) both;
}
.hatch-q { font: 700 124px / 1 var(--font); color: #fff; -webkit-text-stroke: 18px var(--ink); paint-order: stroke fill; }
.hatch-block.shake1 { animation: hatch-shake .35s ease; }
.hatch-block.shake2 { animation: hatch-shake .22s ease 2; }
.hatch-block.shake3 { animation: hatch-shake-big .16s ease 3; }
@keyframes block-drop { from { transform: translateY(-60vh) rotate(-24deg); } }
@keyframes hatch-shake { 25% { transform: rotate(-9deg) scale(1.03); } 75% { transform: rotate(9deg) scale(1.03); } }
@keyframes hatch-shake-big { 25% { transform: rotate(-17deg) scale(1.12); } 75% { transform: rotate(17deg) scale(1.14); } }
.hatch-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(300px, 86vw);
  padding: 20px 18px 18px;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #eef4ff);
  border: 5px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 0 0 5px var(--rc), 0 0 70px 14px color-mix(in srgb, var(--rc) 75%, transparent), 0 9px 0 5px var(--ink);
  animation: card-burst .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes card-burst { from { transform: scale(.2) rotate(-12deg); opacity: 0; } }
.hatch-badge {
  position: absolute;
  top: -20px;
  right: -16px;
  padding: 6px 12px;
  font: 700 21px / 1 var(--font);
  background: linear-gradient(180deg, var(--yellow-hi), var(--yellow));
  border: 3px solid var(--ink);
  border-radius: 12px;
  transform: rotate(9deg);
}
.hatch-emoji { font-size: 112px; line-height: 1.05; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .2)); animation: emoji-bounce 1.3s ease-in-out infinite; }
@keyframes emoji-bounce { 50% { transform: translateY(-8px) rotate(-4deg); } }
.hatch-name { font: 700 40px / 1 var(--font); }
.hatch .pill { padding: .2em .8em; font-size: 16px; }
.hatch-ability { margin: 0 0 4px; font: 600 16px / 1.3 var(--font); color: #4a5563; }

.purchase-pop{position:absolute;left:50%;top:29%;transform:translateX(-50%);display:flex;align-items:center;gap:14px;width:max-content;max-width:calc(100vw - 30px);padding:14px 22px;border:4px solid #282435;border-radius:20px;background:linear-gradient(145deg,#fffacb,#ffe475 60%,#ffba52);box-shadow:0 6px 0 #282435,0 0 35px #ffd56b80;color:#302541;animation:purchase-pop-in .45s cubic-bezier(.2,1.6,.4,1) both;pointer-events:none}
.purchase-pop>div{display:flex;flex-direction:column;gap:5px;min-width:0}.purchase-pop strong{font-size:22px;line-height:1.1}.purchase-pop span{font-size:15px}.purchase-pop .purchase-pop-star{font-size:45px;color:#fff;text-shadow:0 2px 0 #d98b23;animation:purchase-star .6s ease both}.purchase-pop.out{opacity:0;transition:opacity .3s}
@keyframes purchase-pop-in{from{opacity:0;transform:translateX(-50%) translateY(18px) scale(.7)}to{opacity:1;transform:translateX(-50%) translateY(0) scale(1)}}
@keyframes purchase-star{from{transform:rotate(-80deg) scale(.4)}to{transform:rotate(0) scale(1)}}
@media(max-width:600px){.purchase-pop{top:27%;padding:12px 14px;gap:10px}.purchase-pop strong{font-size:18px}.purchase-pop span{font-size:13px}.purchase-pop .purchase-pop-star{font-size:35px}}
@media(prefers-reduced-motion:reduce){.purchase-pop,.purchase-pop .purchase-pop-star{animation:none}}
