/* Paper and ink, on screen. White stock, black ballpoint, hand-drawn boxes. */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --shade: #f3f2ec;
  --ink: #141414;
  --ink-soft: #4a4a4a;
  --hand: "Bradley Hand", "Segoe Print", "Comic Sans MS", "Chalkboard SE", cursive;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-sm: 125px 12px 145px 14px / 12px 145px 10px 130px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  overscroll-behavior: none;
}

/* fixed paper fibre */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.05;
  mix-blend-mode: multiply;
}

#stage { position: fixed; inset: 0; }
canvas { display: block; position: absolute; inset: 0; touch-action: none; }

#pops { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }

.pop {
  position: absolute;
  padding: 16px 26px;
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(15px, 2.4vw, 26px);
  letter-spacing: 0.5px;
  white-space: nowrap;
  transform-origin: center;
  will-change: transform, opacity;
  text-shadow: none;
}
.pop-big { padding: 22px 36px; font-size: clamp(19px, 3.4vw, 38px); }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
/* only the controls catch the pointer; panels must never block a whack */
#hud button { pointer-events: auto; }

/* ---- title ---- */
#titleCard {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 14px;
  transform: rotate(-2deg);
}
#titleCard h1 {
  margin: 0; font-size: clamp(20px, 3.4vw, 34px); line-height: 0.98;
  letter-spacing: 0.5px; text-shadow: 1px 1px 0 rgba(0,0,0,0.12);
}
#titleCard h1 span { display: inline-block; transform: translateX(8px); }
#titleCard .sub { margin: 2px 0 0 6px; font-size: clamp(10px, 1.4vw, 14px); color: var(--ink-soft); }
#titleCard h1::after {
  content: ""; display: block; height: 3px; margin-top: 3px;
  background: var(--ink);
  clip-path: polygon(0 40%, 12% 10%, 30% 55%, 52% 5%, 74% 50%, 100% 20%, 100% 80%, 70% 60%, 48% 95%, 26% 55%, 8% 90%, 0 60%);
}

/* ---- chips / buttons ---- */
.chip {
  font-family: var(--hand); font-size: clamp(12px, 1.6vw, 16px); font-weight: 700;
  color: var(--ink); background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: var(--wobble-sm);
  padding: 7px 14px; cursor: pointer;
  box-shadow: 2px 3px 0 rgba(20,20,20,0.18);
  transition: transform 0.08s ease;
}
.chip:active { transform: translate(1px, 2px) rotate(-1deg); }
.chip.icon { min-width: 92px; }
#checkToggle {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 14px;
  transform: rotate(1.5deg);
}
#checkToggle span { font-weight: 700; }

/* ---- checklist ---- */
.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  box-shadow: 3px 4px 0 rgba(20,20,20,0.16);
}
#checklist {
  position: absolute; top: max(54px, calc(env(safe-area-inset-top) + 46px)); right: 14px;
  width: min(260px, 62vw); padding: 10px 14px 12px;
  transform: rotate(0.6deg);
  max-height: 58vh; overflow: auto;
}
#checklist h2 { margin: 2px 0 6px; font-size: clamp(13px, 1.7vw, 17px); }
#checklist ol { list-style: none; margin: 0; padding: 0; }
#checklist li {
  display: flex; align-items: center; gap: 8px;
  font-size: clamp(11px, 1.5vw, 15px); padding: 3px 0; color: var(--ink-soft);
}
#checklist li .box {
  width: 15px; height: 15px; flex: 0 0 15px;
  border: 2px solid var(--ink); border-radius: 4px 6px 5px 7px / 6px 4px 7px 5px;
  display: grid; place-items: center; font-size: 13px; line-height: 1;
}
#checklist li.done { color: var(--ink); font-weight: 700; }
#checklist li.done .box { background: var(--ink); color: var(--paper); }
#checklist li.hinted { color: var(--ink); }
#checklist li.hinted .name { text-decoration: underline dotted; }
#checklist.hidden { display: none; }

/* ---- bottom controls ---- */
#controls {
  position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}

#toast {
  position: absolute; left: 50%; bottom: max(72px, calc(env(safe-area-inset-bottom) + 66px));
  transform: translateX(-50%) rotate(-0.5deg);
  padding: 8px 16px; font-size: clamp(12px, 1.7vw, 16px);
  opacity: 0; transition: opacity 0.25s ease; max-width: 84vw; text-align: center;
}
#toast.show { opacity: 1; }

#hoverLabel {
  position: absolute; pointer-events: none; z-index: 41;
  font-size: clamp(11px, 1.5vw, 14px); font-weight: 700;
  background: var(--ink); color: var(--paper);
  padding: 3px 8px; border-radius: 8px 10px 7px 11px / 10px 7px 11px 8px;
  transform: translate(-50%, -150%); opacity: 0; transition: opacity 0.12s ease; white-space: nowrap;
}

/* ---- overlays ---- */
.overlay {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 18px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(1px);
}
.overlay.hidden { display: none; }
.card {
  background: var(--paper); border: 3.5px solid var(--ink); border-radius: var(--wobble);
  box-shadow: 5px 6px 0 rgba(20,20,20,0.18);
  padding: clamp(18px, 3.4vw, 34px); max-width: 520px; width: 100%; text-align: center;
  transform: rotate(-0.6deg);
}
.card h1 { margin: 0 0 10px; font-size: clamp(26px, 5.4vw, 48px); line-height: 1; }
.card p { margin: 8px 0; font-size: clamp(13px, 1.9vw, 17px); color: var(--ink); }
.card p.small { font-size: clamp(11px, 1.5vw, 14px); color: var(--ink-soft); }
.card .fine { font-size: clamp(10px, 1.4vw, 13px); color: var(--ink-soft); margin-top: 12px; }
.bigBtn {
  font-family: var(--hand); font-weight: 700; font-size: clamp(16px, 2.4vw, 22px);
  color: var(--paper); background: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--wobble-sm);
  padding: 12px 26px; margin-top: 14px; cursor: pointer;
  box-shadow: 3px 4px 0 rgba(20,20,20,0.25);
}
.bigBtn:active { transform: translate(1px, 2px); }

.board { margin: 12px 0 4px; }
.board h3 { margin: 6px 0; font-size: clamp(13px, 1.8vw, 17px); }
.board ol { list-style: none; margin: 0; padding: 0; font-size: clamp(12px, 1.6vw, 15px); }
.board li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.board li.me { font-weight: 700; text-decoration: underline; }
.board .empty { color: var(--ink-soft); font-size: clamp(11px, 1.5vw, 14px); }

/* ---- narrow screens: keep the room readable ---- */
@media (max-width: 700px), (max-height: 480px) {
  #titleCard h1 { font-size: clamp(17px, 5vw, 24px); }
  #checklist { width: min(220px, 58vw); }
  #controls { gap: 7px; }
  .chip { padding: 6px 11px; }
}
@media (max-width: 420px) {
  #titleCard .sub { display: none; }
  #checklist { top: max(48px, calc(env(safe-area-inset-top) + 42px)); }
}
