/* Dilla Time — the machine.
   A mid-90s sampler drum machine, drawn in CSS: warm grey chassis, backlit green LCD,
   rubber pads, a data wheel. Generic hardware of the era; no real brand marks. */
:root {
  --room: #1a1714;            /* the desk it sits on */
  --room-2: #241f1a;
  --chassis: #bcb8ad;
  --chassis-hi: #cfcbc1;
  --chassis-lo: #9f9b91;
  --chassis-edge: #7d7a72;
  --silk: #2b2a27;            /* silk-screen print */
  --silk-soft: #3f3d38;       /* small printed labels: 5.5:1 on the chassis */
  --stripe-1: #b5432f;        /* the red/orange stripe */
  --stripe-2: #d9822b;
  --key: #3a3936;             /* dark buttons */
  --key-hi: #4b4a46;
  --key-text: #e8e5dc;
  --pad: #d8d4ca;
  --pad-lo: #b9b5ab;
  --lcd: #a8bf6a;
  --lcd-hi: #bdd17e;
  --lcd-lo: #8fa758;
  --lcd-ink: #1d2a12;
  --lcd-ghost: rgba(29, 42, 18, 0.07);
  --led: #ff4a2e;
  --paper: #ece6d6;
  --lcd-font: 'VT323', ui-monospace, monospace;
  --silk-font: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body-font: 'Barlow', 'Helvetica Neue', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--paper); font: 400 16px/1.55 var(--body-font);
  background:
    radial-gradient(1200px 700px at 50% 30%, var(--room-2), var(--room) 70%),
    var(--room);
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--stripe-2); outline-offset: 3px; }

.room { max-width: 1120px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) 16px 56px; }
.intro { font: 500 1.05rem/1.4 var(--body-font); color: #b8b0a0; max-width: 44ch; margin: 0 0 22px; }

/* ---------- chassis ---------- */
.machine {
  position: relative; border-radius: 14px; padding: clamp(16px, 3vw, 30px);
  background:
    linear-gradient(180deg, var(--chassis-hi), var(--chassis) 18%, var(--chassis) 82%, var(--chassis-lo));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 0 rgba(0, 0, 0, 0.18),
    0 2px 0 var(--chassis-edge), 0 28px 60px -18px rgba(0, 0, 0, 0.75), 0 8px 18px rgba(0, 0, 0, 0.35);
  color: var(--silk);
}
/* a faint moulded texture */
.machine::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0.35;
  background-image: radial-gradient(rgba(0,0,0,0.08) 0.6px, transparent 0.7px);
  background-size: 3px 3px;
}
.silk { display: block; font: 600 0.7rem/1 var(--silk-font); letter-spacing: 0.16em; color: var(--silk-soft); margin-bottom: 8px; }
.silk b { color: var(--silk); font-weight: 700; }

.brand { position: relative; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 18px; }
.logo { font: italic 800 clamp(1.7rem, 4vw, 2.5rem)/0.9 var(--silk-font); letter-spacing: -0.01em; color: var(--silk); }
.logo b { font-weight: 800; }
.logo i { color: var(--stripe-1); margin-left: 0.15em; }
.model { font: 600 clamp(0.62rem, 1.4vw, 0.8rem)/1 var(--silk-font); letter-spacing: 0.24em; color: var(--silk-soft); }
.stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: linear-gradient(90deg, var(--stripe-1) 0 50%, var(--stripe-2) 50% 100%); border-radius: 2px; opacity: 0.9; }

.top { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: clamp(16px, 3vw, 30px); align-items: start; }
.bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: clamp(16px, 3vw, 36px); margin-top: clamp(18px, 3vw, 28px); align-items: end; }

/* ---------- LCD ---------- */
.screen-block { min-width: 0; }
.bezel {
  background: linear-gradient(180deg, #2a2926, #3a3935); padding: 12px; border-radius: 6px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.5);
}
.lcd {
  position: relative; color: var(--lcd-ink); border-radius: 2px; overflow: hidden;
  background:
    linear-gradient(var(--lcd-ghost) 1px, transparent 1px) 0 0 / 100% 3px,
    linear-gradient(90deg, var(--lcd-ghost) 1px, transparent 1px) 0 0 / 3px 100%,
    radial-gradient(120% 140% at 30% 20%, var(--lcd-hi), var(--lcd) 55%, var(--lcd-lo));
  box-shadow: inset 0 0 18px rgba(29, 42, 18, 0.35), inset 0 2px 3px rgba(0,0,0,0.35);
  font: 400 20px/1 var(--lcd-font);
}
.lcd-head { display: flex; gap: 14px; align-items: baseline; padding: 8px 12px 6px; border-bottom: 2px solid var(--lcd-ink); white-space: nowrap; }
.lcd-head b { font-weight: 400; margin-left: 6px; background: var(--lcd-ink); color: var(--lcd); padding: 0 5px; }
.lcd-desc { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 17px; opacity: 0.85; }
.lcd-grid { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; padding: 2px 8px 0 4px; scrollbar-width: thin; }
#grid { min-width: 600px; touch-action: pan-x; user-select: none; -webkit-user-select: none; }
.lcd-soft { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 2px solid var(--lcd-ink); }
.lcd-soft span { text-align: center; padding: 5px 0 6px; font-size: 17px; border-left: 2px solid var(--lcd-ink); }
.lcd-soft span:first-child { border-left: 0; }
.lcd-soft span.on { background: var(--lcd-ink); color: var(--lcd); }

.softkeys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; padding: 0 12px; }

