/* tryin' — the whole page is one photographic print: a dark border, a wide bottom margin with
   two small lowercase serif labels, and a paper back you can turn over.
   Layout homage to James Blake, "Trying Times". */

:root {
  --border: #1b1a18;          /* the print's dark border */
  --photo: #0b0a09;           /* inside the frame before anything loads */
  --fg: #e6e1d6;
  --muted: #8f8a80;
  --line: rgba(230, 225, 214, 0.18);
  --panel: rgba(16, 15, 13, 0.78);
  --ember: #c0643a;
  --paper: #ebe6dc;           /* the back of the print */
  --ink: #23211e;
  --ink-muted: #7d776c;
  --ink-line: rgba(35, 33, 30, 0.2);

  --m: clamp(14px, 4.2vmin, 60px);        /* top / side margin */
  --mb: clamp(92px, 15.5vmin, 180px);     /* bottom margin, wider, like the cover */
  --serif: "Cormorant Garamond", "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --hand: "Caveat", "Long Cang", "Kaiti SC", "STKaiti", "KaiTi", cursive;
  --pencil: rgba(43, 40, 37, 0.9);
  --pencil-line: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='12' viewBox='0 0 140 12'%3E%3Cpath d='M0 6.2C12 5.1 22 7.3 35 6S58 4.9 70 6.4S96 7.2 105 5.8S128 5.2 140 6.2' fill='none' stroke='%232b2825' stroke-width='1.3' stroke-linecap='round' opacity='.8'/%3E%3Cpath d='M0 6.9C14 6.3 25 7.6 37 6.8S60 6 72 7S98 7.4 108 6.6S129 6.2 140 6.9' fill='none' stroke='%232b2825' stroke-width='.6' opacity='.35'/%3E%3C/svg%3E");
  --pencil-ring: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12.5 3.4C18.2 3.2 20.6 7.8 20.2 12.2C19.8 17 15.8 20.3 11.5 20.1C6.5 19.8 3.4 16.2 3.6 11.6C3.9 7.2 7.3 3.7 12.8 4.2C14.6 4.4 15.9 5 16.6 5.7' fill='%23ebe6dc' stroke='%232b2825' stroke-width='1.6' stroke-linecap='round'/%3E%3Cpath d='M8.6 10.2L14.8 14.2M9.2 13.8L14.2 9.6' stroke='%232b2825' stroke-width='.9' stroke-linecap='round' opacity='.45'/%3E%3C/svg%3E");
  --pencil-box: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M3.5 4.2C7.2 3.4 12 3.8 16.4 3.5C16.9 7.6 16.6 12.1 16.9 16.3C12.6 16.9 8 16.4 3.7 16.8C3.2 12.5 3.7 8 3.3 3.9' fill='none' stroke='%232b2825' stroke-width='1.3' stroke-linecap='round'/%3E%3C/svg%3E");
  --pencil-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M5.2 10.4C6.8 11.7 7.9 13 8.9 14.8C11 10.4 14.2 6.2 18.8 2.4' fill='none' stroke='%232b2825' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --pencil-caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='12' viewBox='0 0 14 12'%3E%3Cpath d='M1.5 3.6C3.6 5.6 5 7 7 9.2C9 6.9 10.6 5.2 12.6 2.8' fill='none' stroke='%232b2825' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0e0d0c;
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ the print */

.desk {
  position: fixed;
  inset: 0;
  perspective: 2400px;
}

.card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(0.62, 0.02, 0.24, 1);
}
.card.flipped { transform: rotateY(180deg); }
/* a slight lift off the desk while it turns. The shadow sits on the desk, not the card:
   a filter on the card itself would flatten its 3D and show the front mirrored. */
.desk.turning { animation: lift 1.15s cubic-bezier(0.62, 0.02, 0.24, 1); }
@keyframes lift {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)); }
  50% { filter: drop-shadow(0 30px 60px rgba(0, 0, 0, 0.55)); }
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--border);
  overflow: hidden;
}
.face.back { transform: rotateY(180deg); }
/* only the face you are looking at is shown at all (backface-visibility alone is not enough in
   WebKit) and only it can be clicked */
