/* =========================================================================
   The puzzle-maker's desk
   Blue construction paper, copier-white sheets with hand-cut edges,
   ruled index cards, highlighter marks, typewriter labels.
   The one loud element: the site name set in cut-paper crossword squares.
   ========================================================================= */

:root {
  /* Surfaces */
  --desk: #3d5588;            /* blue construction paper */
  --desk-ink: #f2f5fb;        /* text that sits directly on the desk */
  --desk-ink-soft: #b9c6e2;
  --sheet: #fdfdfb;           /* copier paper */
  --sheet-shade: #ecebe6;     /* second sheet underneath */
  --rule: #c3d3ec;            /* index-card ruling */
  --margin-rule: #e58a94;     /* index-card red margin */

  /* Ink */
  --ink: #1c1c1e;
  --ink-soft: #5b5d66;

  /* Marks */
  --hl-yellow: #ffe45c;
  --hl-pink: #ffc6df;
  --hl-pink-faint: #ffe6f1;
  --alert: #d93a2e;
  --ok: #1d7f55;
  --revealed: #2f5fd0;

  /* Actions */
  --action: #1c1c1e;
  --action-ink: #fdfdfb;

  /* Grid */
  --cell: #ffffff;
  --cell-black: #1c1c1e;
  --grid-line: #1c1c1e;
  --circle: #7a7c84;

  /* Paper lying on the desk: short, directional, a little blur */
  --lift: drop-shadow(1px 2px 0 rgb(12 22 54 / 0.22)) drop-shadow(1px 4px 5px rgb(12 22 54 / 0.22));
  --lift-small: drop-shadow(0 1px 0 rgb(12 22 54 / 0.25)) drop-shadow(0 2px 2px rgb(12 22 54 / 0.15));

  --cut-a: polygon(0% 0.45%, 7.98% 0.19%, 13.71% 0.21%, 21.49% 0.15%, 29.08% 0.23%, 35.8% 0.17%, 43.13% 0.29%, 49.48% 0.11%, 57.56% 0.18%, 63.39% 0.17%, 71.36% 0.38%, 79.19% 0.34%, 85.74% 0.38%, 93.23% 0.13%, 99.93% 0%, 99.63% 7.96%, 99.89% 13.96%, 99.7% 21.09%, 99.69% 28.17%, 99.94% 35.3%, 99.61% 42.97%, 99.79% 50.76%, 99.6% 56.69%, 99.95% 64.3%, 99.93% 70.81%, 99.63% 77.68%, 99.88% 85.4%, 99.85% 93.71%, 100% 99.99%, 92.19% 99.92%, 85.28% 99.88%, 78.42% 99.85%, 71.49% 99.9%, 63.75% 99.63%, 57.06% 99.67%, 50.27% 99.88%, 42.89% 100%, 36.09% 99.6%, 28.36% 99.81%, 20.93% 99.92%, 13.99% 99.85%, 6.93% 99.73%, 0.34% 100%, 0.35% 93.5%, 0.38% 85.53%, 0.31% 77.73%, 0.45% 70.87%, 0.12% 63.57%, 0.04% 57.33%, 0.33% 50.84%, 0.35% 43.64%, 0.35% 36.53%, 0.24% 28.12%, 0.44% 20.93%, 0.38% 13.29%, 0.11% 6.61%);
  --cut-b: polygon(0% 0.19%, 8.31% 0.15%, 16.14% 0.31%, 24.47% 0.1%, 34.12% 0.31%, 41.65% 0.4%, 50.83% 0.11%, 59.18% 0.38%, 67.47% 0.25%, 75.94% 0.05%, 83.69% 0.19%, 91.11% 0.23%, 99.95% 0%, 99.64% 6.79%, 99.84% 12.93%, 100% 17.82%, 99.69% 25.84%, 99.7% 31.63%, 99.69% 36.57%, 99.69% 44.47%, 99.61% 50.91%, 99.79% 56.09%, 99.8% 62.96%, 99.69% 68.55%, 99.79% 74.81%, 99.69% 81.37%, 99.88% 87.74%, 99.81% 93.42%, 100% 99.82%, 91.51% 99.76%, 82.96% 99.61%, 75.99% 99.89%, 67.41% 99.67%, 57.73% 99.88%, 49.27% 100%, 41.78% 99.78%, 34.22% 99.99%, 24.37% 99.96%, 16% 99.87%, 8.38% 99.95%, 0.01% 100%, 0.21% 93.47%, 0.2% 86.55%, 0.16% 81.33%, 0.24% 75.45%, 0.17% 68.22%, 0.13% 62.36%, 0.34% 56.8%, 0.26% 50.83%, 0.33% 44.11%, 0.37% 36.55%, 0.21% 31.45%, 0.18% 25.8%, 0.37% 18.02%, 0.34% 11.72%, 0.33% 5.27%);
  --cut-tile: polygon(0% 0.46%, 25.89% 1.36%, 49.27% 1.31%, 75.35% 1.13%, 99.81% 0%, 97.83% 24.85%, 99.24% 50.55%, 99.55% 74.83%, 100% 98.07%, 74.46% 98.65%, 50.95% 98.47%, 25.85% 99.96%, 1.66% 100%, 1.28% 75.21%, 1.45% 49.16%, 1% 25.29%);

  --font-text: 'Atkinson Hyperlegible', 'Verdana', sans-serif;
  --font-type: 'Courier Prime', 'Courier New', monospace;
  --line: 28px;               /* index-card ruling pitch */
  --kb-h: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #121a2e;
    --desk-ink: #dfe5f3;
    --desk-ink-soft: #8d9ab8;
    --sheet: #24262c;
    --sheet-shade: #1b1d22;
    --rule: #333f58;
    --margin-rule: #7d3d48;
    --ink: #eeede9;
    --ink-soft: #a5a8b1;
    --hl-yellow: #6b5f17;
    --hl-pink: #6a2f4c;
    --hl-pink-faint: #3a2530;
    --alert: #ff7b6e;
    --ok: #6fd3a2;
    --revealed: #86a8ff;
    --action: #eeede9;
    --action-ink: #1c1c1e;
    --cell: #2c2e35;
    --cell-black: #0b0c0e;
    --grid-line: #5d6070;
    --circle: #8e919b;
    --lift: drop-shadow(1px 2px 0 rgb(0 0 0 / 0.45)) drop-shadow(1px 4px 6px rgb(0 0 0 / 0.4));
    --lift-small: drop-shadow(0 1px 0 rgb(0 0 0 / 0.5)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.3));
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--desk);
  /* faint construction-paper fibres */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.02 .3' numOctaves='2' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
  color: var(--ink);
  font: 17px/1.5 var(--font-text);
}
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); }
.tw { font-family: var(--font-type); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Sheets of paper ----------
   The element itself is transparent; ::before is the paper, cut with a
   ragged clip-path. The drop-shadow filter sits on the element so the shadow
   follows the cut edge. (filter also makes the element a stacking context,
   which keeps the z-index:-1 paper inside it.) */
.sheet, .board, .clues section, .toolbar, .clue-bar, .panel, .pending-card,
.table-wrap, .dropzone, .notes, .empty, .index-card, .menu-list {
  position: relative;
  filter: var(--lift);
}
.sheet::before, .board::before, .clues section::before, .toolbar::before, .clue-bar::before,
.panel::before, .pending-card::before, .table-wrap::before, .dropzone::before,
.notes::before, .empty::before, .index-card::before, .menu-list::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--sheet);
  clip-path: var(--cut-a);
}
.clues section:nth-child(2)::before, .pending-card:nth-child(even)::before, .panel::before { clip-path: var(--cut-b); }

/* Ruled index card with a red margin line */
.index-card::before, .clues section::before {
  background:
    linear-gradient(90deg, transparent 46px, var(--margin-rule) 46px 48px, transparent 48px),
    var(--sheet);
}
.ruled {
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px));
  background-size: 100% var(--line);
  background-attachment: local;
  line-height: var(--line);
}

/* A staple, for pinning a sheet */
.staple {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 46px;
  height: 7px;
  transform: translateX(-50%) rotate(-4deg);
  border-radius: 2px;
  background: linear-gradient(to bottom, #e3e6ec, #9ea4b0 60%, #7c828e);
  box-shadow: 0 1px 1px rgb(0 0 0 / 0.35);
}

/* Masking tape */
.tape {
  position: absolute;
  top: -11px;
  left: 50%;
  width: 92px;
  height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgb(236 222 186 / 0.85);
  clip-path: polygon(0 6%, 3% 0, 6% 9%, 9% 0, 91% 0, 94% 9%, 97% 0, 100% 6%, 100% 94%, 97% 100%, 94% 91%, 91% 100%, 9% 100%, 6% 91%, 3% 100%, 0 94%);
  pointer-events: none;
  z-index: 3;
}

/* ---------- Crossword-square tiles (the site name) ---------- */

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.09em 0.07em;
  margin: 0;
  font-size: clamp(24px, 8vw, 64px);
  line-height: 1;
}
.tile-word { display: flex; gap: 0.07em; }
.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 1em;
  height: 1em;
  filter: var(--lift-small);
  color: var(--ink);
  font: 700 0.6em/1 var(--font-text);
  text-transform: uppercase;
}
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--sheet);
  clip-path: var(--cut-tile);
}
.tile.block::before { background: var(--cell-black); }
.tile.cursor::before { background: var(--hl-yellow); }
.tile .n { position: absolute; top: 0.12em; left: 0.16em; font-size: 0.3em; font-weight: 700; }
.tile:nth-child(3n + 1) { rotate: -2.5deg; }
.tile:nth-child(3n + 2) { rotate: 1.5deg; translate: 0 0.03em; }
.tile:nth-child(4n) { rotate: 3deg; }
.tiles.small { font-size: 26px; gap: 2px; }
.tiles.small .tile-word { gap: 2px; }

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 0;
}
.brand { display: block; text-decoration: none; }
.site-header nav { display: flex; align-items: center; gap: 18px; }
.site-header nav a {
  color: var(--desk-ink);
  font: 700 15px var(--font-type);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: var(--desk-ink-soft);
}
.site-header nav a:hover { text-decoration-color: var(--hl-yellow); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 16px 80px; }

