/* =========================================================================
   Game Day Freebies - same design system as Paycheck Allocator / Plateload:
   near-black canvas, layered surfaces, hairline borders, mint accent,
   large tabular numerals, system (SF) type.
   Phone (<1024px): frosted bottom tab bar, single column.
   Laptop (>=1024px): left sidebar.
   ========================================================================= */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #07090d;
  --surface: #10141b;
  --surface-2: #171c26;
  --surface-3: #212838;

  /* lines */
  --line: rgba(255, 255, 255, 0.07);

  /* text */
  --text: #f2f5fa;
  --muted: #8f9ab0;
  --faint: #5b6579;

  /* accent (mint, hue 156) */
  --accent-h: 156;
  --accent-l: 47%;
  --accent: hsl(var(--accent-h) 75% var(--accent-l));
  --accent-hover: hsl(var(--accent-h) 73% calc(var(--accent-l) + 12%));
  --accent-ink: hsl(var(--accent-h) 75% 5%);
  --accent-soft: hsl(var(--accent-h) 75% var(--accent-l) / 0.13);
  --accent-glow: hsl(var(--accent-h) 75% var(--accent-l) / 0.38);
  --accent-outline: hsl(var(--accent-h) 75% var(--accent-l) / 0.22);
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.14);
  --warn: #f5b84b;
  --warn-soft: rgba(245, 184, 75, 0.14);

  /* shape */
  --radius-card: 22px;
  --radius-row: 14px;
  --radius-ctl: 12px;
  --sidebar-w: 248px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -0.006em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* Soft mint glow behind everything (fixed pseudo-element; iOS ignores background-attachment:fixed). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 460px at 50% -160px, hsl(var(--accent-h) 75% var(--accent-l) / 0.11), transparent 70%),
    radial-gradient(640px 380px at 100% 0%, rgba(90, 120, 255, 0.07), transparent 70%);
}
#app { position: relative; z-index: 1; min-height: 100vh; }

::selection { background: var(--accent-soft); }
* { scrollbar-width: thin; scrollbar-color: #2b3445 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3445; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden, [hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- brand mark ---------- */
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-hover), hsl(var(--accent-h) 82% calc(var(--accent-l) - 8%)));
  box-shadow: 0 6px 16px -6px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* ---------- header ---------- */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  padding-top: calc(max(12px, env(safe-area-inset-top)) + 28px);
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
#app::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 25;
  height: env(safe-area-inset-top);
  background: var(--bg);
  pointer-events: none;
}
header h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
#refresh-btn { margin-left: auto; }

