#clearing {
  position: fixed; inset: 0; z-index: 2; overflow: hidden; pointer-events: none;
  color: #f4ecd2; font-family: 'Instrument Serif', Georgia, serif; outline: none;
  background:
    radial-gradient(ellipse at 50% 82%, rgba(255, 214, 120, .04), transparent 45%),
    linear-gradient(rgba(5, 12, 30, .2), transparent 52%, rgba(5, 12, 30, .16));
  animation: clearing-in 1.4s ease both;
}
#clearing[hidden] { display: none; }
@keyframes clearing-in { from { opacity: 0; } }

#clearing .hud { position: absolute; inset: 0 0 auto; padding: max(70px, 7vh) 24px 0; text-align: center; }
#clearing h2 { margin: 0; font-weight: 400; font-size: clamp(2.2rem, 6vw, 3.6rem); letter-spacing: .01em; text-shadow: 0 2px 24px rgba(5, 12, 30, .6); }
#clearing .status { margin: .65rem auto .95rem; min-height: 1.3em; max-width: 30em; font: 400 clamp(13px, 1.3vw, 16px)/1.4 system-ui, sans-serif; color: #f8f2e6; text-shadow: 0 1px 14px rgba(5, 12, 30, .7); }
#clearing .pips { display: flex; justify-content: center; gap: 10px; }
#clearing .pips i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid rgba(255, 225, 150, .65); transition: background .8s, box-shadow .8s; }
#clearing .pips i.on { background: #ffd75e; box-shadow: 0 0 10px 2px rgba(255, 214, 90, .7); }

#clearing .exit, #clearing .again {
  pointer-events: auto; cursor: pointer; font: inherit; font-size: 1.15rem; color: inherit; min-height: 44px;
  padding: 8px 20px; border-radius: 999px; border: 1px solid rgba(255, 235, 180, .45);
  background: rgba(8, 16, 34, .35); transition: background .3s;
}
#clearing .exit { position: absolute; z-index: 1; top: max(13px, env(safe-area-inset-top)); left: max(18px, 4vw, env(safe-area-inset-left)); border: 0; padding: 0 5px; background: transparent; font: 500 13px system-ui, sans-serif; text-shadow: 0 1px 5px #081020; }
#clearing .exit span { margin-inline-end: 4px; }
#clearing .again { position: absolute; left: 50%; bottom: max(16px, 6vh, env(safe-area-inset-bottom)); translate: -50% 0; font: 500 13px system-ui,sans-serif; animation: clearing-in .65s ease both; }
#clearing .exit:hover, #clearing .again:hover { background: rgba(8, 16, 34, .6); }
#clearing button:focus-visible { outline: 2px solid #ffe9a8; outline-offset: 3px; }

#clearing .hollow {
  position: absolute; left: 50%; top: 76%; width: min(225px, 42vw); height: 70px; translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 225, 168, .23), rgba(213, 203, 139, .07) 29%, transparent 67%);
  filter: blur(3px);
}
#clearing .trail { position: absolute; inset: 0; width: 100%; height: 100%; }
#clearing .trail path {
  fill: none; stroke: rgba(255, 230, 164, .35); stroke-width: 1.2; stroke-linecap: round;
  stroke-dasharray: 1; filter: drop-shadow(0 0 4px #ffd75e);
}

#clearing .fly {
  position: absolute; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer; pointer-events: auto;
}
#clearing .fly:disabled { cursor: default; pointer-events: none; }
#clearing .bug { display: block; position: relative; width: 100%; height: 100%; pointer-events: none; rotate: var(--lean); animation: drift var(--t) var(--phase) ease-in-out infinite alternate; }
#clearing .fly:hover .bug { filter: brightness(1.25); }
#clearing .home .bug { animation: none; }
@keyframes drift { to { transform: translate(var(--dx), var(--dy)); } }
#clearing .bug::before {
  content: ''; position: absolute; left: 25px; top: 23px; width: 6px; height: 10px; z-index: 1; border-radius: 50%;
  background: radial-gradient(#fffbe7, #fff0a0 50%, #eba654);
  box-shadow: 0 0 5px 2px #ffe7a6bd, 0 0 14px 5px #ffcd6e99, 0 0 25px 10px #ffd76e35; animation: glow 2.6s var(--phase) ease-in-out infinite alternate;
}
@keyframes glow { from { filter: brightness(.8); } to { filter: brightness(1.3); } }
#clearing .bug i {
  position: absolute; top: 20px; width: 11px; height: 4px; border-radius: 50%;
  background: linear-gradient(120deg, rgba(255, 236, 189, .45), rgba(240, 204, 152, .12));
  border: 1px solid rgba(255, 240, 214, .3);
}
#clearing .bug i:first-child { left: 18px; transform-origin: right center; transform: rotate(-30deg); animation: flap-l .5s ease-in-out infinite alternate; }
#clearing .bug i:last-child { right: 18px; transform-origin: left center; transform: rotate(30deg); animation: flap-r .5s ease-in-out infinite alternate; }
@keyframes flap-l { to { transform: rotate(-12deg) scaleX(.85); } }
@keyframes flap-r { to { transform: rotate(12deg) scaleX(.85); } }

#clearing .mote {
  position: absolute; left: 50%; top: 76%; width: 4px; height: 4px; border-radius: 50%; opacity: 0;
  background: #ffe08a; box-shadow: 0 0 10px 3px rgba(255, 214, 90, .7);
  animation: lift var(--t) var(--w) ease-out forwards;
}
@keyframes lift {
  0% { opacity: 0; transform: translate(0, 0) scale(.5); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)); }
}

@media (max-height: 460px) {
  #clearing .hud { padding-top: max(8px, env(safe-area-inset-top)); }
  #clearing h2 { font-size: clamp(23px, 6.5vh, 31px); }
  #clearing .status { margin: 4px auto 6px; font-size: 12px; }
  #clearing .exit { top: 3px; }
  #clearing .again { bottom: max(2px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  #clearing, #clearing *, #clearing *::before, #clearing *::after { animation: none !important; transition: none !important; }
  #clearing .mote { opacity: .8; transform: translate(var(--dx), var(--dy)); }
}
