:root {
  --paper: #f7f4ee;
  --card: #fffdf9;
  --ink: #24221f;
  --muted: #77736d;
  --line: #ded9d0;
  --accent: #55a866;
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--paper); }
body { background: var(--paper); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), white 20%);
  outline-offset: 3px;
}
.modal-open { overflow: hidden; }
.hidden { display: none !important; }

.page {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(30px, env(safe-area-inset-bottom));
}

.topbar,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { margin-bottom: 42px; }

.wordmark {
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -1px;
  text-decoration: none;
}

.brand-lockup {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  color: var(--ink);
  text-decoration: none;
}

.byline {
  color: var(--muted);
  font: 700 8px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1.2px;
}

.mode-label,
.eyebrow,
.memory-meta,
footer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.35px;
}

.mode-label {
  max-width: 48vw;
  overflow: hidden;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 55%);
  border-radius: 999px;
  padding: 8px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-card,
.notice,
.mode-card,
.experience-card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
}

.state-card {
  min-height: 410px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 42px 28px;
  text-align: center;
}

.state-card h1 {
  max-width: 580px;
  margin: 24px 0 8px;
  font-size: clamp(25px, 7vw, 36px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.state-card p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.state-card .subcopy { margin-top: 12px; font-size: 12px; }

.tap-mark {
  width: 100px;
  height: 100px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent), transparent 86%);
  color: var(--accent);
  font: 800 22px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -6px;
}

.loading-mark { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .65; } }

.memory-heading { margin: 0 2px 30px; }
.eyebrow { color: var(--accent); margin: 0 0 12px; }
.memory-heading h1 {
  max-width: 100%;
  margin: 0;
  font-size: clamp(36px, 11vw, 66px);
  line-height: 1.03;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
  word-break: auto-phrase;
  line-break: strict;
}

.memory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  color: var(--muted);
  letter-spacing: .8px;
}

.description { color: var(--muted); line-height: 1.7; margin: 14px 0 0; }

.text-action {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.notice {
  margin-bottom: 18px;
  padding: 16px 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.fiction-switch {
  position: sticky;
  z-index: 5;
  top: max(10px, env(safe-area-inset-top));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--paper), transparent 8%);
  backdrop-filter: blur(16px);
}

.fiction-switch button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.fiction-switch button.active {
  background: var(--ink);
  color: white;
}

.bonus-intro {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 58%);
  border-radius: 24px;
  background: color-mix(in srgb, var(--accent), white 91%);
}

.bonus-intro h2 { margin: 0 0 10px; font-size: clamp(24px, 7vw, 34px); }
.bonus-intro > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.source-heading {
  margin: 34px 2px 14px;
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1.4px;
  color: var(--accent);
}

.photo-grid { display: grid; gap: 15px; }

.photo {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--card);
}

.photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #171817;
  cursor: zoom-in;
}

.photo img {
  width: 100%;
  max-height: 78vh;
  display: block;
  object-fit: contain;
  background: #171817;
}

.photo figcaption {
  display: flex;
  justify-content: space-between;
  padding: 12px 15px;
  color: var(--muted);
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.save-note { margin: 20px 0 52px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.7; }

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
  border: 0;
  background: #0e0e0e;
  color: white;
}

.lightbox::backdrop { background: #0e0e0e; }
.lightbox[open] { display: grid; grid-template-rows: auto 1fr; }

.lightbox-bar {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  min-height: 48px;
  padding: 0 8px;
  font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1px;
  text-align: center;
}

.lightbox-bar button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

#lightbox-close { justify-self: start; width: 44px; font-size: 26px; font-weight: 300; }
#lightbox-save { justify-self: end; }
.lightbox-bar button:disabled { opacity: .48; cursor: default; }

.lightbox-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(48px, 8vw) 1fr minmax(48px, 8vw);
  align-items: center;
}

.lightbox-stage img {
  width: 100%;
  height: calc(100dvh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-nav {
  align-self: stretch;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.86);
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 200;
  cursor: pointer;
}

footer {
  gap: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.simple-page .state-card { min-height: 520px; }
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 52px;
  margin-top: 24px;
  padding: 15px 22px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  text-decoration: none;
  font-weight: 750;
}
.action[aria-disabled="true"] {
  cursor: default;
  opacity: .48;
}
.secondary-web-action {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.invite-card .text-action { margin-top: 18px; }
.invite-code {
  margin-top: 14px !important;
  color: var(--ink) !important;
  font: 800 16px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 3px;
}
.install-note {
  max-width: 430px !important;
  margin-top: 18px !important;
  font-size: 11px;
}
.select-code { user-select: all; }

.landing-page { width: min(100%, 940px); }
.landing-hero { padding: 5vh 0 10vh; }
.landing-hero h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(48px, 12vw, 108px);
  line-height: .98;
  letter-spacing: -.075em;
}
.landing-hero > p:not(.eyebrow) {
  max-width: 590px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 2.5vw, 18px);
  line-height: 1.85;
}

.mode-cards { display: grid; gap: 15px; }
.mode-card { min-height: 260px; padding: 24px; }
.mode-card h2 { margin: 0; font-size: clamp(28px, 7vw, 42px); line-height: 1.13; letter-spacing: -.045em; }
.mode-card > p:last-child { margin: 16px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.mode-roll { --accent: #397a48; }
.mode-random { --accent: #315fa8; }
.mode-fiction { --accent: #63458f; }
.mode-card .eyebrow { color: var(--accent); }

.experience-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 42px 0 80px;
  padding: 22px;
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .7px;
}
.experience-card i { width: 24px; height: 1px; background: var(--line); }

@media (min-width: 640px) {
  .page { padding-left: 34px; padding-right: 34px; }
  .photo-grid { grid-template-columns: 1fr 1fr; }
  .photo img { aspect-ratio: 3 / 4; object-fit: cover; }
  .mode-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .topbar { margin-bottom: 34px; }
  .memory-heading h1 { font-size: clamp(36px, 13.5vw, 58px); }
  footer { align-items: flex-start; flex-direction: column; gap: 6px; }
  .experience-card { justify-content: flex-start; }
  .lightbox-stage { grid-template-columns: 44px 1fr 44px; }
  .lightbox-nav { font-size: 38px; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Support and legal pages */
.document-page { width: min(100%, 760px); }
.document-hero { margin: 2vh 0 34px; }
.document-hero h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(38px, 11vw, 64px);
  line-height: 1.03;
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}
.document-hero > p:not(.eyebrow):not(.document-updated) {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}
.document-updated {
  margin: 14px 0 0;
  color: var(--muted);
  font: 700 10px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .7px;
}
.document-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
}
.document-card > section,
.document-card > div { padding: 24px; }
.document-card > section + section { border-top: 1px solid var(--line); }
.document-card h2 { margin: 0 0 10px; font-size: 17px; line-height: 1.35; }
.document-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.85; }
.document-card a { color: var(--ink); font-weight: 700; }
.document-kicker {
  margin-bottom: 9px !important;
  font: 750 10px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 1.2px;
  color: var(--accent) !important;
}
.support-document { padding-bottom: 22px; }
.support-document .action { margin: 0 22px; }
.support-document h2 { overflow-wrap: anywhere; }
.document-note {
  margin: 18px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}
.document-footer {
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.document-footer a,
.footer-links a {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }

@media (max-width: 560px) {
  .document-card > section,
  .document-card > div { padding: 21px; }
  .document-footer { align-items: flex-start; flex-direction: column; gap: 14px; }
}