.card:not(.show-back) .face.back,
.card.show-back .face.front { visibility: hidden; }
.card:not(.flipped) .face.back,
.card.flipped .face.front { pointer-events: none; }

/* film grain over the whole print */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.photo {
  position: absolute;
  top: max(var(--m), env(safe-area-inset-top));
  left: max(var(--m), env(safe-area-inset-left));
  right: max(var(--m), env(safe-area-inset-right));
  bottom: calc(var(--mb) + env(safe-area-inset-bottom));
  background: var(--photo);
  overflow: hidden;
}

/* the two labels in the bottom margin */
.margin {
  position: absolute;
  left: max(var(--m), env(safe-area-inset-left));
  right: max(var(--m), env(safe-area-inset-right));
  bottom: calc(var(--mb) * 0.36 + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  z-index: 2;
}

.label {
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 0;
  margin: 0;
  color: var(--fg);
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(16px, 2.5vmin, 25px);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  cursor: pointer;
  transition: opacity 0.25s;
}
.label { position: relative; }
/* a generous tap area around the small word */
.label::after { content: ""; position: absolute; inset: -12px -14px; }
.label:hover { opacity: 0.7; }
/* the menu word breathes while the guide is up, so it reads as something to press */
.label.attention {
  animation: breathe 2.1s ease-in-out infinite;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 7px;
}
@keyframes breathe { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.label:disabled { opacity: 0.3; cursor: default; }
.label:focus-visible { outline: 1px solid var(--line); outline-offset: 4px; }
/* the back of the print shows the name mirrored, like the reversed word on the cover */
.label.mirrored { transform: scaleX(-1); }

.credit {
  position: absolute;
  left: max(var(--m), env(safe-area-inset-left));
  right: max(var(--m), env(safe-area-inset-right));
  bottom: calc(var(--mb) * 0.1 + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(10px, 1.35vmin, 13px);
  line-height: 1.45;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.75;
  z-index: 2;
}

/* a tiny Minkowski sketch in the bottom margin, centred between the two labels */
#diagram {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 34px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* on touch screens the sketch is also a thumb stick: drag from its centre to move */
#stick {
  position: absolute;
  left: 50%;
  bottom: calc(var(--mb) * 0.36 + env(safe-area-inset-bottom) + 21px - 44px);
  width: 88px;
  height: 88px;
  margin-left: -44px;
  z-index: 3;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#stick-ring, #stick-knob { position: absolute; left: 50%; top: 50%; pointer-events: none; border-radius: 50%; }
#stick-ring {
  width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border: 1px dashed var(--muted);
  opacity: 0;
  transition: opacity 0.3s;
}
#stick-knob {
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: var(--paper, #f3ede0);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 10px rgba(255, 240, 210, 0.6);
  opacity: 0;
  transition: opacity 0.3s;
}
@media (pointer: coarse) {
  #stick-ring { opacity: 0.55; }
  #stick-knob { opacity: 0.9; }
}
#stick.held #stick-ring { opacity: 0.9; }
@media (pointer: fine) { #stick { pointer-events: none; } }

@media (max-width: 560px) {
  :root { --mb: 124px; }
  .margin { bottom: calc(var(--mb) * 0.44 + env(safe-area-inset-bottom)); }
  #stick { bottom: calc(var(--mb) * 0.44 + env(safe-area-inset-bottom) + 21px - 44px); }
  #guide { bottom: calc(var(--mb) * 0.44 + 40px + env(safe-area-inset-bottom)); }
}

/* hand-drawn arrows from the picture down to the two corner labels */
#guide {
  position: absolute;
  left: max(var(--m), env(safe-area-inset-left));
  right: max(var(--m), env(safe-area-inset-right));
  bottom: calc(var(--mb) * 0.36 + 40px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.6s ease;
  font-family: var(--hand);
  color: var(--fg);
}
#guide.on { opacity: 1; }

.guide-item { display: flex; flex-direction: column; gap: 4px; }
.guide-home { align-items: flex-start; transform: rotate(-3deg); }
.guide-menu { align-items: flex-end; text-align: right; transform: rotate(2deg); }

.guide-note { font-size: clamp(22px, 3.2vmin, 28px); line-height: 1; opacity: 0.8; }
.guide-note small { display: block; margin-top: 3px; font-size: 0.72em; opacity: 0.75; }
.guide-menu .guide-note { font-size: clamp(27px, 4.2vmin, 36px); opacity: 1; }
.guide-menu .guide-note small { font-size: 0.6em; }

.guide-item svg {
  width: 52px;
  height: 68px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.guide-home svg { opacity: 0.8; }
.guide-menu svg { width: 66px; height: 86px; stroke-width: 2.3; }
/* The arrows ease in with opacity and a small drop, which run off the main thread, so they still
   appear while the page is busy loading. The menu arrow then bobs. */
#guide.on .guide-item svg { animation: arrowIn 0.7s 0.45s ease-out both; }
#guide.on .guide-menu svg { animation: arrowIn 0.7s 0.45s ease-out both, bob 1.7s 1.4s ease-in-out infinite; }
@keyframes arrowIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ------------------------------------------------------------------ front: the moment */

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#stage:active { cursor: grabbing; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 42%, #191714 0%, var(--photo) 72%);
  z-index: 10;
}

.intro-inner { width: min(460px, 100%); text-align: center; font-family: var(--hand); }

h1 {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(64px, 12vmin, 112px);
  line-height: 0.95;
  letter-spacing: 0;
  margin: 0 0 6px;
  transform: rotate(-2.5deg);
}

.lede {
  color: var(--muted);
  margin: 0 0 30px;
  line-height: 1.2;
  font-size: clamp(24px, 3.6vmin, 30px);
  transform: rotate(-0.6deg);
}

/* the drop zone is drawn by hand: uneven corners, slightly tilted */
.drop {
  display: block;
  padding: 30px 22px 26px;
  border: 1.6px solid rgba(230, 225, 214, 0.5);
  border-radius: 255px 18px 225px 15px / 15px 225px 18px 255px;
  cursor: pointer;
  transform: rotate(0.8deg);
  transition: border-color 0.25s, background 0.25s, transform 0.25s;
}
.drop:hover, .drop.over {
  border-color: rgba(230, 225, 214, 0.9);
  background: rgba(230, 225, 214, 0.04);
  transform: rotate(-0.4deg);
}
.drop-title { display: block; font-size: clamp(25px, 4vmin, 34px); line-height: 1.15; text-wrap: balance; }

.fine { margin-top: 22px; font-size: 21px; line-height: 1.2; color: var(--muted); opacity: 0.8; transform: rotate(-0.4deg); }
.error { color: var(--ember); }

.busy-inner { text-align: center; width: min(320px, 100%); }
.pulse {
  width: 6px; height: 6px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--fg);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.2; transform: scale(1); } 50% { opacity: 1; transform: scale(2.2); } }
#busy-text { color: var(--muted); font-size: 14px; letter-spacing: 0.06em; }
.bar { height: 1px; background: var(--line); margin-top: 16px; overflow: hidden; }
#busy-bar { height: 100%; width: 0; background: var(--fg); transition: width 0.2s; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* record button, top right of the picture: a ring with a dot, red while recording */
#btn-rec {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  min-width: 34px;
  padding: 0 9px;
  border: 1px solid rgba(255, 250, 240, 0.45);
  border-radius: 17px;
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 250, 240, 0.9);
  font: 12px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.04em;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#btn-rec #rec-time:not(:empty) { margin-left: 8px; }
