/*
  UCSC Quest: organiser dashboard.
  Same system as the player screens: IEEE colours, General Sans, flat fields.
  Surfaces are separated by tone steps (paper → white), not lines or shadows.
  Tables and form fields keep their lines; they are real tables and fields.
*/

:root {
  --paper: #eef0ee;
  --panel: #ffffff;
  --sunk: #f5f6f4;
  --ink: #0a1628;
  --muted: #4b5767;
  --line: #d9dde0;
  --blue: #00629b;
  --blue-dark: #004c79;
  --navy: #002855;
  --green: #78be20;
  --green-soft: #e4f2d2;
  --yellow: #ffc72c;
  --yellow-soft: #fff1c7;
  --cyan: #00b5e2;
  --red: #ba0c2f;
  --red-soft: #fbe3e8;

  --font: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0; }
::selection { background: var(--yellow); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- logo: the white supplied logo used as a mask, so it takes the ink of its field */

.logo {
  display: block;
  height: 26px;
  aspect-ratio: 1808 / 300;
  background-color: currentColor;
  -webkit-mask: url(/brand/logo.png) left center / contain no-repeat;
  mask: url(/brand/logo.png) left center / contain no-repeat;
}

/* ---------- top bar: the blue chapter */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  background: var(--blue);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; font-weight: 600; }
.brand > span:last-child { line-height: 1.1; opacity: 0.9; }
.topbar .spacer { flex: 1; }
.topbar .btn.ghost { color: #fff; }
.topbar .btn.ghost:hover { background: var(--blue-dark); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 32px 28px 96px; }

/* ---------- hunt header + tabs */

.hunt-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.hunt-head h1 { font-weight: 700; font-size: clamp(2.25rem, 1.4rem + 3vw, 4rem); line-height: 0.95; letter-spacing: -0.03em; }
.hunt-head .sub { color: var(--muted); margin-top: 10px; font-size: 17px; }
.hunt-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tabs { display: flex; gap: 2px; margin-bottom: 28px; overflow-x: auto; background: var(--sunk); padding: 4px; width: fit-content; max-width: 100%; }
.tabs a { padding: 10px 18px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; transition: background-color 180ms ease, color 180ms ease; }
.tabs a:hover { color: var(--ink); background: var(--panel); }
.tabs a.on { color: #fff; background: var(--ink); }
.tabs .count { display: inline-block; margin-left: 8px; padding: 0 7px; background: var(--red); color: #fff; font-size: 13px; }

/* ---------- generic */

.panel { background: var(--panel); }
.panel > header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 18px 20px 6px; }
.panel > header h2, .panel > header h3 { font-size: 18px; font-weight: 600; }
.panel > header .hint { color: var(--muted); font-size: 14px; }
.panel .body { padding: 18px 20px 20px; }
.section-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 44px 0 14px; }
.section-title h2 { font-weight: 700; font-size: 28px; letter-spacing: -0.02em; }
.section-title .hint { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 0;
  background: var(--sunk); color: var(--ink); font: 600 15px var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 180ms ease, transform 140ms var(--ease-out);
}
.btn:hover { background: #e2e6e8; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: var(--navy); }
.btn.danger { background: transparent; color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.small { min-height: 32px; padding: 0 11px; font-size: 14px; }

input, select, textarea {
  font: 16px var(--font); color: var(--ink);
  padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 0; background: #fff;
  width: 100%;
}
textarea { resize: vertical; min-height: 66px; line-height: 1.45; }
textarea.clue { font-size: 17px; font-weight: 500; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 98, 155, 0.18); } /* taste-skill-ignore: focus ring, not a resting shadow */
input[type="color"] { width: 38px; height: 38px; padding: 2px; cursor: pointer; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 14px; font-weight: 600; }
.field > small { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.row > .field.grow { flex: 1 1 14rem; } /* a field that grows still wraps before it gets cramped */
/* a checkbox and its words stay on one line together */
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check > input { flex: none; }
.muted { color: var(--muted); }
.tnum { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.empty { padding: 40px 20px; color: var(--muted); }
.empty p { margin: 0 0 8px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 14px; font-weight: 600; background: var(--sunk); color: var(--ink); white-space: nowrap; }
.pill.live { background: var(--green); }
.pill.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: blink 1.6s infinite; }
.pill.ended { background: var(--navy); color: #fff; }
.pill.draft { background: var(--yellow); }
@keyframes blink { 50% { opacity: 0.25; } }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.issues { margin-bottom: 22px; display: grid; gap: 6px; }
.issue { padding: 10px 14px; font-size: 15px; }
.issue.error { background: var(--red-soft); color: #8a0822; }
.issue.warning { background: var(--yellow-soft); color: #5c4400; }
.issues details summary { cursor: pointer; font-weight: 600; font-size: 15px; padding: 4px 0; }

/* ---------- login: a full blue chapter */

.login-field { min-height: 100svh; background: var(--blue); color: #fff; display: grid; align-content: center; padding: 28px; }
.login { width: 100%; max-width: 420px; margin: 0 auto; background: transparent; }
.login .logo { height: 40px; margin-bottom: 48px; }
.login h1 { font-weight: 700; font-size: 56px; line-height: 0.95; letter-spacing: -0.03em; margin-bottom: 10px; }
.login p { margin: 0 0 28px; font-size: 18px; }
.login .field > span { color: #fff; }
.login input { border-color: transparent; min-height: 52px; }
.login .btn.primary { width: 100%; min-height: 52px; background: var(--yellow); color: var(--ink); font-size: 16px; }
.login .btn.primary:hover { background: #fff; }

/* ---------- hunts list: rows, not cards */

.hunt-grid { display: grid; gap: 4px; }
.hunt-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 22px 24px; text-decoration: none; transition: background-color 180ms ease; }
.hunt-card:hover { background: var(--yellow-soft); }
.hunt-card h3 { font-weight: 700; font-size: 28px; letter-spacing: -0.02em; margin: 0; }
.hunt-card .stats { display: flex; gap: 18px; color: var(--muted); font-size: 15px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- live */

.stats-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 22px; }
.stat { padding: 18px 20px; }
.stat b { display: block; font-weight: 700; font-size: 44px; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 8px; color: var(--muted); font-size: 15px; font-weight: 500; }
.stats-row .stat:first-child { background: var(--blue); color: #fff; }
.stats-row .stat:first-child span { color: rgba(255, 255, 255, 0.85); }
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.live-grid > * { min-width: 0; } /* wide tables scroll inside their panel, never the page */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 14px; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background-color 150ms ease; }
tbody tr.click:hover { background: var(--yellow-soft); }
.rank { font-weight: 700; font-size: 20px; width: 40px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank.top { color: var(--ink); background: var(--yellow); }
.team-name { font-weight: 700; }
.team-link { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.team-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.team-name small { display: block; font-weight: 500; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bar { display: flex; gap: 3px; min-width: 150px; align-items: center; }
.bar span { flex: 1; height: 12px; background: #e3e7e9; }
.bar span.on { background: var(--c, var(--ink)); }
.bar span.flag { flex: 0 0 12px; height: 12px; border-radius: 50%; border: 3px solid #c8cfd3; background: transparent; }
.bar span.flag.on { border-color: var(--ink); background: var(--green); }
.bar-label { font-size: 14px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; min-width: 24px; padding: 1px 7px; font-size: 13px; font-weight: 700; text-align: center; }
.badge.bad { background: var(--red); color: #fff; }
.badge.warn { background: var(--yellow); color: var(--ink); }

.feed { max-height: 680px; overflow-y: auto; }
.feed ul { margin: 0; padding: 0 0 6px; }
.feed li { list-style: none; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 10px 18px; font-size: 15px; align-items: start; }
.feed li:nth-child(even) { background: var(--sunk); }
.feed .ico { width: 16px; height: 16px; margin: 4px 0 0 5px; border-radius: 50%; border: 3px solid #b9c2c8; background: transparent; }
.feed .ico.advance, .feed .ico.registered { border-color: var(--green); background: var(--green); }
.feed .ico.finish { border-color: var(--ink); background: var(--green); }
.feed .ico.wrong, .feed .ico.ahead, .feed .ico.early { border-color: var(--red); background: var(--red); }
.feed .ico.decoy { border-color: #e0a800; background: var(--yellow); }
.feed time { color: var(--muted); font-size: 13px; white-space: nowrap; }

.board { overflow-x: auto; }
.board table { min-width: 640px; }
.board td { vertical-align: top; min-width: 90px; }
.board td:first-child { min-width: 120px; }
.board .tchip { display: inline-block; margin: 2px; padding: 2px 9px; border: 0; background: var(--c); color: var(--c-ink, #fff); font: 600 13px/1.5 var(--font); text-align: left; cursor: pointer; transition: transform 140ms var(--ease-out); }
.board .tchip:hover { transform: translateY(-2px); }

/* ---------- paths */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 22px; }
.toolbar .group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 6px 6px 14px; background: var(--panel); }
.toolbar .group input[type="number"] { width: 68px; padding: 6px 8px; }
.toolbar .group > span { white-space: nowrap; }

.matrix { overflow-x: auto; margin-bottom: 30px; }
.matrix th, .matrix td { text-align: center; padding: 9px 12px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix td.hit b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--c-ink, #fff); background: var(--c); font-size: 14px; }
.matrix td.tag { font-size: 14px; color: var(--muted); text-align: left; }

.path-card { margin-bottom: 22px; border-top: 6px solid var(--c); }
.path-card > header { align-items: center; padding-bottom: 14px; }
.path-card > header input.name { font-weight: 700; font-size: 22px; letter-spacing: -0.01em; border-color: transparent; padding: 4px 8px; max-width: 300px; }
.path-card > header input.name:hover { border-color: var(--line); }
.path-card.dirty { outline: 3px solid var(--yellow); }
.steps { display: grid; }
.step { display: grid; grid-template-columns: 44px minmax(180px, 280px) 1fr; gap: 14px; padding: 16px 20px; align-items: start; }
.step:nth-child(odd) { background: var(--sunk); }
.step .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 15px; background: var(--c); color: var(--c-ink, #fff); }
.step .num.start { background: transparent; color: var(--c); border: 3px solid var(--c); font-size: 13px; }
.step .where small { display: block; color: var(--muted); margin-top: 6px; font-size: 14px; }
.step .lead { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.step .lead b { color: var(--ink); }
.step.err .num { outline: 3px solid var(--red); outline-offset: 2px; }
.path-foot { display: flex; gap: 10px; align-items: center; padding: 14px 20px; background: var(--panel); }

/* ---------- codes */

.code-list { display: grid; gap: 4px; }
.panel.code { display: grid; grid-template-columns: 1fr auto; gap: 18px; padding: 18px 20px; align-items: start; }
.panel.code .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--muted); }
.panel.code .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.kind { font-size: 14px; font-weight: 700; padding: 2px 9px; }
.kind.start, .kind.finish { background: var(--ink); color: #fff; }
.kind.checkpoint { background: var(--blue); color: #fff; }
.kind.decoy { background: var(--yellow); color: var(--ink); }
.cards-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.card-thumb { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 6px 5px; border: 0; background: var(--sunk); cursor: zoom-in; font: 600 13px var(--font); color: var(--muted); transition: transform 140ms var(--ease-out), background-color 180ms ease; }
.card-thumb img { width: 68px; height: 68px; display: block; background: #fff; }
.card-thumb em { display: none; font-style: normal; font-size: 12px; font-weight: 700; color: var(--ink); }
.card-thumb.real { background: var(--yellow); color: var(--ink); }
.card-thumb.real em { display: block; }
.card-thumb:hover { transform: translateY(-2px); }
.card-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 15px; }
.card-controls input { padding: 5px 8px; }
.add-box { padding: 18px 20px; display: grid; gap: 12px; }

/* ---------- dialogs (they float, so they may cast a shadow) + toast */

dialog { border: 0; border-radius: 0; padding: 0; width: min(660px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 30px 80px -20px rgba(0, 20, 40, 0.45); } /* taste-skill-ignore: a dialog floats */
dialog::backdrop { background: rgba(0, 40, 85, 0.55); }
dialog[open] { animation: pop 260ms var(--ease-out); }
@keyframes pop { from { opacity: 0; transform: translateY(14px); } }
dialog > header { display: flex; align-items: center; gap: 10px; padding: 18px 20px; position: sticky; top: 0; background: var(--navy); color: #fff; z-index: 1; }
dialog > header h2 { font-weight: 700; font-size: 24px; letter-spacing: -0.01em; flex: 1; }
dialog > header .btn.ghost { color: #fff; }
dialog > header .btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }
dialog .body { padding: 20px; }
.route { list-style: none; margin: 0 0 20px; padding: 0; }
.route li { display: flex; gap: 12px; align-items: center; padding: 7px 0; }
.route .dot { width: 24px; height: 24px; border-radius: 50%; border: 3px solid #c8cfd3; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); flex: none; }
.route li.done .dot { background: var(--c); border-color: var(--c); color: var(--c-ink, #fff); }
.route .dot.advance, .route .dot.registered { background: var(--green); border-color: var(--green); }
.route .dot.wrong, .route .dot.ahead, .route .dot.early { background: var(--red); border-color: var(--red); }
.route .dot.decoy { background: var(--yellow); border-color: #e0a800; }
.route .dot.finish { background: var(--green); border-color: var(--ink); }
.route time { margin-left: auto; color: var(--muted); font-size: 14px; }
/* QR preview: the whole code always fits on screen, so another phone can scan it straight off the dialog
   (100dvh less the dialog's margin, header and padding). */
.qr-big { display: block; width: min(100%, 360px, calc(100dvh - 170px)); aspect-ratio: 1; margin: 0 auto; }
.qr-side { display: grid; gap: 12px; justify-items: center; margin-top: 14px; }
.qr-link { text-align: center; font-size: 14px; color: var(--muted); }
.small-print { margin: 0; text-align: center; font-size: 13px; }
@media (max-height: 560px) and (orientation: landscape) {
  .qr-dialog { width: min(760px, calc(100vw - 32px)); }
  .qr-dialog .body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
  .qr-dialog .qr-side { margin-top: 0; justify-items: stretch; }
}

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; transition: opacity 200ms ease, transform 240ms var(--ease-out); padding: 12px 18px; background: var(--ink); color: #fff; font-weight: 600; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--red); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.show-sm { display: none; }
@media (max-width: 700px) {
  .hide-md { display: none; }
}
@media (max-width: 960px) {
  .live-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .step { grid-template-columns: 38px 1fr; }
  .step > :last-child { grid-column: 1 / -1; }
  .hunt-card { grid-template-columns: 1fr; gap: 10px; }
  .hunt-card .stats { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 16px 72px; }
  .topbar { padding: 12px 16px; }
  .brand > span:last-child { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stat b { font-size: 34px; }
  .panel.code { grid-template-columns: 1fr; }
  .card-thumb img { width: 54px; height: 54px; }
  .panel.code .side { flex-direction: row; justify-content: flex-start; flex-wrap: wrap; }
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  /* the team table fits a phone: path shown under the name, tighter cells, a shorter bar */
  table.teams th, table.teams td { padding: 10px 8px; }
  table.teams .rank { width: 32px; font-size: 17px; }
  table.teams .bar { min-width: 64px; }
  table.teams .misses { white-space: nowrap; }
}
