:root {
  --bg: #0a0f1a;
  --surface: #141b2d;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --ok: #22c55e;
  --err: #ef4444;
  --link: #38bdf8;
  --map-hud: rgba(8, 12, 22, 0.82);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid #334155;
}

.brand a {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
}

.nav .user {
  color: var(--muted);
  font-size: 0.9rem;
}

.container {
  flex: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  width: 100%;
}

.footer {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid #334155;
}

h1 {
  font-size: 1.75rem;
  margin-top: 0;
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
}

.hint,
.hint code {
  color: var(--muted);
  font-size: 0.95rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  display: block;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid #334155;
  color: inherit;
  transition: border-color 0.15s;
}
.card:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  color: var(--accent);
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 520px;
  margin: 1rem 0;
}

.form-narrow {
  max-width: 360px;
}

.form label,
.timing-bar label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form input,
.form select,
.form textarea,
.timing-bar input,
.timing-bar select {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
  font: inherit;
}

.form button,
.timing-bar button {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
}
.form button:hover,
.timing-bar button:hover {
  filter: brightness(1.05);
}

.form-inline {
  margin: 1rem 0;
}

.leaderboard-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #334155;
  border-radius: 10px;
}

.leaderboard-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

.leaderboard-table thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #0f172a;
  box-shadow: inset 0 -1px 0 #334155;
}

.leaderboard-table td {
  vertical-align: top;
  font-size: 0.82rem;
  line-height: 1.35;
}

.leaderboard-table th.leaderboard-col-num,
.leaderboard-table td.leaderboard-col-num {
  width: 2.25rem;
  text-align: right;
  padding-right: 0.35rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

body.admin-runners-bulk-page .runner-row-hidden td {
  opacity: 0.75;
  color: #94a3b8;
}

.map-leaderboard-panel {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: 1rem;
  padding: 0 1rem 1rem;
}

.map-leaderboard-panel__head {
  max-width: 100%;
  margin: 0 auto 0.6rem;
  padding: 0 0.25rem;
}

.map-leaderboard-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 2rem);
  min-height: 780px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0b1220;
}

body.leaderboard-page .container {
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.5rem;
  margin: 1rem 0;
}

.map-toolbar select {
  min-width: 14rem;
}

.drone-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid #334155;
}

.drone-toolbar-label {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.25rem;
}

.drone-btn {
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #334155;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

.drone-btn:hover:not(:disabled) {
  background: #475569;
}

.drone-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.drone-btn-primary {
  background: #14532d;
  border-color: #166534;
  color: #ecfdf5;
}

.drone-btn-primary:hover:not(:disabled) {
  background: #166534;
}

/* Tour toolbar: centered rocker / breaker switches */
.map-controls-bar-drone .drone-switch {
  position: relative;
  min-width: 3.4rem;
  padding: 0.4rem 0.72rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 6px;
  border: 1px solid rgba(72, 80, 94, 0.95);
  background: linear-gradient(180deg, #383e4a 0%, #232830 42%, #1a1e26 100%);
  color: #eef2f7;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -4px 10px rgba(0, 0, 0, 0.38),
    0 1px 2px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.06s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.map-controls-bar-drone .drone-switch:hover:not(:disabled) {
  background: linear-gradient(180deg, #404857 0%, #2a303a 42%, #1f242e 100%);
  border-color: rgba(148, 163, 184, 0.4);
}

.map-controls-bar-drone .drone-switch:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.map-controls-bar-drone .drone-btn-primary.drone-switch {
  border-color: rgba(34, 197, 94, 0.5);
  background: linear-gradient(180deg, #17823e 0%, #0f5130 48%, #0a3020 100%);
  color: #ecfdf5;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 0 12px rgba(34, 197, 94, 0.2);
}

.map-controls-bar-drone .drone-btn-primary.drone-switch:hover:not(:disabled) {
  background: linear-gradient(180deg, #169042 0%, #14532d 48%, #0c3824 100%);
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 0 16px rgba(34, 197, 94, 0.32);
}

.map-controls-bar-drone .drone-switch:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.15);
}

.drone-status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 0.25rem;
}

.flight-controls:not(.flight-controls--overlay) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  margin: 0.25rem 0 0.9rem;
  padding: 0.55rem 0.8rem;
  background: rgba(20, 27, 45, 0.92);
  border: 1px solid #334155;
  border-radius: 10px;
}

/*
 * Flight console: centered without transform — transform + backdrop-filter on
 * children makes many browsers sample solid black (worse in fullscreen).
 */
.flight-controls--overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  z-index: 3;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 0.35rem 0.35rem;
  gap: 0.35rem;
  background: transparent;
  border: none;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  box-shadow: none;
}

/* Reinforce: overlay never expands map-frame height */
#flight_controls.flight-controls--overlay {
  position: absolute;
}

.flight-controls-help {
  margin: 0 0 0.3rem;
  font-size: 0.62rem;
  color: rgba(148, 163, 184, 0.95);
  letter-spacing: 0.02em;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: auto;
  align-self: center;
  width: 100%;
  max-width: min(100%, 720px);
  padding: 0 0.5rem;
}

.flight-controls__bar,
.flight-gauges,
.flight-gauge {
  pointer-events: auto;
}

