@font-face {
  font-family: "Scapholene";
  src: url("assets/fonts/Scapholene.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3efe5;
  --card: #faf7ef;
  --ink: #45433d;
  --muted: #756e61;
  --line: #bab2a1;
  --accent: #ad5845;
  --bad: #a34449;

  --radius: 14px;
  --radius-sm: 10px;

  /* Board metrics. The row-header column is narrower than the play squares so
     the squares get the space, and the Pokemon sits small inside its square. */
  --cell: 116px;
  --head: 96px;
  --gap: 8px;
  --mon: 54px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 46px rgba(16, 24, 40, .22);
}

* { box-sizing: border-box; }

/* author display rules must not defeat the hidden attribute */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe Print", "Bradley Hand", "Chalkboard SE", cursive;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

/* ------------------------------------------------------------- topbar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 18px; font-weight: 800; letter-spacing: -.01em;
}
.ball {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  background: linear-gradient(180deg, var(--accent) 0 48%, #fff 48% 52%, #f3f5f8 52% 100%);
  border: 2px solid var(--ink); position: relative;
}
.ball::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff; border: 2px solid var(--ink);
}
.topbar-actions { display: flex; gap: 7px; align-items: center; }

.pill {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 15px; border-radius: 999px; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.pill:hover { color: var(--ink); }
.pill.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ------------------------------------------------------------ settings --- */
.settings { position: relative; }
.cog {
  display: flex; align-items: center; justify-content: center;
  width: 33px; height: 33px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--muted); cursor: pointer;
  transition: color .12s, border-color .12s;
}
.cog:hover, .cog[aria-expanded="true"] { color: var(--ink); border-color: var(--muted); }

.settings-pop {
  position: absolute; top: 42px; right: 0; z-index: 60;
  width: 212px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg);
}
.set-title {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 9px;
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative; flex: none; width: 38px; height: 22px;
  border-radius: 999px; background: var(--line); transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .15s;
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--ink); outline-offset: 2px; }
.set-note { margin: 9px 0 0; font-size: 11px; color: var(--muted); line-height: 1.45; }

/* -------------------------------------------------------------- board --- */
main { padding: 26px 16px 56px; }

.board-wrap {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 26px; flex-wrap: wrap;
}

.board {
  display: grid;
  grid-template-columns: var(--head) repeat(3, var(--cell));
  grid-template-rows: var(--head) repeat(3, var(--cell));
  gap: var(--gap);
}

/* category headers */
.cat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 4px; text-align: center; line-height: 1.15;
  overflow: hidden;
}
.cat-top {
  font-size: 9px; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
}
.cat-main {
  font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: -.01em; overflow-wrap: anywhere;
}
.cat-icon { width: 30px; height: 30px; object-fit: contain; margin-bottom: 1px; }
/* a plain type clue is shown as its icon alone, so give it the whole square */
.cat-icon-solo { width: 48px; height: 48px; object-fit: contain; }
.crit-icon-solo { width: 42px; height: 42px; object-fit: contain; }

/* inline type icon, used in search results */
.ticon { width: 16px; height: 16px; object-fit: contain; vertical-align: -3px; }
.crit-icon { width: 28px; height: 28px; object-fit: contain; margin-bottom: 3px; }

.corner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px;
}

