/* Forever Loved
   Layout: one tall twilight scene — painted sky with the title, then the stone
   remembrance wall — followed by a quiet night-coloured "About" section.
   Single deliberate theme (dusk), so colours are set explicitly for both
   light and dark system settings. */

:root {
  color-scheme: dark;
  --night: #1b1629;
  --plum-900: #221b35;
  --plum-800: #2a2140;
  --plum-700: #3a2c4f;
  --plum-600: #4e3d65;
  --plum-500: #6a5584;
  --edge: #140e20;
  --ivory: #fbf3e2;
  --ivory-shade: #d9c3a6;
  --amber: #f8b24f;
  --rose: #f2a7bf;
  --rose-deep: #cf7c9c;
  --sky-blue: #a3c8ec;
  --text: #f5eef4;
  --text-soft: #d3c7dd;
  --text-quiet: #b6a8c5;
  --sky-fallback: #595994;

  --font-pixel: "Pixelify Sans", "Courier New", ui-monospace, monospace;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;

  --px: 3px;            /* one "pixel" of UI chrome */
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; background: var(--night); }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
img { max-width: 100%; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 50;
  background: var(--ivory);
  color: var(--plum-800);
  font-family: var(--font-pixel);
  padding: .6rem 1rem;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: var(--px) dashed var(--rose);
  outline-offset: 4px;
}

