.hatch-gate,
.evolution-event {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 24px;
  overflow: hidden;
  color: #fff8f5;
  text-align: center;
  background:
    radial-gradient(circle at 50% 56%, rgba(237, 12, 39, .28), transparent 27%),
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.10) 1px, transparent 1.5px),
    linear-gradient(145deg, #19060b, #040405 55%, #08101a);
  background-size: auto, 9px 9px, auto;
}

.hatch-gate::before,
.hatch-gate::after {
  content: "";
  position: absolute;
  inset: -20%;
  pointer-events: none;
}

.hatch-gate::before {
  background: repeating-conic-gradient(from 11deg, transparent 0 13deg, rgba(242,13,39,.09) 14deg 15deg);
  animation: hatch-rays 16s linear infinite;
}

.hatch-gate::after {
  opacity: 0;
  background: #fff;
}

.hatch-aura {
  position: absolute;
  left: 50%;
  top: 55%;
  width: min(76vw, 460px);
  aspect-ratio: 1;
  border: 2px solid rgba(242,13,39,.32);
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(242,13,39,.22), inset 0 0 55px rgba(21,117,244,.11);
  transform: translate(-50%, -50%);
  animation: hatch-aura 2.8s steps(5, end) infinite;
}

.hatch-eyebrow,
.hatch-title,
.hatch-instruction,
.hatch-egg,
.hatch-counter,
.hatch-hint { position: relative; z-index: 2; }

.hatch-eyebrow {
  margin: 0 0 8px;
  color: #ff6847;
  font: 800 10px/1 monospace;
  letter-spacing: .24em;
}

.hatch-title {
  margin: 0;
  font: italic 950 clamp(25px, 7vw, 48px)/1 monospace;
  letter-spacing: -.07em;
  text-shadow: -4px 2px #1575f4, 4px -2px #e40025;
}

.hatch-instruction {
  max-width: 430px;
  margin: 12px 0 2px;
  color: #b9b0b5;
  font-size: clamp(13px, 3vw, 16px);
}

.hatch-egg {
  width: min(58vw, 320px);
  height: min(58vw, 320px);
  margin: 4px 0 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: transparent;
  filter: drop-shadow(-6px 0 rgba(21,117,244,.72)) drop-shadow(6px 0 rgba(228,0,37,.72));
  touch-action: manipulation;
}

.hatch-egg img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  animation: egg-breathe 2.2s steps(4, end) infinite;
  user-select: none;
  -webkit-user-drag: none;
}

.hatch-egg.is-hit { animation: egg-hit .34s steps(4, end); }
.hatch-gate[data-taps="1"] .hatch-egg { filter: brightness(1.1) drop-shadow(-7px 0 #1575f4) drop-shadow(7px 0 #e40025); }
.hatch-gate[data-taps="2"] .hatch-egg { filter: brightness(1.24) drop-shadow(0 0 28px #e40025) drop-shadow(-8px 0 #1575f4); }

.hatch-counter {
  min-width: 82px;
  margin-top: -9px;
  padding: 7px 13px;
  border: 1px solid rgba(255,255,255,.22);
  color: white;
  background: rgba(8,7,10,.82);
  font: 900 14px/1 monospace;
  letter-spacing: .12em;
}

.hatch-hint {
  margin-top: 10px;
  color: #ff7656;
  font: 800 10px/1 monospace;
  letter-spacing: .18em;
}

.hatch-gate.is-hatching .hatch-egg { animation: egg-hatch .9s steps(7, end) forwards; }
.hatch-gate.is-hatching::after { animation: hatch-flash .92s ease-out forwards; }

body[data-hatched="false"] > *:not(.hatch-gate) { pointer-events: none !important; }

.evolution-hud {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 12px;
  min-width: 170px;
  padding: 8px 10px;
  border: 1px solid rgba(242,13,39,.34);
  background: rgba(10,8,11,.74);
  font: 750 9px/1.15 monospace;
  letter-spacing: .08em;
}

.evolution-hud .evolution-name { color: #fff; }
.evolution-hud .evolution-form { color: #ff7656; text-align: right; }
.evolution-hud .evolution-next { grid-column: 1 / -1; color: #8d8790; font-size: 8px; }
.evolution-track { grid-column: 1 / -1; height: 4px; overflow: hidden; background: #29242b; }
.evolution-track > i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #1575f4, #e40025, #ff7b3d); box-shadow: 0 0 9px #e40025; transition: width .45s ease; }

.evolution-event {
  z-index: 1100;
  opacity: 0;
  transform: scale(1.08);
  transition: opacity .35s ease, transform .35s ease;
}

.evolution-event.is-visible { opacity: 1; transform: scale(1); }
.evolution-event-kicker { margin: 0 0 7px; color: #ff6b4b; font: 900 11px/1 monospace; letter-spacing: .28em; }
.evolution-event h2 { margin: 0; font: italic 900 clamp(24px,7vw,44px)/1.05 monospace; text-shadow: -4px 2px #1575f4, 4px -2px #e40025; }
.evolution-event-sprite { width: min(64vw, 390px); height: min(52vh, 390px); object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 0 38px rgba(242,13,39,.55)); animation: evolution-arrive 1s steps(7,end) both; }
.evolution-event-name { font: italic 950 clamp(20px,6vw,36px)/1 monospace; }
.evolution-event-level { margin-top: 9px; color: #aaa2aa; font: 800 10px/1 monospace; letter-spacing: .17em; }

@keyframes egg-breathe { 50% { transform: translateY(-7px) scale(1.015); } }
@keyframes egg-hit { 0%,100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-12px) rotate(-3deg); } 70% { transform: translateX(12px) rotate(3deg); } }
@keyframes egg-hatch { 0% { transform: scale(1); } 35% { transform: scale(.88) rotate(-3deg); } 68% { transform: scale(1.18) rotate(3deg); filter: brightness(2.5); } 100% { transform: scale(2.4); opacity: 0; filter: brightness(5); } }
@keyframes hatch-flash { 0%,55% { opacity: 0; } 72% { opacity: .95; } 100% { opacity: 0; } }
@keyframes hatch-rays { to { transform: rotate(360deg); } }
@keyframes hatch-aura { 50% { transform: translate(-50%,-50%) scale(1.08); opacity: .56; } }
@keyframes evolution-arrive { from { transform: scale(.25); filter: brightness(5) drop-shadow(0 0 60px #fff); } }

@media (max-height: 700px) {
  .hatch-instruction { margin-top: 8px; }
  .hatch-egg { width: min(43vh, 270px); height: min(43vh, 270px); }
}

@media (prefers-reduced-motion: reduce) {
  .hatch-gate *, .hatch-gate::before, .hatch-gate::after, .evolution-event * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
