@font-face {
  font-family: "Kenney Pixel";
  src: url("assets/fonts/kenney-pixel.ttf") format("truetype");
  font-display: block;
}

:root {
  --ink: #2a2030;
  --muted: #6b5f70;
  --paper: #fbf7f2;
  --card: #ffffff;
  --line: #e7ded4;
  --stage: #3f2631;
  --accent: #c2512f;
  --off: #7a8296;
  --btn: #f3ece4;
  --btn-hover: #ebe0d4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece6ef;
    --muted: #a99fae;
    --paper: #17131b;
    --card: #211b26;
    --line: #362d3c;
    --accent: #f08a5d;
    --off: #9aa3b8;
    --btn: #2e2635;
    --btn-hover: #3a3042;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto;
  max-width: 720px;
  padding: 20px 14px 40px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.intro h1 {
  font-weight: 700;
  font-size: 26px;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: .5px;
}
.intro p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }

.trick {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 14px 12px;
  margin: 0 0 22px;
}
.trick-head { display: flex; gap: 10px; align-items: baseline; }
.trick-num {
  flex: none;
  font-family: "Kenney Pixel", monospace;
  font-size: 20px;
  line-height: 1;
  background: var(--stage);
  color: #f7c282;
  border-radius: 4px;
  padding: 2px 7px 3px;
  align-self: center;
}
.trick h2 {
  font-weight: 700;
  font-size: 19px;
  line-height: 1.25;
  margin: 0;
}
.trick .lede { margin: 4px 0 10px; color: var(--muted); font-size: 14.5px; }

.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  outline: none;
  border-radius: 8px;
}
.stage:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.panel { margin: 0; min-width: 0; }
.panel canvas {
  display: block;
  width: 100%;
  aspect-ratio: 176 / 128;
  background: var(--stage);
  border-radius: 6px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.trick.playing .panel canvas, .trick.gaming .panel canvas { cursor: pointer; }
.panel figcaption {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
  margin-top: 4px;
  color: var(--muted);
}
.tag {
  font-family: "Kenney Pixel", monospace;
  font-size: 19px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.panel.off .tag { color: var(--off); }
.panel.on .tag { color: var(--accent); }
.panel code {
  font: 11.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.bar button {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
  min-height: 34px;
}
.bar button:hover { background: var(--btn-hover); }
.bar button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.bar .sound { margin-left: auto; padding: 5px 9px; }
.progress {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.progress i { display: block; height: 100%; width: 0; background: var(--accent); }

.caption {
  margin: 8px 0 0;
  min-height: 4.6em;
  font-size: 15px;
}
.caption b { color: var(--accent); font-weight: 600; }
.takeaway {
  margin: 6px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  color: var(--muted);
}
.result { margin: 8px 0 0; font-size: 14.5px; }
.result:empty { display: none; }
.result .row { display: grid; grid-template-columns: 74px 1fr 64px; gap: 8px; align-items: center; margin: 3px 0; }
.result .bar-fill { height: 10px; border-radius: 3px; background: var(--off); }
.result .on .bar-fill { background: var(--accent); }

.credits { font-size: 13px; color: var(--muted); text-align: center; }
.credits a, .intro a { color: inherit; }

@media (max-width: 520px) {
  body { padding: 14px 10px 30px; }
  .intro h1 { font-size: 22px; }
  .stage { grid-template-columns: 1fr; gap: 8px; }
  .trick { padding: 12px 10px 10px; }
  .caption { min-height: 5.8em; }
}

/* Solo embed: ?trick=<id>&solo */
body.solo { max-width: none; padding: 8px; background: transparent; }
body.solo .intro, body.solo .credits { display: none; }
body.solo .trick { margin: 0; }
body.solo .trick:not(.solo-target) { display: none; }
