/* Text adventure. Fonts: Inter (story), Michroma (labels), Caveat (handwritten notes). */
:root { --pad: 28px; --soft: #b7b8bf; }
html, body { overflow: hidden; }
body { font-family: var(--body); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; font-size: 17px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

#app {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: minmax(0, 1fr) clamp(380px, 35vw, 540px);
  grid-template-rows: minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
#left { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#pic { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
#scene { position: absolute; image-rendering: pixelated; image-rendering: crisp-edges; }

/* compass */
#compass { position: absolute; top: 14px; left: 14px; width: 132px; height: 150px; color: var(--fg); }
/* the rose is drawn in the picture's two colours: ink with a one-pixel ground outline */
#compass svg { position: absolute; left: 22px; top: 22px; width: 88px; height: 88px; fill: var(--fg); stroke: var(--bg); stroke-width: 2.4; paint-order: stroke; stroke-linejoin: miter; overflow: visible; }
#compass .hollow, #compass .hub { fill: var(--bg); stroke: var(--fg); stroke-width: 2.2; }
#compass button {
  position: absolute; background: none; border: 0; padding: 0; cursor: pointer; font: 400 13px/1 var(--wide); color: var(--fg);
  text-shadow: 1px 0 var(--bg), -1px 0 var(--bg), 0 1px var(--bg), 0 -1px var(--bg), 1px 1px var(--bg), -1px -1px var(--bg), 1px -1px var(--bg), -1px 1px var(--bg);
}
#compass .d { width: 44px; height: 44px; display: grid; place-items: center; }
#compass .d:not(:disabled):hover, #compass .ud:hover { background: var(--fg); color: var(--bg); text-shadow: none; }
#compass button:disabled {
  color: var(--bg); cursor: default;
  text-shadow: 1px 0 var(--fg), -1px 0 var(--fg), 0 1px var(--fg), 0 -1px var(--fg), 1px 1px var(--fg), -1px -1px var(--fg), 1px -1px var(--fg), -1px 1px var(--fg);
}
#compass .n { left: 44px; top: -12px; } #compass .s { left: 44px; top: 100px; }
#compass .w { left: -12px; top: 44px; } #compass .e { left: 100px; top: 44px; }
#compass .ud { top: 132px; height: 44px; padding: 0 8px; }
#compass .u { left: 0; } #compass .dn { left: 0; }

#hovertag { position: absolute; right: 16px; bottom: 12px; margin: 0; padding: 6px 8px; font: 400 12px/1 var(--wide); background: var(--bg); border: 1px solid var(--fg); pointer-events: none; white-space: nowrap; z-index: 3; }
#hovertag.at { right: auto; bottom: auto; transform: translate(-50%, calc(-100% - 16px)); }

/* the tray: pen, eraser, carried things and found cards, in one row over the picture's lower left corner */
#tray { position: absolute; left: 0; bottom: 0; display: flex; flex-direction: row; align-items: flex-end; gap: 14px; padding: 0 0 18px 24px; pointer-events: none; z-index: 2; }
#cards { position: relative; display: flex; align-items: flex-end; pointer-events: none; padding-left: 4px; }
#cards .card { pointer-events: auto; }
#tools { order: -1; display: none; gap: 8px; pointer-events: auto; padding: 4px; margin-left: -4px; }
.has-tools #tools { display: flex; }
#tray.hot #tools { outline: 2px solid var(--blue); outline-offset: 2px; }
.tool { width: 52px; height: 52px; padding: 0; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); display: grid; place-items: center; cursor: pointer; touch-action: none; }
.tool.item { cursor: grab; }
.tool svg { width: 34px; height: 34px; }
.tool canvas { width: 44px; height: 44px; image-rendering: pixelated; pointer-events: none; }
.tool .tw { font: 400 12px/1 var(--wide); pointer-events: none; }
.tool:hover, .tool:focus-visible { box-shadow: 3px 3px 0 var(--fg); }
.tool.eraser.hot { background: var(--fg); color: var(--bg); }
body.dragging, body.dragging * { cursor: grabbing !important; }
/* the menu at a thing */
#menu { position: fixed; z-index: 20; min-width: 168px; padding: 4px 0; background: var(--bg); border: 1.5px solid var(--fg); box-shadow: 3px 3px 0 var(--fg); }
#menu .mt { margin: 0; padding: 9px 14px 7px; font: 400 12px/1 var(--wide); color: var(--muted); }
#menu button { display: block; width: 100%; min-height: 44px; padding: 0 14px; border: 0; background: none; text-align: left; font: 400 16px var(--body); color: var(--fg); cursor: pointer; }
#menu button:hover, #menu button:focus { background: var(--fg); color: var(--bg); outline: none; }

