*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Share Tech Mono", monospace;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.28) 2px,
    rgba(0, 0, 0, 0.28) 4px
  );
  pointer-events: none;
  z-index: 900;
}

#vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, transparent 20%, rgba(0, 0, 0, 0.72) 100%);
  pointer-events: none;
  z-index: 5;
}

#stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sceneFlicker 0.15s steps(1) 0.1s both;
}

@keyframes sceneFlicker {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  70% {
    opacity: 0.1;
  }
  100% {
    opacity: 1;
  }
}

#morpheus-wrap {
  position: relative;
  width: min(720px, 100%);
  flex-shrink: 0;
}

#morpheus-img {
  width: 100%;
  height: auto;
  display: block;
  filter: grayscale(15%) contrast(1.1) brightness(0.9);
}

.pill-btn {
  position: absolute;
  z-index: 30;
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  width: clamp(21px, 3vw, 34px);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  transition: transform 0.18s, filter 0.18s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: grid;
  place-items: center;
}

#btn-blue {
  left: 18%;
  top: 84.5%;
}

#btn-red {
  left: 82%;
  top: 84.5%;
}

.pill-btn img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.65));
}

#btn-blue:hover,
#btn-blue:focus-visible {
  transform: translate(-50%, -50%) scale(1.14);
  filter: brightness(1.22) saturate(1.08);
  outline: none;
}

#btn-red:hover,
#btn-red:focus-visible {
  transform: translate(-50%, -50%) scale(1.14);
  filter: brightness(1.22) saturate(1.08);
  outline: none;
}

#btn-blue:active,
#btn-red:active {
  transform: translate(-50%, -50%) scale(0.95);
}

#speech-wrap {
  position: absolute;
  top: clamp(-132px, -17vw, -92px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  animation: fadeUp 1.2s ease 0.4s both;
  width: min(90vw, 560px);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.bubble {
  position: relative;
  background: #fff;
  border: 3px solid #111;
  border-radius: 14px;
  padding: clamp(8px, 1.5vw, 14px) clamp(16px, 3vw, 28px);
  box-shadow: 4px 4px 0 #111;
  white-space: normal;
  text-align: center;
}

.bubble::before {
  content: "";
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 18px solid #111;
}

.bubble::after {
  content: "";
  position: absolute;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 14px solid #fff;
  z-index: 1;
}

.bubble-text {
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(1.05rem, 2.45vw, 1.65rem);
  color: #0a0a0a;
  letter-spacing: 0.035em;
  line-height: 1.15;
  text-transform: uppercase;
}

#pill-hints {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  animation: hintFadeUp 1.2s ease 0.4s both;
}

@keyframes hintFadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.pill-bubble {
  position: absolute;
  width: clamp(96px, 17vw, 178px);
  transform: translate(-50%, -100%);
  background: #e9f5ff;
  border: 3px solid #111;
  border-radius: 12px;
  padding: clamp(6px, 1vw, 9px) clamp(8px, 1.4vw, 12px);
  box-shadow: 3px 3px 0 #111;
  text-align: center;
  font-family: "Share Tech Mono", monospace;
  font-size: clamp(0.82rem, 1.45vw, 1.08rem);
  color: #0a0a0a;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-transform: lowercase;
}

#hint-blue {
  left: 18%;
  top: 76.8%;
  background: #cde6ff;
}

#hint-red {
  left: 82%;
  top: 76.8%;
  background: #ffd2d2;
}

#sublabel {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  color: #383838;
  font-size: clamp(8px, 1vw, 11px);
  letter-spacing: 0.18em;
  white-space: nowrap;
  z-index: 50;
  animation: fadeUp 1.5s ease 1s both;
}

#matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#matrix-canvas.active {
  pointer-events: all;
}

@media (max-width: 640px) {
  #stage {
    justify-content: flex-end;
    padding-bottom: max(env(safe-area-inset-bottom), 14px);
  }

  #morpheus-wrap {
    width: min(640px, 100%);
    margin: 0 auto;
  }

  #speech-wrap {
    top: clamp(-128px, -26vw, -90px);
    width: min(92vw, 520px);
  }

  #btn-blue {
    left: 18.9%;
    top: 84.9%;
  }

  #btn-red {
    left: 81.1%;
    top: 84.9%;
  }

  .pill-btn {
    width: clamp(16px, 4.3vw, 20px);
  }

  .pill-btn img {
    width: 68%;
  }

  #hint-blue {
    left: 18.9%;
    top: 76.1%;
  }

  #hint-red {
    left: 81.1%;
    top: 76.1%;
  }

  .pill-bubble {
    width: clamp(110px, 27vw, 156px);
    font-size: clamp(0.74rem, 2.85vw, 1rem);
    padding: 6px 8px;
  }

  .bubble-text {
    font-size: clamp(1rem, 4.85vw, 1.25rem);
    letter-spacing: 0.02em;
    line-height: 1.16;
  }
}

@media (max-width: 420px) {
  #morpheus-wrap {
    width: min(640px, 100%);
  }

  #speech-wrap {
    top: clamp(-118px, -27vw, -92px);
  }

  #btn-blue {
    left: 19.3%;
    top: 84.7%;
  }

  #btn-red {
    left: 80.7%;
    top: 84.7%;
  }

  .pill-btn {
    width: clamp(15px, 4.2vw, 18px);
  }

  .pill-btn img {
    width: 64%;
  }

  #hint-blue {
    left: 19.3%;
    top: 75.7%;
  }

  #hint-red {
    left: 80.7%;
    top: 75.7%;
  }

  .pill-bubble {
    width: clamp(100px, 29vw, 142px);
    font-size: clamp(0.7rem, 2.95vw, 0.92rem);
    padding: 5px 7px;
    border-width: 2px;
  }
}
