:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --sam: #2563eb;
  --sam-soft: #dbeafe;
  --kevin: #dc2626;
  --kevin-soft: #fee2e2;
  --dillon: #059669;
  --dillon-soft: #d1fae5;
  --neutral: #6b7280;
  --accent: #111827;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ---- header ---- */
.masthead {
  background: var(--accent);
  color: #fff;
  border-bottom: 4px solid var(--sam);
  /* Fill the iPhone notch/status-bar area with the header color instead of leaving content under it. */
  padding-top: env(safe-area-inset-top);
}
.masthead-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 20px 18px;
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
}
.masthead h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -.5px;
  font-weight: 800;
}
.masthead .tagline { margin: 4px 0 0; color: #c7cbd4; font-size: 14px; }
.masthead .live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #fca5a5; margin-bottom: 6px;
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---- ad slots ---- */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #eceef1, #eceef1 10px, #e6e8ec 10px, #e6e8ec 20px);
  border: 1px dashed #c7ccd3;
  border-radius: 10px;
  color: #9aa1ab; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  overflow: hidden;
}
.ad-slot img { display: block; max-width: 100%; height: auto; }
.ad-cta {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%; height: 100%; text-decoration: none; color: #6b7280; text-align: center;
}
.ad-cta:hover { color: var(--accent); }
.ad-cta:hover ~ * , .ad-slot:hover { }
.ad-cta-title { font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
.ad-cta-sub { font-size: 12px; letter-spacing: .02em; text-transform: none; opacity: .8; }
.ad-leaderboard { max-width: 1100px; margin: 16px auto 0; padding: 0 20px; }
.ad-leaderboard .ad-slot { height: 90px; }
.ad-sidebar .ad-slot { height: 250px; }
.ad-infeed { height: 120px; margin: 4px 0; }

/* ---- dramatic map hero ---- */
.map-hero-wrap { max-width: 1100px; margin: 16px auto 0; padding: 0 20px; }
.map-hero {
  position: relative; height: 58vh; min-height: 360px; max-height: 620px;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line); background: #0b1220;
}
.map-hero #drama-map, .map-hero iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.leaflet-container { background: #0b1220; }
/* Cinematic vignette + a dark intro wash that fades as the map flies in. */
.map-scrim { position: absolute; inset: 0; pointer-events: none; z-index: 2; box-shadow: inset 0 0 160px rgba(0,0,0,.55); }
.map-scrim::before {
  content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, transparent 40%, rgba(4,8,18,.85));
  animation: scrimClear 2.6s ease forwards;
}
@keyframes scrimClear { 0% { opacity: 1; } 100% { opacity: .35; } }

/* Title card that appears over the zoom, then fades. */
.map-title {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 4;
  text-align: center; color: #fff; pointer-events: none; text-shadow: 0 4px 24px rgba(0,0,0,.7);
  animation: titleCard 4.6s cubic-bezier(.2,.7,.2,1) forwards;
}
.map-title .mt-kicker { font-size: 13px; font-weight: 700; letter-spacing: .35em; text-transform: uppercase; color: #fca5a5; }
.map-title .mt-main { font-size: clamp(40px, 9vw, 96px); font-weight: 900; letter-spacing: 2px; line-height: 1; margin: 6px 0; }
.map-title .mt-sub { font-size: clamp(14px, 2.4vw, 20px); font-weight: 600; color: #e5e7eb; letter-spacing: .12em; }
@keyframes titleCard {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.18); filter: blur(6px); letter-spacing: 10px; }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: blur(0); }
  68%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -52%) scale(.97); }
}