/* a typed word on its way into the picture */
.flyword { position: fixed; left: 0; top: 0; z-index: 30; padding: 5px 8px; background: var(--fg); color: var(--bg); font: 400 15px/1 var(--body); white-space: nowrap; pointer-events: none; }
/* a card in the tray: a small upright ticket, its picture above the tear, no words */
.card {
  position: relative; flex: none; width: 56px; height: 80px; display: flex; flex-direction: column; align-items: center; padding-top: 5px;
  border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); text-decoration: none; box-shadow: 2px 2px 0 var(--fg);
  transform: rotate(var(--tilt)); transition: transform .15s ease-out;
}
.card + .card { margin-left: var(--ov, -8px); }
.card:hover, .card:focus-visible { transform: rotate(0deg) translateY(-8px); z-index: 2; }
.card.waiting { visibility: hidden; }
.card canvas { width: 44px; height: 44px; image-rendering: pixelated; }
.card .tear { position: absolute; left: 0; right: 0; top: 56px; border-top: 1.5px dashed var(--fg); }
.card .tear i { position: absolute; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--fg); }
.card .tear i:first-child { left: -6px; } .card .tear i:last-child { right: -6px; }

/* the whole card: just found, or lifted out of the tray */
.ticket {
  position: fixed; z-index: 16; width: 150px; height: 262px; display: flex; flex-direction: column; align-items: center; padding: 6px 10px 0;
  border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); text-decoration: none; box-shadow: 3px 3px 0 var(--fg); overflow: hidden;
}
#cardpeek { pointer-events: none; }
.ticket.arriving { transform-origin: 50% 50%; }
.ticket .brand { align-self: flex-start; font: 400 19px/1 var(--hand); height: 20px; }
.ticket canvas { width: 112px; height: 112px; image-rendering: pixelated; margin-top: 2px; }
.ticket .name { font: 400 12px/1.25 var(--wide); text-align: center; margin-top: 4px; }
.ticket .note { font: 400 12px/1.3 var(--body); color: var(--muted); text-align: center; margin-top: 3px; }
.ticket .tear { position: absolute; left: 0; right: 0; top: 200px; border-top: 1.5px dashed var(--fg); }
.ticket .tear i { position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--fg); }
.ticket .tear i:first-child { left: -9px; } .ticket .tear i:last-child { right: -9px; }
.ticket .stub { position: absolute; left: 10px; right: 10px; top: 208px; display: flex; flex-direction: column; align-items: center; gap: 3px; font: 400 12px/1 var(--body); font-variant-numeric: tabular-nums; }
.ticket .bars { width: 92px; height: 14px; fill: var(--fg); }

/* the handwritten note, once, beside the first card */
.handnote { order: 9; align-self: center; margin: 0 0 0 10px; padding: 4px 10px 6px 4px; background: var(--bg); font: 400 22px/1 var(--hand); display: none; align-items: center; gap: 4px; white-space: nowrap; pointer-events: none; }
.handnote svg { width: 40px; height: 26px; transform: scaleY(-1) rotate(12deg); }
.note-on .handnote { display: flex; }

/* story panel */
#right { display: flex; flex-direction: column; min-height: 0; padding: var(--pad) var(--pad) 12px; border-left: 1px solid var(--line); }
#log { flex: 1; overflow-y: auto; font-size: 17px; line-height: 1.55; padding-right: 6px; overscroll-behavior: contain; }
#log p { margin: 0 0 .7em; max-width: 34em; }
#log .entry.echo p { color: var(--muted); margin: 1.2em 0 .45em; }
#log .placename { font: 400 13px/1.2 var(--wide); margin: 1.4em 0 .7em; letter-spacing: .02em; }
#log .entry:first-child .placename { margin-top: .4em; }
#log .hello { font: 400 14px/1 var(--wide); }
#log a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
#log .aside { color: var(--muted); }
#log .items { list-style: none; padding: 0; margin: .2em 0 .9em; }
#log .items li { padding: 6px 0; border-top: 1px solid var(--line); }
#log .items li:last-child { border-bottom: 1px solid var(--line); }
#log .items .n { color: var(--muted); }
#log .sec { margin-bottom: .3em; }
#log .contact { font-size: 19px; }
#log .thing { text-decoration: underline dotted; text-decoration-thickness: 1.5px; text-underline-offset: 4px; cursor: pointer; }
#log .thing.on { background: var(--fg); color: var(--bg); text-decoration: none; }
#log .thing.old { text-decoration: none; cursor: auto; }

#chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 0 12px; }
.chip { min-height: 44px; padding: 0 18px; border: 1px solid var(--fg); background: var(--bg); border-radius: 22px; font-size: 15px; cursor: pointer; }
.chip:hover { background: var(--fg); color: var(--bg); }
.chip.hint { border-width: 2px; border-style: dashed; }
#cmd { display: flex; align-items: center; gap: 10px; border-top: 1.5px solid var(--fg); padding-top: 6px; }
#cmd span { font-size: 18px; }
#cmd input { flex: 1; min-width: 0; height: 46px; border: 0; background: transparent; font: 400 17px var(--body); color: var(--fg); outline: none; }
#cmd input::placeholder { color: var(--muted); }
#cmd:focus-within { border-top-color: var(--blue); }

/* bottom line */
#bottom {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 26px; padding: 0 20px calc(env(safe-area-inset-bottom)) 20px;
  border-top: 1px solid var(--line); font: 400 12px/1 var(--wide); min-height: 46px;
}
#bottom button, #bottom a { background: none; border: 0; padding: 0; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; font: inherit; text-decoration: none; color: var(--fg); }
#bottom button:hover, #bottom a:hover { text-decoration: underline; text-underline-offset: 4px; }
#where { min-width: 120px; }
#count { color: var(--muted); }
#contact { margin-left: auto; color: var(--orange) !important; font: 400 15px/1 var(--display) !important; }
.phone-only { display: none !important; }
.concepts.phone-only { position: absolute; top: 4px; right: 12px; font: 400 12px/1 var(--wide); text-decoration: none; min-height: 44px; align-items: center; background: transparent; }

/* overlays */
.overlay { position: fixed; inset: 0; background: rgba(245, 245, 245, .92); display: grid; place-items: center; z-index: 10; padding: 16px; }
.overlay .panel { background: var(--bg); border: 1.5px solid var(--fg); width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 18px 22px 22px; }
.overlay .head { display: flex; justify-content: space-between; align-items: center; font: 400 13px/1 var(--wide); margin-bottom: 10px; }
.overlay .btns { display: flex; gap: 8px; }
.overlay .close, .overlay .restart { background: none; border: 1px solid var(--fg); min-height: 44px; padding: 0 16px; border-radius: 22px; cursor: pointer; font: 400 15px var(--body); }
.overlay .close:hover, .overlay .restart:hover { background: var(--fg); color: var(--bg); }
#map svg { width: 100%; height: auto; max-height: calc(100dvh - 170px); display: block; color: var(--fg); font: 400 13px var(--body); }
#map .room.seen:not(.here) { cursor: pointer; }
#map .room.seen:not(.here):hover .lab, #map .room.seen:focus .lab { fill: var(--fg); }
#map .room.seen:not(.here):hover text, #map .room.seen:focus text { fill: var(--bg); }
#map .small, .overlay .small { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
#skip .body { font-size: 17px; line-height: 1.5; }
#skip .body .items { list-style: none; padding: 0; margin: .2em 0 1.2em; }
#skip .body .items li { padding: 6px 0; border-top: 1px solid var(--line); }
#skip .body .n { color: var(--muted); }
#skip .body p { margin: .8em 0 .3em; }