/* ---------- Buttons: little paper tabs with typed labels ---------- */

.btn {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--sheet);
  color: var(--ink);
  font: 700 15px/1 var(--font-type);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s;
  box-shadow: 2px 2px 0 var(--ink);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--hl-yellow); outline-offset: 2px; }
.btn.primary { background: var(--action); color: var(--action-ink); }
.btn.danger { color: var(--alert); border-color: var(--alert); box-shadow: 2px 2px 0 var(--alert); }
.btn.ghost { border-color: transparent; box-shadow: none; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:hover { transform: none; color: var(--ink); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.on { background: var(--hl-yellow); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn svg { fill: currentColor; }
.site-header .btn { border-color: var(--desk-ink); color: var(--desk-ink); background: transparent; box-shadow: 2px 2px 0 var(--desk-ink-soft); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); background: var(--hl-yellow); }
.caret { font-size: 11px; }
.menu-list {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 40;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  rotate: -1deg;
}
.menu-list.right { left: auto; right: 0; rotate: 1deg; }
.menu-list button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  padding: 8px 12px;
  font: 700 15px var(--font-type);
  cursor: pointer;
}
.menu-list button:hover { background: var(--hl-yellow); }

/* ---------- Home ---------- */

.masthead { margin: 26px 0 34px; }
.tagline {
  max-width: 52ch;
  margin: 18px 0 0;
  color: var(--desk-ink);
  font: 400 1.15rem/1.45 var(--font-type);
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 34px;
  align-items: start;
}

.latest {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 28px;
  align-items: center;
  padding: 44px 34px 34px;
  color: var(--ink);
  text-decoration: none;
  rotate: -0.8deg;
  transition: rotate 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.latest:hover { rotate: 0deg; }
/* a second sheet peeking out underneath */
.latest::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--sheet-shade);
  clip-path: var(--cut-b);
  transform: rotate(2.2deg) translate(6px, 8px);
}
.mini-grid { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; }
@media (max-width: 640px) { .mini-grid { max-width: 220px; margin: 0; } }
.mini-grid .bg { fill: var(--cell); stroke: var(--grid-line); stroke-width: 0.06; }
.mini-grid .blk { fill: var(--cell-black); }
.mini-grid .ln { stroke: var(--grid-line); stroke-width: 0.03; }
.mini-grid .c { fill: none; stroke: var(--circle); stroke-width: 0.05; }
.mini-grid .lt { font: 700 0.62px var(--font-text); fill: var(--ink); text-anchor: middle; }
.latest-label { margin: 0 0 6px; font: 700 0.95rem var(--font-type); color: var(--ink-soft); }
.latest h2 { margin: 0; font-size: clamp(1.8rem, 3.4vw, 2.6rem); line-height: 1.1; font-weight: 700; }
.latest .by { margin: 8px 0 22px; color: var(--ink-soft); font-size: 1.05rem; }
.latest .go { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.index-card { padding: 20px 18px 18px 0; rotate: 0.7deg; }
.index-card::before {
  background:
    linear-gradient(90deg, transparent 66px, var(--margin-rule) 66px 68px, transparent 68px),
    var(--sheet);
}
.index-card h2 {
  margin: 0 0 0 80px;
  height: calc(var(--line) * 1.5);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: calc(var(--line) * 1.5);
}
.puzzle-rows { margin: 0; padding: 0; list-style: none; }
.puzzle-rows li a {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
  height: var(--line);
  padding-right: 4px;
  text-decoration: none;
  white-space: nowrap;
}
.puzzle-rows .d { padding-right: 8px; text-align: right; font: 700 13px var(--font-type); color: var(--ink-soft); }
.puzzle-rows .t { overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.puzzle-rows .s { font: 700 13px var(--font-type); color: var(--ink-soft); }
.puzzle-rows .s.solved { color: var(--ok); }
.puzzle-rows li a:hover .t { background: linear-gradient(transparent 55%, var(--hl-yellow) 55% 92%, transparent 92%); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  font: 700 12px/1.4 var(--font-type);
  color: var(--ink-soft);
  white-space: nowrap;
  rotate: -2deg;
}
.badge.solved { color: var(--ok); }
.badge.progress { color: var(--ink); }

.empty { padding: 40px 32px; color: var(--ink-soft); font-family: var(--font-type); }

/* ---------- Solver ---------- */

.status { padding: 60px 0; text-align: center; color: var(--desk-ink); font-family: var(--font-type); }
.status a { color: var(--desk-ink); }

.puzzle-head { color: var(--desk-ink); }
.puzzle-head h1 { margin: 0; font-size: clamp(1.8rem, 3.6vw, 2.6rem); line-height: 1.1; font-weight: 700; }
.byline { margin: 6px 0 0; color: var(--desk-ink-soft); font-family: var(--font-type); font-weight: 700; }

.toolbar {
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 22px 0 26px;
  padding: 12px 14px;
  rotate: -0.3deg;
}
.timer-group { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.timer { font: 700 1.25rem var(--font-type); font-variant-numeric: tabular-nums; min-width: 5ch; }
.timer.done { color: var(--ok); }
#pause .i-play { display: none; }
#pause.is-paused .i-play { display: inline; }
#pause.is-paused .i-pause { display: none; }

.solved-banner {
  display: inline-block;
  margin: -8px 0 22px;
  padding: 4px 12px;
  border: 2.5px solid var(--ok);
  border-radius: 4px;
  color: var(--ok);
  background: var(--sheet);
  font: 700 1.05rem var(--font-type);
  text-transform: uppercase;
  rotate: -3deg;
}

.solve-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.95fr);
  gap: 38px;
  align-items: start;
}
.board-col { min-width: 0; }

.clue-bar {
  display: flex;
  align-items: stretch;
  min-height: 58px;
  margin-bottom: 20px;
}
.clue-bar::before { background: var(--hl-pink); clip-path: var(--cut-b); }
.clue-bar-text {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}
.cb-num { flex: none; font: 700 1.05rem var(--font-type); white-space: nowrap; }
.cb-num:empty { display: none; }
.clue-bar .nav {
  display: none;
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  font: 700 1.6rem var(--font-type);
  width: 40px;
  cursor: pointer;
}

.board { padding: 14px; }
.board::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--sheet-shade);
  clip-path: var(--cut-b);
  transform: rotate(-1.8deg) translate(-4px, 6px);
}
#grid {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 300px);
  max-height: calc(100svh - 300px);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