.flight-controls__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.45rem;
  padding: 0.45rem 0.65rem;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.04) 42%, rgba(15, 23, 42, 0.65) 100%);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  max-width: min(100%, 720px);
  margin-left: auto;
  margin-right: auto;
}

.flight-controls--overlay .flight-controls__bar {
  width: auto;
  max-width: min(100%, 720px);
  margin-top: 0;
  margin-bottom: 0;
  margin-left: auto;
  margin-right: auto;
  align-self: center;
  /* Minimal tint — any solid fill reads as a “black box” over the map */
  background: rgba(8, 10, 14, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 2px 10px rgba(0, 0, 0, 0.1);
}

.flight-controls--overlay .map-controls-bar-drone {
  width: auto;
  margin-left: auto;
  margin-right: auto;
  justify-content: center;
}

.flight-controls--overlay .drone-status {
  font-size: 0.76rem;
}

.map-frame--flight-console .map-hud {
  bottom: 200px;
}

.drone-zoom-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.35rem;
  padding: 0.22rem 0.5rem;
  background: rgba(8, 10, 14, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.drone-zoom-k {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

.drone-zoom-v {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  min-width: 2.6rem;
  text-align: center;
}

.drone-zoom-btn {
  width: 1.55rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid rgba(72, 80, 94, 0.9);
  border-radius: 4px;
  background: linear-gradient(180deg, #3a404c 0%, #252a34 100%);
  color: #e8edf4;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.drone-zoom-btn:hover {
  background: linear-gradient(180deg, #454c5a 0%, #2e343f 100%);
  border-color: rgba(148, 163, 184, 0.45);
}

.drone-zoom-btn:active {
  transform: translateY(1px);
}

.flight-gauges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.45rem;
  pointer-events: none;
}

/* Bottom corners: left = SPD/ATT/ALT, right = TURN/HDG/VSI — center of map stays clear */
.flight-gauges-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.5rem 1rem;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0.3rem;
  padding: 0 0.15rem;
  pointer-events: none;
}

.flight-gauges--dock {
  display: grid;
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  grid-template-rows: auto;
  gap: 0.3rem 0.35rem;
  flex: 0 1 auto;
  width: auto;
  max-width: min(48%, 340px);
  padding: 0.4rem 0.45rem 0.35rem;
  background: rgba(6, 8, 12, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  pointer-events: auto;
}

/* Slightly tighter instruments so three fit per corner on smaller widths */
.flight-gauges--dock .flight-gauge__bezel {
  width: 82px;
  height: 82px;
}

.flight-gauges--dock .flight-gauge__face {
  inset: 8px;
}

.flight-gauges--dock .flight-gauge__needle--asi,
.flight-gauges--dock .flight-gauge__needle--alt,
.flight-gauges--dock .flight-gauge__needle--vsi {
  height: 28px;
}

.flight-gauges--dock .flight-gauge__needle--asi::after {
  bottom: -2px;
}

/* Legacy single-panel layout (if used elsewhere) */
.flight-gauges--sixpack {
  display: grid;
  grid-template-columns: repeat(3, minmax(104px, 1fr));
  grid-template-rows: auto auto;
  gap: 0.5rem 0.55rem;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  padding: 0.55rem 0.65rem 0.45rem;
  background: rgba(6, 8, 12, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.flight-gauge {
  position: relative;
  text-align: center;
  overflow: visible;
}

.flight-gauge--sixpack {
  width: 100%;
  max-width: 128px;
  padding: 0.15rem 0.1rem 0.2rem;
  pointer-events: auto;
}

.flight-gauge--sixpack > * {
  position: relative;
  z-index: 1;
}

.flight-gauge__bezel {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #3a3d44 0%, #1a1b1f 42%, #0e0e12 100%);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    inset 0 2px 4px rgba(255, 255, 255, 0.08),
    inset 0 -3px 8px rgba(0, 0, 0, 0.65);
}

.flight-gauge__screw {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #8b9099, #2a2d34);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  z-index: 5;
  pointer-events: none;
}

.flight-gauge__screw--tl {
  top: 5px;
  left: 5px;
}

.flight-gauge__screw--tr {
  top: 5px;
  right: 5px;
}

.flight-gauge__screw--bl {
  bottom: 5px;
  left: 5px;
}

.flight-gauge__screw--br {
  bottom: 5px;
  right: 5px;
}

.flight-gauge__face {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #08080a;
  box-shadow:
    inset 0 0 16px rgba(0, 0, 0, 0.95),
    inset 0 0 2px rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* ASI — course progress as “speed”, pastel arcs */
.flight-gauge__face--asi {
  background: #0a0a0c;
}

.flight-gauge__asi-arcs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from 225deg,
    #1a2520 0deg,
    #b8d4c4 28deg,
    #9dc9a8 52deg,
    #c9d4a8 76deg,
    #d4c896 100deg,
    #c9a8a8 124deg,
    #1a1518 150deg,
    #0a0a0c 360deg
  );
  opacity: 0.85;
  -webkit-mask: radial-gradient(circle at center, transparent 52%, #000 53%);
  mask: radial-gradient(circle at center, transparent 52%, #000 53%);
}

.flight-gauge__face--asi::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 4deg, rgba(255, 255, 255, 0.12) 4deg 5deg);
  opacity: 0.35;
  -webkit-mask: radial-gradient(circle at center, transparent 50%, #000 51%);
  mask: radial-gradient(circle at center, transparent 50%, #000 51%);
  pointer-events: none;
}

.flight-gauge__needle--asi {
  position: absolute;
  width: 2px;
  height: 34px;
  left: 50%;
  bottom: 50%;
  margin-left: -1px;
  margin-bottom: -2px;
  background: linear-gradient(to top, #aab0b8, #fff);
  transform-origin: bottom center;
  transform: rotate(calc(-135deg + var(--g, 0) * 270deg));
  border-radius: 1px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
  z-index: 3;
}

.flight-gauge__needle--asi::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  left: 50%;
  bottom: -3px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6b7280, #111);
  border: 1px solid #9ca3af;
}

/* Artificial horizon */
.flight-gauge__face--ai {
  background: #0a0a0c;
}

.flight-gauge__ai-bank {
  position: absolute;
  inset: -40%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0.5;
  pointer-events: none;
}

.flight-gauge__ai-horizon-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
}

.flight-gauge__ai-horizon {
  position: absolute;
  left: -15%;
  width: 130%;
  height: 130%;
  top: 50%;
  transform: translateY(calc((0.5 - var(--pitch-norm, 0.5)) * 42px));
  transition: transform 0.12s ease-out;
}

.flight-gauge__ai-sky {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 50%;
  background: linear-gradient(180deg, #9ec5e8 0%, #b8d4f0 100%);
}

.flight-gauge__ai-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 50%;
  background: linear-gradient(180deg, #c9a882 0%, #a08068 100%);
}

.flight-gauge__ai-plane {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 8px;
  margin-left: -11px;
  margin-top: -4px;
  background: #e8a060;
  clip-path: polygon(0 40%, 18% 40%, 35% 0, 65% 0, 82% 40%, 100% 40%, 100% 60%, 82% 60%, 65% 100%, 35% 100%, 18% 60%, 0 60%);
  z-index: 4;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.flight-gauge__ai-mark {
  position: absolute;
  left: 50%;
  top: 8px;
  width: 24px;
  height: 10px;
  margin-left: -12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.7;
}

/* Altimeter */
.flight-gauge__face--alt {
  background: radial-gradient(circle at 50% 50%, #101014 0%, #060608 100%);
}

.flight-gauge__alt-ticks {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 25deg, rgba(255, 255, 255, 0.35) 25deg 26deg);
  -webkit-mask: radial-gradient(circle at center, transparent 46%, #000 47%);
  mask: radial-gradient(circle at center, transparent 46%, #000 47%);
  opacity: 0.55;
}

.flight-gauge__needle--alt {
  position: absolute;
  width: 2px;
  height: 30px;
  left: 50%;
  bottom: 50%;
  margin-left: -1px;
  margin-bottom: -1px;
  background: linear-gradient(to top, #94a3b8, #fff);
  transform-origin: bottom center;
  transform: rotate(calc(-90deg + var(--g, 0.5) * 180deg));
  z-index: 3;
  border-radius: 1px;
}

.flight-gauge__alt-hub {
  position: absolute;
  width: 8px;
  height: 8px;
  left: 50%;
  top: 50%;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #64748b, #0f172a);
  border: 1px solid #cbd5e1;
  z-index: 4;
}

/* Turn coordinator */
.flight-gauge__face--tc {
  background: radial-gradient(circle at 50% 35%, #121418 0%, #060608 100%);
}

.flight-gauge__tc-plane {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 28px;
  height: 11px;
  margin-left: -14px;
  margin-top: -5px;
  background: #e8eef5;
  clip-path: polygon(0 45%, 22% 45%, 38% 0, 62% 0, 78% 45%, 100% 45%, 100% 55%, 78% 55%, 62% 100%, 38% 100%, 22% 55%, 0 55%);
  transform: rotate(calc(var(--ball, 0) * -14deg));
  transition: transform 0.1s ease-out;
  z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.flight-gauge__tc-incline {
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 52px;
  height: 18px;
  margin-left: -26px;
  border-radius: 0 0 26px 26px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: none;
  background: linear-gradient(180deg, rgba(40, 50, 60, 0.5), rgba(20, 24, 30, 0.85));
  overflow: hidden;
  z-index: 3;
}

.flight-gauge__tc-ball {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #4b5563, #111);
  transform: translateX(calc(var(--ball, 0) * -14px));
  transition: transform 0.12s ease-out;
  box-shadow: inset 0 -1px 2px rgba(255, 255, 255, 0.15);
}

/* Heading DG */
.flight-gauge__face--dg {
  background: #08080a;
}

.flight-gauge__dg-card {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #1a1c22 0deg,
    #1a1c22 360deg
  );
  transform: rotate(calc(var(--hdg, 0) * -1deg));
  transition: transform 0.12s ease-out;
}

.flight-gauge__dg-card::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.flight-gauge__dg-n,
.flight-gauge__dg-e,
.flight-gauge__dg-s,
.flight-gauge__dg-w {
  position: absolute;
  font-size: 0.55rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.88);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.flight-gauge__dg-n {
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.flight-gauge__dg-e {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.flight-gauge__dg-s {
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.flight-gauge__dg-w {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.flight-gauge__dg-plane {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 12px solid #f1f5f9;
  margin-left: -5px;
  z-index: 4;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.flight-gauge__dg-knob {
  position: absolute;
  width: 8px;
  height: 8px;
  left: 10px;
  bottom: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6b7280, #1f2937);
  border: 1px solid #9ca3af;
  z-index: 5;
  pointer-events: none;
  opacity: 0.85;
}

/* VSI */
.flight-gauge__face--vsi {
  background: radial-gradient(circle at 50% 50%, #0c0c10 0%, #050508 100%);
}

.flight-gauge__vsi-scale {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255, 255, 255, 0.2) 49%, rgba(255, 255, 255, 0.2) 51%, transparent 52%),
    repeating-conic-gradient(from -90deg, transparent 0deg 18deg, rgba(255, 255, 255, 0.2) 18deg 19deg);
  -webkit-mask: radial-gradient(circle at center, transparent 38%, #000 40%);
  mask: radial-gradient(circle at center, transparent 38%, #000 40%);
  opacity: 0.65;
}

.flight-gauge__needle--vsi {
  position: absolute;
  width: 2px;
  height: 32px;
  left: 50%;
  bottom: 50%;
  margin-left: -1px;
  margin-bottom: -1px;
  background: linear-gradient(to top, #94a3b8, #fff);
  transform-origin: bottom center;
  transform: rotate(calc(-90deg + var(--g, 0.5) * 180deg));
  z-index: 3;
  border-radius: 1px;
}

.flight-gauge__value {
  display: block;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #e8edf4;
  line-height: 1.15;
  margin-top: 1px;
}

.flight-gauge__label {
  display: block;
  font-size: 0.52rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #8b95a5;
  margin-top: 1px;
}

.flight-gauge__hint {
  display: block;
  font-size: 0.48rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-top: 0;
}

.flight-gauge__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem;
  margin-top: 0.28rem;
}

.flight-gauge__btn {
  border: 1px solid rgba(71, 85, 105, 0.9);
  background: rgba(22, 26, 34, 0.92);
  color: #e2e8f0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.12rem 0;
  cursor: pointer;
}

.flight-gauge__btn:hover {
  background: #334155;
}

.flight-input-hidden {
  display: none;
}

@media (max-width: 980px) {
  .map-frame--flight-console .map-hud {
    bottom: 260px;
  }
}

@media (max-width: 620px) {
  .flight-gauges-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    gap: 0.75rem;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
  }

  .flight-gauges--dock {
    flex: 0 0 auto;
    max-width: min(300px, 92vw);
  }
}

.inline-label {
  font-weight: 600;
}

.timing-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem;
  background: var(--surface);
  border-radius: 10px;
  margin: 1rem 0;
}

.runner-preview {
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: #0f172a;
  border-radius: 8px;
  border: 1px dashed #475569;
  min-height: 2.5rem;
}

.runner-preview.not-found {
  color: var(--err);
  border-color: var(--err);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.flash-ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--ok);
  color: #bbf7d0;
}

.flash-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--err);
  color: #fecaca;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0;
}

.table th,
.table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid #334155;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.list {
  color: var(--muted);
}

.map-wrap {
  height: min(75vh, 640px);
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  margin: 1rem 0;
  border: 1px solid #334155;
}

.map-wrap .maplibregl-canvas,
.map-wrap .mapboxgl-canvas {
  outline: none;
}

/* Large on-map click controls (Mapbox) */
.mtr-easy-controls {
  background: rgba(15, 23, 42, 0.92);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
  border: 1px solid #475569;
  max-width: 11rem;
  pointer-events: auto;
}

.mtr-easy-controls .mtr-easy-row {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.mtr-easy-controls .mtr-easy-row:last-child {
  margin-bottom: 0;
}

.mtr-easy-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 0 10px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #334155;
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mtr-easy-btn:hover {
  background: #475569;
  color: #fff;
}

.mtr-easy-btn:active {
  transform: scale(0.96);
}

.mtr-easy-pan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 6px;
}

.mtr-easy-pan-mid {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.mtr-easy-pan .mtr-easy-btn {
  min-width: 52px;
  min-height: 44px;
  font-size: 1.1rem;
}

.map-popup {
  color: #0f172a;
  font-size: 0.9rem;
  line-height: 1.4;
}

kbd {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #334155;
  font-size: 0.85em;
}

/* —— Map dashboard (map.php) —— */
body.map-page {
  background: radial-gradient(ellipse 120% 80% at 50% -20%, #1e3a5f 0%, var(--bg) 45%);
}

.map-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  width: 100%;
}

.map-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.map-hero-title {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
  color: #f8fafc;
}

.map-hero-sub {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.map-nerd-note {
  margin: 0.42rem 0 0;
  font-size: 0.82rem;
  color: #94a3b8;
  letter-spacing: 0.02em;
}

.map-hero-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.map-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(34, 211, 238, 0.12);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.map-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 10px #f97316;
  animation: map-pulse 2s ease-in-out infinite;
}

@keyframes map-pulse {
  50% {
    opacity: 0.65;
  }
}

.map-hero-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.map-token-msg {
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
}

.map-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.85rem;
}

/* Public browser view: keep only the map itself, hide operator-heavy overlays. */
.map-page--public-view .map-controls-bar,
.map-page--public-view .map-badge-tl,
.map-page--public-view .map-hud,
.map-page--public-view .map-live-panel {
  display: none !important;
}

.map-page--public-view .map-main {
  padding-top: 0.65rem;
}

/* Public desktop: keep only simple drone bar (Play/Pause/Stop/Zoom). */
.map-page--public-view #flight_controls {
  display: flex !important;
}

.map-page--public-view #flight_controls .flight-gauges-row,
.map-page--public-view #flight_controls .flight-controls-help {
  display: none !important;
}

.map-control-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.map-control-field select {
  min-width: 11rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
}

.map-controls-bar-drone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.map-drone-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 0.25rem;
}

.map-frame {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.25),
    0 24px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: min(78vh, 720px);
  background: transparent;
}

.map-frame--flight-console {
  /* Only the #map layer draws terrain; frame itself stays clear */
  background: transparent;
}

/*
 * Fullscreen uses #map_frame as the Mapbox FullscreenControl container.
 * The frame becomes viewport-sized, but #map was capped at min(78vh, 720px),
 * so the extra area below stayed empty (black). In fullscreen, stretch #map
 * to fill the entire frame.
 */
.map-frame--flight-console:fullscreen,
.map-frame--flight-console:-webkit-full-screen,
.map-frame--flight-console:-moz-full-screen,
#map_frame:fullscreen,
#map_frame:-webkit-full-screen,
#map_frame.mtr-map-frame--fullscreen {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.map-frame--flight-console:fullscreen #map.map-wrap--dashboard,
.map-frame--flight-console:-webkit-full-screen #map.map-wrap--dashboard,
.map-frame--flight-console:-moz-full-screen #map.map-wrap--dashboard,
#map_frame:fullscreen #map.map-wrap--dashboard,
#map_frame:-webkit-full-screen #map.map-wrap--dashboard,
#map_frame.mtr-map-frame--fullscreen #map.map-wrap--dashboard {
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  max-height: none;
}

/* JS toggles this while fullscreen — fills viewport when :fullscreen pseudo fails */
#map_frame.mtr-map-frame--fullscreen {
  min-height: 100vh;
  min-height: 100dvh;
}

.map-wrap--dashboard {
  height: min(78vh, 720px);
  min-height: 480px;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
}

/* Mobile: overlays are clumsy and can block the map; prioritize clear map canvas. */
@media (max-width: 760px) {
  .map-controls-bar,
  .map-badge-tl,
  .map-hud,
  .map-page--public-view #flight_controls,
  #flight_controls {
    display: none !important;
  }
  .map-frame .mapboxgl-ctrl-top-right,
  .map-frame .mapboxgl-ctrl-top-left,
  .map-frame .mapboxgl-ctrl-bottom-left {
    display: none !important;
  }
  .map-main {
    padding: 0.55rem 0.6rem 1rem;
  }
  .map-frame {
    border-radius: 12px;
    min-height: 66vh;
  }
  .map-wrap--dashboard {
    min-height: 66vh;
  }
}

/* Mapbox root must fill #map — otherwise the empty area shows WebGL clear (black) */
.map-wrap--dashboard .mapboxgl-map,
.map-wrap--dashboard .mapboxgl-canvas-container {
  width: 100%;
  height: 100%;
}

.map-badge-tl {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  background: var(--map-hud);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #e2e8f0;
}

.map-badge-strong {
  color: #38bdf8;
  font-weight: 800;
}

.map-badge-sep {
  opacity: 0.5;
}

.map-badge-meta {
  width: 100%;
  font-size: 0.62rem;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

.map-hud {
  position: absolute;
  left: 14px;
  bottom: 52px;
  z-index: 2;
  pointer-events: none;
  min-width: 220px;
  max-width: 92%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--map-hud);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  color: #e2e8f0;
}

/* Avionics / glass-cockpit style telemetry (map page) */
.map-hud--avionic {
  padding: 0;
  border-radius: 10px;
  background:
    linear-gradient(165deg, rgba(8, 14, 12, 0.92) 0%, rgba(4, 8, 10, 0.94) 100%);
  border: 1px solid rgba(0, 200, 140, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(0, 255, 180, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(0, 180, 120, 0.06);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  overflow: hidden;
}

.map-hud-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.3rem;
  background: linear-gradient(90deg, rgba(0, 60, 45, 0.35) 0%, rgba(0, 30, 24, 0.2) 100%);
  border-bottom: 1px solid rgba(0, 200, 140, 0.15);
}

.map-hud-header__tag {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: rgba(0, 220, 150, 0.85);
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(0, 200, 140, 0.35);
  border-radius: 3px;
  background: rgba(0, 40, 30, 0.4);
}

.map-hud-header__title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  color: rgba(180, 230, 210, 0.75);
}

.map-hud--avionic .map-hud-coords {
  padding: 0.55rem 0.85rem 0.45rem;
  margin-bottom: 0;
  font-size: 0.72rem;
  color: rgba(120, 200, 170, 0.75);
  border-bottom: 1px solid rgba(0, 200, 140, 0.1);
}

.map-hud--avionic .map-hud-grid {
  padding: 0.55rem 0.75rem 0.7rem;
  gap: 0.45rem 0.65rem;
}

.map-hud--avionic .map-hud-cell {
  padding: 0.35rem 0.45rem;
  border-radius: 4px;
  background: rgba(0, 25, 20, 0.35);
  border: 1px solid rgba(0, 200, 140, 0.12);
  box-shadow: inset 0 1px 0 rgba(0, 255, 200, 0.04);
}

.map-hud--avionic .map-hud-cell--wide {
  background: rgba(0, 30, 24, 0.4);
}

.map-hud-coords {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 0.65rem;
  line-height: 1.35;
}

.map-hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
}

.map-hud-cell--wide {
  grid-column: 1 / -1;
}

.map-hud-k {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #64748b;
  margin-bottom: 0.15rem;
}

.map-hud--avionic .map-hud-k {
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  color: rgba(0, 200, 150, 0.55);
  margin-bottom: 0.2rem;
}

.map-hud-v {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.95rem;
}

.map-hud--avionic .map-hud-v {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", monospace;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  color: rgba(200, 255, 230, 0.92);
  text-shadow: 0 0 12px rgba(0, 255, 180, 0.12);
}

.map-live-panel {
  position: absolute;
  right: 14px;
  bottom: 56px;
  z-index: 2;
  min-width: 190px;
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(7, 15, 18, 0.92) 0%, rgba(8, 8, 16, 0.94) 100%);
  border: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  color: #e2e8f0;
  pointer-events: none;
}

.map-live-panel__title {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(125, 222, 255, 0.9);
  margin-bottom: 0.38rem;
}

.map-live-panel__row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.76rem;
  line-height: 1.35;
  padding: 0.14rem 0;
}

.map-live-panel__k {
  color: rgba(170, 190, 210, 0.85);
  letter-spacing: 0.03em;
}

.map-live-panel__v {
  color: #c8f4ff;
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

/* Mapbox controls: glass stack on the right */
.map-frame .mapboxgl-ctrl-top-right {
  top: 14px;
  right: 14px;
}

.map-frame .mapboxgl-ctrl-group:not(.mtr-easy-controls) {
  background: rgba(8, 12, 22, 0.85) !important;
  backdrop-filter: blur(10px);
  border-radius: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.map-frame .mapboxgl-ctrl-group:not(.mtr-easy-controls) button {
  filter: brightness(1.1);
}

.map-frame .mapboxgl-ctrl-bottom-left {
  left: 14px;
  bottom: 14px;
}

.map-frame .mapboxgl-ctrl-scale {
  background: rgba(8, 12, 22, 0.75) !important;
  backdrop-filter: blur(8px);
  border-radius: 6px !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #cbd5e1 !important;
  font-size: 0.7rem !important;
}

.mtr-easy-controls {
  background: rgba(8, 12, 22, 0.92) !important;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45) !important;
}

/* ——— Timing: simple bib + modal ——— */
.timing-hint kbd {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #1e293b;
  border: 1px solid #475569;
  font-size: 0.9em;
}

.timing-race-clock {
  margin: 0.9rem 0 1.2rem;
  padding: 0.85rem 1rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: linear-gradient(180deg, rgba(20, 5, 7, 0.98), rgba(10, 2, 3, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 24px rgba(0, 0, 0, 0.35);
  max-width: 42rem;
}

.timing-race-clock__race {
  font-size: 0.88rem;
  color: #fca5a5;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.timing-race-clock__elapsed {
  margin-top: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(1.9rem, 5.3vw, 3.1rem);
  line-height: 1.05;
  color: #ef4444;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 0 16px rgba(239, 68, 68, 0.35), 0 0 3px rgba(255, 255, 255, 0.08);
}

.timing-race-clock__start {
  margin-top: 0.35rem;
  color: #cbd5e1;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.race-clock-display-page {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 22%, #29090d 0%, #0b0203 58%, #060102 100%);
  color: #f8fafc;
  overflow: hidden;
}

.race-clock-display {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0.6rem;
  box-sizing: border-box;
  text-align: center;
}

.race-clock-display__top {
  position: fixed;
  top: 0.4rem;
  right: 0.4rem;
  display: flex;
  gap: 0.4rem;
  opacity: 0.65;
}

.race-clock-display__back,
.race-clock-display__fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.62);
  color: #e2e8f0;
  padding: 0.3rem 0.55rem;
  font-size: 0.68rem;
  text-decoration: none;
  cursor: pointer;
}

.race-clock-display__race {
  font-size: clamp(1.5rem, 4vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fca5a5;
  margin-bottom: 0.2rem;
  line-height: 1.05;
  white-space: nowrap;
  max-width: 98vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.race-clock-display__elapsed {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 900;
  line-height: 0.96;
  color: #ef4444;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.32), 0 0 4px rgba(255, 255, 255, 0.14);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  width: 100%;
  text-align: center;
  align-self: center;
}

.race-clock-display__elapsed-hm {
  font-family: 'DS-Digital', 'DSEG7 Classic', 'Digital-7', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(16rem, 60vw, 46rem);
  letter-spacing: 0.004em;
  display: inline-block;
  transform: none;
  transform-origin: center;
  font-weight: 700;
}

.race-clock-display__elapsed-sec {
  font-size: clamp(1.9rem, 6.6vw, 5.6rem);
  letter-spacing: 0;
  opacity: 0.95;
  margin-bottom: 0.12em;
}

.race-clock-display__start {
  margin-top: 0.3rem;
  font-size: clamp(0.95rem, 2.2vw, 1.8rem);
  color: #cbd5e1;
  letter-spacing: 0.04em;
}

.race-clock-display__hint {
  margin-top: 0.2rem;
  font-size: clamp(0.62rem, 1.3vw, 0.92rem);
  color: #94a3b8;
  letter-spacing: 0.03em;
  opacity: 0.72;
}

.race-clock-switcher {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem 0.55rem;
  margin-top: 1.25rem;
  padding: 0 0.5rem 1rem;
  max-width: min(100%, 42rem);
}

.race-clock-switcher__link {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.55);
  color: #cbd5e1;
  font-size: clamp(0.72rem, 2vw, 0.88rem);
  font-weight: 600;
  text-decoration: none;
}

.race-clock-switcher__link:hover {
  border-color: rgba(252, 165, 165, 0.45);
  color: #f8fafc;
}

.race-clock-switcher__link.is-active {
  border-color: rgba(252, 165, 165, 0.65);
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
}

.nav-race-clocks {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  max-width: 100%;
}

.nav-race-clocks__pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  text-decoration: none;
  white-space: nowrap;
}

.nav-race-clocks__pill:hover {
  border-color: var(--accent);
  color: #fff;
}

body.race-clock-hub-page .race-clock-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  max-width: 720px;
  margin: 1.5rem 0 2rem;
}

body.race-clock-hub-page .race-clock-hub-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 5.5rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid #334155;
  background: var(--surface);
  color: var(--accent);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  text-align: center;
  transition:
    border-color 0.15s,
    transform 0.12s;
}

body.race-clock-hub-page .race-clock-hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  color: #fde68a;
}

