@font-face {
  font-family: "KenneyPixel";
  src: url("assets/fonts/KenneyPixel.ttf") format("truetype");
  font-display: block;
}
@font-face {
  font-family: "KenneyMini";
  src: url("assets/fonts/KenneyMiniSquare.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #2b2230;
  --muted: #6b6270;
  --paper: #fbf7ef;
  --card: #ffffff;
  --line: #e6dccb;
  --without: #b8402a;
  --without-bg: #fbe7e1;
  --with: #2f7d3a;
  --with-bg: #e3f3e2;
  --accent: #e7a33e;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 12px 40px;
}

h1, h2 {
  font-family: "KenneyMini", system-ui, sans-serif;
  font-weight: normal;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
h1 { font-size: 28px; margin: 0 0 10px; }
.intro p { margin: 0 0 8px; color: var(--muted); }
.outro { margin-top: 28px; font-size: 14px; color: var(--muted); }
a { color: #8a4b12; }

.chip {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  line-height: 20px;
  vertical-align: 1px;
}
.chip-without { background: var(--without-bg); color: var(--without); }
.chip-with { background: var(--with-bg); color: var(--with); }

/* ---------- one trick ---------- */
.trick {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin: 18px 0;
  box-shadow: 0 1px 0 rgba(60, 40, 20, 0.04);
}
.trick.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }

.trick-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.trick-num {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font: 18px/30px "KenneyMini", system-ui, sans-serif;
  text-align: center;
}
.trick-head h2 { font-size: 20px; margin: 2px 0 4px; }
.trick-head .rule { margin: 0; font-size: 14.5px; color: var(--muted); }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.side { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  margin-bottom: 6px;
}

.stage {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #6ab04c;
  aspect-ratio: 16 / 10;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.2s;
  touch-action: manipulation;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.stage.playing { outline-color: var(--accent); cursor: pointer; }
.stage:focus-visible { outline-color: #3a6bd6; }

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.bubble {
  position: absolute;
  left: 0; top: 0;
  max-width: 72%;
  width: max-content;
  padding: 4px 7px 5px;
  background: #fffdf7;
  color: var(--ink);
  border: 2px solid #3e2b3a;
  border-radius: 6px;
  font: 17px/0.95 "KenneyPixel", monospace;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
  animation: pop 0.18s ease-out;
}
.bubble b { display: block; font-weight: normal; color: #b05a1c; font-size: 14px; margin-bottom: 1px; }
.bubble::after {
  content: "";
  position: absolute;
  left: var(--tail, 50%);
  bottom: -7px;
  width: 8px; height: 8px;
  margin-left: -5px;
  background: #fffdf7;
  border-right: 2px solid #3e2b3a;
  border-bottom: 2px solid #3e2b3a;
  transform: rotate(45deg);
}
.bubble.below::after { bottom: auto; top: -7px; transform: rotate(225deg); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }

.banner {
  position: absolute;
  left: 50%; top: 8px;
  transform: translateX(-50%);
  padding: 3px 10px 4px;
  background: rgba(43, 34, 48, 0.88);
  color: #ffe9a8;
  border-radius: 4px;
  font: 18px/1 "KenneyPixel", monospace;
  white-space: nowrap;
  animation: drop 0.25s ease-out;
}
@keyframes drop { from { transform: translate(-50%, -12px); opacity: 0; } }

.try {
  border: 1px solid #cdbfa9;
  border-radius: 6px;
  padding: 4px 10px;
  background: #fff8ea;
  color: var(--ink);
  font: 600 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
}
.try:hover { background: #ffefcf; }
.side.is-playing .try { background: var(--ink); color: #fff; border-color: var(--ink); }
.try:focus-visible, .replay:focus-visible { outline: 2px solid #3a6bd6; outline-offset: 2px; }

/* ---------- quest tracker (HUD) ---------- */
.tracker {
  margin-top: 6px;
  padding: 6px 8px 6px;
  background: #2b2230;
  color: #f3eadb;
  border-radius: 6px;
  min-height: 70px;
  font-size: 13px;
  line-height: 1.3;
}
.tracker.ping { animation: ping 0.6s ease-out; }
@keyframes ping { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }
.trk-title { font: 15px/1.1 "KenneyPixel", monospace; color: #e7a33e; letter-spacing: 0.04em; text-transform: uppercase; }
.trk-line { font-weight: 650; margin-top: 2px; }
.trk-line.mood { font-style: italic; font-weight: 400; color: #cfc4d8; }
.trk-line.done { text-decoration: line-through; color: #9a8fa3; font-weight: 400; }
.trk-tick { color: #7fd68a; font-weight: 700; text-decoration: none; display: inline-block; margin-right: 4px; }
.trk-sub { margin-top: 2px; font-size: 12px; color: #b9aec4; }
.trk-reward { margin-top: 2px; color: #ffe08a; font-weight: 650; }
.trk-empty { color: #8d8296; font-style: italic; padding-top: 2px; }

/* ---------- caption ---------- */
.caption {
  display: grid;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.4;
}
.caption p {
  grid-area: 1 / 1;
  margin: 0;
  opacity: 0;
  transition: opacity 0.25s;
}
.caption p.on { opacity: 1; }
.caption p.free { font-weight: 600; }
.caption .step {
  display: inline-block;
  min-width: 18px;
  margin-right: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.trick-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.replay {
  border: 1px solid #cdbfa9;
  background: #fff8ea;
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 12px;
  font: 600 14px/1 system-ui, sans-serif;
  cursor: pointer;
}
.replay:hover { background: #ffefcf; }
.trick-foot .hint { font-size: 13px; color: var(--muted); flex: 1 1 260px; }

.noscript { text-align: center; color: var(--muted); }

/* ---------- solo / embed ---------- */
body.solo { background: transparent; }
body.solo .page { padding: 0; max-width: none; }
body.solo .intro, body.solo .outro { display: none; }
body.solo .trick { margin: 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 560px) {
  .page { padding: 16px 10px 32px; }
  h1 { font-size: 23px; }
  .pair { grid-template-columns: 1fr; gap: 16px; }
  .trick { padding: 12px 10px 10px; }
  .trick-head h2 { font-size: 18px; }
  .tracker { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .banner, .tracker.ping, .trick.flash { animation: none; }
}