#grid .sq { fill: var(--cell); stroke: var(--grid-line); stroke-width: 1.6; }
#grid .sq.black { fill: var(--cell-black); cursor: default; }
#grid .sq.word { fill: var(--hl-pink); }
#grid .sq.sel { fill: var(--hl-yellow); }
#grid .frame { fill: none; stroke: var(--grid-line); stroke-width: 5; pointer-events: none; }
#grid .num { font: 700 25px var(--font-text); fill: var(--ink); pointer-events: none; }
#grid .letter { font-family: var(--font-text); font-weight: 700; fill: var(--ink); pointer-events: none; }
#grid .circle { fill: none; stroke: var(--circle); stroke-width: 2.5; pointer-events: none; }
#grid .slash, #grid .flag { display: none; pointer-events: none; }
#grid .cell.wrong .slash { display: inline; stroke: var(--alert); stroke-width: 4; stroke-linecap: round; }
#grid .cell.wrong .letter { fill: var(--alert); }
#grid .cell.revealed .flag { display: inline; fill: var(--revealed); }
#grid .cell.revealed .letter { fill: var(--revealed); }
.board.paused #grid .letter, .board.paused #grid .num { visibility: hidden; }

.rebus-input {
  position: absolute;
  z-index: 5;
  padding: 0 6px;
  border: 2.5px solid var(--ink);
  border-radius: 2px;
  background: var(--hl-yellow);
  color: var(--ink);
  font-family: var(--font-type);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.pause-overlay {
  position: absolute;
  inset: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--sheet);
}
.pause-overlay p { margin: 0; font: 700 1.6rem var(--font-type); }

