:root { --ink: #efe6d2; --dim: #b9b3a6; --amber: #f6c98b; --plum: #2b1320; --night: #101e32; --line: #f3c98b55; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font: 14px/1.4 Georgia, 'Iowan Old Style', serif; overflow: hidden; overscroll-behavior: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
button { font: inherit; color: inherit; }
kbd { font: 11px/1 ui-monospace, monospace; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; margin-left: 6px; opacity: .8; }
.pill { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #1a1420cc; color: var(--amber); cursor: pointer; backdrop-filter: blur(4px); }
.pill:hover { background: #2b1a2ccc; } .pill[aria-pressed="true"] { background: #5a3418cc; border-color: #f6c98bcc; }

/* where you are */
#place { position: fixed; left: 10px; top: 8px; max-width: min(70vw, 460px); text-shadow: 0 1px 4px #000c; pointer-events: none;
  padding: 6px 12px 8px; border-radius: 14px; background: radial-gradient(ellipse at 30% 40%, #0b1220c4, #0b122088 70%, #0b122000); }
#place .crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumb { background: none; border: 0; padding: 2px 0; font-size: 17px; letter-spacing: .01em; color: var(--ink); pointer-events: auto; }
button.crumb { cursor: default; }
button.crumb.link { cursor: pointer; color: var(--amber); text-decoration: underline dotted; text-underline-offset: 4px; }
/* on touch screens each part of the trail is a finger-sized target */
@media (pointer: coarse) { button.crumb { min-height: 40px; padding: 8px 6px; } #place .crumbs { gap: 2px; } }
.crumb.here::before { content: '›'; margin-right: 6px; color: var(--dim); }
#place-detail { color: var(--dim); font-size: 13px; }
#aim { margin-top: 6px; min-height: 1.4em; font-size: 14px; color: var(--amber); }
#aim .cue { font-style: italic; margin-left: 6px; }
#reticle { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #f6dcae99; box-shadow: 0 0 8px #f6c98b; pointer-events: none; display: none; }
body.touch #reticle { display: block; }

#buttons { position: fixed; right: 12px; top: 10px; display: flex; gap: 8px; z-index: 5; }

/* hunt */
#hunt { position: fixed; right: 12px; top: 58px; width: 170px; display: none; text-align: right; text-shadow: 0 1px 4px #000c; pointer-events: none; }
#hunt.on { display: block; }
#hunt .target { position: relative; display: inline-block; padding: 5px; border-radius: 10px; background: #efe6d2; box-shadow: 0 0 0 1px #f6c98b, 0 0 22px #f6a54a66; transform: rotate(2deg); }
#hunt img { display: block; max-width: 120px; max-height: 120px; min-width: 40px; min-height: 40px; border-radius: 5px; }
#hunt-timer { position: absolute; left: -6px; bottom: -8px; background: var(--plum); color: var(--amber); border-radius: 999px; padding: 1px 8px; font-size: 12px; border: 1px solid var(--line); }
#hunt-note { margin-top: 10px; font-size: 12.5px; color: var(--ink); }
#hunt.found #hunt-timer { display: none; }
#hunt.found .target { box-shadow: 0 0 0 2px #ffd88f, 0 0 40px #ffb85a; }
#hunt-next { margin-top: 8px; pointer-events: auto; }
#ember-wrap { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
body.hunting #ember-wrap { display: flex; }
#ember-word { font-style: italic; font-size: 15px; text-shadow: 0 1px 4px #000; color: var(--ink); white-space: nowrap; }
#ember { --heat: .1; --hue: 48; --sat: 18%; --beat: 1.4s; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 18%, hsl(var(--hue) var(--sat) 66%) 40%, transparent 70%);
  box-shadow: 0 0 calc(8px + 46px * var(--heat)) calc(2px + 16px * var(--heat)) hsl(var(--hue) var(--sat) 60% / calc(.35 + .65 * var(--heat)));
  opacity: calc(.45 + .55 * var(--heat)); transform: scale(calc(.6 + .9 * var(--heat))); animation: beat var(--beat) ease-in-out infinite; }
#ember.flare { animation: flare .5s ease-out, beat var(--beat) ease-in-out .5s infinite; }
@keyframes beat { 50% { filter: brightness(1.35); } }
@keyframes flare { 0% { filter: brightness(2.6); } 100% { filter: brightness(1); } }

/* knobs */
#knobs { position: fixed; right: 12px; top: 56px; bottom: 12px; width: 268px; display: none; overflow: auto; z-index: 4;
  background: #14101cd9; border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); padding: 4px 14px 12px; box-sizing: border-box; font-size: 12.5px; }
#knobs.open { display: block; }
#knobs.open ~ #hunt, body.knobs-open #hunt { right: 292px; }
#knobs h3 { margin: 14px 0 4px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); font-weight: normal; }
.knob { display: grid; grid-template-columns: 96px 1fr 34px; align-items: center; column-gap: 8px; padding: 3px 0; }
.knob small { grid-column: 2 / 4; color: #8f897c; font-size: 11px; line-height: 1.2; }
.knob output { text-align: right; font: 11px ui-monospace, monospace; color: var(--dim); }
.knob input[type=range] { width: 100%; accent-color: #f0b267; margin: 0; }
.knob select { grid-column: 2 / 4; background: #241a2c; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; font: inherit; }
.knob-toggle input { justify-self: start; accent-color: #f0b267; width: 16px; height: 16px; margin: 0; }
.knob-foot { display: flex; gap: 8px; margin-top: 14px; }
.knob-foot button { flex: 1; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: #241a2c; cursor: pointer; }

#stats { position: fixed; left: 14px; bottom: 44px; margin: 0; font: 11px/1.45 ui-monospace, monospace; color: #cfe0ff; background: #0b1220b8; padding: 6px 9px; border-radius: 8px; pointer-events: none; white-space: pre; }
#help { position: fixed; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 10px; background: #0b122099; max-width: min(60vw, 560px); color: var(--dim); font-size: 13px; text-shadow: 0 1px 3px #000c; pointer-events: none; transition: opacity .8s; }
#help.gone { opacity: 0; }
#stick { position: fixed; left: 26px; bottom: 30px; width: 84px; height: 84px; border-radius: 50%; border: 1px dashed #f6c98b66; box-shadow: inset 0 0 18px #f6c98b22; display: none; pointer-events: none; }
#stick::after { content: 'move'; position: absolute; inset: 0; display: grid; place-items: center; color: #f6c98b99; font-size: 12px; }
body.touch #stick { display: block; } body.touch #help { left: 130px; bottom: 44px; max-width: 46vw; }
#exit { position: fixed; right: 14px; bottom: 16px; display: none; z-index: 3; }
body.inside #exit, body.nested #exit { display: block; }
body.touch #exit kbd { display: none; }

/* an opened leaf */
#sheet { position: fixed; inset: 0; display: none; flex-direction: column; background: radial-gradient(ellipse at 50% 40%, #2b1320d9, #0d0710f2); z-index: 10; }
#sheet.open { display: flex; }
#sheet header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--amber); }
#sheet .spread { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; justify-content: center; gap: 18px 16px; padding: 10px 18px 60px; }
.card { --tilt: 0deg; position: relative; width: clamp(104px, 21vw, 180px); aspect-ratio: 1; padding: 6px; border: 0; border-radius: 8px; background: #efe6d2; cursor: zoom-in;
  transform: rotate(var(--tilt)); box-shadow: 0 6px 18px #0009; transition: transform .25s, box-shadow .25s, opacity .25s; display: grid; place-items: center; }
.card img { max-width: 100%; max-height: 100%; opacity: 0; transition: opacity .3s; border-radius: 3px; }
.card.ready img { opacity: 1; }
.card.missing::after { content: 'unavailable'; color: #7a6d5c; font-size: 11px; }
.card:hover { transform: rotate(0) scale(1.05); box-shadow: 0 0 0 2px var(--amber), 0 8px 26px #000c; }
.card.at { box-shadow: 0 0 0 2px var(--amber), 0 8px 26px #000c; }
/* the viewer: one image, large, over the sheet */
#sheet .viewer { position: absolute; inset: 0; z-index: 3; background: rgba(8, 5, 10, .93); touch-action: none; animation: viewer-in .16s ease-out; }
#sheet .viewer.going { opacity: 0; transition: opacity .16s; pointer-events: none; }
@keyframes viewer-in { from { opacity: 0; } }
.viewer .frame.card.held { position: absolute; left: 50%; top: calc(50% - 44px); width: min(92vw, calc(100vh - 210px), 680px); height: min(92vw, calc(100vh - 210px), 680px); box-sizing: border-box;   /* square whatever the picture's shape; room below for the caption and the count */ cursor: default; transform: translate(-50%, -50%); transition: transform .22s cubic-bezier(.2, .9, .3, 1), opacity .18s; box-shadow: 0 0 0 2px var(--amber), 0 0 80px #000; touch-action: none; }
.viewer .frame.card.held:hover { transform: translate(-50%, -50%); }
.viewer .frame img { position: absolute; inset: 0; margin: 0; padding: 6px; box-sizing: border-box; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; opacity: 1; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.viewer .count { position: absolute; left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); text-align: center; color: var(--dim); font-size: 14px; pointer-events: none; }
.viewer .info { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 24px); width: min(92vw, 680px); min-height: 3.9em; text-align: center; color: var(--dim); font-size: 13px; line-height: 1.3; pointer-events: none; }
.viewer .info div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .viewer .info .title { color: var(--ink); }
.viewer .info a { color: var(--amber); pointer-events: auto; text-decoration: underline; text-underline-offset: 2px; }
.viewer .x { position: absolute; right: 14px; top: 12px; width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 72px; border: 0; border-radius: 10px; background: #1a142099; color: var(--amber); font-size: 30px; cursor: pointer; }
.viewer .nav:disabled { opacity: .2; cursor: default; } .viewer .prev { left: 8px; } .viewer .next { right: 8px; }
@media (pointer: coarse) { .viewer .nav { display: none; } }
#sheet { transition: transform .22s cubic-bezier(.2, .9, .3, 1), opacity .22s; }
#sheet .spread { overscroll-behavior: contain; }
#sheet header .grab { display: none; }
@media (pointer: coarse) { #sheet header { position: relative; padding-top: 20px; touch-action: none; } #sheet header .grab { display: block; position: absolute; left: 50%; top: 7px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: #f3c98b66; } }
.card.held img { width: 100%; height: 100%; object-fit: contain; }
.card.held.hit { box-shadow: 0 0 0 4px #ffd88f, 0 0 90px #ffb85a; }
.card.held.miss { animation: shake .35s; }
@keyframes shake { 25% { margin-left: -8px; } 75% { margin-left: 8px; } }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: #2b1320e6; border: 1px solid var(--line); color: var(--ink); opacity: 0; transition: opacity .4s; pointer-events: none; z-index: 12; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#toast.show { opacity: 1; }
#loading { position: fixed; left: 0; right: 0; top: 38%; text-align: center; font-style: italic; color: var(--amber); pointer-events: none; z-index: 20; transition: opacity .6s; text-shadow: 0 1px 4px #000; }   /* no curtain: space shows while the world loads */
/* the loading bar, just under the ship */
#progress { position: fixed; right: calc(50% + min(11vw, 84px)); top: calc(50% + min(17.5vh, 150px)); width: min(26vw, 150px);   /* beside the ship, clear of the tag under it and the beam ahead of it */ z-index: 6; pointer-events: none; opacity: 0; transition: opacity .5s; text-align: right; }
#progress.show { opacity: 1; }
#progress .bar { height: 3px; border-radius: 2px; background: #6fe3ff2e; overflow: hidden; box-shadow: 0 0 8px #000; }
#progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6fe3ff, #ffb347); transition: width .35s ease-out; }
#progress span { display: block; margin-top: 6px; font: 11px/1.2 'Eurostile', 'Bank Gothic', 'Share Tech Mono', ui-monospace, Menlo, monospace; letter-spacing: .14em; text-transform: uppercase; color: #9fe9ff; text-shadow: 0 1px 3px #000; }
#loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 700px) {
  #place { max-width: 58vw; } .crumb { font-size: 15px; }
  #knobs { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 58vh; }
  body.knobs-open #hunt { right: 12px; }
  #hunt { width: 120px; } #hunt img { max-width: 84px; max-height: 84px; }
  #stats { bottom: auto; top: 96px; left: 10px; font-size: 10px; }
  #ember-wrap { bottom: 132px; }
  body.touch #help { left: 124px; bottom: 30px; max-width: 58vw; font-size: 12px; }
}

/* ---- cluster prototype additions (everything above is experiments/grid/style.css, kept identical on purpose) ---- */
#bundles { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); display: flex; z-index: 5; border: 1px solid var(--line); border-radius: 999px; background: #1a1420cc; backdrop-filter: blur(4px); overflow: hidden; }
#bundles button { border: 0; background: none; padding: 8px 14px; color: var(--dim); cursor: pointer; white-space: nowrap; }
#bundles button + button { border-left: 1px solid var(--line); }
#bundles button:hover { color: var(--ink); }
#bundles button[aria-checked="true"] { background: #5a3418cc; color: var(--amber); }
#bundles button small { opacity: .7; margin-left: 5px; font-size: 11px; }
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, 0); font-style: italic; font-size: 13px; color: #e9dfc8; text-shadow: 0 1px 3px #000, 0 0 8px #0b1220; white-space: nowrap; opacity: 0; transition: opacity .35s; will-change: transform; }
.tag.kin { color: var(--amber); }
.tag.aimed { color: #fff3d6; font-size: 14px; }
.tag small { font-style: normal; opacity: .7; margin-left: 5px; font-size: 11px; }
body.sheet-open #tags, body.sheet-open #bundles { display: none; }
body.inside #bundles, body.travelling #bundles { opacity: .0; pointer-events: none; }
#bundles { transition: opacity .4s; }
#knobs .knob[data-key="world"] select { border-color: #f6c98bcc; color: var(--amber); }
#knobs .knob.off { opacity: .4; }

@media (max-width: 900px) {
  #bundles { top: 8px; font-size: 12.5px; }
  #bundles button { padding: 6px 11px; } #bundles button small { display: none; }
  #place { top: 46px; } #buttons { top: 50px; } #hunt { top: 98px; } #knobs { top: 96px; }
  body.inside #place, body.travelling #place { top: 8px; } body.inside #buttons, body.travelling #buttons { top: 10px; } body.inside #hunt, body.travelling #hunt { top: 58px; }
  .tag { font-size: 12px; }
}
@media (max-width: 700px) {
  #place { max-width: 56vw; }
  #place-detail { font-size: 12px; }
  body.touch #help { max-width: 40vw; }
  #knobs { top: auto; }
}

/* phone: rise / descend (the shared fly controls have keys for it but no touch control) */
#lift { position: fixed; right: 14px; bottom: 76px; display: none; flex-direction: column; gap: 8px; z-index: 3; }
body.touch #lift { display: flex; }
#lift button { width: 46px; height: 46px; border-radius: 50%; border: 1px dashed #f6c98b66; background: #1a142066; color: #f6c98bcc; font-size: 15px; touch-action: none; user-select: none; -webkit-user-select: none; }
#lift button.down { background: #5a3418cc; }
body.sheet-open #lift { display: none; }
/* seven worlds and three pills no longer fit one row: the world switch sits on its own line under the pills on narrow desktops */
@media (min-width: 701px) and (max-width: 1500px) { #bundles { top: auto; bottom: 12px; left: auto; right: 12px; transform: none; max-width: calc(100vw - 24px); overflow-x: auto; } body.knobs-open #bundles { right: 292px; max-width: calc(100vw - 304px); } }

/* search: a panel under the top bar; results are a strip of pictures, grouped by the cluster each one lives in */
#find { position: fixed; left: 50%; top: 58px; transform: translateX(-50%); width: min(760px, calc(100vw - 20px)); z-index: 6; padding: 10px 12px 12px; border-radius: 14px; border: 1px solid var(--line); background: #140f19ee; backdrop-filter: blur(6px); }
#find[hidden] { display: none; }
#find-form { display: flex; gap: 8px; }
#find-q { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: #0b0a10; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; outline: none; }
#find-q:focus { border-color: #f6c98bcc; }
#find-note { color: var(--dim); font-size: 13px; margin-top: 8px; min-height: 1.3em; }
#find-where { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; max-height: 5.4em; overflow: auto; }
#find-where button { font: inherit; font-size: 13px; color: var(--amber); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; cursor: pointer; }
#find-where button[aria-pressed="true"] { background: #5a3418cc; }
#find-results { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; }
#find-results:empty { display: none; }
#find-results button { flex: none; width: 92px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: #efe6d2; cursor: pointer; overflow: hidden; }
#find-results button:hover, #find-results button:focus-visible { border-color: var(--amber); }
#find-results button.off { opacity: .25; }
#find-results img { display: block; width: 88px; height: 88px; object-fit: cover; }
body.sheet-open #find { display: none; }
#sheet .card.found { outline: 3px solid var(--amber); outline-offset: 3px; box-shadow: 0 0 34px #f6a54acc; }
@media (max-width: 700px) { #find { top: 96px; } #find-results button { width: 76px; } #find-results img { width: 72px; height: 72px; } }

/* peek: pictures that pop out of the leaf you point at */
#peek { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
body.sheet-open #peek { display: none; }
.peek-card { position: absolute; left: 0; top: 0; padding: 5px; border-radius: 7px; background: #efe6d2; box-shadow: 0 8px 26px #000b; overflow: hidden;
  transform: translate(var(--x0), var(--y0)) scale(.12) rotate(0deg); opacity: 0; transition: transform var(--ms) cubic-bezier(.5, 0, .9, .5), opacity var(--ms); will-change: transform; }
.peek-ring.out .peek-card { transform: translate(var(--x), var(--y)) scale(1) rotate(var(--tilt)); opacity: 1; transition: transform var(--ms) cubic-bezier(.2, 1.35, .4, 1) var(--d), opacity 90ms var(--d); }
.peek-card i, .peek-card img { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); border-radius: 3px; }
.peek-card i { background-repeat: no-repeat; image-rendering: auto; }
.peek-card img { object-fit: cover; opacity: 0; transition: opacity .15s; } .peek-card.sharp img { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .peek-card, .peek-ring.out .peek-card { transition: opacity 80ms; transform: translate(var(--x), var(--y)); } }

/* the row of worlds is gone from the screen: the world is chosen from the knobs (clustering), or with keys 1-9, 0 */
#bundles { display: none !important; }
/* `grow back out` stays reachable when the knobs are open beside it */
@media (min-width: 701px) { body.knobs-open #exit { right: 292px; } }

/* a game surface, not a document: nothing selects, nothing calls up the copy menu, and the page never zooms.
   (iPad Safari ignores user-scalable=no; pinch and double-tap zoom are also stopped in main.js.) */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }
img { -webkit-user-drag: none; }
.pill.icon { padding: 7px 9px; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }

/* settings: the world picker, and an experimental world's own section; every other knob is behind 'all knobs' */
#knobs:not(.all) .adv { display: none; }
#knobs .exp { margin: 12px 0 6px; padding-top: 4px; border-top: 1px solid var(--line); }
#knobs .exp-note { margin: 2px 0 10px; font-size: 12px; line-height: 1.35; color: var(--dim); }
#knobs .exp-row { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 7px 0; border-top: 1px solid #ffffff10; }
#knobs .exp-row.sub { padding-left: 12px; }
#knobs .exp-row.none { opacity: .45; }
#knobs .exp-name b { display: block; font-weight: normal; font-size: 13px; color: var(--ink); }
#knobs .exp-name small { display: block; font-size: 11px; color: var(--dim); }
#knobs .exp-ctl { display: flex; align-items: center; gap: 8px; }
#knobs .exp-ctl input[type=range] { flex: 1; min-width: 0; }
#knobs .exp-lit, #knobs .exp-reset { border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--dim); font: inherit; font-size: 11.5px; padding: 3px 9px; cursor: pointer; white-space: nowrap; }
#knobs .exp-lit[aria-pressed=true] { color: #1a1206; background: var(--amber); border-color: var(--amber); }
#knobs .exp-reset { margin-top: 8px; }

#knobs .to2d { display: block; margin: 14px 0 4px; padding: 10px 0; color: var(--amber); text-decoration: none; font-size: 13px; letter-spacing: .06em; border-top: 1px solid #ffffff1f; }
#knobs .to2d:hover { text-decoration: underline; }