/* ── Sky / hero ─────────────────────────────────────────────────────────── */
.sky {
  position: relative;
  isolation: isolate;
  background-color: var(--sky-fallback);
  background-image: url("../assets/sky.webp");
  background-size: cover;
  background-position: center 78%;
  text-align: center;
  padding-block: clamp(2.25rem, 8vh, 7rem) clamp(2.25rem, 7vh, 4.5rem);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.sky::after {
  /* faint warm horizon where the sky meets the wall */
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(to top, rgba(247, 171, 140, .28), rgba(247, 171, 140, 0));
  z-index: -1;
  pointer-events: none;
}
.sky-stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  image-rendering: pixelated;
  pointer-events: none;
}
.sky-inner {
  max-width: 44rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.eyebrow {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 500;
  font-size: clamp(.78rem, 2.6vw, .95rem);
  letter-spacing: .06em;
  color: #ffe6ee;
  text-shadow: 0 2px 0 rgba(30, 24, 60, .75);
  text-wrap: balance;
}
.title {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: clamp(3.1rem, 13vw, 6rem);
  line-height: .95;
  letter-spacing: .01em;
  color: var(--ivory);
  text-shadow:
    0 .06em 0 #3b2d57,
    0 .12em 0 rgba(30, 22, 50, .45);
  text-wrap: balance;
}
.lede {
  margin: .25rem 0 0;
  max-width: 30ch;
  font-size: clamp(1.08rem, 3.6vw, 1.3rem);
  line-height: 1.5;
  color: #fff6f1;
  text-shadow: 0 1px 0 rgba(40, 28, 70, .7), 0 0 14px rgba(40, 28, 70, .5);
  text-wrap: balance;
}
.actions {
  margin-top: .9rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1.1rem 1.75rem;
}
.link-quiet {
  font-family: var(--font-pixel);
  font-size: 1.05rem;
  color: var(--ivory);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-shadow: 0 2px 0 rgba(40, 28, 70, .7);
  padding: .65rem .25rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.link-quiet:hover { color: #fff; text-decoration-style: solid; }

.wall-count,
.preview-flag {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: rgba(34, 27, 53, .82);
  padding: .4rem .8rem;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--plum-600),
    0 var(--px) 0 0 var(--plum-600),
    calc(var(--px) * -1) 0 0 0 var(--plum-600),
    var(--px) 0 0 0 var(--plum-600);
  margin: .4rem 0 0;
  font-family: var(--font-pixel);
  font-size: .95rem;
  color: #fff0e2;
  text-shadow: 0 2px 0 rgba(40, 28, 70, .75);
  font-variant-numeric: tabular-nums;
}
.preview-flag {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: rgba(34, 27, 53, .82);
  padding: .4rem .8rem;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--plum-600),
    0 var(--px) 0 0 var(--plum-600),
    calc(var(--px) * -1) 0 0 0 var(--plum-600),
    var(--px) 0 0 0 var(--plum-600);
  text-shadow: none;
  font-size: .88rem;
}
.preview-dot {
  width: 9px; height: 9px;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(248, 178, 79, .25);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  --face: var(--ivory);
  --ink: var(--plum-800);
  --rim: var(--edge);
  --lo: var(--ivory-shade);
  --hi: #fffaf1;
  appearance: none;
  border: 0;
  margin: var(--px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  min-height: 52px;
  padding: .7rem 1.5rem .8rem;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.1;
  color: var(--ink);
  background: var(--face);
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--rim),
    0 var(--px) 0 0 var(--rim),
    calc(var(--px) * -1) 0 0 0 var(--rim),
    var(--px) 0 0 0 var(--rim),
    inset 0 calc(var(--px) * -1) 0 0 var(--lo),
    inset 0 var(--px) 0 0 var(--hi),
    0 calc(var(--px) * 3) 0 0 rgba(14, 9, 24, .45);
  transition: transform .08s ease, background-color .15s ease;
}
.btn:hover { --face: #fff8ec; }
.btn:active { transform: translateY(2px); }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  --face: #b9adb9;
  --lo: #9d909f;
  --hi: #cbc0ca;
  --ink: #3a2f45;
}
.btn-primary { font-size: 1.2rem; }
.btn-secondary {
  --face: var(--plum-600);
  --ink: var(--ivory);
  --lo: #3c2d52;
  --hi: #66548a;
}
.btn-secondary:hover { --face: #5a4774; }
.btn-small {
  min-height: 44px;
  padding: .45rem 1rem .55rem;
  font-size: 1rem;
}
.btn-flame {
  display: inline-block;
  width: 15px;
  height: 24px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  image-rendering: pixelated;
  flex: none;
}

.btn-text {
  appearance: none;
  background: none;
  border: 0;
  min-height: 44px;
  padding: .5rem .75rem;
  font-family: var(--font-pixel);
  font-size: 1.02rem;
  color: var(--text-soft);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 5px;
  cursor: pointer;
}
.btn-text:hover { color: var(--ivory); }

.btn-icon,
.btn-toggle {
  appearance: none;
  border: 0;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  color: var(--ivory);
  background: var(--plum-700);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--edge),
    0 var(--px) 0 0 var(--edge),
    calc(var(--px) * -1) 0 0 0 var(--edge),
    var(--px) 0 0 0 var(--edge),
    inset 0 var(--px) 0 0 var(--plum-500);
  margin: var(--px);
}
.btn-icon:hover,
.btn-toggle:hover { background: var(--plum-600); }
.btn-icon:disabled { color: var(--plum-500); cursor: default; background: var(--plum-800); }
.btn-toggle {
  padding: .3rem .8rem;
  font-size: .95rem;
  color: var(--text-soft);
}
.btn-toggle[aria-pressed="true"] { color: var(--ivory); }

.arrow {
  width: 14px;
  height: 8px;
  background: currentColor;
  clip-path: polygon(6px 0, 8px 0, 8px 2px, 10px 2px, 10px 4px, 12px 4px, 12px 6px, 14px 6px, 14px 8px, 0 8px, 0 6px, 2px 6px, 2px 4px, 4px 4px, 4px 2px, 6px 2px);
}
.arrow-down { transform: rotate(180deg); }

/* ── Wall ───────────────────────────────────────────────────────────────── */
.wall {
  position: relative;
  background: var(--plum-900);
}
.wall-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #3a2c45;
  min-height: 300px;
}
.wall-stage:focus-visible { outline-offset: -8px; }
.wall-stage canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
}

.tip {
  position: absolute;
  z-index: 3;
  left: 0; top: 0;
  width: max-content;
  max-width: min(17rem, calc(100% - 24px));
  transform: translate(-50%, calc(-100% - 12px));
  padding: .65rem .9rem .7rem;
  text-align: center;
  background: var(--plum-800);
  color: var(--text);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--ivory-shade),
    0 var(--px) 0 0 var(--ivory-shade),
    calc(var(--px) * -1) 0 0 0 var(--ivory-shade),
    var(--px) 0 0 0 var(--ivory-shade),
    0 calc(var(--px) * 3) 0 0 rgba(14, 9, 24, .5);
}
.tip::after {
  content: "";
  position: absolute;
  left: calc(50% - 6px + var(--tip-shift, 0px));
  bottom: -9px;
  width: 12px;
  height: 6px;
  background: var(--ivory-shade);
  clip-path: polygon(0 0, 12px 0, 12px 2px, 10px 2px, 10px 4px, 8px 4px, 8px 6px, 4px 6px, 4px 4px, 2px 4px, 2px 2px, 0 2px);
}
.tip-text {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--ivory);
}
.tip-meta {
  margin: .2rem 0 0;
  font-size: .85rem;
  line-height: 1.35;
  color: var(--text-soft);
}
.tip-card {
  margin-top: .5rem;
  appearance: none;
  border: 0;
  background: none;
  color: var(--rose);
  font-family: var(--font-pixel);
  font-size: .92rem;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
  cursor: pointer;
  min-height: 36px;
  padding: .2rem .4rem;
}