#btn-rec i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 250, 240, 0.85); transition: background 0.2s, border-radius 0.2s; }
#btn-rec.on { border-color: #e0574f; }
#btn-rec.on i { background: #e0574f; border-radius: 3px; animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 50% { opacity: 0.45; } }
#btn-rec:focus-visible { outline: 1px solid var(--line); outline-offset: 2px; }

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: 10px;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 14px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-shadow: 0 0 6px #000;
  /* no backdrop-filter inside the turning print: iPhone Safari samples it from the wrong place
     and can leave a stale blurred copy of the page on screen */
  background: rgba(11, 10, 9, 0.6);
  border-radius: 3px;
  /* a drawer tucked under the bottom edge of the picture, closed by default */
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#hud.drawer-open .hud-bottom { opacity: 1; transform: translate(-50%, 0); }
.hud-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; }

/* the pull dot: a small grabber in the margin, just under the picture and above the sketch */
#hud-handle {
  position: absolute;
  left: 50%;
  bottom: calc(var(--mb) + env(safe-area-inset-bottom) - 24px);
  width: 48px;
  height: 20px;
  transform: translateX(-50%);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: none;
  z-index: 3;
}
#hud-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 3px;
  background: var(--muted);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, background 0.3s ease;
}
#hud-handle:hover::before { background: var(--fg); width: 16px; }
#hud-handle[aria-expanded="true"]::before { background: var(--fg); width: 22px; }
#hud-handle:focus-visible { outline: 1px solid var(--line); outline-offset: 2px; }
#dist, #tstat { color: var(--fg); font-variant-numeric: tabular-nums; }


