:root {
  color-scheme: light;
  --ink: #151510;
  --paper: #d9d9d0;
  --acid: #e8ff47;
  --orange: #ff552e;
  --blue: #2667ff;
  --violet: #9b51ff;
  --shadow: rgba(21, 21, 16, 0.2);
  --ease: cubic-bezier(.2, .9, .2, 1);
  font-family: "Arial Narrow", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100svh;
  position: relative;
  isolation: isolate;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.daily-mark {
  position: fixed;
  z-index: 30;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  width: 74px;
  height: 74px;
  display: grid;
  align-content: space-between;
  padding: 9px;
  border: 2px solid var(--ink);
  background: var(--acid);
  text-decoration: none;
  font-size: 10px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .08em;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.daily-mark:hover,
.daily-mark:focus-visible {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.mast {
  position: fixed;
  z-index: 4;
  top: max(18px, env(safe-area-inset-top));
  left: 112px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.mast h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(34px, 4.1vw, 70px);
  line-height: .77;
  letter-spacing: -.035em;
  font-weight: 900;
}

.sound-toggle {
  position: fixed;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  min-width: 112px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

.sound-dot {
  width: 10px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
}

.sound-toggle[aria-pressed="true"] .sound-dot {
  background: var(--orange);
}

.stage {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
}

.keyboard-scene {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  perspective: 1100px;
  background:
    linear-gradient(90deg, transparent 49.85%, rgba(21, 21, 16, .16) 50%, transparent 50.15%),
    linear-gradient(180deg, var(--paper), #c8c8bf 74%, #bdbdb5);
}

.keyboard-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .28;
  background-image: radial-gradient(rgba(21, 21, 16, .4) .65px, transparent .8px);
  background-size: 5px 5px;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.horizon {
  position: absolute;
  left: 50%;
  top: 55%;
  width: 150vmax;
  height: 150vmax;
  border: 1px solid rgba(21, 21, 16, .18);
  border-radius: 50%;
  transform: translate(-50%, -50%) rotateX(70deg);
}

.horizon-two {
  width: 102vmax;
  height: 102vmax;
}

.keyboard {
  --scene-tilt: 57deg;
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(1100px, 86vw);
  display: grid;
  gap: clamp(7px, .8vw, 14px);
  transform-style: preserve-3d;
  transform: translate(-50%, -37%) rotateX(var(--scene-tilt)) rotateZ(-1deg);
  transition: transform 900ms var(--ease), filter 400ms ease;
}

.key-row {
  display: grid;
  gap: clamp(5px, .65vw, 11px);
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  transform-style: preserve-3d;
}

.key-row-number {
  --columns: 10;
  width: 88%;
  margin-inline: auto;
}

.key-row-top {
  --columns: 10;
  width: 96%;
  margin-inline: auto;
}

.key-row-home {
  --columns: 9;
  width: 91%;
  margin-inline: auto;
}

.key-row-bottom {
  --columns: 7;
  width: 72%;
  margin-inline: auto;
}

.key-row-space {
  --columns: 1;
  width: 44%;
  margin-inline: auto;
}

.key {
  --rise: 0px;
  --key-color: var(--paper);
  position: relative;
  aspect-ratio: 1.08;
  min-width: 0;
  display: grid;
  align-items: end;
  padding: clamp(5px, .7vw, 11px);
  overflow: visible;
  border: clamp(1.5px, .18vw, 3px) solid var(--ink);
  border-radius: clamp(6px, .65vw, 12px);
  background: var(--key-color);
  color: var(--ink);
  font-size: clamp(11px, 1.35vw, 22px);
  line-height: 1;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow:
    0 9px 0 #a3a39b,
    0 12px 0 var(--ink);
  transform: translateZ(var(--rise));
  transition:
    transform 120ms var(--ease),
    background 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    opacity 180ms ease;
}

.key[data-code="Space"] {
  aspect-ratio: 6 / 1;
  align-items: center;
  justify-items: center;
}

.key::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -8px;
  border: 2px solid transparent;
  border-radius: inherit;
  opacity: 0;
  transform: scale(.82);
  transition: opacity 180ms ease, transform 320ms var(--ease);
}

.key.is-requested {
  --key-color: var(--acid);
}

.key.is-requested::before {
  border-color: var(--ink);
  opacity: .28;
  transform: scale(1.06);
}

.key.is-held {
  --rise: clamp(44px, 6vw, 92px);
  --key-color: var(--orange);
  color: #fff;
  box-shadow:
    0 16px 0 #b82c14,
    0 20px 0 var(--ink);
}

.key.is-held:nth-child(3n + 2) {
  --key-color: var(--blue);
  box-shadow:
    0 16px 0 #173aa9,
    0 20px 0 var(--ink);
}

.key.is-held:nth-child(4n) {
  --key-color: var(--violet);
  box-shadow:
    0 16px 0 #58239c,
    0 20px 0 var(--ink);
}

.key.is-missing {
  --rise: -28px;
  --key-color: #7b7b74;
  color: #292924;
  opacity: .62;
  box-shadow: inset 0 8px 0 rgba(21, 21, 16, .35);
}

.key.is-missing::after {
  content: "NOT REPORTED";
  position: absolute;
  left: 50%;
  bottom: -34px;
  width: max-content;
  transform: translateX(-50%) rotateX(-57deg);
  font-size: 9px;
  letter-spacing: .09em;
  color: var(--ink);
}

.touch-field {
  display: none;
}

.wave {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 57%;
  width: 8vmin;
  height: 8vmin;
  border: 2px solid var(--ink);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.1);
  pointer-events: none;
}

.panel {
  position: absolute;
  z-index: 20;
  width: min(520px, calc(100vw - 36px));
  padding: clamp(22px, 3vw, 42px);
  border: 2px solid var(--ink);
  background: rgba(232, 255, 71, .96);
  box-shadow: 12px 12px 0 var(--ink);
  transition:
    opacity 380ms ease,
    transform 500ms var(--ease),
    visibility 0s linear 500ms;
}

.panel-index {
  margin: 0 0 18px;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(34px, 4.7vw, 62px);
  line-height: .92;
  letter-spacing: -.022em;
  font-weight: 900;
}

.panel p:not(.panel-index, .result-number, .max-readout) {
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.38;
}

.intro {
  right: clamp(20px, 5vw, 82px);
  bottom: clamp(22px, 6vw, 88px);
}

.intro-copy {
  max-width: 42ch;
}

.intro-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 28px;
}

.primary {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--orange);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary:hover,
.primary:focus-visible {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--orange);
}

.text-button {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  border-bottom: 2px solid currentColor;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  color: var(--blue);
}

.trial,
.result,
.finale,
.touch-result {
  left: clamp(18px, 7vw, 110px);
  bottom: clamp(22px, 7vw, 100px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(32px) rotate(-1deg);
}

.trial-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.timer-label {
  margin: -2px 0 0 !important;
  max-width: 155px;
  text-align: right;
  font-size: 10px !important;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.requested {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  margin: 25px 0 18px;
}

.requested-key,
.missing-chip {
  min-width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 7px;
  border: 2px solid var(--ink);
  background: var(--paper);
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--ink);
}

.requested-key.is-received {
  background: var(--orange);
  color: #fff;
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.meter {
  height: 10px;
  margin: 0 0 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
}

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

.skip {
  margin-top: 8px;
}

.result {
  background: rgba(255, 85, 46, .97);
  color: #fff;
}

.result-number {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(90px, 13vw, 180px);
  line-height: .78;
  letter-spacing: -.05em;
}

.result h2 {
  margin-top: 20px;
  font-size: clamp(31px, 4vw, 52px);
}

.missing-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.missing-chip {
  background: #fff;
  color: var(--ink);
}

.finale {
  background: rgba(38, 103, 255, .96);
  color: #fff;
}

.max-readout {
  margin: 24px 0 4px;
  font-size: clamp(18px, 2.2vw, 28px);
  line-height: 1.1;
  font-weight: 900;
  text-transform: uppercase;
}

.max-readout span {
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.8em;
}

.finale .text-button {
  margin-top: 18px;
}

.touch-result {
  background: rgba(155, 81, 255, .96);
  color: #fff;
}

footer {
  position: fixed;
  z-index: 15;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(15px, env(safe-area-inset-bottom));
  display: flex;
  gap: 24px;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  pointer-events: none;
}

footer p {
  margin: 0;
}

#liveStatus {
  max-width: 40ch;
}

html[data-phase="guided"] .intro,
html[data-phase="result"] .intro,
html[data-phase="finale"] .intro,
html[data-phase="touch"] .intro {
  opacity: 0;
  visibility: hidden;
  transform: translateY(32px) rotate(1deg);
}

html[data-phase="guided"] .trial,
html[data-phase="result"] .result,
html[data-phase="finale"] .finale,
html[data-phase="touch"] .touch-result {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) rotate(-1deg);
  transition-delay: 120ms, 120ms, 0s;
}

html[data-phase="result"] .keyboard {
  transform: translate(-43%, -40%) rotateX(64deg) rotateZ(1.5deg);
}

html[data-phase="finale"] .keyboard {
  transform: translate(-50%, -34%) rotateX(50deg) rotateZ(-1deg) scale(1.02);
}

html[data-phase="result"][data-chord="1"][data-signature="passed"] .key-row-home {
  animation: home-sweep 720ms var(--ease);
}

html[data-phase="result"][data-chord="2"][data-signature="passed"] .key-row-top {
  animation: roof-open 780ms var(--ease);
}

html[data-phase="result"][data-chord="3"][data-signature="passed"] .key-row:nth-child(odd) {
  animation: weave-left 820ms var(--ease);
}

html[data-phase="result"][data-chord="3"][data-signature="passed"] .key-row:nth-child(even) {
  animation: weave-right 820ms var(--ease);
}

html[data-signature="passed"] .wave {
  animation: wave-out 850ms var(--ease);
}

html[data-signature="passed"] .keyboard {
  animation: keyboard-kick 900ms var(--ease);
}

html[data-signature="passed"] .mast h1 {
  color: var(--blue);
  text-shadow: 5px 5px 0 var(--acid);
}

html[data-phase="finale"][data-signature="passed"] .finale {
  width: min(360px, calc(100vw - 36px));
  padding: 16px 18px;
  background: rgba(38, 103, 255, .9);
  box-shadow: 7px 7px 0 var(--ink);
}

html[data-phase="finale"][data-signature="passed"] .finale h2,
html[data-phase="finale"][data-signature="passed"] .finale-copy,
html[data-phase="finale"][data-signature="passed"] .finale .text-button {
  display: none;
}

html[data-phase="finale"][data-signature="passed"] .finale .panel-index {
  margin-bottom: 5px;
}

html[data-phase="finale"][data-signature="passed"] .max-readout {
  margin: 0;
  font-size: 15px;
}

@keyframes wave-out {
  0% { opacity: .9; transform: translate(-50%, -50%) scale(.1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(24); }
}

@keyframes keyboard-kick {
  0%, 100% { filter: none; }
  28% { filter: saturate(1.8) contrast(1.15); }
}

@keyframes home-sweep {
  0%, 100% { transform: translateZ(0); }
  32% { transform: translateZ(88px) translateX(-3%); }
  62% { transform: translateZ(34px) translateX(3%); }
}

@keyframes roof-open {
  0%, 100% { transform: translateZ(0) scaleX(1); }
  42% { transform: translateZ(112px) scaleX(1.12); }
}

@keyframes weave-left {
  0%, 100% { transform: translateX(0) translateZ(0); }
  38% { transform: translateX(-7%) translateZ(88px); }
}

@keyframes weave-right {
  0%, 100% { transform: translateX(0) translateZ(0); }
  38% { transform: translateX(7%) translateZ(52px); }
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .daily-mark {
    width: 58px;
    height: 58px;
    font-size: 8px;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .mast {
    left: 88px;
  }

  .mast h1 {
    font-size: clamp(30px, 10vw, 48px);
  }

  .eyebrow {
    font-size: 8px;
  }

  .sound-toggle {
    top: auto;
    right: 14px;
    bottom: max(13px, env(safe-area-inset-bottom));
    min-width: 94px;
    min-height: 42px;
    font-size: 9px;
  }

  .panel {
    left: 14px;
    right: 14px;
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 66px));
    width: auto;
    max-height: 47svh;
    overflow: auto;
    padding: 20px;
    box-shadow: 7px 7px 0 var(--ink);
  }

  .panel h2 {
    font-size: clamp(29px, 8.6vw, 43px);
  }

  .panel p:not(.panel-index, .result-number, .max-readout) {
    font-size: 14px;
  }

  .intro {
    transform: none;
  }

  .intro-actions {
    gap: 12px;
    margin-top: 17px;
  }

  .primary {
    min-height: 48px;
  }

  .keyboard {
    top: 35%;
    width: 118vw;
    opacity: .42;
    transform: translate(-50%, -48%) rotateX(62deg) rotateZ(-2deg);
  }

  .key-row-number,
  .key-row-space {
    display: none;
  }

  html[data-input="touch"] .keyboard {
    display: none;
  }

  html[data-input="touch"] .touch-field {
    position: absolute;
    inset: 96px 10px 48svh;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 9px;
    align-items: center;
  }

  .touch-pad {
    position: relative;
    width: min(27vw, 118px);
    aspect-ratio: 1;
    justify-self: center;
    border: 3px solid var(--ink);
    border-radius: 50%;
    background: var(--acid);
    box-shadow: 0 8px 0 var(--ink);
    touch-action: none;
    user-select: none;
    font-size: 23px;
    font-weight: 900;
    transition: transform 100ms ease, background 120ms ease, box-shadow 100ms ease;
  }

  .touch-pad:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .touch-pad:nth-child(2) { grid-column: 3 / 5; grid-row: 1; }
  .touch-pad:nth-child(3) { grid-column: 5 / 7; grid-row: 1; }
  .touch-pad:nth-child(4) { grid-column: 2 / 4; grid-row: 2; }
  .touch-pad:nth-child(5) { grid-column: 4 / 6; grid-row: 2; }

  .touch-pad.is-held {
    background: var(--orange);
    color: #fff;
    transform: translateY(-12px) scale(1.02);
    box-shadow: 0 19px 0 var(--ink);
  }

  .touch-pad:nth-child(2).is-held {
    background: var(--blue);
  }

  .touch-pad:nth-child(3).is-held {
    background: var(--violet);
  }

  .touch-pad:nth-child(4).is-held {
    background: var(--orange);
  }

  .touch-pad:nth-child(5).is-held {
    background: var(--blue);
  }

  html[data-phase="touch"][data-signature="passed"] .touch-pad.is-held {
    transform: translateY(-25px) scale(1.05);
    box-shadow: 0 30px 0 var(--ink);
  }

  .touch-pad span {
    pointer-events: none;
  }

  html[data-phase="touch"] .touch-field {
    inset-bottom: 42svh;
  }

  .result-number {
    font-size: 78px;
  }

  .touch-maximum {
    margin: 14px 0 0;
    font-size: 11px !important;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .touch-maximum strong {
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: 2em;
  }

  html[data-phase="touch"][data-signature="passed"] .touch-result {
    max-height: none;
    padding: 14px 18px;
  }

  html[data-phase="touch"][data-signature="passed"] .touch-result h2,
  html[data-phase="touch"][data-signature="passed"] .touch-result > p:not(.panel-index, .result-number, .touch-maximum) {
    display: none;
  }

  html[data-phase="touch"][data-signature="passed"] .touch-result .panel-index,
  html[data-phase="touch"][data-signature="passed"] .touch-result .result-number,
  html[data-phase="touch"][data-signature="passed"] .touch-result .touch-maximum {
    display: inline-block;
    margin: 0 12px 0 0;
    vertical-align: middle;
  }

  html[data-phase="touch"][data-signature="passed"] .touch-result .result-number {
    font-size: 42px;
  }

  footer {
    left: 14px;
    right: 120px;
    bottom: max(15px, env(safe-area-inset-bottom));
    display: block;
  }

  footer p:last-child {
    display: none;
  }

  #liveStatus {
    max-width: none;
  }
}

@media (max-height: 670px) and (min-width: 761px) {
  .intro,
  .trial,
  .result,
  .finale {
    bottom: 32px;
    max-height: calc(100svh - 130px);
    overflow: auto;
  }

  .panel {
    padding: 24px;
  }

  .panel h2 {
    font-size: 38px;
  }

  .keyboard {
    width: 78vw;
    top: 42%;
  }
}

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

  .key.is-held {
    outline: 5px solid var(--ink);
  }
}

:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 4px;
}

noscript {
  position: fixed;
  z-index: 100;
  inset: auto 20px 20px;
  padding: 18px;
  border: 2px solid var(--ink);
  background: var(--orange);
  color: #fff;
  font-weight: 900;
}