.wall-overlay {
  position: absolute;
  left: 50%;
  bottom: 13%;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  width: max-content;
  max-width: calc(100% - 40px);
  padding: .55rem 1rem;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 1rem;
  color: var(--ivory);
  background: rgba(34, 27, 53, .92);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--plum-600),
    0 var(--px) 0 0 var(--plum-600),
    calc(var(--px) * -1) 0 0 0 var(--plum-600),
    var(--px) 0 0 0 var(--plum-600);
}

.wall-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem 1rem;
  padding-block: .8rem 1rem;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: var(--plum-900);
  border-top: var(--px) solid var(--edge);
}
.pager {
  display: flex;
  align-items: center;
  gap: .35rem;
}
.pager-label {
  min-width: 9.5rem;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: .98rem;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.scrub {
  flex: 1 1 10rem;
  min-width: 0;
  display: flex;
  align-items: center;
  min-height: 44px;
}
.scrub input {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  height: 44px;
  margin: 0;
  cursor: pointer;
}
.scrub input::-webkit-slider-runnable-track { height: 6px; background: var(--plum-600); }
.scrub input::-moz-range-track { height: 6px; background: var(--plum-600); }
.scrub input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 24px;
  margin-top: -9px;
  background: var(--ivory);
  border: 0;
  box-shadow: inset 0 -3px 0 var(--ivory-shade), 0 0 0 3px var(--edge);
}
.scrub input::-moz-range-thumb {
  width: 18px; height: 24px;
  background: var(--ivory);
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 -3px 0 var(--ivory-shade), 0 0 0 3px var(--edge);
}
.bar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin-left: auto;
}
.wall-status {
  flex: 1 1 18rem;
  order: -1;
  margin: 0;
  font-size: .95rem;
  line-height: 1.45;
  color: var(--text-soft);
  min-height: 1.45em;
}
.wall-status .inline-btn {
  appearance: none;
  border: 0;
  background: none;
  color: var(--rose);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: .3rem .2rem;
  min-height: 36px;
}