/* walking with the phone: the invitation, and a warning near the edge of the moment */
#walk-prompt {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 7, 6, 0.72);
  z-index: 8;
}
.walk-card { max-width: 340px; text-align: center; }
.walk-title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(24px, 4.6vmin, 34px);
  line-height: 1.2;
  margin: 0 0 12px;
}
.walk-sub { color: var(--muted); font-size: 13px; line-height: 1.8; margin: 0 0 26px; }
.walk-actions { display: flex; justify-content: center; gap: 36px; }
#btn-walk-go { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }

#edge-warn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18px;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.3s;
  box-shadow: inset 0 0 120px 40px rgba(0, 0, 0, 0.85);
}
#edge-warn span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--fg);
  text-shadow: 0 0 8px #000;
}

/* ------------------------------------------------------------------ back: the paper */
/* Everything on the back is written by hand in pencil: text, sliders, ticks, underlines. */

.photo.paper {
  background: var(--paper);
  color: var(--ink);
}
/* a faint print-back watermark */
.photo.paper::before {
  content: "tryin'   tryin'   tryin'   tryin'   tryin'   tryin'   tryin'   tryin'";
  position: absolute;
  inset: -20% -20%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.4em;
  line-height: 4.2;
  color: rgba(35, 33, 30, 0.045);
  transform: rotate(-24deg);
  white-space: pre-wrap;
  word-spacing: 2em;
  pointer-events: none;
}

.back-inner {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: clamp(18px, 4vmin, 48px);
  -webkit-overflow-scrolling: touch;
  font-family: var(--hand);
  color: var(--pencil);
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 40, 37, 0.3) transparent;
}
.back-inner::-webkit-scrollbar { width: 6px; }
.back-inner::-webkit-scrollbar-track { background: transparent; }
.back-inner::-webkit-scrollbar-thumb { background: rgba(43, 40, 37, 0.25); border-radius: 3px; }

.back-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 22px;
  background: var(--pencil-line) repeat-x left bottom / 140px 12px;
}
.back-title {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(34px, 5.4vmin, 52px);
  line-height: 1;
  transform: rotate(-2deg);
  transform-origin: left center;
}
.back-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

