:root {
  --bg: #15110d;
  --bg-2: #211a14;
  --ink: #f1e6cf;
  --muted: #a8977d;
  --parchment: #ead9b0;
  --parchment-ink: #2b1d10;
  --parchment-edge: #c9b07a;
  --rust: #c4552a;
  --rust-dark: #9b3f1c;
  --gold: #e0a93e;
  --green: #6fa86a;
  --radius: 12px;
  --slab: "Zilla Slab", "Rockwell", "Roboto Slab", Georgia, serif;
  --western: "Rye", var(--slab);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, #2a1f15 0%, var(--bg) 60%) fixed var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--slab); font-weight: 700; line-height: 1.15; margin: 0 0 8px; }
h1 { font-size: 28px; }
h2 { font-size: 21px; margin-top: 24px; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

.logo {
  font-family: var(--western);
  font-size: 34px;
  color: var(--gold);
  text-align: center;
  letter-spacing: 1px;
  margin: 8px 0 4px;
  text-shadow: 0 2px 0 #000;
}
.tagline { text-align: center; color: var(--muted); margin: 0 0 20px; }

/* --- forms --- */
label.field { display: block; margin: 16px 0; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="search"] {
  width: 100%;
  font-size: 17px; /* >=16px stops iOS zooming on focus */
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #4a3b2c;
  background: var(--bg-2);
  color: var(--ink);
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn {
  display: block;
  width: 100%;
  padding: 15px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--rust);
  color: #fff;
  font: 700 18px var(--slab);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { background: var(--rust-dark); }
.btn[disabled] { opacity: 0.55; }
.btn.secondary { background: transparent; border: 1px solid #5a4835; color: var(--ink); }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 15px; }

.segmented { display: flex; gap: 8px; }
.segmented label {
  flex: 1;
  padding: 12px 8px;
  border: 1px solid #4a3b2c;
  border-radius: var(--radius);
  text-align: center;
  background: var(--bg-2);
  cursor: pointer;
}
.segmented label small { display: block; color: var(--muted); font-size: 13px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked),
.segmented label.checked { border-color: var(--gold); background: #33271a; }

.selfie {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px dashed var(--parchment-edge);
  background: var(--bg-2) center / cover no-repeat;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}
.selfie.has-photo { border-style: solid; border-color: var(--gold); }
.selfie.has-photo span { display: none; }
.selfie-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

.error { color: #ff8a6a; min-height: 1.4em; margin: 8px 0; }
.progress { height: 4px; background: #3a2d20; border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

/* --- parchment cards --- */
.card {
  background: var(--parchment);
  color: var(--parchment-ink);
  border-radius: 6px;
  padding: 16px;
  margin: 12px 0;
  border: 2px solid var(--parchment-edge);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 0 40px rgba(120, 80, 30, 0.25);
}
.card h3 { font-family: var(--western); font-weight: 400; letter-spacing: 1px; }
.card a { color: var(--rust-dark); }
.card .muted { color: #6f5a3e; }
.panel {
  background: var(--bg-2);
  border: 1px solid #3a2d20;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
}

.rules-short { margin: 0; padding-left: 20px; }
.rules-short li { margin: 4px 0; }

/* --- /me header --- */
.me-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 4px; }
.me-head img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); }
.me-head .name { font: 700 22px var(--slab); }
.scores { display: flex; gap: 8px; margin: 12px 0; }
.score {
  flex: 1;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid #3a2d20;
  border-radius: var(--radius);
  padding: 10px 6px;
}
.score b { display: block; font: 700 24px var(--slab); color: var(--gold); }
.score span { font-size: 13px; color: var(--muted); }
.away-banner { background: #3b2f1e; border: 1px solid var(--gold); }

/* --- friend picker --- */
.picker-search { margin-bottom: 10px; }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.picker-tile {
  position: relative;
  padding: 6px 4px 8px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.picker-tile img {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 6px;
  border-radius: 50%;
  object-fit: cover;
}
.picker-tile span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-tile.on { border-color: var(--green); background: #1f2a1c; }
.picker-tile.on::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  line-height: 22px;
}

.addback { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #3a2d20; }
.addback:first-of-type { border-top: 0; }
.addback img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.addback .grow { flex: 1; min-width: 0; }

/* --- modal sheet --- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.sheet[hidden] { display: none; }
.sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid #3a2d20;
}
.sheet header h2 { margin: 0; }
.sheet .body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 448px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--gold);
  color: #1d140a;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transform: translateY(150%);
  transition: transform 0.25s;
}
.toast.show { transform: none; }

/* --- rules page --- */
.step { display: flex; gap: 14px; align-items: flex-start; }
.step .num {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--rust);
  color: #fff;
  font: 700 20px/40px var(--slab);
  text-align: center;
}
.points-table { width: 100%; border-collapse: collapse; }
.points-table td { padding: 6px 0; border-bottom: 1px dashed var(--parchment-edge); }
.points-table td:last-child { text-align: right; font-weight: 700; }

/* --- bounties --- */
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 20px; }
.board-head h2 { margin: 0; }
.bounty { padding: 8px; }
.bounty .btn { margin-top: 8px; }
.bounty-photo {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  border: 2px solid var(--parchment-ink);
  background: var(--bg-2);
}
.bounty-photo img { display: block; width: 100%; height: 100%; object-fit: cover; filter: sepia(0.15); }
.bounty-photo .value {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 12px;
  border-radius: 6px;
  background: var(--gold);
  color: #1d140a;
  font: 700 24px var(--slab);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
/* Strong gradient + shadow so the text stays readable over white or bright costumes. */
.bounty-overlay {
  position: absolute;
  inset: auto 0 0;
  padding: 56px 12px 12px;
  background: linear-gradient(to bottom, rgba(10, 7, 4, 0) 0%, rgba(10, 7, 4, 0.82) 38%, rgba(10, 7, 4, 0.95) 100%);
  color: #fff;
  text-shadow: 0 1px 3px #000;
}
.bounty-name { font: 700 24px/1.1 var(--slab); overflow-wrap: anywhere; }
.bounty-overlay .ask { margin-top: 2px; font-size: 14px; color: #e8dcc4; }
.word {
  margin-top: 8px;
  padding: 6px 10px;
  border: 2px dashed var(--gold);
  border-radius: 6px;
  text-align: center;
  font: 700 26px/1.15 var(--slab);
  color: var(--gold);
  overflow-wrap: anywhere;
}
.word span { display: block; font: 11px -apple-system, sans-serif; color: #e8dcc4; text-transform: uppercase; letter-spacing: 1px; }
.word em { display: block; font: italic 600 16px var(--slab); color: #f1e6cf; }
.wanted-title {
  font-family: var(--western);
  font-size: 44px;
  text-align: center;
  letter-spacing: 4px;
  line-height: 1;
  margin: 4px 0 10px;
}
.wanted .btn.secondary { color: var(--parchment-ink); border-color: var(--parchment-edge); }
.catch-preview { display: block; width: 100%; border-radius: 6px; margin-top: 8px; }
.empty-slot { color: var(--muted); }
.happy-banner { background: #3a2a10; border-color: var(--gold); }
.score small { display: block; font-size: 12px; color: var(--muted); }
.alert p { margin: 0 0 10px; }
.alert-photo { display: block; width: 100%; max-height: 320px; object-fit: cover; border-radius: 6px; margin-bottom: 10px; }
.alert-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-btn { background: none; border: 0; padding: 8px 0; color: var(--rust-dark); text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; }
.awards-card { display: block; text-decoration: none; border-color: var(--gold); }

/* Hidden but still focusable/clickable via its <label> (iOS ignores display:none inputs in some versions). */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  opacity: 0;
}
.offline {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 5;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: #5a2a18;
  color: #ffd9c7;
  text-align: center;
  font-size: 14px;
}
