/* =====================================================================
   HiChord Emulator — anodised black aluminium, cream pads, blue studio.
   The device is laid out in a fixed 940x620 design space and scaled to fit.
   ===================================================================== */

:root {
  --ink: #05070c;
  --metal-hi: #4a5058;
  --metal-1: #2b3037;
  --metal-2: #14171b;
  --metal-3: #0a0c0f;
  --face: #14171a;
  --cream: #f4ead0;
  --cream-2: #e0d3ab;
  --cream-3: #c8ba90;
  --grey-1: #dfe3e7;
  --grey-2: #a2aab2;
  --yellow-1: #ffcb46;
  --yellow-2: #e0930a;
  --red-1: #ff414a;
  --red-2: #bd0d17;
  --screen-bg: #04070b;
  --screen-fg: #fbf4de;
  --screen-dim: #7f8b7a;
  --accent: #4d8dff;
  --radius: 34px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: #e8ecf2;
  background: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
}

/* --- background ---------------------------------------------------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 50% 8%, #1b3f9b 0%, #0c1f56 32%, #050b1e 62%, #01030a 100%),
    #01030a;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.34'/></svg>");
  opacity: .16;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* --- chrome -------------------------------------------------------- */

.topbar, .footbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  flex: 0 0 auto;
}

.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #58e08a;
  box-shadow: 0 0 12px #58e08a;
  opacity: .35;
  transition: opacity .3s;
}
body.is-on .topbar__brand .dot { opacity: 1; }
.topbar h1 {
  font-size: 15px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 700;
  margin: 0;
}
.topbar h1 em {
  font-style: normal;
  font-weight: 400;
  opacity: .5;
}
.topbar__actions { display: flex; gap: 8px; }

.chip {
  font: inherit;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #cfd8e6;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background .18s, color .18s, border-color .18s;
}
.chip:hover { background: rgba(255, 255, 255, .11); }
.chip[aria-pressed="true"] {
  color: #06121f;
  background: #cfe0ff;
  border-color: #cfe0ff;
}

.footbar { justify-content: center; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.keyhelp {
  font-size: 11.5px;
  letter-spacing: .04em;
  color: rgba(220, 232, 250, .45);
  text-align: center;
}
kbd {
  font: 500 11px/1 var(--mono);
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06);
  color: #dce7f8;
}

/* --- stage --------------------------------------------------------- */

.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 0 18px;
}

.device-wrap {
  --scale: 1;
  position: relative;
  width: calc(940px * var(--scale));
  height: calc(620px * var(--scale));
  flex: 0 0 auto;
}

/* Scaled from the top-left corner: an overflowing box would otherwise be
   snapped to the start edge by the grid/flex safe-alignment fallback. */
.device {
  position: absolute;
  left: 0;
  top: 0;
  width: 940px;
  height: 620px;
  transform: scale(var(--scale));
  transform-origin: 0 0;
}

/* soft studio glow under the unit */
.device__shadow {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -46px;
  height: 90px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, .75), transparent 70%);
  filter: blur(14px);
  z-index: 0;
}

/* --- body / chassis ------------------------------------------------ */

.device__body {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, #464c54 0%, #23272d 12%, #15181c 42%, #0d0f13 76%, #1a1e23 100%);
  box-shadow:
    0 60px 90px -30px rgba(0, 0, 0, .85),
    0 24px 48px -18px rgba(0, 0, 0, .7),
    0 2px 0 rgba(255, 255, 255, .07) inset,
    0 -2px 0 rgba(0, 0, 0, .6) inset;
  overflow: hidden;
}
/* chamfered highlight around the milled edge */
.device__body::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .06) 28%, rgba(255, 255, 255, 0) 55%, rgba(255, 255, 255, .16));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 4;
}
/* brushed metal sheen */
.device__body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, rgba(255, 255, 255, .08) 0%, transparent 22%, transparent 70%, rgba(255, 255, 255, .05) 100%);
  pointer-events: none;
}

