/* Bio-War v4.2 — Menu Button URL Fix layer */
:root {
  --polish-fast: 130ms;
  --polish-medium: 280ms;
  --polish-slow: 520ms;
  --polish-cinematic: 760ms;
  --polish-spring: cubic-bezier(.2,.9,.2,1.18);
  --polish-smooth: cubic-bezier(.22,.8,.28,1);
  --polish-exit: cubic-bezier(.4,0,1,1);
}

body.stage-animations-polish {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body.stage-animations-polish #app {
  isolation: isolate;
}

/* Global FX layer */
.polish-fx-layer {
  position: fixed;
  z-index: 140;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
}
.polish-screen-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at var(--fx-x,50%) var(--fx-y,50%), var(--fx-color,rgba(75,255,161,.24)), transparent 54%);
  animation: polishScreenFlash var(--polish-slow) var(--polish-smooth) both;
  mix-blend-mode: screen;
}
.polish-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size,6px);
  height: var(--size,6px);
  border-radius: 50%;
  background: var(--particle-color,var(--ds-accent,#51ffa2));
  box-shadow: 0 0 12px var(--particle-color,var(--ds-accent,#51ffa2));
  opacity: 0;
  transform: translate(-50%,-50%);
  animation: polishParticle var(--life,720ms) var(--polish-smooth) forwards;
}
.polish-particle.glyph {
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--particle-color,var(--ds-accent,#51ffa2));
  font-size: var(--size,13px);
  font-weight: 900;
  text-shadow: 0 0 12px currentColor;
}
.polish-floating-text {
  position: absolute;
  left: var(--x);
  top: var(--y);
  min-width: max-content;
  color: var(--float-color,#caffdf);
  font: 900 13px/1 ui-monospace,SFMono-Regular,monospace;
  letter-spacing: .02em;
  text-shadow: 0 2px 10px #000,0 0 16px color-mix(in srgb,var(--float-color) 55%,transparent);
  transform: translate(-50%,0);
  animation: polishFloatText 1050ms var(--polish-smooth) forwards;
}
.polish-confetti {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 5px;
  height: 11px;
  border-radius: 3px;
  background: var(--confetti-color,var(--ds-accent));
  animation: polishConfetti var(--life,1100ms) var(--polish-smooth) forwards;
  transform: translate(-50%,-50%) rotate(var(--rotate));
}
.polish-route-dot {
  position: absolute;
  z-index: 12;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8ffeb;
  box-shadow: 0 0 8px #fff,0 0 22px var(--ds-accent);
  offset-path: path("M 50 50 C 62 45, 70 58, 82 64");
  offset-distance: 0%;
  animation: polishRoute 1100ms var(--polish-smooth) forwards;
}

/* Press and ripple feedback */
body.stage-animations-polish button,
body.stage-animations-polish [role="button"] {
  transform: translateZ(0);
  backface-visibility: hidden;
}
body.stage-animations-polish button:not(:disabled) {
  transition: transform var(--polish-fast) var(--polish-spring), filter var(--polish-fast), border-color var(--polish-medium), background var(--polish-medium), box-shadow var(--polish-medium);
}
body.stage-animations-polish button:not(:disabled).polish-pressed {
  transform: scale(.972) translateZ(0);
  filter: brightness(1.09);
}
.polish-ripple-host { position: relative !important; overflow: hidden !important; }
.polish-ripple {
  position: absolute;
  z-index: 30;
  width: 12px;
  height: 12px;
  margin: -6px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle,rgba(235,255,244,.35),rgba(92,255,169,.14) 45%,transparent 72%);
  transform: scale(0);
  animation: polishRipple 600ms var(--polish-smooth) forwards;
}

/* View transitions and stagger */
body.stage-animations-polish .view.polish-view-enter {
  animation: polishViewEnter var(--polish-cinematic) var(--polish-smooth) both !important;
}
body.stage-animations-polish .view.polish-view-enter .main-screen-hero,
body.stage-animations-polish .view.polish-view-enter .view-hero {
  animation: polishHeroEnter 680ms var(--polish-smooth) 60ms both;
}
body.stage-animations-polish .view.polish-view-enter .polish-stagger-item {
  opacity: 0;
  animation: polishStaggerIn 520ms var(--polish-smooth) var(--polish-delay,0ms) both;
}
body.stage-animations-polish .view.polish-view-exit {
  display: block !important;
  position: absolute;
  inset-inline: 0;
  pointer-events: none;
  animation: polishViewExit 210ms var(--polish-exit) both !important;
}
.polish-transition-wipe {
  position: fixed;
  z-index: 130;
  left: -35%;
  top: -25%;
  width: 55%;
  height: 150%;
  pointer-events: none;
  opacity: .48;
  background: linear-gradient(90deg,transparent,rgba(var(--ds-accent-rgb,81,255,162),.22),rgba(255,255,255,.1),transparent);
  filter: blur(10px);
  transform: skewX(-12deg) translateX(-100%);
  animation: polishWipe 620ms var(--polish-smooth) forwards;
}

/* Living interfaces */
body.stage-animations-polish .game-hud-stack {
  transition: transform var(--polish-medium) var(--polish-smooth), background var(--polish-medium);
}
body.stage-animations-polish .resource-rack > div {
  overflow: hidden;
}
body.stage-animations-polish .resource-rack > div::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(105deg,transparent 20%,rgba(255,255,255,.08) 42%,transparent 64%);
  transform: translateX(-110%);
}
body.stage-animations-polish .resource-rack > div.polish-value-up::after {
  animation: polishResourceSweep 650ms var(--polish-smooth);
}
body.stage-animations-polish .polish-number-pulse {
  animation: polishNumberPulse 430ms var(--polish-spring);
}
body.stage-animations-polish .central-chamber::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 14% 3%;
  border-radius: 48%;
  opacity: .18;
  background: radial-gradient(circle,rgba(var(--ds-accent-rgb),.22),transparent 68%);
  animation: polishChamberBreath 5.5s ease-in-out infinite;
  pointer-events: none;
}
body.stage-animations-polish .virus-button.reacted .virus-visual {
  animation: polishVirusReaction 620ms var(--polish-spring) !important;
}
body.stage-animations-polish .hotspot:not(.locked):active,
body.stage-animations-polish .module-card:not(.locked):active { filter: brightness(1.16); }
body.stage-animations-polish .module-card.polish-upgrade-start,
body.stage-animations-polish .evo-node.polish-upgrade-start,
body.stage-animations-polish .corp-tech-card.polish-upgrade-start {
  animation: polishUpgradeStart 900ms var(--polish-smooth);
}

/* Combat cinematic polish */
body.stage-animations-polish .combat-view.polish-combat-charge .combat-console,
body.stage-animations-polish .combat-view.polish-combat-charge .attack-panel {
  animation: polishCombatCharge 900ms ease-in-out;
}
body.stage-animations-polish .combat-view.polish-combat-charge::after {
  content: "";
  position: fixed;
  z-index: 125;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,transparent 0 3px,rgba(89,255,166,.045) 4px 5px);
  animation: polishScanNoise 900ms linear both;
}
body.stage-animations-polish .combat-result.polish-result-in {
  animation: polishResultIn 640ms var(--polish-spring) both;
}
body.stage-animations-polish .combat-result.success.polish-result-in { box-shadow: 0 0 0 1px rgba(77,255,164,.14),0 0 34px rgba(77,255,164,.10); }
body.stage-animations-polish .combat-result.fail.polish-result-in { animation-name: polishResultFail; }
body.stage-animations-polish .target-card.selected {
  animation: polishTargetLock 520ms var(--polish-smooth);
}

/* Operations and map */
body.stage-animations-polish .operations-map.polish-expedition-launch {
  animation: polishMapLaunch 1150ms var(--polish-smooth);
}
body.stage-animations-polish .sector-node.selected::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(var(--ds-accent-rgb),.42);
  border-radius: inherit;
  animation: polishTargetRing 2.2s ease-out infinite;
  pointer-events: none;
}
body.stage-animations-polish .expedition-card.ready {
  animation: polishReadyGlow 2.1s ease-in-out infinite;
}