.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-width: 0; }
.clues section { min-width: 0; padding: 14px 10px 14px 0; }
.clues section:nth-child(1) { rotate: 0.5deg; }
.clues section:nth-child(2) { rotate: -0.6deg; }
.clues h2 {
  margin: 0 0 0 58px;
  height: var(--line);
  font: 700 1.05rem/var(--line) var(--font-type);
}
.clues ol {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: calc(100vh - 290px);
  max-height: calc(100svh - 290px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px));
  background-size: 100% var(--line);
  background-attachment: local;
}
.clues li {
  display: flex;
  gap: 0;
  padding: 0 6px 0 0;
  line-height: var(--line);
  cursor: pointer;
}
.clues li .n {
  flex: 0 0 48px;
  padding-right: 10px;
  text-align: right;
  font: 700 15px/var(--line) var(--font-type);
}
.clues li .t { padding-left: 10px; }
.clues li:hover .t { background: linear-gradient(transparent 60%, var(--hl-yellow) 60% 90%, transparent 90%); }
.clues li.done .t { color: var(--ink-soft); text-decoration: line-through; text-decoration-thickness: 1.5px; }
/* highlighter swipes, slightly uneven like a real marker */
.clues li.active .t, .clues li.crossing .t {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  border-radius: 2px 6px 3px 5px;
}
.clues li.active .t { background: var(--hl-pink); }
.clues li.crossing .t { background: var(--hl-pink-faint); }

