.ig4 {
  --cell: 104px;
  --gap: 10px;
  --pad: 28px;
  --slot: calc(var(--cell) * .05);
  --chip: calc(var(--cell) - var(--slot) * 2);
  --r: calc(var(--chip) * .21);
  --ll-black: #0a0a0b;
  --ll-blue: #2347ff;
}

.ig4-panel {
  position: relative; isolation: isolate; overflow: hidden;
  margin-top: 64px;
  height: calc(var(--cell) * 5 + var(--gap) * 4 + var(--pad) * 2);
  border-radius: 28px;
  background:
    radial-gradient(60% 70% at 50% 50%, #ffffff 0%, #f7f7f8 100%);
  box-shadow: inset 0 0 0 1px var(--border);
}
.ig4-panel::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--grain); background-size: 200px 200px;
  opacity: .035;
}

.ig4-glow {
  position: absolute; left: 50%; top: 50%; z-index: 0;
  width: calc(var(--cell) * 4.6); height: calc(var(--cell) * 3.6);
  translate: -50% -50%;
  background: radial-gradient(50% 50% at 50% 50%, rgb(35 71 255 / .2), rgb(35 71 255 / .06) 45%, rgb(35 71 255 / 0) 72%);
  pointer-events: none;
}

.ig4-field {
  --mx: -999px; --my: -999px; --peek: 0;
  position: absolute; inset: 0; z-index: 1;
  --fade: #000 18%, rgb(0 0 0 / .55) 38%, rgb(0 0 0 / .22) 58%, rgb(0 0 0 / .06) 76%, rgb(0 0 0 / 0) 90%;
  --peek-r: calc(var(--cell) * 2.1);
  --peek-fade:
    rgb(0 0 0 / min(1, calc(var(--peek) * 1.6))) 0%,
    rgb(0 0 0 / min(1, calc(var(--peek) * 1.6))) 20%,
    rgb(0 0 0 / calc(var(--peek) * .5)) 45%,
    rgb(0 0 0 / calc(var(--peek) * .14)) 72%,
    rgb(0 0 0 / 0) 100%;
  --m-fade: radial-gradient(50% 58% at 50% 50%, var(--fade));
  --m-peek: radial-gradient(circle var(--peek-r) at var(--mx) var(--my), var(--peek-fade));
  -webkit-mask-image: var(--m-fade), var(--m-peek);
          mask-image: var(--m-fade), var(--m-peek);
}
.ig4-wall {
  --step: 190ms;
  position: absolute; left: 50%; top: 50%;
  translate: -50% -50%;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  gap: var(--gap);
}

@property --lit { syntax: '<number>'; inherits: true; initial-value: 0; }

.ig4-cell {
  position: relative;
  display: grid; place-items: center;
  border-radius: calc(var(--r) + var(--slot));
  background: rgb(16 24 40 / .035);
  box-shadow:
    inset 0 1px 2px rgb(16 24 40 / .09),
    inset 0 0 0 1px rgb(16 24 40 / .04),
    inset 0 0 0 var(--slot) rgb(35 71 255 / calc(var(--lit) * .14)),
    inset 0 0 0 1.5px rgb(35 71 255 / calc(var(--lit) * .55)),
    0 1px 0 rgb(255 255 255 / .9);
}

.ig4-cell .ig-tile,
.ig4-hub {
  --tile: var(--chip);
  width: var(--chip); height: var(--chip);
  border-radius: var(--r);
  animation: ig4Plug .75s cubic-bezier(.3, .7, .3, 1) both;
  animation-delay: calc(.4s + var(--d) * .9s);
}
.ig4-cell .ig-tile {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--ll-blue) calc(var(--lit) * 45%), #e9e9ec);
  box-shadow: 0 1px 1px rgb(16 24 40 / .06), 0 2px 5px -2px rgb(16 24 40 / .1);
  transition: background-color .15s ease, border-color .15s ease;
}
@keyframes ig4Plug {
  0%   { opacity: 0; transform: translateY(-12px) scale(1.06); box-shadow: 0 20px 28px -14px rgb(16 24 40 / .3); }
  55%  { opacity: 1; }
  80%  { transform: translateY(1px) scale(.985); }
  100% { opacity: 1; transform: none; }
}

.ig4-cell .ig-tile img,
.ig4-cell .ig-tile svg {
  width: 46%; height: 46%;
  --grey: calc(var(--g) * (1 - var(--lit)));
  filter: grayscale(var(--grey)) contrast(calc(1 - var(--grey) * .55)) brightness(calc(1 + var(--grey) * .35));
  transition: filter .2s ease;
}
.ig4-cell .ig-tile--app img { width: 52%; height: 52%; }

a.ig4-cell:hover .ig-tile { background: #f7f7f8; border-color: #d9dade; }
a.ig4-cell:hover .ig-tile img { filter: none; }

.ig4-name {
  position: absolute; left: 0; top: 0; z-index: 3;
  max-width: calc(var(--cell) * 2);
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--ll-black); color: #fff;
  font: 500 11.5px/1 var(--font-ui); letter-spacing: -.004em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 8px 18px -10px rgb(0 0 0 / .45);
  translate: -50% -50%;
  opacity: 0; transform: translateY(4px);
  transition: opacity .18s ease, transform .25s cubic-bezier(.2, .8, .3, 1);
  pointer-events: none;
}
.ig4-name.is-on { opacity: 1; transform: none; }