/* hand-drawn boxes: uneven corners and a slight tilt */
.ink-btn, .hand-btn {
  appearance: none;
  background: none;
  color: var(--pencil);
  font-family: var(--hand);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.ink-btn {
  border: 1.6px solid var(--pencil);
  border-radius: 255px 18px 225px 15px / 15px 225px 18px 255px;
  padding: 8px 16px 6px;
  transform: rotate(1.2deg);
}
.ink-btn:hover { background: var(--pencil); color: var(--paper); transform: rotate(-0.6deg); }
.hand-btn {
  border: 0;
  padding: 4px 2px;
  text-decoration: underline wavy rgba(43, 40, 37, 0.45);
  text-underline-offset: 5px;
  transform: rotate(-1.5deg);
}
.hand-btn:hover { color: #000; }

#panel {
  position: relative;
  /* the slightly tilted lines would otherwise clip their numbers at the right edge */
  padding-right: 6px;
  font-size: 20px;
  color: var(--pencil);
  column-width: 270px;
  column-gap: 44px;
}
#panel .row, #panel .checks, #panel .stats { break-inside: avoid; }

/* each written line sits a little off the horizontal, the way handwriting does */
#panel > :nth-child(3n + 1) { transform: rotate(-0.5deg); }
#panel > :nth-child(3n + 2) { transform: rotate(0.35deg); }
#panel > :nth-child(3n) { transform: rotate(-0.15deg); }

.row { margin-bottom: 14px; }
.row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: var(--pencil);
  margin-bottom: 0;
  line-height: 1.15;
}
.row label output {
  color: var(--pencil);
  font-variant-numeric: normal;
  font-family: var(--hand);
  font-size: 19px;
  opacity: 0.8;
  white-space: nowrap;
}

/* pencil slider: a wobbly line with a hand-drawn ring */
.row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.row input[type=range]::-webkit-slider-runnable-track {
  height: 12px;
  background: var(--pencil-line) repeat-x left center / 140px 12px;
}
.row input[type=range]::-moz-range-track {
  height: 12px;
  background: var(--pencil-line) repeat-x left center / 140px 12px;
}
.row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  /* iOS paints a white rounded square with a shadow behind the thumb unless told otherwise */
  background: var(--pencil-ring) center / contain no-repeat transparent;
}
.row input[type=range]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: var(--pencil-ring) center / contain no-repeat;
}
.row input[type=range]:focus-visible { outline: none; }
.row input[type=range]:focus-visible::-webkit-slider-thumb { filter: drop-shadow(0 0 2px rgba(43, 40, 37, 0.5)); }

/* pencil select: underlined, with a scribbled caret */
.row select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: var(--pencil-caret) no-repeat right 2px center / 14px 12px,
              var(--pencil-line) repeat-x left bottom / 140px 12px;
  color: var(--pencil);
  border: 0;
  border-radius: 0;
  padding: 4px 22px 8px 0;
  font-family: var(--hand);
  font-size: 19px;
  color-scheme: light;
  cursor: pointer;
}

/* pencil checkbox: a wonky square, ticked by hand */
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 16px; color: var(--pencil); line-height: 1.2; }
.checks label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.checks input[type=checkbox] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
  background: var(--pencil-box) center / contain no-repeat;
  cursor: pointer;
}
.checks input[type=checkbox]:checked {
  background: var(--pencil-tick) center / contain no-repeat, var(--pencil-box) center / contain no-repeat;
}
.checks input[type=checkbox]:focus-visible { outline: 1px dashed rgba(43, 40, 37, 0.5); outline-offset: 2px; }

.stats { color: var(--pencil); opacity: 0.65; font-size: 16px; line-height: 1.35; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  .label.attention, #guide.on .guide-menu svg { animation: none; }
  #guide.on .guide-item svg { animation: none; }
  .card { transition-duration: 0.01s; }
  .desk.turning { animation: none; }
}

