/* comandle web, "cowsay": a quiet terminal session in Dracula colours. Square
   tiles, monospace everywhere it matters, prose in Manrope, and an ASCII cow
   that comments on the round. One dark theme on purpose: it is a terminal.
   Fonts are self-hosted (OFL, see fonts/). */

@font-face {
  font-family: "Martian Mono";
  src: url("fonts/martian-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #1d1e26;
  --bg-2: #262733;
  --surface: #282a36;
  --edge: #353848;
  --edge-2: #50546f;
  --fg: #f8f8f2;
  --soft: #c9cce0;
  --muted: #a2a8cc;
  --comment: #6272a4;      /* decoration only: # marks, bubble lines */
  --comment-tx: #8a95c8;   /* the same hue, light enough for text (AA) */
  --dim-key: #8087ad;
  --absent: #474e6d;
  --ink: #1d1e26;
  --green: #50fa7b;
  --yellow: #f1fa8c;
  --orange: #ffb86c;
  --pink: #ff79c6;
  --purple: #bd93f9;
  --cyan: #8be9fd;
  --red: #ff6e6e;

  --mono: "Martian Mono", ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--purple); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--pink); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(189, 147, 249, .35); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------- header */

.top {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; display: block; margin-right: 2px; }
.word {
  margin: 0;
  font: 650 19px/1 var(--mono);
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
}
.caret {
  display: inline-block;
  width: .52em;
  height: .95em;
  margin-left: .12em;
  background: var(--green);
  border-radius: 1px;
  animation: blink 1.1s steps(1) infinite;
}
.day { font: 500 13px/1 var(--mono); color: var(--comment-tx); white-space: nowrap; margin-left: 2px; padding-top: 3px; }
.day.practice { color: var(--orange); }
.tools { display: flex; gap: 2px; }
.icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon svg { width: 21px; height: 21px; stroke-width: 1.7; }
.icon:hover { background: var(--bg-2); color: var(--fg); }

/* ------------------------------------------------------------- stage */

.stage {
  --t: 56px;
  --g: calc(var(--t) * .12);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 16px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "talk" "board" "side" "assist" "kb" "man";
  row-gap: 14px;
  align-items: start;
}
.aside { display: contents; }
.talk { grid-area: talk; display: flex; justify-content: flex-end; min-width: 0; position: relative; }
.board-wrap { grid-area: board; display: flex; justify-content: center; min-width: 0; }
.notes, .result { grid-area: side; min-width: 0; }
.assist { grid-area: assist; }
.kb { grid-area: kb; }
.man { grid-area: man; }

@media (max-width: 599px) {
  .top { padding: 10px 10px 2px 16px; }
  .logo { width: 28px; height: 28px; }
  .word { font-size: 17px; }
  .stage { row-gap: 10px; padding-top: 4px; }
  .key { height: 48px; }
  .kr4 .key { height: 34px; }
  .kb { gap: 6px; }
  .key.wide { font-size: 11px; }
  .comments .clue.old { cursor: pointer; }
  .comments .clue.old > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .comments .clue.old.open > span:last-child { white-space: normal; }
  .keys { display: none; }
}
@media (max-width: 599px) and (max-height: 720px) {
  .top { padding-top: 6px; }
  .stage { row-gap: 6px; }
  .key { height: 40px; }
  .kr4 .key { height: 28px; }
  .kb { gap: 5px; }
  .assist { min-height: 28px; }
}
@media (min-width: 600px) { .talk { flex-direction: column; align-items: center; gap: 12px; } }
@media (min-width: 960px) {
  .top { padding: 28px 32px 12px; }
  .stage {
    max-width: 1040px;
    padding: 28px 32px 24px;
    grid-template-columns: minmax(0, 400px) minmax(0, 540px);
    grid-template-areas:
      "aside board"
      "aside assist"
      "aside kb"
      "man   man";
    column-gap: clamp(48px, 7vw, 104px);
    row-gap: 18px;
    justify-content: center;
  }
  .stage.over {
    grid-template-areas:
      "aside board"
      "man   man";
  }
  .aside {
    grid-area: aside;
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-self: start;
    min-width: 0;
    padding-top: 0;
  }
  .talk { align-items: flex-start; }
}