/* Corporate / profile polish */
body.stage-animations-polish .corp-xp-line i,
body.stage-animations-polish .achievement-progress i,
body.stage-animations-polish .meter i,
body.stage-animations-polish .skill-row i::after,
body.stage-animations-polish .expedition-progress i {
  transition: width 720ms var(--polish-smooth) !important;
}
body.stage-animations-polish .achievement-card.completed:not(.claimed)::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg,transparent 30%,rgba(255,255,255,.07),transparent 70%);
  transform: translateX(-110%);
  animation: polishRewardShine 3.2s ease-in-out infinite;
}
body.stage-animations-polish .profile-hero.polish-profile-arrive > div:first-child {
  animation: polishAvatarArrive 720ms var(--polish-spring);
}

/* Sheets, toast, loading */
body.stage-animations-polish .sheet.open > section {
  transform-origin: 50% 100%;
  animation: polishSheetSpring 520ms var(--polish-spring) both !important;
}
body.stage-animations-polish .sheet.open .sheet-backdrop { animation: polishBackdrop 280ms ease both; }
body.stage-animations-polish .toast.show {
  animation: polishToastIn 440ms var(--polish-spring) both;
}
body.stage-animations-polish button.busy::after {
  box-shadow: 0 0 12px rgba(var(--ds-accent-rgb),.35);
}
body.stage-animations-polish button.busy {
  background-size: 220% 100%;
  animation: polishBusySurface 1.3s linear infinite;
}
body.stage-animations-polish .boot-mark span { animation: polishBootCore 2.4s ease-in-out infinite; }
body.stage-animations-polish .loader span { animation-duration: 1.1s; }