.notes {
  max-width: 600px;
  margin-top: 40px;
  padding: 26px 24px 20px;
  rotate: -1.2deg;
  white-space: pre-wrap;
  font-family: var(--font-type);
}
.notes::before { background: var(--hl-yellow); clip-path: var(--cut-b); }
.copyright { color: var(--desk-ink-soft); font: 13px var(--font-type); margin-top: 28px; }

/* Touch keyboard */
.keyboard {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 4px calc(10px + env(safe-area-inset-bottom));
  background: var(--desk);
  border-top: 3px solid var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.keyboard .clue-bar { margin: 0 6px 10px; min-height: 50px; }
.keyboard .clue-bar .nav { display: block; }
.kb-row { display: flex; justify-content: center; gap: 5px; margin: 0 0 7px; }
.kb-row button {
  flex: 1 1 0;
  max-width: 46px;
  height: 46px;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--sheet);
  color: var(--ink);
  font: 700 18px var(--font-text);
  box-shadow: 0 2px 0 var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.kb-row button:active { transform: translateY(2px); box-shadow: none; background: var(--hl-yellow); }
.kb-row button.wide { flex-grow: 1.6; max-width: 72px; font: 700 13px var(--font-type); }
.kb-row button.on { background: var(--hl-yellow); }
body.has-keyboard main { padding-bottom: calc(var(--kb-h) + 24px); }
body.has-keyboard #grid { max-height: calc(100svh - var(--kb-h) - 56px); }
body.has-keyboard #rebus-btn, body.has-keyboard #download { display: none; }
body.has-keyboard .board-col > .clue-bar { display: none; }

/* Toast: a torn slip of paper */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--kb-h) + 26px);
  z-index: 50;
  max-width: min(92vw, 460px);
  padding: 14px 20px;
  background: var(--sheet);
  color: var(--ink);
  font: 700 15px/1.4 var(--font-type);
  clip-path: var(--cut-b);
  filter: var(--lift);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) rotate(1deg);
  transition: opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1), transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

