/* v01: the in-play HUD, the pencil markers, the pressure hatching, the clip taped in like a photo. */
.hud__note {
  --rot: -2deg; position: absolute; top: calc(12px + var(--safe-t)); left: 12px; width: min(72vw, 420px);
  padding: 12px 16px 12px; transform: rotate(var(--rot)); transform-origin: 30% 0;
}
.hud__note.is-wiggle { animation: wiggle .45s var(--ease-pop); }
.hud__tag { display: block; font-size: 12px; color: rgba(45, 43, 40, .7); margin-bottom: 2px; }
.hud__q { margin: 0; font-size: 29px; line-height: 1.02; color: var(--graphite); }
.hud__sub { margin: 4px 0 0; font-size: 15px; line-height: 1.25; color: var(--pencil); }
.hud .is-writing { clip-path: inset(-20% 100% -20% 0); animation: write .5s var(--ease-out) forwards; }
.hud.is-good .hud__q { color: var(--green); }
.hud.is-hmm .hud__q { color: var(--red); }

/* the scout's margin mark after the tap */
.hud__margin { position: absolute; top: calc(70px + var(--safe-t)); right: 14px; display: grid; justify-items: center; transform: rotate(8deg); }
.hud__margin:empty { display: none; }
.hud__margin span { font-size: 30px; color: var(--paper); text-shadow: 0 2px 0 rgba(0, 0, 0, .5), 0 0 14px rgba(0, 0, 0, .6); animation: rise .35s var(--ease-pop) both; }
.hud__mark { width: 64px; height: 64px; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.hud__mark path { stroke-width: 5; animation-delay: 0s; }
.hud.is-hmm .hud__margin span { font-size: 40px; color: #ffd9d4; }

/* the timer: a pencil drawing a line along the bottom */
.hud__clock {
  position: absolute; left: 0; right: 0; bottom: calc(10px + var(--safe-b)); height: 46px; opacity: 0;
  transition: opacity .25s;
}
.hud__clock.is-on { opacity: 1; }
.hud__line { position: absolute; left: 0; top: 6px; width: 100%; height: 34px; overflow: visible; }
.hud__line path { fill: none; stroke-linecap: round; }
.hud__ghost { stroke: rgba(251, 246, 232, .35); stroke-width: 3; stroke-dasharray: 2 7; }
.hud__drawn { stroke: var(--paper); stroke-width: 5; stroke-dasharray: 1; stroke-dashoffset: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6)); }
.hud__clock.is-late .hud__drawn { stroke: #ff8f84; }
.hud__pencil { position: absolute; left: -68px; top: 2px; width: 74px; transform: rotate(-14deg); transform-origin: 92% 50%; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .45)); }
.hud__pencil svg { display: block; width: 100%; height: auto; }
.hud__clock.is-on .hud__pencil { animation: scribble .22s ease-in-out infinite alternate; }
@keyframes scribble { to { transform: rotate(-9deg) translateY(-2px); } }
.hud__secs {
  position: absolute; right: 14px; top: 0; min-width: 56px; text-align: right; font-size: 34px; line-height: 1;
  color: var(--paper); text-shadow: 0 2px 0 rgba(0, 0, 0, .55), 0 0 10px rgba(0, 0, 0, .5);
}
.hud__clock.is-late .hud__secs { color: #ffb1a8; }

/* pressure: red pencil hatching closes in, the note shakes, the gap in metres */
.nb-hatch {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: repeating-linear-gradient(-48deg, rgba(196, 55, 44, .7) 0 2px, transparent 2px 10px);
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 52%, #000 100%);
  mask-image: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 52%, #000 100%);
}
.hud.is-press.is-shake .hud__note { animation: shake .12s linear infinite; }
@keyframes shake { 0% { transform: rotate(-2deg) translate(0, 0); } 33% { transform: rotate(-2.6deg) translate(-1.5px, 1px); } 66% { transform: rotate(-1.4deg) translate(1.5px, -1px); } }
.hud__gap {
  position: absolute; left: 14px; bottom: calc(60px + var(--safe-b)); margin: 0; font-size: 28px; color: #ffd0ca;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .6), 0 0 12px rgba(120, 0, 0, .6); transform: rotate(-3deg);
}
.hud__threat { position: absolute; display: none; top: 46%; align-items: center; gap: 2px; color: #ffd0ca; font-size: 24px; text-shadow: 0 2px 0 rgba(0, 0, 0, .6); }
.hud__arrow { width: 64px; height: 32px; }
.hud__arrow path { fill: none; stroke: #ff8f84; stroke-width: 5; stroke-linecap: round; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .5)); }
.hud__threat[data-side="right"] { display: flex; right: 8px; }
.hud__threat[data-side="left"] { display: flex; left: 8px; flex-direction: row-reverse; }
.hud__threat[data-side="left"] .hud__arrow { transform: scaleX(-1); }
.hud__threat[data-side="behind"] { display: flex; top: auto; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.hud__threat[data-side="behind"] .hud__arrow { transform: rotate(90deg); }
.hud__threat[data-side="behind"] span::after { content: ', behind you'; }

/* ---- markers: pencil circles around a letter (never transform .pt-mk itself) ---- */
/* hidden until the engine's first layout frame has placed them (no flash in the top-left corner) */
.nb-placing .pt-mk { visibility: hidden; }
.nb-mk { position: relative; width: 66px; height: 66px; display: grid; place-items: center; animation: mkin .35s calc(var(--i) * .1s) var(--ease-pop) both; }
@keyframes mkin { from { opacity: 0; scale: .4; } to { opacity: 1; scale: 1; } }
.nb-mk::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: rgba(251, 246, 232, .93); box-shadow: 0 0 0 6px rgba(251, 246, 232, .26), 0 4px 12px rgba(0, 0, 0, .4); transition: background .2s; }
.nb-mk__ring, .nb-mk__ring2, .nb-mk__x { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.nb-mk__ring path, .nb-mk__ring2 path { fill: none; stroke: var(--graphite); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .5s calc(.1s + var(--i) * .12s) var(--ease-out) forwards; }
.nb-mk__ring2 { inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); opacity: 0; }
.nb-mk__l { position: relative; font-size: 34px; line-height: 1; color: var(--graphite); }
.nb-mk__x { opacity: 0; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.nb-mk__x path { fill: none; stroke: var(--red); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.nb-mk__tag { position: absolute; top: calc(100% - 4px); left: 50%; translate: -50% 0; white-space: nowrap; font-style: normal; font-size: 20px; line-height: 1; padding: 3px 8px 4px; border-radius: 4px; background: var(--paper); box-shadow: 0 3px 8px rgba(0, 0, 0, .35); opacity: 0; }
.pt-choosing .nb-mk { animation: mkin .35s calc(var(--i) * .1s) var(--ease-pop) both, breathe 1.6s calc(.5s + var(--i) * .2s) ease-in-out infinite; }
@keyframes breathe { 50% { scale: 1.07; } }
.pt-pressing .nb-mk__ring path { stroke: var(--red); }
.pt-mk:hover .nb-mk::before { background: #fff; }
.pt-mk:active .nb-mk { scale: .9; }
.pt-mk.is-pro .nb-mk::before { background: #e6f5e9; }
.pt-mk.is-pro .nb-mk__ring path, .pt-mk.is-pro .nb-mk__ring2 path { stroke: var(--green); }
.pt-mk.is-pro .nb-mk__ring2 { opacity: 1; }
.pt-mk.is-pro .nb-mk__ring2 path { animation: draw .45s var(--ease-out) forwards; }
.pt-mk.is-pro .nb-mk__l { color: var(--green); }
.pt-mk.is-pro .nb-mk__tag--pro { opacity: 1; color: var(--green); animation: rise .3s .2s var(--ease-pop) both; }
.pt-mk.is-mine .nb-mk::before { background: #fde6e2; }
.pt-mk.is-mine .nb-mk__x { opacity: 1; }
.pt-mk.is-mine .nb-mk__x path { animation: draw .35s var(--ease-out) forwards; }
.pt-mk.is-mine .nb-mk__tag--me { opacity: 1; color: var(--red); animation: rise .3s .2s var(--ease-pop) both; }
.pt-mk[data-edge=l]::before { border-right-color: var(--paper); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.pt-mk[data-edge=r]::before { border-left-color: var(--paper); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.pt-paths path { stroke: rgba(251, 246, 232, .85); stroke-width: 3; stroke-dasharray: 1 9; }
.pt-paths ellipse { fill: rgba(251, 246, 232, .22); }
.pt-paths path.is-pro { stroke: #3fbf75; stroke-width: 4; }
.pt-paths ellipse.is-pro { fill: rgba(63, 191, 117, .35); }

/* ---- the reveal: the real clip taped into the notebook ---- */
/* visibility hidden on the stage stops the engine drawing the 3D under the clip; the clip and its tape stay visible */
#stage.nb-reveal { background: transparent; visibility: hidden; }
#stage.nb-reveal > .pt-clip, #stage.nb-reveal::after { visibility: visible; }
#stage.nb-reveal > .pt-canvas, #stage.nb-reveal > .pt-marks, #stage.nb-reveal > .pt-paths, #stage.nb-reveal > .nb-hatch { opacity: 0; transition: opacity .3s; }
#stage > .pt-clip {
  inset: auto; top: calc(74px + var(--safe-t)); left: 18px; width: calc(100% - 36px); height: auto; aspect-ratio: 16 / 9;
  object-fit: cover; background: #1a1612; border: 7px solid #fbf8ef; border-bottom-width: 9px; border-radius: 2px;
  box-shadow: 0 14px 28px rgba(30, 18, 4, .45); transform: rotate(-1.3deg);
}
#stage.nb-reveal > .pt-clip { opacity: 1; }
#stage.nb-reveal::after {
  content: ''; position: absolute; z-index: 2; top: calc(62px + var(--safe-t)); left: 50%; width: 112px; height: 28px; margin-left: -56px;
  background: var(--tape); transform: rotate(2.5deg); box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}

@media (min-width: 900px) {
  .hud__note { top: 22px; left: 26px; padding: 16px 22px; width: min(46vw, 560px); }
  .hud__q { font-size: 38px; }
  .hud__sub { font-size: 17px; }
  .hud__tag { font-size: 13px; }
  .hud__margin { top: 84px; right: 30px; }
  .hud__clock { left: 8vw; right: 8vw; bottom: 22px; }
  .hud__secs { font-size: 40px; }
  #stage > .pt-clip { top: 50%; left: 5vw; width: min(56vw, 820px); transform: translateY(-50%) rotate(-1.3deg); }
  #stage.nb-reveal::after { top: calc(50% - min(56vw, 820px) * .28125 - 16px); left: calc(5vw + min(56vw, 820px) / 2); }
}
