:root {
  --soil: #1f1610;
  --soil-2: #33241a;
  --panel: #2b1f16;
  --line: #4d3a2a;
  --cream: #f6ecda;
  --muted: #c6b49b;
  --gold: #efbf4f;
  --ink: #241809;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(120% 90% at 50% 40%, var(--soil-2), var(--soil) 70%);
  color: var(--cream);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--gold); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#patch {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#patch.over { cursor: pointer; }
#patch.dragging { cursor: grabbing; }

/* The overlays let pointer events through to the canvas except on their controls. */
#top, #bottom {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
#top > *, #bottom a, #bottom button { pointer-events: auto; }

/* Solid behind the text, fading out, so drifting bubbles never make it unreadable. */
#top {
  top: 0;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: 14px;
  background: linear-gradient(var(--soil) 78%, transparent);
  display: grid;
  gap: 10px;
  justify-items: center;
}

h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  pointer-events: none !important;
}
h1 span { color: var(--muted); font-weight: 600; }

#find {
  display: flex;
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
#find:focus-within { border-color: var(--gold); }

#find-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--cream);
  font: inherit;
  font-size: 16px; /* Stops iOS zooming the page when the field gets focus. */
}
#find-input::placeholder { color: var(--muted); }

button, .button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soil-2);
  color: var(--cream);
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--gold); }

#find button, .primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

#bottom {
  bottom: 0;
  padding-top: 18px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--soil) 22%);
  text-align: center;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  font-size: 0.9rem;
}
.meta button {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
}
#today { color: var(--gold); }

.note, #sample-note {
  margin: 6px auto 0;
  font-size: 0.75rem;
  color: var(--muted);
}
#sample-note { color: var(--gold); font-weight: 700; }

#card {
  position: fixed;
  z-index: 3;
  right: 20px;
  bottom: 20px;
  width: 340px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 0.45);
}
#card h2 {
  margin: 0 36px 8px 0;
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}
#card-lines p { margin: 0 0 6px; color: var(--muted); line-height: 1.4; }
#card-lines p.lead { color: var(--gold); font-weight: 800; }
#card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
#card-close, .dialog-close {
  min-height: 44px;
  width: 44px;
  padding: 0;
  font-size: 1.3rem;
  border: 0;
  background: transparent;
}
#card-close { position: absolute; top: 8px; right: 8px; }

dialog {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 16px 20px 20px;
  background: var(--panel);
  color: var(--cream);
  border: 1px solid var(--line);
  border-radius: 20px;
}
dialog::backdrop { background: rgb(10 6 3 / 0.7); }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.dialog-head h2 { margin: 0; font-size: 1.1rem; }

#everyone-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
#everyone-list button {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: left;
}
#everyone-list button:hover { background: var(--soil-2); }
#everyone-list span { color: var(--muted); white-space: nowrap; }
#everyone-list strong { font-weight: 600; }

.tick { display: inline-block; vertical-align: -0.12em; }

.founder-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink) !important;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: 0.18em;
}
#everyone-list .founder-pill { vertical-align: baseline; }

#story-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 58dvh;
  margin: 8px auto 0;
  border-radius: 12px;
  /* Lets a long press reach the browser's "save image" menu. */
  -webkit-touch-callout: default;
}
.hint { margin: 10px 0; font-size: 0.8rem; color: var(--muted); line-height: 1.4; }
.dialog-actions { display: flex; gap: 8px; justify-content: center; }

.fatal {
  position: fixed;
  inset: 45% 20px auto;
  z-index: 5;
  margin: 0;
  text-align: center;
}

@media (max-width: 720px) {
  #card {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 55dvh;
    border-radius: 20px 20px 0 0;
    border-width: 1px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}