/* ------------------------------------------------------------- the cow */

.cow {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  max-width: 100%;
  border-radius: 8px;
}
.cow-art {
  --cow-fs: 11px;
  display: block;
  white-space: pre;
  font-family: var(--mono);
  font-size: var(--cow-fs);
  font-weight: 450;
  font-stretch: 75%;
  line-height: 1.24;
  letter-spacing: 0;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  color: var(--muted);
}
@media (min-width: 600px) { .cow-art { --cow-fs: 13px; font-stretch: 87.5%; } }
@media (min-width: 960px) { .talk .cow-art { --cow-fs: 17px; font-weight: 480; } }
.cow-art span { color: var(--c); }
.cow-art .b { --c: var(--comment); }
.cow-art .t { --c: var(--fg); }
.cow-art .w { --c: var(--muted); }
.cow-art .e { --c: var(--fg); font-weight: 650; }
.cow-art .u { --c: var(--pink); }
/* runs of _ and -- keep their ASCII but draw as one solid line */
.cow-art .us, .cow-art .hy {
  color: transparent;
  text-decoration-color: var(--c);
  text-decoration-thickness: max(1px, .065em);
  text-decoration-skip-ink: none;
}
.cow-art .us { text-decoration-line: underline; }
.cow-art .hy { text-decoration-line: line-through; }
.cow-art.think .t { --c: var(--comment-tx); }
.cow-art.err .t { --c: var(--red); }
.cow-art.win .t, .cow-art.win .e { --c: var(--green); }
.cow-art.dead .t, .cow-art.dead .e { --c: var(--red); }
.cow-art.fun .t { --c: var(--cyan); }
.cow-art.warn .e { --c: var(--orange); }
.cow:hover .cow-art .w { --c: var(--soft); }

.buddy-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 7px 5px 10px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--bg);
  font: 500 12px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.buddy-chip svg { width: 14px; height: 14px; }
.buddy-chip:hover { color: var(--fg); border-color: var(--edge-2); }
.buddy-chip.inline { padding: 3px 5px 3px 8px; margin-left: 2px; vertical-align: 1px; font-size: 11.5px; }
@media (max-width: 599px) {
  .talk .buddy-chip { position: absolute; left: 0; bottom: 3px; }
  .talk.face-only .buddy-chip { display: none; }
}