/* phone */
@media (max-width: 760px) {
  :root { --pad: 16px; }
  #app { grid-template-columns: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
  #left { display: block; }
  #pic { height: 40vh; height: 40dvh; min-height: 250px; flex: none; }
  #compass { transform: scale(.8); transform-origin: 0 0; top: 6px; left: 6px; }
  #tray { position: static; flex-direction: row; align-items: center; gap: 8px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; pointer-events: auto; display: none; }
  .has-cards #tray, .has-tools #tray { display: flex; padding-top: 6px; padding-bottom: 6px; border-top: 1px solid var(--line); }
  #tools { order: -1; flex: none; margin: 0; padding: 0; }
  #cards { pointer-events: auto; align-items: center; gap: 0; flex: none; padding: 8px 0 4px 4px; }
  .handnote { font-size: 20px; }
  .card { width: 48px; height: 66px; padding-top: 4px; }
  .card canvas { width: 38px; height: 38px; }
  .card .tear { top: 48px; }
  .ticket.arriving { box-shadow: 3px 3px 0 var(--fg); }
  #right { border-left: 0; border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: 6px; }
  #log { font-size: 16px; }
  /* the replies are one row that scrolls sideways, so the story above them keeps its height; the suggested reply comes first */
  #chips { padding: 10px var(--pad) 8px; margin: 0 calc(-1 * var(--pad)); gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; flex: none; }
  #chips::-webkit-scrollbar { display: none; }
  .chip { padding: 0 14px; flex: none; white-space: nowrap; }
  .chip.hint { order: -1; }
  #bottom { gap: 14px; flex-wrap: nowrap; white-space: nowrap; padding: 0 16px env(safe-area-inset-bottom); font-size: 12px; }
  #where { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
  /* the address stays in Skip the game and in the mailbox */
  #contact { display: none !important; }
  .desk-only, .desk-word { display: none !important; }
  .concepts.phone-only { top: 6px; min-height: 40px; padding: 0 10px; background: var(--bg) !important; border: 1px solid var(--fg); }
  .phone-only { display: inline-flex !important; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }
#contact[hidden] { display: none !important; }
#contact[hidden] + .concepts { margin-left: auto; }

/* the journey: the effects layer, the sword, the beat meter, chapters, sound */
#fx { position: absolute; left: 0; top: 0; pointer-events: none; image-rendering: pixelated; image-rendering: crisp-edges; }
#fx[hidden] { display: none; }
body.sword-drawn #scene { cursor: crosshair; }
body.sword-drawn #pic::after { content: ''; position: absolute; inset: 5px; border: 1.5px solid var(--fg); pointer-events: none; }
.tool.sword.drawn { background: var(--fg); color: var(--bg); }
.tool.sword.drawn svg path:first-child { fill: var(--fg); }
.tool.leaving { transition: transform .6s ease-in, opacity .6s ease-in; transform: translateY(-40px) rotate(-30deg); opacity: 0; }
/* the beat meter: a real 16 x 4 grid, 7px cells with 2px gaps; lit cells solid ink, the current step outlined in the accent */
#meter { display: inline-flex !important; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 0; }
#meter[hidden] { display: none !important; }
#meter .row { display: flex; gap: 2px; }
#meter .row.merged { display: none; }
#meter i { display: block; width: 7px; height: 7px; box-sizing: border-box; border: 1px solid var(--line); background: transparent; }
#meter .row i.p { background: var(--line); }
#meter .row.earned i.p, #meter .row.merged i.lit { background: var(--fg); border-color: var(--fg); }
#meter .row i.now { outline: 1.5px solid var(--orange); outline-offset: 0; }
#meter:hover { text-decoration: none !important; }
#meter:hover .row i.p:not(.lit) { border-color: var(--muted); }
#btn-sound[hidden] { display: none !important; }
#log .chapter { margin: 1.2em 0 .6em; padding-top: .6em; border-top: 1.5px solid var(--fg); }
#log .chapter .k { font: 400 12px/1 var(--wide); color: var(--muted); margin-right: .5em; }
#log .chapter .sub { color: var(--muted); }
#log .technique strong { font-family: var(--wide); font-weight: 400; font-size: .85em; letter-spacing: .02em; }
@media (prefers-reduced-motion: reduce) { .tool.leaving { transition: none; } }
/* a narrow phone: one merged row of 16 */
@media (max-width: 430px) {
  #meter .row { display: none; }
  #meter .row.merged { display: flex; gap: 1.5px; }
  #meter i { width: 4px; height: 6px; }
  #meter .row.merged { gap: 1px; }
  /* everything in the bottom line fits a 375-point phone; on anything narrower the line scrolls sideways */
  #bottom { gap: 10px; padding-left: 12px; padding-right: 12px; overflow-x: auto; scrollbar-width: none; }
  #bottom::-webkit-scrollbar { display: none; }
  #where { display: none; }
}
/* a phone with the browser's own bars showing (about 660 points tall): the picture gives a little, so the story
   keeps about five lines */
@media (max-width: 760px) and (max-height: 720px) {
  #pic { height: 36vh; height: 36dvh; min-height: 230px; }
  #cmd input { height: 44px; }
}
#map .panel { width: min(1100px, 100%); }
#map .panel { width: fit-content; max-width: 100%; min-width: min(560px, 100%); }
#map svg { max-height: none; }

/* ---------- the picture comes first: goal, ways out, markers, tools, writing in place ---------- */
#compass { transform: scale(.62); transform-origin: 0 0; }
#pictags { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
#pictags .way {
  position: absolute; left: 0; top: 0; pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 10px 0 8px; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg);
  font: 400 14px/1 var(--body); white-space: nowrap; cursor: default;
}
#pictags .way .ar { font: 400 16px/1 var(--wide); }
/* Peggy, December 3: "dont have the labels they are super distracting". A way out is a small arrow box; its words
   show in the hover tag, and on the box itself only while Show everything is held down. */