.device__face {
  position: absolute;
  left: 30px;
  top: 30px;
  width: 880px;
  height: 560px;
  border-radius: 22px;
  background:
    linear-gradient(170deg, #1c2024 0%, #131619 45%, #0e1114 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .09) inset,
    0 -1px 0 rgba(0, 0, 0, .8) inset,
    0 10px 26px -14px rgba(0, 0, 0, .9);
  z-index: 2;
}
.device__face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/></filter><rect width='120' height='120' filter='url(%23g)' opacity='.5'/></svg>");
  opacity: .07;
  pointer-events: none;
}

/* --- branding, grille --------------------------------------------- */

.brand {
  position: absolute;
  left: 26px;
  top: 16px;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -.015em;
  color: #cfd3d8;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .9), 0 -1px 0 rgba(255, 255, 255, .16);
  z-index: 3;
}

.grille {
  position: absolute;
  left: 24px;
  top: 62px;
  width: 194px;
  height: 194px;
  border-radius: 50%;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 96%, transparent 100%);
  mask-image: radial-gradient(circle at 50% 50%, #000 96%, transparent 100%);
  background-image:
    radial-gradient(circle at 50% 55%, rgba(255, 255, 255, .07) 0 3.4px, transparent 3.7px),
    radial-gradient(circle at 50% 45%, #03050700 0 1.4px, #020406 1.5px 2.9px, transparent 3.2px);
  background-size: 13px 13px, 13px 13px;
  background-position: 3px 3px, 3px 3px;
  z-index: 3;
}

.led {
  position: absolute;
  left: 80px;
  top: 286px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 38%, #23272d, #0a0c0f 70%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08), 0 2px 5px rgba(0, 0, 0, .8) inset;
  z-index: 3;
}
.led::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #4de08a;
  opacity: 0;
  box-shadow: 0 0 10px #4de08a;
  transition: opacity .3s;
}
body.is-on .led::after { opacity: .85; }

.mic-dots {
  position: absolute;
  left: 58px;
  top: 500px;
  display: flex;
  gap: 9px;
  z-index: 3;
}
.mic-dots i {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #05070a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .07);
}

/* --- joystick ------------------------------------------------------ */

.joystick {
  position: absolute;
  left: 30px;
  top: 328px;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  z-index: 4;
  cursor: grab;
  touch-action: none;
}
.joystick.is-down { cursor: grabbing; }
.joystick__well {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #05070a 0 46%, #1d2126 60%, #363c44 78%, #101317 100%);
  box-shadow:
    0 3px 7px rgba(0, 0, 0, .9) inset,
    0 -2px 3px rgba(255, 255, 255, .12) inset,
    0 1px 0 rgba(255, 255, 255, .07),
    0 0 0 1px rgba(0, 0, 0, .7);
}
.joystick__cap {
  position: absolute;
  left: 11px;
  top: 11px;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff9e6 0%, var(--cream) 32%, var(--cream-2) 66%, var(--cream-3) 100%);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, .6),
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 -6px 12px rgba(0, 0, 0, .22) inset;
  transition: transform .12s cubic-bezier(.2, .9, .3, 1.2);
}
.joystick.is-down .joystick__cap {
  box-shadow: 0 3px 8px rgba(0, 0, 0, .65), 0 1px 0 rgba(255, 255, 255, .55) inset;
}

/* --- screen -------------------------------------------------------- */

.screen {
  position: absolute;
  left: 252px;
  top: 14px;
  width: 176px;
  height: 84px;
  border-radius: 9px;
  background: var(--screen-bg);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .9),
    0 2px 6px rgba(0, 0, 0, .9) inset,
    0 0 22px rgba(120, 190, 255, .06) inset;
  overflow: hidden;
  z-index: 3;
  padding: 6px 8px;
  font-family: var(--mono);
  color: var(--screen-fg);
  font-size: 8px;
}
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg, rgba(255, 255, 255, .13), transparent 45%);
  pointer-events: none;
}

/* --- coloured buttons ---------------------------------------------- */

