:root {
  --acid: #f3ff4b;
  --ink: #171520;
  --coral: #ff5b45;
  --blue: #2864ff;
  --aqua: #22d6c8;
  --pink: #ff6fb7;
  --paper: #fffce8;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 4px solid var(--paper);
  outline-offset: 3px;
  box-shadow: 0 0 0 7px var(--ink);
}

.app {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  background: var(--acid);
}

#score,
.grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#score {
  z-index: -3;
}

.grain {
  z-index: -2;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: multiply;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.36'/%3E%3C/svg%3E");
}

.mast {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(18px, 3vw, 44px);
  border-bottom: 2px solid rgba(23, 21, 32, 0.75);
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.11em;
}

.live-dot {
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 14px 0 0 -3px var(--ink), 28px 0 0 -4px var(--ink);
}

.sound-toggle {
  display: flex;
  min-width: 128px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: rgba(255, 252, 232, 0.84);
  cursor: pointer;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
  box-shadow: 4px 4px 0 var(--ink);
}

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

.sound-icon {
  font-size: 17px;
}

.intro {
  position: absolute;
  z-index: 2;
  left: clamp(20px, 5vw, 78px);
  bottom: clamp(72px, 10vh, 120px);
  width: min(880px, calc(100vw - 40px));
  transition: opacity 350ms ease, transform 500ms cubic-bezier(.16, 1, .3, 1);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: clamp(10px, 1vw, 13px);
  font-weight: 500;
  letter-spacing: 0.18em;
}

h1,
h2 {
  margin: 0;
  font-family: "Arial Black", Impact, sans-serif;
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: -0.075em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(64px, 11vw, 176px);
}

h1 span,
h2 span {
  display: block;
}

h1 span:last-child {
  color: var(--paper);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 8px 8px 0 var(--ink);
}

.lede {
  max-width: 540px;
  margin: 24px 0 22px;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.start-row {
  display: flex;
  align-items: center;
  gap: 22px;
}

.start-button,
.again-button {
  display: inline-flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 21px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--coral);
  box-shadow: 7px 7px 0 var(--ink);
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.start-button:hover,
.again-button:hover {
  background: var(--pink);
}

.start-button:active,
.again-button:active {
  transform: translate(5px, 5px);
  box-shadow: 2px 2px 0 var(--ink);
}

.button-arrow {
  font-size: 24px;
}

.input-note {
  max-width: 300px;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
}

kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid currentColor;
  background: rgba(255, 252, 232, 0.72);
  box-shadow: 2px 2px 0 currentColor;
  font: inherit;
  font-size: 0.9em;
}

.performance {
  position: absolute;
  z-index: 3;
  inset: 86px clamp(18px, 3vw, 44px) 60px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease;
}

