/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --border:    #2a2d3a;
  --accent:    #e8a838;
  --accent-dim:#a87520;
  --text:      #e2e4ec;
  --muted:     #7a7f9a;
  --danger:    #e85c5c;
  --radius:    6px;
  --font:      'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

header h1 {
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

#site-author {
  font-size: 11px;
  color: var(--muted);
  margin-top: -6px;   /* pull tight under the h1 */
}
#site-author a {
  color: var(--accent);
  text-decoration: none;
}
#site-author a:hover { text-decoration: underline; }

#api-key-section {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#api-key-input {
  flex: 1;
  min-width: 220px;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  font-family: monospace;
}

#api-key-input:focus { outline: 1px solid var(--accent); }

#status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

#status-msg {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

#status-msg.error { color: var(--danger); }
#status-msg.ok    { color: #6ec97a; }

#countdown-display {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 4ch;
}

#auto-refresh-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
}

#auto-refresh-select:focus { outline: 1px solid var(--accent); }

#key-privacy-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

#key-privacy-note strong { color: #9aa0b8; font-weight: 600; }
#key-privacy-note code   { font-family: monospace; color: #9aa0b8; }


/* ── Buttons ────────────────────────────────────────────── */
button {
  background: var(--accent);
  color: #0f1117;
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}

button:hover:not(:disabled) { background: #f0b84a; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

button.secondary:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }

/* ── Filters ────────────────────────────────────────────── */
#filter-toggle { display: none; }   /* shown only on mobile via media query */

#filters {
  display: flex;
  gap: 12px 16px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 20px 0;
}

#filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

#filters label.filter-wide input {
  width: 200px;
}

#filters input,
#filters select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  width: 120px;
}

#filters select { cursor: pointer; }

#filters input:focus,
#filters select:focus { outline: 1px solid var(--accent); }

/* ── Bounty count ───────────────────────────────────────── */
#bounty-count {
  padding: 10px 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#bounty-count-text {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

.status-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#check-status-btn {
  padding: 4px 10px;
  font-size: 12px;
}
#check-status-btn:not(:disabled) {
  background: rgba(46, 106, 63, 0.35);
  border-color: #3a8a52;
  color: #6ec97a;
}
#check-status-btn:not(:disabled):hover {
  background: rgba(46, 106, 63, 0.55);
  border-color: #6ec97a;
}

#status-checked-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Status badges ──────────────────────────────────────── */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}

.status-ok        { color: #6ec97a; }
.status-hospital  { color: var(--danger); }
.status-traveling { color: #4a9eff; }
.status-jail      { color: #e89838; }
.status-federal   { color: #c04040; }
.status-unknown   { color: var(--muted); }

/* ── Profile row (rank / last action / life) ────────────── */
.card-profile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}
.target-rank        { color: var(--muted); }
.target-rank em     { font-style: normal; color: var(--accent); }
.target-last-action { color: var(--muted); }
.life-high          { color: #6ec97a; }
.life-mid           { color: var(--accent); }
.life-low           { color: var(--danger); }
.revivable-badge    { color: #4a9eff; font-weight: 600; }
#filter-location:disabled { opacity: 0.4; cursor: not-allowed; }
.ff-badge           { font-size: 11px; font-weight: 700; white-space: nowrap; }
.ff-high            { color: var(--accent); }
.ff-mid             { color: #6ec97a; }
.ff-low             { color: var(--muted); }
.ff-unknown         { color: var(--muted); }
.ff-bs              { font-size: 11px; color: var(--muted); }
.ff-consent-actions { display: flex; gap: 10px; margin-top: 16px; }

#ff-checked-time { font-size: 11px; color: var(--muted); white-space: nowrap; }

#check-ff-btn:not(:disabled) {
  background: rgba(46, 106, 63, 0.35);
  border-color: #3a8a52;
  color: #6ec97a;
}
#check-ff-btn:not(:disabled):hover {
  background: rgba(46, 106, 63, 0.55);
  border-color: #6ec97a;
}

/* ── Bounty list ────────────────────────────────────────── */
#bounty-list {
  padding: 14px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.placeholder {
  color: var(--muted);
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
}

/* ── Bounty card ────────────────────────────────────────── */
.bounty-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.bounty-card:hover { border-color: var(--accent-dim); }

/* ── Card states ────────────────────────────────────────── */
.bounty-card.expiring-soon { border-color: var(--danger); }
.bounty-card.fair-fight    { border-color: #4a9eff; }
.expires-soon-text         { color: var(--danger); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.reward-block {
  text-align: right;
  flex-shrink: 0;
}

.total-value {
  font-size: 11px;
  color: var(--accent-dim);
  margin-top: 2px;
}

.player-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.player-name a {
  color: inherit;
  text-decoration: none;
}

.player-name a:hover { color: var(--accent); }

.reward {
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  white-space: nowrap;
}

.card-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.qty-badge {
  display: inline-block;
  background: var(--accent-dim);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

.card-reason {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.hunt-btn {
  align-self: flex-start;
  padding: 5px 12px;
  font-size: 12px;
  margin-top: 2px;
}

/* ── Help button ────────────────────────────────────────── */
#help-btn {
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

/* ── Help dialog ────────────────────────────────────────── */
#help-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 0;
  max-width: 560px;
  width: calc(100vw - 32px);
  max-height: min(80vh, 640px);
  overflow: hidden;
}

#help-dialog[open] {
  display: flex;
  flex-direction: column;
}

#help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-header h2 {
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

#help-close-btn {
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.help-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.help-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-section li {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  padding-left: 12px;
  position: relative;
}

.help-section li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--border);
}

.help-section strong { color: var(--text); }

.help-section code {
  font-family: monospace;
  color: #9aa0b8;
  font-size: 12px;
}

.help-section em { color: #9aa0b8; font-style: normal; }

.help-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 2px solid;
  vertical-align: middle;
  margin-right: 3px;
  flex-shrink: 0;
}

.help-swatch.blue { border-color: #4a9eff; }
.help-swatch.red  { border-color: var(--danger); }

/* ── Loading spinner ────────────────────────────────────── */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 0;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 600px) {

  /* ── Show / hide filter panel ── */
  #filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(100% - 32px);
    margin: 12px 16px 0;
    min-height: 44px;
  }

  #filters          { display: none; grid-template-columns: 1fr 1fr; padding: 12px 16px 0; }
  #filters.open     { display: grid; }

  /* Name search and reset button span both columns */
  #filters label.filter-wide,
  #reset-filters-btn { grid-column: 1 / -1; }

  /* All inputs fill their label */
  #filters input,
  #filters select,
  #filters label.filter-wide input { width: 100%; }

  /* ── Touch-friendly tap targets (≥ 44 px tall) ── */
  button       { min-height: 44px; }
  .hunt-btn  { align-self: stretch; text-align: center; min-height: 44px; }

  /* ── Tighten outer padding on small screens ── */
  header        { padding: 12px 16px; }
  #bounty-list  { padding: 12px 16px; }
  #bounty-count { padding: 8px 16px 0; }

  /* ── Bump small text up for readability ── */
  .card-meta,
  .card-reason  { font-size: 13px; }
  .total-value  { font-size: 12px; }
  #key-privacy-note { font-size: 12px; }
}