.timing-bar--simple {
  align-items: stretch;
  max-width: 42rem;
}

.timing-field-bib input {
  font-size: 1.35rem;
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  min-height: 2.75rem;
}

.timing-btn-continue {
  min-height: 2.85rem;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  touch-action: manipulation;
}

.timing-recent-heading {
  margin-top: 2rem;
  font-size: 1.1rem;
}

.timing-dialog {
  max-width: 92vw;
  width: min(22rem, 100%);
  padding: 0;
  border: none;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
}

.timing-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.timing-dialog-inner {
  padding: 1.35rem 1.25rem 1.25rem;
}

.timing-dialog-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.timing-dialog-name {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
}

.timing-dialog-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.timing-dialog-time-row {
  margin: 0 0 1rem;
}

.timing-dialog-stub-wrap {
  margin: 0 0 1rem;
}

.timing-dialog-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font-size: 1rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
}

.timing-dialog-datetime {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
}

.timing-dialog-datetime:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.timing-dialog-hint {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.timing-dialog-error {
  margin: 0 0 1rem;
  color: var(--err);
  font-size: 0.95rem;
}

.timing-dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.timing-btn-checkin {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: #15803d;
  color: #ecfdf5;
  cursor: pointer;
  touch-action: manipulation;
}

.timing-btn-checkin:hover:not(:disabled) {
  filter: brightness(1.06);
}

.timing-btn-checkin:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.timing-btn-cancel {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  border-radius: 10px;
  border: 1px solid #475569;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}

.timing-btn-cancel:hover {
  background: #1e293b;
  color: var(--text);
}

@media (min-width: 480px) {
  .timing-dialog-actions {
    flex-direction: row-reverse;
  }
  .timing-btn-checkin,
  .timing-btn-cancel {
    width: auto;
    flex: 1;
  }
}

/* CP log — live feed: newest largest for wall / distance viewing */
.cp-feed-panel {
  margin: 1.75rem 0 2rem;
  padding: 1.35rem 1.35rem 1.5rem;
  background: linear-gradient(165deg, rgba(20, 27, 45, 0.98) 0%, rgba(15, 23, 42, 0.88) 55%, rgba(15, 23, 42, 0.75) 100%);
  border-radius: 14px;
  border: 1px solid #334155;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.cp-feed-heading {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.cp-feed-sub {
  margin: 0 0 1.1rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 40rem;
}

.cp-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: min(70vh, 52rem);
  overflow-y: auto;
  padding-right: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.cp-feed-empty {
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 1rem;
}

.cp-feed-item {
  --feed-index: 0;
  margin: 0;
  padding: 0.55em 0 0.65em;
  border-bottom: 1px solid rgba(51, 65, 85, 0.55);
  font-size: max(0.72rem, calc(2.35rem - var(--feed-index) * 0.072rem));
  line-height: 1.28;
  opacity: max(0.62, calc(1 - var(--feed-index) * 0.009));
  font-variant-numeric: tabular-nums;
}

.cp-feed-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.cp-feed-time {
  font-weight: 800;
  color: #fde68a;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.cp-feed-main {
  font-weight: 600;
  margin-top: 0.2em;
  color: var(--text);
}

.cp-feed-bib {
  color: var(--link);
  font-weight: 700;
}

.cp-feed-cp {
  color: #cbd5e1;
}

.cp-feed-note {
  margin-top: 0.25em;
  font-size: 0.82em;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}

@media (min-width: 900px) {
  .cp-feed-item {
    font-size: max(0.75rem, calc(2.55rem - var(--feed-index) * 0.078rem));
  }
}

/* Public CP updates page (updates.php) */
.public-updates-lead {
  max-width: 40rem;
}

.public-updates-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 1.5rem;
  margin: 1.25rem 0 1rem;
}

.public-updates-filter select {
  margin-left: 0.35rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
}

.public-updates-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.public-updates-feed {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 42rem;
}

.public-updates-empty {
  color: var(--muted);
  padding: 1rem 0;
}

.public-update-card {
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid #334155;
  border-radius: 12px;
}

.public-update-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.public-update-badge {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.public-update-badge--quiet {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.public-update-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.public-update-runner {
  font-size: 0.95rem;
  margin-top: 0.25rem;
  color: #cbd5e1;
}

.public-update-note {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  line-height: 1.45;
  white-space: pre-wrap;
}

.public-update-photo {
  margin-top: 0.85rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #334155;
}

.public-update-photo img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

.cp-existing-record-hint {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #b91c1c;
  font-weight: 600;
}

.cp-log-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.btn-certificate {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 7px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
}

.btn-certificate:hover {
  background: #1e293b;
  color: #fff;
  text-decoration: none;
}

.certificate-toolbar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
  align-items: center;
  margin: 0.8rem 0 1rem;
}

.certificate-calib-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.9rem;
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #475569;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
}

.certificate-calib-toolbar select {
  margin-left: 0.35rem;
  padding: 0.25rem 0.4rem;
}

.certificate-canvas-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  padding: 0.8rem;
}

