:root {
  color-scheme: light;
  --navy: #062856;
  --navy-deep: #041d41;
  --blue: #1976ff;
  --blue-soft: #eaf3ff;
  --coral: #ff493d;
  --coral-dark: #e9332a;
  --ink: #0e2546;
  --muted: #61708a;
  --line: #dce6f2;
  --surface: #ffffff;
  --canvas: #f4f8fc;
  --easy: #17a765;
  --medium: #f2a51a;
  --hard: #ef4338;
  --radius: 18px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { min-height: 100vh; margin: 0; background: var(--canvas); }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; }

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 66px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-deep), var(--navy));
  box-shadow: 0 4px 18px rgb(4 29 65 / 20%);
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand span { max-width: 145px; font-size: .86rem; font-weight: 800; line-height: 1.05; letter-spacing: .01em; }
.brand strong { display: block; color: var(--coral); font-size: 1.13rem; }
.app-header form { margin: 0; }
.icon-button { width: 42px; height: 42px; border: 1px solid rgb(255 255 255 / 25%); border-radius: 50%; padding: 0; color: #fff; background: rgb(255 255 255 / 8%); font-size: 1.25rem; }

.app-main { width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 112px; }
.guest-shell .app-main { min-height: calc(100vh - 54px); display: grid; align-content: center; padding-top: 32px; padding-bottom: 32px; }
.page-kicker { margin: 0 0 5px; color: var(--blue); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(1.55rem, 8vw, 2.15rem); line-height: 1.1; }
h2 { margin: 0; font-size: 1.08rem; }
.page-heading { margin-bottom: 18px; }
.page-heading p { margin: 7px 0 0; }
.muted { color: var(--muted); }

.card {
  margin: 0 0 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(14 37 70 / 7%);
}
.card-title { display: flex; gap: 9px; align-items: center; margin-bottom: 16px; color: var(--ink); }
.card-title::before { content: ""; width: 11px; height: 11px; flex: 0 0 11px; border: 4px solid var(--coral); border-radius: 50%; box-shadow: 0 0 0 2px var(--navy); }

.button, button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  color: white;
  background: linear-gradient(180deg, #ff574b, var(--coral-dark));
  box-shadow: 0 6px 14px rgb(239 67 56 / 20%);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.button-block { width: 100%; }
.button-secondary { border: 1px solid #9cc5ff; color: #075dce; background: #fff; box-shadow: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgb(25 118 255 / 35%); outline-offset: 2px; }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid #cbd8e7;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
}
input[type="checkbox"] { width: 22px; min-height: 22px; accent-color: var(--blue); }
label { color: var(--ink); font-weight: 700; }
form p { display: grid; gap: 6px; margin: 0 0 15px; }
.errorlist { margin: 0 0 6px; padding: 10px 13px; border-radius: 9px; color: #9d1e18; background: #ffe6e3; list-style: none; font-size: .88rem; }
.helptext { color: var(--muted); font-size: .78rem; }

.message { margin: 0 0 14px; padding: 12px 14px; border: 1px solid #f3d38b; border-radius: 12px; background: #fff6d8; }
.status-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 11px; font-size: .76rem; font-weight: 800; }
.status-easy { color: #087742; background: #dcf7e9; }
.status-medium { color: #8b5800; background: #fff0ca; }
.status-hard { color: #a5241d; background: #ffe1df; }
.status-instructor { color: #5134a4; background: #e9e3ff; }

.dashboard-grid { display: grid; gap: 14px; }
.target-card { text-align: center; overflow: hidden; }
.target-meta { display: flex; justify-content: center; gap: 7px; margin-bottom: 12px; }
.selfie-wrap { width: 148px; height: 148px; margin: 0 auto 14px; padding: 5px; border: 3px solid var(--blue); border-radius: 50%; background: #fff; box-shadow: 0 8px 24px rgb(25 118 255 / 18%); }
.selfie { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.selfie-placeholder { display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); font-size: 3rem; font-weight: 800; }
.target-card h2 { font-size: 1.4rem; }
.target-card .school { margin: 7px 0 0; color: var(--muted); font-size: .88rem; }
.target-note { margin: 15px 0 0; padding: 12px; border-radius: 12px; background: var(--blue-soft); text-align: left; font-size: .9rem; }
.replace-box { margin: 17px -7px -7px; padding: 14px; border: 1px solid #ffce72; border-radius: 13px; background: #fff8e5; }
.replace-box p { margin: 0 0 10px; font-size: .82rem; }

.score-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.score-number { color: var(--navy); font-size: 3.2rem; font-weight: 800; line-height: 1; letter-spacing: -.06em; }
.score-number small { font-size: .78rem; letter-spacing: normal; }
.score-catches { text-align: right; color: var(--muted); font-size: .82rem; }

.difficulty-form select { margin-bottom: 9px; }
.difficulty-form .form-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.difficulty-form .form-actions small { flex: 1; font-size: .74rem; }
.difficulty-form button { min-height: 42px; padding: 9px 13px; box-shadow: none; font-size: .8rem; }

.scanner-card { color: #fff; border-color: #12558f; background: linear-gradient(145deg, #07366b, #041d41); }
.scanner-card .card-title, .scanner-card .muted { color: #fff; }
.scanner-card .muted { opacity: .76; }
.scanner-frame { position: relative; min-height: 140px; display: grid; place-items: center; margin: 14px 0; border: 1px solid #2879bd; border-radius: 14px; background: repeating-linear-gradient(0deg, transparent 0 24px, rgb(34 125 204 / 10%) 25px), repeating-linear-gradient(90deg, transparent 0 24px, rgb(34 125 204 / 10%) 25px), #052b58; overflow: hidden; }
.scanner-frame::before, .scanner-frame::after { content: ""; position: absolute; width: 44px; height: 44px; border-color: #65bcff; border-style: solid; }
.scanner-frame::before { top: 12px; left: 12px; border-width: 3px 0 0 3px; border-radius: 8px 0 0; }
.scanner-frame::after { right: 12px; bottom: 12px; border-width: 0 3px 3px 0; border-radius: 0 0 8px; }
.scanner-card button { width: 100%; }
#qr-reader { width: 100%; overflow: hidden; border: 0 !important; }
#my-qr { width: min(100%, 260px); margin: 0 auto; padding: 10px; border-radius: 12px; background: #fff; }

.catch-list { margin: 0; padding: 0; list-style: none; }
.catch-list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.catch-list li:last-child { border-bottom: 0; }
.points { color: var(--easy); font-weight: 800; white-space: nowrap; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 7px 10px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 -8px 24px rgb(14 37 70 / 8%);
  backdrop-filter: blur(14px);
}
.bottom-nav a { min-width: 82px; min-height: 54px; display: grid; place-items: center; align-content: center; gap: 3px; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 700; }
.bottom-nav a[aria-current="page"] { color: var(--blue); background: var(--blue-soft); }
.nav-icon { font-size: 1.35rem; line-height: 1; }

.leaderboard-tabs { display: flex; gap: 7px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.leaderboard-tabs a { flex: 0 0 auto; padding: 8px 13px; border-radius: 999px; color: var(--muted); background: #e9eef5; font-size: .78rem; font-weight: 800; text-decoration: none; }
.leaderboard-tabs a:first-child { color: white; background: var(--blue); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 11px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th:last-child, td:last-child { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.rank { width: 30px; color: var(--muted); font-weight: 800; }
.rank-selfie { width: 38px; height: 38px; margin-right: 8px; border: 2px solid #87baff; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.player-name { display: inline-block; max-width: 150px; vertical-align: middle; }

.auth-card { width: 100%; max-width: 470px; margin: auto; }
.auth-brand { margin-bottom: 22px; text-align: center; }
.auth-brand img { width: 110px; height: 110px; object-fit: contain; }
.auth-brand h1 { margin-top: 5px; }
.auth-brand h1 strong { display: block; color: var(--coral); }
.auth-card .card { padding: 22px; }
.auth-card button { width: 100%; margin-top: 4px; }
.turnstile-wrap { width: 100%; min-height: 65px; margin: 4px 0 15px; overflow: hidden; }
.cf-turnstile { width: 100%; }
.auth-footer { margin: 17px 0 0; text-align: center; font-size: .84rem; }
.registration-intro { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }

footer { padding: 18px 16px 100px; color: var(--muted); text-align: center; font-size: .75rem; }
.guest-shell footer { padding-bottom: 24px; }
footer a { color: inherit; }

@media (min-width: 700px) {
  .app-header { padding-right: max(24px, calc((100% - 920px) / 2)); padding-left: max(24px, calc((100% - 920px) / 2)); }
  .app-main { max-width: 920px; padding: 28px 24px 120px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.35fr) minmax(250px, .65fr); align-items: start; }
  .target-card { grid-row: span 2; }
  .dashboard-wide { grid-column: 1 / -1; }
  .leaderboard-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .leaderboard-layout .card:first-child { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: no-preference) {
  .card { animation: card-in .3s ease both; }
  @keyframes card-in { from { opacity: 0; transform: translateY(6px); } }
}