/* play squares */
.cell {
  position: relative;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  cursor: pointer; padding: 6px 5px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  transition: box-shadow .12s, border-color .12s, transform .12s;
}
.cell:hover:not(.filled):not(.locked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(227, 53, 13, .16), var(--shadow-sm);
}
.cell.filled, .cell.locked { cursor: default; }
.cell img { width: var(--mon); height: var(--mon); object-fit: contain; }
.cell .cname {
  font-size: 9.5px; font-weight: 700; text-align: center; line-height: 1.2;
  max-width: 100%; overflow: hidden; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.cell.miss { background: #fdf0f1; border-color: #f0c8cd; }
.cell.miss .cname { color: var(--bad); }

/* a filled square you can still spend the undo on */
.cell.undoable { cursor: pointer; }
.cell.undoable:hover { box-shadow: 0 0 0 2px rgba(123, 135, 148, .35), var(--shadow-sm); }

/* a square whose free retry has been spent */
.cell.used-retry::after {
  content: ""; position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: #e78b96;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake .28s; }

/* ------------------------------------------------------------- rarity --- */
/* Tint by how many other players gave the same answer. */
.cell.tier-legendary,
.cell.tier-epic,
.cell.tier-rare,
.cell.tier-uncommon,
.cell.tier-common { border-width: 2px; }

.tier-legendary { background: #ffd873; border-color: #c08a00; }
.tier-epic      { background: #d7bdfa; border-color: #6d28d9; }
.tier-rare      { background: #a9d2fb; border-color: #1667c8; }
.tier-uncommon  { background: #98e3b0; border-color: #17833f; }
.tier-common    { background: #cfd8e5; border-color: #74839a; }

.rarity {
  position: absolute; top: 5px; left: 5px;
  font-size: 9px; font-weight: 800;
  padding: 1.5px 5px; border-radius: 6px;
  background: #fff; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .14);
}

.legend {
  display: flex; flex-wrap: wrap; gap: 7px 15px;
  justify-content: center; margin-top: 24px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-item i {
  width: 13px; height: 13px; border-radius: 3px;
  border: 1px solid; display: inline-block;
}

/* ---------------------------------------------------------- scorepanel --- */
.scorepanel { display: flex; flex-direction: column; gap: 9px; width: 166px; }

.panel-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm);
}

.guess-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.score-label {
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  color: var(--muted); text-transform: uppercase; line-height: 1.3;
}
.score-value { font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

/* nine bars, one per guess, dimming as they are spent */
.pips { display: flex; gap: 4px; margin-top: 11px; }
.pip { flex: 1; height: 5px; border-radius: 3px; background: var(--accent); }
.pip.spent { background: var(--line); }

.undo-card {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; padding: 11px 13px;
}
.undo-icon { font-size: 15px; line-height: 1; }
.undo-card.is-ready { color: var(--ink); box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm); }
.undo-card.is-spent { color: var(--muted); border-style: dashed; background: transparent; box-shadow: none; }
.undo-card.is-spent .undo-icon { opacity: .45; }

.score-sub { font-size: 11px; color: var(--muted); text-align: center; }

.ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.ghost:hover { color: var(--bad); border-color: var(--bad); }
.ghost:disabled { opacity: .4; cursor: default; }
.ghost:disabled:hover { color: var(--muted); border-color: var(--line); }
.ghost.wide { width: 100%; }

.hint { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.loading { text-align: center; padding: 80px 20px; color: var(--muted); }

/* -------------------------------------------------------------- sheet --- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 28, 38, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 14px 14px; z-index: 50;
  overflow-y: auto;
}
.sheet {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 430px;
  padding: 22px; position: relative; box-shadow: var(--shadow-lg);
}
.sheet-close {
  position: absolute; top: 8px; right: 10px; border: 0; background: none;
  width: 32px; height: 32px; font-size: 24px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.sheet-close:hover { color: var(--ink); }

.sheet-crit { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 16px; }
.crit { text-align: center; flex: 1; min-width: 0; }
.crit-top {
  display: block; font-size: 9.5px; font-weight: 700; letter-spacing: .09em;
  color: var(--muted); text-transform: uppercase;
}
.crit-main { display: block; font-size: 15px; font-weight: 800; text-transform: uppercase; overflow-wrap: anywhere; }
.crit-x { color: var(--muted); font-size: 18px; flex: none; }

.answer-count {
  text-align: center; font-size: 12px; font-weight: 600; color: var(--muted);
  margin: -6px 0 13px;
}
.sheet-miss {
  text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--bad); margin: -6px 0 12px;
}
.undo-square {
  display: block; margin: 0 auto 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
}
.undo-square:hover { color: var(--ink); border-color: var(--muted); }

#search {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 9px; outline: none;
}
#search:focus { border-color: var(--accent); }

.results { list-style: none; margin: 10px 0 0; padding: 0; max-height: 44vh; overflow-y: auto; }
.results li {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer;
}
.results li:hover, .results li.sel { background: #f1f4f9; }
.results img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.results .rname { font-size: 14px; font-weight: 600; }
.results .rmeta { font-size: 11px; color: var(--muted); }
.results .empty { color: var(--muted); font-size: 13px; padding: 10px 8px; cursor: default; }

/* --------------------------------------------------------- done sheet --- */
.sheet-done { text-align: center; max-width: 400px; }
.sheet-done h2 { margin: 4px 0 4px; font-size: 22px; }
.sheet-done p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.done-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-bottom: 16px; font-size: 11px;
}
.done-grid > button {
  background: #f1f4f9; border-radius: 8px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.done-grid img { width: 42px; height: 42px; object-fit: contain; }
.done-grid img.faded { opacity: .45; }
.done-grid .miss-txt { color: var(--muted); }
.done-score { margin: 0 0 6px; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.done-hint { font-size: 12px; color: var(--muted); margin: 0 0 14px; }

/* nearest-neighbour only where a real pixel sprite is being shown */
body.pixel-art img.poke, img.poke.is-sprite { image-rendering: pixelated; }

.sheet-confirm { text-align: center; max-width: 360px; }
.sheet-confirm h2 { margin: 4px 0 8px; font-size: 19px; }
.sheet-confirm p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .ghost, .confirm-actions .primary { flex: 1; padding: 11px 14px; }

.primary {
  border: 0; background: var(--accent); color: #fff; font: inherit;
  font-size: 14px; font-weight: 700; padding: 12px 22px;
  border-radius: 10px; cursor: pointer; width: 100%;
}
.primary:hover { filter: brightness(1.06); }

/* -------------------------------------------------------------- toast --- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px; z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100vw - 28px);
  text-align: center;
}
.toast b { color: #ffb4a6; }

/* Sketchbook finish: local paper grain, uneven pencil contours, soft pigment. */
body {
  min-height: 100vh;
  background-image: url("assets/paper-grain.svg"),
    radial-gradient(ellipse at 45% 20%, #fffdf680, transparent 75%);
}

.topbar {
  background: var(--bg) url("assets/paper-grain.svg");
  border-bottom: 1px solid #aaa18c;
  box-shadow: 0 2px 0 -1px #aaa18c40;
  padding: 14px max(24px, calc((100vw - 1000px) / 2));
}
.brand { font-size: 24px; font-weight: 700; transform: rotate(-2deg); }
.ball {
  border-radius: 48% 52% 46% 54%;
  background: linear-gradient(175deg, #ba6c57 0 46%, var(--ink) 47% 53%, #f6f0df 54%);
  box-shadow: 1px 1px 0 #45433d40;
}
.pill, .cog, .ghost, .undo-square, .primary {
  border: 1px solid #898273;
  border-radius: 5px 12px 4px 10px / 10px 4px 12px 5px;
  background-image: url("assets/paper-grain.svg");
  box-shadow: 1px 2px 0 #514a3520;
}
.pill { color: var(--ink); }
.pill.is-active {
  color: var(--accent); border-color: var(--accent); background-color: #efe1cf;
  background-image: repeating-linear-gradient(-38deg, transparent 0 4px, #ad584510 4px 5px);
  transform: rotate(-2deg);
}
.cog { border-radius: 46% 54% 48% 52%; }
.cell {
  border: 1.5px solid #8c877a;
  border-radius: 4px 8px 5px 9px / 8px 4px 9px 4px;
  background-image: url("assets/paper-grain.svg");
  box-shadow: 1px 2px 0 #61564020, inset 0 0 15px #aa926708;
}
.cell:nth-child(3n) { border-radius: 8px 4px 9px 3px / 4px 9px 3px 8px; }
.cell::before {
  content: ""; position: absolute; inset: 2px; pointer-events: none;
  border: 1px solid #655b4220; border-radius: inherit;
}
.cell:hover:not(.filled):not(.locked) {
  background-color: #f2e8d6; border-color: var(--accent);
  box-shadow: 1px 2px 0 #ad584535; transform: translateY(-2px);
}
.cat-main, .crit-main { font-weight: 700; }
.cat-icon, .cat-icon-solo, .crit-icon, .crit-icon-solo { filter: saturate(.7); }
.panel-card, .settings-pop, .sheet {
  background-image: url("assets/paper-grain.svg");
  border: 1px solid #a59a83;
  border-radius: 3px 7px 4px 9px / 8px 3px 8px 4px;
  box-shadow: 2px 3px 0 #675b3c13, 0 8px 18px #675b3c09;
}
.scorepanel { padding-top: 12px; }
.guess-card { position: relative; padding-top: 19px; transform: rotate(1deg); }
.guess-card::before {
  content: ""; position: absolute; top: -7px; left: 32%; width: 36%; height: 14px;
  background: #dbc89c85; border-left: 1px dashed #b3a17970; border-right: 1px dashed #b3a17970;
  transform: rotate(-5deg);
}
.score-value { font-weight: 400; }
.pip { border-radius: 40% 20% 30% 10%; height: 6px; transform: rotate(-6deg); }
.pip:nth-child(even) { transform: rotate(4deg); }
.undo-card.is-ready { box-shadow: inset 3px 0 0 #ad584590, 1px 2px 0 #514a3515; }
.legend { margin-top: 30px; }
.legend-item i { border-radius: 35% 20% 30% 15%; background-image: url("assets/paper-grain.svg"); }
.hint { max-width: 540px; margin: 20px auto 0; line-height: 1.8; }
.tier-legendary { background-color: #f0dc9b; border-color: #a58a3f; }
.tier-epic { background-color: #ddcde8; border-color: #9377a4; }
.tier-rare { background-color: #cbdce5; border-color: #6b8fa5; }
.tier-uncommon { background-color: #d0dfbf; border-color: #7e9568; }
.tier-common { background-color: #dedbd1; border-color: #938d7e; }
.cell.miss { background-color: #f1dcd5; border-color: #bf8782; }
.rarity { background: #faf7efd9; box-shadow: none; border-radius: 2px 5px 3px 4px; }
.overlay { background: #3e392c66; backdrop-filter: blur(2px); }
.sheet { box-shadow: 5px 8px 0 #30261618, 0 18px 50px #30261626; }
#search {
  color: var(--ink); background: #fffdf660 url("assets/paper-grain.svg");
  border: 1px solid #9e9380; border-bottom: 2px solid #807563;
  border-radius: 5px 3px 8px 3px;
}
#search::placeholder { color: var(--muted); opacity: 1; }
.results li:hover, .results li.sel, .done-grid > button { background: #e9e1d1; }
.primary { border-color: #8c4839; }
.toast { background: #514c42 url("assets/paper-grain.svg"); border-radius: 4px 9px 5px 7px; }
button:focus-visible, .cell:focus-visible, #search:focus-visible {
  outline: 2px dashed var(--accent); outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Size the grid from its container, including when scrollbars take up space. */
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100svh; }
main {
  width: 100%; max-width: 1040px; margin-inline: auto;
  padding: clamp(18px, 4svh, 48px) 24px max(20px, env(safe-area-inset-bottom));
}
.topbar {
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left), calc((100% - 992px) / 2));
  padding-right: max(16px, env(safe-area-inset-right), calc((100% - 992px) / 2));
}
.brand { white-space: nowrap; }
.topbar-actions { flex: none; }
.pill, .cog, .ghost, .primary, .undo-square, .sheet-close { min-height: 44px; }
.cog, .sheet-close { width: 44px; }
.settings-pop { top: calc(100% + 10px); max-width: calc(100vw - 32px); }
.board-wrap { flex-wrap: nowrap; gap: clamp(18px, 3vw, 36px); }
.board {
  width: min(62vw, max(340px, calc(100svh - 230px)), 620px);
  flex: none; aspect-ratio: 1;
  grid-template-columns: minmax(0, .8fr) repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, .8fr) repeat(3, minmax(0, 1fr));
  gap: clamp(5px, 1vw, 9px);
}
.cat, .cell { min-width: 0; min-height: 0; }
.cell img { width: min(48%, 72px); height: auto; aspect-ratio: 1; flex-shrink: 1; min-height: 0; }
.cell .cname { font-size: clamp(9px, .85vw, 12px); }
.cat-main { font-size: clamp(11px, 1.1vw, 15px); }
.cat-top { font-size: clamp(8px, .8vw, 10px); }
.scorepanel { width: 184px; flex: none; padding-top: 12px; gap: 12px; }
.score-label { font-size: 11px; }
.undo-card { line-height: 1.6; }
.legend { margin-top: 22px; font-size: 11px; gap: 7px 16px; }
.hint { margin-top: 14px; font-size: 13px; }
.overlay {
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  align-items: center; overscroll-behavior: contain;
}
.sheet { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.sheet-crit { padding-inline: 16px; }
.sheet-close { top: 2px; right: 2px; }
.results { max-height: min(44dvh, 380px); overscroll-behavior: contain; }
.results li { min-height: 48px; }
#search { min-height: 48px; }

@media (max-width: 759px) {
  main { padding: 18px 12px max(16px, env(safe-area-inset-bottom)); }
  .board-wrap { flex-direction: column; align-items: center; gap: 18px; }
  .board {
    /* Keep the board large enough to read on short screens; the page can scroll. */
    width: min(100%, 500px, max(280px, calc(100svh - 280px)));
  }
  .scorepanel {
    width: min(100%, 500px, max(280px, calc(100svh - 280px)));
    padding-top: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 10px; align-items: stretch;
  }
  .guess-card { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; padding: 16px 12px; }
  .guess-head { gap: 5px; }
  .score-label { font-size: 10px; }
  .undo-card { padding: 6px 10px; font-size: 11px; line-height: 1.4; }
  .scorepanel .ghost.wide { width: 100%; padding: 5px 10px; }
  .score-sub { grid-column: 1 / -1; font-size: 10px; }
  .legend { margin-top: 16px; font-size: 10px; gap: 5px 12px; }
  .hint { font-size: 12px; max-width: 440px; margin-top: 10px; line-height: 1.6; }
  .cat-main { font-size: clamp(10px, 2.5vw, 13px); }
  .cat-top { font-size: clamp(8px, 1.8vw, 9px); letter-spacing: .03em; }
  .cell .cname { font-size: clamp(8px, 2vw, 11px); }
  .rarity { font-size: 8px; padding: 1px 3px; top: 3px; left: 3px; }
  .cat-icon { width: 25px; height: 25px; }
  .cat-icon-solo { width: 38px; height: 38px; }
}
@media (max-width: 400px) {
  .topbar { padding-inline: 10px; gap: 6px; }
  .brand { font-size: 18px; gap: 5px; }
  .topbar-actions { gap: 5px; }
  .pill { padding: 6px 9px; font-size: 12px; }
  .cat { padding: 2px; gap: 2px; }
  .cell { padding: 4px 3px; gap: 2px; }
  .sheet { padding: 22px 12px 14px; }
  .crit-main { font-size: 12px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  main { padding-top: 12px; }
  .board-wrap { flex-direction: row; align-items: flex-start; }
  .board { width: min(55%, max(260px, calc(100svh - 90px))); }
  .scorepanel { display: flex; width: 170px; padding-top: 10px; }
  .legend { margin-top: 14px; }
  .overlay { align-items: flex-start; }
}
@media (max-width: 400px) and (max-height: 650px) {
  main { padding-top: 10px; padding-bottom: 10px; }
  .board { width: min(100%, max(260px, calc(100svh - 305px))); }
  .board-wrap { gap: 12px; }
  .guess-card { padding: 12px 8px; }
  .score-value { font-size: 26px; }
  .legend { margin-top: 10px; font-size: 9px; gap: 4px 9px; }
  .legend-item { gap: 4px; }
  .legend-item i { width: 10px; height: 10px; }
  .hint { margin-top: 8px; font-size: 10px; line-height: 1.5; }
}

/* Crawlable information pages keep the same sketchbook treatment. */
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px dashed var(--accent); outline-offset: 4px; }
.info-page .brand { color: var(--ink); text-decoration: none; }
.info-page .topbar > .pill { display: inline-flex; align-items: center; text-decoration: none; }
.document-page { max-width: 760px; padding-block: 28px 32px; }
.document-page article {
  padding: clamp(18px, 4vw, 36px); background: var(--card) url("assets/paper-grain.svg");
  border: 1px solid var(--line); border-radius: 4px 9px 5px 7px;
  line-height: 1.85; font-family: "Segoe UI", system-ui, sans-serif; font-size: 16px;
  overflow-wrap: anywhere;
}
.document-page h1, .document-page h2 { font-family: "Segoe Print", "Bradley Hand", cursive; line-height: 1.5; }
.document-page h1 { font-size: clamp(25px, 5vw, 34px); margin: 0 0 20px; }
.document-page h2 { font-size: 20px; margin: 28px 0 10px; }
.document-page p { margin: 0 0 16px; }
.document-page li { margin-block: 8px; }
.document-page ul, .document-page ol { padding-left: 24px; }
.draft-note { padding: 12px; border: 1px dashed var(--accent); background: #efe1cf; }
.site-footer { max-width: 820px; margin: 0 auto; padding: 8px 12px max(14px, env(safe-area-inset-bottom)); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 16px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; font-size: 11px; color: var(--muted); }
@media (max-width: 400px) { .site-footer nav { gap: 0 12px; } }

.theme-switch { margin-bottom: 16px; }
.switch-row { min-height: 44px; }
.theme-footer { text-align: center; padding: 0 12px 24px; }
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #242522;
  --card: #30322d;
  --ink: #e5e0d3;
  --muted: #b5b2a6;
  --line: #656759;
  --accent: #e4a28b;
  --bad: #eda4a5;
  --shadow-sm: 0 1px 2px #0003;
  --shadow-lg: 0 18px 46px #0006;
}
[data-theme="dark"] body {
  background-image: url("assets/paper-grain.svg"), radial-gradient(ellipse at 45% 20%, #d7ceb408, transparent 75%);
}
[data-theme="dark"] .topbar { border-bottom-color: var(--line); box-shadow: 0 2px 0 -1px #0005; }
[data-theme="dark"] .ball { background: linear-gradient(175deg, #ae705c 0 46%, #c6beab 47% 53%, #42443b 54%); }
[data-theme="dark"] .ball::after { background: #393b34; }
[data-theme="dark"] :is(.pill, .cog, .ghost, .undo-square) { border-color: #858674; }
[data-theme="dark"] .pill.is-active { background-color: #493b32; border-color: var(--accent); }
[data-theme="dark"] .cell { border-color: #878979; box-shadow: 1px 2px 0 #0004, inset 0 0 15px #0001; }
[data-theme="dark"] .cell::before { border-color: #cbc6af22; }
[data-theme="dark"] .cell:hover:not(.filled):not(.locked) { background-color: #454137; border-color: var(--accent); box-shadow: 1px 2px 0 #0005; }
[data-theme="dark"] :is(.panel-card, .settings-pop, .sheet) { border-color: #777866; box-shadow: 2px 3px 0 #0003, 0 8px 18px #0002; }
[data-theme="dark"] .guess-card::before { background: #ac9d6870; }
[data-theme="dark"] .undo-card.is-ready { box-shadow: inset 3px 0 0 var(--accent), 1px 2px 0 #0003; }
[data-theme="dark"] .overlay { background: #11140fd1; }
[data-theme="dark"] #search { background: #242620 url("assets/paper-grain.svg"); border-color: #8e8c77; }
[data-theme="dark"] #search:focus { border-color: var(--accent); }
[data-theme="dark"] :is(.results li:hover, .results li.sel, .done-grid > button) { background: #44463c; }
[data-theme="dark"] .primary { background-color: #a65842; color: #fff5e9; border-color: #d38d72; }
[data-theme="dark"] .tier-legendary { background-color: #554b2b; border-color: #ba9c53; }
[data-theme="dark"] .tier-epic { background-color: #4a3d56; border-color: #b79bc8; }
[data-theme="dark"] .tier-rare { background-color: #334955; border-color: #88b1c6; }
[data-theme="dark"] .tier-uncommon { background-color: #3c4c32; border-color: #a0b785; }
[data-theme="dark"] .tier-common { background-color: #44453d; border-color: #a3a08d; }
[data-theme="dark"] .cell.miss { background-color: #563738; border-color: #c98c8a; }
[data-theme="dark"] .rarity { background: #252720e8; }
[data-theme="dark"] .switch { background: #626654; }
[data-theme="dark"] .switch-row input:checked + .switch { background: #b76e55; }
[data-theme="dark"] .draft-note { background: #493b32; }
[data-theme="dark"] .theme-footer [aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* Retraced pencil lines stay on decorative layers, leaving text and hit areas crisp. */
:root { --pencil: #6f695a; --hatch: #766c5410; }
:root[data-theme="dark"] { --pencil: #b8b6a2; --hatch: #ddd3b510; }
.cell, [data-theme="dark"] .cell {
  border-style: solid;
  border-radius: 3% 2% 4% 2% / 2% 4% 2% 3%;
  box-shadow: 1px 2px 0 var(--hatch);
  background-image: url("assets/paper-grain.svg"), repeating-linear-gradient(128deg, transparent 0 9px, var(--hatch) 9px 10px, transparent 10px 14px);
}
.cell::before, [data-theme="dark"] .cell::before {
  inset: 0; border: 0; border-radius: 0;
  background: var(--pencil); opacity: .75;
  mask: url("assets/sketch-frame.svg") center / 100% 100% no-repeat;
}
.cell:nth-child(3n)::before { transform: rotate(180deg); }
.cell:not([class*="tier-"]):not(.miss),
[data-theme="dark"] .cell:not([class*="tier-"]):not(.miss) { border-color: transparent; }
.cell:nth-child(4n)::before { transform: scaleX(-1); }
.panel-card, .settings-pop, .sheet, .document-page article { position: relative; }
.panel-card::after, .settings-pop::after, .sheet::after, .document-page article::after {
  content: ""; position: absolute; inset: 1px; pointer-events: none;
  background: var(--pencil); opacity: .35;
  mask: url("assets/sketch-frame.svg") center / 100% 100% no-repeat;
}
.pill, .ghost, .undo-square, .primary {
  position: relative;
  border-radius: 3px 9px 2px 7px / 9px 2px 8px 3px;
}
.pill::after, .ghost::after, .undo-square::after, .primary::after {
  content: ""; position: absolute; inset: 1px; pointer-events: none;
  background: currentColor; opacity: .28;
  mask: url("assets/sketch-frame.svg") center / 100% 100% no-repeat;
}
.pill.is-active, [data-theme="dark"] .pill.is-active {
  background-image: repeating-linear-gradient(-32deg, transparent 0 3px, var(--hatch) 3px 5px), url("assets/paper-grain.svg");
  text-decoration: underline wavy; text-underline-offset: 5px; text-decoration-thickness: 1px;
}
.brand { position: relative; }
.brand::after {
  content: ""; position: absolute; left: 28px; right: -3px; bottom: -5px; height: 8px;
  background: var(--accent); opacity: .65; pointer-events: none;
  mask: url("assets/scribble.svg") center / 100% 100% no-repeat;
  transform: rotate(-2deg);
}
.pips { gap: 2px; }
.pip {
  height: 10px; border-radius: 0;
  mask: url("assets/scribble.svg") center / 100% 100% no-repeat;
}
.legend-item i {
  background-image: repeating-linear-gradient(125deg, transparent 0 2px, var(--hatch) 2px 4px);
  border-radius: 2px 4px 1px 3px; transform: rotate(-7deg);
}
.legend-item:nth-child(even) i { transform: rotate(6deg); }
.cat-main { transform: rotate(-1deg); }
.cat:nth-child(even) .cat-main { transform: rotate(1deg); }
.score-value { position: relative; left: -8px; transform: rotate(-5deg); }
#search, [data-theme="dark"] #search {
  border-bottom-style: dashed; border-bottom-width: 2px;
  border-radius: 3px 8px 2px 4px / 7px 2px 6px 3px;
}
.site-footer a { text-decoration-style: wavy; text-decoration-thickness: 1px; }

/* The supplied iPad sketches float in the page margins like notebook doodles. */
.doodle-layer {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
}
.doodle {
  position: absolute; display: block; height: auto; width: var(--doodle-size);
  opacity: .62; mix-blend-mode: multiply;
  filter: contrast(1.55) drop-shadow(var(--doodle-x, 2px) var(--doodle-y, 3px) 0 #59615b55);
  user-select: none;
}
.doodle-star {
  --doodle-size: clamp(72px, 9vw, 132px); --doodle-x: 2px; --doodle-y: 4px;
  left: max(8px, calc((100vw - 1160px) / 2)); top: 19vh; transform: rotate(-12deg);
}
.doodle-eye {
  --doodle-size: clamp(56px, 7vw, 96px); --doodle-x: 3px; --doodle-y: 2px;
  right: max(10px, calc((100vw - 1160px) / 2)); top: 25vh; transform: rotate(8deg);
}
.doodle-differential {
  --doodle-size: clamp(122px, 15vw, 220px); --doodle-x: 2px; --doodle-y: 4px;
  left: max(-28px, calc((100vw - 1330px) / 2)); top: 50vh; transform: rotate(-5deg);
}
.doodle-kinetic {
  --doodle-size: clamp(110px, 14vw, 200px); --doodle-x: 4px; --doodle-y: 3px;
  right: max(-20px, calc((100vw - 1300px) / 2)); top: 59vh; transform: rotate(4deg);
}
.doodle-stick {
  --doodle-size: clamp(72px, 9vw, 125px); --doodle-x: 2px; --doodle-y: 4px;
  left: max(12px, calc((100vw - 1120px) / 2)); bottom: 11vh; transform: rotate(-7deg);
}
.doodle-pythagorean {
  --doodle-size: clamp(132px, 17vw, 250px); --doodle-x: 3px; --doodle-y: 3px;
  right: max(-25px, calc((100vw - 1230px) / 2)); bottom: 9vh; transform: rotate(3deg);
}
body > :is(.topbar, main, .loading, .site-footer) { position: relative; z-index: 1; }
[data-theme="dark"] .topbar { z-index: 40; }
[data-theme="light"] .topbar, :root:not([data-theme="dark"]) .topbar { z-index: 40; }
[data-theme="dark"] .doodle {
  opacity: .48; mix-blend-mode: screen;
  filter: invert(1) contrast(1.55) drop-shadow(var(--doodle-x, 2px) var(--doodle-y, 3px) 0 #eee8d075);
}
@media (max-width: 759px) {
  .doodle { opacity: .42; }
  .doodle-star { --doodle-size: 64px; left: 1%; top: 18vh; }
  .doodle-eye { --doodle-size: 54px; right: 1%; top: 24vh; }
  .doodle-differential { --doodle-size: 104px; left: -9%; top: 53vh; }
  .doodle-kinetic { --doodle-size: 96px; right: -8%; top: 61vh; }
  .doodle-stick { --doodle-size: 68px; left: 2%; bottom: 10vh; }
  .doodle-pythagorean { --doodle-size: 120px; right: -10%; bottom: 8vh; }
  [data-theme="dark"] .doodle { opacity: .34; }
}
@media (max-width: 400px) {
  .doodle-star { top: 15vh; }
  .doodle-eye { top: 21vh; }
  .doodle-differential { top: 49vh; }
  .doodle-kinetic { top: 57vh; }
}

/* Correct answers sit on tiny, imperfect paper cut-outs. */
:root {
  --cutout-paper: #fffefa;
  --cutout-line: #76786f;
  --cutout-shadow: #59615b55;
}
:root[data-theme="dark"] {
  --cutout-paper: #ebe8dc;
  --cutout-line: #575b53;
  --cutout-shadow: #080b09b8;
}
.cell.filled .poke-cutout {
  position: relative; z-index: 0; isolation: isolate;
  display: flex; align-items: center; justify-content: center;
  width: min(52%, 78px); aspect-ratio: 1; flex: none;
  transform: rotate(var(--cutout-tilt, -2deg));
  /* The shadow is painted by the image below so it follows the Pokémon silhouette. */
  filter: none;
}
.cell.filled .poke-cutout::before {
  /* The mask uses the artwork's alpha channel, so the paper follows the silhouette. */
  content: ""; position: absolute; z-index: -2; inset: 0;
  background: var(--cutout-line); opacity: .65;
  -webkit-mask-image: var(--cutout-image); mask-image: var(--cutout-image);
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  transform: scale(1.14);
}
.cell.filled .poke-cutout::after {
  content: ""; position: absolute; z-index: -1; inset: 0;
  background: var(--cutout-paper);
  -webkit-mask-image: var(--cutout-image); mask-image: var(--cutout-image);
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
  transform: scale(1.09);
}
.cell.filled .poke-cutout .poke {
  position: relative; z-index: 0;
  width: 100%; height: 100%; object-fit: contain;
  /* Multiple one-pixel offsets create a crisp paper border around the alpha silhouette. */
  filter:
    drop-shadow(2px 0 0 var(--cutout-paper))
    drop-shadow(-2px 0 0 var(--cutout-paper))
    drop-shadow(0 2px 0 var(--cutout-paper))
    drop-shadow(0 -2px 0 var(--cutout-paper))
    drop-shadow(1px 1px 0 var(--cutout-paper))
    drop-shadow(-1px -1px 0 var(--cutout-paper))
    drop-shadow(0 0 1px var(--cutout-line))
    drop-shadow(var(--cutout-x, 2px) var(--cutout-y, 3px) 1px var(--cutout-shadow));
}
.cell.cutout-0 .poke-cutout { --cutout-tilt: -3deg; --cutout-x: 2px; --cutout-y: 4px; }
.cell.cutout-1 .poke-cutout { --cutout-tilt: 2deg; --cutout-x: 3px; --cutout-y: 2px; }
.cell.cutout-2 .poke-cutout { --cutout-tilt: -1deg; --cutout-x: 1px; --cutout-y: 4px; }
.cell.cutout-3 .poke-cutout { --cutout-tilt: 3deg; --cutout-x: 4px; --cutout-y: 3px; }
.cell.cutout-4 .poke-cutout { --cutout-tilt: -2deg; --cutout-x: 2px; --cutout-y: 2px; }
.cell.cutout-5 .poke-cutout { --cutout-tilt: 1deg; --cutout-x: 4px; --cutout-y: 4px; }

/* White notepad stock with faint ruling and pencil-hatched drop shadows. */
:root {
  --bg: #fafbf9;
  --card: #fffffd;
  --line: #babdb6;
  --pencil: #72766e;
  --hatch: #6972690b;
  --notepad-rule: #7498b51c;
  --notepad-margin: #c97d7d27;
  --scribble-shadow: #5f685347;
}


:root[data-theme="dark"] {
  --notepad-rule: #9aafbc0e;
  --notepad-margin: #d39a8e19;
  --scribble-shadow: #080c08a6;
}
body, [data-theme="dark"] body {
  background-image: url("assets/paper-grain.svg"),
    linear-gradient(90deg, transparent 0 39px, var(--notepad-margin) 39px 40px, transparent 40px),
    repeating-linear-gradient(0deg, transparent 0 31px, var(--notepad-rule) 31px 32px);
}
.topbar { background-image: url("assets/paper-grain.svg"); }
.cell, [data-theme="dark"] .cell, .guess-card {
  /* Border-image paints beyond the box without clipping its contents or moving it. */
  border-image-source: url("assets/pencil-shadow.svg");
  border-image-slice: 12;
  border-image-width: 0 7px 7px 0;
  border-image-outset: 0 3px 3px 0;
  border-image-repeat: round;
}
.panel-card, .settings-pop, .sheet, .ghost, .primary, .undo-square, .document-page article {
  isolation: isolate;
}
.panel-card::before, .settings-pop::before, .sheet::before,
.ghost::before, .primary::before, .undo-square::before, .document-page article::before {
  content: ""; position: absolute; inset: 5px -5px -5px 5px;
  border-radius: inherit; pointer-events: none; z-index: -1;
  background: repeating-linear-gradient(128deg, transparent 0 2px, var(--scribble-shadow) 2px 3px, transparent 3px 5px);
  /* Only expose an L-shaped strip, so the paper and text stay clean. */
  clip-path: polygon(calc(100% - 6px) 0, 100% 0, 100% 100%, 0 100%, 0 calc(100% - 6px), calc(100% - 6px) calc(100% - 6px));
}
/* The guess card already uses its first decorative layer for the tape. */
.guess-card::before {
  inset: auto; top: -7px; left: 32%; width: 36%; height: 14px;
  z-index: 1; clip-path: none; border-radius: 0;
  background: #ddd3b78c;
}
[data-theme="dark"] .guess-card::before { background: #ac9d6870; }
.guess-card { filter: drop-shadow(2px 3px 0 var(--hatch)); }
.cell.tier-legendary { --pencil: #a58a3f; }
.cell.tier-epic { --pencil: #9377a4; }
.cell.tier-rare { --pencil: #6b8fa5; }
.cell.tier-uncommon { --pencil: #7e9568; }
.cell.tier-common { --pencil: #938d7e; }
.cell.miss { --pencil: var(--bad); }
[data-theme="dark"] .cell.tier-legendary { --pencil: #ba9c53; }
[data-theme="dark"] .cell.tier-epic { --pencil: #b79bc8; }
[data-theme="dark"] .cell.tier-rare { --pencil: #88b1c6; }
[data-theme="dark"] .cell.tier-uncommon { --pencil: #a0b785; }
[data-theme="dark"] .cell.tier-common { --pencil: #a3a08d; }
@media (max-width: 560px) {
  body, [data-theme="dark"] body {
    background-image: url("assets/paper-grain.svg"),
      repeating-linear-gradient(0deg, transparent 0 27px, var(--notepad-rule) 27px 28px);
  }
}

/* Loose doodle marks rather than perfectly repeated pencil hatching. */
.cell::before, [data-theme="dark"] .cell::before { opacity: .9; }
.cell:nth-child(3n + 1)::before { transform: rotate(180deg) scaleX(-1); }
.cell:nth-child(3n + 2)::before { transform: scaleY(-1); }
.panel-card::after, .settings-pop::after, .sheet::after, .document-page article::after { opacity: .5; }
.panel-card:not(.guess-card)::before, .settings-pop::before, .sheet::before,
.ghost::before, .primary::before, .undo-square::before, .document-page article::before {
  background: var(--scribble-shadow);
  mask: url("assets/doodle-shadow.svg") 0 0 / 18px 18px repeat;
}
.ball { transform: rotate(-9deg); }
.pill:not(.is-active) { transform: rotate(1deg); }
.scorepanel > .undo-card { transform: rotate(-.6deg); }
.scorepanel > .ghost { transform: rotate(.5deg); }
.legend-item:nth-child(odd) i { transform: rotate(-11deg); }

/* Individually drawn contours and full-length shadows; no repeating shadow tiles. */
.cell:nth-child(6) { --box-outline: url("assets/freeform-1.svg"); --box-shadow: url("assets/freeform-shadow-1.svg"); border-radius: 9% 9% 3% 3% / 4% 4% 4% 7%; }
.cell:nth-child(7) { --box-outline: url("assets/freeform-2.svg"); --box-shadow: url("assets/freeform-shadow-2.svg"); border-radius: 9% 3% 6% 9% / 9% 7% 8% 10%; }
.cell:nth-child(8) { --box-outline: url("assets/freeform-3.svg"); --box-shadow: url("assets/freeform-shadow-3.svg"); border-radius: 6% 5% 7% 3% / 10% 6% 5% 8%; }
.cell:nth-child(10) { --box-outline: url("assets/freeform-4.svg"); --box-shadow: url("assets/freeform-shadow-4.svg"); border-radius: 4% 4% 5% 8% / 7% 4% 5% 3%; }
.cell:nth-child(11) { --box-outline: url("assets/freeform-5.svg"); --box-shadow: url("assets/freeform-shadow-5.svg"); border-radius: 4% 5% 6% 6% / 4% 3% 10% 7%; }
.cell:nth-child(12) { --box-outline: url("assets/freeform-6.svg"); --box-shadow: url("assets/freeform-shadow-6.svg"); border-radius: 8% 3% 3% 7% / 6% 9% 5% 7%; }
.cell:nth-child(14) { --box-outline: url("assets/freeform-7.svg"); --box-shadow: url("assets/freeform-shadow-7.svg"); border-radius: 8% 3% 6% 5% / 9% 10% 7% 9%; }
.cell:nth-child(15) { --box-outline: url("assets/freeform-8.svg"); --box-shadow: url("assets/freeform-shadow-8.svg"); border-radius: 7% 9% 9% 5% / 10% 10% 3% 5%; }
.cell:nth-child(16) { --box-outline: url("assets/freeform-9.svg"); --box-shadow: url("assets/freeform-shadow-9.svg"); border-radius: 4% 8% 9% 5% / 8% 6% 7% 7%; }

.board .cell:nth-child(n)::before {
  mask-image: var(--box-outline); transform: none; opacity: .9;
}
.cell, [data-theme="dark"] .cell {
  border-image-source: var(--box-shadow);
  border-image-slice: 16;
  border-image-width: 0 9px 9px 0;
  border-image-outset: 0 3px 3px 0;
  border-image-repeat: stretch;
}
.guess-card { border-image-source: url("assets/freeform-shadow-4.svg"); border-image-slice: 16; border-image-repeat: stretch; }
.panel-card::after, .settings-pop::after, .sheet::after, .document-page article::after {
  mask-image: url("assets/freeform-3.svg");
}
.undo-card::after { mask-image: url("assets/freeform-7.svg"); }
.panel-card:not(.guess-card)::before, .settings-pop::before, .sheet::before,
.ghost::before, .primary::before, .undo-square::before, .document-page article::before {
  inset: 1px -5px -6px 2px; clip-path: none;
  mask: url("assets/freeform-shadow-6.svg") center / 100% 100% no-repeat;
}
.ghost::before, .undo-square::before { mask-image: url("assets/freeform-shadow-2.svg"); }
.sheet::before { mask-image: url("assets/freeform-shadow-8.svg"); }

/* Keep the settings card floating over the page instead of expanding the header. */
.settings-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
}

/* Scapholène by Scapholène; original font and license retained in assets/fonts. */
body, .document-page article, .document-page h1, .document-page h2 {
  font-family: "Scapholene", "Segoe Print", cursive;
}
input, button, select, textarea, code { font-family: inherit; }
.guess-card { padding: 22px 20px 18px; }
.guess-head { gap: 10px; align-items: center; }
.score-label { font-size: 15px; line-height: 1.2; }
.score-value { font-size: 38px; flex: none; }
.undo-card { padding: 16px 20px; font-size: 16px; line-height: 1.3; }
.undo-icon { flex: none; }
#undo-note { min-width: 0; overflow-wrap: anywhere; }
.scorepanel .panel-card::after { inset: 0; }
.pips { margin-top: 10px; }
.document-page article { font-size: 20px; line-height: 1.6; }
@media (max-width: 759px) {
  .guess-card { padding: 20px 16px 16px; }
  .guess-head { gap: 8px; }
  .score-label { font-size: 14px; }
  .score-value { font-size: 34px; }
  .undo-card { padding: 12px 17px; font-size: 14px; }
}
@media (max-width: 400px) and (max-height: 650px) {
  .guess-card { padding: 18px 15px 15px; }
  .score-label { font-size: 13px; }
  .score-value { font-size: 30px; }
  .undo-card { padding: 11px 16px; font-size: 13px; }
}

/* ------------------------------------------- archive, answers, countdown --- */
.done-grid > button {
  font: inherit; color: inherit; border: 1px solid transparent; cursor: pointer;
}
.done-grid > button:hover, .done-grid > button:focus-visible { border-color: var(--accent); outline: none; }
.done-tip { font-size: 12px !important; margin: -8px 0 12px !important; }
.done-next, .next-daily { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.done-next { margin: 12px 0 0; }
.next-daily { margin-top: 2px; }


.done-answers { text-align: left; }
.answers-back { font-size: 12px; padding: 6px 12px; margin-bottom: 10px; }
.answers-title { font-size: 17px !important; margin: 0 0 2px !important; text-align: center; }
.answers-title .crit-x { color: var(--muted); font-size: 14px; }
.answers-meta, .answers-note { text-align: center; font-size: 12.5px !important; margin: 0 0 6px !important; }
.answers-note { margin: 10px 0 0 !important; }
.answers-list { max-height: 50vh; }
.answers-list li { cursor: default; }
.answers-list li .rname { flex: 1; }
.answers-list li.mine { background: #efe1cf; box-shadow: inset 3px 0 0 var(--accent); }
.answers-list li em { font-size: 11px; color: var(--accent); font-style: normal; font-weight: 700; }
.ans-pct {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 9px;
  border: 1px solid var(--line); color: var(--ink); font-variant-numeric: tabular-nums;
}

.sheet-archive { max-width: 400px; }
.sheet-archive h2 { margin: 4px 0 6px; font-size: 21px; }
.archive-sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.archive-form { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.archive-form label { font-size: 13px; font-weight: 700; }
.archive-form input {
  flex: 1; min-width: 140px; font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink);
}
.archive-form .primary { width: auto; padding: 9px 18px; }
.archive-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.archive-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font: inherit; font-size: 13.5px; color: var(--ink); background: none; border: 0;
  border-bottom: 1px dashed var(--line); padding: 9px 6px; cursor: pointer; text-align: left;
}
.archive-list button:hover, .archive-list button:focus-visible { background: #e9e1d1; outline: none; }
.arch-day small { color: var(--muted); font-size: 11px; margin-left: 4px; }
.arch-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.arch-status.won { color: #17833f; font-weight: 700; }
.arch-status.done { color: var(--ink); }
.arch-status.progress { color: var(--accent); font-weight: 700; }

[data-theme="dark"] .answers-list li.mine { background: #493b32; }
[data-theme="dark"] .archive-list button:hover,
[data-theme="dark"] .archive-list button:focus-visible { background: #44463c; }
[data-theme="dark"] .arch-status.won { color: #8fd8a6; }
@media (max-width: 560px) {
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* ------------------------------------------------ nine-slice paper frames ---
 * The squiggly outline and hatched shadow used to be masks stretched to each
 * panel's full size, so on a big dialog the wobble sat 30-50px inside the edge
 * and crossed the text. As nine-slice border images, the hand-drawn corners
 * keep their size and the wobbly edges repeat rather than stretch, so the lines
 * stay within a fixed --frame distance of the edge at any size and content
 * padding always clears them. */
.panel-card, .settings-pop, .sheet, .document-page article {
  --frame: 22px;
  --frame-img: url("assets/frames/frame-a-light.svg");
  --shadow-img: url("assets/frames/shadow-a-light.svg");
}
.panel-card, .settings-pop { --frame: 13px; }
.undo-card { --frame-img: url("assets/frames/frame-b-light.svg"); }
.sheet { --shadow-img: url("assets/frames/shadow-b-light.svg"); }
[data-theme="dark"] :is(.panel-card, .settings-pop, .sheet, .document-page article) {
  --frame-img: url("assets/frames/frame-a-dark.svg");
  --shadow-img: url("assets/frames/shadow-a-dark.svg");
}
[data-theme="dark"] .undo-card { --frame-img: url("assets/frames/frame-b-dark.svg"); }
[data-theme="dark"] .sheet { --shadow-img: url("assets/frames/shadow-b-dark.svg"); }

.panel-card::after, .settings-pop::after, .sheet::after, .document-page article::after {
  mask: none; background: none; opacity: .5;
  border: var(--frame) solid transparent;
  border-image: var(--frame-img) 24 / var(--frame) round;
}
.panel-card:not(.guess-card)::before, .settings-pop::before, .sheet::before, .document-page article::before {
  mask: none; background: none;
  border: var(--frame) solid transparent;
  border-image: var(--shadow-img) 24 / var(--frame) round;
}

/* Keep text clear of the frame: at least the frame band plus a little air. */
.sheet { padding: calc(var(--frame) + 8px); }
.sheet-close { top: 10px; right: 12px; }
.document-page article { padding: max(calc(var(--frame) + 10px), clamp(18px, 4vw, 36px)); }
.settings-pop { padding: 16px 18px; }
.panel-card:not(.guess-card) { padding-inline: 17px; }
@media (max-width: 400px) {
  .sheet { padding: calc(var(--frame) + 6px) calc(var(--frame) + 2px); }
}
/* Sheets scroll when tall; a shadow hanging past the edge would add a stray
   scrollbar and scroll away with the content, so keep it inside the edge. */
.sheet::before { inset: 1px 0 0 2px; }
