:root {
  --ink: #fdf3e6;
  --dim: rgba(253, 243, 230, 0.72);
  --gold: #ffc98a;
  --panel: rgba(22, 16, 38, 0.74);
  --line: rgba(255, 228, 196, 0.16);
  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --hand: "Bradley Hand", "Noteworthy", "Segoe Print", "Dancing Script", "Comic Sans MS", cursive;
  --top: max(14px, env(safe-area-inset-top));
  --bottom: max(18px, env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: var(--font);
  /* the dusk sky, so there is something to see before the first frame is drawn */
  background: linear-gradient(180deg, #080c22 0%, #1b1740 30%, #5b3052 52%, #c9603f 62%, #2b2330 63%, #1f1a1c 100%);
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; left: 50%; top: 50%; width: 100vw; height: 100vh; transform: translate(-50%, -50%); overflow: hidden; }
/* #gl is the touch layer: nothing is drawn on it. The shore is drawn on a canvas placed under it (3D, or the flat one when 3D is not to be had). */
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
canvas.draw { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#veil { position: absolute; inset: 0; background: #0b0a18; pointer-events: none; opacity: 1; transition: opacity 1.4s ease; }
#veil.up { opacity: 0; }

/* What to do next: one line, always in the same place */
#hint {
  position: absolute; left: 50%; bottom: calc(var(--bottom) + 22px); transform: translateX(-50%);
  width: max-content; max-width: 88%; padding: 12px 20px; border-radius: 22px; text-align: center;
  font-size: 17px; line-height: 1.3; letter-spacing: 0.01em; text-wrap: balance;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0; transition: opacity 0.6s ease; pointer-events: none;
}
#hint.show { opacity: 1; }
/* drops of sea water when the cork comes out */
.drop { position: absolute; border-radius: 50%; background: rgba(255, 244, 230, 0.92); box-shadow: 0 0 6px rgba(255, 220, 180, 0.7); pointer-events: none; z-index: 2; }
/* Dawn is bright: the first words and the skip link turn dark so they can be read against it */
[data-mood=dawn] #hint.big { color: #35233c; font-weight: 400; text-shadow: 0 1px 18px rgba(255, 250, 240, 0.9); }
[data-mood=dawn] #skip { color: #35233c; }
#hint.big { font-size: clamp(24px, 7vmin, 34px); font-weight: 300; background: none; border-color: transparent; box-shadow: none; bottom: 46%; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.75); animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.62; } }
/* said while a bottle is cast out: lower down, so it does not sit on the bottle going */
#hint.big.low { bottom: 20%; }

/* A ghost finger that shows the move when someone hesitates */
#finger {
  position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  border: 2px solid rgba(255, 240, 220, 0.9); background: rgba(255, 240, 220, 0.18); box-shadow: 0 0 22px rgba(255, 220, 180, 0.5);
  opacity: 0; pointer-events: none; will-change: transform, opacity;
}
#skip { position: absolute; right: 12px; top: var(--top); appearance: none; border: 0; background: none; color: var(--dim); font: inherit; font-size: 13px; padding: 10px; text-decoration: underline; text-underline-offset: 3px; opacity: 0; pointer-events: none; transition: opacity 1s; cursor: pointer; }
#skip.show { opacity: 0.85; pointer-events: auto; }

/* The note */
#letter { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 22px; overflow-y: auto; touch-action: pan-y; scrollbar-width: none; padding: calc(var(--top) + 8px) 6% calc(var(--bottom) + 8px); opacity: 0; pointer-events: none; }
#letter.show { opacity: 1; pointer-events: auto; }
#paper {
  position: relative; width: min(100%, 440px); max-height: 76%; overflow-y: auto; padding: 34px 30px 30px; border-radius: 3px;
  color: #3a2616; font-family: var(--hand); font-size: clamp(21px, 5.6vmin, 27px); line-height: 1.5;
  background:
    radial-gradient(120% 90% at 20% 10%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    repeating-linear-gradient(92deg, rgba(120, 90, 50, 0.035) 0 2px, rgba(255, 255, 255, 0) 2px 7px),
    linear-gradient(175deg, #f6ead0, #ead8b4 60%, #dcc59a);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), inset 0 0 50px rgba(150, 110, 60, 0.28), inset 0 -14px 18px -10px rgba(90, 60, 30, 0.35), inset 0 14px 18px -10px rgba(90, 60, 30, 0.30);
  transform-origin: 50% 0; clip-path: inset(0 0 100% 0); touch-action: pan-y; scrollbar-width: none;
  -webkit-user-select: text; user-select: text;
}
#paper::-webkit-scrollbar, #letter::-webkit-scrollbar { display: none; }
/* The paper is never squeezed by what is under it. Together they sit in the middle when they fit, and the page scrolls when they do not. */
#paper { flex: none; margin-top: auto; }
#after { flex: none; margin-bottom: auto; }
#letter.show #paper { animation: unroll 1.7s cubic-bezier(0.25, 0.8, 0.25, 1) 0.15s forwards; }
@keyframes unroll {
  0% { clip-path: inset(0 0 100% 0); transform: perspective(900px) rotateX(-28deg) scale(0.92); }
  100% { clip-path: inset(0 0 0 0); transform: none; }
}
#words { white-space: pre-wrap; overflow-wrap: anywhere; }
/* a picture that came in the bottle: on the paper, above the words. A tap shows it larger. */
#picWrap { display: none; margin: 0 0 16px; }
#picWrap.on { display: block; }
/* It is kept small, like a print slipped in with the letter, so the words and the buttons under them are never crowded out. */
#pic { display: none; width: auto; height: auto; max-width: 100%; max-height: min(26vh, 220px); margin: 0 auto; padding: 5px; border-radius: 2px; background: #fdfaf2; box-shadow: 0 3px 12px rgba(60, 40, 20, 0.40); transform: rotate(-1.2deg); cursor: zoom-in; opacity: 0; transition: opacity 0.8s ease; }
#picWrap.got #pic { display: block; opacity: 1; }
#picHint { display: none; font-family: var(--font); font-size: 12.5px; line-height: 1.3; opacity: 0.6; text-align: center; margin-top: 9px; }
#picWrap.got #picHint { display: block; }
#picNote { font-family: var(--font); font-size: 14px; line-height: 1.4; opacity: 0.7; padding: 18px 8px; text-align: center; border: 1px dashed rgba(90, 60, 30, 0.35); border-radius: 2px; }
#picWrap.got #picNote { display: none; }
#picBig { position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; background: rgba(8, 6, 16, 0.94); cursor: zoom-out; }
#picBig.show { display: flex; }
#picBigImg { max-width: 100%; max-height: 100%; object-fit: contain; }
/* written in the sand: the pad to write on, the same sand at the other end, and the card that follows the wave */
#sand { position: absolute; inset: 0; z-index: 7; display: none; touch-action: none; }
#sand.show { display: block; }
#sandCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: opacity 0.9s ease; touch-action: none; }
#sand.wait #sandCanvas { opacity: 0; }                 /* before the touch, the live beach shows through */
#sandSay { position: absolute; left: 6%; right: 6%; top: calc(var(--top) + 16px); text-align: center; font-size: 17px; line-height: 1.35; color: var(--ink); text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8); pointer-events: none; }
#sand.wait #sandSay { top: 42%; font-size: clamp(22px, 6.4vmin, 32px); font-weight: 300; animation: breathe 3.2s ease-in-out infinite; }
#sandSay:empty { display: none; }
#sandBar { position: absolute; left: 5%; right: 5%; bottom: calc(var(--bottom) + 10px); display: none; gap: 10px; }
#sand.pad #sandBar { display: flex; }
#sandBar .btn { margin-top: 0; }
#sandCard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(90%, 420px); padding: 24px 22px 20px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); display: none; flex-direction: column; gap: 10px; }
#sand.card #sandCard { display: flex; }
#sandRow { display: flex; flex-direction: column; gap: 8px; }
#sandAdd { flex: none; padding: 11px 14px; }
#sandShow { display: none; align-items: center; gap: 10px; }
#sandRow.has #sandShow { display: flex; }
#sandRow.has #sandAdd { display: none; }
#sandThumb { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--line); }
#sandNote { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--dim); }
#sandDrop { padding: 6px 4px; text-shadow: none; }
/* a message written in the sand has no typed words and no picture */
#desk.sand #msg, #desk.sand .count, #desk.sand #picRow, #desk.sand label[for=msg] { display: none; }
/* on the desk: choosing one, and the small copy that shows it is tucked in */
/* a picture and the sand sit side by side until one of them is used, then it takes the whole line */
#extras { display: flex; flex-wrap: wrap; gap: 8px; }
#extras > div { flex: 1 1 0; min-width: 0; }
#extras > div.has { flex-basis: 100%; }
#extras .mood { width: 100%; font-size: 14px; }
#deskHead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
/* "how does this work?": a small round question mark beside the title */
#howDesk { flex: none; appearance: none; width: 30px; height: 30px; margin-top: 1px; border-radius: 50%; border: 1px solid rgba(255, 201, 138, 0.55); background: rgba(255, 201, 138, 0.12); color: var(--gold); font: inherit; font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
#mobileAsk { align-self: flex-start; padding: 2px 0 4px; font-size: 14px; text-shadow: none; display: none; }
#picRow { display: flex; flex-direction: column; gap: 8px; }
#picAdd { flex: none; padding: 11px 14px; }
#picShow { display: none; align-items: center; gap: 10px; }
#picRow.has #picShow { display: flex; }
#picRow.has #picAdd { display: none; }
#picThumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 240, 220, 0.08); }
#picSay { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--dim); }
#picDrop { padding: 6px 4px; text-shadow: none; }
#words span { display: inline-block; opacity: 0; animation: ink 0.5s ease forwards; }
/* a wax seal with the sender's initial, pressed on once the words are down */
#seal { position: relative; left: -8px; margin: 6px 0 -56px; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 700; color: rgba(255, 220, 210, 0.85); text-shadow: 0 -1px 0 rgba(60, 0, 0, 0.6); background: radial-gradient(circle at 35% 30%, #d8483a, #8f1d18 62%, #6b1210); box-shadow: 0 3px 8px rgba(60, 10, 0, 0.45), inset 0 0 0 3px rgba(255, 255, 255, 0.07), inset 0 -4px 8px rgba(0, 0, 0, 0.35); opacity: 0; transform: rotate(-12deg) scale(1.7); }
#letter.show #seal { animation: stamp 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) forwards; }
@keyframes stamp { from { opacity: 0; transform: rotate(-12deg) scale(1.7); } to { opacity: 1; transform: rotate(-12deg) scale(1); } }
#paper { padding-bottom: 68px; }
@keyframes ink { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }
#sign { margin-top: 20px; text-align: right; font-size: 1.05em; opacity: 0; }
#letter.show #sign { animation: ink 0.9s ease forwards; }
/* not a signature: the page saying whose conversation an unsigned note came from */
#sign.unsigned { font-family: var(--font); font-size: 13.5px; line-height: 1.35; text-align: left; color: rgba(58, 38, 22, 0.72); }
#after { opacity: 0; transition: opacity 1s ease; width: min(100%, 340px); display: flex; flex-direction: column; align-items: center; gap: 2px; }
#dear { font-size: 0.86em; opacity: 0.72; margin-bottom: 10px; }
#dear:empty { display: none; }
#toChip { align-self: flex-start; padding: 6px 14px; border-radius: 14px; background: rgba(255, 201, 138, 0.18); border: 1px solid rgba(255, 201, 138, 0.45); color: var(--gold); font-size: 15px; font-weight: 600; }
#toChip:empty { display: none; }
#backToNote { display: none; }
.reading #backToNote { display: block; }
/* Earlier notes in this conversation */
#shelf { width: 100%; margin-top: 6px; }
#shelf:empty { display: none; }
.shelfHead { font-size: 13px; color: var(--dim); text-align: center; margin-bottom: 8px; }
.shelfRow { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; touch-action: pan-x; scrollbar-width: none; }
.shelfRow::-webkit-scrollbar { display: none; }
.chip { flex: none; appearance: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 13.5px; padding: 8px 12px; border-radius: 14px; cursor: pointer; }
.chip.on { border-color: var(--gold); color: var(--gold); }
.chip.new { box-shadow: 0 0 0 2px rgba(255, 201, 138, 0.55); }
#after.show { opacity: 1; }
#newest { margin-bottom: 8px; }
#sealNote, #keepNote, #replyHow, .lanternSay { margin: 8px 0 0; max-width: 30em; font-size: 14px; line-height: 1.4; color: var(--dim); text-align: center; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7); }
#sealNote:empty, #keepNote:empty, #replyHow:empty, #madeNext:empty { display: none; }
/* something small tucked in with the note: it lies on the paper under the words */
#tuck { display: none; align-items: center; gap: 12px; margin-top: 16px; opacity: 0; }
#tuck.on { display: flex; }
#letter.show #tuck.on { animation: ink 0.9s ease forwards; }
#tuckArt { flex: none; width: 60px; height: 60px; transform: rotate(-7deg); filter: drop-shadow(0 2px 3px rgba(60, 40, 20, 0.35)); }
#tuckArt svg, #tuckIcon svg, #tuckPick svg, .mark svg { display: block; width: 100%; height: 100%; }
#tuckNote { font-family: var(--font); font-size: 13.5px; line-height: 1.35; color: rgba(58, 38, 22, 0.72); }
/* tucking something in and sealing it until later sit side by side until one of them is opened, then it takes the whole line */
#extras2 { display: flex; flex-wrap: wrap; gap: 8px; }
#extras2 > div { flex: 1 1 0; min-width: 0; }
#extras2 > div.has, #extras2 > div.pick { flex-basis: 100%; }
/* sealed until a time: a few quick choices, or a day and time */
#whenRow { display: flex; flex-direction: column; gap: 8px; }
#whenAdd { flex: none; width: 100%; padding: 11px 14px; font-size: 14px; }
#whenPick { display: none; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 240, 220, 0.06); }
#whenRow.pick #whenPick { display: flex; }
#whenRow.pick #whenAdd, #whenRow.has #whenAdd { display: none; }
#whenQuick { display: flex; gap: 6px; }
#whenQuick .mood { font-size: 13.5px; padding: 10px 4px; }
#whenPick label { margin-top: 2px; }
#whenWarn { font-size: 14px; color: var(--gold); }
#whenWarn:empty { display: none; }
#whenNo { align-self: flex-start; padding: 2px 0; font-size: 14px; text-shadow: none; }
#whenShow { display: none; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255, 201, 138, 0.45); background: rgba(255, 201, 138, 0.10); }
#whenRow.has #whenShow { display: flex; }
#whenSay { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--ink); }
#whenDrop { padding: 6px 4px; text-shadow: none; }
#desk.sand #whenRow, #desk.sand #extras2 { display: none; }
/* a bottle for no one: only the words and a sky */
#desk.cast #names, #desk.cast #extras, #desk.cast #extras2, #desk.cast #steps { display: none; }
#made.cast #byLink, #made.cast #try, #made.cast #backToNote { display: none; }
/* a sealed bottle opened before its time: it rides out at sea, and the page says when it washes up */
#wait { position: absolute; inset: 0; z-index: 3; display: none; }
#wait.show { display: block; }
#waitHead { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--top) + 26px) 7% 0; text-align: center; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.5); }
#waitTitle { font-size: clamp(28px, 8vmin, 36px); font-weight: 300; }
#waitWho { margin: 8px 0 0; font-size: 16px; color: var(--ink); }
#waitWhen { margin: 6px 0 0; font-size: 18px; line-height: 1.35; color: var(--gold); }
#waitLeft { margin: 6px 0 0; font-size: 14.5px; color: var(--ink); opacity: 0.85; }
[data-mood=dawn] #waitHead { color: #35233c; text-shadow: 0 1px 14px rgba(255, 250, 240, 0.9); }
[data-mood=dawn] #waitWho, [data-mood=dawn] #waitLeft { color: #35233c; }
[data-mood=dawn] #waitWhen { color: #6b3a1c; }
#waitFoot { position: absolute; left: 6%; right: 6%; bottom: var(--bottom); display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* on the desk: choosing what to tuck in */
#tuckRow { display: flex; flex-direction: column; gap: 8px; }
#tuckAdd { flex: none; width: 100%; padding: 11px 14px; font-size: 14px; }
#tuckPick { display: none; gap: 6px; }
#tuckRow.pick #tuckPick { display: flex; }
#tuckRow.pick #tuckAdd, #tuckRow.has #tuckAdd { display: none; }
#tuckPick button { flex: 1; min-width: 0; height: 50px; padding: 6px; appearance: none; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 245, 230, 0.94); cursor: pointer; }
#tuckShow { display: none; align-items: center; gap: 10px; }
#tuckRow.has #tuckShow { display: flex; }
#tuckIcon { flex: none; width: 56px; height: 56px; padding: 7px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 245, 230, 0.94); }
#tuckSay { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--dim); }
#tuckDrop { padding: 6px 4px; text-shadow: none; }
#desk.sand #tuckRow { display: none; }
#toBeach { display: none; padding: 4px 10px 8px; }
/* a beach, visited: its name over the sky, a ring on each shell to tap, and what to do next at the foot */
#visit { position: absolute; inset: 0; z-index: 3; display: none; pointer-events: none; }
#visit.show { display: block; }
#visitHead { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--top) + 4px) 6% 0; text-align: center; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.5); }
#visitWho { margin: 2px 0 0; font-size: 15.5px; color: var(--gold); }
#visitSay { margin: 6px auto 0; max-width: 27em; font-size: 14px; line-height: 1.35; color: var(--ink); opacity: 0.9; }
[data-mood=dawn] #visitHead { color: #35233c; text-shadow: 0 1px 14px rgba(255, 250, 240, 0.9); }
[data-mood=dawn] #visitWho { color: #6b3a1c; }
#visitShells { position: absolute; inset: 0; }
#visit.plain #visitShells { display: none; }
.mark { position: absolute; left: 0; top: 0; width: 46px; height: 46px; margin: -23px 0 0 -23px; padding: 0; appearance: none; border: 0; background: none; border-radius: 50%; pointer-events: auto; cursor: pointer; opacity: 0; transition: opacity 0.7s ease; will-change: transform; }
.mark::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; border: 1.5px solid rgba(255, 232, 200, 0.6); animation: ring 2.8s ease-in-out infinite; }
@keyframes ring { 50% { transform: scale(1.3); opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .mark::after { animation: none; } }
/* what was tucked into that bottle stands by its shell */
.mark svg { position: absolute; left: 50%; bottom: 52%; width: 30px; height: 30px; margin-left: -15px; transform: rotate(-8deg); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55)); pointer-events: none; }
#visitFoot { position: absolute; left: 5%; right: 5%; bottom: var(--bottom); display: flex; flex-direction: column; gap: 2px; pointer-events: auto; }
#visitFoot .btn { margin-top: 0; }
#visitRow:empty { display: none; }
#visitRow { margin-bottom: 6px; }
#visitLinks { display: flex; justify-content: space-between; gap: 10px; }
#visitLinks .link { padding: 8px 4px; }
/* how the reply gets there: said right under the button, a little brighter than the lines further down */
#replyHow { margin: 6px 0 4px; font-size: 15px; color: var(--ink); }
/* the button that answers a note draws the eye once the words are down */
#after.show .btn.call { animation: call 2.6s ease-in-out 1.2s 3; }
@keyframes call { 50% { box-shadow: 0 10px 26px rgba(255, 170, 90, 0.28), 0 0 0 9px rgba(255, 201, 138, 0.22); transform: scale(1.025); } }
@media (prefers-reduced-motion: reduce) { #after.show .btn.call { animation: none; } }
/* The lantern: one line and one button, wherever it is offered */
.lantern { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lantern:empty { display: none; }
#desk .lantern, #made .lantern { margin-top: 2px; }
#desk .lanternSay, #made .lanternSay { text-shadow: none; }
/* iPhone: the Home Screen steps */
#homecard, #howcard { position: absolute; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; padding: 20px 5%; background: rgba(10, 8, 20, 0.74); }
#homecard.show, #howcard.show { display: flex; }
#homecard .card, #howcard .card { width: min(100%, 420px); max-height: 100%; overflow-y: auto; padding: 24px 22px 20px; border-radius: 24px; background: #241c33; border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; gap: 10px; }
#homecard ol, #howcard ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; line-height: 1.4; }
#homecard svg { width: 20px; height: 20px; vertical-align: -4px; color: var(--gold); }
#homeState { color: var(--gold); min-height: 1.4em; }
#howcard ol b { color: var(--gold); font-weight: 600; }
#howcard .lede { margin-top: 4px; }

/* The safety net: the note on its own, when the beach cannot load */
#plain { position: fixed; inset: 0; z-index: 9; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 6%; background: linear-gradient(180deg, #1b1740, #5b3052 60%, #2b2330); }
#plain.show { display: flex; }
#plainPaper { width: min(100%, 440px); max-height: 70%; overflow-y: auto; padding: 30px 26px; border-radius: 3px; color: #3a2616; font-family: var(--hand); font-size: 22px; line-height: 1.5; background: linear-gradient(175deg, #f6ead0, #dcc59a); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5); }
#plainWords { white-space: pre-wrap; overflow-wrap: anywhere; }
#plainSign { margin-top: 18px; text-align: right; }
#plainWhy { margin: 0; max-width: 30em; text-align: center; font-size: 14px; line-height: 1.4; color: var(--dim); }

/* The writing desk */
#compose { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; padding: calc(var(--top) + 10px) 5% var(--bottom); overflow-y: auto; touch-action: pan-y; }
#compose.show { display: flex; }
#desk, #made, #home {
  width: min(100%, 420px); margin: auto 0; padding: 24px 22px 22px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 10px;
}
#made, #home { display: none; }
#compose.done #desk, #compose.home #desk { display: none; }
#compose.done #made { display: flex; }
#compose.home:not(.done) #home { display: flex; }
/* Your shore: one row for each person. The name sends them a bottle; the small button opens the last one. */
#people { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 4px; }
#people:empty { display: none; }
.person { display: flex; gap: 8px; align-items: stretch; }
.person .row { flex: 1; min-width: 0; }
.peek { flex: none; appearance: none; font: inherit; font-size: 13.5px; color: var(--dim); background: rgba(255, 240, 220, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; cursor: pointer; }
.rowWho { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
#install, #homeBack, #toHome, #text, #several, #editPeople, #gatherB, #castB, .keep { display: none; }
/* the three steps, for someone who has never sent one: write, text it, they write back */
#steps { display: none; list-style: none; margin: 2px 0 2px; padding: 0; gap: 6px; }
#desk.first #steps { display: flex; }
#steps li { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px 9px; border-radius: 14px; background: rgba(255, 240, 220, 0.07); border: 1px solid var(--line); text-align: center; font-size: 13.5px; line-height: 1.25; color: var(--ink); position: relative; }
#steps b { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #2b1a0c; background: linear-gradient(180deg, #ffe0b4, #ffc07a); }
#steps li + li::before { content: ""; position: absolute; left: -7px; top: 21px; width: 8px; height: 1px; background: rgba(255, 201, 138, 0.6); }
/* the last step: where the phone can send it in one tap, the bare link stays out of sight */
#made.sheet #link { display: none; }
#madeNext { color: var(--gold); margin: 2px 0 0; }
#made.gather #madeNext, #made.many #madeNext { display: none; }
/* a beach many people fill: what it is for, on the desk; its two links, once it is started; the ones this phone started, on the shore */
#occasionRow { display: none; flex-direction: column; gap: 8px; }
#desk.gather #occasionRow { display: flex; }
#gatherSay { color: var(--gold); margin: 0; }
#gatherSay:empty, #gatherCount:empty, #gathers:empty { display: none; }
#gathers { display: flex; flex-direction: column; gap: 8px; }
#gatherBox, #beachPart { display: none; flex-direction: column; gap: 10px; }
#made.gather #gatherBox, #made.gather #beachPart { display: flex; }
#made.gather #byLink, #made.gather #showLink, #made.gather #try { display: none; }
#gatherCount { color: var(--gold); }
/* renaming or removing someone: the name becomes a field, with the way to remove them beside it */
.person input.rowEdit { flex: 1; min-width: 0; font-size: 16.5px; padding: 11px 14px; }
/* a lantern lit for someone: one tap, no words */
.peek.lamp { color: var(--gold); border-color: rgba(255, 201, 138, 0.45); }
.peek[disabled] { opacity: 0.6; }
.peek.sure { color: #ffd0b8; border-color: rgba(255, 150, 120, 0.6); }
/* choosing several people for one bottle: a tapped name is ticked */
.row.picked { border-color: var(--gold); background: rgba(255, 201, 138, 0.16); }
.row.picked .rowWho::after { content: "  \2713"; color: var(--gold); }
/* one bottle to several people: a line for each, and a button only for those who need their link texted */
#sentList { display: none; flex-direction: column; gap: 10px; }
#made.many #sentList { display: flex; }
#made.many #byLink, #made.many #showLink, #made.many #try { display: none; }
.sentRow { display: flex; flex-direction: column; gap: 4px; padding: 11px 14px; border-radius: 14px; background: rgba(255, 240, 220, 0.08); border: 1px solid var(--line); }
.sentRow .btn { margin-top: 6px; padding: 12px 14px; font-size: 16px; }
.sentRow.done { border-color: rgba(255, 201, 138, 0.45); }
.reading #homeBack { display: block; }
/* a bottle sent straight to a lit lantern needs no link: the link waits behind one tap */
#byLink { display: flex; flex-direction: column; gap: 10px; }
#made.direct #byLink, #made:not(.direct) #showLink, #made.busy #showLink, #made.busy #try { display: none; }
#mobileLine { display: flex; gap: 8px; }
#mobileLine input { flex: 1; min-width: 0; }
#mobileLine .mood { flex: none; padding: 0 14px; }
#mobileRow { display: none; flex-direction: column; gap: 8px; }
h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
@media (max-width: 380px) { h1 { font-size: 24px; } }
.lede { margin: 0 0 6px; font-size: 15.5px; line-height: 1.45; color: var(--dim); }
label { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); margin-top: 6px; }
label span { text-transform: none; letter-spacing: 0; color: var(--dim); }
textarea, input[type=text], input[type=tel], input[type=datetime-local] {
  width: 100%; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 245, 230, 0.94); color: #2e1f12;
  padding: 13px 14px; font: inherit; font-size: 17px; line-height: 1.4; -webkit-user-select: text; user-select: text; outline: none;
}
textarea { font-family: var(--hand); font-size: 21px; resize: none; min-height: 132px; }
textarea:focus, input[type=text]:focus, input[type=tel]:focus, input[type=datetime-local]:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 138, 0.25); }
#link { font-size: 16px; color: #4a3a2a; }   /* 16px or more: an iPhone zooms the whole page when a smaller field is tapped */
.count { font-size: 12.5px; color: var(--dim); text-align: right; margin-top: -4px; }
.btn {
  appearance: none; display: block; width: 100%; text-align: center; text-decoration: none; border: 0; border-radius: 16px; padding: 15px 18px; margin-top: 6px;
  font: inherit; font-size: 17px; font-weight: 600; color: #2b1a0c; background: linear-gradient(180deg, #ffe0b4, #ffc07a); box-shadow: 0 10px 26px rgba(255, 170, 90, 0.28); cursor: pointer;
}
.btn:active { transform: scale(0.985); }
/* The button that makes the bottle never leaves the screen, however short the phone or however long the page */
#make { position: sticky; bottom: 10px; z-index: 2; box-shadow: 0 10px 26px rgba(255, 170, 90, 0.28), 0 0 0 7px rgba(34, 24, 42, 0.6); }
@media (max-height: 700px) { #desk.first #deskLede, #desk.gather #deskLede { display: none; } #desk { padding-top: 18px; gap: 8px; } }
@media (max-height: 600px) { textarea { min-height: 96px; } }
#names { display: flex; gap: 10px; }
#names > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
/* The sky picker */
#moods { display: flex; gap: 8px; }
.mood { flex: 1; appearance: none; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); background: rgba(255, 240, 220, 0.08); border: 1px solid var(--line); border-radius: 12px; padding: 11px 4px; cursor: pointer; }
.mood.on { border-color: var(--gold); color: var(--gold); background: rgba(255, 201, 138, 0.16); }
/* Your bottles: the conversations this phone is part of */
.row { appearance: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; font: inherit; color: var(--ink); background: rgba(255, 240, 220, 0.08); border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; cursor: pointer; }
.row.new { border-color: var(--gold); background: rgba(255, 201, 138, 0.16); }
.rowWho { font-size: 16.5px; font-weight: 600; }
.rowSub { font-size: 13.5px; color: var(--dim); }
.row.new .rowSub { color: var(--gold); }
.btn.ghost { background: rgba(255, 240, 220, 0.10); color: var(--ink); font-weight: 500; box-shadow: none; border: 1px solid var(--line); }
.btn[disabled] { opacity: 0.5; }
.link { appearance: none; border: 0; background: none; color: var(--gold); font: inherit; font-size: 15px; padding: 10px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7); }
