/* Dispatch Hunt — theme layer on top of Bootstrap 5. Brand colours arrive as CSS variables. */
:root {
  --dh-header: #0B2E59;
  --dh-accent: #0A5CB8;
  --dh-accent-dark: #084C99;
  --dh-accent-rgb: 10, 92, 184;
  --dh-team: #6C757D;
  --bs-link-color: var(--dh-accent);
  --bs-link-color-rgb: var(--dh-accent-rgb);
  --bs-link-hover-color: var(--dh-accent-dark);
  --bs-primary: var(--dh-accent);
  --bs-primary-rgb: var(--dh-accent-rgb);
}
[hidden] { display: none !important; }
body { background: #F3F5F8; }
.tnum { font-variant-numeric: tabular-nums; }
.btn-primary {
  --bs-btn-bg: var(--dh-accent); --bs-btn-border-color: var(--dh-accent);
  --bs-btn-hover-bg: var(--dh-accent-dark); --bs-btn-hover-border-color: var(--dh-accent-dark);
  --bs-btn-active-bg: var(--dh-accent-dark); --bs-btn-active-border-color: var(--dh-accent-dark);
  --bs-btn-disabled-bg: var(--dh-accent); --bs-btn-disabled-border-color: var(--dh-accent);
}
.btn-outline-primary {
  --bs-btn-color: var(--dh-accent); --bs-btn-border-color: var(--dh-accent);
  --bs-btn-hover-bg: var(--dh-accent); --bs-btn-hover-border-color: var(--dh-accent);
  --bs-btn-active-bg: var(--dh-accent-dark); --bs-btn-active-border-color: var(--dh-accent-dark);
}
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--dh-accent); box-shadow: 0 0 0 .2rem rgba(var(--dh-accent-rgb), .25); }
.form-check-input:checked { background-color: var(--dh-accent); border-color: var(--dh-accent); }
.nav-tabs .nav-link { color: #495057; }
.nav-tabs .nav-link.active { color: #212529; font-weight: 600; }

.dh-nav { background: var(--dh-header); color: #fff; }
.dh-nav .brand-logo { max-height: 32px; width: auto; }
.dh-team-bar { border-bottom: 5px solid var(--dh-team); }
.dh-clock { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.team-swatch { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: -.05em; margin-right: .35em; }
.card-team { border-top: 4px solid var(--dh-team); }
.prewrap { white-space: pre-wrap; }

/* Letter slots */
.slots { display: flex; flex-wrap: wrap; gap: .5rem; }
.slot { width: 3.2rem; min-height: 3.7rem; border: 2px solid #CED4DA; border-radius: .4rem; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.slot.empty { border-style: dashed; color: #6C757D; }
.slot .l { font-family: var(--bs-font-monospace); font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.slot .n { font-size: .75rem; color: #6C757D; }
.slot input { width: 2.6rem; text-align: center; font-family: var(--bs-font-monospace); font-size: 1.1rem; text-transform: uppercase; margin-top: .25rem; }
.keytable td, .keytable th { text-align: center; padding: .2rem 0; font-family: var(--bs-font-monospace); }

/* Ticket */
.ticket-clue { font-size: 1.5rem; line-height: 1.4; margin: 0; }
.symbol-box { width: 64px; height: 64px; border: 2px solid #212529; border-radius: .5rem; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; flex: none; }

/* Field */
.sym-btn { aspect-ratio: 1; font-size: 2.4rem; line-height: 1; width: 100%; }
.field-wrap { max-width: 34rem; margin: 0 auto; }
.bottom-nav { position: sticky; bottom: 0; z-index: 5; }
.lead-me { background: #FFF3CD; border: 2px solid #E0A800; }

/* Overlays */
.dh-overlay { position: fixed; inset: 0; z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(15, 23, 32, .6); }
.dh-overlay[hidden] { display: none; }
.dh-sheet { align-items: flex-end; padding: 0; }
.dh-sheet .sheet { width: 100%; max-width: 34rem; background: #fff; border-radius: 1rem 1rem 0 0; padding: 1.5rem; }
.lockout { background: #111; color: #fff; flex-direction: column; text-align: center; gap: 1rem; }
.lockout .count { font-size: 5rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.paused-box { background: #fff; border-radius: .75rem; padding: 2rem; text-align: center; max-width: 24rem; }
.inject-card { width: 100%; max-width: 32rem; max-height: 92vh; overflow: auto; }
.inject-card .card-header { background: #B42318; color: #fff; }
.diversion-bar { position: sticky; top: 0; z-index: 6; }

/* Toasts */
#toasts { position: fixed; top: .75rem; right: .75rem; z-index: 1100; width: min(22rem, calc(100vw - 1.5rem)); display: flex; flex-direction: column; gap: .5rem; }
#toasts .toast { display: block; opacity: 1; }
#toasts .toast.urgent { border: 2px solid #B42318; }
#toasts .toast.urgent .toast-header { background: #B42318; color: #fff; }

/* C&C */
.feed { max-height: 70vh; overflow-y: auto; }
.feed li { display: flex; gap: .5rem; }
.feed .t { color: #6C757D; font-variant-numeric: tabular-nums; flex: none; min-width: 3.6rem; }
.chat-list { max-height: 22rem; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.chat-list .msg-control strong { color: #8A4B00; }
.table-sm td, .table-sm th { white-space: nowrap; }
.wrap-cell { white-space: normal !important; min-width: 12rem; }
#map, #ed-map { height: 70vh; min-height: 22rem; border-radius: .5rem; }
.ro .admin-only { display: none !important; }
.presence .badge { font-weight: 500; }
.editor-row { border: 1px solid #DEE2E6; border-radius: .5rem; padding: .75rem; background: #fff; }
.qr svg { width: 100%; height: auto; display: block; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}

/* ---------------------------------------------------------------- v2: C&C layout */
.game-switch { width: auto; max-width: 22rem; background-color: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.game-switch option { color: #212529; }
.nextbar { background: #E7F0FA; border-bottom: 1px solid #C9DBEF; font-size: .9rem; }
.nextbar.warn { background: #FFF3CD; border-bottom-color: #F0D78C; }
.cc-body { display: flex; align-items: stretch; }
.cc-side { flex: 0 0 210px; background: #fff; border-right: 1px solid #DEE2E6; padding: .5rem; position: sticky; top: 0; align-self: flex-start; max-height: 100vh; overflow-y: auto; }
.cc-side h3 { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: #6C757D; margin: .9rem .6rem .2rem; }
.cc-side a { display: flex; justify-content: space-between; align-items: center; padding: .38rem .6rem; border-radius: .4rem; color: #212529; text-decoration: none; font-size: .9rem; }
.cc-side a:hover { background: #F3F5F8; }
.cc-side a.on { background: rgba(var(--dh-accent-rgb), .12); color: var(--dh-accent); font-weight: 600; }
.cc-side a[hidden] { display: none; }
.cc-main { flex: 1 1 0; min-width: 0; padding: 1.25rem 1.5rem 3rem; }
@media (max-width: 991.98px) {
  .cc-body { display: block; }
  .cc-side { position: static; max-height: none; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: .25rem; border-right: 0; border-bottom: 1px solid #DEE2E6; }
  .cc-side h3, .cc-side .presence { display: none; }
  .cc-side a { white-space: nowrap; flex: none; }
  .cc-main { padding: 1rem; }
}
.live-map { height: 20rem; border-radius: 0 0 .375rem .375rem; }
.map-pin { background: #fff; border: 2px solid #212529; border-radius: 6px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.need { font-size: .9rem; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: .35rem; background: #E9ECEF; cursor: zoom-in; flex: none; }
.thumb-sm { width: 48px; height: 36px; vertical-align: middle; }
.photo-card { aspect-ratio: 4 / 3; object-fit: cover; background: #E9ECEF; cursor: zoom-in; }
.photo-view { text-align: center; }
.photo-view img { max-width: 92vw; max-height: 84vh; border-radius: .5rem; background: #fff; }
.psteps { display: flex; flex-wrap: wrap; gap: 4px; }
.pstep { min-width: 1.9rem; height: 1.6rem; border-radius: .3rem; background: #E9ECEF; color: #495057; font-size: .75rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; padding: 0 .3rem; }
.mode-card { display: block; border: 2px solid #DEE2E6; border-radius: .5rem; padding: .6rem .75rem; height: 100%; cursor: pointer; background: #fff; font-size: .9rem; }
.mode-card.on { border-color: var(--dh-accent); background: rgba(var(--dh-accent-rgb), .06); }
.mode-card input { margin-right: .25rem; }
.sticky-ed { position: sticky; top: 0; z-index: 4; background: #F3F5F8; padding: .5rem 0; }
.help-body { max-width: 52rem; }
.team-sel { min-width: 8rem; }
#pl-table select { min-width: 10rem; }

/* ---------------------------------------------------------------- v2: players */
.bottom-tabs { position: sticky; bottom: 0; z-index: 5; background: #fff; border-top: 1px solid #DEE2E6; display: flex; padding: .25rem; gap: .25rem; padding-bottom: calc(.25rem + env(safe-area-inset-bottom)); }
.bottom-tabs button { flex: 1 1 0; border: 0; background: none; border-radius: .5rem; padding: .55rem .25rem; font-size: .9rem; color: var(--dh-accent); font-weight: 500; }
.bottom-tabs button.active { background: var(--dh-accent); color: #fff; }
.bottom-tabs button.sos { color: #B42318; }
.arrive-btn { font-size: 1.35rem; padding-top: .9rem; padding-bottom: .9rem; }
.ticket-card { border-left: 6px solid var(--dh-team) !important; }
.instructions { color: #495057; }
.rule-note { font-size: .9rem; }
.practice-badge { background: #CFF4FC; color: #055160; }
.secret-wrap { min-height: calc(100vh - 3.5rem); display: flex; align-items: center; }
.neutral-head { background: #1F2328; color: #fff; }
.results-table td, .results-table th { vertical-align: middle; }
.photo-preview { max-width: 100%; max-height: 14rem; border-radius: .5rem; }

/* ---------------------------------------------------------------- v2: projector */
body.screen { background: #0B1A2E; color: #E6EDF3; overflow: hidden; }
.scr-wrap { height: 100vh; padding: 2vh 2.5vw; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; gap: 2vh 2vw; }
.scr-head { grid-column: 1 / 3; display: flex; align-items: center; gap: 1.5rem; }
.scr-title { font-size: 2.4vw; font-weight: 700; }
.scr-sub { color: #9FB7D6; font-size: 1.3vw; }
.scr-clock { margin-left: auto; font-size: 2.8vw; font-weight: 600; font-variant-numeric: tabular-nums; }
.scr-map { border-radius: 12px; overflow: hidden; background: #1B2D45; min-height: 0; }
.scr-side { display: flex; flex-direction: column; gap: 1.6vh; min-height: 0; overflow: hidden; }
.scr-team .nm { font-size: 1.6vw; font-weight: 700; }
.scr-team .meta { color: #9FB7D6; font-size: 1vw; }
.scr-team .pts { margin-left: auto; font-size: 1.6vw; font-weight: 700; }
.scr-lane { display: grid; gap: 4px; margin-top: .4vh; }
.scr-step { height: 3.4vh; border-radius: 5px; background: rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1vw; }
.scr-latest { margin-top: auto; background: rgba(255,255,255,.05); border-radius: 10px; padding: 1.4vh 1.2vw; font-size: 1.15vw; }
.scr-latest .lbl { color: #9FB7D6; letter-spacing: .15em; text-transform: uppercase; font-size: .8vw; margin-bottom: .6vh; }
.scr-foot { grid-column: 1 / 3; color: #7F97B5; font-size: .9vw; }
.scr-wait { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2vh; padding: 4vw; }
.scr-wait h1 { font-size: 5vw; font-weight: 700; margin: 0; }
.scr-wait p { font-size: 2vw; color: #9FB7D6; margin: 0; }
.scr-pulse { width: 1.2vw; height: 1.2vw; border-radius: 50%; background: var(--dh-accent); animation: scrpulse 2s infinite ease-in-out; }
@keyframes scrpulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.2); } }
.scr-results { grid-column: 1 / 3; overflow: auto; }
.scr-results table { width: 100%; font-size: 1.6vw; color: #E6EDF3; }
.scr-results td, .scr-results th { padding: .8vh 1vw; border-bottom: 1px solid rgba(255,255,255,.1); }
.scr-dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }
@media (prefers-reduced-motion: reduce) { .scr-pulse { animation: none; } }
body.cc #toasts { top: auto; bottom: .75rem; }