.chapter {
  position: absolute;
  top: 14px;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.chapter strong {
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(18px, 2.5vw, 34px);
  letter-spacing: -0.04em;
}

.prompt {
  position: absolute;
  left: 50%;
  top: 10px;
  width: min(560px, 52vw);
  transform: translateX(-50%);
  text-align: center;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(22px, 4vw, 62px);
  line-height: 0.95;
  letter-spacing: -0.055em;
  text-transform: uppercase;
}

.feel {
  position: absolute;
  top: 14px;
  right: 0;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.feel-label {
  font-size: 10px;
  letter-spacing: 0.14em;
}

.feel strong {
  padding: 7px 10px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: clamp(14px, 2vw, 24px);
  letter-spacing: -0.05em;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  background: var(--paper);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 90ms linear;
}

.mic-status {
  position: absolute;
  z-index: 6;
  left: clamp(18px, 3vw, 44px);
  bottom: calc(var(--safe-bottom) + 25px);
  display: none;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.mic-status button {
  min-height: 30px;
  border: 1px solid var(--ink);
  background: var(--acid);
  cursor: pointer;
  font-size: 9px;
}

.mic-mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
}

.mic-status.is-listening .mic-mark {
  background: #12ad52;
  box-shadow: 0 0 0 4px rgba(18, 173, 82, 0.22);
}

.tap-catcher {
  position: absolute;
  z-index: 5;
  right: clamp(18px, 3vw, 44px);
  bottom: calc(var(--safe-bottom) + 22px);
  display: none;
  width: 84px;
  height: 84px;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: 18px;
}

.tap-catcher:active,
.tap-catcher.is-hit {
  transform: translate(5px, 5px) scale(0.94);
  box-shadow: 1px 1px 0 var(--ink);
  background: var(--paper);
}

.ending {
  position: absolute;
  z-index: 5;
  left: clamp(20px, 6vw, 90px);
  top: 50%;
  width: min(980px, calc(100vw - 40px));
  opacity: 0;
  pointer-events: none;
  transform: translateY(-44%) scale(0.97);
  transition: opacity 500ms ease, transform 700ms cubic-bezier(.16, 1, .3, 1);
}

.ending h2 {
  font-size: clamp(58px, 9.6vw, 154px);
}

.ending h2 span:last-child {
  color: var(--blue);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 7px 7px 0 var(--ink);
}

.ending > p:not(.eyebrow) {
  max-width: 620px;
  margin: 24px 0;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(16px, 2vw, 25px);
  letter-spacing: -0.035em;
}

.ending-stats {
  display: flex;
  max-width: 720px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 7px 7px 0 var(--ink);
}

.ending-stats div {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-right: 2px solid var(--ink);
}

.ending-stats div:last-child {
  border-right: 0;
}

.ending-stats span,
.ending-stats strong {
  display: block;
}

.ending-stats span {
  margin-bottom: 6px;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ending-stats strong {
  overflow: hidden;
  font-family: "Arial Black", Impact, sans-serif;
  font-size: clamp(18px, 3vw, 35px);
  letter-spacing: -0.06em;
  text-overflow: ellipsis;
}

.again-button {
  margin-top: 25px;
  background: var(--aqua);
}

footer {
  position: absolute;
  z-index: 4;
  left: clamp(18px, 3vw, 44px);
  right: clamp(18px, 3vw, 44px);
  bottom: var(--safe-bottom);
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 8px;
  letter-spacing: 0.12em;
}

.app[data-state="playing"] .intro {
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
}

.app[data-state="playing"] .performance {
  opacity: 1;
}

.app[data-state="playing"] .tap-catcher,
.app[data-state="playing"] .mic-status {
  display: flex;
}

.app[data-state="ending"] .intro,
.app[data-state="ending"] .performance,
.app[data-state="ending"] .tap-catcher,
.app[data-state="ending"] .mic-status {
  opacity: 0;
  pointer-events: none;
}

.app[data-state="ending"] .ending {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.app.flash::after {
  content: "";
  position: absolute;
  z-index: 12;
  inset: 0;
  pointer-events: none;
  background: var(--paper);
  animation: flash 180ms steps(2, end) forwards;
}

@keyframes flash {
  from { opacity: 0.72; }
  to { opacity: 0; }
}

@media (max-width: 680px) {
  .app {
    min-height: 480px;
  }

  .mast {
    padding: 14px 16px;
  }

  .kicker {
    max-width: 190px;
    font-size: 8px;
  }

  .sound-toggle {
    min-width: 96px;
    min-height: 40px;
    padding: 0 8px;
    font-size: 8px;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .intro {
    left: 16px;
    bottom: 60px;
    width: calc(100vw - 32px);
  }

  h1 {
    font-size: clamp(54px, 18vw, 104px);
    line-height: 0.87;
  }

  h1 span:last-child {
    -webkit-text-stroke-width: 2px;
    text-shadow: 5px 5px 0 var(--ink);
  }

  .lede {
    max-width: 90%;
    margin: 18px 0;
    font-size: 16px;
  }

  .start-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .start-button {
    min-height: 54px;
    width: 100%;
  }

  .input-note {
    max-width: 90%;
    font-size: 9px;
  }

  .performance {
    inset: 70px 16px 55px;
  }

  .chapter {
    top: 8px;
    max-width: 34vw;
  }

  .chapter strong {
    font-size: 14px;
  }

  .prompt {
    top: 70px;
    width: 94%;
    font-size: clamp(26px, 8vw, 48px);
    line-height: 0.9;
  }

  .feel {
    top: 8px;
  }

  .feel strong {
    max-width: 48vw;
    font-size: 13px;
    text-align: right;
  }

  .mic-status {
    right: 116px;
    bottom: calc(var(--safe-bottom) + 17px);
    left: 16px;
    min-height: 34px;
    font-size: 8px;
  }

  .tap-catcher {
    right: 18px;
    bottom: calc(var(--safe-bottom) + 14px);
    width: 78px;
    height: 78px;
  }

  .ending {
    left: 16px;
    width: calc(100vw - 32px);
  }

  .ending h2 {
    font-size: clamp(48px, 14vw, 88px);
    line-height: 0.86;
  }

  .ending-stats div {
    padding: 10px 8px;
  }

  .ending-stats span {
    font-size: 6px;
  }

  .ending-stats strong {
    font-size: 16px;
  }

  .again-button {
    width: 100%;
  }

  footer {
    right: 112px;
    left: 16px;
    bottom: var(--safe-bottom);
  }

  footer span:first-child {
    display: none;
  }
}

@media (max-height: 650px) and (min-width: 681px) {
  .intro {
    bottom: 52px;
  }

  h1 {
    font-size: clamp(62px, 10vw, 122px);
  }

  .lede {
    margin: 15px 0;
  }
}

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