/* ── About ─────────────────────────────────────────────────────────────── */
.about {
  background: linear-gradient(to bottom, var(--plum-900), var(--night) 60%);
  padding-block: clamp(3rem, 8vw, 5rem) clamp(2.5rem, 6vw, 4rem);
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.about-inner {
  max-width: 38rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.about-inner p { margin: 0; }
.section-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  line-height: 1.15;
  color: var(--ivory);
  text-wrap: balance;
}
.donate {
  margin-top: .8rem;
  padding: 1.25rem 1.35rem;
  background: var(--plum-800);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--plum-600),
    0 var(--px) 0 0 var(--plum-600),
    calc(var(--px) * -1) 0 0 0 var(--plum-600),
    var(--px) 0 0 0 var(--plum-600);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.donate-title {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 1.35rem;
  color: #ffe0b8;
}
.donate p { margin: 0; }
.donate .btn { align-self: flex-start; }
.learn a {
  font-family: var(--font-pixel);
  color: var(--rose);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 5px;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
.learn a:hover { color: #ffd0de; }

.footer {
  background: var(--night);
  border-top: var(--px) solid var(--plum-800);
  padding-block: 2rem 2.75rem;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.footer-inner {
  max-width: 38rem;
  margin: 0 auto;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text-quiet);
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.footer-inner p { margin: 0; }
.footer strong { color: var(--text-soft); font-family: var(--font-pixel); font-weight: 500; }

/* ── Dialogs ───────────────────────────────────────────────────────────── */
.pixel-dialog {
  width: min(27rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 1.5rem 1.4rem 1.3rem;
  border: 0;
  color: var(--text);
  background: #2f2547;
  box-shadow:
    0 -4px 0 0 var(--edge),
    0 4px 0 0 var(--edge),
    -4px 0 0 0 var(--edge),
    4px 0 0 0 var(--edge),
    inset 0 4px 0 0 #4b3a67,
    inset 0 -4px 0 0 #241c38,
    0 14px 0 0 rgba(10, 6, 18, .35);
}
.pixel-dialog::backdrop { background: rgba(16, 10, 28, .62); }
.pixel-dialog[open] { animation: dialog-in .22s ease-out; }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.dialog-low {
  margin-top: auto;
  margin-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}
.dialog-low::backdrop { background: rgba(16, 10, 28, .28); }
.dialog-title {
  margin: 0 0 .9rem;
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--ivory);
  text-wrap: balance;
}
.dialog-line {
  margin: -.4rem 0 .8rem;
  font-size: 1.12rem;
  color: #ffe4d4;
}
.dialog-note {
  margin: 0 0 1rem;
  font-size: .92rem;
  line-height: 1.5;
  color: var(--text-soft);
}
.dialog-note:empty { display: none; }
.dialog-error {
  margin: .9rem 0 0;
  padding: .65rem .8rem;
  font-size: .95rem;
  line-height: 1.45;
  color: #ffe5e5;
  background: #4a2a44;
  box-shadow: inset var(--px) 0 0 0 #e7889a;
}
.choices {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 64px;
  padding: .5rem 1rem .5rem .8rem;
  margin: var(--px);
  background: var(--plum-700);
  cursor: pointer;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--edge),
    0 var(--px) 0 0 var(--edge),
    calc(var(--px) * -1) 0 0 0 var(--edge),
    var(--px) 0 0 0 var(--edge);
  transition: background-color .15s ease;
}
.choice:hover { background: #45355c; }
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.choice-mark {
  flex: none;
  width: 16px;
  height: 40px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-position: bottom;
  image-rendering: pixelated;
}
.choice-text {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
.choice:has(input:checked) {
  background: #57436f;
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--amber),
    0 var(--px) 0 0 var(--amber),
    calc(var(--px) * -1) 0 0 0 var(--amber),
    var(--px) 0 0 0 var(--amber);
}
.choice:has(input:focus-visible) {
  outline: var(--px) dashed var(--rose);
  outline-offset: 6px;
}
.choice:has(input:disabled) { cursor: default; opacity: .75; }
.dialog-actions {
  margin-top: 1.3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem .9rem;
}
.dialog-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .8rem;
  margin-top: .4rem;
}
.dialog-stack .btn-text { align-self: center; }
.dialog-card { width: min(30rem, calc(100vw - 32px)); }
.card-frame {
  position: relative;
  aspect-ratio: 1;
  max-width: 100%;
  background: var(--plum-800);
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  box-shadow: 0 0 0 var(--px) var(--edge);
}
.card-frame img { width: 100%; height: 100%; display: block; }
.card-loading { margin: 0; font-family: var(--font-pixel); color: var(--text-soft); }
.btn.is-busy { cursor: progress; }

@media (max-width: 559px) {
  .title { margin-top: .1rem; }
  .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
  .dialog-actions .btn-text { align-self: center; }
  .actions { gap: .5rem 1.5rem; }
  .preview-flag { font-size: .8rem; }
}
@media (min-width: 720px) {
  :root { --px: 4px; }
}

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

/* sprite-backed marks (sprites are generated in app.js from the wall art) */
.choice-mark { background-image: var(--candle-unlit); }
.choice:has(input:checked) .choice-mark { background-image: var(--candle-lit); }
.tip.tip-below { transform: translate(-50%, 0); }
.tip.tip-below::after {
  top: -9px;
  bottom: auto;
  transform: rotate(180deg);
}

/* ── Contract address bar ─────────────────────────────────────────────── */
.ca-bar {
  background: var(--edge);
  border-bottom: var(--px) solid var(--plum-700);
  padding-block: .45rem;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.ca-inner {
  max-width: 60rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem .6rem;
  flex-wrap: wrap;
}
.ca-label {
  font-family: var(--font-pixel);
  font-weight: 600;
  font-size: .95rem;
  color: var(--amber);
  letter-spacing: .08em;
}
.ca-value {
  min-width: 0;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(.6rem, 2.75vw, .85rem);
  color: var(--ivory);
  word-break: break-all;
  user-select: all;
}
.ca-copy {
  appearance: none;
  border: 0;
  min-height: 36px;
  padding: .25rem .8rem;
  font-family: var(--font-pixel);
  font-size: .9rem;
  color: var(--plum-800);
  background: var(--ivory);
  cursor: pointer;
  box-shadow: inset 0 -3px 0 var(--ivory-shade);
}
.ca-copy:hover { background: #fff8ec; }
