:root {
  --navy: #182b49;
  --navy-2: #22375c;
  --gold: #ffcd00;
  --gold-dk: #e0b500;
  --bg: #0f1830;
  --card: #1b2a49;
  --card-2: #223357;
  --line: #2f4470;
  --text: #eef2fb;
  --muted: #9fb0d0;
  --green: #34c759;
  --green-dk: #1f9e46;
  --red: #ff453a;
  --red-dk: #c62f27;
  --amber: #ffb020;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2c52 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

.wrap { max-width: 780px; margin: 0 auto; padding: 0 14px 96px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(15, 24, 48, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 780px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.scorepill {
  background: linear-gradient(180deg, var(--gold), var(--gold-dk));
  color: #3a2c00; font-weight: 800; border-radius: 999px;
  padding: 6px 12px; font-size: 14px; white-space: nowrap;
}
.rankpill {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px; font-size: 13px; white-space: nowrap;
}
.iconbtn {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 10px; font-size: 13px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex; gap: 6px; margin: 14px 0;
  background: var(--card); padding: 6px; border-radius: 14px; border: 1px solid var(--line);
}
.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  padding: 10px; border-radius: 10px; font-weight: 700; font-size: 14px;
}
.tabs button.active { background: var(--navy-2); color: #fff; box-shadow: var(--shadow); }
.tabs .badge {
  display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px;
  background: var(--gold); color: #3a2c00; border-radius: 999px; font-size: 12px; font-weight: 800;
}

/* ---------- zone + clue cards ---------- */
.zone-h {
  display: flex; align-items: baseline; gap: 8px; margin: 22px 4px 10px;
}
.zone-h h2 { margin: 0; font-size: 18px; }
.zone-h span { color: var(--muted); font-size: 13px; }

.clue {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  color: var(--text);
}
.clue:active { transform: scale(0.995); }
.clue .pts {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dk)); color: #3a2c00;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; line-height: 1;
}
.clue .pts b { font-size: 18px; }
.clue .pts small { font-size: 9px; margin-top: 2px; }
.clue .body { flex: 1; min-width: 0; }
.clue .poem { white-space: pre-line; font-size: 14.5px; line-height: 1.45; }
.clue .idea { color: var(--muted); font-size: 12.5px; margin-top: 8px; font-style: italic; }
.clue .status { margin-top: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.chip.none { background: #2a3a5f; color: var(--muted); }
.chip.pending { background: #4a3a12; color: var(--amber); }
.chip.approved { background: #14371f; color: var(--green); }
.chip.rejected { background: #3f1714; color: #ff8079; }

/* ---------- leaderboard ---------- */
.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.lb-row.me { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-dk) inset; }
.lb-rank { width: 30px; text-align: center; font-weight: 800; font-size: 18px; color: var(--muted); }
.lb-row.top1 .lb-rank { color: var(--gold); }
.lb-name { flex: 1; font-weight: 700; }
.lb-name small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.lb-score { font-weight: 800; font-size: 20px; }
.lb-score small { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(6, 11, 24, 0.75);
  display: none; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; width: 100%; max-width: 780px;
  max-height: 92vh; overflow-y: auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
@media (min-width: 560px) {
  .modal-bg { align-items: center; }
  .modal { border-radius: 20px; }
}
.modal h3 { margin: 4px 0 2px; font-size: 17px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.modal .poem {
  white-space: pre-line; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-size: 14.5px; line-height: 1.45; margin-bottom: 14px;
}

.filebtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px dashed var(--line); border-radius: 16px; padding: 26px; text-align: center;
  color: var(--muted); background: var(--card); font-weight: 700;
}
.filebtn.has { border-style: solid; color: var(--text); padding: 10px; }
.filebtn img { border-radius: 12px; max-height: 260px; }
.geo {
  display: flex; align-items: center; gap: 8px; margin: 12px 2px; font-size: 13px; color: var(--muted);
}
.geo.ok { color: var(--green); }
.geo.err { color: #ff8079; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px;
  font-size: 16px; font-weight: 800; margin-top: 10px;
}
.btn-gold { background: linear-gradient(180deg, var(--gold), var(--gold-dk)); color: #3a2c00; }
.btn-green { background: linear-gradient(180deg, var(--green), var(--green-dk)); color: #04240f; }
.btn-red { background: linear-gradient(180deg, var(--red), var(--red-dk)); color: #2a0603; }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 0; }

input, select, textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 14px; font-size: 16px; outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 12px 2px 6px; font-weight: 600; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 26px 22px; box-shadow: var(--shadow);
}
.login-card .logo { text-align: center; margin-bottom: 6px; }
.login-card .logo .badge2 {
  display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px;
  border-radius: 18px; background: linear-gradient(180deg, var(--gold), var(--gold-dk));
  font-size: 30px; margin-bottom: 10px;
}
.login-card h1 { text-align: center; font-size: 21px; margin: 0 0 2px; }
.login-card p.tag { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.err { color: #ff8079; font-size: 13px; margin: 10px 2px 0; min-height: 16px; text-align: center; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin-top: 16px; line-height: 1.5; }

/* ---------- organizer submission cards ---------- */
.sub {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow);
}
.sub .photo { width: 100%; display: block; background: #000; max-height: 60vh; object-fit: contain; }
.sub .meta { padding: 12px 14px; }
.sub .meta .row1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sub .team { font-weight: 800; }
.sub .zone-tag { font-size: 12px; color: var(--muted); background: var(--card-2); padding: 3px 8px; border-radius: 999px; }
.sub .clue-name { font-weight: 700; margin: 6px 0 2px; }
.sub .loc { color: var(--muted); font-size: 13px; }
.sub .gps { font-size: 13px; margin: 8px 0; }
.sub .gps a { font-weight: 700; }
.sub .controls { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.sub .controls input { width: 84px; text-align: center; }
.sub .controls .btn { margin-top: 0; flex: 1; padding: 13px; }
.sub .decided { padding: 10px 14px; font-weight: 700; font-size: 13px; }

/* ---------- photo contest ---------- */
.reveal-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.reveal-status { font-weight: 700; font-size: 13.5px; color: var(--muted); flex: 1; min-width: 180px; }
.reveal-status.on { color: var(--green); }

.rate-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px;
}
.rate-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; background: #000; }
.rate-meta { flex: 1; min-width: 0; }
.rate-meta .team { font-weight: 800; }
.rate-meta .loc { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.rate-input { display: flex; align-items: center; gap: 8px; }
.rate-input span { color: var(--muted); font-size: 12px; }
.rate-input input { width: 78px; text-align: center; padding: 9px; }

.subtabs { display: flex; gap: 8px; margin-bottom: 12px; }
.subtabs button {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.subtabs button.active { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }

.danger-zone {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 28px; padding: 16px; border: 1px solid var(--red-dk); border-radius: 14px;
  background: rgba(255, 69, 58, 0.06);
}
.danger-zone b { display: block; color: #ff8079; font-size: 14px; }
.danger-zone small { color: var(--muted); font-size: 12.5px; }
.danger-zone > div { flex: 1; min-width: 200px; }

/* first-to-location bonus */
.sub.first { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-dk) inset, var(--shadow); }
.first-banner {
  background: linear-gradient(180deg, var(--gold), var(--gold-dk)); color: #3a2c00;
  font-weight: 800; font-size: 13px; line-height: 1.35; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
}

/* clickable leaderboard rows (organizer photos) */
.lb-row.clickable { cursor: pointer; }
.lb-row.clickable:hover { border-color: var(--gold-dk); }
.lb-row.clickable:active { transform: scale(0.996); }
.lb-chev { color: var(--muted); font-size: 24px; font-weight: 700; margin-left: 2px; }

.filter-chip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 14px;
}
.filter-chip span { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #05224a; border: 1px solid var(--line); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); opacity: 0;
  transition: all .25s; z-index: 200; pointer-events: none; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err2 { background: #3f1714; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