/* Dialogs: an index card taped to the screen */
.dialog {
  width: min(92vw, 400px);
  padding: 38px 28px 26px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  overflow: visible;
  filter: var(--lift);
}
.dialog > form { position: relative; }
.dialog::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, transparent 24px, var(--margin-rule) 24px 26px, transparent 26px),
    var(--sheet);
  clip-path: var(--cut-b);
}
.dialog::after {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  width: 92px;
  height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgb(236 222 186 / 0.9);
  clip-path: polygon(0 6%, 3% 0, 6% 9%, 9% 0, 91% 0, 94% 9%, 97% 0, 100% 6%, 100% 94%, 97% 100%, 94% 91%, 91% 100%, 9% 100%, 6% 91%, 3% 100%, 0 94%);
}
.dialog[open] { animation: settle 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes settle { from { opacity: 0; transform: translateY(-16px) rotate(-3deg); } }
.dialog::backdrop { background: rgb(12 20 44 / 0.5); }
.dialog h2 { margin: 0 0 6px; font-size: 2rem; font-weight: 700; }
.dialog p { margin: 0 0 24px; color: var(--ink-soft); font-family: var(--font-type); }
.dialog-mark {
  display: inline-block;
  margin-bottom: 14px;
  padding: 2px 12px;
  border: 3px solid var(--ok);
  border-radius: 4px;
  color: var(--ok);
  font: 700 1rem var(--font-type);
  text-transform: uppercase;
  rotate: -6deg;
}
.dialog-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.dialog.confirm p { color: var(--ink); font: 700 1.1rem/1.4 var(--font-text); margin: 0 0 24px; }
.btn.primary.danger-fill { background: var(--alert); border-color: var(--alert); color: var(--sheet); box-shadow: 2px 2px 0 var(--ink); }

/* ---------- Upload page ---------- */

.page-admin h1 { margin: 4px 0 28px; color: var(--desk-ink); font-size: 2.2rem; font-weight: 700; }
.login { max-width: 420px; margin: 40px auto; }
.panel { display: flex; flex-direction: column; gap: 10px; padding: 30px 28px; rotate: -0.8deg; }
.panel label { font: 700 0.95rem var(--font-type); }
.panel input, .date-field input {
  height: 42px;
  padding: 0 4px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 700 17px var(--font-type);
}
.panel input:focus, .date-field input:focus { outline: none; background: var(--hl-yellow); }
.form-error { color: var(--alert); margin: 0; font: 700 0.92rem var(--font-type); }
.warn { margin: 6px 0 0; font: 700 0.9rem var(--font-type); color: var(--ink); background: var(--hl-yellow); display: inline; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 34px 34px 30px;
  cursor: pointer;
  rotate: 0.4deg;
  transition: rotate 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.dropzone::after {
  content: '';
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--ink-soft);
  pointer-events: none;
}
.dropzone:hover, .dropzone.over { rotate: 0deg; }
.dropzone.over::before { background: var(--hl-yellow); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dz-title { font-size: 1.35rem; font-weight: 700; }
.dz-title::before { content: '✂  '; color: var(--ink-soft); }
.dz-sub { color: var(--ink-soft); font-family: var(--font-type); }

.pending { display: flex; flex-direction: column; gap: 18px; margin-top: 24px; }
.pending-card {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
  animation: settle 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pending-card:nth-child(odd) { rotate: -0.4deg; }
.pending-card:nth-child(even) { rotate: 0.5deg; }
.pending-card.error { grid-template-columns: minmax(0, 1fr) auto; }
.pending-card.error::before { background: var(--hl-pink); }
.thumb { width: 80px; height: 80px; background: var(--cell); border: 2px solid var(--grid-line); fill: var(--cell-black); rotate: -3deg; }
.thumb .c { fill: none; stroke: var(--circle); stroke-width: 0.08; }
.pc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-body strong { font-size: 1.25rem; }
.pc-body .muted { font-family: var(--font-type); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pc-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.pc-buttons { display: flex; gap: 10px; }
.date-field { display: flex; align-items: center; gap: 8px; font: 700 0.85rem var(--font-type); color: var(--ink-soft); }
.date-field input { height: 32px; font-size: 15px; }
.pending-actions { margin-top: 16px; display: flex; justify-content: flex-end; }

.section-title { margin: 56px 0 16px; color: var(--desk-ink); font-size: 1.4rem; font-weight: 700; }
.table-wrap { overflow-x: auto; padding: 10px 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.table th, .table td { padding: 0 12px; height: 44px; text-align: left; border-bottom: 1.5px solid var(--rule); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table th { font: 700 0.85rem var(--font-type); color: var(--ink-soft); }
.table td:first-child { font: 700 0.9rem var(--font-type); }
.table td a { font-weight: 700; text-decoration-color: var(--ink-soft); }
.table td.right { text-align: right; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .solve-layout { grid-template-columns: 1fr; gap: 30px; }
  .clues ol { max-height: none; overflow: visible; }
  .clue-bar .nav { display: block; }
  #grid { max-height: none; }
}
@media (max-width: 640px) {
  main { padding-top: 20px; }
  .latest { grid-template-columns: 1fr; padding: 38px 22px 26px; }
  .clues { grid-template-columns: 1fr; }
  .toolbar { gap: 7px; padding: 10px; }
  .toolbar .btn { padding: 0 9px; font-size: 14px; }
  .board { padding: 9px; }
  .pending-card { grid-template-columns: 60px minmax(0, 1fr); }
  .thumb { width: 60px; height: 60px; }
  .pc-actions { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.table .small-url { font-size: 12px; font-weight: 400; }