/* ---------------------------------------------------------------- UniverseChopLAb (cosmic, full screen) */
#lab {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 40%, #0b1222 0%, #04060c 60%, #010205 100%);
  color: #dfe6f3;
  overflow: hidden;
  touch-action: none;
}
#lab-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lab-head {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.lab-title { margin: 0; font: 600 clamp(24px, 4.6vmin, 38px)/1 var(--hand); letter-spacing: 0.02em; color: #f2f6ff; }
#lab-mode { margin: 8px 0 0; font: 600 clamp(15px, 2.5vmin, 19px)/1.2 var(--hand); color: #ffcf8a; letter-spacing: 0.02em; }
.lab-actions { display: flex; gap: 8px; pointer-events: auto; }
#lab-rec { min-width: 44px; color: #f3d6d3; }
#lab-rec.on { border-color: #e0574f; color: #ff8b84; }
.lab-sub { margin: 6px 0 0; max-width: 34ch; font: clamp(14px, 2.4vmin, 18px)/1.25 var(--hand); color: #8fa0bf; }
.lab-btn {
  pointer-events: auto;
  font: clamp(17px, 2.8vmin, 22px)/1 var(--hand);
  color: #e8eefc;
  background: rgba(20, 30, 52, 0.35);
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 999px;
  padding: 7px 16px 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lab-btn:hover { border-color: rgba(125, 211, 252, 0.8); }
.lab-legend {
  position: absolute;
  top: calc(max(16px, env(safe-area-inset-top)) + clamp(104px, 17vmin, 140px));
  left: max(18px, env(safe-area-inset-left));
  font: clamp(13px, 2.1vmin, 16px)/1.5 var(--hand);
  color: #9aa9c6;
  pointer-events: none;
}
.lab-legend p { margin: 0; }
.lab-legend { transition: opacity 0.6s; }
#lab.inside .lab-legend { opacity: 0; }
.lab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.lab-dot.star { background: #ffb851; box-shadow: 0 0 6px #ffb851; }
.lab-dot.earth { background: #7dd3fc; box-shadow: 0 0 6px #7dd3fc; }
.lab-dot.slice { background: transparent; border: 1px solid #7dd3fc; border-radius: 1px; }
.lab-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: 0 max(18px, env(safe-area-inset-left));
  text-align: center;
  pointer-events: none;
}
#lab-readout { margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: clamp(10px, 2.6vw, 12px)/1.4 ui-monospace, Menlo, monospace; color: #9fc4e8; letter-spacing: 0.03em; }
#lab-hint { margin: 0 0 10px; font: clamp(13px, 2.2vmin, 16px)/1.3 var(--hand); color: #7f8eaa; }
.lab-controls { display: flex; align-items: center; justify-content: space-between; max-width: 520px; margin: 0 auto; }
.lab-toggle { pointer-events: auto; display: flex; align-items: center; gap: 6px; font: clamp(16px, 2.6vmin, 20px)/1 var(--hand); color: #c9d4ea; cursor: pointer; }
.lab-toggle input { accent-color: #7dd3fc; width: 16px; height: 16px; }
#lab-stick {
  position: relative;
  width: 104px;
  height: 104px;
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.lab-ring, #lab-knob { position: absolute; left: 50%; top: 50%; border-radius: 50%; pointer-events: none; }
.lab-ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 1px dashed rgba(125, 211, 252, 0.55); }
.lab-ring::before, .lab-ring::after { content: ""; position: absolute; left: 50%; top: 50%; background: rgba(125, 211, 252, 0.25); }
.lab-ring::before { width: 1px; height: 80px; margin: -40px 0 0 0; }
.lab-ring::after { width: 80px; height: 1px; margin: 0 0 0 -40px; transform: rotate(0deg); }
#lab-knob { width: 16px; height: 16px; margin: -8px 0 0 -8px; background: #e9f6ff; box-shadow: 0 0 12px rgba(125, 211, 252, 0.9); }
#lab-stick.held .lab-ring { border-color: rgba(125, 211, 252, 0.95); }
.panel-lab { display: block; width: 100%; margin: 0 0 14px; font: 600 clamp(19px, 3vmin, 24px)/1.1 var(--hand); }
