:root {
  color-scheme: dark;
  --bg: #050814;
  --text: #e8eefc;
  --muted: #8b95b8;
  --cyan: #5ce1ff;
  --mint: #7cffb2;
  --gold: #ffe38a;
  --panel: rgba(10, 16, 32, 0.55);
  --stroke: rgba(92, 225, 255, 0.28);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
}

.top,
.bottom,
#mute,
#clear,
#key {
  pointer-events: auto;
}

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
}

.brand .title {
  letter-spacing: 0.28em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cyan);
}

.brand .tag {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.legend {
  justify-self: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding-top: 4px;
}

#mute {
  justify-self: end;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  cursor: pointer;
}

#mute[aria-pressed='true'] {
  color: #ffb4bc;
  border-color: rgba(255, 93, 108, 0.45);
}

.path {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  margin-top: 4px;
}

.bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px 16px;
}

.tape-wrap {
  grid-column: 1;
  max-width: 420px;
}

.tape-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.label {
  color: var(--muted);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#clear {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 8px;
  font: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  cursor: pointer;
}

#clear:hover {
  color: var(--text);
  border-color: var(--stroke);
}

.tape {
  min-height: 1.3em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--mint);
  text-shadow: 0 0 18px rgba(124, 255, 178, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.signal {
  min-height: 1.1em;
  margin-top: 2px;
  color: var(--gold);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.28em;
  font-size: 1rem;
}

#key {
  grid-column: 2;
  width: min(220px, 70vw);
  height: 56px;
  border: 1px solid var(--cyan);
  border-radius: 999px;
  background: rgba(18, 32, 58, 0.85);
  color: #dff8ff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(92, 225, 255, 0.18);
  touch-action: none;
  user-select: none;
}

#key.down {
  background: #1a4d3a;
  border-color: var(--mint);
  transform: scale(0.98);
  box-shadow: 0 0 28px rgba(124, 255, 178, 0.45);
}

#key.dah {
  background: #4a3a12;
  border-color: var(--gold);
  box-shadow: 0 0 28px rgba(255, 227, 138, 0.4);
  color: var(--gold);
}

.hold-hint {
  grid-column: 1 / -1;
  justify-self: center;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

@media (max-width: 640px) {
  .top {
    grid-template-columns: 1fr auto;
  }
  .legend {
    display: none;
  }
  .path {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
  }
  .tape {
    font-size: 1.35rem;
  }
  .bottom {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .tape-wrap,
  #key,
  .hold-hint {
    grid-column: 1;
  }
  .tape-head {
    justify-content: center;
  }
}
