:root {
  --paper: #06191d;
  --panel: #09252a;
  --panel-light: #0d3035;
  --ink: #bdfefa;
  --muted: #6fa8a8;
  --cyan: #23d8d1;
  --cyan-dark: #087f80;
  --warm: #ffcc66;
  --black: #020b0d;
  --header-height: 58px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(35, 216, 209, 0.18), transparent 45%),
    linear-gradient(rgba(35, 216, 209, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 216, 209, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 32px, 32px 32px, auto;
  font-family: "DM Mono", monospace;
  -webkit-font-smoothing: antialiased;
}

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

a {
  text-decoration: none;
}

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

.noise {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  opacity: 0.13;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 3px,
    rgba(0, 0, 0, 0.3) 4px
  );
}

.project-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--header-height);
  padding: 0 2.2vw;
  background: rgba(6, 25, 29, 0.95);
  border-bottom: 3px double var(--cyan);
  box-shadow: 0 4px 0 var(--black);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(6px, 0.65vw, 9px);
  letter-spacing: 0.08em;
}

.project-header p {
  justify-self: end;
  margin: 0;
  color: var(--muted);
}

body.is-reading .project-header p {
  visibility: hidden;
}

.back-link {
  justify-self: start;
  padding: 8px 10px;
  border: 1px solid var(--cyan-dark);
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--black);
  background: var(--cyan);
  outline: none;
}

.project-title {
  display: flex;
  align-items: center;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(0, 72fr) minmax(0, 28fr);
  height: calc(100dvh - var(--header-height));
  padding: clamp(10px, 1.7vh, 18px) clamp(10px, 1.8vw, 28px);
  gap: clamp(10px, 1.8vh, 18px);
}

.piano-zone,
.keyboard-zone {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: clamp(20px, 3vh, 28px);
  color: var(--muted);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(5px, 0.55vw, 8px);
  letter-spacing: 0.1em;
}

.section-label h1,
.section-label h2 {
  margin: 0;
  color: var(--cyan);
  font: inherit;
}

.piano-frame {
  min-height: 0;
  padding: clamp(7px, 1.2vh, 12px);
  background: var(--panel-light);
  border: 2px solid var(--cyan-dark);
  box-shadow: 7px 7px 0 var(--black);
}

.piano-rows {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(7px, 1.2vh, 12px);
}

.piano {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 70px;
  padding: 5px 5px 9px;
  background: var(--black);
  user-select: none;
  touch-action: none;
}

.piano-key {
  border-radius: 0;
  cursor: pointer;
  transition:
    background 70ms ease,
    box-shadow 70ms ease,
    transform 70ms ease;
}

.piano-key.white {
  position: relative;
  flex: 1;
  min-width: 0;
  color: var(--black);
  background: #dcf9f7;
  border: 1px solid #15383a;
  box-shadow: inset 0 -7px 0 #7da8a7;
}

.piano-key.black {
  position: absolute;
  z-index: 2;
  top: 5px;
  left: calc(var(--position) * var(--white-width) - var(--black-half));
  width: calc(var(--white-width) * 0.62);
  height: 61%;
  color: var(--cyan);
  background: #031013;
  border: 2px solid var(--cyan-dark);
  box-shadow:
    inset 0 -7px 0 #000,
    3px 4px 0 rgba(0, 0, 0, 0.45);
}

.piano-key span {
  position: absolute;
  right: 0;
  bottom: clamp(8px, 1.5vh, 15px);
  left: 0;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(4px, 0.38vw, 6px);
  text-align: center;
  opacity: 0.7;
}

.piano-key.is-active.white {
  background: var(--cyan);
  box-shadow:
    inset 0 -2px 0 var(--cyan-dark),
    0 0 18px rgba(35, 216, 209, 0.72);
  transform: translateY(5px);
}

.piano-key.is-active.black {
  color: var(--black);
  background: var(--warm);
  border-color: #ffe7b8;
  box-shadow:
    inset 0 -2px 0 #9d641e,
    0 0 18px rgba(255, 204, 102, 0.68);
  transform: translateY(5px);
}

.computer-keyboard {
  display: grid;
  min-height: 0;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: clamp(2px, 0.35vh, 4px);
  padding: clamp(4px, 0.65vh, 7px);
  background: var(--panel);
  border: 2px solid var(--cyan-dark);
  box-shadow: 7px 7px 0 var(--black);
  user-select: none;
  touch-action: none;
}

.keyboard-row {
  display: flex;
  min-height: 0;
  justify-content: center;
  gap: clamp(2px, 0.3vw, 5px);
}

.computer-key {
  display: grid;
  min-width: 0;
  height: 100%;
  flex: var(--size, 1);
  padding: 2px;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(189, 254, 250, 0.04), transparent 45%),
    #041316;
  border: 1px solid var(--cyan-dark);
  border-bottom-width: 2px;
  box-shadow: 1px 2px 0 var(--black);
  cursor: pointer;
  place-items: center;
  font-family: "DM Mono", monospace;
  font-size: clamp(5px, 0.72vw, 10px);
  font-weight: 500;
  line-height: 1;
  transition:
    background 60ms ease,
    color 60ms ease,
    transform 60ms ease;
}

.computer-key span {
  align-self: end;
}

.computer-key small {
  align-self: start;
  color: var(--muted);
  font-size: clamp(4px, 0.5vw, 7px);
  line-height: 1;
}

.computer-key.is-active {
  color: var(--black);
  background: var(--cyan);
  border-color: var(--ink);
  box-shadow:
    0 0 14px rgba(35, 216, 209, 0.6),
    1px 1px 0 var(--black);
  transform: translate(2px, 2px);
}

.computer-key.is-active small {
  color: var(--black);
}

.computer-key[data-code^="Arrow"].is-active,
.computer-key[data-code="Space"].is-active,
.computer-key[data-code="Enter"].is-active {
  background: var(--warm);
}

@media (max-height: 650px) {
  :root {
    --header-height: 48px;
  }

  .workspace {
    grid-template-rows: minmax(0, 73fr) minmax(0, 27fr);
    padding-top: 7px;
    padding-bottom: 7px;
    gap: 7px;
  }

  .section-label {
    min-height: 17px;
  }
}

@media (max-width: 700px) {
  .project-header {
    grid-template-columns: auto 1fr;
  }

  .project-title {
    justify-self: end;
  }

  .project-header p {
    display: none;
  }

  .workspace {
    padding-right: 8px;
    padding-left: 8px;
  }

  .computer-key {
    font-size: clamp(5px, 1.8vw, 9px);
  }
}

@media (max-width: 500px) {
  .project-title strong {
    font-size: 6px;
  }

  .piano-key span {
    display: none;
  }

  .computer-keyboard {
    gap: 3px;
    padding: 5px;
  }

  .keyboard-row {
    gap: 2px;
  }

  .computer-key {
    overflow: hidden;
    border-bottom-width: 2px;
    font-size: 5px;
  }

  .computer-key small {
    font-size: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
