/* Scavenger Hunt: player app and admin panel. */
:root {
  --ink: #1f2a30; --muted: #5f6c73; --paper: #e9f2fb; --card: #fff; --line: #c9dbec;
  --teal: #146c64; --teal-dark: #0d4e48; --teal-soft: #e2f0ee;
  --coral: #e3592f; --coral-dark: #c2441d;
  --ok: #23824f; --ok-bg: #e2f3e8; --bad: #c0392b; --bad-bg: #fbe4e0; --wait: #8f5d00; --wait-bg: #fff1d3;
  --r: 0; --shadow: 0 0 0 1px var(--line);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; margin-top: 1.2em; }
a { color: var(--teal); }
p { margin: .3em 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.loading { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Top bar */
.bar {
  background: var(--teal); color: #fff; position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top); box-shadow: 0 3px 0 var(--coral);
}
.bar-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; padding: .6rem 16px; min-height: 62px; }
.brand { font-size: 1.3rem; margin: 0; font-weight: 800; }
.brand-icon { font-size: 1.6rem; }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar-title strong { font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score { background: rgba(255, 255, 255, .15); border-radius: 0; padding: .25rem .75rem; text-align: center; line-height: 1.1; }
.score strong { display: block; font-size: 1.35rem; }
.score small { font-size: .72rem; opacity: .9; }
.bar .icon-btn { color: #fff; border-color: rgba(255, 255, 255, .35); background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn svg { width: 24px; height: 24px; display: block; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.wrap.has-tabs { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.wrap.wide { max-width: 1180px; }
.wrap.narrow { max-width: 420px; padding-top: 10vh; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin: 0 0 16px; }
.hero { text-align: center; padding: 28px 20px; }
.hero-icon { font-size: 3rem; line-height: 1; margin-bottom: .4rem; }
.notice { background: var(--wait-bg); }
.section-title { margin: 24px 4px 10px; font-size: 1.05rem; color: var(--muted); font-weight: 700; }
.section-title small { font-weight: 400; display: block; font-size: .85rem; margin-top: 2px; }
.kicker { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--coral-dark); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 48px; padding: 0 18px;
  border-radius: 0; border: 2px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.primary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.btn.big { width: 100%; min-height: 58px; font-size: 1.1rem; margin-top: 8px; }
.btn.small { min-height: 42px; padding: 0 14px; font-size: .95rem; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.bad-outline { color: var(--bad); border-color: #efc2bb; }
.btn.link { border: 0; background: none; color: var(--teal); font-weight: 600; }
.btn.busy { opacity: .7; cursor: progress; }
.icon-btn {
  min-width: 44px; min-height: 44px; border-radius: 0; border: 2px solid var(--line); background: #fff;
  font: inherit; font-size: 1.2rem; cursor: pointer; color: inherit; flex: none;
}
.icon-btn:disabled { opacity: .35; cursor: default; }

/* Forms */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.field > span small { font-weight: 400; color: var(--muted); }
input, textarea, select {
  font: inherit; color: inherit; width: 100%; min-height: 48px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 0; background: #fff;
}
textarea { min-height: 0; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); }
.error { color: var(--bad); font-weight: 600; }
.choice { display: flex; gap: 12px; align-items: center; border: 2px solid var(--line); border-radius: 0; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.choice input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--teal); }
.choice small { display: block; color: var(--muted); }

/* Home */
.saved { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.row-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; text-align: left; background: #fff; border: 0;
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; font: inherit; color: inherit; cursor: pointer; min-height: 64px;
}
.row-btn small { display: block; color: var(--muted); }
.chev { font-size: 1.6rem; color: var(--muted); }

/* Stops */
.stop h2 { font-size: 1.6rem; margin-top: .2em; }
.clue { white-space: pre-wrap; font-size: 1.08rem; background: var(--teal-soft); border-radius: 0; padding: 12px 14px; }
.or { text-align: center; color: var(--muted); margin: 16px 0 8px; font-size: .92rem; }
.code-form { display: flex; gap: 8px; }
.code-form input { text-transform: uppercase; letter-spacing: .15em; font-weight: 700; text-align: center; }
.code-form .btn { flex: none; }
.done-msg { font-weight: 600; margin-top: 14px; }
details.card > summary { cursor: pointer; list-style: none; display: flex; gap: .6rem; align-items: center; font-weight: 700; min-height: 36px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "›"; margin-left: .3rem; font-size: 1.4rem; color: var(--muted); transition: transform .15s; }
details[open].card > summary::after { transform: rotate(90deg); }
.mini-score { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: auto; white-space: nowrap; }

/* Photo items */
.items { list-style: none; margin: 12px 0 4px; padding: 0; }
.item { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.thumb { width: 76px; height: 76px; flex: none; border-radius: 0; object-fit: cover; background: #eee; cursor: zoom-in; }
.thumb.empty { display: flex; align-items: center; justify-content: center; font-size: 1.8rem; background: var(--paper); border: 2px dashed var(--line); cursor: default; }
.item-body { flex: 1; min-width: 0; }
.item-text { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; font-size: .9rem; }
.pts { color: var(--muted); font-weight: 700; }
.reason { background: var(--bad-bg); color: #7d2219; border-radius: 0; padding: 6px 10px; font-size: .92rem; margin-bottom: 8px; }
.chip { display: inline-block; border-radius: 0; padding: 2px 10px; font-size: .8rem; font-weight: 700; background: #eee; white-space: nowrap; }
.chip.pending { background: var(--wait-bg); color: var(--wait); }
.chip.approved { background: var(--ok-bg); color: var(--ok); }
.chip.rejected { background: var(--bad-bg); color: var(--bad); }
.chip.hunt-running { background: var(--ok-bg); color: var(--ok); }
.chip.hunt-ready { background: var(--wait-bg); color: var(--wait); }
.chip.hunt-ended { background: #e8e8e8; color: #555; }

/* Formatted text, About boxes, maps */
.rich p { margin: 0 0 .6em; }
.rich p:last-child { margin-bottom: 0; }
.about { background: #f3f8fd; border-left: 4px solid var(--coral); border-radius: 0; padding: 10px 14px; margin: 10px 0 14px; }
.about-head { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--coral-dark); margin-bottom: 4px; }
.items-title { font-size: 1rem; margin: 16px 0 0; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.map-wrap { margin: 12px 0 14px; }
.map { height: 260px; border-radius: 0; overflow: hidden; isolation: isolate; background: #e3ebec; }
.map-fail { padding: 110px 12px 0; margin: 0; }
.map-pin { font-size: 28px; line-height: 1; background: none; border: 0; }
.map-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.finish-early > summary { font-weight: 700; }
.finish-early h3 { margin-top: 10px; }

/* Checkboxes and the photo release */
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 14px; cursor: pointer; font-weight: 600; }
.check input { width: 24px; height: 24px; min-height: 0; flex: none; margin: 0; accent-color: var(--teal); }
.check input:disabled + span { opacity: .5; }
input:disabled { background: #f2f2f2; color: #888; }
.release { border: 2px solid var(--line); border-radius: 0; padding: 12px 14px; margin: 4px 0 14px; }
.release-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.release-text { max-height: 260px; overflow: auto; font-size: .95rem; background: var(--paper); border-radius: 0; padding: 10px 12px; }

/* My photos */
.tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 4px 14px; }
.photo-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.photo-card { display: flex; gap: 14px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px; }
.photo-card img { width: 110px; height: 110px; object-fit: cover; border-radius: 0; flex: none; cursor: zoom-in; background: #eee; }

/* Leaderboard */
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 10px; }
.board li.me { outline: 3px solid var(--coral); }
.board .rank { width: 2.2rem; text-align: center; font-size: 1.4rem; font-weight: 800; flex: none; }
.board .name { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.board .name em { font-style: normal; font-weight: 400; color: var(--coral-dark); }
.board .name small { display: block; font-weight: 400; color: var(--muted); }
.board .pts { color: var(--ink); font-weight: 400; white-space: nowrap; }
.board .pts strong { font-size: 1.3rem; }

/* Bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 190px; background: none; border: 0; font: inherit; font-size: .8rem; font-weight: 700; color: var(--muted);
  padding: 8px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; cursor: pointer;
}
.tabs button span { font-size: 1.45rem; filter: grayscale(1); opacity: .65; }
.tabs button.on { color: var(--teal); }
.tabs button.on span { filter: none; opacity: 1; }

/* First-time tour */
.tour { position: fixed; inset: 0; z-index: 40; background: rgba(10, 25, 40, .55); }
.tour-intro { display: flex; align-items: center; justify-content: center; padding: 16px; }
.tour-tip {
  position: absolute; width: min(340px, calc(100vw - 24px)); background: #fff; padding: 16px 18px 12px;
  border: 3px solid var(--teal); box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}
.tour-intro .tour-tip { position: relative; width: min(420px, 100%); }
.tour-tip h3 { margin: 0 0 6px; }
.tour-tip p { margin: 0 0 12px; }
.tour-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.tour-count { margin-right: auto; color: var(--muted); font-size: .85rem; }
.tour-arrow {
  position: absolute; bottom: -13px; width: 20px; height: 20px; background: #fff; transform: rotate(45deg);
  border-right: 3px solid var(--teal); border-bottom: 3px solid var(--teal);
}
.tour-intro .tour-arrow { display: none; }
body.touring .tabs { z-index: 45; pointer-events: none; }
body.touring .tabs button { opacity: .35; }
body.touring .tabs button.tour-on { opacity: 1; color: var(--teal); background: var(--teal-soft); }
body.touring .tabs button.tour-on span { filter: none; opacity: 1; }

/* Toast and photo viewer */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  width: max-content; max-width: min(92vw, 520px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 0;
  font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: .2s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }
body.admin .toast { bottom: 24px; }
.lightbox { position: fixed; inset: 0; background: rgba(10, 15, 18, .92); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 0; }
.lightbox-close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .15); color: #fff; font-size: 1.3rem; cursor: pointer;
}

/* ---------- Admin ---------- */
.bar.admin .bar-in { max-width: 1180px; flex-wrap: wrap; }
.bar.admin { box-shadow: none; border-bottom: 3px solid var(--coral); }
.bar.admin .bar-in { align-items: flex-end; padding-bottom: 0; }
.bar.admin .brand-icon, .bar.admin .btn.link { align-self: center; }
.admin-nav { display: flex; gap: 2px; flex: 1; align-self: flex-end; margin-bottom: -3px; }
.admin-nav a {
  color: #fff; text-decoration: none; font-weight: 700; padding: 11px 20px 12px; background: rgba(255, 255, 255, .12);
  border: 3px solid transparent; border-bottom: 0;
}
.admin-nav a:hover { background: rgba(255, 255, 255, .22); }
.admin-nav a.on { background: var(--paper); color: var(--ink); border-color: var(--coral); padding-bottom: 15px; }
.bar .btn.link { color: #fff; min-height: 40px; padding: 0 8px; }
.login { text-align: center; }
.login .field { text-align: left; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar select { width: auto; min-width: 200px; }
.seg { display: inline-flex; background: #fff; border: 2px solid var(--line); border-radius: 0; overflow: hidden; }
.seg button { border: 0; background: none; font: inherit; font-weight: 700; padding: 0 14px; min-height: 44px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--teal); color: #fff; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.sub-card { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.sub-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #eee; cursor: zoom-in; }
.sub-card.working { opacity: .5; pointer-events: none; }
.sub-card.approved { box-shadow: inset 0 0 0 3px var(--ok-bg), var(--shadow); }
.sub-info { padding: 12px 14px 14px; }
.sub-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sub-team { font-size: 1.05rem; overflow-wrap: anywhere; }
.sub-text { font-weight: 600; margin: 2px 0; overflow-wrap: anywhere; }
.sub-actions { display: flex; gap: 8px; margin-top: 8px; }
.sub-actions .btn { flex: 1; padding: 0 10px; }
.reason-box { margin-top: 10px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 0; padding: 6px 10px; font: inherit; font-size: .82rem; cursor: pointer; color: inherit; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; grid-column: 1 / -1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.actions .btn.big { width: auto; margin: 0; }
.list { display: grid; gap: 10px; }
.list-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #fff; border-radius: var(--r);
  box-shadow: var(--shadow); padding: 14px 16px; color: inherit; text-decoration: none; flex-wrap: wrap;
}
.list-row small { display: block; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.form-row { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 160px; }
.form-row .field.narrow { flex: 0 1 150px; min-width: 120px; }
.form-row > .btn { margin-bottom: 14px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.loc-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.loc-num { width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.loc-name { font-weight: 700; font-size: 1.1rem; }
.loc-tools { display: flex; gap: 4px; }
.loc-gps { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.item-edit { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-edit > input { flex: 1; min-width: 0; }
.pts-input { display: flex; align-items: center; gap: 4px; flex: none; width: 104px; }
.pts-input input { text-align: right; padding: 10px 8px; }
.pts-input span { color: var(--muted); font-size: .85rem; }
.save-bar {
  position: sticky; bottom: 0; background: var(--paper); padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 12px; align-items: center; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 20px; z-index: 5;
}
.save-bar .btn.big { width: auto; margin: 0; }
.plan ol { padding-left: 1.4em; margin: 0; }
.plan li { margin-bottom: 12px; }
.plan ul { margin: 4px 0; padding-left: 1.2em; color: var(--muted); }
.loc-special .loc-num { background: var(--coral); font-size: 1.1rem; }
.rich-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.rich-tools .chip-btn { min-width: 40px; min-height: 34px; }
.rich-preview { margin-top: 8px; background: var(--paper); border-radius: 0; padding: 10px 12px; font-size: .95rem; }
.rich-preview:empty { display: none; }
.rich-preview::before { content: "Preview"; display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.release-edit { margin: 0 0 14px; }
.release-edit > summary { cursor: pointer; font-weight: 700; margin-bottom: 10px; }
.danger-zone { margin-top: 30px; text-align: right; }
.sign { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); text-align: center; padding: 40px 20px; margin-bottom: 20px; }
.sign h2 { font-size: 2.4rem; margin: .3em 0 .6em; }
.sign .qr { display: inline-block; padding: 12px; background: #fff; }
.sign .qr img, .sign .qr canvas { display: block; margin: 0 auto; }
.sign-kicker { font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--coral-dark); }
.sign-code { font-size: 1.2rem; }
.sign-code strong { font-size: 2.2rem; letter-spacing: .15em; display: block; margin-top: 4px; }

@media print {
  body { background: #fff; }
  .bar, .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .sign { box-shadow: none; break-after: page; page-break-after: always; margin: 0; padding-top: 12vh; }
}
@media (max-width: 560px) {
  .toolbar select { width: 100%; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 4px; font-size: .85rem; }
  .sub-grid { grid-template-columns: 1fr; }
  .admin-nav a { padding: 10px 12px 11px; }
  .admin-nav a.on { padding-bottom: 14px; }
}

/* Template import */
#tpl-import { margin-top: 20px; }
#tpl-paste { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; }