.map-caption {
  position: absolute; left: 18px; bottom: 16px; z-index: 3; color: #fff;
  font-weight: 800; font-size: 19px; letter-spacing: .3px; text-shadow: 0 2px 12px rgba(0,0,0,.7);
  opacity: 0; transform: translateY(10px); animation: capIn .8s ease 4s forwards;
}
.map-caption .pin { filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
@keyframes capIn { to { opacity: 1; transform: none; } }

/* Pulsing location pin (Leaflet divIcon). */
.pulse-marker { background: none; border: none; }
.pulse-dot { width: 16px; height: 16px; background: #dc2626; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 0 rgba(220,38,38,.6); animation: pulseRing 1.9s infinite; }
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
  70%  { box-shadow: 0 0 0 26px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

/* No-tiles fallback: cinematic CSS zoom-in reveal on the embedded map. */
.map-hero.reveal iframe { animation: mapZoom 3s cubic-bezier(.19,.72,.16,1) both; transform-origin: 50% 52%; }
@keyframes mapZoom {
  0%   { transform: scale(2.2); filter: saturate(1.25) brightness(1.05) blur(2px); }
  100% { transform: scale(1);   filter: none; }
}
@media (max-width: 860px) {
  .map-hero { height: 46vh; height: 46dvh; min-height: 280px; max-height: 440px; }
  /* On mobile the map is a passive cinematic element — don't let it trap page scrolling. */
  .map-hero #drama-map, .map-hero iframe { pointer-events: none; }
  .map-caption { font-size: 15px; left: 14px; bottom: 12px; }
  .map-title .mt-main { letter-spacing: 1px; }
}

/* ---- layout ---- */
.wrap {
  max-width: 1100px;
  margin: 20px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 26px;
  align-items: start;
}
@media (max-width: 860px) {
  .wrap {
    grid-template-columns: 1fr;
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
  }
  /* Not sticky on mobile, so articles don't scroll behind it. */
  .sidebar { position: static; order: 0; }
  /* Mobile ads: only the in-feed square between articles — hide the top + sidebar banners. */
  .ad-leaderboard, .ad-sidebar { display: none; }
}

/* ---- filters ---- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.chip:hover { border-color: #c3c8d0; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.active.sam { background: var(--sam); border-color: var(--sam); }
.chip.active.kevin { background: var(--kevin); border-color: var(--kevin); }
.chip.active.dillon { background: var(--dillon); border-color: var(--dillon); }

/* ---- feed cards ---- */
.feed { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden; position: relative;
}
.card.team-sam { border-left: 5px solid var(--sam); }
.card.team-kevin { border-left: 5px solid var(--kevin); }
.card.team-dillon { border-left: 5px solid var(--dillon); }
.card.team-neutral { border-left: 5px solid var(--neutral); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  background: #e5e7eb; flex: none; display: grid; place-items: center; color: #9aa1ab; font-weight: 700;
}
.card-head .who { flex: 1; min-width: 0; }
.card-head .who .name { font-weight: 700; font-size: 15px; }
.card-head .who .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 6px;
}
.badge.facebook { background: #e7f0ff; color: #1d4ed8; }
.badge.instagram { background: #fdeaf4; color: #c2185b; }
.badge.patch { background: #e6f6ec; color: #15803d; }
.badge.court { background: #f3ede1; color: #92400e; }
.badge.manual { background: #eef1f4; color: #475569; }
.team-badge { font-size: 11px; font-weight: 800; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.team-badge.sam { background: var(--sam-soft); color: var(--sam); }
.team-badge.kevin { background: var(--kevin-soft); color: var(--kevin); }
.team-badge.dillon { background: var(--dillon-soft); color: var(--dillon); }
.team-badge.neutral { background: #eef1f4; color: var(--neutral); }

.card-title { padding: 8px 16px 0; font-size: 17px; font-weight: 700; }
.card-body { padding: 6px 16px 0; color: #2b2f36; white-space: pre-wrap; }
.card-thumb { margin: 12px 0 0; display: block; }
.card-thumb img { width: 100%; max-height: 460px; object-fit: cover; display: block; }
.source-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 12px 16px 0;
  font-size: 13px; font-weight: 600; color: var(--sam); text-decoration: none;
}
.source-link:hover { text-decoration: underline; }

.card-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px 14px; margin-top: 12px;
  border-top: 1px solid var(--line);
}
.act {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--ink);
}
.act:hover { border-color: #c3c8d0; }
.act.liked { background: var(--kevin-soft); border-color: var(--kevin); color: var(--kevin); }
.act .cnt { color: var(--muted); font-weight: 700; }

/* ---- reactions ---- */
.react-wrap { position: relative; }
.act.react-btn.reacted { background: var(--sam-soft); border-color: var(--sam); color: var(--sam); }
.react-pop {
  position: absolute; bottom: 44px; left: 0; display: none; gap: 4px; z-index: 6;
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px; box-shadow: var(--shadow);
}
.react-pop.open { display: flex; }
.react-opt {
  border: none; background: none; cursor: pointer; font-size: 22px; line-height: 1; padding: 2px;
  transition: transform .12s; border-radius: 50%;
}
.react-opt:hover { transform: scale(1.35) translateY(-2px); }
.react-summary { padding: 8px 16px 0; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-height: 0; }
.react-summary:empty { display: none; }
.rsum-item { display: inline-flex; align-items: center; gap: 3px; }
.rsum-item b { font-weight: 700; color: var(--ink); }
.rsum-total { margin-left: 4px; font-weight: 700; color: var(--ink); }

/* ---- scraped social comments ---- */
.comments { margin: 10px 16px 0; padding: 10px 12px; background: #f7f8fa; border-radius: 10px; }
.cmt-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.cmt { font-size: 14px; margin-bottom: 5px; }
.cmt-author { font-weight: 700; }
.cmt-text { color: #2b2f36; }
.cmt-more { font-size: 12px; color: var(--muted); margin-top: 4px; }
.share-menu { position: relative; }
.share-pop {
  position: absolute; bottom: 44px; left: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 5; min-width: 150px;
}
.share-pop.open { display: block; }
.share-pop a, .share-pop button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px;
  font-size: 13px; border-radius: 7px; cursor: pointer; color: var(--ink); text-decoration: none;
}
.share-pop a:hover, .share-pop button:hover { background: #f1f3f5; }

/* ---- sidebar ---- */
.sidebar { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.poll-opt { margin-bottom: 12px; }
.poll-btn {
  width: 100%; text-align: left; border: 1px solid var(--line); background: #fff;
  padding: 10px 12px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.poll-btn[data-side="0"]:hover, .poll-btn.voted[data-side="0"] { border-color: var(--sam); color: var(--sam); }
.poll-btn[data-side="1"]:hover, .poll-btn.voted[data-side="1"] { border-color: var(--kevin); color: var(--kevin); }
.poll-btn[data-side="2"]:hover, .poll-btn.voted[data-side="2"] { border-color: var(--dillon); color: var(--dillon); }
.poll-bar-wrap { height: 8px; background: #eef1f4; border-radius: 999px; margin-top: 8px; overflow: hidden; }
.poll-bar { height: 100%; width: 0; transition: width .4s ease; }
.poll-bar.s0 { background: var(--sam); }
.poll-bar.s1 { background: var(--kevin); }
.poll-bar.s2 { background: var(--dillon); }

/* ---- momentum (stock-ticker) chart ---- */
.trend-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.trend-range { font-size: 12px; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.trend-chart { width: 100%; height: auto; display: block; }
.ticker { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ticker li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ticker .tk-name { font-weight: 700; flex: 1; }
.ticker .tk-dot { width: 10px; height: 10px; border-radius: 3px; }
.ticker .tk-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.ticker .tk-chg { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tk-up { color: var(--dillon); }
.tk-down { color: var(--kevin); }
.tk-flat { color: var(--muted); }
.poll-pct { font-size: 12px; color: var(--muted); margin-top: 4px; }
.poll-total { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

.disclaimer {
  max-width: 1100px; margin: 0 auto; padding: 26px 20px 50px; color: var(--muted); font-size: 12px;
  text-align: center; line-height: 1.6;
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.footer-nav { margin-top: 12px; font-size: 13px; }
.footer-nav a { color: var(--sam); text-decoration: none; font-weight: 600; }
.footer-nav a:hover { text-decoration: underline; }

/* ---- public (news) mode: hide the private/targeting UI ---- */
body.public-mode #poll-panel,
body.public-mode #trend-panel { display: none; }
body.public-mode .masthead { border-bottom-color: #6b7280; }

/* ---- admin ---- */
.admin-wrap { max-width: 900px; margin: 24px auto 80px; padding: 0 20px; }
.admin-wrap h2 { margin-top: 34px; }
.gate { text-align: center; padding: 60px 20px; }
.gate input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; width: 280px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn.sam { background: var(--sam); }
.btn.kevin { background: var(--kevin); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--kevin); border: 1px solid var(--kevin); }
.admin-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.admin-card .ameta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.admin-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.admin-card img.thumb { max-height: 120px; border-radius: 8px; margin-top: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .3s; pointer-events: none; }
.toast.show { opacity: 1; }
