/* SPACEBOYCT.COM FEATURE GAMES -------------------------------------------------
   Shared shell for NIGHT SHIFT, 3D RACER, and FEED SPACEBOY.
   The visuals intentionally lean into glossy pseudo-RTX lighting: bloom,
   wet-looking reflections, dynamic gradients, and deep vignette shading.
*/
body.mega-active {
  background: #020204 !important;
  filter: none !important;
  cursor: crosshair;
}

body.mega-active > .bouncer,
body.mega-active > #ghostFace,
body.mega-active > #noiseOverlay,
body.mega-active > #blackout,
body.mega-active > #flashText,
body.mega-active > #statusHint {
  visibility: hidden !important;
}

#megaTakeover {
  position: fixed;
  inset: 0;
  z-index: 11100;
  display: none;
  overflow: hidden;
  background: #020204;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-family: "Arial Black", Impact, system-ui, sans-serif;
}

#megaTakeover.active { display: block; }

#megaCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #030307;
}

#megaBloom,
#megaVignette,
#megaNoise {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#megaBloom {
  z-index: 2;
  opacity: .68;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 50% 19%, rgba(125,177,255,.16), transparent 30%),
    radial-gradient(circle at 18% 70%, rgba(255,73,136,.08), transparent 28%),
    radial-gradient(circle at 82% 62%, rgba(62,224,255,.08), transparent 30%);
}

#megaVignette {
  z-index: 3;
  background: radial-gradient(circle at 50% 46%, transparent 34%, rgba(0,0,0,.23) 62%, rgba(0,0,0,.72) 100%);
}

#megaNoise {
  z-index: 4;
  opacity: .08;
  mix-blend-mode: soft-light;
  background:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,.08) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 5px, rgba(255,255,255,.025) 5px 6px);
}

#megaHUD {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
  font-family: "Courier New", monospace;
  font-weight: 900;
  letter-spacing: .05em;
  text-shadow: 2px 2px 0 #000, 0 0 10px #000;
  font-size: clamp(12px, 1.45vw, 19px);
}

#megaHudLeft,
#megaHudCenter,
#megaHudRight {
  position: absolute;
  top: max(13px, env(safe-area-inset-top, 0px));
  white-space: pre-line;
}

#megaHudLeft { left: max(14px, env(safe-area-inset-left, 0px)); }
#megaHudCenter { left: 50%; transform: translateX(-50%); text-align: center; }
#megaHudRight { right: max(14px, env(safe-area-inset-right, 0px)); text-align: right; }

#megaMessage {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 10;
  width: min(940px, 92vw);
  transform: translate(-50%, -50%) scale(.88);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: clamp(34px, 7vw, 100px);
  line-height: .92;
  color: #fff2a0;
  text-transform: uppercase;
  text-shadow: 5px 5px 0 #000, 0 0 28px rgba(255,255,255,.2);
  transition: opacity 110ms linear, transform 160ms cubic-bezier(.15,.85,.18,1.15);
}

#megaMessage small {
  display: block;
  margin-top: 13px;
  font-family: "Courier New", monospace;
  font-size: clamp(12px, 1.7vw, 22px);
  line-height: 1.25;
  letter-spacing: .08em;
  color: rgba(255,255,255,.88);
}

#megaMessage.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#megaHint {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  width: min(980px, 92vw);
  transform: translateX(-50%);
  text-align: center;
  font: 900 clamp(10px, 1.15vw, 14px)/1.25 "Courier New", monospace;
  color: rgba(255,255,255,.62);
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}

.megaControls {
  position: absolute;
  z-index: 9;
  display: none;
  gap: 8px;
  pointer-events: none;
}

.megaControls.active { display: flex; }

.megaControls button {
  min-width: 58px;
  min-height: 52px;
  padding: 10px 13px;
  border: 2px solid rgba(255,255,255,.68);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(45,48,60,.88), rgba(6,7,11,.9));
  color: #fff;
  font: 900 13px/1 "Arial Black", Impact, sans-serif;
  letter-spacing: .03em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.2),
    inset 0 -12px 20px rgba(0,0,0,.18),
    0 0 14px rgba(120,180,255,.08);
  touch-action: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.megaControls button:active,
.megaControls button.pressed {
  transform: scale(.94);
  background: linear-gradient(180deg, rgba(94,110,150,.92), rgba(17,19,29,.94));
}

#fnafControls {
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: min(780px, 96vw);
}