/* ---------- bottom tab bar (phones + tablets) ---------- */
#bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
  background: rgba(11, 14, 20, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px 2px;
  background: none;
  border: none;
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease;
}
.tab-icon { position: relative; display: grid; place-items: center; width: 54px; height: 30px; border-radius: 15px; transition: background 0.2s ease; }
.tab-icon svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; line-height: 1; }
.tab-btn.active { color: var(--accent); }
.tab-btn.active .tab-icon { background: var(--accent-soft); }
.tab-btn:active .tab-icon { transform: scale(0.94); }
.tab-count {
  position: absolute;
  top: -2px;
  right: 8px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

main {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px calc(100px + env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.tab-panel:not(.hidden) { animation: panelIn 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- cards ---------- */
.card {
  position: relative;
  margin: 0 0 16px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 130px), var(--surface);
  border: 3px solid var(--accent-outline);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 44px -24px rgba(0, 0, 0, 0.8);
}
.card h2 { position: relative; margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.018em; }
.card h2::after {
  content: "";
  position: absolute;
  left: 8%; right: 8%; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 35%, hsl(var(--accent-h) 75% var(--accent-l) / 0.22) 65%, transparent);
  pointer-events: none;
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card h2.collapse-toggle { flex: 0 1 auto; margin-right: auto; }
.collapse-arrow {
  position: relative;
  flex-shrink: 0;
  width: 8px; height: 8px;
  padding: 12px; margin: -12px;
  box-sizing: content-box;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease;
}
.collapse-arrow::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  margin: -6px 0 0 -4px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-radius: 1px;
  transform: rotate(45deg);
}
.card.collapsed .collapse-arrow { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }
.card.collapsed .card-header-row { margin-bottom: 0; }
.card.collapsible.collapsed, .card.collapsible .card-header-row { cursor: pointer; user-select: none; -webkit-user-select: none; }

/* Today's hero: count big and first, like Paycheck Allocator's balance. */
.card.hero {
  background:
    radial-gradient(520px 240px at 100% 0%, hsl(var(--accent-h) 75% var(--accent-l) / 0.17), transparent 70%),
    linear-gradient(180deg, #141c24, #0f151c);
  border-color: hsl(var(--accent-h) 75% var(--accent-l) / 0.2);
}
.hero-total { display: flex; flex-direction: column; gap: 4px; padding: 2px 0 16px; }
.hero-total .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.hero-total .big { font-size: clamp(34px, 9.5vw, 46px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.05; }
.hero-total .big small { font-size: 0.42em; font-weight: 600; color: var(--muted); letter-spacing: -0.01em; margin-left: 6px; }

/* ---------- lists + rows ---------- */
.list { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--accent-outline);
  border-radius: var(--radius-row);
  font-size: 15px;
  font-weight: 500;
}
.list-item > div:first-child { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 650; letter-spacing: -0.012em; }
.meta { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.meta.small { font-size: 12px; }
.row-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* Button groups stay side by side: they never shrink, wrap their labels, or get squeezed by the text beside them. */
.row-inline > button, .row-inline > a { flex: none; white-space: nowrap; }
.list-item > .row-inline { flex: none; flex-wrap: nowrap; }
.muted { color: var(--muted); font-size: 13px; }
.empty { padding: 6px 2px; color: var(--muted); font-size: 14px; }
.error-text { color: var(--danger); font-size: 13px; }
.status-line { min-height: 1.3em; margin: -4px 4px 12px; color: var(--muted); font-size: 12px; }

/* A freebie you can claim: accent rail like Paycheck Allocator's notifications. */
.list-item.freebie { align-items: flex-start; box-shadow: inset 3px 0 0 var(--accent); }
.freebie .price { flex: none; text-align: right; }
.freebie .price b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -0.03em; color: var(--accent); line-height: 1.1; }
.freebie .price span { color: var(--muted); font-size: 12px; }
.freebie .claim { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--accent-outline); font-size: 13px; color: var(--muted); }
.freebie .claim b { color: var(--text); font-weight: 600; }

.game-day { margin-top: 4px; font-size: 12px; font-weight: 650; letter-spacing: 0.02em; text-transform: uppercase; color: var(--accent); }
.expired .game-day { color: var(--muted); }
.list-item.freebie.claimed { box-shadow: inset 3px 0 0 var(--faint); background: rgba(255, 255, 255, 0.02); }
.list-item.freebie.claimed .price b { color: var(--muted); }
.list-item.freebie.expired { box-shadow: inset 3px 0 0 var(--faint); opacity: 0.6; }
.list-item.freebie.expired .price b { color: var(--muted); text-decoration: line-through; }

/* Game score line inside a row */
.score { display: inline-flex; gap: 6px; margin-top: 6px; padding: 3px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); color: var(--muted); font-size: 12px; font-weight: 600; }
.score .me { color: var(--text); }

/* ---------- badges ---------- */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.unlocked { background: var(--accent-soft); color: var(--accent); }
.pill.missed { background: var(--danger-soft); color: var(--danger); }
.pill.live, .pill.unknown { background: var(--warn-soft); color: var(--warn); }
.pill.idle { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.tag-badge { display: inline-block; margin: 2px 4px 2px 0; padding: 3px 9px; background: rgba(255, 255, 255, 0.07); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; border-radius: 999px; }
.tag-badge.accent { background: var(--accent-soft); color: var(--accent); }
.tag-badge.via { background: rgba(90, 120, 255, 0.14); color: #9db0ff; }
.tag-badge.warn { background: var(--warn-soft); color: var(--warn); }
.lead-sources { margin: 0 0 12px; }
.snippet { margin: 8px 0 8px; padding-left: 10px; border-left: 2px solid var(--accent-outline); color: var(--text); opacity: 0.85; font-size: 13.5px; line-height: 1.45; }
.snippet.none { color: var(--muted); font-style: italic; opacity: 1; }
.article { margin: 4px 0 10px; padding: 14px 16px; max-height: 60vh; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--accent-outline); border-radius: var(--radius-ctl); font-size: 14.5px; line-height: 1.6; }
.article p { margin: 0 0 10px; max-width: 65ch; }
.article p.li { margin-left: 4px; }
.article h4 { margin: 14px 0 6px; font-size: 15px; font-weight: 700; }
.article > :last-child { margin-bottom: 0; }

/* ---------- form controls ---------- */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.row label { flex: 1 1 100%; font-size: 13px; color: var(--muted); }
input, select {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--accent-outline);
  border-radius: var(--radius-ctl);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f9ab0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}
.row label { margin-bottom: -4px; }
.preview { margin: 4px 0 16px; padding: 12px 14px; border-radius: var(--radius-ctl); background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; }
.preview:empty { display: none; }
.check-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; color: var(--muted); cursor: pointer; }
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  flex: none;
  width: 18px; height: 18px; min-height: 0;
  margin: 0; padding: 0;
  border: 1.5px solid #3b475c;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