/* the buddy picker */
.bud-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 3px 3px 8px;
  margin: 0 -3px;
}
.bud-opt {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: end;
  gap: 10px;
  min-width: 0;
  padding: 14px 4px 11px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.bud-opt:hover { background: var(--bg-2); }
.bud-opt:has(input:checked) { border-color: var(--purple); background: rgba(189, 147, 249, .08); }
.bud-opt:has(input:focus-visible) { outline: 2px solid var(--purple); outline-offset: 2px; }
.bud-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.cow-art.bud-art { --cow-fs: 8.5px; font-stretch: 75%; }
.bud-name { font: 500 11.5px/1.25 var(--mono); color: var(--muted); text-align: center; }
.bud-opt:has(input:checked) .bud-name { color: var(--fg); }
@media (min-width: 600px) {
  .bud-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cow-art.bud-art { --cow-fs: 10px; }
}

/* ------------------------------------------------------------- board */

.board { display: grid; gap: var(--g); }
.row { display: grid; grid-template-columns: repeat(var(--len, 5), var(--t)); gap: var(--g); }
.cell {
  --tile-bg: transparent;
  --tile-fg: var(--fg);
  width: var(--t);
  height: var(--t);
  display: grid;
  place-items: center;
  position: relative;
  border: 1.5px solid var(--edge);
  border-radius: calc(var(--t) * .14);
  font: 600 calc(var(--t) * .44)/1 var(--mono);
  color: var(--fg);
  user-select: none;
}
.cell.typed { border-color: var(--edge-2); }
.cell.active { border-color: #444862; }
.cell.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 24%;
  width: 36%;
  height: 3px;
  margin-left: -18%;
  border-radius: 2px;
  background: var(--purple);
  animation: blink 1.1s steps(1) infinite;
}
.cell.c0, .cell.c1, .cell.c2 { background: var(--tile-bg); border-color: var(--tile-bg); color: var(--tile-fg); }
.cell.c2 { --tile-bg: var(--green); --tile-fg: var(--ink); }
.cell.c1 { --tile-bg: var(--yellow); --tile-fg: var(--ink); }
.cell.c0 { --tile-bg: var(--absent); --tile-fg: #e4e6f3; }
.cell.pop { animation: pop .14s var(--ease); }
.cell.rev { animation: flip .56s ease-in-out var(--d, 0ms) backwards; }
.cell.hop { animation: hop .52s var(--ease) var(--wd, 0ms); }
.row.shake { animation: shake .36s ease-in-out; }

/* ------------------------------------------------------------- clues: # comments */

.comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.comments li { display: grid; grid-template-columns: 1.5em minmax(0, 1fr); align-items: baseline; }
.hash { font: 500 13px/1 var(--mono); color: var(--comment); }
.comments .meta, .comments .lock { font: 450 12.5px/1.5 var(--mono); color: var(--comment-tx); }
.comments .meta b { font-weight: 600; color: var(--muted); }
.comments .clue { font: 500 14.5px/1.5 var(--sans); color: var(--soft); text-wrap: pretty; }
.comments .clue b { font: 600 11.5px/1 var(--mono); color: var(--purple); margin-right: .5em; }
.comments .fresh { animation: rise .5s var(--ease); }
@media (min-width: 960px) {
  .comments { gap: 10px; }
  .comments .clue { font-size: 15px; }
}

/* ------------------------------------------------------------- assist row */

.assist {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}
.sug-list { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.sug {
  flex: none;
  border: 1px solid transparent;
  background: var(--bg-2);
  border-radius: 7px;
  padding: 6px 10px;
  font: 450 13px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
}
.sug b { font-weight: 600; color: var(--fg); }
.sug.sel { border-color: var(--purple); color: var(--fg); }
.sug:hover { color: var(--fg); }
.sug-hint { font: 450 12px/1 var(--mono); color: var(--comment-tx); white-space: nowrap; }
.tab-hint { font: 450 12px/1 var(--mono); color: var(--comment-tx); white-space: nowrap; }
.tab-hint kbd { margin-right: 6px; }
.words-open {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 7px 4px 7px 8px;
  border-radius: 8px;
  font: 450 12.5px/1 var(--mono);
  color: var(--comment-tx);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.words-open svg { width: 15px; height: 15px; }
.words-open:hover { color: var(--fg); background: var(--bg-2); }
.words-open b { color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------- keyboard */

.kb { display: grid; gap: 7px; width: 100%; max-width: 540px; justify-self: center; user-select: none; }
.kr { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1 1 0;
  min-width: 0;
  max-width: 50px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #2c2e3c;
  color: var(--fg);
  font: 500 15px/1 var(--mono);
  cursor: pointer;
  touch-action: manipulation;
  transition: background .12s, color .12s, transform .08s;
}
.key:hover { background: #353849; }
.key.down, .key:active { transform: translateY(1px) scale(.97); }
.kr2 { padding: 0 calc((100% - 9 * 6px) / 10 / 2); }
.kr2 .key { max-width: 50px; }
.key.wide { flex: 1.55 1 0; max-width: 78px; font-size: 12px; font-stretch: 85%; }
.key.enter { background: var(--purple); color: var(--ink); font-weight: 650; }
.key.enter:hover { background: #cba8fb; }
.key.bksp svg { width: 22px; height: 22px; }
.kr4 .key { height: 38px; font-size: 13px; background: var(--bg-2); color: var(--muted); }
.kr4 .key:hover { color: var(--fg); }
.key.c2 { background: var(--green); color: var(--ink); }
.key.c1 { background: var(--yellow); color: var(--ink); }
.key.c0 { background: transparent; color: var(--dim-key); box-shadow: inset 0 0 0 1px var(--edge); }
.key:disabled { cursor: default; opacity: .5; }

/* ------------------------------------------------------------- result (round over) */

.stage.over .assist, .stage.over .kb { display: none; }
.result.in { animation: rise .5s var(--ease) .15s backwards; }

.result { display: grid; gap: 16px; align-content: start; }
.res-top { display: flex; align-items: center; gap: 18px; }
.mini { display: grid; grid-template-columns: repeat(var(--len, 5), 11px); gap: 3px; flex: none; }
.mini i { width: 11px; height: 11px; border-radius: 2.5px; background: var(--absent); }
.mini i.c1 { background: var(--yellow); }
.mini i.c2 { background: var(--green); }
.res-score { display: grid; gap: 4px; }
.res-score b { font: 650 30px/1 var(--mono); letter-spacing: -.02em; }
.res-score span { font: 450 12px/1.3 var(--mono); color: var(--comment-tx); }
.res-score span b { font: 600 15px/1 var(--mono); color: var(--fg); letter-spacing: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  border: 1px solid var(--edge-2);
  background: none;
  color: var(--fg);
  border-radius: 9px;
  padding: 11px 16px;
  font: 550 13px/1 var(--mono);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--bg-2); }
.btn.primary { background: var(--purple); border-color: var(--purple); color: var(--ink); }
.btn.primary:hover { background: #cba8fb; }
.btn.wide { width: 100%; padding: 14px; font-size: 14px; }
.count { margin: 0; font: 450 12.5px/1.4 var(--mono); color: var(--comment-tx); }
.count time { color: var(--fg); font-variant-numeric: tabular-nums; }
.share-text {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-2);
  font: 450 12px/1.5 var(--mono);
  white-space: pre-wrap;
  user-select: all;
}

/* ------------------------------------------------------------- man page */

.man { width: 100%; min-width: 0; max-width: 700px; justify-self: center; margin-top: 18px; }
.man-prompt { margin: 0 0 14px; font: 450 13px/1 var(--mono); color: var(--comment-tx); }
.man-prompt .p { color: var(--pink); }
.man-prompt b { color: var(--fg); font-weight: 500; }
.man-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--edge);
  font: 450 11.5px/1 var(--mono);
  color: var(--comment-tx);
}
.man-head span { white-space: nowrap; }
@media (max-width: 599px) { .man-head span:nth-child(2) { display: none; } }
.man-title { margin: 22px 0 6px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; }
.man-title .id { font: 650 clamp(34px, 8vw, 46px)/1 var(--mono); letter-spacing: -.03em; color: var(--fg); }
.man-title .tags { font: 450 12.5px/1 var(--mono); color: var(--comment-tx); }
.man-title .tags b { color: var(--cyan); font-weight: 500; }
.summary { margin: 14px 0 0; font: 600 18px/1.45 var(--sans); color: var(--fg); text-wrap: pretty; }
.explain { margin: 12px 0 0; font: 400 15px/1.7 var(--sans); color: var(--soft); text-wrap: pretty; }
.sec-h { margin: 30px 0 12px; font: 600 11.5px/1 var(--mono); letter-spacing: .14em; color: var(--fg); }
.ex { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.ex li { min-width: 0; }
.ex p { margin: 6px 0 0 2px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.code {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  border-radius: 9px;
  background: var(--bg-2);
  min-width: 0;
}
.code code {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  font: 450 13px/1.5 var(--mono);
  color: var(--fg);
  overflow-x: auto;
  white-space: pre;
  scrollbar-width: none;
}
.code code::-webkit-scrollbar { display: none; }
.code .p { color: var(--pink); }
.code .c { color: var(--green); }
.code .f { color: var(--orange); }
.code .s { color: var(--yellow); }
.copy {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 32px;
  justify-content: center;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--comment-tx);
  font: 500 11.5px/1 var(--mono);
  cursor: pointer;
}
.copy svg { width: 15px; height: 15px; }
.copy:hover { color: var(--fg); background: rgba(255, 255, 255, .05); }
.copy.done { color: var(--green); }
.copy span:empty { display: none; }
.hazard { margin: 0; font-size: 15px; line-height: 1.65; color: var(--soft); text-wrap: pretty; }
.sec-h.warn { color: var(--orange); }
.lab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font: 500 13px/1.4 var(--mono);
}
.lab svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------- footer */

.foot {
  width: 100%;
  max-width: 1040px;
  margin: auto auto 0;
  padding: 36px 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font: 450 11.5px/1.5 var(--mono);
  color: var(--comment-tx);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--fg); }
.sound-btn {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--comment-tx);
  cursor: pointer;
}
.sound-btn b { font-weight: 600; color: var(--muted); }
.sound-btn[aria-pressed="true"] b { color: var(--green); }
.sound-btn:hover { color: var(--fg); }
@media (min-width: 960px) { .foot { padding-left: 32px; padding-right: 32px; } }

/* ------------------------------------------------------------- list sheet */

.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(12, 12, 17, .55); animation: fade .2s ease; }
.sheet {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 62vh;
  max-height: 62dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--edge);
  border-radius: 18px 18px 0 0;
  padding: 0 16px max(14px, env(safe-area-inset-bottom));
  visibility: hidden;
  transform: translateY(102%);
  transition: transform .3s var(--ease), visibility 0s linear .3s;
}
.sheet.open { visibility: visible; transform: none; transition: transform .3s var(--ease), visibility 0s; }
.sheet-grip { width: 36px; height: 4px; border-radius: 2px; background: var(--edge-2); margin: 8px auto 2px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 6px 0 4px; }
.sheet-head h2 { margin: 0; font: 600 14px/1.2 var(--mono); }
.words-count { font: 450 12.5px/1 var(--mono); color: var(--comment-tx); }
.sheet-head .x { margin-left: auto; margin-right: -8px; }
.sheet-hint { margin: 0 0 10px; font: 450 12px/1.4 var(--mono); color: var(--comment-tx); }
.words-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--len, 5) * 9px + 28px), 1fr));
  gap: 2px;
  margin: 0 -6px;
  padding-bottom: 6px;
}
.wchip {
  border: 0;
  background: none;
  border-radius: 7px;
  padding: 9px 8px;
  text-align: left;
  font: 450 14px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
}
.wchip b { font-weight: 650; color: var(--pink); }
.wchip:hover { background: var(--bg-2); color: var(--fg); }
.words-empty { grid-column: 1 / -1; margin: 6px 8px; font: 450 13px/1.5 var(--mono); color: var(--comment-tx); }
@media (min-width: 600px) {
  .sheet {
    top: 0;
    left: auto;
    width: 380px;
    max-height: none;
    border-top: 0;
    border-left: 1px solid var(--edge);
    border-radius: 0;
    padding: 18px 22px 18px;
    transform: translateX(102%);
  }
  .sheet-grip { display: none; }
}

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--fg);
  color: var(--ink);
  font: 500 13px/1.4 var(--mono);
  pointer-events: none;
}
.toast:empty { display: none; }

