/* NFL Live Score Notifier - panel styles.
   Self-contained: no external fonts, no CDNs, no build step. */

:root {
  --bg:          #0a0e14;
  --bg-soft:     #111823;
  --surface:     #151d2b;
  --surface-2:   #1c2636;
  --border:      #24304333;
  --border-solid:#243043;
  --text:        #e8edf5;
  --text-dim:    #93a1b8;
  --text-faint:  #64748b;
  --accent:      #38bdf8;
  --live:        #22c55e;
  --live-glow:   #22c55e40;
  --alert:       #f59e0b;
  --danger:      #ef4444;
  --radius:      14px;
  --shadow:      0 8px 28px rgba(0,0,0,.45);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1100px 520px at 12% -8%, #16304a 0%, transparent 62%),
    radial-gradient(900px 460px at 92% 0%, #1d2340 0%, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-solid);
  background: rgba(10, 14, 20, .72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(140deg, #1d4ed8, #0ea5e9);
  font-weight: 800; font-size: 15px; letter-spacing: .5px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(14,165,233,.35);
}

.brand-text h1 { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.brand-text p  { font-size: 13px; color: var(--text-dim); }

.status-cluster { display: flex; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-solid);
  background: var(--surface);
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.pill-quiet { color: var(--text-dim); font-weight: 500; }
.pill-quiet strong { color: var(--text); font-weight: 600; font-family: var(--mono); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot-live { background: var(--live); box-shadow: 0 0 0 4px var(--live-glow); animation: pulse 2s ease-in-out infinite; }
.dot-off  { background: var(--danger); box-shadow: none; animation: none; }
.dot-idle { background: var(--alert); box-shadow: 0 0 0 4px #f59e0b33; animation: none; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--live-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}

/* ---------- Demo mode banner ---------- */
/* Without this rule the `display:flex` below beats the HTML [hidden]
   attribute and the banner would show outside demo mode too. */
.demo-bar[hidden] { display: none; }

.demo-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 28px;
  background: linear-gradient(90deg, #f59e0b26, #f59e0b0d 60%, transparent);
  border-bottom: 1px solid #f59e0b4d;
  font-size: 13px;
  position: sticky; top: 90px; z-index: 15;
  backdrop-filter: blur(10px);
}
.demo-bar-tag {
  font-weight: 800; font-size: 11.5px; letter-spacing: .8px;
  color: #0a0e14; background: var(--alert);
  padding: 5px 11px; border-radius: 999px; flex: none;
}
.demo-bar-text { color: #fbd38d; min-width: 0; }
.demo-bar-progress { display: flex; align-items: center; gap: 9px; margin-left: auto; flex: none; }
.demo-bar-track {
  width: 130px; height: 6px; border-radius: 999px;
  background: #ffffff1f; overflow: hidden; display: block;
}
.demo-bar-fill {
  display: block; height: 100%; width: 0;
  background: var(--alert); border-radius: 999px;
  transition: width .4s ease;
}
.demo-bar-count {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  color: var(--alert); min-width: 42px; text-align: right;
}
.demo-bar.is-finished { background: linear-gradient(90deg, #22c55e26, #22c55e0d 60%, transparent); border-bottom-color: #22c55e4d; }
.demo-bar.is-finished .demo-bar-tag { background: var(--live); }
.demo-bar.is-finished .demo-bar-text { color: #9ae6b4; }
.demo-bar.is-finished .demo-bar-fill,
.demo-bar.is-finished .demo-bar-count { background: var(--live); color: var(--live); }
.demo-bar.is-finished .demo-bar-fill { background: var(--live); }

/* ---------- Layout ---------- */
.layout { max-width: 1320px; margin: 0 auto; padding: 26px 28px 40px; }

.stats {
  display: grid;
  /* auto-fit so the tiles reflow on their own when metrics are added/removed */
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  background: linear-gradient(160deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--border-solid);
  border-radius: var(--radius);
  padding: 16px 18px;
  /* Grid items default to min-width:auto, which lets long labels push the
     whole page wider than the viewport. Reset it everywhere it can happen. */
  min-width: 0;
}
.stat-label { display: block; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .7px; font-weight: 600; overflow-wrap: anywhere; }
.stat-value { display: block; margin-top: 6px; font-size: 30px; font-weight: 700; font-family: var(--mono); letter-spacing: -1px; }

.columns { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 18px; align-items: start; }
/* Main column wrapper: groups the scoreboard and the simulation card so they
   do not become independent grid columns. */
.main-col { min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.panel + .panel { margin-top: 18px; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-solid);
  background: var(--bg-soft);
}
.panel-head h2 { font-size: 15px; font-weight: 700; letter-spacing: .2px; }

.counter {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
  padding: 3px 10px; border-radius: 999px;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; cursor: pointer;
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 7px;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--accent); color: #06131c; }

/* ---------- Games ---------- */
.games { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.game {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px 14px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border-solid);
  border-radius: 12px;
  transition: border-color .18s, transform .18s;
}
.game::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; border-radius: 12px 0 0 12px; background: var(--text-faint);
}
.game.is-live::before { background: var(--live); }
.game.is-post::before { background: var(--text-faint); }
.game.is-pre::before  { background: var(--accent); }
.game.is-live { border-color: #22c55e44; }
.game:hover { border-color: #38bdf855; transform: translateY(-1px); }

.teams { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.team { display: flex; align-items: center; gap: 11px; min-width: 0; }
.team-logo {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px; background: var(--surface-2);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--text);
  overflow: hidden;
}
.team-logo img { width: 100%; height: 100%; object-fit: contain; }
.team-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.team-rec  { font-size: 12px; color: var(--text-faint); font-family: var(--mono); flex: none; }
.team.is-loser .team-name, .team.is-loser .team-score { opacity: .5; }
.team-score {
  margin-left: auto; padding-left: 14px;
  font-family: var(--mono); font-size: 24px; font-weight: 700;
  letter-spacing: -1px; min-width: 44px; text-align: right; flex: none;
  /* Explicit line-height: some fonts clip the digits without it. */
  line-height: 1.25;
}
.team.is-winner .team-score { color: var(--live); }

.game-meta { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; min-width: 118px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.badge-live { background: #22c55e1f; color: var(--live); }
.badge-pre  { background: #38bdf81f; color: var(--accent); }

.game-clock { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.game-sub { font-size: 12px; color: var(--text-faint); }

/* Quarter-by-quarter line score table */
.quarters { grid-column: 1 / -1; order: 3; overflow-x: auto; }
.qt {
  border-collapse: collapse;
  font-family: var(--mono); font-size: 12px;
  margin-top: 2px;
}
.qt th, .qt td {
  padding: 4px 9px;
  text-align: center;
  border-bottom: 1px solid var(--border-solid);
}
.qt thead th {
  color: var(--text-faint); font-size: 10.5px; font-weight: 700;
  letter-spacing: .5px; border-bottom-color: var(--border-solid);
}
.qt tbody tr:last-child th, .qt tbody tr:last-child td { border-bottom: 0; }
.qt .qt-team {
  color: var(--text-dim); font-weight: 700; text-align: left;
  min-width: 42px;
}
.qt tbody td { color: var(--text-dim); }
.qt .qt-total { color: var(--text); font-weight: 700; }

.lastplay {
  grid-column: 1 / -1;
  order: 4;
  font-size: 12.5px; color: var(--text-dim);
  border-top: 1px dashed var(--border-solid);
  padding-top: 10px; margin-top: 2px;
  display: flex; gap: 8px;
}
.lastplay b { color: var(--accent); font-weight: 700; flex: none; }

/* ---------- Simulation details card ---------- */
.demo-info { padding: 14px 18px 16px; }
.demo-note {
  font-size: 13px; color: var(--text-dim); line-height: 1.55;
  margin-bottom: 14px;
  padding: 11px 13px;
  background: #f59e0b12; border: 1px solid #f59e0b33; border-radius: 9px;
}
.demo-note b { color: var(--alert); }
.demo-rows { display: flex; flex-direction: column; gap: 1px; }
.demo-row {
  display: grid; grid-template-columns: 190px minmax(0, 1fr);
  gap: 12px; padding: 9px 2px;
  border-bottom: 1px solid var(--border-solid);
}
.demo-row:last-child { border-bottom: 0; }
.demo-row dt { font-size: 12.5px; color: var(--text-faint); font-weight: 600; }
.demo-row dd { font-size: 13px; color: var(--text); overflow-wrap: anywhere; }

@media (max-width: 620px) {
  .demo-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

/* ---------- Feed ---------- */
/* Fades the last visible card so a scrollable history reads as intentional. */
.feed {
  list-style: none; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 470px; overflow-y: auto;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent 100%);
}
.feed::-webkit-scrollbar { width: 8px; }
.feed::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; }

.feed-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px;
  padding: 11px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border-solid);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.feed-tag {
  font-family: var(--mono); font-size: 10px; font-weight: 800;
  padding: 3px 7px; border-radius: 6px; height: fit-content;
  background: var(--surface-2); color: var(--accent);
}
.feed-tag.td { background: #22c55e1f; color: var(--live); }
.feed-tag.fg { background: #f59e0b1f; color: var(--alert); }
.feed-body { min-width: 0; }
.feed-score { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.feed-text { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.feed-when { font-size: 11px; color: var(--text-faint); font-family: var(--mono); margin-top: 3px; }

/* ---------- Channels ---------- */
.channels { list-style: none; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.channel {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border-solid);
  border-radius: 10px;
  min-width: 0;
}
.channel .dot { margin-top: 5px; }
.channel-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.channel-name { font-weight: 600; font-size: 14px; }
.channel-detail { font-size: 12px; color: var(--text-faint); overflow-wrap: anywhere; }
.channel-error { font-size: 11.5px; color: var(--danger); overflow-wrap: anywhere; }
.channel-state { margin-left: auto; padding-left: 8px; font-size: 12px; font-weight: 600; flex: none; }
.channel-state.on  { color: var(--live); }
.channel-state.off { color: var(--text-faint); }

/* Overall notification-channel status banner */
.banner {
  margin: 12px 12px 10px;
  padding: 12px 14px;
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12.5px; line-height: 1.45;
  border: 1px solid transparent;
}
.banner b { font-size: 13.5px; }
.banner span { color: var(--text-dim); }
.banner code {
  font-family: var(--mono); font-size: 11.5px;
  background: #ffffff14; padding: 1px 5px; border-radius: 4px; color: var(--text);
}
.banner-warn { background: #f59e0b14; border-color: #f59e0b40; }
.banner-warn b { color: var(--alert); }
.banner-ok { background: #22c55e14; border-color: #22c55e40; }
.banner-ok b { color: var(--live); }

/* Last alert delivered */
.last-sent {
  margin: 0 12px 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border-solid);
  border-left: 3px solid var(--accent);
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.last-sent-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px;
  font-weight: 700; color: var(--text-faint);
}
.last-sent-score { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.last-sent-text { font-size: 12.5px; color: var(--text-dim); overflow-wrap: anywhere; }
.last-sent-when { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.last-sent-empty {
  border-left-color: var(--border-solid);
  color: var(--text-faint); font-size: 13px; text-align: center;
}

.empty { padding: 26px 18px; text-align: center; color: var(--text-faint); font-size: 13.5px; }

/* ---------- Footer ---------- */
.foot {
  max-width: 1320px; margin: 0 auto; padding: 0 28px 30px;
  color: var(--text-faint); font-size: 12.5px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.sep { opacity: .5; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .columns { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .topbar, .layout, .foot { padding-left: 14px; padding-right: 14px; }
  .topbar { padding-top: 16px; padding-bottom: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-label { font-size: 10.5px; letter-spacing: .4px; }
  .stat-value { font-size: 23px; }

  .panel-head { padding: 13px 14px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 7px 8px; text-align: center; }

  .games, .feed, .channels { padding: 10px; }
  .game { grid-template-columns: minmax(0, 1fr); padding: 13px 13px 13px 17px; gap: 11px; }
  .game-meta {
    flex-direction: row; align-items: center; justify-content: flex-start;
    gap: 10px; flex-wrap: wrap; width: 100%; text-align: left; min-width: 0;
  }
  .team-score { font-size: 21px; min-width: 38px; padding-left: 10px; }
  .team-logo { width: 26px; height: 26px; }
  .team-name { font-size: 13.5px; }
  .lastplay { flex-direction: column; gap: 3px; }

  .brand-mark { width: 42px; height: 42px; font-size: 13px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { font-size: 12px; }
  .foot { font-size: 11.5px; }
}

/* Extra-narrow phones: one stat per row rather than two cramped ones. */
@media (max-width: 380px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
