/* ============================================================
   Lifeguard Rotation — styles
   ============================================================ */
:root {
  --red: #e63946;
  --navy: #1d3557;
  --blue: #457b9d;
  --sky: #a8dadc;
  --bg: #eef2f6;
  --card: #ffffff;
  --text: #1d2b3a;
  --muted: #7c8a9a;
  --line: #e3e9ef;
  --ok: #2a9d8f;
  --shadow: 0 6px 20px rgba(29, 53, 87, 0.08);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --card: #17222e;
    --text: #eaf1f7;
    --muted: #8fa1b3;
    --line: #24313f;
    --sky: #2a4a58;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Banner ---------- */
.banner {
  background: #fff3cd;
  color: #6b5300;
  padding: 10px 16px;
  font-size: 0.85rem;
  text-align: center;
  border-bottom: 1px solid #f0e0a0;
}
.banner code { background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 4px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 1.6rem; }
.app-header h1 { font-size: 1.15rem; margin: 0; font-weight: 700; letter-spacing: 0.2px; }

/* ---------- Layout ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-title {
  margin: 0 0 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- Timer ---------- */
.timer-card {
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.clock {
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  opacity: 0.9;
  margin-bottom: 10px;
}
.timer-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  opacity: 0.85;
}
.timer {
  font-size: clamp(3.6rem, 18vw, 6rem);
  font-weight: 800;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.timer.ending { color: #ffd7d7; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.rotation-meta { font-size: 0.9rem; opacity: 0.9; }

/* ---------- Position lists ---------- */
.pos-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pos {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.pos-num {
  flex: 0 0 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.95rem;
}
.pos-list.next .pos-num { background: var(--blue); }
.pos-name { font-size: 1.12rem; font-weight: 600; }
.pos-name.muted, .muted { color: var(--muted); }
.pos-empty { opacity: 0.65; }

/* ---------- Float chips ---------- */
.float-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--sky);
  color: var(--navy);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
}
@media (prefers-color-scheme: dark) { .chip { color: var(--text); } }

/* ---------- Map placeholder ---------- */
.map-placeholder {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- Manager panel ---------- */
.manager-panel { border: 2px solid var(--blue); }
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.control-label { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper-value { min-width: 28px; text-align: center; font-size: 1.3rem; font-weight: 800; }

.sub-title { margin: 18px 0 10px; font-size: 0.95rem; }

.roster { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--line);
}
.roster-name { flex: 1; font-weight: 600; }
.roster-actions { display: flex; gap: 4px; }

.add-form { display: flex; gap: 8px; }
.add-form input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
}

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--muted); border-radius: 999px; transition: 0.2s;
}
.switch span::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.05s ease, filter 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); }
.btn.ghost { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn.round { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.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); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(15, 23, 32, 0.55);
  padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.modal h2 { margin: 0 0 4px; }
.modal-sub { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }
.modal input {
  width: 100%;
  padding: 14px;
  font-size: 1.3rem;
  text-align: center;
  letter-spacing: 0.3em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.pw-error { color: var(--red); font-size: 0.85rem; 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(--bg); color: var(--text); border-color: var(--line); }

[hidden] { display: none !important; }
