:root {
  --paper: #f6f1e7;
  --card: #fffdf8;
  --ink: #1d1b16;
  --muted: #6b665b;
  --line: #e2dccd;
  --ember: #e8502a;
  --ember-dark: #c23c1a;
  --moss: #2f5d46;
  --moss-soft: #e3eee6;
  --sun: #f4c95d;
  --danger: #b3261e;
  --radius: 18px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.15rem calc(4rem + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
}
body { overflow-x: hidden; }
h1, h2, h3, h4, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.boot { text-align: center; color: var(--muted); padding: 4rem 0; }

.brand { font-weight: 800; letter-spacing: .28em; font-size: .8rem; color: var(--ember); }
.hero { display: grid; gap: 1.1rem; padding-top: 1.5rem; }
.hero h1 { font-size: clamp(2.6rem, 12vw, 3.9rem); line-height: .98; letter-spacing: -.045em; font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--ember); }
.hero.join h1 { font-size: clamp(2.2rem, 10vw, 3.2rem); }
.lead { font-size: 1.12rem; color: #3a372f; }
.lead.small { font-size: 1rem; color: var(--muted); }
.hint, .fine { font-size: .88rem; color: var(--muted); }
.fine { text-align: center; }
.title { font-size: 2rem; letter-spacing: -.03em; line-height: 1.1; }
.back { color: var(--muted); text-decoration: none; font-size: .95rem; }
h3 { font-size: 1.15rem; letter-spacing: -.01em; margin-bottom: .6rem; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 1.1rem 0 .5rem; }

.steps { display: grid; gap: .75rem; margin-top: .5rem; }
.step { display: flex; gap: .9rem; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.step > span { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-weight: 800; }
.step p { color: var(--muted); font-size: .95rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.card.soft { background: var(--moss-soft); border-color: #cfe0d4; }
.card.win { background: var(--sun); border-color: #e0b443; }
.card.center { text-align: center; }
.card.center strong { display: inline-flex; gap: .4rem; align-items: center; }
.card p { color: #4a463d; font-size: .97rem; margin-top: .3rem; }
.card.recover { border-style: dashed; }

.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none; text-align: center;
  font: inherit; font-weight: 700; color: var(--ink); background: transparent;
  border-radius: 999px; padding: .8rem 1.2rem; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.big { width: 100%; font-size: 1.08rem; padding: 1.05rem 1.2rem; min-height: 58px; }
.btn.small { font-size: .9rem; padding: .5rem .9rem; min-height: 40px; }
.btn.primary { background: var(--ember); color: #fff; box-shadow: 0 6px 18px -8px rgba(232, 80, 42, .8); }
.btn.primary:hover { background: var(--ember-dark); }
.btn.ghost { border: 1.5px solid var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-text { color: var(--danger); border-color: var(--danger); }
.link { appearance: none; border: 0; background: none; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; padding: .4rem 0; }
:focus-visible { outline: 3px solid var(--moss); outline-offset: 2px; }

.form { display: grid; gap: .95rem; }
.form label { display: grid; gap: .35rem; font-weight: 600; font-size: .95rem; }
.form label small, legend small { font-weight: 400; color: var(--muted); }
legend { font-weight: 600; font-size: .95rem; margin-bottom: .45rem; }
input[type=text], input:not([type]), input[type=date] {
  font: inherit; width: 100%; padding: .8rem .9rem; min-height: 48px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus { border-color: var(--ink); outline: none; }
#names { display: grid; gap: .5rem; }
.form label.check { grid-template-columns: auto 1fr; align-items: start; gap: .7rem; font-weight: 500; }
.check input { width: 1.35rem; height: 1.35rem; margin-top: .15rem; accent-color: var(--ember); }
.error { color: var(--danger); font-weight: 600; font-size: .95rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }

.top { display: grid; gap: .3rem; padding-top: .4rem; }
.top h2 { font-size: clamp(2rem, 9vw, 2.7rem); letter-spacing: -.04em; line-height: 1.05; }
.meta { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .95rem; }
.mission { font-size: 1.05rem; }

.progress { display: grid; gap: .9rem; background: var(--ink); color: var(--paper); border-color: var(--ink); }
.score { display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; }
.score .n { font-size: 4.2rem; font-weight: 800; line-height: .9; letter-spacing: -.05em; color: var(--sun); }
.score .of { font-size: 1.6rem; font-weight: 700; opacity: .8; }
.score .what { font-size: .95rem; opacity: .75; margin-left: .2rem; }
.stones { display: grid; grid-template-columns: repeat(8, 1fr); gap: .4rem; }
.stone {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; border: 2px solid rgba(246, 241, 231, .3); color: rgba(246, 241, 231, .6);
}
.stone.done { background: var(--ember); border-color: var(--ember); color: #fff; }
.stone.done.recovered { background: var(--moss); border-color: #6fa588; }
.stone.current { border-color: var(--sun); color: var(--sun); box-shadow: 0 0 0 4px rgba(244, 201, 93, .18); }
.stone.missed { border-style: dashed; }
.progress .week { font-size: .9rem; color: #d8d2c4; }

.pulse { display: grid; gap: .6rem; border-color: var(--ink); }
.pulse > small { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.scale { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .4rem; }
.dot { appearance: none; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; min-width: 0; height: 44px; border-radius: 12px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); padding: 0; }
.dot:hover, .dot:active { background: var(--ink); color: var(--paper); }
.scale-legend { display: flex; justify-content: space-between; font-size: .8rem !important; color: var(--muted) !important; margin: 0 !important; }
.measure { display: grid; gap: .35rem; font-size: .92rem; }
.measure li { display: flex; justify-content: space-between; gap: .8rem; }
.measure strong { text-align: right; }

.reward { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.reward small { display: block; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.badge { flex: none; font-size: .78rem; font-weight: 700; padding: .3rem .65rem; border-radius: 999px; background: #efe8d8; color: #6a5a2c; }
.badge.confirmed { background: var(--moss-soft); color: var(--moss); }

.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.tile {
  appearance: none; border: 1px solid var(--line); padding: 0; cursor: pointer; font: inherit; color: inherit;
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #ebe4d4; display: block;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.tile.loaded img, .detail-photo.loaded img { opacity: 1; }
.tile.nophoto { background: var(--moss-soft); }
.nophoto-mark { position: absolute; inset: 0; display: grid; place-items: center; color: var(--moss); font-size: 2.2rem; }
.tile-label {
  position: absolute; left: .45rem; bottom: .45rem; right: auto; background: rgba(29, 27, 22, .82); color: #fff;
  font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 999px;
}
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 1.1rem; text-align: center; font-size: .95rem; }

.people { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.people li { display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .6rem .7rem; font-weight: 600; font-size: .95rem; }
.people small { grid-column: 2; color: var(--muted); font-weight: 400; font-size: .8rem; }
.avatar { grid-row: span 2; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-weight: 800; }
.people li.out .avatar { background: transparent; color: var(--muted); border: 2px dashed var(--line); }

.list { display: grid; gap: .6rem; }
.invite { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.invite > div { flex: 1; min-width: 7rem; display: grid; }
.invite small { color: var(--muted); font-size: .82rem; }
.organizer summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
fieldset .chips { margin-top: 0; }
.form label.chip { display: inline-flex; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { border: 1.5px solid var(--line); border-radius: 999px; padding: .55rem 1rem; font-weight: 600; cursor: pointer; background: #fff; min-height: 44px; display: inline-flex; align-items: center; }
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--moss); outline-offset: 2px; }

.photo-pick { position: relative; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.photo-cta { display: flex; align-items: center; justify-content: center; gap: .6rem; border: 2px dashed var(--ink); border-radius: 14px; padding: 1rem; font-weight: 700; min-height: 58px; }
.photo-cta small { font-weight: 400; color: var(--muted); margin-left: .3rem; }
.photo-pick:focus-within .photo-cta { outline: 3px solid var(--moss); outline-offset: 2px; }
#preview { width: 100%; max-height: 14rem; object-fit: cover; border-radius: 14px; margin-top: .5rem; }
.detail-photo { border-radius: 14px; overflow: hidden; background: #ebe4d4; min-height: 8rem; }
.detail-photo img { width: 100%; max-height: 60vh; object-fit: contain; display: block; opacity: 0; transition: opacity .25s; }
.meta-line { color: var(--muted); font-size: .95rem; }

dialog {
  border: 0; padding: 1.3rem 1.15rem calc(1.3rem + env(safe-area-inset-bottom)); width: 100%; max-width: 34rem;
  margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--paper); color: var(--ink);
  max-height: 92vh; overflow: auto;
}
dialog::backdrop { background: rgba(29, 27, 22, .55); }
@media (min-width: 40rem) { dialog { margin: auto; border-radius: 22px; } }

#toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: var(--ink); color: var(--paper); padding: .8rem 1.1rem; border-radius: 14px; font-weight: 600; font-size: .95rem;
  max-width: min(92vw, 30rem); text-align: center; transition: transform .25s ease; z-index: 2147483647; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }
#toast.bad { background: var(--danger); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.dot.on { background: var(--ink); color: var(--paper); }
.photo-pick[aria-disabled=true] .photo-cta { opacity: .45; border-color: var(--muted); }
.photo-pick[aria-disabled=true] input { cursor: not-allowed; }
a.link { color: inherit; }
dialog #toast { position: sticky; left: auto; bottom: 0; transform: none; margin: .6rem auto 0; display: none; max-width: none; }
dialog #toast.show { display: block; transform: none; }
