:root {
  --night: #1a1b26;
  --storm: #24283b;
  --line: #414868;
  --blue: #7aa2f7;
  --cyan: #7dcfff;
  --green: #9ece6a;
  --unit: clamp(1.25rem, 3.2vw, 2.8rem);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--night);
  cursor: crosshair;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .1;
  background-image:
    linear-gradient(rgb(65 72 104 / .08) 1px, transparent 1px),
    linear-gradient(90deg, rgb(65 72 104 / .08) 1px, transparent 1px);
  background-size: 2.5rem 2.5rem;
  mask-image: radial-gradient(circle at center, black, transparent 62%);
}

.mark {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  position: relative;
  width: calc(var(--unit) * 7);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: calc(var(--unit) * .18);
  filter: drop-shadow(0 0 1.75rem rgb(122 162 247 / .04));
  transform: perspective(52rem) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) rotateZ(45deg);
  transition: transform .36s cubic-bezier(.2, .8, .2, 1), filter .3s ease;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mark:focus-visible { filter: drop-shadow(0 0 2rem rgb(125 207 255 / .12)); }
.mark.is-pressed {
  filter: drop-shadow(0 0 2rem rgb(125 207 255 / .1));
  transform: perspective(52rem) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) rotateZ(45deg) scale(.982);
}

.cell {
  --heat: 0;
  --pulse-delay: 0ms;
  --drift-x: 0px;
  --drift-y: 0px;
  --i: 0;
  position: relative;
  border: max(1px, .075rem) solid var(--line);
  background: rgb(36 40 59 / .38);
  transform: translate(var(--drift-x), var(--drift-y)) scale(calc(1 + var(--heat) * .06));
  box-shadow: 0 0 calc(var(--heat) * .65rem) color-mix(in srgb, currentColor 20%, transparent);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1), box-shadow .24s ease-out, border-color .4s ease, background-color .4s ease, color .4s ease;
}

.cell::before {
  content: "";
  position: absolute;
  inset: -10%;
  border: max(1px, .075rem) solid currentColor;
  opacity: 0;
  pointer-events: none;
}
.cell.burst::before { animation: ripple .68s cubic-bezier(.16, 1, .3, 1) var(--pulse-delay) both; }

.green { color: var(--green); border-color: var(--green); }
.blue { color: var(--blue); border-color: var(--blue); }
.cyan { color: var(--cyan); border-color: var(--cyan); }
.signal:not(.solid):not(.core) { border-color: color-mix(in srgb, currentColor 62%, var(--line)); }
.solid { background: currentColor; box-shadow: 0 0 .7rem color-mix(in srgb, currentColor 12%, transparent); }
.ghost { color: var(--line); border-color: color-mix(in srgb, var(--line) 32%, transparent); background: transparent; }
.void { visibility: hidden; }
.core { border-width: max(2px, .12rem); }

.paused .cell::before { animation-play-state: paused !important; }

@keyframes ripple { 0% { opacity: 0; transform: scale(.55); } 18% { opacity: .55; } 100% { opacity: 0; transform: scale(1.65); } }

@media (max-width: 32rem) {
  :root { --unit: clamp(1rem, 8.5vw, 2rem); }
  body::before { background-size: 2rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cell, .core { animation: none; }
  .mark, .cell { transition: none; }
  .cell.burst::before { animation: none; }
}