/* ------------------------------------------------------------- dialogs */

dialog {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 20px 22px 22px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--surface);
  color: var(--fg);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.wide { width: min(720px, calc(100vw - 24px)); }
dialog[open] { animation: rise .26s var(--ease); }
dialog::backdrop { background: rgba(12, 12, 17, .7); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 10px 0; }
.dlg-head h2 { margin: 0; font: 600 15px/1 var(--mono); }
.dlg-head h2::before { content: "$ "; color: var(--pink); }
.dlg-head form { margin: 0; }

#help .cow-art.small { --cow-fs: 11px; margin: 4px 0 18px; }
.tut { display: flex; gap: 6px; margin-bottom: 16px; --t: 46px; }
.tut .cell { animation: flip .56s ease-in-out var(--d, 0ms) backwards; }
.legend { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font: 450 13px/1.2 var(--mono); color: var(--soft); }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.sw.c2 { background: var(--green); }
.sw.c1 { background: var(--yellow); }
.sw.c0 { background: var(--absent); }
.facts { margin-bottom: 16px; }
.facts li span:last-child { font: 450 13px/1.5 var(--mono); color: var(--comment-tx); }
.keys { margin: 0 0 20px; font: 450 12.5px/2 var(--mono); color: var(--muted); }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 3px 7px;
  margin-right: 4px;
  border: 1px solid var(--edge-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  font: 500 11.5px/1.2 var(--mono);
  color: var(--fg);
  text-align: center;
}
.keys kbd:not(:first-child) { margin-left: 12px; }
#help form:last-child { margin: 0; }

