/* ZerPad, console style: night blue background, bright blue highlights, the controller in the spotlight.
   Fonts: IBM Plex Sans and IBM Plex Mono (SIL Open Font License), served from assets/fonts. */
@font-face { font-family: "Plex Sans"; src: url(assets/fonts/plex-sans-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url(assets/fonts/plex-sans-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Sans"; src: url(assets/fonts/plex-sans-600.woff2) format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url(assets/fonts/plex-mono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url(assets/fonts/plex-mono-500.woff2) format("woff2"); font-weight: 500 700; font-display: swap; }

:root {
  --bg: #070b15; --panel: #0e1424; --panel2: #141c30; --text: #eaf0fb; --muted: #8e9ab4; --line: #1f2a45; --line2: #18213a;
  --accent: #5b9bff; --accent-fill: #2563eb; --on-accent: #ffffff; --accent2: #38d6c4; --glow: #2f6bff;
  --ok: #3ddc84; --okbg: #3ddc841c; --bad: #ff5d6c; --badbg: #ff5d6c1c; --warn: #ffb84d; --warnbg: #ffb84d1a; --infobg: #2f6bff1f;
  --btn-bg: #141c30; --btn-hover: #1b2540; --btn-border: #26324f; --primary: #2563eb; --primary-hover: #2f6bff; --on-primary: #ffffff;
  --font: "Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --c1: #ff5d6c; --c2: #3ddc84; --c3: #5b9bff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html.i18n-wait body { visibility: hidden; }
body { margin: 0; color: var(--text); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  background: radial-gradient(1200px 600px at 50% -200px, #12204a 0%, transparent 70%), var(--bg); background-attachment: fixed; min-height: 100vh; }
.mono, pre { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; color: var(--muted); }
h1, h2, h3 { font-weight: 600; margin: 0; }
h3 { font-size: 13px; margin: 18px 0 8px; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: .2em; }
a:hover { color: #8cb8ff; }
::selection { background: var(--accent-fill); color: #fff; }

/* Buttons and fields */
button { font: inherit; font-size: 13px; font-weight: 500; line-height: 20px; padding: 7px 16px; border-radius: 8px; cursor: pointer;
  color: var(--text); background: var(--btn-bg); border: 1px solid var(--btn-border); white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover:not(:disabled) { background: var(--btn-hover); border-color: #34446a; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { color: var(--muted); cursor: not-allowed; opacity: .5; }
button:focus-visible, .tab:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
button.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost { background: transparent; }
button.ok { color: var(--ok); border-color: #3ddc8466; }
button.bad { color: var(--bad); border-color: #ff5d6c66; }
button.small { font-size: 12px; line-height: 18px; padding: 3px 10px; }
button.big { font-size: 15px; line-height: 24px; padding: 12px 28px; border-radius: 10px; }
input[type=text], select { font: inherit; font-size: 13px; line-height: 20px; padding: 7px 12px; border-radius: 8px; color: var(--text);
  background: var(--panel2); border: 1px solid var(--btn-border); }
input[type=text]::placeholder { color: #66728c; }
input[type=text]:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #2f6bff33; }
input[type=text] { flex: 1; min-width: 0; }
input[type=range], input[type=checkbox] { accent-color: var(--accent-fill); }

/* Header */
.top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 32px; min-height: 64px;
  background: #070b15cc; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line2); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; }
.name { font-size: 17px; font-weight: 600; line-height: 1.2; letter-spacing: .02em; }
.sub { margin: 0; font-size: 12px; color: var(--muted); }
.conn { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#btnConnect { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 12px; font-weight: 500; line-height: 18px;
  padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--panel); margin-right: 2px; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4a5674; flex: none; }
.pill.on { color: var(--text); border-color: #3ddc8440; }
.pill.on::before { background: var(--ok); }
select.lang { font-size: 12px; line-height: 18px; padding: 5px 8px; }

/* Messages */
.banner { margin: 16px 32px 0; padding: 12px 16px; border-radius: 10px; border: 1px solid #2f6bff55; background: var(--infobg); font-size: 13px; }
.banner.warn { border-color: #ffb84d55; background: var(--warnbg); }
.banner.bad { border-color: #ff5d6c66; background: var(--badbg); }
.lang-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.lang-offer span { flex: 1; min-width: 200px; }

/* Welcome screen, until a controller is connected */
body:not(.connected) .side, body:not(.connected) .workspace { display: none; }
body.connected #welcome { display: none; }
#welcome { max-width: 1160px; margin: 0 auto; padding: 56px 32px 48px; }
.wl-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: center; }
#welcome h1 { font-size: 50px; line-height: 1.05; letter-spacing: -.02em; margin: 0 0 18px; }
.lead { font-size: 17px; line-height: 1.6; color: var(--muted); margin: 0 0 28px; max-width: 52ch; }
.steps { list-style: none; counter-reset: step; margin: 0 0 30px; padding: 0; display: grid; gap: 10px; max-width: 52ch; }
.steps li { counter-increment: step; position: relative; padding: 12px 14px 12px 52px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line2); font-size: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 11px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-fill); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.wl-text .small { margin: 14px 0 0; }
/* The controller in the spotlight */
.wl-img { width: 100%; height: auto; padding: 24px; filter: drop-shadow(0 30px 40px #000a);
  background: radial-gradient(closest-side, #2f6bff80, #2f6bff26 55%, transparent 100%); }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 56px; }
.features > div { padding: 20px; border-radius: 14px; background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--line2); }
.features h2 { font-size: 15px; margin-bottom: 6px; }
.features h2::before { content: ""; display: block; width: 28px; height: 3px; border-radius: 2px; background: var(--accent-fill); margin-bottom: 14px; }
.features p { margin: 0; font-size: 13.5px; color: var(--muted); }

/* Menu bar under the header, like a console home screen */
.side { position: sticky; top: 64px; z-index: 4; background: #070b15e6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line2); }
.tabs { display: flex; gap: 4px; padding: 8px 32px; overflow-x: auto; scrollbar-width: none; max-width: 1344px; margin: 0 auto; }
.tab { flex: none; font-size: 14px; font-weight: 500; line-height: 20px; padding: 8px 16px; color: var(--muted); background: none; border: 1px solid transparent; border-radius: 999px; }
.tab:hover:not(:disabled) { color: var(--text); background: var(--panel); border-color: transparent; }
.tab.active { color: #fff; background: var(--panel2); border-color: #2f6bff66; }
.tab-aside { margin-left: auto; }
.side-dev { display: none; }

.workspace { padding: 28px 32px 32px; max-width: 1344px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.ph { margin-bottom: 20px; }
.ph-n { display: none; }
.ph h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.01em; }

/* Panels */
.card { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 20px; margin-bottom: 16px; min-width: 0; }
.card > h2:first-child { font-size: 15px; margin: 0 0 16px; }
.card > h2:first-child .small { font-weight: 400; }
.card > h2:not(:first-child) { font-size: 15px; margin: 24px 0 12px; }
.grid2, .grid3 { display: grid; gap: 16px; margin-bottom: 16px; align-items: start; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }

table.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.kv th { text-align: left; font-weight: 400; color: var(--muted); padding: 8px 16px 8px 0; white-space: nowrap; vertical-align: top; width: 1%; }
table.kv td { padding: 8px 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
table.kv td.mono { font-size: 12.5px; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid var(--line2); }
table.kv.small th, table.kv.small td { padding: 4px 12px 4px 0; font-size: 12px; }
#history table.kv td { padding: 8px 12px 8px 0; }

.bat { display: inline-block; width: 40px; height: 14px; border: 1.5px solid #6c7896; border-radius: 4px; vertical-align: -2px; margin-right: 8px; padding: 2px; position: relative; }
.bat::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 5px; background: #6c7896; border-radius: 0 1px 1px 0; }
.bat div { height: 100%; background: var(--ok); width: 0; border-radius: 1px; }
.bat div.low { background: var(--bad); }

/* Controller header */
.hero { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 32px; align-items: center; padding: 24px 32px;
  background: radial-gradient(500px 300px at 22% 50%, #2f6bff33, transparent 70%), linear-gradient(180deg, var(--panel2), var(--panel)); }
.hero-img { width: 100%; height: auto; filter: drop-shadow(0 24px 30px #000b); transition: opacity .2s, filter .2s; }
.hero-img.idle { opacity: .35; filter: grayscale(1); }
.hero-info { min-width: 0; }
.hero-model { font-size: 32px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.hero-color { color: var(--accent); font-weight: 500; margin: 6px 0 20px; }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 10px; margin: 0; }
.hero-facts div { padding: 10px 12px; border-radius: 10px; background: #0a1020; border: 1px solid var(--line2); }
.hero-facts dt { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.hero-facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#btnStartCheck { margin-top: 22px; font-size: 15px; padding: 10px 24px; border-radius: 10px; }

/* Inputs */
.btngrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn { text-align: center; padding: 10px 2px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 13px; font-weight: 500;
  user-select: none; color: var(--muted); transition: background .06s, box-shadow .06s; }
.btn.on { background: var(--accent-fill); color: #fff; border-color: var(--accent); }
.sticks { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.sticks figure { margin: 0; text-align: center; }
.sticks canvas { width: 180px; max-width: 42vw; height: auto; border-radius: 50%; background: radial-gradient(circle, #16203a, #0b1120); border: 1px solid var(--line); }
figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.trig { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.trig label { width: 24px; font-weight: 600; }
.bar { flex: 1; height: 8px; background: #0a1020; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--accent-fill); }
.trig span { min-width: 34px; text-align: right; }
canvas.wide { width: 100%; height: auto; background: #0a1020; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; }
canvas.touch { width: 100%; max-width: 720px; display: block; margin: 0 auto; height: auto; border-radius: 16px; border: 1px solid var(--line); }

/* Outputs */
.row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row input[type=range] { flex: 1; min-width: 80px; }
.row span.mono { width: 34px; text-align: right; }
.leds { display: inline-flex; gap: 8px; }
.leds input { width: 16px; height: 16px; }
.trigfx label { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.micbar { max-width: 240px; min-width: 120px; }
.micbar div { background: var(--ok); }

/* Output presets */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button.sel { color: #fff; background: var(--accent-fill); border-color: var(--accent-fill); }
.grid-btns { display: grid; grid-template-columns: 1fr 1fr; }
.grid-btns button { white-space: normal; text-align: left; }
.grid-btns .stop { grid-column: 1 / -1; text-align: center; }
.chips { align-items: center; }
.chip { width: 32px; height: 32px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid #ffffff26; }
.chip:hover:not(:disabled) { background: var(--c); border-color: #ffffff80; }
.chip.off { background: #000; border-color: #ffffff40; }
.chip.off:hover:not(:disabled) { background: #000; }
.seg .chip.sel { background: var(--c); border-color: #fff; box-shadow: 0 0 0 2px var(--accent-fill); }
.seg .chip.off.sel { background: #000; }
.chips .cycle { margin-left: 4px; }
#tab-out h3 { color: var(--muted); font-weight: 500; font-size: 12px; margin: 16px 0 8px; }
#tab-out h3:first-of-type { margin-top: 0; }

/* Games */
.intro { margin: -10px 0 18px; font-size: 14px; }
.game { display: flex; flex-direction: column; }
.game > p.small:first-of-type { min-height: 54px; margin-top: 0; }
.game canvas { display: block; width: 100%; height: 220px; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #0a1020; }
.game .row { flex-wrap: wrap; gap: 12px; }
.game .gstatus { min-height: 21px; margin: 12px 0 0; font-weight: 600; }
.game .gstatus + .small { margin: 2px 0 0; }

/* Check */
.verdict-card { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; align-items: center;
  background: linear-gradient(180deg, var(--panel2), var(--panel)); }
.verdict-card h2 { font-size: 13px; color: var(--muted); font-weight: 500; }
.verdict { display: inline-flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 600; line-height: 1.2; margin: 6px 0; color: var(--muted); }
.verdict::before { content: ""; width: 12px; height: 12px; border-radius: 50%; flex: none; background: currentColor; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict.partial { color: var(--warn); }
.verdict.none::before { background: none; box-shadow: none; border: 2px solid currentColor; }
.verdict-card .small { font-size: 13px; margin: 0; max-width: 70ch; }
.progress { height: 6px; background: #0a1020; border-radius: 999px; overflow: hidden; margin: 12px 0 0; max-width: 420px; border: 1px solid var(--line2); }
.progress > div { height: 100%; background: var(--accent-fill); transition: width .3s; }
.progress > div.bad { background: var(--bad); box-shadow: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tests { display: grid; gap: 10px; margin-bottom: 16px; }
.tests > .card { margin: 0; }
.test { padding: 16px 20px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line2); min-width: 0; transition: border-color .15s; }
.test.running { border-color: #2f6bff66; }
.test.current { border-color: #2f6bff99; }
.test.pass { border-color: #3ddc8433; }
.test.fail { border-color: #ff5d6c55; }
.test.skip { opacity: .55; }
.thead { display: flex; align-items: center; gap: 12px; }
.thead h3 { flex: 1; margin: 0; font-size: 15px; }
.thead small { color: var(--muted); font-weight: 400; font-size: 12px; }
.num { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--panel2); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.test.current .num { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.test.pass .num { background: #3ddc8422; border-color: #3ddc8466; color: var(--ok); }
.test.fail .num { background: #ff5d6c22; border-color: #ff5d6c66; color: var(--bad); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 18px; padding: 2px 10px; border-radius: 999px; color: var(--muted); background: var(--panel2); white-space: nowrap; }
.badge.running { color: #fff; background: var(--accent-fill); }
.badge.pass { color: #062b16; background: var(--ok); }
.badge.fail { color: #fff; background: #e5414f; }
.test > p.small { margin: 6px 0 0 40px; font-size: 13.5px; max-width: 95ch; }
.detail { margin: 10px 0 0 40px; color: var(--text); padding: 8px 12px; border-radius: 8px; background: #0a1020; border: 1px solid var(--line2); }
.detail:empty { display: none; }
.tact { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0 40px; }

pre.hex { background: #0a1020; padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 0; line-height: 1.5; border: 1px solid var(--line2); color: #b9c6e3; }
pre.log { max-height: 260px; overflow-y: auto; white-space: pre-wrap; }
.foot { padding: 24px 32px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line2); margin-top: 32px; text-align: center; }

/* Calibration */
.reqs { list-style: none; padding: 0; margin: 0 0 12px; }
.reqs li { padding: 8px 0; border-top: 1px solid var(--line2); }
.reqs li:first-child { border-top: none; }
.reqs li.bad { color: var(--bad); }
.calstep { background: #0a1020; border: 1px solid #2f6bff44; border-radius: 12px; padding: 16px; margin-bottom: 12px; min-height: 72px; }
.calstep b.big { font-size: 16px; display: block; margin-bottom: 4px; }

.txt-ok { color: var(--ok); }
.txt-bad { color: var(--bad); }
.presses { display: flex; flex-wrap: wrap; gap: 6px; }
.presses span { font-size: 12px; line-height: 18px; padding: 3px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); }
.presses span b { font-weight: 600; margin-right: 6px; color: var(--accent); }

/* Printed report: one A4 page */
.print-only { display: none; }
@page { size: A4; margin: 11mm 12mm; }
@media print {
  body { background: #fff; color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 9.5px; line-height: 1.35; }
  .top, .banner, .tabs, main, .foot { display: none !important; }
  .print-only { display: block; }
  .print-only h2 { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #333; margin: 12px 0 4px; padding-bottom: 3px; border-bottom: 1.5px solid #111; }
  .print-only table { width: 100%; border-collapse: collapse; }
  .print-only th, .print-only td { padding: 2.5px 5px 2.5px 0; text-align: left; vertical-align: top; border-bottom: .5px solid #d4d4d4; }
  .print-only th { font-weight: 400; color: #555; width: 40%; }
  .rp-head { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 8px; border-bottom: 2.5px solid #111; }
  .rp-brand { display: flex; align-items: center; gap: 8px; }
  .rp-brand img { width: 26px; height: 26px; border-radius: 5px; }
  .rp-brand b { display: block; font-size: 15px; }
  .rp-brand span { font-size: 11px; color: #444; }
  .rp-meta { text-align: right; font-size: 9px; color: #444; }
  .rp-meta b { color: #111; font-size: 10px; }
  .rp-top { display: flex; align-items: center; gap: 18px; margin: 10px 0 2px; }
  .rp-pad { width: 62mm; height: auto; flex: none; }
  .rp-verdict { flex: 1; border-left: 4px solid #777; padding: 4px 0 4px 12px; }
  .rp-verdict span { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #555; }
  .rp-verdict strong { display: block; font-size: 22px; margin: 1px 0 3px; }
  .rp-verdict p { margin: 0; color: #333; }
  .rp-verdict .rp-count { margin-top: 4px; font-weight: 600; }
  .rp-verdict.ok { border-color: #1d7a4c; } .rp-verdict.ok strong { color: #1d7a4c; }
  .rp-verdict.bad { border-color: #b3261e; } .rp-verdict.bad strong { color: #b3261e; }
  .rp-verdict.partial { border-color: #8f6200; } .rp-verdict.partial strong { color: #8f6200; }
  .rp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .rp-tests th { width: auto; font-weight: 600; color: #333; border-bottom: 1px solid #111; }
  .rp-tests .n { width: 14px; color: #777; }
  .rp-tests .st { width: 52px; font-weight: 700; }
  .rp-tests tr.pass .st { color: #1d7a4c; }
  .rp-tests tr.fail .st { color: #b3261e; }
  .rp-tests tr.pending .st, .rp-tests tr.skip .st { color: #888; }
  .rp-tests .dt { font-size: 8.5px; color: #333; }
  .rp-tests i { color: #777; font-style: normal; }
  .rp-tests tr { break-inside: avoid; }
  .rp-notes { margin: 8px 0 0; }
  .rp-scope p { margin: 0; font-size: 8.5px; color: #333; text-align: justify; }
  .rp-foot { margin: 8px 0 0; font-size: 8px; color: #777; }
}

@media (max-width: 960px) {
  .wl-main { grid-template-columns: 1fr; gap: 12px; }
  .wl-img { order: -1; max-width: 560px; justify-self: center; }
  #welcome h1 { font-size: 38px; }
  .hero { grid-template-columns: 1fr; gap: 8px; padding: 20px; }
  .hero-img { max-width: 420px; justify-self: center; }
  .features { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .top { position: static; padding: 10px 16px; }
  .side { top: 0; }
  .tabs { padding: 8px 16px; }
  .workspace { padding: 20px 16px; }
  .banner { margin-left: 16px; margin-right: 16px; }
  #welcome { padding: 28px 16px; }
  #welcome h1 { font-size: 31px; }
  .lead { font-size: 15.5px; }
  .features { grid-template-columns: 1fr; }
  .btngrid { grid-template-columns: repeat(3, 1fr); }
  .ph h1 { font-size: 23px; }
  .test { padding: 14px; }
  .test > p.small, .detail, .tact { margin-left: 0; }
  .top .sub { display: none; }
  .conn { width: 100%; flex-wrap: nowrap; }
  .conn button { font-size: 12px; padding: 5px 10px; }
  .conn .pill { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
  .verdict { font-size: 22px; }
  label.row { flex-wrap: wrap; }
  label.row input[type=text] { flex-basis: 100%; }
}

/* Quick test (Gamepad API) */
.quick { margin: 16px 32px 0; }
.qstatus { font-size: 13px; margin: 8px 0 14px; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 16px; align-items: center; }
.qcol { text-align: center; min-width: 0; }
.qstick { width: 100%; max-width: 180px; aspect-ratio: 1; display: block; margin: 0 auto 6px; }
.qtrig { text-align: left; }
.qbar { height: 10px; border-radius: 5px; background: var(--line2); margin: 4px 0 12px; overflow: hidden; }
.qbar i { display: block; height: 100%; width: 0; background: var(--primary); }
.qbuttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 6px; }
.qbtn { min-width: 40px; padding: 5px 9px; border: 1px solid var(--line2); border-radius: 8px; font-size: 13px; text-align: center; color: var(--muted); }
.qbtn.seen { color: var(--text); border-color: var(--primary); }
.qbtn.on { background: var(--primary); color: #fff; }
.qactions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
@media (max-width: 640px) { .quick { margin: 12px 16px 0; } }

/* FAQ */
.faq { margin-top: 48px; max-width: 820px; }
.faq h2 { font-size: 18px; margin: 0 0 12px; }
.faq details { border-bottom: 1px solid var(--line2); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 500; font-size: 14.5px; }
.faq p { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.6; }
#btnClearHistory { margin-top: 12px; }

/* Less motion when the system asks for it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
.kbd-hint { flex-basis: 100%; margin: 4px 0 0; }

/* ZP Arena promotion in the Games tab */
.arena-promo { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; border-color: var(--btn-border); }
.arena-promo > div { flex: 1 1 320px; }
.arena-promo h2 { margin: 0 0 6px; font-size: 18px; }
.arena-promo p { margin: 0; }
a.btnlink { display: inline-block; padding: 9px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; }
a.btnlink.primary { background: var(--primary); color: var(--on-primary); }
a.btnlink.primary:hover { background: var(--primary-hover); }
