@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0d0b14;
  --surface: #16131f;
  --surface-raised: #1e1a2c;
  --border: #2c2740;
  --border-bright: #3d3558;
  --text: #ede9f7;
  --text-muted: #8b84a8;
  --text-faint: #5a5372;
  --accent: #a970ff;
  --accent-dim: #6b4fa0;
  --accent-soft: rgba(169, 112, 255, 0.14);
  --claimed: #4ade80;
  --error: #ff6b6b;
  --pending: #f5c451;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(169, 112, 255, 0.10), transparent),
    radial-gradient(ellipse 700px 400px at 100% 0%, rgba(107, 79, 160, 0.10), transparent);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

input, select {
  font-family: var(--font-mono);
}

/* -- layout shell -------------------------------------------------- */

.shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 24px 96px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow .glyph {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--accent);
  transform: rotate(45deg);
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 4px 0 0;
}

.back-link {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

/* -- buttons --------------------------------------------------------- */

.btn {
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-bright);
  background: var(--surface-raised);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--accent-dim); background: #241f36; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #140b24;
}
.btn-accent:hover { background: #b984ff; border-color: #b984ff; }

.btn-danger { border-color: rgba(255, 107, 107, 0.35); color: #ffb3b3; }
.btn-danger:hover { border-color: var(--error); background: rgba(255, 107, 107, 0.08); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }

/* -- cards ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card + .card { margin-top: 14px; }

/* -- status dot -------------------------------------------------------- */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: var(--text-faint);
}
.status-dot.is-running {
  background: var(--claimed);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16);
  animation: pulse 2s ease-in-out infinite;
}
.status-dot.is-error { background: var(--error); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.16); }
.status-dot.is-pending { background: var(--pending); box-shadow: 0 0 0 3px rgba(245, 196, 81, 0.16); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* -- forms --------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}
.field input:focus,
.field select:focus { border-color: var(--accent); }
.field .hint { font-size: 12px; color: var(--text-faint); font-family: var(--font-body); }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 8px;
  min-height: 42px;
}
.tag-input input {
  border: none;
  background: none;
  flex: 1;
  min-width: 100px;
  padding: 4px;
  font-size: 13px;
}
.tag-input input:focus { outline: none; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
}
.tag button {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  opacity: 0.7;
}
.tag button:hover { opacity: 1; }

/* -- empty / loading states ------------------------------------------ */

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
.empty-state .glyph-drop {
  width: 32px;
  height: 40px;
  margin: 0 auto 16px;
  opacity: 0.5;
}
.empty-state p { margin: 0; font-size: 14px; }
.empty-state .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--surface-raised);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  font-family: var(--font-mono);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(-8px); }
.toast.is-error { border-color: rgba(255, 107, 107, 0.4); color: #ffb3b3; }

/* -- account cards (dashboard) -------------------------------------- */

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

.account-card .identity {
  flex: 1;
  min-width: 0;
}

.account-card .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-card .status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.account-card .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* -- device-code login screen ----------------------------------------- */

.code-display {
  text-align: center;
  padding: 12px 0 4px;
}

.code-display .code {
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 8px 0 18px;
  word-break: break-all;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-bright);
  border-top-color: var(--accent);
  display: inline-block;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* -- progress bars ------------------------------------------------- */

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.is-complete { background: var(--claimed); }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* -- campaign grid ---------------------------------------------------- */

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.campaign-card .art {
  height: 120px;
  background: var(--surface-raised) center/cover no-repeat;
  position: relative;
}

.campaign-card .art .badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(13, 11, 20, 0.75);
  backdrop-filter: blur(4px);
}

.campaign-card .art .badge.is-unlinked { color: var(--pending); border: 1px solid rgba(245, 196, 81, 0.4); }
.campaign-card .art .badge.is-linked { color: var(--claimed); border: 1px solid rgba(74, 222, 128, 0.35); }

.campaign-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }

.campaign-card .game { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }

.campaign-card .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.3; }

.benefit-row { display: flex; flex-wrap: wrap; gap: 6px; }

.benefit-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 3px;
  font-size: 11px;
  color: var(--text-muted);
}
.benefit-chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; background: var(--surface-raised); }
.benefit-chip.is-claimed { border-color: rgba(74, 222, 128, 0.3); color: var(--claimed); }

.campaign-card .footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.game-tag-actions { display: flex; gap: 6px; }
.game-tag-actions .btn-sm.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* -- settings panel (priority / exclude lists) ------------------------ */

.settings-row { display: flex; gap: 16px; flex-wrap: wrap; }
.settings-row .field { flex: 1; min-width: 220px; }

/* -- watching card (progress screen) ----------------------------------- */

.watching-card { display: flex; align-items: center; gap: 14px; }
.watching-card .glyph-live {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.watching-card .glyph-live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.watching-card .channel-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.watching-card .channel-status { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.progress-campaign-group + .progress-campaign-group { margin-top: 14px; }

.progress-campaign-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.progress-campaign-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--surface-raised) center/cover no-repeat;
  flex-shrink: 0;
}

.progress-campaign-meta { min-width: 0; }
.progress-campaign-meta .game { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.progress-campaign-meta .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.3; margin-top: 2px; }
.progress-campaign-meta .sub-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--text-faint); }

.badge-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(13, 11, 20, 0.5);
}
.badge-inline.is-unlinked { color: var(--pending); border: 1px solid rgba(245, 196, 81, 0.4); }
.badge-inline.is-linked { color: var(--claimed); border: 1px solid rgba(74, 222, 128, 0.35); }

.drop-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; }
.drop-row + .drop-row { border-top: 1px solid var(--border); }
.drop-row .drop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.drop-row .drop-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.drop-row .drop-head .name { font-weight: 600; }
.drop-row .drop-head .claimed-tag { color: var(--claimed); font-family: var(--font-mono); font-size: 11px; flex-shrink: 0; }
.drop-benefit-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  flex-shrink: 0;
  cursor: zoom-in;
}
.drop-benefit-icon:hover { border-color: var(--accent); }

.nav-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.nav-tabs a {
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
}
.nav-tabs a:hover { color: var(--text); }
.nav-tabs a.is-active { color: var(--accent); background: var(--accent-soft); border-color: rgba(169, 112, 255, 0.25); }

@media (max-width: 560px) {
  .account-card { flex-wrap: wrap; }
  .account-card .actions { width: 100%; justify-content: flex-start; }
}

/* -- modal --------------------------------------------------------------- */

.campaign-card { cursor: pointer; }
.benefit-chip { cursor: pointer; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 10, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 560px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }

.modal-art {
  width: 100%;
  aspect-ratio: 16 / 7;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.modal-item-art {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  margin-bottom: 14px;
  cursor: zoom-in;
}

.modal h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 20px; }
.modal .modal-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.modal .modal-section { margin-top: 18px; }
.modal .modal-section-title {
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

/* -- image lightbox ------------------------------------------------------- */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 10, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  z-index: 200;
  cursor: zoom-out;
}

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}