/* Ambient Motion owns only its added layers. HOME's card pseudos already paint
   artwork/frames; the child edge sits above those frames without moving the UI.
   City marks share the owl scene's 1280x725 cover coordinates, below its veil.
   Table z2 stays below the existing edge pseudos (z4) and TABLE PRESSURE (z5). */
.ambient-card-edge,
.ambient-card-particles,
.ambient-card-particles *,
.ambient-card-particle::after,
.ambient-city-layer,
.ambient-table-layer,
.ambient-card-edge::before,
.ambient-city-layer *,
.ambient-table-layer * {
  pointer-events:none !important;
  user-select:none;
}

body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge {
  pointer-events:none !important;
  --ambient-glow-alpha:.62;
  position:absolute;
  inset:1px;
  z-index:6;
  display:block;
  overflow:hidden;
  color:rgb(88,218,241);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge[data-tone="purple"] {
  color:rgb(169,112,227);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge::before {
  pointer-events:none !important;
  content:"";
  position:absolute;
  left:var(--ambient-edge-x,28%);
  top:0;
  width:clamp(36px,28%,120px);
  height:2px;
  background:linear-gradient(90deg,transparent,currentColor 45%,transparent);
  box-shadow:0 0 5px currentColor;
  opacity:0;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge[data-edge="bottom"]::before {
  top:auto;
  bottom:0;
}
/* The narrowly owned !important animation exceeds HOME V2's descendant reset. */
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge.is-ambient-on::before {
  animation:ponderAmbientCardEdge var(--ambient-duration,720ms) ease-out both !important;
}
@keyframes ponderAmbientCardEdge {
  0%,100% { opacity:0; }
  20%,52% { opacity:var(--ambient-glow-alpha,.62); }
  72% { opacity:calc(var(--ambient-glow-alpha,.62) * .55); }
}

/* Twelve small CSS sprites in total. Each card uses its own artwork emission
   points. Individual translate also survives the older HOME transform reset. */
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particles {
  position:absolute;
  inset:0;
  z-index:1;
  overflow:hidden;
  pointer-events:none !important;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particles[data-art="ranked"] {
  clip-path:polygon(52% 42%,82% 42%,86% 26%,96% 26%,96% 88%,52% 88%);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particles[data-art="custom"] {
  clip-path:polygon(56% 40%,76% 40%,80% 28%,98% 28%,98% 91%,56% 91%);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particles[data-art="analytics"] {
  clip-path:inset(12% 2% 14% 56%);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle {
  position:absolute;
  display:block;
  left:var(--particle-x);
  top:var(--particle-y);
  width:calc(var(--home-paint-unit,1px) * 6);
  height:calc(var(--home-paint-unit,1px) * 6);
  border-radius:25%;
  color:#78e5ff;
  background:currentColor;
  box-shadow:0 0 4px currentColor;
  opacity:0;
  pointer-events:none !important;
  animation:ponderAmbientArtworkRise var(--particle-cycle,4s) var(--particle-delay,0s) linear infinite both !important;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle[data-tone="purple"] { color:#d18bff; }
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle[data-shape="spark"] { rotate:45deg; }
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle[data-shape="tick"] {
  height:calc(var(--home-paint-unit,1px) * 3);
  border-radius:0;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle::after {
  content:"";
  position:absolute;
  left:40%;
  top:100%;
  width:calc(var(--home-paint-unit,1px) * 1.5);
  height:calc(var(--home-paint-unit,1px) * 18);
  background:linear-gradient(currentColor,transparent);
  opacity:.6;
}
@keyframes ponderAmbientArtworkRise {
  0% { opacity:0; translate:0 0; }
  14% { opacity:.92; }
  72% { opacity:.72; }
  100% { opacity:0; translate:var(--particle-drift) calc(-1 * var(--particle-rise)); }
}

body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-layer {
  pointer-events:none !important;
  --ambient-city-alpha:.48;
  position:absolute;
  inset:0;
  z-index:0;
  overflow:hidden;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light {
  pointer-events:none !important;
  position:absolute;
  display:block;
  width:3px;
  height:3px;
  color:rgb(77,193,222);
  background:currentColor;
  box-shadow:0 0 4px currentColor;
  opacity:0;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light[data-tone="purple"] {
  color:rgb(155,104,208);
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light[data-sign="true"] {
  width:clamp(9px,1.1%,16px);
  height:2px;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light.is-ambient-on {
  animation:ponderAmbientCityLight var(--ambient-duration,900ms) ease-in-out both !important;
}
body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light.is-ambient-on[data-flicker="true"] {
  animation-name:ponderAmbientCityReply !important;
}
@keyframes ponderAmbientCityLight {
  0%,100% { opacity:0; }
  25%,66% { opacity:var(--ambient-city-alpha,.48); }
}
/* A single soft reply, selected rarely by the scheduler; no repeating flicker. */
@keyframes ponderAmbientCityReply {
  0%,100% { opacity:0; }
  25% { opacity:var(--ambient-city-alpha,.48); }
  44% { opacity:calc(var(--ambient-city-alpha,.48) * .3); }
  61% { opacity:calc(var(--ambient-city-alpha,.48) * .75); }
}

.ambient-table-layer {
  --ambient-table-alpha:.86;
  --ambient-table-breath-alpha:.10;
  --ambient-image-breath-alpha:.48;
  --ambient-image-shade-alpha:.28;
  position:absolute;
  inset:0;
  z-index:2;
  overflow:hidden;
  contain:layout paint;
}
body #table > .ambient-table-layer,
body #table > .ambient-table-layer * {
  pointer-events:none !important;
}
.ambient-table-layer[hidden],
.ambient-city-layer[hidden],
.ambient-card-edge[hidden] {
  display:none !important;
}
.ambient-card-particles[hidden] { display:none !important; }
.ambient-table-layer[data-ambient-accents="off"] .ambient-table-paths { visibility:hidden; }
.ambient-table-surface {
  position:absolute;
  inset:2.1% 1.7% 2.3% 1.7%;
  transform:translateY(-3.1%);
  display:block;
}
/* A static screen blend makes a brighter copy of the existing bitmap. Only
   this owned image plane changes opacity; cards, labels and actions stay put. */
.ambient-table-image-breath,
.ambient-table-image-shade {
  position:absolute;
  inset:0;
  display:block;
}
.ambient-table-image-shade {
  background:#000;
  opacity:var(--ambient-image-shade-alpha,.28);
  animation:ponderAmbientImageShade var(--ambient-breath-duration,6.4s) ease-in-out infinite;
}
.ambient-table-image-breath {
  background-position:center;
  background-size:100% 100%;
  background-repeat:no-repeat;
  background-blend-mode:screen;
  opacity:0;
  animation:ponderAmbientImageBreath var(--ambient-breath-duration,6.4s) ease-in-out infinite;
}
/* The controller suspends this owned subtree during hand-rank/SNG scenes.
   Avoid a body relational selector on every unrelated table mutation. */
@keyframes ponderAmbientImageBreath {
  0%,100% { opacity:0; }
  48% { opacity:var(--ambient-image-breath-alpha,.48); }
}
@keyframes ponderAmbientImageShade {
  0%,100% { opacity:var(--ambient-image-shade-alpha,.28); }
  48% { opacity:0; }
}
.ambient-table-paths {
  position:absolute;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  overflow:hidden;
  fill:none;
}
.ambient-table-breath,
.ambient-table-glow,
.ambient-table-feather,
.ambient-table-trace {
  fill:none;
  vector-effect:non-scaling-stroke;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.ambient-table-breath {
  stroke:#b788f4;
  stroke-width:1;
  opacity:0;
  animation:ponderAmbientTableBreath var(--ambient-breath-duration,15.7s) ease-in-out infinite;
}
.ambient-table-glow,
.ambient-table-feather,
.ambient-table-trace {
  animation:ponderAmbientTableOrbit var(--ambient-orbit-duration,19s) var(--ambient-orbit-delay,0s) linear infinite;
}
/* Short, concentric dashes feather from the native violet into a small bright
   centre. Their dash/gap sums and phase centres match, so no extra light or
   moving replacement frame is introduced. No blur or per-frame JS is needed. */
.ambient-table-glow {
  stroke:#9951fa;
  stroke-width:4;
  opacity:.10;
}
.ambient-table-feather { stroke-width:1.4; }
.ambient-table-trace {
  stroke:#d2a6ff;
  stroke-width:1.4;
  opacity:var(--ambient-table-alpha,.86);
}
@keyframes ponderAmbientTableBreath {
  0%,100% { opacity:calc(var(--ambient-table-breath-alpha,.10) * .3); }
  48% { opacity:var(--ambient-table-breath-alpha,.10); }
}
@keyframes ponderAmbientTableOrbit {
  from { stroke-dashoffset:var(--ambient-dash-start); }
  to { stroke-dashoffset:var(--ambient-dash-end); }
}

/* CSS failsafes complement the controller, including mode changes mid-pulse. */
body:is(.perf-lite,.static-neon) :is(.ambient-card-edge,.ambient-card-particles,.ambient-city-layer,.ambient-table-layer),
html:is(.perf-lite,.static-neon) :is(.ambient-card-edge,.ambient-card-particles,.ambient-city-layer,.ambient-table-layer) {
  display:none !important;
}
@media (prefers-reduced-motion:reduce) {
  .ambient-card-edge,
  .ambient-card-particles,
  .ambient-city-layer,
  .ambient-table-layer {
    display:none !important;
  }
  body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-edge.is-ambient-on::before,
  body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-card-particle,
  body #appHomeScreen#appHomeScreen.ponder-home-v2 .ambient-city-light.is-ambient-on,
  .ambient-table-breath,
  .ambient-table-image-breath,
  .ambient-table-image-shade,
  .ambient-table-glow,
  .ambient-table-feather,
  .ambient-table-trace {
    animation:none !important;
    opacity:0 !important;
  }
}
