:root {
  --red: #b3122e;
  --red-dark: #7d0b1f;
  --green: #1f6f50;
  --gold: #f2b632;
  --ink: #1c1917;
  --muted: #57534e;
  --paper: #fffaf3;
  --card: #ffffff;
  --line: #eadfd2;
  --shadow: 0 10px 30px rgba(60, 10, 20, 0.18);
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); }
button, input, textarea { font: inherit; }

/* ---------------- Viewer ---------------- */
.viewer { overflow: hidden; }
#map { position: fixed; inset: 0; z-index: 0; background: #e8e4dc; }
#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 500; }

.banner {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 64px;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  border-radius: 18px;
  box-shadow: var(--shadow);
  max-width: 560px;
}
.banner::after {
  /* candy-cane edge */
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -5px;
  height: 5px;
  border-radius: 0 0 6px 6px;
  background: repeating-linear-gradient(-45deg, #fff 0 8px, var(--red) 8px 16px);
  opacity: 0.9;
}
.club { margin: 0; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.banner h1 { margin: 0; font-size: 1.45rem; font-weight: 700; line-height: 1.1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #d6d3d1; }
.pill.live .dot { background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); animation: blip 1.6s infinite; }
.pill.break .dot { background: var(--gold); }
.pill.stale .dot { background: #fb923c; }
@keyframes blip { 70% { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

.leaflet-top.leaflet-right { top: calc(env(safe-area-inset-top)); }

.sheet {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 600;
  max-width: 560px;
  padding: 16px 16px 14px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  border-top: 5px solid var(--green);
}
.headline { margin: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.25; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.note {
  margin: 10px 0 0; padding: 8px 12px;
  background: #fff6dc; border: 1px solid #f5dfa0; border-radius: 12px;
  font-size: 0.95rem;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; }
.cards:not(:has(.card:not([hidden]))) { display: none; }
.card {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 14px;
  background: #f6f1ea; border: 1px solid var(--line);
}
.card[hidden] { display: none; }
.label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.value { font-size: 1.1rem; font-weight: 600; }
.meta { font-size: 0.85rem; color: var(--muted); }

.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary[aria-pressed='false'] { background: #fff; color: var(--green); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.extra-link { display: block; margin-top: 10px; text-align: center; color: var(--red); font-weight: 600; }

/* Santa marker */
.santa-icon { position: relative; }
.santa-badge {
  position: absolute; inset: 6px;
  display: grid; place-items: center;
  font-size: 26px; line-height: 1;
  background: #fff; border: 4px solid var(--red); border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.santa-pulse {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(179, 18, 46, 0.35);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }

.stop-icon span {
  display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; color: var(--green);
  border: 3px solid var(--green); font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.stop-icon.visited span { background: var(--green); color: #fff; }

@media (min-width: 720px) {
  .sheet { left: 20px; bottom: 20px; right: auto; width: 400px; }
  .banner { left: 20px; top: 20px; right: auto; width: 400px; }
}

@media (prefers-reduced-motion: reduce) {
  .santa-pulse, .pill.live .dot { animation: none; }
}

/* ---------------- Sender ---------------- */
.sender { min-height: 100%; background: linear-gradient(var(--red), var(--red)) top / 100% 150px no-repeat, var(--paper); }
.sender main { max-width: 480px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 16px 40px; }
.sender h1 { color: #fff; margin: 0 0 4px; font-size: 1.6rem; }
.sender .lede { color: #ffe4e8; margin: 0 0 20px; }
.panel { background: #fff; border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 1.05rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field input, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 1rem; background: #fffdf9;
}
.big {
  width: 100%; min-height: 64px; border: 0; border-radius: 16px;
  font-size: 1.2rem; font-weight: 600; color: #fff; background: var(--green); cursor: pointer;
}
.big.stop { background: var(--red); }
#reset { width: 100%; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stat { background: #f6f1ea; border-radius: 12px; padding: 8px 10px; }
.stat .value { font-size: 1rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { margin: 10px 0 0; font-size: 0.95rem; color: var(--muted); }
.status-line.bad { color: var(--red); font-weight: 600; }
.status-line.good { color: var(--green); font-weight: 600; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }
