:root {
  color-scheme: dark;
  --bg: #0d0b14;
  --panel: #17141f;
  --line: #2a2536;
  --text: #ece8f4;
  --muted: #a39cb3;
  --accent: #8b5cf6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header, .keys, footer { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
header { padding-top: 24px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
.tag {
  font-size: 13px; font-weight: 600; vertical-align: middle;
  padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff;
}
header p, footer p { color: var(--muted); margin: 4px 0; }

main {
  max-width: 1280px; margin: 16px auto; padding: 0 20px;
  display: grid; grid-template-columns: 1fr 180px; gap: 16px; align-items: start;
}
main > .remote { grid-column: 2; grid-row: 1;
}
.tv {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border: 10px solid #1d1a24; border-radius: 14px; overflow: hidden;
  box-shadow: 0 20px 60px #0008;
}
#canvas { display: block; width: 100% !important; height: 100% !important; outline: none; }
.badge {
  grid-column: 1; margin: -6px 0 0; justify-self: center;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 6px; color: #fbbf24; border: 1px solid #fbbf2466;
}
.status {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); background: #000; font-size: 18px;
}
.status.hidden { display: none; }

.remote {
  background: var(--panel); border: 1px solid var(--line); border-radius: 28px;
  padding: 20px 14px; display: grid; gap: 12px; justify-items: center;
}
.remote button {
  background: #262131; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer;
  touch-action: manipulation; user-select: none;
}
.remote button:active, .remote button.down-now { background: var(--accent); }
.dpad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 4px; }
.dpad button { padding: 0; }
.dpad .up { grid-area: 1 / 2; }
.dpad .left { grid-area: 2 / 1; }
.dpad .ok { grid-area: 2 / 2; border-radius: 50%; font-weight: 700; }
.dpad .right { grid-area: 2 / 3; }
.dpad .down { grid-area: 3 / 2; }
.row { display: flex; gap: 6px; }

.keys ul { margin: 0; padding-left: 18px; color: var(--muted); }
kbd {
  font: 12px ui-monospace, monospace; padding: 1px 6px; margin-right: 2px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; color: var(--text);
}
footer { padding-top: 16px; padding-bottom: 32px; font-size: 13px; }

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; }
  .remote { grid-template-columns: auto auto auto; justify-content: center; border-radius: 18px; }
}
