/* Telly: the site is a television, your device is the remote. */

@property --grow { syntax: '<length>'; inherits: true; initial-value: 0px; }

/* TV page only. Fonts, palette, base rules, the tab bar and the footer live in site.css. */
:root {
  --g: 70 78 110;            /* glow colour, set from the picture */
  --gut: 10px;               /* gutter around the set on phones */
  --bz: 8px;                 /* bezel thickness */
  --sw: calc(100vw - 2 * var(--gut) - 2 * var(--bz) - 2 * var(--pad));
  --pad: 0px;
  --sh: calc(var(--sw) * .75);
  --kh: 44px;                /* key height */
}
body.page-tv { overscroll-behavior-y: none; }

/* ---------- the room ---------- */
.room {
  position: relative; isolation: isolate;
  height: calc(100vh - var(--tabs-h)); height: calc(100svh - var(--tabs-h)); min-height: 420px;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: radial-gradient(120% 80% at 50% 30%, #0d0d12 0%, #070709 60%, #050506 100%);
}
.wall { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.wallpaper {
  position: absolute; inset: -10%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 16px, rgb(var(--g) / .55) 17px 18.5px, transparent 19.5px 100%) 0 0 / 56px 56px,
    radial-gradient(circle at 50% 50%, rgb(var(--g) / .35) 0 3px, transparent 4px) 28px 28px / 56px 56px;
  -webkit-mask-image: radial-gradient(48% 46% at 50% 36%, #000 0%, rgb(0 0 0 / .45) 45%, transparent 100%);
          mask-image: radial-gradient(48% 46% at 50% 36%, #000 0%, rgb(0 0 0 / .45) 45%, transparent 100%);
  opacity: .16; transition: opacity 1.2s ease;
}
.glow { position: absolute; pointer-events: none; will-change: opacity; opacity: 0; }
.glow-wall {
  left: 50%; top: 34%; width: 150vmax; height: 110vmax; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgb(var(--g) / .55), rgb(var(--g) / .22) 38%, rgb(var(--g) / .06) 70%, transparent 100%);
}
.glow-spill { inset: 0; background: radial-gradient(90% 70% at 50% 40%, rgb(var(--g) / .14), transparent 75%); }
.surface { position: absolute; left: 0; right: 0; bottom: 0; height: 0; z-index: -1; pointer-events: none; }
.glow-floor { display: none; }
/* the sound chip, in the tab bar on this page */
.chip-sound {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 14px 0 12px;
  border: 0; border-radius: 10px; cursor: pointer; color: #cfc9bd;
  font: 700 11px/1 var(--ui); font-stretch: 112%; letter-spacing: .12em; text-transform: uppercase;
  background: linear-gradient(180deg, #232328, #19191d); box-shadow: 0 2px 0 #050506, inset 0 1px 0 rgb(255 255 255 / .1);
}
.chip-sound:hover { color: #fff; }
.chip-sound:active { transform: translateY(1px); }
.chip-sound .ic { width: 18px; height: 18px; flex: none; }
.chip-sound .ic-off, .is-muted .chip-sound .ic-on { display: none; }
.is-muted .chip-sound .ic-off { display: block; color: #ff9b85; }
.is-muted .chip-sound { color: #ffb3a3; }
@media (max-width: 599px) {
  .chip-sound { padding: 0; width: 44px; }
  .chip-sound-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- the stage ---------- */
.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- the set ---------- */
.set { position: relative; z-index: 2; padding: var(--gut) var(--gut) 0; flex: none; }
.cabinet {
  position: relative; border-radius: 18px;
  padding: var(--pad);
  background:
    linear-gradient(180deg, rgb(255 222 190 / .2) 0, rgb(255 222 190 / .06) 2px, transparent 18%, transparent 78%, rgb(0 0 0 / .38)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='720' height='360'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0028 0.13' numOctaves='4' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.16 0 0 0 0 0.08 0 0 0 0 0.03 0 0 0 1.9 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E") 0 0 / 720px 360px,
    linear-gradient(90deg, #3b2314, #5a3921 24%, #684327 50%, #573620 76%, #36200f);
  box-shadow:
    inset 0 1px 0 rgb(255 225 195 / .32),
    inset 0 -3px 0 rgb(0 0 0 / .5),
    inset 1px 0 0 rgb(255 225 195 / .08), inset -1px 0 0 rgb(0 0 0 / .35),
    0 26px 50px -18px rgb(0 0 0 / .95),
    0 0 110px -30px rgb(var(--g) / .5);
}
.cabinet::before { /* the screen's light catching the metal */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(75% 95% at 42% 50%, rgb(var(--g) / .34), rgb(var(--g) / .08) 55%, transparent 80%);
  mix-blend-mode: soft-light; opacity: var(--lit, 0); transition: opacity .6s;
}
.cabinet::after { /* fine edge highlight */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .05), inset 0 10px 18px -12px rgb(255 255 255 / .18);
}
.bezel {
  position: relative; padding: var(--bz); border-radius: 16px;
  background: radial-gradient(120% 120% at 50% 0%, #1b1b1d, #0a0a0b 60%);
  box-shadow:
    inset 0 3px 10px rgb(0 0 0 / .95), inset 0 0 0 1px #000,
    0 0 0 1px rgb(0 0 0 / .55), 0 0 0 2px rgb(255 255 255 / .1), 0 2px 0 2px rgb(255 255 255 / .06);
}
.bezel::after { /* spill from the tube onto the black surround */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 calc(var(--bz) * 2.2) rgb(var(--g) / calc(.32 * var(--lit, 0)));
}
.screen {
  position: relative; width: var(--sw); height: calc(var(--sh) + var(--grow));
  border-radius: 5% / 6.6%; overflow: hidden;
  background: #0c0e0d;
  box-shadow: 0 0 0 1px #000, 0 0 22px rgb(var(--g) / .28);
  transition: --grow .45s cubic-bezier(.3, .7, .2, 1);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  contain: layout paint;
}
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.glass {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background:
    radial-gradient(60% 45% at 26% 12%, rgb(255 255 255 / .085), transparent 70%),
    linear-gradient(162deg, rgb(255 255 255 / .05) 0%, transparent 34%),
    radial-gradient(130% 120% at 50% 50%, transparent 58%, rgb(0 0 0 / .42) 100%);
  box-shadow: inset 0 0 18px rgb(0 0 0 / .85), inset 0 0 2px rgb(0 0 0 / .9);
}
.is-standby .glass, .is-off .glass {
  background:
    radial-gradient(60% 45% at 26% 12%, rgb(255 255 255 / .11), transparent 70%),
    linear-gradient(162deg, rgb(255 255 255 / .07) 0%, transparent 34%),
    radial-gradient(40% 30% at 70% 78%, rgb(255 120 80 / .045), transparent 70%),
    radial-gradient(130% 120% at 50% 50%, transparent 55%, rgb(0 0 0 / .5) 100%);
}
.nogl .screen::after { /* CSS treatment when there is no WebGL */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    repeating-linear-gradient(180deg, rgb(0 0 0 / .26) 0 1px, transparent 1px 3px),
    radial-gradient(120% 110% at 50% 50%, transparent 55%, rgb(0 0 0 / .55) 100%);
  mix-blend-mode: multiply;
}
.hits { position: absolute; inset: 0; z-index: 2; }
.hit {
  position: absolute; display: block; color: transparent; text-decoration: none;
  background: none; border: 0; padding: 0; margin: 0; appearance: none; -webkit-appearance: none;
  border-radius: 6px; font-size: 1px; line-height: 1; overflow: hidden;
  -webkit-tap-highlight-color: rgb(255 255 255 / .12);
}
.hit:focus-visible { outline: 2px solid #ffd23f; outline-offset: 0; }
.hit-pic { inset: 0; border-radius: 0; z-index: 0; cursor: pointer; }
.hit-pic:focus-visible { outline-offset: -4px; }

/* no JavaScript or no canvas: say so, and point to the plain pages */
.fallback {
  position: absolute; inset: 0; z-index: 4; display: none;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6% 9%; gap: .55em; background: #0b0d0c;
  font-size: clamp(12px, calc(var(--sw) / 30), 22px);
}
.no-canvas .fallback { display: flex; }
.no-canvas .invite { display: none; }
.fallback p { margin: 0; }
.fallback-k { font: 400 .75em/1 var(--tt); letter-spacing: .3em; text-transform: uppercase; color: #ff6d5a; }
.fallback-big { font: 800 1.5em/1.08 var(--ui); font-stretch: 112%; color: #f4efe6; text-wrap: balance; }
.fallback-small { max-width: 28em; font-size: .85em; line-height: 1.5; color: #c9c2b4; }
.fallback a { display: inline-block; padding: .2em 0; color: #3ff0ff; text-underline-offset: 3px; }

/* standby invitation */
.invite {
  position: absolute; inset: 0; z-index: 3; display: none;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6% 8%; gap: .55em;
  font-size: clamp(12px, calc(var(--sw) / 28), 26px);
}
.is-standby .invite, .is-off .invite { display: flex; }
.js .invite { animation: invite-in 1s .2s both ease-out; }
@keyframes invite-in { from { opacity: 0; transform: translateY(6px); } }
.invite-kicker {
  margin: 0; font: 400 .75em/1 var(--tt); letter-spacing: .3em; color: #ff6d5a; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: .6em;
}
.invite-kicker::before { content: ''; width: .55em; height: .55em; border-radius: 50%; background: #ff3b2a; box-shadow: 0 0 8px 2px rgb(255 50 30 / .7); animation: pulse 2.4s ease-in-out infinite; }
.invite-big { margin: 0; font: 800 1.9em/1.02 var(--ui); font-stretch: 125%; letter-spacing: -.01em; color: #f4efe6; text-wrap: balance; }
.invite-small { margin: 0; max-width: 26em; color: #bdb6a8; font-size: .78em; line-height: 1.45; text-wrap: pretty; }
.invite-btn {
  margin-top: .5em; display: inline-flex; align-items: center; gap: .55em; min-height: 44px; padding: 0 1.2em 0 .9em;
  border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, #ff6a3d, #e2401c); color: #fff;
  font: 800 .8em/1 var(--ui); font-stretch: 112%; letter-spacing: .12em; text-transform: uppercase;
  box-shadow: 0 4px 0 #8f2410, 0 10px 24px -6px rgb(255 80 40 / .7), inset 0 1px 0 rgb(255 255 255 / .35);
  transition: transform .08s, box-shadow .08s;
}
.invite-btn svg { width: 1.4em; height: 1.4em; }
.invite-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8f2410, 0 4px 12px -4px rgb(255 80 40 / .6), inset 0 1px 0 rgb(255 255 255 / .3); }
.is-off .invite-kicker { color: #c9c2b4; }
.only-key { display: none; }
@media (hover: hover) and (pointer: fine) { .only-key { display: inline; } }

/* the side panel; on phones it is the chin under the screen */
.panel {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 36px; padding: 0 6px 0 4px;
}
.grille, .panel-keys, .pkey-power { display: none; }
.readout {
  display: inline-flex; align-items: center; justify-content: center; min-width: 52px; height: 26px; padding: 0 8px;
  border-radius: 5px; background: #050605; box-shadow: inset 0 1px 3px #000, 0 1px 0 rgb(255 255 255 / .07);
}
.readout-ch { font: 800 17px/1 var(--ui); font-stretch: 125%; font-variant-numeric: tabular-nums; letter-spacing: .1em; color: var(--led); text-shadow: 0 0 6px rgb(87 255 140 / .8), 0 0 14px rgb(87 255 140 / .35); transition: opacity .3s; }
.is-standby .readout-ch, .is-off .readout-ch { opacity: .14; text-shadow: none; }
.standby-led {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #3a1410; box-shadow: inset 0 1px 1px rgb(0 0 0 / .6);
  transition: background .3s, box-shadow .3s;
}
.is-standby .standby-led, .is-off .standby-led { background: #ff3b2a; box-shadow: 0 0 6px 2px rgb(255 59 42 / .75), 0 0 18px 4px rgb(255 59 42 / .3); animation: pulse 2.4s ease-in-out infinite; }
.is-on .standby-led { background: #49ff8a; box-shadow: 0 0 5px 1px rgb(73 255 138 / .6); }
@keyframes pulse { 50% { opacity: .45; } }
.maker { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; white-space: nowrap; }
.maker b { font: 800 10px/1 var(--ui); font-stretch: 125%; letter-spacing: .18em; color: #e9e6df; text-shadow: 0 1px 0 rgb(0 0 0 / .6); }
.maker i { font: italic 600 9px/1 var(--ui); letter-spacing: .1em; color: #b9b5ac; margin-top: 4px; }
.plinth { display: none; }
@media (max-width: 340px) { .maker { display: none; } }
@media (max-width: 400px) { .maker i { display: none; } .maker b { letter-spacing: .12em; font-size: 9px; } }

/* ---------- the remote ---------- */
.remote-wrap { position: relative; z-index: 3; flex: 1; min-height: 0; display: flex; justify-content: center; padding: 12px calc(var(--gut) + 2px) 0; }
.remote {
  --rg: 8px;
  position: relative; width: 100%; max-width: 440px;
  display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); grid-auto-rows: var(--kh);
  align-content: start; gap: var(--rg) 7px;
  padding: 26px 14px calc(var(--sab) + 16px);
  border-radius: 38px 38px 0 0;
  background:
    radial-gradient(120% 40% at 50% 0%, rgb(var(--g) / .14), transparent 70%),
    linear-gradient(90deg, rgb(0 0 0 / .45), transparent 9%, transparent 91%, rgb(0 0 0 / .45)),
    linear-gradient(180deg, #2a2a30 0%, #1f1f24 40%, #19191d 100%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .16),
    inset 0 0 0 1px rgb(255 255 255 / .03),
    0 -10px 40px -10px rgb(0 0 0 / .8),
    0 -1px 22px -6px rgb(var(--g) / .35);
  transition: transform .45s cubic-bezier(.3, .7, .2, 1);
}
.remote::before { /* soft-touch texture */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgb(255 255 255 / .035) 1px, transparent 1.2px);
  background-size: 4px 4px;
}
.rm-ir {
  position: absolute; left: 50%; top: 9px; width: 34px; height: 9px; transform: translateX(-50%);
  border-radius: 6px; background: linear-gradient(180deg, #3b0d10, #170405);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .8), 0 1px 0 rgb(255 255 255 / .08);
}
.rm-ir::after { content: ''; position: absolute; inset: 2px 13px; border-radius: 50%; background: #ff2d2d; opacity: 0; box-shadow: 0 0 8px 3px rgb(255 45 45 / .8); }
.rm-ir.blink::after { animation: ir .18s ease-out; }
@keyframes ir { 0% { opacity: 1; } 100% { opacity: 0; } }
.rm-brand { display: none; }

.k {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0; cursor: pointer;
  border-radius: 13px;
  color: #efeae0;
  font: 700 12px/1 var(--ui); font-stretch: 112%; letter-spacing: .08em; text-transform: uppercase;
  background: radial-gradient(120% 90% at 50% 18%, #4d4d56 0%, #3a3a42 45%, #2d2d34 100%);
  box-shadow:
    0 3px 0 #0e0e11,
    0 5px 8px -2px rgb(0 0 0 / .7),
    inset 0 1px 0 rgb(255 255 255 / .2),
    inset 0 -2px 3px rgb(0 0 0 / .25);
  transition: transform .07s ease-out, box-shadow .07s ease-out, filter .2s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.k:hover { filter: brightness(1.12); }
.k:active, .k.is-down {
  transform: translateY(3px);
  box-shadow: 0 0 0 #0e0e11, 0 1px 2px rgb(0 0 0 / .7), inset 0 2px 5px rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 255 255 / .06);
}
.k svg { width: 20px; height: 20px; flex: none; }
.k-num { font: 700 20px/1 var(--ui); font-stretch: 112%; font-variant-numeric: tabular-nums; letter-spacing: 0; border-radius: 50% / 46%; }
.k-power { color: #fff; background: radial-gradient(120% 90% at 50% 18%, #ff6e47 0%, #e8401f 50%, #b72b12 100%); box-shadow: 0 3px 0 #5e1405, 0 5px 10px -2px rgb(255 70 30 / .45), inset 0 1px 0 rgb(255 255 255 / .35), inset 0 -2px 3px rgb(0 0 0 / .2); }
.k-power:active, .k-power.is-down { box-shadow: 0 0 0 #5e1405, inset 0 2px 5px rgb(0 0 0 / .4); }
.k-power svg { width: 22px; height: 22px; }
.is-standby .k-power, .is-off .k-power { animation: beg 2.4s ease-in-out infinite; }
@keyframes beg { 50% { box-shadow: 0 3px 0 #5e1405, 0 0 0 5px rgb(255 90 50 / .22), 0 0 26px 4px rgb(255 70 30 / .55), inset 0 1px 0 rgb(255 255 255 / .35); } }
.k-mute .ic-off, .is-muted .k-mute .ic-on { display: none; }
.is-muted .k-mute .ic-off { display: block; color: #ffb3a3; }
.k-led { position: absolute; top: 6px; right: 8px; width: 5px; height: 5px; border-radius: 50%; background: #2a1210; }
.is-muted .k-led { background: #ff3b2a; box-shadow: 0 0 6px 1px rgb(255 59 42 / .8); }
.k-word[aria-pressed="true"] { color: #ffe27a; }
.k-word[aria-pressed="true"]::after { content: ''; position: absolute; bottom: 5px; left: 50%; width: 14px; height: 2px; margin-left: -7px; border-radius: 2px; background: #ffd23f; box-shadow: 0 0 6px #ffd23f; }

.k-fast { border-radius: 999px; font-size: 10px; letter-spacing: .08em; color: #111; }
.k-fast .fl { white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 92%; }
.k-fast .fl { pointer-events: none; }
.k-red { background: radial-gradient(120% 90% at 50% 15%, #ff7262, #e3352a 55%, #b1221a); box-shadow: 0 3px 0 #5a0e09, 0 5px 8px -2px rgb(0 0 0 / .7), inset 0 1px 0 rgb(255 255 255 / .35); color: #fff; }
.k-green { background: radial-gradient(120% 90% at 50% 15%, #6fe07f, #2fb24c 55%, #1f7e34); box-shadow: 0 3px 0 #0d3a17, 0 5px 8px -2px rgb(0 0 0 / .7), inset 0 1px 0 rgb(255 255 255 / .35); color: #04210b; }
.k-yellow { background: radial-gradient(120% 90% at 50% 15%, #ffe680, #f2c230 55%, #c08f0f); box-shadow: 0 3px 0 #5a4105, 0 5px 8px -2px rgb(0 0 0 / .7), inset 0 1px 0 rgb(255 255 255 / .45); color: #2a1d00; }
.k-blue { background: radial-gradient(120% 90% at 50% 15%, #79a8ff, #2f6fe0 55%, #1d4aa6); box-shadow: 0 3px 0 #0b2152, 0 5px 8px -2px rgb(0 0 0 / .7), inset 0 1px 0 rgb(255 255 255 / .35); color: #fff; }
.k-fast:active, .k-fast.is-down { box-shadow: inset 0 2px 5px rgb(0 0 0 / .4); }

.rm-digits { display: contents; }
.k-123 { display: none; }

.ring {
  position: relative; grid-row: span 3; align-self: center; justify-self: center;
  width: min(100%, calc(var(--kh) * 3 + 2 * var(--rg))); aspect-ratio: 1; height: auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #131316 0 44%, #232329 45%, #2c2c33 70%, #1c1c21 71%);
  box-shadow: inset 0 2px 6px rgb(0 0 0 / .8), 0 1px 0 rgb(255 255 255 / .08);
}
.rk { position: absolute; height: auto; border-radius: 12px; flex-direction: column; gap: 2px; font-size: 8.5px; letter-spacing: .14em; background: radial-gradient(120% 90% at 50% 18%, #46464f, #34343b 60%, #2a2a31); }
.rk svg { width: 16px; height: 16px; }
.rk-up { left: 30%; right: 30%; top: 4%; height: 28%; }
.rk-down { left: 30%; right: 30%; bottom: 4%; height: 28%; flex-direction: column-reverse; }
.rk-left { top: 30%; bottom: 30%; left: 4%; width: 28%; }
.rk-right { top: 30%; bottom: 30%; right: 4%; width: 28%; }
.rk-left span, .rk-right span { display: none; }
.rk-ok {
  left: 33%; top: 33%; width: 34%; height: 34%; border-radius: 50%;
  font: 800 13px/1 var(--ui); font-stretch: 125%; letter-spacing: .06em; color: #1b1a17;
  background: radial-gradient(120% 100% at 50% 20%, #fffaf0, #e7e0d1 55%, #bdb4a2);
  box-shadow: 0 3px 0 #6d6656, 0 6px 10px -3px rgb(0 0 0 / .8), inset 0 1px 0 #fff, 0 0 18px -4px rgb(var(--g) / .55);
}
.rk-ok:active, .rk-ok.is-down { box-shadow: 0 0 0 #6d6656, inset 0 2px 5px rgb(0 0 0 / .35); }

/* phone portrait grid: 20 columns */
.k-power { grid-area: 1 / 1 / 2 / 5; }
.k-text { grid-area: 1 / 5 / 2 / 9; }
.k-guide { grid-area: 1 / 9 / 2 / 13; }
.k-info { grid-area: 1 / 13 / 2 / 17; }
.k-mute { grid-area: 1 / 17 / 2 / 21; }
.k-red { grid-area: 2 / 1 / 3 / 6; }
.k-green { grid-area: 2 / 6 / 3 / 11; }
.k-yellow { grid-area: 2 / 11 / 3 / 16; }
.k-blue { grid-area: 2 / 16 / 3 / 21; }
.rm-digits > :nth-child(1) { grid-area: 3 / 1 / 4 / 5; }
.rm-digits > :nth-child(2) { grid-area: 3 / 5 / 4 / 9; }
.rm-digits > :nth-child(3) { grid-area: 3 / 9 / 4 / 13; }
.rm-digits > :nth-child(4) { grid-area: 3 / 13 / 4 / 17; }
.rm-digits > :nth-child(5) { grid-area: 3 / 17 / 4 / 21; }
.rm-digits > :nth-child(6) { grid-area: 4 / 1 / 5 / 5; }
.rm-digits > :nth-child(7) { grid-area: 4 / 5 / 5 / 9; }
.rm-digits > :nth-child(8) { grid-area: 4 / 9 / 5 / 13; }
.rm-digits > :nth-child(9) { grid-area: 4 / 13 / 5 / 17; }
.rm-digits > :nth-child(10) { grid-area: 4 / 17 / 5 / 21; }
.k-exit { grid-area: 6 / 1 / 7 / 5; }
.ring { grid-area: 5 / 6 / 8 / 16; }
.k-swap { grid-area: 6 / 17 / 7 / 21; }
.k-123 { grid-area: 7 / 17 / 8 / 21; }
.k-side { border-radius: 14px; font-size: 11px; }

/* compact remote: digits share the ring's slot (short phones) */
.rm-compact .rm-digits > * { grid-row: auto; }
.rm-compact .k-123 { display: flex; }
.rm-compact .rm-digits > :nth-child(-n+5) { grid-row: 4 / 5; }
.rm-compact .rm-digits > :nth-child(n+6) { grid-row: 5 / 6; }
.rm-compact .ring { grid-area: 3 / 6 / 6 / 16; }
.rm-compact .k-exit { grid-area: 3 / 1 / 4 / 5; }
.rm-compact .k-swap { grid-area: 3 / 17 / 4 / 21; }
.rm-compact .k-123 { grid-area: 5 / 17 / 6 / 21; }
.rm-compact:not(.show-pad) .rm-digits { display: none; }
.rm-compact.show-pad .ring, .rm-compact.show-pad .k-swap { display: none; }
.rm-compact.show-pad .rm-digits { display: contents; }
.rm-compact.show-pad .rm-digits > :nth-child(1) { grid-area: 3 / 5 / 4 / 9; }
.rm-compact.show-pad .rm-digits > :nth-child(2) { grid-area: 3 / 9 / 4 / 13; }
.rm-compact.show-pad .rm-digits > :nth-child(3) { grid-area: 3 / 13 / 4 / 17; }
.rm-compact.show-pad .rm-digits > :nth-child(4) { grid-area: 3 / 17 / 4 / 21; }
.rm-compact.show-pad .rm-digits > :nth-child(5) { grid-area: 4 / 5 / 5 / 9; }
.rm-compact.show-pad .rm-digits > :nth-child(6) { grid-area: 4 / 9 / 5 / 13; }
.rm-compact.show-pad .rm-digits > :nth-child(7) { grid-area: 4 / 13 / 5 / 17; }
.rm-compact.show-pad .rm-digits > :nth-child(8) { grid-area: 4 / 17 / 5 / 21; }
.rm-compact.show-pad .rm-digits > :nth-child(9) { grid-area: 5 / 5 / 6 / 9; }
.rm-compact.show-pad .rm-digits > :nth-child(10) { grid-area: 5 / 9 / 6 / 13; }
.rm-compact.show-pad .k-123 { color: #ffe27a; }
.rm-tiny .k-fast { display: none; }
.rm-tiny .ring { grid-area: 2 / 6 / 5 / 16; }
.rm-tiny .k-exit { grid-area: 2 / 1 / 3 / 5; }
.rm-tiny .k-swap { grid-area: 2 / 17 / 3 / 21; }
.rm-tiny .k-123 { grid-area: 4 / 17 / 5 / 21; }
.rm-tiny.show-pad .rm-digits > :nth-child(-n+4) { grid-row: 2 / 3; }
.rm-tiny.show-pad .rm-digits > :nth-child(n+5):nth-child(-n+8) { grid-row: 3 / 4; }
.rm-tiny.show-pad .rm-digits > :nth-child(n+9) { grid-row: 4 / 5; }

/* text mode on phones: lower the remote, let the picture grow */
.legend { display: none; }

/* ---------- desktop: set and remote side by side ---------- */
@media (min-width: 900px) and (orientation: landscape) and (min-height: 561px) {
  :root {
    --rw: clamp(206px, 15vw, 248px);
    --pw: clamp(104px, 9.6vw, 150px);
    --pad: clamp(18px, 2vw, 32px);
    --bz: clamp(10px, 1vw, 16px);
    --gap: clamp(28px, 4vw, 90px);
    --pi: clamp(20px, 2.8vw, 40px);              /* the stage's side padding */
    /* The set and the remote stand on the sideboard. The taller of the two sits one tab button below the tab
       bar (--top) at any window shape; whatever height is left over goes into the sideboard below them. */
    --top: clamp(28px, 3.6svh, 44px);
    --room-h: calc(100svh - var(--tabs-h));
    --surf-base: 96px;                          /* the sideboard at its smallest */
    --rgd: clamp(6px, .9svh, 10px);             /* gap between remote keys */
    --sh: min(
      calc(var(--room-h) - var(--top) - var(--surf-base) + 14px - 2 * var(--pad) - 2 * var(--bz)),
      calc((100vw - var(--rw) - var(--pw) - 4 * var(--pad) - 2 * var(--bz) - var(--gap) - 2 * var(--pi) - 16px) * .75),
      1000px);
    --sw: calc(var(--sh) * 4 / 3);
    --set-h: calc(var(--sh) + 2 * var(--bz) + 2 * var(--pad));
    /* keys as big as the height allows, but the remote no taller than the set (so the set's top is the one
       at --top), and never below 32 px */
    --kh: clamp(32px, min(4.9svh,
      calc((var(--set-h) - 10px - 10 * var(--rgd) - 52px) / 11),
      calc((var(--room-h) - var(--top) - var(--surf-base) + 4px - 10 * var(--rgd) - 52px) / 11)), 46px);
    --remote-h: calc(11 * var(--kh) + 10 * var(--rgd) + 52px);
    --surface-h: max(var(--surf-base), calc(var(--room-h) - var(--top) - max(var(--set-h) - 14px, var(--remote-h) - 4px)));
  }
  .stage { flex-direction: row; align-items: flex-end; justify-content: center; gap: var(--gap); padding: var(--top) var(--pi) 0; }
  .stage::after { /* sideboard edge */
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--surface-h, 96px));
    background:
      linear-gradient(180deg, rgb(var(--g) / .22) 0, rgb(255 255 255 / .06) 1px, transparent 2px),
      linear-gradient(180deg, rgb(var(--g) / .08), transparent 60%),
      linear-gradient(180deg, #0f0e0d, #080807);
    box-shadow: 0 -1px 0 rgb(0 0 0 / .8);
    z-index: 0;
  }
  .set { padding: 0; margin-bottom: calc(var(--surface-h, 96px) - 14px); }
  .cabinet { display: grid; grid-template-columns: auto var(--pw); gap: var(--pad); border-radius: 30px; }
  .bezel { border-radius: 22px; }
  .panel {
    flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 12px; padding: 12px;
    border-radius: 14px;
    background:
      linear-gradient(180deg, rgb(255 255 255 / .22), transparent 14%),
      repeating-linear-gradient(90deg, rgb(255 255 255 / .05) 0 1px, transparent 1px 3px, rgb(0 0 0 / .04) 3px 4px),
      linear-gradient(180deg, #8d8e93, #6e6f74 60%, #5c5d62);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -2px 0 rgb(0 0 0 / .3), 0 0 0 1px rgb(0 0 0 / .45), 0 2px 6px rgb(0 0 0 / .5);
  }
  .panel::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(120% 60% at 0% 40%, rgb(var(--g) / calc(.35 * var(--lit, 0))), transparent 70%); mix-blend-mode: soft-light; }
  .grille {
    display: block; flex: 1; min-height: 60px; border-radius: 10px;
    background:
      radial-gradient(circle, #0a0a0b 0 2.3px, rgb(255 255 255 / .22) 2.8px, transparent 3.3px) 0 0 / 11px 11px,
      radial-gradient(circle, #0a0a0b 0 2.3px, rgb(255 255 255 / .22) 2.8px, transparent 3.3px) 5.5px 5.5px / 11px 11px,
      linear-gradient(180deg, #808186, #6a6b70);
    box-shadow: inset 0 2px 4px rgb(0 0 0 / .55), inset 0 0 0 1px rgb(0 0 0 / .35), 0 1px 0 rgb(255 255 255 / .12);
  }
  .readout { height: 46px; width: 100%; border-radius: 8px; }
  .readout-ch { font-size: 30px; }
  .panel-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pkey {
    display: flex; align-items: center; justify-content: center; height: 34px; border: 0; border-radius: 7px; cursor: pointer; color: #d9d6cf;
    background: linear-gradient(180deg, #2a2a2e, #18181b); box-shadow: 0 2px 0 #08080a, inset 0 1px 0 rgb(255 255 255 / .14), 0 0 0 1px rgb(0 0 0 / .4);
  }
  .pkey svg { width: 14px; height: 14px; }
  .pkey:active { transform: translateY(2px); box-shadow: inset 0 2px 4px rgb(0 0 0 / .6); }
  .pkey-power {
    display: flex; height: 52px; color: #fff; border-radius: 10px;
    background: linear-gradient(180deg, #ff6a3d, #d93d19); box-shadow: 0 3px 0 #6a1a07, inset 0 1px 0 rgb(255 255 255 / .35), 0 0 22px -6px rgb(255 80 40 / .6);
  }
  .pkey-power svg { width: 22px; height: 22px; }
  .is-standby .pkey-power, .is-off .pkey-power { animation: beg 2.4s ease-in-out infinite; }
  .standby-led { position: absolute; right: 16px; bottom: 116px; z-index: 1; }
  .maker { align-items: center; padding: 8px 0 4px; border-radius: 6px; background: #121214; box-shadow: inset 0 1px 2px #000, 0 1px 0 rgb(255 255 255 / .25); }
  .maker b { font-size: clamp(8px, .75vw, 11px); letter-spacing: .14em; }
  .maker i { font-size: clamp(8px, .7vw, 10px); }
  .plinth {
    display: block; position: absolute; left: 7%; right: 7%; bottom: -12px; height: 12px;
    background:
      linear-gradient(90deg, #111 0 9%, transparent 9% 91%, #111 91%),
      linear-gradient(180deg, rgb(0 0 0 / .0), rgb(0 0 0 / .0));
    border-radius: 0 0 6px 6px;
    filter: drop-shadow(0 8px 10px rgb(0 0 0 / .9));
  }
  .remote-wrap { flex: none; width: var(--rw); padding: 0; margin-bottom: calc(var(--surface-h, 96px) - 4px); flex-direction: column; align-items: center; gap: 18px; }
  .remote {
    --rg: var(--rgd);
    grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--rg) 8px;
    padding: 30px 18px 22px; border-radius: 44px 44px 40px 40px;
    background:
      radial-gradient(130% 30% at 0% 50%, rgb(var(--g) / .16), transparent 70%),
      linear-gradient(90deg, rgb(0 0 0 / .45), transparent 10%, transparent 88%, rgb(0 0 0 / .5)),
      linear-gradient(180deg, #2a2a30 0%, #1f1f24 40%, #19191d 100%);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / .16), inset 0 -3px 0 rgb(0 0 0 / .5),
      0 30px 50px -16px rgb(0 0 0 / .95), -6px 0 30px -10px rgb(var(--g) / .4);
  }
  .k-power { grid-area: 1 / 1 / 2 / 4; }
  .k-mute { grid-area: 1 / 10 / 2 / 13; }
  .rm-digits > :nth-child(1) { grid-area: 2 / 1 / 3 / 5; }
  .rm-digits > :nth-child(2) { grid-area: 2 / 5 / 3 / 9; }
  .rm-digits > :nth-child(3) { grid-area: 2 / 9 / 3 / 13; }
  .rm-digits > :nth-child(4) { grid-area: 3 / 1 / 4 / 5; }
  .rm-digits > :nth-child(5) { grid-area: 3 / 5 / 4 / 9; }
  .rm-digits > :nth-child(6) { grid-area: 3 / 9 / 4 / 13; }
  .rm-digits > :nth-child(7) { grid-area: 4 / 1 / 5 / 5; }
  .rm-digits > :nth-child(8) { grid-area: 4 / 5 / 5 / 9; }
  .rm-digits > :nth-child(9) { grid-area: 4 / 9 / 5 / 13; }
  .rm-digits > :nth-child(10) { grid-area: 5 / 5 / 6 / 9; }
  .k-exit { grid-area: 5 / 1 / 6 / 5; }
  .k-swap { grid-area: 5 / 9 / 6 / 13; }
  .ring { grid-area: 6 / 1 / 9 / 13; }
  .k-text { grid-area: 9 / 1 / 10 / 5; }
  .k-guide { grid-area: 9 / 5 / 10 / 9; }
  .k-info { grid-area: 9 / 9 / 10 / 13; }
  .k-red { grid-area: 10 / 1 / 11 / 4; }
  .k-green { grid-area: 10 / 4 / 11 / 7; }
  .k-yellow { grid-area: 10 / 7 / 11 / 10; }
  .k-blue { grid-area: 10 / 10 / 11 / 13; }
  .k-fast { height: 24px; align-self: start; margin-top: 2px; font-size: 8.5px; letter-spacing: .08em; }
  .k-fast .fl { position: absolute; top: calc(100% + 6px); left: -4px; right: -4px; max-width: none; text-align: center; color: var(--ink-2); font-size: 8.5px; overflow: visible; }
  .k-fast:active, .k-fast.is-down { transform: translateY(2px); }
  .k-side, .k-word { font-size: 10.5px; }
  .rm-brand {
    display: block; grid-area: 11 / 1 / 12 / 13; align-self: center; text-align: center;
    font: 800 9px/1 var(--ui); font-stretch: 125%; letter-spacing: .3em; color: #6d6a64;
  }
  .legend {
    display: flex; align-items: center; gap: 14px; position: absolute; z-index: 4;
    left: calc(var(--sal) + 28px); bottom: 26px; color: var(--ink-3); font-size: 11.5px; line-height: 1.5;
  }
  .legend-h { margin: 0; font: 700 10px/1 var(--ui); font-stretch: 112%; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); }
  .legend ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
  kbd {
    display: inline-block; min-width: 20px; padding: 2px 5px; margin: 0 1px; text-align: center;
    border-radius: 5px; border: 1px solid rgb(255 255 255 / .16); border-bottom-width: 2px;
    font: 400 11px/1.3 var(--tt); color: var(--ink);
    background: rgb(255 255 255 / .04);
  }
  .glow-floor {
    display: block; position: absolute; left: 50%; bottom: 0; width: 120vmax; height: 120px; transform: translateX(-50%);
    background: radial-gradient(closest-side, rgb(var(--g) / .35), rgb(var(--g) / .1) 50%, transparent 100%);
  }
  .surface { height: var(--surface-h, 96px); z-index: 1; }
  .is-text .k-fast { font-size: 8.5px; }
}
@media (min-width: 900px) and (orientation: landscape) and (min-height: 561px) and (max-height: 760px) {
  :root { --surf-base: 70px; }
  .legend { display: none; }
}

/* ---------- tablet portrait ---------- */
@media (min-width: 640px) and (orientation: portrait) {
  /* the set on top, one tab button below the tab bar, sized so the remote below it always fits */
  :root {
    --gut: 28px; --bz: 14px; --pad: 0px;
    --top: clamp(28px, 3.6svh, 44px);
    --remote-want: 426px;                      /* seven rows of 48 px keys with their gaps and padding */
    --sw: min(calc(100vw - 2 * var(--gut) - 2 * var(--bz)), 860px,
      calc((100svh - var(--tabs-h) - var(--top) - 24px - var(--remote-want) - var(--sab) - 2 * var(--bz) - 18px - 58px) * 4 / 3));
  }
  .set { display: flex; justify-content: center; padding-top: var(--top); }
  .cabinet { padding: 18px 18px 0; border-radius: 30px; }
  .panel { padding: 0 6px; min-height: 58px; }
  .remote-wrap { padding-top: 24px; }
  .remote { max-width: 460px; }
}

/* ---------- phone landscape: the picture gets the screen ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --bz: 6px; --gut: 8px; --pad: 0px;
    --sh: calc(100svh - var(--tabs-h) - 2 * var(--bz) - 2 * var(--gut) - var(--sab));
    --sw: min(calc(var(--sh) * 4 / 3), calc(100vw - 300px - var(--sal) - var(--sar)));
  }
  .room { min-height: 300px; }
  .stage { flex-direction: row; align-items: center; justify-content: center; gap: 12px; padding: 0 calc(var(--sar) + 8px) 0 calc(var(--sal) + 8px); }
  .set { padding: 0; }
  .cabinet { padding: 0; background: none; box-shadow: none; }
  .cabinet::before { display: none; }
  .screen { height: calc(var(--sw) * .75); }
  .panel { display: none; }
  .remote-wrap { flex: 0 1 290px; padding: 0; align-self: center; }
  .remote {
    --rg: 6px;
    border-radius: 30px; padding: 20px 12px 14px; max-width: 290px;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .16), 0 20px 40px -10px rgb(0 0 0 / .9), -6px 0 30px -10px rgb(var(--g) / .4);
  }
}



/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