/* ---------- buttons ---------- */
.key {
  position: relative; min-height: 34px; border-radius: 4px; color: transparent; font: 600 0.62rem/1 var(--silk-font); letter-spacing: 0.12em; text-transform: uppercase;
  background: linear-gradient(180deg, var(--key-hi), var(--key));
  box-shadow: 0 2px 0 #1d1c1a, 0 3px 4px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: transform 0.06s, box-shadow 0.06s;
}
/* soft keys under the screen are blank caps: the LCD labels them */
.softkeys .key { min-height: 26px; }
.key:active, .key.pressed { transform: translateY(2px); box-shadow: 0 0 0 #1d1c1a, 0 1px 2px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.08); }
/* labelled keys print their label on the chassis above */
.track, .big, .small { color: var(--key-text); }
.row { display: flex; gap: 10px; }
.track { flex: 1; min-height: 44px; font-size: 0.72rem; }
.track[aria-pressed="true"] { background: linear-gradient(180deg, #5a4a2c, #43361f); color: #ffd28a; }
.big { flex: 1; min-height: 52px; font-size: 0.8rem; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.big .led { width: 8px; height: 8px; border-radius: 50%; background: #5a1d14; box-shadow: inset 0 1px 1px rgba(0,0,0,0.5); }
.play[aria-pressed="true"] .led { background: var(--led); box-shadow: 0 0 8px var(--led), 0 0 2px #fff inset; }
.small { width: 48px; min-height: 40px; font-size: 1.2rem; }

/* ---------- data wheel ---------- */
.wheel-block { display: flex; flex-direction: column; align-items: center; }
.wheel-block > .silk { align-self: flex-start; }
.wheel-ring { position: relative; width: 190px; height: 190px; display: grid; place-items: center; }
.detent { position: absolute; font: 700 0.66rem/1 var(--silk-font); letter-spacing: 0.14em; color: var(--silk-soft); transition: color 0.2s; }
.detent.on { color: #7c2718; }
.d0 { left: 0; bottom: 14px; }
.d1 { top: 0; left: 50%; transform: translateX(-50%); }
.d2 { right: 4px; bottom: 14px; }
.wheel {
  width: 132px; height: 132px; border-radius: 50%; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 50% 45%, #3c3b38, #262523 70%);
  box-shadow: 0 0 0 4px var(--chassis-lo), 0 0 0 5px rgba(0,0,0,0.25), 0 10px 18px rgba(0,0,0,0.45), inset 0 2px 2px rgba(255,255,255,0.12);
}
.wheel:active { cursor: grabbing; }
.wheel-face {
  width: 100%; height: 100%; border-radius: 50%; position: relative;
  background: repeating-conic-gradient(rgba(255,255,255,0.05) 0 4deg, rgba(0,0,0,0.05) 4deg 8deg);
  transform: rotate(var(--angle, 120deg));
}
.dimple { position: absolute; left: 50%; top: 16px; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #1a1918, #33322f); box-shadow: inset 0 2px 3px rgba(0,0,0,0.7), 0 1px 0 rgba(255,255,255,0.12); }
.tempo { align-self: stretch; margin-top: 14px; }
.tempo .pair { display: flex; gap: 10px; }

/* ---------- pads ---------- */
.pads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pad {
  aspect-ratio: 1; border-radius: 6px; position: relative;
  background: linear-gradient(180deg, #e3dfd6, var(--pad) 40%, var(--pad-lo));
  box-shadow: 0 3px 0 #8f8b82, 0 5px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.7);
  transition: transform 0.05s, box-shadow 0.05s, background 0.1s;
}
.pad .n { position: absolute; left: 7px; top: 6px; font: 600 0.62rem/1 var(--silk-font); letter-spacing: 0.08em; color: #5d594f; }
.pad.on::after { content: ''; position: absolute; right: 8px; bottom: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--stripe-1); box-shadow: 0 0 0 2px rgba(181,67,47,0.18); }
.pad.beat .n { color: var(--silk); }
.pad.hit, .pad:active { transform: translateY(3px); box-shadow: 0 0 0 #8f8b82, 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.5); background: linear-gradient(180deg, #d6d2c8, #c9c5bb); }

.sticker {
  display: inline-flex; flex-direction: column; gap: 3px; margin-top: 22px; padding: 7px 10px;
  background: #e9e4d4; color: #4a463e; border-radius: 2px; transform: rotate(-0.6deg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25); font: 600 0.58rem/1.2 var(--silk-font); letter-spacing: 0.16em;
}
.left-controls { display: flex; flex-direction: column; gap: 22px; align-self: stretch; }
.left-controls .sticker { order: -1; align-self: flex-start; margin: 0 0 auto; }

/* ---------- the grid on the LCD ---------- */
svg.grid { display: block; overflow: visible; }
.grid .band { fill: rgba(29, 42, 18, 0.06); }
.grid .step { stroke: var(--lcd-ink); stroke-width: 1; stroke-dasharray: 1 4; opacity: 0.55; }
.grid .beat { stroke: var(--lcd-ink); stroke-width: 1.5; stroke-dasharray: 2 3; }
.grid .lane { stroke: var(--lcd-ink); stroke-width: 1; opacity: 0.35; }
.grid .num { font: 400 15px var(--lcd-font); fill: var(--lcd-ink); text-anchor: middle; opacity: 0.78; }
.grid .num.beatnum { font-size: 18px; opacity: 1; }
.grid .lanelabel { font: 400 17px var(--lcd-font); fill: var(--lcd-ink); letter-spacing: 0.04em; }
.grid .cell { fill: transparent; cursor: copy; }
.grid .cell:hover { fill: rgba(29, 42, 18, 0.07); }
.grid .playhead { stroke: var(--lcd-ink); stroke-width: 10; opacity: 0.16; pointer-events: none; }

.hit { cursor: ew-resize; outline: none; touch-action: none; }
.hit .hitarea { fill: transparent; }
.hit .gridtick { stroke: var(--lcd-ink); stroke-width: 2; opacity: 0.4; }
.hit .link { stroke: var(--lcd-ink); stroke-width: 2; }
.hit .dot { fill: var(--lcd-ink); transform-box: fill-box; transform-origin: center; transition: transform 0.12s; shape-rendering: crispEdges; }
.hit .offlabel { font: 400 17px var(--lcd-font); fill: var(--lcd-ink); text-anchor: middle; pointer-events: none; }
.hit:hover .dot, .hit.dragging .dot { transform: scale(1.25); }
.hit:focus-visible .dot { transform: scale(1.25); stroke: var(--lcd); stroke-width: 2; outline: none; }
.hit:focus-visible .hitarea { stroke: var(--lcd-ink); stroke-width: 1.5; stroke-dasharray: 3 2; }
.hit.flash .dot { animation: flash 0.28s steps(3); }
@keyframes flash { 0% { transform: scale(1.6); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .hit.flash .dot, .pad { animation: none; transition: none; } }

/* ---------- manual + toast ---------- */
.manual { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 36px; color: #b8b0a0; font-size: 0.92rem; }
.manual b { color: var(--paper); font-weight: 500; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--lcd); color: var(--lcd-ink); font: 400 20px/1 var(--lcd-font); padding: 10px 16px; border-radius: 3px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- smaller screens ---------- */
@media (max-width: 860px) {
  .top { grid-template-columns: minmax(0, 1fr); }
  .wheel-block { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
  .wheel-block > .silk { flex-basis: 100%; margin-bottom: 0; }
  .tempo { align-self: center; margin-top: 0; }
  .bottom { grid-template-columns: minmax(0, 1fr); }
  .pads-block { order: -1; }
  .manual { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 520px) {
  .machine { border-radius: 10px; }
  .softkeys { gap: 5px; padding: 0 6px; }
  .lcd-soft span { font-size: 14px; }
  .lcd-desc { display: none; }
  .wheel-ring { width: 170px; height: 170px; }
  .wheel { width: 116px; height: 116px; }
}

/* ---------- the room and the box (3D intro) ---------- */
#stage { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; display: block; z-index: 0; }
.room { position: relative; z-index: 1; }
body.boxed { overflow: hidden; }
body.boxed .room { opacity: 0; pointer-events: none; }
body.open .room { opacity: 1; transition: opacity 0.7s ease; }
/* once open, the scene is a still backdrop that scrolls with the page */
body.open #stage { position: absolute; top: 0; left: 0; pointer-events: none; }
body.open.tall #stage { -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
body.no3d #stage { display: none; }
/* the manual: a printed card lying on the desk */
.manual {
  background: #ece6d6; color: #4a453b; padding: 18px 22px; border-radius: 2px; transform: rotate(-0.35deg);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 10px 24px -8px rgba(0,0,0,0.6), 0 2px 4px rgba(0,0,0,0.3);
  margin-top: 56px;
}
.manual b { color: #1f1c17; font-weight: 500; }
.room { padding-top: clamp(40px, 7vw, 84px); }

.open-hint {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2;
  font: 600 0.72rem/1 var(--silk-font); letter-spacing: 0.28em; text-transform: uppercase; color: #cfc6b4;
  padding: 14px 18px; min-height: 44px; border-bottom: 1px solid rgba(207,198,180,0.35);
  animation: hint 2.6s ease-in-out infinite; transition: opacity 0.4s;
}
.open-hint:hover { color: #fff; }
@keyframes hint { 50% { opacity: 0.45; } }
body.opening .open-hint, body.open .open-hint { opacity: 0; pointer-events: none; animation: none; }
body.open .open-hint { display: none; }
@media (prefers-reduced-motion: reduce) { .open-hint { animation: none; } body.open .room { transition: none; } }

/* ---------- touch devices: landscape only ---------- */
#rotate { display: none; }
@media (orientation: portrait) {
  html.touch body { overflow: hidden; }
  html.touch #rotate {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
    position: fixed; inset: 0; z-index: 10; padding: 24px; background: #100e0c; color: var(--paper);
  }
  #rotate p { margin: 10px 0 0; font: italic 800 1.9rem/1 var(--silk-font); letter-spacing: 0.01em; }
  #rotate small { font: 600 0.72rem/1.4 var(--silk-font); letter-spacing: 0.2em; text-transform: uppercase; color: #9a917f; }
  #rotate .phone {
    width: 54px; height: 96px; border: 3px solid #f29ab8; border-radius: 10px; position: relative;
    animation: turn 2.4s cubic-bezier(0.6, 0, 0.3, 1) infinite;
  }
  #rotate .phone::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 16px; height: 3px; margin-left: -8px; border-radius: 2px; background: #f29ab8; }
  @keyframes turn { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
  @media (prefers-reduced-motion: reduce) { #rotate .phone { animation: none; transform: rotate(-90deg); } }
}

/* a phone on its side: everything on one screen, in three columns (screen · controls · pads) */
@media (orientation: landscape) and (max-height: 540px) {
  html.touch .room { padding: 8px max(8px, env(safe-area-inset-right)) 20px max(8px, env(safe-area-inset-left)); }
  html.touch .machine {
    padding: 8px 12px 10px; border-radius: 10px;
    display: grid; grid-template-columns: minmax(0, 1fr) 122px minmax(170px, 24vw); grid-template-rows: auto auto 1fr; gap: 6px 12px;
  }
  html.touch .top, html.touch .bottom { display: contents; }
  html.touch .brand { grid-column: 1 / -1; padding-bottom: 6px; margin: 0; gap: 10px; }
  html.touch .logo { font-size: 1.15rem; }
  html.touch .model { font-size: 0.55rem; }
  html.touch .stripe { height: 3px; }
  html.touch .screen-block { grid-column: 1; grid-row: 2 / span 2; }
  html.touch .wheel-block { grid-column: 2; grid-row: 2; flex-direction: column; flex-wrap: nowrap; align-items: center; gap: 4px; margin-top: 6px; }
  html.touch .left-controls { grid-column: 2; grid-row: 3; gap: 6px; justify-content: flex-end; }
  html.touch .pads-block { grid-column: 3; grid-row: 2 / span 2; align-self: end; }

  html.touch .bezel { padding: 6px; }
  html.touch .lcd { font-size: 16px; }
  html.touch .lcd-head { padding: 4px 8px 3px; }
  html.touch .lcd-desc { display: none; }
  html.touch .lcd-grid { padding: 0 4px 0 2px; }
  html.touch #grid { min-width: 0; --lane-h: 40; --head-h: 27; touch-action: none; }
  html.touch .lcd-soft span { font-size: 13px; padding: 3px 0 4px; }
  html.touch .softkeys { margin-top: 6px; gap: 5px; padding: 0 6px; }
  html.touch .softkeys .key { min-height: 24px; }

  html.touch .wheel-block > .silk, html.touch .tempo .silk, html.touch .left-controls .silk, html.touch .sticker { display: none; }
  html.touch .wheel-ring { width: 122px; height: 100px; }
  html.touch .wheel { width: 74px; height: 74px; }
  html.touch .dimple { top: 8px; width: 12px; height: 12px; margin-left: -6px; }
  html.touch .detent { font-size: 0.5rem; letter-spacing: 0.08em; }
  html.touch .d0 { bottom: 2px; } html.touch .d2 { bottom: 2px; right: 0; }
  html.touch .tempo { align-self: stretch; margin: 0; }
  html.touch .tempo .pair { gap: 6px; }
  html.touch .small { flex: 1; width: auto; min-height: 30px; font-size: 1rem; }
  html.touch .tracks .row { flex-wrap: wrap; gap: 5px; }
  html.touch .track { flex: 1 1 40%; min-height: 30px; font-size: 0.6rem; }
  html.touch .transport .row { gap: 6px; }
  html.touch .big { min-height: 36px; font-size: 0.66rem; gap: 6px; }
  html.touch .pads { gap: 6px; }
  html.touch .pads-block .silk { margin-bottom: 5px; font-size: 0.58rem; }
  html.touch .pad .n { left: 5px; top: 4px; font-size: 0.55rem; }
  html.touch .pad.on::after { right: 6px; bottom: 6px; width: 7px; height: 7px; }
  html.touch .manual { margin-top: 28px; grid-template-columns: 1fr 1fr; gap: 20px; font-size: 0.82rem; }
  html.touch .open-hint { bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* the room fades up once its models have loaded */
#stage { opacity: 0; transition: opacity 1.4s ease; }
body.ready #stage { opacity: 1; }
body:not(.ready) .open-hint { opacity: 0; pointer-events: none; animation: none; }
@media (prefers-reduced-motion: reduce) { #stage { transition: none; } }

/* ---------- "Open the box": a pink tag that floats above the box and points at it ---------- */
.open-hint {
  left: 50%; top: 40%; bottom: auto; transform: translate(-50%, -100%); z-index: 2;
  font: italic 800 clamp(1.5rem, 3.6vw, 2.4rem)/1 var(--silk-font); letter-spacing: 0.02em; text-transform: uppercase;
  color: #1c1114; background: #f29ab8; padding: 0.55em 1.05em 0.6em; min-height: 52px; border: 0; border-radius: 999px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  opacity: 0; pointer-events: none; animation: none; transition: opacity 0.7s ease, background 0.2s;
  white-space: nowrap;
}
.open-hint::after { /* the pointer */
  content: ''; position: absolute; left: 50%; top: 100%; margin: -1px 0 0 -11px;
  border: 11px solid transparent; border-top: 13px solid #f29ab8; border-bottom: 0; transition: border-color 0.2s;
}
.open-hint:hover, .open-hint:focus-visible { color: #1c1114; background: #ffc2d6; }
.open-hint:hover::after, .open-hint:focus-visible::after { border-top-color: #ffc2d6; }
body.cta .open-hint { opacity: 1; pointer-events: auto; animation: bob 2.2s ease-in-out infinite; }
body.opening .open-hint, body.open .open-hint { opacity: 0; pointer-events: none; animation: none; }
@keyframes bob { 50% { transform: translate(-50%, calc(-100% - 9px)); } }
@media (prefers-reduced-motion: reduce) { body.cta .open-hint { animation: none; } }

/* ---------- the loader: a light switch in the dark ---------- */
#gate {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: #050404; transition: opacity 0.25s ease 0.05s, visibility 0s linear 0.4s;
}
body.lit #gate, body.open #gate { opacity: 0; visibility: hidden; pointer-events: none; }
#lightswitch { padding: 14px; border-radius: 16px; cursor: pointer; position: relative; }
#lightswitch:disabled { cursor: progress; }
#lightswitch::before { /* just enough glow to find it in the dark */
  content: ''; position: absolute; inset: -60px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 190, 120, 0.10), transparent); opacity: 0; transition: opacity 0.8s;
}
#lightswitch:not(:disabled)::before { opacity: 1; animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: 0.45; } }
.plate {
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; width: 84px; height: 132px; padding: 12px 0;
  border-radius: 9px; background: linear-gradient(160deg, #57524a, #3a3630 60%, #2c2925);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.14), inset 0 -2px 3px rgba(0,0,0,0.5), 0 10px 26px rgba(0,0,0,0.8);
  opacity: 0.45; transition: opacity 0.8s;
}
#lightswitch:not(:disabled) .plate { opacity: 1; }
.screw { width: 9px; height: 9px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #8a8478, #2a2723); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5); position: relative; }
.screw::after { content: ''; position: absolute; left: 1px; right: 1px; top: 4px; height: 1px; background: rgba(0,0,0,0.6); transform: rotate(35deg); }
.rocker { /* off: the bottom half sits proud */
  width: 30px; height: 56px; border-radius: 5px; position: relative;
  background: linear-gradient(180deg, #25221f 0 47%, #6a645a 53% 100%);
  box-shadow: 0 0 0 3px #1c1a17, inset 0 -3px 4px rgba(0,0,0,0.4), inset 0 2px 2px rgba(255,255,255,0.05);
  transition: background 0.05s;
}
#lightswitch.on .rocker { background: linear-gradient(180deg, #7a7468 0 47%, #25221f 53% 100%); box-shadow: 0 0 0 3px #1c1a17, inset 0 3px 4px rgba(255,255,255,0.12); }
#lightswitch:active:not(:disabled) .rocker { filter: brightness(1.15); }
#gatemsg { margin: 0; font: 600 0.74rem/1 var(--silk-font); letter-spacing: 0.3em; text-transform: uppercase; color: #7d766a; min-height: 1em; }
#lightswitch:not(:disabled) + #gatemsg { color: #d9cfbd; }
@media (prefers-reduced-motion: reduce) { #lightswitch::before { animation: none; } }

/* the first screen: title and subline above the switch, lit as if by the switch's own glow */
#gate { gap: 0; padding: 24px; text-align: center; }
.gate-title { margin: 0; font: italic 800 clamp(3.4rem, 13vw, 8rem)/0.86 var(--silk-font); letter-spacing: -0.01em; color: #e9e2d2; }
.gate-title b { font-weight: 800; }
.gate-title i { color: #f29ab8; }
.gate-sub { margin: 18px 0 0; max-width: 30ch; font: 500 clamp(1rem, 2.4vw, 1.25rem)/1.4 var(--body-font); color: #a59c8c; }
#lightswitch { margin-top: clamp(28px, 6vh, 64px); }
#gatemsg { margin-top: 22px; }
.gate-note { margin: 14px 0 0; font: 600 0.62rem/1 var(--silk-font); letter-spacing: 0.26em; text-transform: uppercase; color: #948c7d; }
@media (max-height: 540px) { /* a phone on its side: title and switch side by side */
  #gate { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto; column-gap: 40px; align-content: center; justify-content: center; justify-items: start; text-align: left; padding: 16px max(24px, env(safe-area-inset-left)); }
  .gate-title { grid-column: 1; grid-row: 1; font-size: clamp(2.6rem, 9vw, 4.4rem); align-self: end; }
  .gate-sub { grid-column: 1; grid-row: 2; margin-top: 10px; font-size: 0.95rem; }
  .gate-note { grid-column: 1; grid-row: 3; margin-top: 12px; }
  #lightswitch { grid-column: 2; grid-row: 1 / span 2; margin: 0; justify-self: center; align-self: center; }
  #gatemsg { grid-column: 2; grid-row: 3; margin-top: 8px; justify-self: center; }
  .plate { width: 70px; height: 108px; }
}

/* ---------- the switch, redrawn: an old ivory toggle switch, lever down = off ---------- */
#lightswitch { padding: 18px; border-radius: 20px; }
#lightswitch::before { inset: -90px; background: radial-gradient(closest-side, rgba(255, 196, 130, 0.13), transparent); }
.plate {
  width: 112px; height: 178px; padding: 13px 0; border-radius: 10px; position: relative; gap: 0;
  background:
    linear-gradient(155deg, rgba(255,255,255,0.22), transparent 38%),
    linear-gradient(180deg, #d9cfb6, #bfb49a 55%, #a3987f);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -3px 5px rgba(60,48,30,0.45), inset 0 0 0 1px rgba(70,58,38,0.35),
    0 1px 0 #6f664f, 0 16px 36px rgba(0,0,0,0.85), 0 3px 6px rgba(0,0,0,0.6);
  opacity: 0.32; filter: saturate(0.8); transition: opacity 0.9s, filter 0.9s;
}
#lightswitch:not(:disabled) .plate { opacity: 0.92; filter: none; }
#lightswitch:not(:disabled):hover .plate, #lightswitch:focus-visible .plate { opacity: 1; }
.screw { width: 11px; height: 11px; background: radial-gradient(circle at 35% 30%, #f1ead6, #8c826a 70%); box-shadow: inset 0 0 0 1px rgba(60,50,30,0.55), 0 1px 0 rgba(255,255,255,0.35); }
.screw::after { left: 1px; right: 1px; top: 5px; height: 1.5px; background: rgba(50,40,25,0.75); }
.screw:last-child::after { transform: rotate(-20deg); }
.mark { font: 700 0.5rem/1 var(--silk-font); letter-spacing: 0.22em; color: rgba(70,58,38,0.6); text-shadow: 0 1px 0 rgba(255,255,255,0.35); margin: 9px 0 7px; padding-left: 0.22em; }
.well { /* the slot the lever sits in */
  width: 36px; height: 62px; border-radius: 5px; background: linear-gradient(180deg, #17140f, #2b261d);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.45), 0 0 0 1px rgba(70,58,38,0.5);
  display: grid; place-items: center; perspective: 150px;
}
.lever {
  width: 22px; height: 46px; border-radius: 4px 4px 6px 6px; transform-origin: 50% 50%;
  transform: rotateX(-46deg);                       /* down: off */
  background: linear-gradient(180deg, #f3ecd8 0%, #d8ceb4 45%, #a69b80 100%);
  box-shadow: 0 10px 10px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -4px 6px rgba(70,58,38,0.45), 0 0 0 1px rgba(60,50,30,0.5);
  transition: transform 0.09s cubic-bezier(0.3, 1.6, 0.6, 1), background 0.09s, box-shadow 0.09s;
}
#lightswitch:not(:disabled):hover .lever { transform: rotateX(-38deg); }
#lightswitch:not(:disabled):active .lever { transform: rotateX(-18deg); }
#lightswitch.on .lever, #lightswitch.on:hover .lever {
  transform: rotateX(46deg);                        /* up: on */
  background: linear-gradient(180deg, #b5aa8e 0%, #ddd3ba 50%, #f6f0de 100%);
  box-shadow: 0 -8px 9px rgba(0,0,0,0.55), inset 0 -1px 0 rgba(255,255,255,0.7), inset 0 4px 6px rgba(70,58,38,0.4), 0 0 0 1px rgba(60,50,30,0.5);
}
/* let the flip be seen before the dark lifts */
#gate { transition: opacity 0.3s ease 0.26s, visibility 0s linear 0.6s; }
@media (max-height: 540px) { .plate { width: 92px; height: 146px; padding: 10px 0; } .well { height: 52px; } .lever { height: 38px; } .mark { margin: 6px 0 5px; } }
@media (prefers-reduced-motion: reduce) { .lever { transition: none; } }

/* a slower, softer hand-over from the 3D machine to the real one */
body.open .room { transition: opacity 1.1s cubic-bezier(0.4, 0, 0.2, 1); }

/* ---------- About: liner notes on a sheet of paper ---------- */
.about-btn {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); z-index: 6;
  font: 700 0.7rem/1 var(--silk-font); letter-spacing: 0.22em; text-transform: uppercase; color: #e9e2d2;
  padding: 12px 14px; min-height: 40px; border-radius: 999px; background: rgba(20, 17, 14, 0.55); box-shadow: inset 0 0 0 1px rgba(233, 226, 210, 0.28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: background 0.2s, color 0.2s, opacity 0.4s;
}
.about-btn:hover, .about-btn:focus-visible { background: #f29ab8; color: #1c1114; }
body.opening .about-btn { opacity: 0; pointer-events: none; }
#about {
  width: min(760px, calc(100vw - 24px)); max-height: min(92vh, 92dvh); padding: 0; border: 0; border-radius: 3px; overflow: auto;
  background: #ece6d6; color: #332f27; box-shadow: 0 30px 80px rgba(0,0,0,0.7); overscroll-behavior: contain;
  background-image: radial-gradient(rgba(60,50,30,0.05) 0.6px, transparent 0.7px); background-size: 4px 4px;
}
#about::backdrop { background: rgba(8, 6, 5, 0.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#about[open] { animation: sheet 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes sheet { from { opacity: 0; transform: translateY(14px) rotate(-0.4deg); } }
.about-close {
  position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; z-index: 1;
  font: 700 0.68rem/1 var(--silk-font); letter-spacing: 0.2em; text-transform: uppercase; color: #ece6d6; background: #2a2620;
  padding: 11px 14px; min-height: 40px; border-radius: 999px;
}
.about-close:hover { background: #b5432f; }
.notes { padding: clamp(22px, 5vw, 54px); padding-top: clamp(18px, 4vw, 40px); font: 400 1rem/1.6 var(--body-font); }
.notes-kicker { margin: 0 0 10px; font: 700 0.68rem/1 var(--silk-font); letter-spacing: 0.26em; text-transform: uppercase; color: #8a7f6a; }
.notes h2 { margin: 0; font: italic 800 clamp(2.8rem, 9vw, 4.6rem)/0.88 var(--silk-font); color: #1f1c17; }
.notes h2 b { font-weight: 800; } .notes h2 i { color: #c2356c; }
.notes-lede { font-size: 1.2rem; line-height: 1.45; color: #1f1c17; margin: 16px 0 0; max-width: 34ch; }
.notes h3 { margin: 2.1em 0 0.5em; padding-top: 0.9em; border-top: 2px solid #1f1c17; font: italic 800 1.5rem/1 var(--silk-font); letter-spacing: 0.01em; text-transform: uppercase; color: #1f1c17; }
.notes p { margin: 0 0 0.9em; max-width: 62ch; }
.notes ul { margin: 0 0 0.9em; padding-left: 1.1em; max-width: 62ch; } .notes li { margin-bottom: 0.45em; }
.notes b { font-weight: 500; color: #1f1c17; }
.notes a { color: #a02a58; text-underline-offset: 3px; } .notes a:hover { color: #1f1c17; }
.notes table { width: 100%; border-collapse: collapse; margin: 0.4em 0 1.1em; font-size: 0.94rem; }
.notes th { text-align: left; font: 700 0.66rem/1 var(--silk-font); letter-spacing: 0.18em; text-transform: uppercase; color: #655c4a; padding: 0 10px 8px 0; border-bottom: 1px solid rgba(31,28,23,0.5); }
.notes td { padding: 9px 10px 9px 0; border-bottom: 1px solid rgba(31,28,23,0.16); vertical-align: top; }
.notes td:nth-child(2) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.notes-embed { margin: 0.4em 0 1em; min-height: 352px; border-radius: 12px; background: rgba(31,28,23,0.08); overflow: hidden; }
.notes-embed iframe { display: block; width: 100%; height: 352px; border: 0; }
.notes-small { font-size: 0.82rem; color: #655c4a; margin-top: 2em; }
@media (max-height: 540px) { #about { max-height: 96vh; width: min(760px, calc(100vw - 12px)); } .notes-embed, .notes-embed iframe { min-height: 152px; height: 152px; } }
@media (prefers-reduced-motion: reduce) { #about[open] { animation: none; } }

/* the machine's badge: same colours as the first screen, on a dark plate so the off-white reads on the pale chassis */
.logo {
  color: #e9e2d2; background: #14100f; padding: 0.14em 0.42em 0.17em 0.34em; border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 1px 0 rgba(255,255,255,0.5);
}
.logo i { color: #f29ab8; margin-left: 0.2em; }

/* About: the title block uses the first screen's colours — dark, off-white and pink */
.notes-head { background: #14100f; margin: calc(-1 * clamp(18px, 4vw, 40px)) calc(-1 * clamp(22px, 5vw, 54px)) 0; padding: clamp(26px, 5vw, 48px) clamp(22px, 5vw, 54px) clamp(24px, 4vw, 40px); }
.notes-head .notes-kicker { color: #a59c8c; }
.notes h2 { color: #e9e2d2; }
.notes h2 i { color: #f29ab8; }
.notes-head .notes-lede { color: #cfc6b4; }
.notes-head + h3 { border-top: 0; margin-top: 1.4em; }
.about-close { color: #14100f; background: #e9e2d2; }
.about-close:hover { background: #f29ab8; }
.notes a { color: #b03065; }
.notes h2 b { color: #e9e2d2; }

/* ---------- accessibility ---------- */
/* Skip the intro: a plain link-style button, bottom left, on the first screen and during the room. */
.skip {
  position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 6;
  font: 700 0.68rem/1 var(--silk-font); letter-spacing: 0.2em; text-transform: uppercase; color: #cfc6b4;
  padding: 12px 14px; min-height: 40px; border-radius: 999px; background: rgba(20, 17, 14, 0.55); box-shadow: inset 0 0 0 1px rgba(233, 226, 210, 0.28);
}
.skip:hover, .skip:focus-visible { background: #f29ab8; color: #1c1114; }
body.open .skip, body.opening .skip { display: none; }
/* "Open the box" can't be reached until it is showing */
.open-hint { visibility: hidden; }
body.cta .open-hint { visibility: visible; }
body.opening .open-hint { visibility: hidden; }
/* the hidden machine can't be reached either (it also has the inert attribute) */
body.boxed .room { visibility: hidden; }
/* stronger focus rings: pink on dark surfaces, dark on the pale machine and paper */
:focus-visible { outline: 3px solid #f29ab8; outline-offset: 3px; }
.machine :focus-visible, #about :focus-visible { outline-color: #14100f; }
.machine .key:focus-visible, .pad:focus-visible { outline: 3px solid #14100f; box-shadow: 0 0 0 6px #f29ab8; }
.hit:focus-visible { outline: none; }
.hit:focus-visible .hitarea { stroke: var(--lcd-ink); stroke-width: 2.5; stroke-dasharray: none; }
/* (portrait is blocked on touch devices: Mark's decision, 2026-11-16) */
.upright { margin-top: 18px; font: 700 0.72rem/1 var(--silk-font); letter-spacing: 0.2em; text-transform: uppercase; color: #e9e2d2; padding: 14px 18px; min-height: 44px; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(233, 226, 210, 0.4); }
.upright:hover, .upright:focus-visible { background: #f29ab8; color: #1c1114; }
/* Windows high-contrast and forced colours: keep the blank soft keys and pads visible */
@media (forced-colors: active) { .key, .pad, .plate, .lever { border: 1px solid ButtonText; } .softkeys .key { color: ButtonText; } }
/* for screen readers only: takes no space and shows nothing */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* "See the room": only when a shared link opened straight on the machine */
.seeroom {
  display: none; position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 6;
  font: 700 0.68rem/1 var(--silk-font); letter-spacing: 0.2em; text-transform: uppercase; color: #cfc6b4;
  padding: 12px 14px; min-height: 40px; border-radius: 999px; background: rgba(20, 17, 14, 0.55); box-shadow: inset 0 0 0 1px rgba(233, 226, 210, 0.28);
}
.seeroom:hover, .seeroom:focus-visible { background: #f29ab8; color: #1c1114; }
html.direct body.open .seeroom { display: block; }
.wheel-face { transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1); } /* springs back from "too far" */

/* ---------- fine timing bar: the last hit you touched, 1 ms at a time ---------- */
.nudgebar {
  position: fixed; left: 50%; bottom: calc(74px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 6px;
  background: var(--lcd); color: var(--lcd-ink); box-shadow: 0 8px 24px rgba(0,0,0,0.55); font: 400 19px/1 var(--lcd-font); white-space: nowrap;
}
.nudgebar[hidden] { display: none; }
.nudgebar output { padding: 0 10px; min-width: 15ch; text-align: center; }
.nudgebar button { width: 48px; height: 44px; border-radius: 4px; background: var(--lcd-ink); color: var(--lcd); font: 400 26px/1 var(--lcd-font); }
.nudgebar button:active { transform: translateY(1px); }
.nudgebar button:focus-visible { outline: 3px solid #14100f; box-shadow: 0 0 0 6px #f29ab8; }
@media (max-height: 540px) { .nudgebar { bottom: calc(8px + env(safe-area-inset-bottom)); left: auto; right: max(10px, env(safe-area-inset-right)); transform: none; } .nudgebar button { height: 40px; } }

/* ---------- a wide window that isn't tall (most laptops): three columns, so it all fits ---------- */
/* screen · dial and keys · pads, the same arrangement the phone uses, at full size */
@media (min-width: 1180px) and (max-height: 1060px) {
  html:not(.touch) .room, html.touch.wide-ok .room { max-width: 1400px; padding-top: clamp(20px, 5vh, 56px); }
  .room { max-width: 1400px; padding-top: clamp(20px, 5vh, 56px); }
  .machine { display: grid; grid-template-columns: minmax(0, 1fr) 196px minmax(220px, 300px); grid-template-rows: auto auto auto auto; gap: 14px 28px; align-items: start; }
  .top, .bottom, .left-controls { display: contents; }
  .brand { grid-column: 1 / -1; margin-bottom: 4px; }
  .screen-block { grid-column: 1; grid-row: 2 / span 2; }
  .left-controls .sticker { grid-column: 1; grid-row: 4; margin: 0; align-self: end; justify-self: start; order: 0; }
  .wheel-block { grid-column: 2; grid-row: 2; }
  .tracks { grid-column: 2; grid-row: 3; }
  .transport { grid-column: 2; grid-row: 4; align-self: end; }
  .tracks .row { flex-wrap: wrap; gap: 8px; }
  .track { flex: 1 1 40%; }
  .pads-block { grid-column: 3; grid-row: 2 / span 3; align-self: end; }
  #grid { min-width: 520px; }
}

/* a phone on its side: keep About and See the room small, together, top right, clear of the controls */
@media (max-height: 540px) {
  .about-btn, .seeroom, .skip { min-height: 30px; padding: 8px 10px; font-size: 0.58rem; }
  .about-btn { top: max(10px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  .seeroom { top: max(10px, env(safe-area-inset-top)); bottom: auto; left: auto; right: calc(max(14px, env(safe-area-inset-right)) + 62px); }
}

/* ---------- five lanes (bass added): keep the heights where they were ---------- */
@media (min-width: 1180px) and (max-height: 1060px) { #grid { --lane-h: 54; } .track { flex: 1 1 28%; } }
@media (orientation: landscape) and (max-height: 540px) { html.touch #grid { --lane-h: 32; --head-h: 24; } html.touch .track { flex: 1 1 28%; font-size: 0.52rem; letter-spacing: 0.06em; } }
/* on a phone the fine-timing bar sits at the top, over the model name, so it never covers a control */
@media (max-height: 540px) { .nudgebar { top: max(4px, env(safe-area-inset-top)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); padding: 2px; font-size: 16px; } .nudgebar button { width: 40px; height: 30px; font-size: 22px; } .nudgebar output { min-width: 13ch; padding: 0 6px; } }

/* phone on its side: the "Open the box" tag must size to its text (a leftover bottom offset was stretching it tall) */
html.touch .open-hint, .open-hint { bottom: auto; height: auto; }
@media (max-height: 540px) { .open-hint { font-size: 1.25rem; min-height: 40px; padding: 0.5em 0.95em 0.55em; } .open-hint::after { border-width: 8px; border-top-width: 10px; margin-left: -8px; } }

/* About: a little more room at the sides, and clear of a phone's notch and rounded corners when held sideways */
.notes { --pad-x: clamp(28px, 6vw, 68px); padding-left: var(--pad-x); padding-right: var(--pad-x); }
.notes-head { margin-left: calc(-1 * var(--pad-x)); margin-right: calc(-1 * var(--pad-x)); padding-left: var(--pad-x); padding-right: var(--pad-x); }
@media (max-height: 540px) {
  .notes { --pad-x: max(48px, calc(env(safe-area-inset-left) + 24px), calc(env(safe-area-inset-right) + 24px)); }
  .about-close { margin-right: max(12px, env(safe-area-inset-right)); }
}
