/* Simplified phone layout: one card at the bottom, two small buttons, nothing else on top of the town. */
:root { --felt: #3b2f4a; --felt2: #4a3a5c; --thread: #f3c97a; --ink: #fdf3e1; --pink: #f4a7b9; --muted: #c9b8d8; --night: #1d1a2e; color-scheme: dark; }
* { box-sizing: border-box; }
/* Anything marked hidden stays hidden, even if its class sets display (the X buttons, the places menu, the card details) */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink);
  font: 15px/1.35 ui-rounded, "Trebuchet MS", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: auto; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
/* No long-press menus or text selection on the game's buttons and cards */
.round, .pill, .card, .places, .x { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Close buttons: always a 44px target */
.x { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--felt2); color: var(--ink); }
.x:active { background: var(--thread); color: var(--felt); }
:focus-visible { outline: 3px solid var(--thread); outline-offset: 2px; }

/* Stitched felt patches */
.patch { background: var(--felt); border: 2px dashed var(--thread); border-radius: 14px; box-shadow: 0 0 0 4px var(--felt), 0 6px 18px #0008; padding: 8px 12px; }
.round { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  background: var(--felt); color: var(--thread); border: 2px dashed var(--thread); box-shadow: 0 0 0 4px var(--felt), 0 6px 18px #0008; }
.pill { min-height: 44px; border: 0; border-radius: 999px; padding: 10px 18px; font-weight: 700; background: var(--thread); color: var(--felt); box-shadow: 0 4px 12px #0007; }

/* Top */
.map { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(18px + env(safe-area-inset-right, 0px)); }
/* Top bar: "Back to Bobbin", "Go inside" / "Back outside", between the postcard button (left) and the map (right) */
.topbar { position: fixed; top: calc(18px + env(safe-area-inset-top, 0px)); left: calc(86px + env(safe-area-inset-left, 0px)); right: calc(86px + env(safe-area-inset-right, 0px));
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.back { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.door-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; background: var(--pink); }
.round, .pill, .card, .places, .x, .info { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.places { overscroll-behavior: contain; position: fixed; top: calc(78px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); width: min(260px, calc(100vw - 32px)); display: grid; gap: 2px; padding: 8px; max-height: 60vh; overflow-y: auto; }
.places button { min-height: 44px; text-align: left; background: none; border: 0; border-radius: 10px; padding: 10px; color: var(--ink); }
.places .places-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 4px 10px; font-weight: 700; color: var(--thread); }
.places .places-head .x { min-height: 0; padding: 0; text-align: center; background: var(--felt2); }
.places button:active, .places button:hover { background: var(--felt2); }
.places .who { color: var(--pink); font-weight: 700; }
.places hr { border: 0; border-top: 1px dashed var(--muted); opacity: .4; margin: 4px 6px; width: auto; }

.hint { position: fixed; left: 50%; top: 42%; transform: translateX(-50%); background: #0007; color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 13px; white-space: nowrap; pointer-events: none; transition: opacity .6s; }
.hint.gone { opacity: 0; }

/* Speech bubble over Bobbin's head */
.bubble { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -100%); max-width: min(78vw, 340px);
  background: var(--ink); color: var(--felt); border-radius: 14px; padding: 8px 12px; font-size: 14px; box-shadow: 0 4px 12px #0007; pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -8px; border: 8px solid transparent; border-top-color: var(--ink); border-bottom: 0; transform: translateX(-50%); }

/* Bottom: sits above Netlify's "Powered by Netlify" badge in the bottom corner */
.bottom { position: fixed; left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: flex-end; gap: 12px; }
.card { position: relative; flex: 1; min-width: 0; padding: 0; }
.card-head { display: grid; gap: 2px; width: 100%; min-height: 56px; text-align: left; background: none; border: 0; border-radius: 12px; padding: 8px 12px; color: var(--ink); }
.grab { display: none; justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--muted); opacity: .6; margin-bottom: 4px; }
.card.open .grab { display: block; }
.card.open .card-head { touch-action: none; padding-right: 60px; } /* swipe down on the header to close */
.card.open .chev { display: none; }
.card-x { position: absolute; top: 6px; right: 6px; }
.card-row { display: flex; align-items: baseline; gap: 8px; }
.name { font-weight: 700; font-size: 18px; color: var(--pink); }
.mood { font-size: 12px; font-weight: 700; color: var(--felt); background: var(--pink); border-radius: 999px; padding: 1px 8px; }
.day { margin-left: auto; font-size: 13px; color: var(--muted); }
.chev { color: var(--thread); transition: transform .2s; }
.doing { display: block; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.open .doing { white-space: normal; }
.more { display: grid; gap: 8px; margin: 0 12px; padding: 8px 0 10px; border-top: 1px dashed #c9b8d855;
  max-height: calc(100vh - 290px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain; }
.card { transition: transform .15s; }
.needs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 12px; }
.need { display: flex; align-items: center; gap: 6px; }
.need span { width: 44px; color: var(--muted); }
.need i { flex: 1; height: 7px; background: #0004; border-radius: 4px; overflow: hidden; }
.need b { display: block; height: 100%; width: 50%; background: var(--thread); transition: width 1s; }
.small { font-size: 13px; color: var(--muted); }
.pinned { display: flex; gap: 6px; overflow-x: auto; }
.pinned:empty { display: none; }
.pinned div { flex: 0 0 auto; max-width: 70vw; background: var(--felt2); border-radius: 8px; padding: 4px 8px; font-size: 12px; color: var(--muted); }
.bottle { flex: 0 0 auto; }

/* Note dialog */
.stitch-btn { min-height: 44px; font: inherit; font-weight: 700; color: var(--felt); background: var(--thread); border: 2px dashed var(--felt); border-radius: 12px; padding: 10px 14px; }
/* Sits near the top so the phone keyboard doesn't cover it; tap the dark area or the X to close */
dialog { color: var(--ink); width: min(92vw, 420px); margin: calc(16px + env(safe-area-inset-top, 0px)) auto auto; }
.dlg-head { display: flex; align-items: center; gap: 10px; }
.dlg-head label { flex: 1; }
dialog::backdrop { background: #0008; }
textarea { width: 100%; margin: 8px 0; font: inherit; border-radius: 8px; border: 0; padding: 8px; background: var(--ink); color: var(--felt); }
.row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.row span { flex: 1; font-size: 13px; color: var(--muted); }
/* Message in a bottle: the email opt-in and the visitor's own bottles */
.bottle-fine { margin: 0 0 8px; }
.mail-opt { margin: 0 0 8px; }
.tick { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; }
.tick input { width: 20px; height: 20px; accent-color: var(--thread); }
.mail-opt input[type=email] { width: 100%; font: inherit; border-radius: 8px; border: 0; padding: 8px; margin: 4px 0; background: var(--ink); color: var(--felt); }
.mail-opt .small { margin: 4px 0 0; }
.my-bottles { margin-top: 10px; border-top: 2px dashed var(--thread); padding-top: 8px; }
.my-bottles h3 { margin: 0 0 6px; font-size: 14px; }
.my-bottles ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 32vh; overflow-y: auto; }
.my-bottles li { background: var(--felt2); border-radius: 8px; padding: 6px 8px; font-size: 13px; }
.my-bottles li b { display: block; font-weight: 600; }
.my-bottles li q { display: block; margin-top: 4px; font-style: italic; }
.pinned div q { display: block; margin-top: 2px; font-style: italic; color: var(--ink); }
/* What you tapped inside the house: sits over Bobbin's card so the thing you tapped stays in view above it */
.info { position: fixed; z-index: 5; left: calc(16px + env(safe-area-inset-left, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 12px 14px; }
.info-head { display: flex; align-items: center; gap: 10px; }
.info-head h2 { flex: 1; margin: 0; font-size: 17px; color: var(--pink); }
.info-body { padding-right: 6px; }
.info-body p { margin: 6px 0 0; }
.info-body ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.info-body li { margin: 5px 0; }
/* The quilt gallery: one quilt at a time, with buttons to flip through */
.gallery-open { display: block; margin: 10px 0 0; }
.gallery-pic { display: block; width: min(220px, 56vw, 26vh); height: auto; aspect-ratio: 1; margin: 6px auto 0; border-radius: 6px; box-shadow: 0 4px 12px #0007; image-rendering: pixelated; }
.gallery-cap { text-align: center; font-size: 14px; color: var(--muted); }
.gallery-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.gallery-nav .pill { min-width: 56px; font-size: 22px; line-height: 1; padding: 8px 14px; }
.gallery-nav .pill:disabled { opacity: .4; }
.gallery-nav span { font-size: 14px; color: var(--muted); min-width: 64px; text-align: center; }
/* A quick dip to dark when stepping in or out */
.fade { position: fixed; inset: 0; z-index: 20; background: var(--night); opacity: 0; pointer-events: none; transition: opacity .22s; }
.fade.on { opacity: 1; }
.demo { position: fixed; left: 50%; bottom: calc(4px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); font-size: 11px; color: var(--muted); opacity: .7; white-space: nowrap; }
.hint { max-width: calc(100vw - 32px); white-space: normal; text-align: center; }
@media (prefers-reduced-motion: reduce) { .hint, .chev, .need b, .card, .fade { transition: none; } }

/* "But then" errands on Bobbin's card: a patch pinned on the cloth, and the latest stitch of the story */
.errand { display: grid; gap: 2px; background: var(--felt2); border: 2px dashed #f3c97a66; border-radius: 10px; padding: 6px 10px; min-width: 0; }
.errand-k { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--thread); }
.errand-goal { font-weight: 700; line-height: 1.3; }
.errand-story { font-size: 13px; color: var(--pink); font-style: italic; line-height: 1.35; }
.errand-story:empty, #errand-why:empty { display: none; }
/* Lake encounters: what turned up on the water, on its own little patch */
.lake { display: grid; gap: 2px; background: var(--felt2); border: 2px dashed #9fd4f066; border-radius: 10px; padding: 6px 10px; min-width: 0; }
.lake .errand-k { color: #9fd4f0; }
.lake-text { font-size: 13px; line-height: 1.35; }
.hint.lake-hint { border-radius: 14px; max-width: min(420px, calc(100vw - 32px)); }

/* Living map: the compass opens Bobbin's stitched map, sized to fit above the closed card on a phone */
.places { width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 210px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
.places .places-who { display: flex; gap: 6px; }
.places .places-who button { flex: 1; text-align: center; background: var(--felt2); }
.living-map { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 10px; background:
  repeating-linear-gradient(0deg, #ffffff09 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, #ffffff09 0 1px, transparent 1px 4px), #1b2742; }
.living-map .lbl { font-size: 13px; font-weight: 700; fill: #f1e7d0; paint-order: stroke; stroke: #1b2742; stroke-width: 4px; }
.living-map .place { cursor: pointer; }
.living-map .place:focus { outline: none; }
.living-map .place:focus-visible .knot, .living-map .place:active .knot { fill: #ecc45e; }
.map-key { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--muted); padding: 2px 4px 0; }
.map-key span::before { content: ""; display: inline-block; width: 14px; border-top: 3px dashed currentColor; margin-right: 5px; vertical-align: middle; }
.map-key .k-water { color: #7db8ea; } .map-key .k-path { color: #92d18a; } .map-key .k-trouble { color: #ef5d55; } .map-key .k-old { color: #f1e7d0aa; }

/* Postcard button (top left, across from the places button) and its sheet */
.postcard-btn { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); left: calc(18px + env(safe-area-inset-left, 0px)); }
.postcard-btn.busy { opacity: .6; }
.pc-dlg { width: min(94vw, 420px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.pc-title { flex: 1; font-weight: 700; color: var(--thread); }
.pc-img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; margin: 8px 0 6px; border-radius: 8px; background: var(--night); -webkit-touch-callout: default; }
.pc-stage { position: relative; touch-action: pan-y; }
.pc-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #3b2f4ad9; color: #fdf3e1; cursor: pointer; box-shadow: 0 2px 8px #0006; }
.pc-nav:disabled { opacity: .3; cursor: default; }
.pc-nav:focus-visible { outline: 3px solid var(--thread); outline-offset: 2px; }
.pc-prev { left: 8px; } .pc-next { right: 8px; }
.pc-count { margin: 0 0 2px; min-height: 1.2em; font-size: 13px; font-weight: 700; color: var(--thread); text-align: center; }
.pc-stamps { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-align: center; }
.pc-stamps b { color: var(--pink); letter-spacing: 2px; }
.pc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.pc-actions .stitch-btn { flex: 1 1 100%; }
.pc-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; background: none; border: 0; color: var(--thread); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.pc-msg { margin: 6px 0 0; min-height: 1.3em; font-size: 13px; color: var(--muted); }

/* Sound button, under the postcard button */
.sound-btn { position: fixed; top: calc(80px + env(safe-area-inset-top, 0px)); left: calc(18px + env(safe-area-inset-left, 0px)); }
.sound-btn .snd-on { display: none; }
.sound-btn[aria-pressed="true"] .snd-on { display: inline; }
.sound-btn[aria-pressed="true"] .snd-off { display: none; }

/* Send Bobbin a picture */
.pic-btn { flex: 0 0 auto; }
.pic-title { flex: 1; font-weight: 700; color: var(--thread); }
.pic-tips { margin: 6px 0 8px; color: var(--muted); font-size: 13px; }
.pic-stage { display: grid; place-items: center; }
.pic-canvas { width: min(60vw, 240px); height: auto; aspect-ratio: 1; border-radius: 10px; background: var(--felt2); margin-bottom: 8px; }
.pic-pick { display: inline-flex; align-items: center; margin-right: auto; }
.pic-dlg .stitch-btn:disabled { opacity: .5; }
.pic-msg { min-height: 1.3em; margin: 8px 0 0; font-size: 14px; }
.pic-mine { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