.ig4-hub {
  position: relative;
  display: grid; place-items: center;
  padding: 0; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #4d6bff 0%, var(--ll-blue) 62%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .28),
    inset 0 0 0 1px rgb(255 255 255 / .08),
    0 2px 4px rgb(35 71 255 / .2),
    0 14px 28px -12px rgb(35 71 255 / .55);
  animation-delay: .15s;
}
.ig4-hub svg { width: 38%; fill: #fff; }
.ig4-hub { transition: scale .12s ease; }
.ig4-hub:active { scale: .97; }
.ig4-hub::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  background: #fff; opacity: 0;
  pointer-events: none;
}

.ig4-current {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.ig4-current path { fill: none; stroke: var(--ll-blue); stroke-linecap: butt; }
.ig4-current__trace path {
  stroke-width: 1.5;
  stroke-dasharray: 1 1; stroke-dashoffset: 1;
  opacity: 0;
}
.ig4-current__spark { filter: drop-shadow(0 0 2px rgb(35 71 255 / .9)) drop-shadow(0 0 7px rgb(35 71 255 / .55)); }
.ig4-current__spark path {
  stroke-width: 2.2;
  stroke-dasharray: .6 3; stroke-dashoffset: .6;
  opacity: 0;
}

.is-zap .ig4-current__trace path {
  animation:
    ig4Draw calc(var(--step) / 2) linear calc(var(--t) * var(--step)) both,
    ig4Fade .9s ease-out calc((var(--t) + .5) * var(--step) + .15s) both;
}
.is-zap .ig4-current__spark path {
  opacity: 1;
  animation: ig4Run calc(var(--step) * .8) linear calc(var(--t) * var(--step)) both;
}
.is-zap .ig4-cell:not(.ig4-cell--hub) { animation: ig4Lit 1.1s ease-out calc(var(--t) * var(--step)) both; }
.is-zap .ig4-hub::after { animation: ig4Flash .5s ease-out both; }

@keyframes ig4Draw  { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ig4Fade  { from { opacity: .6; } to { opacity: 0; } }
@keyframes ig4Run   { from { stroke-dashoffset: .6; } to { stroke-dashoffset: -1; } }
@keyframes ig4Lit   { 0% { --lit: 0; } 12% { --lit: 1; } 100% { --lit: 0; } }
@keyframes ig4Flash { 0% { opacity: .4; } 100% { opacity: 0; } }

.ig4--iso .ig4-wall {
  transform: rotateX(54.74deg) rotateZ(45deg);
  transform-style: preserve-3d;
}
.ig4--iso .ig4-cell { transform-style: preserve-3d; }

.ig4--iso .ig4-cell .ig-tile,
.ig4--iso .ig4-hub {
  transform: translateZ(6px);
  animation-name: ig4Drop;
}
.ig4--iso .ig4-cell .ig-tile {
  border-color: #e6e7eb;
  box-shadow:
    1px 1px 0 #e4e5ea, 2px 2px 0 #e1e3e8, 3px 3px 0 #dfe0e6,
    4px 4px 0 #dcdee4, 5px 5px 0 #dadce2, 6px 6px 0 #d6d8df,
    14px 14px 18px -6px rgb(16 24 40 / .16);
}
.ig4--iso .ig4-hub {
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .28),
    1px 1px 0 #1e3cf0, 2px 2px 0 #1b37e0, 3px 3px 0 #1932d2,
    4px 4px 0 #172ec4, 5px 5px 0 #152ab6, 6px 6px 0 #1326a8,
    16px 16px 24px -6px rgb(35 71 255 / .45);
}
.ig4--iso .ig-tile img,
.ig4--iso .ig-tile svg,
.ig4--iso .ig4-hub svg { rotate: -45deg; }
@keyframes ig4Drop {
  0%   { opacity: 0; transform: translateZ(70px); }
  45%  { opacity: 1; }
  80%  { transform: translateZ(5px); }
  100% { opacity: 1; transform: translateZ(6px); }
}

@media (max-width: 900px) {
  .ig4 { --cell: 84px; --gap: 9px; --pad: 24px; }
  .ig4-panel { margin-top: 48px; border-radius: 22px; }
}

@media (max-width: 560px) {
  .ig4 { --cell: 64px; --gap: 7px; --pad: 20px; }
  .ig4-panel { margin-top: 40px; border-radius: 20px; }
  .ig4-field { --m-fade: radial-gradient(64% 58% at 50% 50%, var(--fade)); }
  .ig4-name { font-size: 10.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .ig4-cell .ig-tile, .ig4-hub { animation: none; }
  .ig4-cell .ig-tile, .ig4-cell .ig-tile img, .ig4-name { transition: none; }
}
