:root {
  color-scheme: dark;
  --lime: #dbff5c;
  --bg: #111713;
  --panel: #19221c;
  --line: #354139;
  --text: #f0f6ed;
  --muted: #a8b9ad;
  --warn: #ffd27a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top right, #243928, var(--bg) 62%);
  background-color: var(--bg);
  color: var(--text);
  font: 16px system-ui, sans-serif;
}

main {
  max-width: 980px;
  margin: auto;
  padding: 24px clamp(16px, 5vw, 44px);
}

header,
footer,
.stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  color: var(--lime);
  font: 700 12px ui-monospace, monospace;
  letter-spacing: 0.12em;
}

footer {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
}

.stats b {
  font-size: 16px;
}

h1 {
  margin: 24px 0 6px;
  font-size: clamp(40px, 8vw, 76px);
  line-height: 1.04;
  letter-spacing: -0.07em;
}

p,
small {
  color: var(--muted);
}

a {
  color: var(--lime);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 460;
  margin: 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: pan-y;
}

canvas:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.keys {
  margin: 0 0 12px;
  font: 13px ui-monospace, monospace;
}

.feedback {
  min-height: 1.4em;
  margin: 6px 0 0;
  color: var(--warn);
  font-weight: 700;
}

.actions,
.pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.actions + .actions,
.qa + .actions {
  margin-top: 12px;
}

.pair {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.pair small {
  flex-basis: 100%;
}

button,
input,
select {
  font: inherit;
  border-radius: 8px;
}

button {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--lime);
  background: var(--lime);
  color: #132012;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost,
input,
select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
}

input {
  padding: 10px 14px;
  max-width: 16ch;
}

select {
  padding: 8px 10px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.check input {
  width: 18px;
  height: 18px;
  padding: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid white;
  outline-offset: 3px;
}

#qr canvas {
  width: 134px;
  height: 134px;
  aspect-ratio: 1;
  margin: 0;
  border: 0;
  border-radius: 0;
  image-rendering: pixelated;
}

/* QA mode */
.qa {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--lime);
  border-radius: 12px;
}

.qa #qaPrompt {
  margin-top: 0;
  color: var(--text);
  font-weight: 700;
}

.qa-answers button {
  flex: 1 1 140px;
}

/* Diagnostics */
.diagnostics {
  margin-top: 22px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.diagnostics summary {
  cursor: pointer;
  color: var(--lime);
  font: 700 13px ui-monospace, monospace;
}

.diagnostics table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font: 12px ui-monospace, monospace;
}

.diagnostics th,
.diagnostics td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.diagnostics th {
  color: var(--muted);
  font-weight: 600;
}

.diagnostics p,
.diagnostics dl {
  font: 12px ui-monospace, monospace;
}

#diagBody {
  overflow-x: auto;
}

.copy-fallback {
  width: 100%;
  max-width: none;
  margin-top: 8px;
  font: 12px ui-monospace, monospace;
}

.load-error {
  padding: 12px;
  border: 1px solid var(--warn);
  border-radius: 8px;
  color: var(--warn);
}

/* Phone */
#remote .actions button {
  min-height: 60px;
}

#remote input[type='range'] {
  width: 100%;
  max-width: none;
  padding: 0;
}