.certificate-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 595 / 842;
  margin: 0 auto;
}

.certificate-pdf {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.certificate-calib-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.certificate-text-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* On screen the merged PDF already includes text; hide HTML overlay unless ?debug=1 (calibration). */
@media screen {
  body.certificate-print-page .certificate-text-layer {
    display: none !important;
  }
  body.certificate-print-page.certificate-print-debug .certificate-text-layer {
    display: block !important;
  }
}

.certificate-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(245, 158, 11, 0.92);
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.18rem 0.3rem;
  border-radius: 6px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.certificate-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 2px;
  height: 10px;
  transform: translateX(-50%);
  background: rgba(245, 158, 11, 0.95);
}

.cert-field {
  position: absolute;
  transform: translate(-50%, -100%);
  transform-origin: center bottom;
  white-space: pre;
  line-height: 1;
  color: #111827;
  font-family: "Times New Roman", Georgia, serif;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.35);
}

.certificate-stage,
.certificate-pdf,
.certificate-text-layer,
.certificate-calib-layer {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

@media print {
  .topbar,
  .footer,
  .hint,
  .certificate-toolbar,
  .certificate-calib-toolbar,
  #cert_status {
    display: none !important;
  }
  body.certificate-print-page h1,
  body.certificate-print-page > .hint,
  body.certificate-print-page .flash {
    display: none !important;
  }
  .container {
    max-width: none;
    padding: 0;
    margin: 0;
  }
  .certificate-canvas-wrap {
    border: 0;
    padding: 0;
    background: #fff;
  }
  .certificate-stage {
    width: 100%;
    max-width: none;
    box-shadow: none;
  }
  /* Text-only print: hide embedded PDF (template background), keep HTML field overlay. */
  body.certificate-print-page .certificate-pdf {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    border: 0 !important;
  }
  body.certificate-print-page .certificate-text-layer {
    display: block !important;
  }
  body.certificate-print-page .certificate-calib-layer {
    display: none !important;
  }
  body.certificate-print-page .cert-field {
    color: #000 !important;
    text-shadow: none !important;
  }
  .certificate-pdf,
  .certificate-text-layer,
  .certificate-calib-layer {
    box-shadow: none;
  }
}

/* Final mobile override: force-hide bulky map overlays on phones/tablets. */
@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  body.map-page .map-controls-bar,
  body.map-page .map-badge-tl,
  body.map-page .map-hud,
  body.map-page .map-live-panel,
  body.map-page .map-frame .mapboxgl-ctrl-top-left,
  body.map-page .map-frame .mapboxgl-ctrl-bottom-left {
    display: none !important;
  }

  /* Keep only simple drone controls (Play/Pause/Stop/Zoom) on mobile. */
  body.map-page #flight_controls {
    display: flex !important;
  }

  body.map-page #flight_controls .flight-gauges-row,
  body.map-page #flight_controls .flight-controls-help {
    display: none !important;
  }

  body.map-page #flight_controls .flight-controls__bar {
    width: min(96vw, 720px) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Keep current-location button (top-right controls) visible on mobile. */
  body.map-page .map-frame .mapboxgl-ctrl-top-right {
    display: block !important;
  }

  body.map-page .map-main {
    padding: 0.45rem 0.45rem 0.9rem !important;
  }

  body.map-page .map-frame {
    min-height: 70vh !important;
    border-radius: 10px !important;
  }

  body.map-page .map-wrap--dashboard {
    min-height: 70vh !important;
  }
}
