:root {
  color-scheme: dark;
  --base: #070a0b;
  --surface: #101617;
  --surface-2: #161e20;
  --stroke: #293537;
  --grid: rgba(210, 229, 118, 0.09);
  --text: #f4f5ef;
  --muted: #a3afad;
  --lime: #d8ef5e;
  --mint: #68dfc0;
  --amber: #f0ae5f;
  --red: #ee6674;
  --radius: 8px;
  font-family: "Bahnschrift", "Yu Gothic UI", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  background:
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    radial-gradient(circle at 15% 0%, rgba(104, 223, 192, 0.14), transparent 29rem),
    var(--base);
  background-size: 44px 44px, 44px 44px, auto, auto;
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input,
a {
  border-radius: var(--radius);
}

button,
a {
  align-items: center;
  border: 1px solid var(--stroke);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  text-decoration: none;
}

button:hover,
a:hover {
  border-color: var(--lime);
}

.practice-shell {
  margin: 0 auto;
  padding: 28px 0 44px;
  width: min(1480px, calc(100vw - 32px));
}

.practice-head {
  align-items: end;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding-bottom: 18px;
}

.practice-head p {
  color: var(--lime);
  font-family: "Consolas", monospace;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-family: "Yu Gothic UI Semibold", "Bahnschrift", sans-serif;
  font-size: clamp(2.2rem, 4vw, 4.5rem);
  line-height: 0.95;
  margin-bottom: 0;
}

h2 {
  font-size: 0.95rem;
  margin-bottom: 14px;
  text-transform: uppercase;
}

nav {
  display: flex;
  gap: 8px;
}

#micButton.ready {
  background: var(--lime);
  color: #050707;
}

.practice-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(520px, 1.35fr) minmax(330px, 0.65fr);
  padding: 18px 0 16px;
}

.target-stage,
.control-rack section,
.keyboard-bay,
.history-bay {
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
}

.target-stage {
  display: grid;
  gap: 18px;
  min-height: 610px;
  padding: 22px;
}

.target-readout {
  align-items: baseline;
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr auto;
}

.target-readout span,
label span,
article span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.target-readout strong {
  font-family: "Consolas", monospace;
  font-size: clamp(3rem, 9vw, 8.6rem);
  line-height: 0.9;
}

.target-readout em,
.live-readout em {
  color: var(--amber);
  font-family: "Consolas", monospace;
  font-style: normal;
}

.tuner {
  align-content: center;
  display: grid;
  gap: 14px;
}

.tuner-scale {
  color: var(--muted);
  display: grid;
  font-family: "Consolas", monospace;
  grid-template-columns: repeat(5, 1fr);
}

.tuner-scale span:nth-child(3) {
  color: var(--lime);
  text-align: center;
}

.tuner-scale span:nth-child(n+4) {
  text-align: right;
}

.tuner-rail {
  background:
    linear-gradient(90deg, transparent 24.8%, var(--stroke) 25%, transparent 25.2%, transparent 49.8%, var(--lime) 50%, transparent 50.2%, transparent 74.8%, var(--stroke) 75%, transparent 75.2%),
    #091012;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  height: 42px;
  overflow: hidden;
  position: relative;
}

.tuner-rail i {
  background: rgba(216, 239, 94, 0.15);
  display: block;
  height: 100%;
  left: 32.5%;
  position: absolute;
  width: 35%;
}

#needle {
  background: var(--red);
  box-shadow: 0 0 18px rgba(238, 102, 116, 0.68);
  display: block;
  height: 100%;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  transition: left 90ms linear, background 90ms linear;
  width: 5px;
}

#needle.hit {
  background: var(--mint);
  box-shadow: 0 0 18px rgba(104, 223, 192, 0.68);
}

.live-readout {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.live-readout strong {
  font-family: "Consolas", monospace;
  font-size: clamp(1.1rem, 2vw, 2rem);
}

#trail {
  background: #091012;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  display: block;
  height: 200px;
  width: 100%;
}

.round-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 58px 1fr 1fr;
}

#playTone {
  background: var(--lime);
  color: #050707;
  font-weight: 700;
  padding: 0;
}

.control-rack {
  display: grid;
  gap: 16px;
}

.control-rack section,
.keyboard-bay,
.history-bay {
  padding: 18px;
}

.control-rack label {
  display: grid;
  gap: 7px;
  margin-bottom: 11px;
}

select,
input {
  background: #091012;
  border: 1px solid var(--stroke);
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

input[type="range"] {
  accent-color: var(--lime);
  padding: 0;
}

.scoreboard > div {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
}

.scoreboard article {
  background: #091012;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 13px;
}

.scoreboard strong {
  font-family: "Consolas", monospace;
  font-size: 1.5rem;
}

.keyboard-bay header,
.history-bay header {
  align-items: baseline;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.keyboard-bay p {
  color: var(--muted);
  margin-bottom: 0;
}

.keyboard {
  display: flex;
  height: clamp(180px, 24vw, 300px);
  overflow-x: auto;
  padding-bottom: 6px;
  position: relative;
}

.key {
  border: 1px solid #091012;
  border-radius: 0 0 6px 6px;
  flex: 0 0 clamp(36px, 4vw, 58px);
  min-height: 100%;
  padding: 0 0 12px;
  position: relative;
}

.key.white {
  align-items: end;
  background: #f4f1dc;
  color: #071011;
  display: flex;
}

.key.black {
  background: #111719;
  color: var(--text);
  flex-basis: 0;
  height: 62%;
  margin-left: calc(clamp(36px, 4vw, 58px) * -0.32);
  margin-right: calc(clamp(36px, 4vw, 58px) * -0.32);
  min-width: clamp(25px, 2.6vw, 38px);
  z-index: 2;
}

.key.active {
  background: var(--lime);
  color: #071011;
}

.key span {
  bottom: 10px;
  font-family: "Consolas", monospace;
  font-size: 0.72rem;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
}

#history {
  display: grid;
  gap: 8px;
}

.history-row {
  border-top: 1px solid var(--stroke);
  display: grid;
  gap: 10px;
  grid-template-columns: 70px 1fr auto auto;
  padding-top: 10px;
}

.history-row b,
.history-row em {
  font-family: "Consolas", monospace;
  font-style: normal;
}

.history-row em.good {
  color: var(--mint);
}

.history-row em.warn {
  color: var(--amber);
}

@media (max-width: 980px) {
  .practice-grid {
    grid-template-columns: 1fr;
  }

  .target-stage {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .practice-shell {
    padding-top: 18px;
    width: calc(100vw - 18px);
  }

  .practice-head,
  .keyboard-bay header {
    align-items: stretch;
    flex-direction: column;
  }

  nav,
  .round-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  nav button,
  nav a,
  .round-actions button {
    min-width: 0;
    width: 100%;
  }

  .round-actions #playTone {
    grid-column: 1 / -1;
  }

  .target-readout {
    grid-template-columns: 1fr;
  }

  .history-row {
    grid-template-columns: 58px 1fr;
  }

  .target-stage,
  .control-rack section,
  .keyboard-bay,
  .history-bay {
    padding: 14px;
  }

  .target-stage {
    gap: 13px;
  }

  #trail {
    height: 154px;
  }

  .keyboard {
    height: 210px;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .key {
    flex-basis: 42px;
  }

  .key.black {
    margin-left: -13px;
    margin-right: -13px;
    min-width: 28px;
  }
}
