:root {
  color-scheme: dark;
  --ink: #f3f0e8;
  --dim: rgba(243, 240, 232, 0.54);
  --faint: rgba(243, 240, 232, 0.16);
  --void: #050505;
  --danger: #ff6b5f;
  font-family: "Courier New", Courier, monospace;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  content: "";
  opacity: 0.14;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 3px,
    rgba(255, 255, 255, 0.055) 4px
  );
  mix-blend-mode: screen;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.chrome {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

h1 {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  width: min(90vw, 980px);
  margin: 0;
  transform: translateX(-50%);
  font-size: clamp(1.55rem, 4.6vw, 4.5rem);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.07em;
  text-align: center;
  text-transform: lowercase;
  text-shadow: 0 0 18px rgba(243, 240, 232, 0.18);
}

.hud {
  position: absolute;
  top: max(94px, calc(env(safe-area-inset-top) + 86px));
  right: max(16px, env(safe-area-inset-right));
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  color: var(--dim);
  font-size: clamp(0.62rem, 1.25vw, 0.78rem);
  line-height: 1.45;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  color: var(--ink);
  font-size: 1.12em;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.hud .right {
  text-align: right;
}

.sound {
  position: fixed;
  right: max(15px, env(safe-area-inset-right));
  bottom: max(15px, env(safe-area-inset-bottom));
  z-index: 12;
  width: 42px;
  height: 42px;
  border: 1px solid var(--faint);
  border-radius: 50%;
  color: var(--dim);
  background: rgba(5, 5, 5, 0.66);
  font:
    16px/1 "Courier New",
    monospace;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    color 0.18s ease;
}

.sound:hover,
.sound:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  outline: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 112px 24px 92px;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(5, 5, 5, 0.46),
    rgba(5, 5, 5, 0.06) 42%,
    transparent 68%
  );
  transition: opacity 0.2s ease;
}

.modal[hidden] {
  display: none;
}

.card {
  width: min(520px, 92vw);
  padding: 30px 26px 26px;
  border: 1px solid rgba(243, 240, 232, 0.7);
  background: rgba(5, 5, 5, 0.91);
  box-shadow:
    0 0 0 5px rgba(5, 5, 5, 0.68),
    0 0 44px rgba(243, 240, 232, 0.06);
  text-align: center;
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--dim);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.card h2 {
  margin: 0 auto 16px;
  max-width: 460px;
  font-size: clamp(1.25rem, 4.5vw, 2rem);
  font-weight: 400;
  line-height: 1.18;
  text-transform: lowercase;
}

.card p {
  margin: 0 auto 24px;
  color: var(--dim);
  font-size: 0.75rem;
  line-height: 1.7;
}

.primary {
  min-height: 46px;
  padding: 0 19px;
  border: 1px solid var(--ink);
  color: var(--void);
  background: var(--ink);
  font:
    700 0.72rem/1 "Courier New",
    monospace;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  cursor: pointer;
}

.primary:hover,
.primary:focus-visible {
  color: var(--ink);
  background: var(--void);
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

.wave-message {
  position: fixed;
  top: 51%;
  left: 50%;
  z-index: 7;
  width: min(90vw, 760px);
  transform: translate(-50%, -50%);
  color: var(--ink);
  font-size: clamp(1rem, 3vw, 1.8rem);
  letter-spacing: 0.13em;
  text-align: center;
  text-transform: lowercase;
  opacity: 0;
  pointer-events: none;
}

.wave-message.show {
  animation: announce 2.2s ease both;
}

@keyframes announce {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%);
  }
  18%,
  68% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%);
  }
}

.touch-controls {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 8;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-group {
  display: flex;
  gap: 10px;
}

.touch {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(243, 240, 232, 0.42);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(5, 5, 5, 0.52);
  font:
    18px/1 "Courier New",
    monospace;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.touch.fire {
  width: 68px;
  height: 68px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.touch.active {
  color: var(--void);
  background: var(--ink);
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
  .sound {
    right: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(50%);
  }
  .modal {
    padding-bottom: 108px;
  }
}

@media (max-width: 560px) {
  h1 {
    top: max(16px, env(safe-area-inset-top));
    font-size: clamp(1.7rem, 9vw, 2.65rem);
  }
  .hud {
    top: max(84px, calc(env(safe-area-inset-top) + 76px));
  }
  .card {
    padding: 25px 19px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wave-message.show {
    animation-duration: 0.01ms;
  }
}

.back-home,
.pause-control {
  position: fixed;
  top: 18px;
  z-index: 30;
  font: 10px Courier New;
  color: #b9b0a6;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}
.back-home {
  left: 14px;
}
.pause-control {
  right: 14px;
}
.extra-hud {
  position: fixed;
  bottom: 25px;
  left: 25px;
  right: 80px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  z-index: 8;
  pointer-events: none;
  color: #ac9a9d;
  font: 10px Courier New;
}
.difficulty {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0 0 18px;
}
.difficulty button {
  font: 10px Courier New;
  color: #b9b0a6;
  border: 1px solid #54464a;
  padding: 8px 10px;
  background: transparent;
  cursor: pointer;
}
.difficulty button[aria-pressed="true"] {
  background: #6d3c49;
  color: #f3f0e8;
  border-color: #9c6373;
}
.touch-controls {
  gap: 7px;
}
.touch-group {
  gap: 7px;
}
@media (max-width: 760px) {
  h1 {
    top: 54px;
    font-size: clamp(1.6rem, 7vw, 2.6rem);
  }
  .hud {
    top: 112px;
  }
  .extra-hud {
    bottom: 102px;
    left: 16px;
    right: 16px;
    font-size: 9px;
  }
  .touch {
    width: 47px;
    height: 47px;
  }
  .touch.fire {
    width: 54px;
    height: 54px;
  }
  .sound {
    bottom: 160px;
  }
  .card {
    margin-top: 50px;
  }
  .back-home,
  .pause-control {
    top: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  body::after {
    display: none;
  }
}