input[type="checkbox"]:checked {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.6 9.4l2.8 2.8 6-6.4' fill='none' stroke='%2303150d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}

button {
  min-height: 46px;
  padding: 11px 18px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.005em;
  border: none;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button:focus-visible, .tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 10px 24px -12px var(--accent-glow); }
button.secondary { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--accent-outline); color: var(--text); }
button.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
button.danger-text { color: var(--danger); }
button.wide { width: 100%; }
.form-actions > button { flex: 1 1 0; }
.promo-msg { margin: -4px 0 10px; color: var(--accent); font-size: 13px; font-weight: 600; }
.promo-msg:empty { display: none; }

/* ---------- hover (mouse devices only) ---------- */
@media (hover: hover) {
  .tab-btn:hover:not(.active) { color: var(--text); }
  button.primary:hover { background: var(--accent-hover); }
  button.secondary:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--accent-glow); }
  .collapse-arrow:hover { color: var(--text); }
}

/* ---------- phones ---------- */
@media (max-width: 420px) {
  .list-item.promo-row { flex-direction: column; align-items: stretch; }
  .list-item.promo-row > .row-inline { justify-content: flex-start; }
  /* The status pill moves above the text so the text (and its buttons) get the full width. */
  .list-item.status-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .list-item.status-row > .pill { order: -1; }
  .list-item.status-row > div:first-child { width: 100%; }
}

/* ---------- laptops: sidebar ---------- */
@media (min-width: 1024px) {
  header {
    position: fixed;
    top: 0; left: 0;
    z-index: 21;
    width: var(--sidebar-w);
    height: 84px;
    padding: 0 24px;
    background: none;
    border-bottom: none;
  }
  header h1 { font-size: 16px; }
  #refresh-btn { position: fixed; top: 20px; right: 28px; }
  #bottom-nav {
    top: 0; right: auto; bottom: 0;
    width: var(--sidebar-w);
    flex-direction: column;
    gap: 4px;
    padding: 92px 14px 24px;
    background: rgba(12, 15, 21, 0.7);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .tab-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; width: 100%; min-height: 46px; padding: 0 16px; }
  .tab-icon, .tab-btn.active .tab-icon { width: 24px; height: 24px; background: none; border-radius: 0; }
  .tab-count { top: -6px; right: -10px; }
  .tab-label { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
  .tab-btn.active { background: var(--accent-soft); }
  main { max-width: none; margin: 0 0 0 var(--sidebar-w); padding: 72px 48px 64px; }
  .tab-panel { max-width: 780px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