.fbtn {
  position: absolute;
  top: 14px;
  width: 80px;
  height: 80px;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  z-index: 4;
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  touch-action: none;
  transition: transform .06s ease, box-shadow .06s ease, filter .15s;
}
.fbtn svg { width: 40px; height: 40px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.fbtn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .4), rgba(255, 255, 255, 0) 42%);
  pointer-events: none;
}
.fbtn--key {
  left: 528px;
  background: linear-gradient(180deg, var(--grey-1), var(--grey-2));
  color: #3b4149;
  box-shadow: 0 5px 0 #6e767e, 0 10px 18px rgba(0, 0, 0, .55);
}
.fbtn--sound {
  left: 620px;
  background: linear-gradient(180deg, var(--yellow-1), var(--yellow-2));
  box-shadow: 0 5px 0 #8f5c04, 0 10px 18px rgba(0, 0, 0, .55);
}
.fbtn--time {
  left: 712px;
  background: linear-gradient(180deg, var(--red-1), var(--red-2));
  box-shadow: 0 5px 0 #7c060d, 0 10px 18px rgba(0, 0, 0, .55);
}
.fbtn.is-down { transform: translateY(4px); }
.fbtn--key.is-down { box-shadow: 0 1px 0 #6e767e, 0 4px 10px rgba(0, 0, 0, .5); }
.fbtn--sound.is-down { box-shadow: 0 1px 0 #8f5c04, 0 4px 10px rgba(0, 0, 0, .5); }
.fbtn--time.is-down { box-shadow: 0 1px 0 #7c060d, 0 4px 10px rgba(0, 0, 0, .5); }

/* --- pads ---------------------------------------------------------- */

.pads {
  position: absolute;
  left: 246px;
  top: 108px;
  width: 616px;
  height: 438px;
  padding: 11px;
  border-radius: 14px;
  background: linear-gradient(180deg, #0a0c0f, #101317);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, .9) inset,
    0 -1px 0 rgba(255, 255, 255, .06) inset;
  /* 12 columns so the 3 wide pads (4 columns each) sit between the 4 lower
     pads (3 columns each), the way the degrees interleave on the hardware. */
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: 118px 1fr;
  gap: 9px;
  z-index: 3;
}

.pad {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 9px;
  cursor: pointer;
  touch-action: none;
  background:
    linear-gradient(180deg, #fbf4dd 0%, var(--cream) 16%, var(--cream-2) 82%, var(--cream-3) 100%);
  box-shadow:
    0 5px 0 #9d9271,
    0 9px 16px rgba(0, 0, 0, .55),
    0 1px 0 rgba(255, 255, 255, .95) inset,
    0 -3px 6px rgba(0, 0, 0, .14) inset;
  transition: transform .05s ease, box-shadow .05s ease, filter .12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 12px;
  overflow: hidden;
}
.pad::before {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 40%;
  border-radius: 8px 8px 30% 30%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.pad--t:nth-child(1) { grid-area: 1 / 1 / 2 / 5; }
.pad--t:nth-child(2) { grid-area: 1 / 5 / 2 / 9; }
.pad--t:nth-child(3) { grid-area: 1 / 9 / 2 / 13; }
.pad--b:nth-child(4) { grid-area: 2 / 1 / 3 / 4; }
.pad--b:nth-child(5) { grid-area: 2 / 4 / 3 / 7; }
.pad--b:nth-child(6) { grid-area: 2 / 7 / 3 / 10; }
.pad--b:nth-child(7) { grid-area: 2 / 10 / 3 / 13; }

.pad__num {
  position: absolute;
  top: 9px;
  left: 12px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(90, 78, 48, .34);
  letter-spacing: .04em;
}
.pad__chord {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: rgba(58, 48, 26, .62);
  opacity: 0;
  transition: opacity .2s;
  text-align: center;
  padding: 0 6px;
  line-height: 1.1;
}
body.labels-on .pad__chord { opacity: 1; }

.pad.is-down, .pad.is-active {
  transform: translateY(4px);
  filter: brightness(.94);
  box-shadow:
    0 1px 0 #9d9271,
    0 3px 8px rgba(0, 0, 0, .5),
    0 1px 0 rgba(255, 255, 255, .7) inset,
    0 -2px 5px rgba(0, 0, 0, .18) inset;
}

/* --- right edge: wheel, switch, jack ------------------------------- */

.edge {
  position: absolute;
  right: -30px;
  top: 40px;
  width: 58px;
  height: 540px;
  border-radius: 0 18px 18px 0;
  background: linear-gradient(90deg, #1a1e23 0%, #3d434b 40%, #2a2f35 72%, #10131700 100%);
  box-shadow: 8px 0 22px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 255, 255, .14) inset;
  z-index: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 28px;
  padding: 150px 7px 0 0;
}
.edge__wheel {
  width: 20px;
  height: 74px;
  border-radius: 10px;
  background: repeating-linear-gradient(180deg, #4a5058 0 2px, #23272d 2px 5px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .7) inset, 0 0 0 1px rgba(0, 0, 0, .5);
  cursor: ns-resize;
  touch-action: none;
}
.edge__wheel-inner {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .55), transparent 40%, rgba(255, 255, 255, .18) 70%, rgba(0, 0, 0, .5));
}
.edge__switch {
  position: relative;
  width: 22px;
  height: 52px;
  border-radius: 11px;
  background: linear-gradient(180deg, #101317, #1e2228);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .8) inset;
  cursor: pointer;
}
.edge__knob {
  position: absolute;
  left: 3px;
  top: 26px;
  width: 16px;
  height: 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #cfd4da, #7d858e);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .6);
  transition: top .16s cubic-bezier(.4, 1.6, .5, 1);
}
body.is-on .edge__knob { top: 4px; }
.edge__label {
  position: absolute;
  left: 50%;
  top: -16px;
  transform: translateX(-50%);
  font-size: 8px;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .3);
}
.edge__jack {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2b3037, #06080a 70%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1);
}

/* --- screen content (shared by device + mirror) -------------------- */

.scr {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: .25em;
  line-height: 1.25;
  letter-spacing: .02em;
  text-shadow: 0 0 6px rgba(230, 245, 255, .28);
  animation: scr-in .18s ease;
}
@keyframes scr-in { from { opacity: .55; } to { opacity: 1; } }
.scr-off { width: 100%; height: 100%; }

.scr-top {
  display: flex;
  justify-content: space-between;
  color: var(--screen-dim);
  font-size: .82em;
  letter-spacing: .08em;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  padding-bottom: .18em;
}
.scr-top i { font-style: normal; opacity: .55; margin-left: .25em; }
.scr-title {
  font-size: .82em;
  letter-spacing: .14em;
  color: #9fd8ff;
  text-transform: uppercase;
}
.scr-main {
  font-size: 2.6em;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1;
  margin: .06em 0 0;
}
.scr-main.sm { font-size: 1.9em; }
.scr-main i { font-size: .4em; opacity: .5; font-style: normal; margin-left: .3em; }
.scr-sub {
  font-size: .8em;
  color: var(--screen-dim);
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scr-foot {
  margin-top: auto;
  font-size: .72em;
  color: rgba(190, 205, 220, .45);
  letter-spacing: .06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scr-row {
  display: flex;
  justify-content: space-between;
  gap: .5em;
  font-size: .85em;
  color: rgba(240, 245, 250, .8);
}
.scr-row em { font-style: normal; opacity: .4; }
.scr-row.is-active { color: #ffd479; }
.scr-row.is-rec { color: #ff5a5f; }
.scr-list { display: flex; flex-direction: column; margin: .1em 0; }
.scr-list .dim { color: rgba(160, 175, 190, .4); font-size: .8em; }
.scr-list .sel { font-size: 1.35em; font-weight: 700; color: #fff; }
.scr-bar { display: flex; gap: 2px; margin: .25em 0; }
.scr-bar i {
  flex: 1;
  height: .45em;
  background: rgba(255, 255, 255, .13);
  border-radius: 1px;
}
.scr-bar i.on { background: #9fd8ff; box-shadow: 0 0 5px rgba(159, 216, 255, .8); }
.scr-loop { display: flex; align-items: center; gap: .4em; font-size: .8em; }
.scr-loop .scr-bar { flex: 1; margin: 0; }
.scr-loop em { font-style: normal; color: #9fd8ff; }
.scr-loop em.rec { color: #ff5a5f; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.scr-dots { display: flex; gap: 4px; margin-top: .2em; }
.scr-dots i {
  width: .5em; height: .5em; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
}
.scr-dots i.on { background: #9fd8ff; box-shadow: 0 0 6px #9fd8ff; }
.scr-tracks { display: flex; flex-direction: column; gap: 1px; }
.scr-steps {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  margin: .2em 0;
}
.scr-steps i {
  aspect-ratio: 1.6;
  display: grid;
  place-items: center;
  font-size: .7em;
  font-style: normal;
  border-radius: 2px;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .5);
}
.scr-steps i.on { background: rgba(159, 216, 255, .25); color: #eaf6ff; }
.scr-steps i.cur { outline: 1px solid #ffd479; color: #ffd479; }
.scr-game { display: flex; flex-direction: column; gap: 1px; margin: .2em 0; }
.scr-lane { display: flex; align-items: center; gap: 2px; }
.scr-lane b { font-size: .62em; width: 1em; color: rgba(255, 255, 255, .35); }
.scr-lane i {
  flex: 1;
  height: .5em;
  border-radius: 1px;
  background: rgba(255, 255, 255, .07);
}
.scr-lane i.line { background: rgba(255, 212, 121, .3); }
.scr-lane i.on { background: #9fd8ff; box-shadow: 0 0 6px rgba(159, 216, 255, .9); }
.scr-flash {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(159, 216, 255, .92);
  color: #04070b;
  font-weight: 700;
  font-size: .8em;
  letter-spacing: .1em;
  text-align: center;
  padding: .18em 0;
  border-radius: 3px;
  text-shadow: none;
}

/* --- HUD (companion display) --------------------------------------- */

.hud {
  position: relative;
  z-index: 2;
  width: min(360px, 30vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hud__screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #060a10, #02040a);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .9), 0 0 40px rgba(80, 150, 255, .06) inset;
  font-family: var(--mono);
  color: var(--screen-fg);
  font-size: 15px;
  overflow: hidden;
}
.hud__screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.hud__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.hud__cell {
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.hud__cell span {
  font-size: 9.5px;
  letter-spacing: .18em;
  color: rgba(200, 216, 236, .45);
}
.hud__cell b {
  font: 600 15px/1.1 var(--mono);
  letter-spacing: .02em;
}
.hud__hint {
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(200, 216, 236, .38);
  text-align: center;
}

/* --- power overlay -------------------------------------------------- */

.poweroff {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(3, 6, 14, .72);
  backdrop-filter: blur(6px);
  transition: opacity .35s ease, visibility .35s;
}
.poweroff.is-hidden { opacity: 0; visibility: hidden; }
.poweroff__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px 44px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: #eaf1ff;
  font: inherit;
  cursor: pointer;
  transition: transform .18s, background .18s, border-color .18s;
}
.poweroff__btn:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .09); }
.poweroff__btn svg { width: 34px; height: 34px; color: #7fe6a0; }
.poweroff__btn span { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; }
.poweroff__btn em { font-style: normal; font-size: 12px; opacity: .5; }

/* --- manual sheet --------------------------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(2, 5, 12, .8);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: 40px 20px;
  -webkit-user-select: text;
  user-select: text;
}
.sheet__inner {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  background: linear-gradient(180deg, #0d1220, #070a12);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 22px;
  padding: 34px clamp(20px, 4vw, 44px) 40px;
  box-shadow: 0 40px 90px -40px #000;
}
.sheet__close {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: #dbe6f5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.sheet h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: .02em; }
.sheet__lead { margin: 0 0 22px; color: rgba(214, 228, 245, .6); font-size: 14px; max-width: 62ch; }
.sheet__cols {
  columns: 2 320px;
  column-gap: 34px;
}
.sheet section {
  break-inside: avoid;
  margin: 0 0 24px;
}
.sheet h3 {
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #9fd8ff;
  margin: 0 0 8px;
}
.sheet p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: rgba(220, 232, 248, .78); }
.sheet .tip { color: rgba(255, 212, 121, .8); font-size: 12.5px; }
.sheet table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sheet td { padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, .06); color: rgba(220, 232, 248, .72); }
.sheet td:first-child { color: #fff; font-weight: 600; width: 6.5em; }
.sheet__note { margin-top: 18px; font-size: 11.5px; color: rgba(200, 216, 236, .35); }
.c-key { color: var(--grey-1); }
.c-sound { color: var(--yellow-1); }
.c-time { color: var(--red-1); }

/* --- keyboard mapping panel ---------------------------------------- */

.keys__inner { max-width: 780px; }

.keys__status {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 8px 14px;
  margin-bottom: 18px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.4;
  color: rgba(214, 228, 245, .7);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
}
.keys__status.ok { color: #a9e9c1; border-color: rgba(120, 230, 160, .25); background: rgba(90, 220, 140, .08); }
.keys__status.warn { color: #ffd479; border-color: rgba(255, 212, 121, .25); background: rgba(255, 200, 90, .08); }

.keys__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px 28px;
}
.keys__group h3 {
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #9fd8ff;
  margin: 0 0 8px;
}
.keys__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.keys__label {
  font-size: 13px;
  color: rgba(220, 232, 248, .78);
}
.keys__row.is-unbound .keys__label { color: rgba(220, 232, 248, .35); }
.keys__key {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: #eaf2ff;
  font: 600 12.5px/1 var(--mono);
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.keys__key:hover { background: rgba(255, 255, 255, .14); }
.keys__row.is-unbound .keys__key { color: rgba(234, 242, 255, .35); }
.keys__row.is-capturing .keys__key {
  background: #9fd8ff;
  border-color: #9fd8ff;
  color: #04070b;
  animation: keys-pulse 1.1s ease-in-out infinite;
}
@keyframes keys-pulse { 50% { opacity: .55; } }

.keys__reset {
  margin-top: 26px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .05);
  color: #cfd8e6;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.keys__reset:hover { background: rgba(255, 255, 255, .11); }

/* --- responsive ----------------------------------------------------- */

@media (max-width: 1079px) {
  .stage {
    flex-direction: column;
    gap: 14px;
    padding: 0 12px;
  }
  .hud {
    width: min(560px, 100%);
    flex-direction: row;
    align-items: stretch;
    gap: 10px;
  }
  .hud__screen {
    flex: 1 1 auto;
    aspect-ratio: auto;
    min-height: 128px;
    font-size: 13px;
    padding: 12px 14px;
  }
  .hud__grid {
    flex: 0 0 132px;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .hud__cell { padding: 6px 10px; }
  .hud__cell b { font-size: 13px; }
  .hud__hint { display: none; }
  .footbar { display: none; }
}

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 12.5px; }
  .chip { padding: 7px 11px; font-size: 11px; }
  .stage { padding: 0 8px; gap: 10px; }
  .hud { flex-direction: column; gap: 8px; }
  .hud__screen {
    flex: 0 0 auto;
    min-height: 0;
    height: 132px;
    font-size: 12.5px;
    border-radius: 14px;
  }
  .hud__grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .hud__cell { align-items: center; text-align: center; padding: 6px 4px; gap: 1px; }
  .hud__cell span { font-size: 8px; letter-spacing: .1em; }
  .hud__cell b { font-size: 12px; }
  .sheet__cols { columns: 1; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .hud__grid { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