#fnafControls button { min-width: 92px; }
#fnafLeftDoor, #fnafRightDoor { min-width: 106px; }
#fnafLeftLight, #fnafRightLight { min-width: 96px; }
#fnafCameras { min-width: 104px; }
#fnafPrevCam, #fnafNextCam { min-width: 86px; }

#racerControls {
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  align-items: flex-end;
  justify-content: center;
}

#racerLeft, #racerRight {
  width: 84px;
  height: 72px;
  font-size: 26px;
}

#racerBoost {
  width: 116px;
  height: 86px;
  border-radius: 50%;
  color: #fff7a8;
  font-size: 17px;
}

#feedControls {
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: min(720px, 96vw);
}

#feedControls button:not(#feedServe) {
  width: 62px;
  height: 62px;
  font-size: 19px;
}

#feedServe {
  min-width: 112px;
  height: 64px;
  color: #fff7a8;
}

@media (hover: hover) and (pointer: fine) {
  .megaControls button:hover {
    border-color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 0 18px rgba(130,190,255,.22);
  }
}

@media (hover: none), (pointer: coarse), (max-width: 900px) {
  #megaHint { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); font-size: 10px; }
  .megaControls.active { display: flex; }
  .megaControls button {
    min-width: 58px;
    min-height: 56px;
    font-size: 12px;
  }
  #fnafControls { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  #racerControls, #feedControls { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 520px) {
  #megaHudCenter { top: calc(max(13px, env(safe-area-inset-top, 0px)) + 42px); }
  #fnafControls { gap: 5px; }
  #fnafControls button { min-width: 70px; min-height: 48px; padding: 7px 8px; font-size: 10px; }
  #fnafLeftDoor, #fnafRightDoor { min-width: 82px; }
  #fnafLeftLight, #fnafRightLight { min-width: 78px; }
  #fnafPrevCam, #fnafNextCam { min-width: 68px; }
  #racerLeft, #racerRight { width: 70px; height: 62px; }
  #racerBoost { width: 96px; height: 70px; font-size: 14px; }
  #feedControls { gap: 5px; }
  #feedControls button:not(#feedServe) { width: 52px; height: 52px; min-width: 52px; min-height: 52px; }
  #feedServe { min-width: 88px; height: 54px; min-height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  #megaMessage { transition: none; }
}

/* Fair-night readability: the threatened door becomes impossible to miss without using a rapid flash. */
#fnafControls button.danger {
  border-color: #ff606a;
  color: #fff6a8;
  background: linear-gradient(180deg, rgba(146,24,36,.96), rgba(40,3,8,.96));
  box-shadow: 0 0 0 4px rgba(255,58,76,.18), 0 0 28px rgba(255,35,55,.48), inset 0 1px 0 rgba(255,255,255,.3);
  animation: fnafDangerPulse 1.2s ease-in-out infinite;
}

@keyframes fnafDangerPulse {
  0%,100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.035); filter: brightness(1.22); }
}

@media (prefers-reduced-motion: reduce) {
  #fnafControls button.danger { animation: none; }
}

.gameExitButton {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 40;
  min-width: 74px;
  min-height: 42px;
  padding: 8px 12px;
  border: 2px solid rgba(255,255,255,.78);
  border-radius: 10px;
  background: rgba(8,8,12,.78);
  color: #fff;
  font: 900 12px/1 system-ui, sans-serif;
  letter-spacing: .06em;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}
.gameExitButton:hover,
.gameExitButton:focus-visible {
  background: rgba(85,15,25,.92);
  border-color: #fff;
  outline: 3px solid rgba(255,255,255,.2);
}

#fnafLeftLight.pressed, #fnafRightLight.pressed {
  background: linear-gradient(180deg, rgba(255,244,175,.98), rgba(115,83,22,.96));
  color: #fff8c7;
  box-shadow: 0 0 18px rgba(255,225,118,.38) inset, 0 0 14px rgba(255,230,140,.22);
}
#fnafControls button.danger {
  border-color: #ff505d !important;
  box-shadow: 0 0 0 2px rgba(255,60,70,.25), 0 0 18px rgba(255,40,55,.36);
}
#megaTakeover.fnaf-mode #megaCanvas {
  image-rendering: auto;
}
#megaTakeover.fnaf-mode #megaBloom { opacity: .22; }
#megaTakeover.fnaf-mode #megaNoise { opacity: .10; mix-blend-mode: screen; }