.numbers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 22px; }
.numbers div { display: grid; gap: 6px; }
.numbers b { font: 650 28px/1 var(--mono); letter-spacing: -.02em; }
.numbers span { font: 450 11px/1.2 var(--mono); color: var(--comment-tx); }
.numbers .hot b { color: var(--pink); }
#stats h3 { margin: 0 0 10px; font: 500 12px/1 var(--mono); color: var(--comment-tx); }
#stats h3 span { color: var(--comment); }
.history { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 22px; }
.history i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font: 600 12px/1 var(--mono);
  font-style: normal;
  background: var(--green);
  color: var(--ink);
}
.history i.x { background: var(--absent); color: #e4e6f3; }
.history .empty { font: 450 12.5px/1.4 var(--mono); color: var(--comment-tx); }
.dist { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 16px 1fr; align-items: center; gap: 8px; font: 500 12px/1 var(--mono); color: var(--muted); }
.bar i {
  width: 8%;
  min-width: 26px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--absent);
  color: #e4e6f3;
  font-style: normal;
  text-align: right;
  transition: width .6s var(--ease);
}
.bar i.lit { background: var(--purple); color: var(--ink); }

.arch-note { margin: 4px 0; font: 450 13px/1.5 var(--mono); color: var(--comment-tx); }
.arch-list { list-style: none; margin: 0; padding: 0; display: grid; }
.arch-card {
  width: 100%;
  display: grid;
  grid-template-columns: 3.4em 1fr auto;
  align-items: baseline;
  gap: 12px;
  padding: 12px 10px;
  border: 0;
  border-bottom: 1px solid var(--edge);
  background: none;
  text-align: left;
  cursor: pointer;
}
.arch-card:hover { background: var(--bg-2); }
.arch-card .n { font: 450 12px/1 var(--mono); color: var(--comment-tx); }
.arch-card .id { font: 600 15px/1 var(--mono); }
.arch-card .tags { font: 450 12px/1 var(--mono); color: var(--comment-tx); }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  margin: 0 0 6px -6px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: 500 12.5px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
}
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--fg); background: var(--bg-2); }
dialog .man { margin-top: 6px; }

/* ------------------------------------------------------------- failed load */

.stage.failed .board-wrap, .stage.failed .assist, .stage.failed .kb { display: none; }

/* ------------------------------------------------------------- burst */

.burst { position: fixed; inset: 0; z-index: 25; pointer-events: none; }

/* ------------------------------------------------------------- motion */

@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.86); } 60% { transform: scale(1.05); } 100% { transform: none; } }
@keyframes flip {
  0%, 49.9% { background: transparent; border-color: var(--edge-2); color: var(--fg); }
  0% { transform: perspective(500px) rotateX(0); }
  50% { transform: perspective(500px) rotateX(90deg); background: var(--tile-bg); border-color: var(--tile-bg); color: var(--tile-fg); }
  100% { transform: perspective(500px) rotateX(0); background: var(--tile-bg); border-color: var(--tile-bg); color: var(--tile-fg); }
}
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-24%); } 70% { transform: translateY(4%); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
