:root {
  --ink: #0a0a12;
  --screen: #111323;
  --screen-high: #1c2035;
  --console: #d7d4cb;
  --console-edge: #747276;
  --console-shadow: #34343c;
  --yellow: #ffe14b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: var(--ink);
}

button { font: inherit; }
[hidden] { display: none !important; }

.machine {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 42%, rgb(59 65 108 / 34%), transparent 41%),
    linear-gradient(145deg, var(--screen-high), var(--screen) 52%, #080912);
}

.ambient-grid {
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.19;
  background-image:
    linear-gradient(rgb(120 130 188 / 18%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(120 130 188 / 18%) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black, transparent 73%);
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0.15;
  background: repeating-linear-gradient(0deg, transparent 0 3px, #000 3px 5px);
  mix-blend-mode: multiply;
}

.sound-toggle {
  position: fixed;
  z-index: 20;
  top: max(1.1rem, env(safe-area-inset-top));
  right: max(1.1rem, env(safe-area-inset-right));
  display: grid;
  width: 2.75rem;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #5d627f;
  border-radius: 3px;
  color: #9da5d1;
  background: #181a2b;
  box-shadow: 4px 4px 0 #070810;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.sound-toggle img { grid-area: 1 / 1; }

.sound-toggle:hover,
.sound-toggle:focus-visible {
  border-color: #fff;
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

.sound-toggle:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #070810;
}

.button-stage {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(88vw, 35rem);
  place-items: center;
  perspective: 900px;
}

.console {
  --anticipation: 0;
  position: relative;
  width: min(82vw, 29rem);
  aspect-ratio: 1.55;
  border: clamp(5px, 1.2vw, 9px) solid var(--console-edge);
  border-right-color: #4d4c52;
  border-bottom-color: var(--console-shadow);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgb(255 255 255 / 44%), transparent 12%),
    repeating-linear-gradient(90deg, transparent 0 6px, rgb(88 87 90 / 5%) 6px 7px),
    var(--console);
  box-shadow:
    0 2px 0 #f5f2ea inset,
    0 -12px 0 #aaa7a0 inset,
    0 26px 0 #272832,
    0 38px 45px rgb(0 0 0 / 52%);
  transform: rotateX(5deg);
}

.console::before,
.console::after {
  position: absolute;
  bottom: -18px;
  width: 36px;
  height: 10px;
  content: '';
  background: #171821;
}

.console::before { left: 34px; }
.console::after { right: 34px; }

.console-highlight {
  position: absolute;
  inset: 7% 5% auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, #faf8f0, transparent);
  opacity: 0.72;
}

.button-well {
  position: absolute;
  left: 50%;
  top: 46%;
  display: grid;
  width: clamp(9.5rem, 36vw, 12rem);
  aspect-ratio: 1;
  place-items: center;
  border: 9px solid #4a494e;
  border-top-color: #69686c;
  border-left-color: #5d5c61;
  border-radius: 50%;
  background: #292a31;
  box-shadow: 0 4px 0 #16171c inset, 0 -3px 0 #858388;
  transform: translate(-50%, -50%);
}

.red-button {
  width: 82%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 8px 0 #34050d) drop-shadow(0 8px 12px rgb(0 0 0 / 48%));
  transform: translateY(-5px);
  transition: transform 80ms steps(2), filter 140ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.red-button img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.red-button:hover { filter: brightness(1.06) saturate(1.12) drop-shadow(0 8px 0 #34050d) drop-shadow(0 8px 12px rgb(0 0 0 / 48%)); }

.red-button:focus-visible {
  outline: 5px solid var(--yellow);
  outline-offset: 8px;
}

.red-button:active,
.console.is-pressed .red-button {
  transform: translateY(6px);
  filter: drop-shadow(0 2px 0 #34050d) drop-shadow(0 4px 5px rgb(0 0 0 / 40%));
}

.console.is-lit .red-button {
  filter:
    brightness(1.22)
    saturate(1.18)
    drop-shadow(0 8px 0 #34050d)
    drop-shadow(0 0 calc(22px + 34px * var(--anticipation)) rgb(255 49 88 / 80%));
  animation: button-glow 820ms steps(2) infinite;
}

.console.is-celebrating .red-button { animation-duration: 260ms; }

.status-lamp {
  position: absolute;
  top: 18%;
  right: 12%;
  width: 13px;
  aspect-ratio: 1;
  border: 3px solid #5a585c;
  border-radius: 1px;
  background: #542429;
  box-shadow: 0 2px 0 #fff9 inset;
}

.console.is-lit .status-lamp {
  background: var(--yellow);
  box-shadow: 0 0 16px #fff16a, 0 2px 0 #fff9 inset;
}

.speaker-slots {
  position: absolute;
  right: 9%;
  bottom: 13%;
  display: flex;
  gap: 6px;
}

.speaker-slots i {
  display: block;
  width: 5px;
  height: 25px;
  border-radius: 2px;
  background: #6d6b70;
  box-shadow: 1px 1px 0 #f4f1e9;
  transform: skewX(-7deg);
}

@keyframes button-glow {
  50% { filter: brightness(1.4) saturate(1.24) drop-shadow(0 8px 0 #34050d) drop-shadow(0 0 52px rgb(255 49 88 / 88%)); }
}

@media (max-width: 520px) {
  .console { width: min(90vw, 25rem); aspect-ratio: 1.25; }
  .button-well { top: 48%; width: min(45vw, 10.5rem); }
  .speaker-slots { bottom: 9%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