/* Adaptive performance */
body.polish-paused *,
body.polish-paused *::before,
body.polish-paused *::after { animation-play-state: paused !important; }
body.polish-low-fps .screen-atmosphere,
body.polish-low-fps .polish-transition-wipe,
body.polish-low-fps .central-chamber::after { display: none !important; }
body.polish-low-fps .ambient i { filter: blur(80px) !important; opacity: .035 !important; }
body.polish-low-fps .sheet-backdrop,
body.polish-low-fps .bottom-nav { backdrop-filter: none !important; }

@keyframes polishRipple { to { transform: scale(18); opacity: 0; } }
@keyframes polishParticle { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.35); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) scale(.1) rotate(var(--spin,0deg)); } }
@keyframes polishFloatText { 0% { opacity: 0; transform: translate(-50%,8px) scale(.9); } 18% { opacity: 1; transform: translate(-50%,-4px) scale(1.04); } 100% { opacity: 0; transform: translate(-50%,-54px) scale(.96); } }
@keyframes polishConfetti { 0% { opacity: 0; transform: translate(-50%,-50%) rotate(var(--rotate)) scale(.2); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) rotate(calc(var(--rotate) + 260deg)) scale(.6); } }
@keyframes polishScreenFlash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
@keyframes polishViewEnter { from { opacity: 0; transform: translate3d(18px,6px,0) scale(.992); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes polishViewExit { to { opacity: 0; transform: translate3d(-11px,0,0) scale(.995); filter: blur(3px); } }
@keyframes polishHeroEnter { from { opacity: 0; transform: translate3d(0,-12px,0) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes polishStaggerIn { from { opacity: 0; transform: translate3d(0,16px,0) scale(.988); } to { opacity: 1; transform: none; } }
@keyframes polishWipe { 0% { transform: skewX(-12deg) translateX(-110%); } 100% { transform: skewX(-12deg) translateX(330%); } }
@keyframes polishResourceSweep { to { transform: translateX(115%); opacity: 1; } }
@keyframes polishNumberPulse { 0%,100% { transform: none; } 45% { transform: scale(1.12); color: #e5fff0; text-shadow: 0 0 16px var(--ds-accent); } }
@keyframes polishChamberBreath { 0%,100% { transform: scale(.95); opacity: .10; } 50% { transform: scale(1.07); opacity: .27; } }
@keyframes polishVirusReaction { 0% { transform: translate(-50%,-50%) scale(1); } 26% { transform: translate(-50%,-50%) scale(.87) rotate(-4deg); filter: brightness(1.7); } 52% { transform: translate(-50%,-50%) scale(1.13) rotate(3deg); } 100% { transform: translate(-50%,-50%) scale(1); } }
@keyframes polishUpgradeStart { 0%,100% { transform: none; } 35% { transform: translateY(-4px) scale(1.015); box-shadow: 0 0 0 1px rgba(var(--ds-accent-rgb),.28),0 0 42px rgba(var(--ds-accent-rgb),.18); } }
@keyframes polishCombatCharge { 0%,100% { filter: none; } 32% { filter: brightness(.72) saturate(1.5); transform: scale(.996); } 55% { filter: brightness(1.22) saturate(1.35); } }
@keyframes polishScanNoise { 0% { opacity: 0; transform: translateY(-8px); } 25% { opacity: .9; } 100% { opacity: 0; transform: translateY(12px); } }
@keyframes polishResultIn { 0% { opacity: 0; transform: translateY(9px) scale(.95); } 58% { opacity: 1; transform: translateY(-2px) scale(1.015); } 100% { transform: none; } }
@keyframes polishResultFail { 0% { opacity: 0; transform: translateX(0); } 30% { opacity: 1; transform: translateX(-5px); } 48% { transform: translateX(4px); } 66% { transform: translateX(-2px); } 100% { transform: none; } }
@keyframes polishTargetLock { 0% { box-shadow: 0 0 0 0 rgba(var(--ds-accent-rgb),.6); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes polishMapLaunch { 0%,100% { filter: none; } 20% { filter: brightness(.7); } 48% { filter: brightness(1.45) saturate(1.4); box-shadow: inset 0 0 70px rgba(var(--ds-accent-rgb),.18),0 0 36px rgba(var(--ds-accent-rgb),.12); } }
@keyframes polishRoute { 0% { opacity: 0; offset-distance: 0%; } 12% { opacity: 1; } 86% { opacity: 1; } 100% { opacity: 0; offset-distance: 100%; } }
@keyframes polishTargetRing { 0% { transform: scale(.7); opacity: .8; } 70%,100% { transform: scale(1.3); opacity: 0; } }
@keyframes polishReadyGlow { 0%,100% { box-shadow: 0 0 0 rgba(var(--ds-accent-rgb),0); } 50% { box-shadow: 0 0 30px rgba(var(--ds-accent-rgb),.09); } }
@keyframes polishRewardShine { 0%,62% { transform: translateX(-110%); } 100% { transform: translateX(110%); } }
@keyframes polishAvatarArrive { 0% { opacity: 0; transform: rotate(-12deg) scale(.65); } 65% { opacity: 1; transform: rotate(3deg) scale(1.08); } 100% { transform: none; } }
@keyframes polishSheetSpring { from { opacity: 0; transform: translate3d(0,36px,0) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes polishBackdrop { from { opacity: 0; } to { opacity: 1; } }
@keyframes polishToastIn { 0% { opacity: 0; transform: translate(-50%,18px) scale(.93); } 65% { opacity: 1; transform: translate(-50%,-3px) scale(1.015); } 100% { transform: translate(-50%,0); } }
@keyframes polishBusySurface { 0% { background-position: 140% 0; } 100% { background-position: -80% 0; } }
@keyframes polishBootCore { 0%,100% { transform: scale(.96); box-shadow: inset 0 0 30px rgba(68,255,156,.08),0 0 36px rgba(54,255,149,.06); } 50% { transform: scale(1.04); box-shadow: inset 0 0 35px rgba(68,255,156,.16),0 0 62px rgba(54,255,149,.15); } }

@media (max-width: 430px) {
  :root { --polish-cinematic: 570ms; }
  body.stage-animations-polish .view.polish-view-enter { animation-name: polishViewEnterMobile !important; }
  .polish-transition-wipe { width: 70%; }
}
@keyframes polishViewEnterMobile { from { opacity: 0; transform: translate3d(0,10px,0) scale(.994); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .polish-fx-layer,.polish-transition-wipe { display: none !important; }
}
body.motion-reduced .polish-fx-layer,
body.motion-reduced .polish-transition-wipe,
body.quality-economy .polish-fx-layer { display: none !important; }
body.motion-reduced .view.polish-view-enter,
body.motion-reduced .polish-stagger-item,
body.quality-economy .polish-stagger-item { animation: none !important; opacity: 1 !important; }
body.quality-economy .central-chamber::after,
body.quality-economy .achievement-card.completed:not(.claimed)::before { display: none !important; }
body.stage-animations-polish .resource-rack > div,
body.stage-animations-polish .achievement-card { position: relative; }
body.stage-animations-polish .achievement-card { overflow: hidden; }
