/* ============================================================
   Lifeguard Rotation — styles
   ------------------------------------------------------------
   Design language: "pool deck" — deep ocean hero, foam-white
   cards, lifeguard-red accents, aqua highlights. Mobile-first,
   glanceable from across a deck, light + dark themes.
   ============================================================ */
:root {
  /* brand */
  --red: #e63946;          /* lifeguard red — primary actions, danger */
  --aqua: #2dd4bf;         /* highlight — "you", focus moments */
  --sky: #38bdf8;

  /* station states — each hue means exactly one thing */
  --green: #22c55e;        /* open */
  --yellow: #facc15;       /* opening */
  --orange: #f97316;       /* closing */
  --slate: #90a4b3;        /* closed / inactive */

  /* surfaces */
  --bg: #e9f1f5;
  --card: #ffffff;
  --card-2: #f0f6f9;       /* inset surfaces on cards */
  --text: #0e2836;
  --muted: #5f7a8a;
  --line: #dde8ee;

  /* hero ocean */
  --ocean-1: #062c42;
  --ocean-2: #0a4a68;
  --ocean-3: #0c7a96;

  --shadow: 0 8px 28px rgba(8, 44, 66, 0.09);
  --radius: 20px;
  --font-display: "Outfit", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071219;
    --card: #0d1f2b;
    --card-2: #122938;
    --text: #e8f2f7;
    --muted: #8aa4b4;
    --line: #1c3140;
    --ocean-1: #041d2c;
    --ocean-2: #073850;
    --ocean-3: #095e75;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-image:
    radial-gradient(720px 360px at 88% 220px, rgba(56, 189, 248, 0.10), transparent 65%),
    radial-gradient(560px 320px at -60px 55%, rgba(45, 212, 191, 0.08), transparent 65%);
  background-repeat: no-repeat;
}

:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 6px; }