#pictags .way { justify-content: center; min-width: 34px; padding: 0; }
#pictags .way .wl { display: none; }
#pictags.ways-named .way { padding: 0 10px 0 8px; }
#pictags.ways-named .way .wl { display: inline; }
#pictags .way:hover, #pictags .way:focus-visible { background: var(--fg); color: var(--bg); }
#pictags .way.shut { border-style: dashed; color: var(--muted); }
#pictags .way.shut:hover { background: var(--bg); color: var(--fg); }
#pictags.engine-marks .marks i { opacity: 0 !important; }
#btn-map.ring { outline: 2.5px solid var(--orange); outline-offset: 3px; }
#pictags .ring, #tools .tool.ring { outline: 2.5px solid var(--orange); outline-offset: 3px; animation: ring-in .6s ease-out; }
@keyframes ring-in { from { outline-offset: 14px; outline-color: transparent; } }
#pictags .marks i {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--fg); box-shadow: 0 0 0 2px var(--bg);
  opacity: .14; transition: opacity .5s ease-out;
}
#pictags.marks-loud .marks i { opacity: 1; transition-duration: .12s; }
@media (pointer: coarse) { #pictags .marks i { opacity: .4; } #pictags .way { min-height: 44px; min-width: 44px; } }
#pictags .showring { position: absolute; left: 0; top: 0; border: 2.5px solid var(--orange); border-radius: 50%; pointer-events: none; }
#pictags .showring.drawn { animation: show-ring .7s ease-out; }
@keyframes show-ring { from { clip-path: polygon(50% 50%, 50% 0, 50% 0); } 25% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 50%); } 50% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 50% 100%); } 75% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 50%); } to { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 0 100%, 0 0, 50% 0); } }
#pictags .arrows svg { position: absolute; left: 0; top: 0; width: 64px; height: 64px; fill: none; stroke: var(--fg); stroke-width: 3.5; stroke-linecap: square; opacity: .6; overflow: visible; }
#pictags .arrows svg path { paint-order: stroke; }
#pictags .arrows svg.answer { stroke: var(--orange); opacity: .9; }
#pictags .arrows .an { position: absolute; left: 0; top: 0; padding: 3px 6px; font: 400 12px/1 var(--wide); background: var(--bg); border: 1px solid var(--fg); white-space: nowrap; }
#goalstrip {
  position: absolute; top: 10px; left: 104px; right: 12px; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px; background: var(--bg); border: 1.5px solid var(--fg); font: 400 14px/1.3 var(--body);
}
#goalstrip[hidden], #goal[hidden] { display: none; }
/* the hint is asked for with Hint in the bottom bar; on a computer it shows above the story only, never over the picture */
@media (min-width: 761px) { #goalstrip { display: none !important; } }
#btn-hint[hidden] { display: none !important; }
#btn-hint[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 4px; }
#goalstrip p, #goal p { margin: 0; flex: 1; min-width: 0; }
#goalstrip .k, #goal .k { font: 400 12px/1 var(--wide); color: var(--muted); margin-right: .5em; }
#goalstrip .showme, #goal .showme { flex: none; min-height: 32px; padding: 0 12px; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 13px/1 var(--body); cursor: pointer; }
#goalstrip .showme:hover, #goal .showme:hover { background: var(--fg); color: var(--bg); }
#goal { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; margin-bottom: 4px; background: var(--bg); border-bottom: 1.5px solid var(--fg); font: 400 15px/1.35 var(--body); }
#btn-all { position: absolute; right: 12px; top: 10px; z-index: 3; min-height: 32px; padding: 0 12px; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 13px/1 var(--body); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
#btn-all[aria-pressed="true"], #btn-all:hover { background: var(--fg); color: var(--bg); }
#hovertag { display: flex; align-items: center; gap: 6px; }
#hovertag[hidden] { display: none; }
#hovertag .more { pointer-events: auto; min-width: 26px; height: 22px; margin: -4px -4px -4px 2px; padding: 0 4px; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 13px/1 var(--body); cursor: pointer; }
#hovertag .more:hover { background: var(--fg); color: var(--bg); }
/* the four tools, labelled; the selected one inverted, the ones not found yet empty outlines */
#tools { display: flex !important; }
.tool.named { width: 64px; height: 60px; grid-template-rows: 34px 14px; align-content: center; gap: 3px; position: relative; }
.tool.named svg { width: 30px; height: 30px; }
.tool.named .tw { font: 400 12px/1 var(--wide); }
.tool.named .kn { position: absolute; right: 3px; top: 3px; font: 400 12px/1 var(--wide); color: var(--muted); }
.tool.named.on { background: var(--fg); color: var(--bg); }
.tool.named.on svg path:first-child { fill: var(--fg); stroke: var(--bg); }
.tool.named.on svg path { stroke: var(--bg); }
.tool.named.on .kn { color: var(--bg); }
.tool.named.missing { border-style: dashed; color: var(--muted); background: transparent; cursor: help; box-shadow: none; }
.tool.named.missing svg { opacity: .45; }
.tool.named.missing svg path { fill: transparent; }
@media (pointer: coarse) { .tool.named .kn { display: none; } }
body.tool-pen #scene { cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28"><path d="M3 25 L5 18 L19 4 L24 9 L10 23 Z" fill="white" stroke="black" stroke-width="2"/><path d="M3 25 L5 18 L10 23 Z"/></svg>') 3 25, text; }
body.tool-eraser #scene { cursor: cell; }
body.tool-sword #scene { cursor: crosshair; }
/* writing in the picture: a caret and a small field where the pen touched */
#ink { position: absolute; left: 0; top: 0; z-index: 4; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; row-gap: 6px; width: 230px; }
#ink[hidden] { display: none; }
#ink .caret { width: 2px; height: 30px; background: var(--fg); animation: caret 1s steps(1) infinite; align-self: center; }
@keyframes caret { 50% { opacity: 0; } }
#ink input { min-width: 0; height: 34px; padding: 0 8px; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 16px var(--body); border-radius: 0; }
#ink input:focus { outline: 2px solid var(--fg); outline-offset: 1px; }
#ink .sugg { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; }
#ink .sugg button { min-height: 32px; padding: 0 10px; border: 1px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 13px/1 var(--body); cursor: pointer; }
#ink .sugg button:hover { background: var(--fg); color: var(--bg); }
@media (pointer: coarse) { #ink .sugg button, #goalstrip .showme, #goal .showme, #btn-all { min-height: 44px; } #ink input { height: 44px; } }
@media (prefers-reduced-motion: reduce) { #pictags .ring, #tools .tool.ring, #pictags .showring.drawn, #ink .caret { animation: none; } #pictags .marks i { transition: none; } }
@media (max-width: 760px) {
  #goalstrip { left: 8px; right: 8px; top: auto; bottom: 8px; font-size: 13px; padding: 4px 4px 4px 10px; }
  #goal { display: none !important; }
  #btn-all { top: 54px; right: 8px; min-height: 44px; }
  #compass { transform: scale(.55); top: 6px; left: 6px; }
  #pictags.ways-named .way { padding: 0 8px 0 6px; }
}

/* the hover tag reads over busy pictures: 14 px, room inside, a one-cell shadow */
#hovertag { padding: 8px 10px; font: 400 14px/1 var(--wide); border: 1.5px solid var(--fg); box-shadow: 3px 3px 0 var(--fg); }
#hovertag .more { height: 26px; margin: -6px -6px -6px 4px; font-size: 14px; }
#hovertag.at { transform: translate(calc(-50% + var(--nx, 0px)), calc(-100% - 16px + var(--ny, 0px))); }
#tools .tool.arrive { animation: tool-arrive .8s steps(4, end); }
@keyframes tool-arrive { 0% { outline: 2.5px solid var(--orange); outline-offset: 10px; } 50% { outline: 2.5px solid var(--orange); outline-offset: 2px; transform: scale(1.08); } 100% { outline: 2.5px solid transparent; outline-offset: 2px; transform: none; } }
@media (prefers-reduced-motion: reduce) { #tools .tool.arrive { animation: none; outline: 2.5px solid var(--orange); outline-offset: 3px; } }

/* ---------- part four: the tool line, bigger tools, the pen and the eraser in the picture ---------- */
#toolbox { order: -1; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: auto; }
#toolbox #tools { order: 0; }
#toolline { margin: 0; max-width: 340px; min-height: 30px; padding: 6px 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  font: 400 14px/1.3 var(--body); background: var(--bg); border: 1.5px solid var(--fg); box-shadow: 3px 3px 0 var(--fg); }
#toolline[hidden], #toolline:empty { display: none; }
#toolline.peek { border-style: dashed; box-shadow: none; }
#toolline .topen { min-height: 30px; padding: 0 12px; border: 1.5px solid var(--fg); background: var(--fg); color: var(--bg); font: 400 13px/1 var(--wide); cursor: pointer; }
.tool.named { width: 76px; height: 72px; grid-template-rows: 38px 16px; gap: 4px; }
.tool.named svg { width: 34px; height: 34px; }
.tool.named .tw { font-size: 13px; }
.tool.named .cnt { position: absolute; right: -9px; top: -9px; min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; background: var(--orange); color: #fff; font: 400 12px/1 var(--wide); border: 1.5px solid var(--fg); }
body.tool-eraser #scene { cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30"><path d="M3 20 L13 10 L25 22 L19 28 L11 28 Z" fill="white" stroke="black" stroke-width="2"/><path d="M3 20 L8 15 L20 27 L19 28 L11 28 Z" fill="black"/></svg>') 4 27, cell; }
#pictags .landing { position: absolute; left: 0; top: 0; width: 46px; height: 16px; margin: -8px 0 0 -23px; border: 2px dotted var(--fg); border-radius: 50%; pointer-events: none; }
#pictags .landing.inkspot { border-color: var(--orange); }
#pictags .handw { position: absolute; left: 0; top: 0; font: 400 30px/1 var(--hand); color: var(--fg); white-space: nowrap; pointer-events: none; text-shadow: 0 0 2px var(--bg), 0 0 4px var(--bg); }
#pictags .putback { position: absolute; left: 0; top: 0; pointer-events: auto; min-height: 36px; padding: 0 12px; border: 1.5px solid var(--fg); background: var(--bg); color: var(--fg); font: 400 14px/1 var(--body); box-shadow: 3px 3px 0 var(--fg); cursor: pointer; }
#pictags .putback:hover { background: var(--fg); color: var(--bg); }
#pictags .crumb { position: absolute; left: 0; top: 0; width: 3px; height: 3px; background: var(--fg); pointer-events: none; }
#hovertag.hollow { background: transparent; box-shadow: none; border-style: dashed; color: var(--fg); text-shadow: 0 0 2px var(--bg), 0 0 3px var(--bg); }
#penink { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; image-rendering: pixelated; }
#ink .msg { grid-column: 2; margin: 0; padding: 4px 6px; font: 400 13px/1.3 var(--body); background: var(--bg); border: 1px dashed var(--fg); }
#ink .msg[hidden] { display: none; }
#ink.shake { animation: ink-shake .32s steps(4, end); }
@keyframes ink-shake { 25% { margin-left: -6px; } 50% { margin-left: 6px; } 75% { margin-left: -3px; } }
@media (pointer: coarse) { #pictags .putback { min-height: 44px; } #toolline .topen { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { #ink.shake { animation: none; } }
@media (max-width: 760px) {
  #toolbox { flex: none; }
  #toolline { max-width: calc(100vw - 40px); font-size: 14px; box-shadow: none; }
  .tool.named { width: 74px; height: 66px; }
  #tray { align-items: flex-end; }
}
#ink.dock { grid-template-columns: auto 1fr; box-sizing: border-box; padding: 6px; background: var(--bg); border: 1.5px solid var(--fg); }
#ink.dock .sugg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
body.ink-docked #pic > #goalstrip { visibility: hidden; }

/* ---------- the tools get their own strip under the picture (not over it) ---------- */
@media (min-width: 761px) {
  #tray { position: static; flex: none; align-items: center; gap: 16px; padding: 8px 16px 8px 16px; border-top: 1px solid var(--line); background: var(--bg); pointer-events: auto; }
  #toolbox { flex-direction: row; align-items: center; gap: 8px; }
  #toolbox #tools { display: contents !important; }
  #toolbox .tool.named { order: 0; }
  #toolline { order: 1; max-width: 400px; margin-left: 6px; box-shadow: none; display: block; line-height: 1.45; }
  #toolline .topen { margin-left: 4px; vertical-align: middle; }
  #tray { min-height: 89px; box-sizing: border-box; }
  #toolbox .tool.item { order: 2; }
  #tray.hot #toolbox { outline: 2px solid var(--blue); outline-offset: 2px; }
  #cards { padding-bottom: 0; }
}
/* a refusal reads over any picture: the page's own ground, a dashed edge */
#hovertag.hollow { background: var(--bg); border-style: dashed; box-shadow: none; text-shadow: none; }
/* a tool not found yet: solid ground, dashed edge, muted icon */
.tool.named.missing { background: var(--bg); }
@media (min-width: 761px) and (pointer: fine) { #toolline .topen { min-height: 26px; } }
@media (max-width: 760px) {
  #left > #goalstrip { position: static; margin: 0; border-width: 0 0 1px; border-color: var(--line); padding: 4px 8px 4px 16px; }
}

/* ---- The hidden footer (foot.js), as on the Digipals site: a slim bar kept below the bottom of the page until it is
   asked for (html.foot-on). --footk runs 0 to 1 and is the one thing that is animated; the page rises by the bar's
   height with it, the way a page does when it is scrolled to its end. */
@property --footk { syntax: '<number>'; inherits: true; initial-value: 0; }
html { --footh: 42px; --foot: calc(var(--footk) * var(--footh)); transition: --footk .45s cubic-bezier(.2, .7, .2, 1); }
html.foot-on { --footk: 1; }
@media (prefers-reduced-motion: reduce) { html { transition: none; } }
#app { translate: 0 calc(-1 * var(--foot)); }
.foot {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; min-height: 42px; display: flex; align-items: center; gap: 8px 22px;
  padding: 0 max(20px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(20px, env(safe-area-inset-left, 0px));
  translate: 0 calc((1 - var(--footk)) * 100%);   /* below the page, still in the tab order: tabbing into it brings it up */
  background: var(--bg); border-top: 1px solid var(--line); font: 400 11px/1 var(--wide); letter-spacing: .04em; color: var(--muted); white-space: nowrap;
}
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-left: auto; }
.foot a { color: var(--fg); text-decoration: none; min-height: 30px; display: inline-flex; align-items: center; transition: color .15s; }
.foot a:hover { color: var(--orange); }
.foot a:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }
.foot a span { margin-left: 6px; color: var(--muted); }
.foot a.mail { color: var(--orange); }
.foot .soc { display: flex; align-items: center; gap: 14px; }
.foot .soc a { position: relative; display: grid; place-items: center; width: 18px; height: 18px; min-height: 0; }
.foot .soc svg { width: 13px; height: 13px; fill: currentColor; }
#bottom .concepts.desk-only { margin-left: auto; }
@media (pointer: coarse) { .foot a { min-height: 44px; } .foot .soc { gap: 22px; } .foot .soc a::after { content: ""; position: absolute; inset: -13px; } }
@media (max-width: 760px) {
  .foot { flex-wrap: wrap; justify-content: center; padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); font-size: 10px; }
  .foot nav { margin-left: 0; justify-content: center; gap: 0 18px; order: -1; width: 100%; }
}