/* ---------- Banner (demo / error) ---------- */
.banner {
  background: #fff3cd;
  color: #6b5300;
  padding: 9px 16px;
  font-size: 0.82rem;
  text-align: center;
  border-bottom: 1px solid #f0e0a0;
}
.banner code { background: rgba(0, 0, 0, 0.08); padding: 1px 5px; border-radius: 4px; }
@media (prefers-color-scheme: dark) {
  .banner { background: #33290e; color: #ffd35e; border-bottom-color: #4d3f13; }
  .banner code { background: rgba(255, 255, 255, 0.12); }
}
/* Loud variant for a localhost session that has reached the LIVE database. */
.banner.danger { background: #fde2e1; color: #7a1a12; border-bottom-color: #f6bcb7; }
@media (prefers-color-scheme: dark) {
  .banner.danger { background: #3a1310; color: #ffb4ab; border-bottom-color: #5a1c17; }
}

/* ---------- Environment badge ----------
   Fixed corner chip naming the database this session is hitting. Bottom-LEFT so
   it never overlaps the manager map controls (bottom-right of the map). Purely
   informational — pointer-events:none so it can't intercept a tap. */
.env-badge {
  position: fixed;
  left: calc(10px + env(safe-area-inset-left));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--slate);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  user-select: none;
}
.env-badge strong { font-weight: 800; }
.env-badge .env-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
.env-badge .env-ref {
  font-weight: 600;
  opacity: 0.85;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.env-badge.env-demo { background: var(--slate); }
.env-badge.env-staging { background: #0ea5e9; }        /* teal — a safe copy */
.env-badge.env-live { background: var(--red); }         /* red = you're on the real DB */
.env-badge.env-live .env-dot { animation: markerPulse 1.4s ease-in-out infinite; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ocean-1);
  color: #fff;
}
.app-header.open { box-shadow: 0 14px 34px rgba(4, 18, 28, 0.35); }
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: 0 0 auto; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35)); }
.app-header h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact countdown chip — the tap target that drops the full hero down. */
.header-timer {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.header-timer:hover { background: rgba(255, 255, 255, 0.2); }
.header-timer.ending { color: #ffd7d7; border-color: rgba(255, 157, 157, 0.6); animation: pulse 1s ease-in-out infinite; }
.header-timer .chev { flex: 0 0 auto; opacity: 0.8; transition: transform 0.3s ease; }
.app-header.open .header-timer .chev { transform: rotate(180deg); }

/* The hero is a normal-flow sibling right after the sticky header (not nested
   inside it), so it scrolls away with the page; collapsed it has no height,
   tapped it falls open to full height. max-height is just past the tallest
   hero so the ease lands close to the real edge. #appHeader has z-index: 20
   and .hero-drop is unpositioned, so the sticky bar always paints above it
   as the hero scrolls underneath — no extra z-index needed here. */
.hero-drop { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
.hero-drop.open { max-height: 520px; }

/* ---------- Hero (countdown) ---------- */
.hero {
  background:
    radial-gradient(560px 300px at 18% -40px, rgba(94, 234, 212, 0.16), transparent 60%),
    radial-gradient(640px 340px at 92% 30%, rgba(56, 189, 248, 0.18), transparent 60%),
    linear-gradient(168deg, var(--ocean-1) 0%, var(--ocean-2) 52%, var(--ocean-3) 120%);
  color: #fff;
}
.hero-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 16px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.hero-wave { display: block; width: 100%; height: 46px; margin-top: -6px; }
.hero-wave path { fill: var(--bg); }

.clock-chip {
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 15px;
}

.ring-wrap { position: relative; width: min(62vw, 258px); aspect-ratio: 1; margin: 4px 0 0; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring-track { stroke: rgba(255, 255, 255, 0.13); }
.ring-fg {
  stroke: url(#ringGrad);
  stroke-dasharray: 552.92;
  transition: stroke 0.4s ease;
  filter: drop-shadow(0 0 6px rgba(94, 234, 212, 0.35));
}
.ring-wrap.ending .ring-fg { stroke: #ff9d9d; filter: drop-shadow(0 0 8px rgba(255, 120, 120, 0.5)); }

.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}
.timer-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
}
.timer {
  font-size: clamp(2.9rem, 14vw, 3.7rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
}
.timer.ending { color: #ffd7d7; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.boundary-at {
  font-size: 0.86rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.hchip {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 13px;
  white-space: nowrap;
}
.hchip b { font-weight: 800; }
.hchip.warn { background: rgba(240, 165, 62, 0.22); border-color: rgba(240, 165, 62, 0.55); color: #ffe1b3; }

.you-chip {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  color: #0e2836;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(45, 212, 191, 0.65);
}
.you-chip b { font-weight: 800; }
.you-arrow { color: #0c7a96; font-weight: 800; }
.you-x { color: #90a4b3; font-size: 0.8rem; margin-left: 2px; }

/* ---------- Layout ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px;
  padding-bottom: calc(36px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 14px;
}
.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.count-badge {
  min-width: 28px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

/* ---------- Rotation board ---------- */
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board-cols,
.brow {
  display: grid;
  grid-template-columns: 1fr 22px 1fr;
  align-items: center;
  gap: 8px;
}
.board-cols {
  padding: 0 14px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.brow {
  padding: 10px 14px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
/* A cell = the station line (dot · name · tag) stacked over the guard name. */
.brow-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brow-at { display: flex; align-items: center; gap: 7px; min-width: 0; }
.brow-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brow-dash { color: var(--slate); font-size: 0.82rem; font-weight: 700; }
.brow-arrow { color: var(--slate); text-align: center; font-weight: 700; }
.row-tag {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  padding: 2px 7px;
  flex: 0 0 auto;
}
/* Tints carry their own text colours: yellow/orange are too light to read as
   text on a light card, so the label darkens instead of matching the dot. */
.row-tag.opening { background: rgba(250, 204, 21, 0.22); color: #854d0e; }
.row-tag.closing { background: rgba(249, 115, 22, 0.16); color: #9a3412; }
.row-tag.off { background: rgba(148, 163, 184, 0.18); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .row-tag.opening { color: #fde047; }
  .row-tag.closing { color: #fdba74; }
}

/* Guard name = tappable "follow" target */
.gname {
  font: inherit;
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 3px 8px;
  margin-left: -8px;
  cursor: pointer;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.brow-to .gname { font-weight: 600; color: var(--muted); }
.gname:hover { background: rgba(45, 212, 191, 0.12); }
.gname.me, .brow-to .gname.me {
  background: rgba(45, 212, 191, 0.16);
  box-shadow: inset 0 0 0 1.5px var(--aqua);
  color: var(--text);
}
.gname.empty {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--slate);
  cursor: default;
  padding-left: 0;
  margin-left: 0;
}
.board-empty { list-style: none; color: var(--muted); font-size: 0.95rem; padding: 4px 2px; }
.board-hint { margin: 12px 2px 0; font-size: 0.8rem; color: var(--muted); }

/* "On break" shares the board's card — a rule separates the deck from the float. */
.break-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.break-head { margin-bottom: 12px; }
.break-title { font-size: 0.95rem; }

/* ---------- Float chips ---------- */
.float-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.chip:hover { background: rgba(45, 212, 191, 0.12); }
.chip.me { background: rgba(45, 212, 191, 0.16); box-shadow: inset 0 0 0 1.5px var(--aqua); }
/* "up next" = this guard is about to be on deck — same signal as "opening". */
.chip-badge {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(250, 204, 21, 0.22);
  color: #854d0e;
  border-radius: 999px;
  padding: 2px 8px;
}
@media (prefers-color-scheme: dark) { .chip-badge { color: #fde047; } }

/* Manager-only chip that opens the guard picker — dashed so it reads as an
   action, not as a guard standing on break. */
.chip.add { background: transparent; border: 1px dashed var(--slate); color: var(--muted); }
.chip.add:hover { background: rgba(45, 212, 191, 0.1); border-color: var(--aqua); color: var(--text); }

/* ---------- Pool map ---------- */
.map-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}
.map-legend li { display: flex; align-items: center; gap: 5px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-dot.open { background: var(--green); }
.lg-dot.closed { background: var(--slate); }
.lg-dot.opening { background: var(--yellow); }
.lg-dot.closing { background: var(--orange); }

.pool-map {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-2);
  border: 1px solid var(--line);
  min-height: 180px;
  line-height: 0;
  user-select: none;
  -webkit-user-select: none;
}
.pool-img { display: block; width: 100%; height: auto; }

.markers { position: absolute; inset: 0; line-height: normal; }

/* Manager-only apply/undo pills, floating inside the image's bottom-right
   corner. `.pool-map` resets line-height to 0 for the image, so restore it
   here. z-index clears the marker stack (highest is 6, on hover/focus).
   The button overrides are scoped by the `#mapControls` id (rather than a
   plain class) so they reliably beat `.btn` / `.btn.primary` regardless of
   where those rules land in the cascade below. */
.map-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  line-height: normal;
  display: flex;
  align-items: center;
  gap: 8px;
}
#mapControls .btn {
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.84rem;
  box-shadow: 0 3px 14px rgba(8, 44, 66, 0.3);
}
#mapControls .btn.is-busy { cursor: wait; }

/* Marker is a zero-size anchor at its x/y point: the dot is centred on the
   point, the card hangs just below. Near an edge the card shifts inward so it
   never spills outside the image. */
.marker {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: center;
  cursor: default;
  z-index: 1;
}
.marker.interactive { cursor: pointer; }
.marker.interactive:focus-visible { outline: none; }
.marker.interactive:focus-visible .marker-card { outline: 2px solid #fff; outline-offset: 2px; }
.marker.interactive:active .marker-dot { transform: translate(-50%, -50%) scale(0.85); }

.marker-dot {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}

.marker-card {
  position: absolute;
  left: 0;
  top: 11px;
  transform: translate(-50%, 0);
  width: max-content;
  min-width: 62px;
  max-width: 124px;
  padding: 4px 9px 5px;
  border-radius: 10px;
  background: rgba(5, 20, 30, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1px;
  backdrop-filter: blur(5px);
}
.marker.edge-left .marker-card { transform: translate(-12%, 0); }
.marker.edge-right .marker-card { transform: translate(-88%, 0); }
/* Lower markers: hang the card above the dot so it never clips the bottom. */
.marker.above .marker-card { top: auto; bottom: 11px; }

/* Layer so open + about-to-change + focused markers sit above their neighbours. */
.marker.closed { z-index: 1; }
.marker.open { z-index: 2; }
.marker.opening, .marker.closing { z-index: 3; }
.marker.mine { z-index: 4; }
.marker.interactive:hover, .marker.interactive:focus-within { z-index: 6; }

.marker-name {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.8;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
/* The name lives in its own box so a long station name wraps onto extra lines
   (growing the card downward) instead of being cropped mid-word or ellipsized
   by the flex row it shares with the badge. align-items: flex-start above
   keeps the badge pinned to the name's first line when it wraps. */
.marker-label { min-width: 0; white-space: normal; overflow-wrap: break-word; }
.marker-cur { font-size: 0.9rem; font-weight: 700; line-height: 1.15; }
.marker-next { font-size: 0.66rem; opacity: 0.75; line-height: 1.1; font-weight: 600; }

.marker-badge {
  font-size: 0.52rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

/* Marker states */
.marker.closed .marker-dot { background: var(--slate); }
.marker.closed .marker-card { opacity: 0.72; }
/* On the pool map, opening reads green (going on duty) and closing reads red
   (coming off). The pulse + badge still set an opening marker apart from an
   already-open one; the board dots/tags keep the yellow/orange scale. */
.marker.opening .marker-dot { background: var(--green); animation: markerPulse 1.4s ease-in-out infinite; }
.marker.opening .marker-badge { background: var(--green); color: #052e16; }
.marker.closing .marker-dot { background: var(--red); animation: markerPulse 1.4s ease-in-out infinite; }
.marker.closing .marker-badge { background: var(--red); color: #fff; }
@keyframes markerPulse { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.15), 0 1px 4px rgba(0, 0, 0, 0.5); } }

/* Followed guard: glow the marker they're at / headed to */
.marker.mine .marker-card {
  border-color: var(--aqua);
  box-shadow: 0 0 0 1.5px var(--aqua), 0 0 14px rgba(45, 212, 191, 0.55), 0 3px 10px rgba(0, 0, 0, 0.4);
}

.map-hint {
  margin: 12px 0 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ocean-3);
}
@media (prefers-color-scheme: dark) { .map-hint { color: var(--sky); } }

/* Phones: run the map full-bleed (the photo spans the whole viewport) and
   shrink marker cards so 8 stations stay legible on a narrow screen. The two
   negative margins cancel the .container and .map-card side padding in turn. */
@media (max-width: 520px) {
  .map-card {
    padding: 12px;
    margin-inline: -16px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .pool-map {
    width: auto;
    margin-inline: -12px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .marker-dot { width: 13px; height: 13px; }
  .marker-card {
    min-width: 0;
    max-width: 106px;
    padding: 2px 6px 3px;
    border-radius: 8px;
    gap: 0;
  }
  .marker-name { font-size: 0.5rem; }
  .marker-cur { font-size: 0.72rem; }
  .marker-next { display: none; } /* full now→next lives in the board below */
  .marker-badge { font-size: 0.46rem; padding: 0 3px; }
  .map-controls { right: 8px; bottom: 8px; gap: 6px; }
  #mapControls .btn { padding: 7px 12px; font-size: 0.76rem; }
}

/* Phones: tighten the two cells; the station line already stacks above the name.
   Also grow the buttons workers actually tap — a wet thumb on a deck wants a
   ~44px target, and on desktop these ran ~25-36px (fine for a mouse, small for
   touch). Scoped to the phone media query so the mouse layout is untouched. */
@media (max-width: 560px) {
  .board-cols { display: none; }
  .brow { grid-template-columns: 1fr 18px 1fr; gap: 6px; padding: 10px 12px; }
  .brow-at { gap: 5px; }
  .brow-name { font-size: 0.72rem; letter-spacing: 0.02em; }
  /* The follow target is the most-tapped control; fatten it vertically so it
     fills the cell (~25px -> ~44px) instead of hugging the text. */
  .brow-cell .gname { font-size: 0.98rem; padding-top: 11px; padding-bottom: 11px; }
  .row-tag { font-size: 0.54rem; padding: 2px 5px; }

  /* Break / add-guard chips: ~35px -> ~44px. */
  .float-list .chip { padding: 11px 16px; }
  /* Footer manager toggle: ~36px -> ~42px. Selectors below carry an extra class
     so they win over the base rules, which are declared later in this file. */
  .app-footer .footer-btn { padding: 11px 20px; }
  /* Guard picker (manager, on a phone): give the row toggle and the reorder /
     delete controls room so ✕ isn't a tiny target crammed against the arrows. */
  .gp-list .gp-name { padding: 10px 6px; }
  .gp-list .gp-actions .btn { padding: 9px 11px; }
}

/* ---------- Station dots (board rows) ---------- */
.st-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.st-dot.open { background: var(--green); }
.st-dot.closed { background: var(--slate); }
.st-dot.opening { background: var(--yellow); }
.st-dot.closing { background: var(--orange); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(0.97); }
.btn.primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 3px 12px rgba(230, 57, 70, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); border-color: transparent; background: transparent; padding: 6px 10px; }
.roster-actions .btn { padding: 6px 10px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; }
.btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Footer (manager lock) ---------- */
.app-footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px calc(30px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}
.footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9rem;
  color: var(--muted);
  background: var(--card);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(4, 18, 28, 0.6);
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.modal h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.2rem; }
.modal-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
/* The PIN field — wide-tracked digits. Scoped by type so the guard picker's
   search box below keeps normal typography. */
.modal input[type="password"] {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.35em;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--text);
}
.pw-error { color: var(--red); font-size: 0.85rem; font-weight: 600; min-height: 1.1em; margin: 8px 0 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.modal-actions .ghost { background: var(--card-2); color: var(--text); border-color: var(--line); }

/* ---------- Guard picker (manager roster) ---------- */
.modal.picker { max-width: 400px; }
.search-input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-2);
  color: var(--text);
}
.search-input::placeholder { color: var(--muted); }

.gp-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(44vh, 300px);
  overflow-y: auto;
}
.gp-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 6px 4px 4px;
}
.gp-row.on { border-color: rgba(34, 197, 94, 0.45); }
.gp-name {
  font: inherit;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 6px;
  background: none;
  border: 0;
  border-radius: 9px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.gp-name:hover { background: rgba(45, 212, 191, 0.12); }
.gp-check {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid var(--slate);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.gp-row.on .gp-check { background: var(--green); border-color: var(--green); }
.gp-row.on .gp-check::after { content: "✓"; color: #fff; font-size: 0.68rem; font-weight: 800; line-height: 1; }
.gp-text { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-state {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #15803d;
  background: rgba(34, 197, 94, 0.16);
  border-radius: 999px;
  padding: 2px 8px;
}
@media (prefers-color-scheme: dark) { .gp-state { color: #86efac; } }
.gp-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.gp-actions .btn { padding: 6px 9px; font-size: 0.78rem; background: var(--card); border-radius: 9px; }
.gp-actions .btn.danger { background: transparent; border-color: transparent; }
.gp-empty { list-style: none; color: var(--muted); font-size: 0.88rem; line-height: 1.45; padding: 10px 4px; }
.gp-hint { margin: 10px 2px 0; min-height: 1.1em; font-size: 0.82rem; font-weight: 600; color: var(--muted); }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .timer.ending, .marker.opening .marker-dot, .marker.closing .marker-dot { animation: none; }
  .ring-fg { transition: none; }
  * { transition-duration: 0.01ms !important; }
}

[hidden] { display: none !important; }
