:root {
    --bg: #06060f;
    --surface: #0d0d1a;
    --surface2: #111122;
    --border: rgba(255,255,255,0.07);
    --accent: #00f5ff;
    --accent-dim: rgba(0,245,255,0.12);
    --accent-glow: rgba(0,245,255,0.25);
    --red: #ff2d55;
    --green: #00ff88;
    --gold: #ffd060;
    --text: #eef;
    --muted: #778;
    --font-mono: 'Share Tech Mono', monospace;
    --font-display: 'Orbitron', sans-serif;
  }

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

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* Scanlines */
  body::before {
    content: '';
    position: fixed; inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.04) 3px, rgba(0,0,0,0.04) 4px);
    pointer-events: none; z-index: 9999;
  }

  /* Grid noise bg */
  body::after {
    content: '';
    position: fixed; inset: 0;
    background-image:
      linear-gradient(rgba(0,245,255,0.015) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0,245,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none; z-index: 0;
  }

  /* ── CONFIG SCREEN ── */
  #config-screen {
    position: fixed; inset: 0;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 5000; flex-direction: column; gap: 0;
  }
  #config-screen.hidden { display: none; }

  .config-box {
    background: var(--surface);
    border: 1px solid var(--accent-glow);
    border-radius: 8px;
    padding: 40px 48px;
    max-width: 540px; width: 90%;
    box-shadow: 0 0 60px rgba(0,245,255,0.08);
  }

  .config-logo {
    font-family: var(--font-display);
    font-size: 22px; font-weight: 900;
    color: var(--accent);
    letter-spacing: 6px;
    text-align: center;
    margin-bottom: 8px;
    text-shadow: 0 0 30px var(--accent-glow);
  }

  .config-sub {
    font-size: 10px; color: var(--muted);
    letter-spacing: 3px; text-align: center;
    margin-bottom: 32px;
  }

  .config-section { margin-bottom: 24px; }

  .config-section h3 {
    font-size: 9px; color: var(--accent);
    letter-spacing: 3px; margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,245,255,0.15);
  }

  .config-row { display: flex; gap: 10px; align-items: flex-end; }
  .config-row .field { flex: 1; }

  .field label {
    display: block; font-size: 9px;
    color: var(--muted); letter-spacing: 2px;
    margin-bottom: 6px;
  }

  .field input, .field select {
    width: 100%; padding: 9px 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text); font-family: var(--font-mono);
    font-size: 11px; border-radius: 4px;
    outline: none; transition: border-color 0.2s;
  }

  .field input:focus, .field select:focus {
    border-color: rgba(0,245,255,0.4);
  }

  .field input::placeholder { color: var(--muted); }

  .btn {
    padding: 10px 20px;
    font-family: var(--font-mono); font-size: 10px;
    letter-spacing: 2px; border-radius: 4px;
    cursor: pointer; border: 1px solid;
    transition: all 0.15s;
  }
  .btn-primary {
    background: var(--accent-dim); border-color: var(--accent);
    color: var(--accent);
  }
  .btn-primary:hover { background: rgba(0,245,255,0.2); box-shadow: 0 0 12px var(--accent-glow); }
  .btn-ghost {
    background: transparent; border-color: rgba(255,255,255,0.12);
    color: var(--muted);
  }
  .btn-ghost:hover { border-color: rgba(255,255,255,0.3); color: var(--text); }
  .btn-danger {
    background: rgba(255,45,85,0.1); border-color: var(--red);
    color: var(--red);
  }
  .btn-danger:hover { background: rgba(255,45,85,0.2); }
  .btn-full { width: 100%; }
  .btn-sm { padding: 5px 10px; font-size: 9px; }

  .config-note {
    font-size: 9px; color: var(--muted);
    line-height: 1.7; margin-top: 8px;
  }

  .config-note a { color: var(--accent); text-decoration: none; }
  .config-note a:hover { text-decoration: underline; }

  .config-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; font-size: 9px; color: var(--muted); letter-spacing: 2px;
  }
  .config-divider::before, .config-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
  }

  .msg { font-size: 10px; padding: 8px 12px; border-radius: 4px; margin-top: 10px; letter-spacing: 1px; }
  .msg-error { background: rgba(255,45,85,0.1); border: 1px solid rgba(255,45,85,0.3); color: var(--red); }
  .msg-success { background: rgba(0,255,136,0.08); border: 1px solid rgba(0,255,136,0.3); color: var(--green); }

  /* ── APP SHELL ── */
  #app { display: none; flex-direction: column; height: 100vh; position: relative; z-index: 1; }
  #app.visible { display: flex; }

  /* Top bar */
  #topbar {
    height: 46px; display: flex; align-items: center;
    padding: 0 20px; gap: 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(6,6,15,0.9);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    position: relative; z-index: 100;
  }

  .topbar-logo {
    font-family: var(--font-display);
    font-size: 12px; font-weight: 900;
    color: var(--accent); letter-spacing: 4px;
    text-shadow: 0 0 20px var(--accent-glow);
    flex-shrink: 0;
  }

  .topbar-spacer { flex: 1; }

  .nav-tab {
    padding: 5px 12px; font-family: var(--font-mono);
    font-size: 9px; letter-spacing: 2px;
    background: transparent; border: none;
    color: var(--muted); cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
  }
  .nav-tab:hover { color: var(--text); }
  .nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  .topbar-user {
    font-size: 9px; color: var(--muted);
    letter-spacing: 2px;
  }

  .status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: blink 2.5s infinite;
  }

  @keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }
  @keyframes slideUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
  @keyframes fadeIn { from{opacity:0} to{opacity:1} }
  @keyframes slideInRight { from{opacity:0;transform:translateX(40px)} to{opacity:1;transform:translateX(0)} }

  /* ── AMBIENT BACKGROUND ─────────────────────── */
  #ambient-bg {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-size: cover; background-position: center;
    filter: blur(60px) saturate(1.4);
    opacity: 0; transition: opacity 1.2s ease, background-image 1s ease;
  }
  #ambient-bg { opacity: 0.07; }

  /* ── PLATFORM BADGE ──────────────────────────── */
  .platform-badge {
    font-size: 8px; letter-spacing: 1px; padding: 2px 7px;
    border-radius: 3px; border: 1px solid rgba(255,255,255,0.15);
    color: var(--muted); font-family: var(--font-mono);
    margin-left: 6px; vertical-align: middle;
  }

  /* ── GUIDE LINK ──────────────────────────────── */
  .guide-link {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 8px; letter-spacing: 1px; color: var(--accent);
    text-decoration: none; padding: 3px 8px;
    border: 1px solid rgba(0,245,255,0.2); border-radius: 3px;
    transition: all 0.15s;
  }
  .guide-link:hover { background: var(--accent-dim); }

  /* ── COVER CAROUSEL ─────────────────────────── */
  .cover-carousel { position: relative; }
  .cover-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.6); border: none; color: #fff;
    cursor: pointer; padding: 2px 5px; font-size: 10px; border-radius: 2px;
    opacity: 0; transition: opacity 0.2s; z-index: 2;
  }
  .cover-carousel:hover .cover-nav { opacity: 1; }
  .cover-nav.prev { left: 1px; }
  .cover-nav.next { right: 1px; }
  @keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }

  /* Layout */
  #layout { display: flex; flex: 1; overflow: hidden; }

  /* Sidebar */
  #sidebar {
    width: 230px; flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: rgba(13,13,26,0.7);
    display: flex; flex-direction: column;
    overflow: hidden;
  }

  .sidebar-header {
    padding: 14px 16px 10px;
    font-size: 8px; color: var(--muted);
    letter-spacing: 3px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
  }

  .game-list { flex: 1; overflow-y: auto; padding: 8px; }

  .game-item {
    padding: 10px 12px 10px 15px; /* left pad for status stripe */
    border-radius: 5px;
    cursor: pointer; margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.15s;
    position: relative;
    overflow: hidden; /* clip the stripe to rounded corners */
  }

  .game-item:hover { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.06); }
  .game-item.active {
    background: var(--accent-dim);
    border-color: rgba(0,245,255,0.25);
  }

  .game-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

  .game-cover {
    width: 32px; height: 42px; object-fit: cover;
    border-radius: 2px; flex-shrink: 0;
    background: rgba(255,255,255,0.05);
  }

  .game-cover-placeholder {
    width: 32px; height: 42px; border-radius: 2px;
    background: rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
  }

  .game-info { flex: 1; min-width: 0; }
  .game-title {
    font-size: 10px; font-weight: bold;
    letter-spacing: 0.5px; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 2px;
  }

  .game-item.active .game-title { color: var(--accent); }
  .game-count { font-size: 8px; color: #99a; letter-spacing: 1px; }

  .progress-bar {
    height: 2px; background: rgba(255,255,255,0.06);
    border-radius: 1px; overflow: hidden;
  }
  .progress-fill {
    height: 100%; background: var(--accent);
    border-radius: 1px; transition: width 0.5s ease;
  }
  .game-item.active .progress-fill { box-shadow: 0 0 6px var(--accent); }

  /* DLC sub-items */
  .dlc-list { padding-left: 12px; margin-top: 2px; }

  .dlc-item {
    padding: 7px 10px; border-radius: 4px;
    cursor: pointer; margin-bottom: 3px;
    border: 1px solid transparent;
    border-left: 2px solid rgba(255,208,96,0.3);
    transition: all 0.15s;
    display: flex; align-items: center; gap: 8px;
  }
  .dlc-item:hover { background: rgba(255,208,96,0.05); border-left-color: rgba(255,208,96,0.6); }
  .dlc-item.active {
    background: rgba(255,208,96,0.08);
    border-color: rgba(255,208,96,0.25);
    border-left-color: #ffd060;
  }
  .dlc-icon { font-size: 10px; color: #ffd060; flex-shrink: 0; }
  .dlc-title { font-size: 10px; color: #ccc; letter-spacing: 0.5px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dlc-item.active .dlc-title { color: #ffd060; }
  .dlc-count { font-size: 8px; color: var(--muted); }

  .game-item .expand-btn {
    font-size: 9px; color: var(--muted); background: none; border: none;
    cursor: pointer; padding: 0 4px; line-height: 1; flex-shrink: 0;
    transition: color 0.15s;
  }
  .game-item .expand-btn:hover { color: var(--text); }

  .add-dlc-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px; margin-bottom: 3px;
    font-size: 9px; color: var(--muted); letter-spacing: 1px;
    cursor: pointer; border-radius: 3px;
    border: 1px dashed rgba(255,208,96,0.15);
    background: transparent; font-family: var(--font-mono);
    transition: all 0.15s; width: 100%;
  }
  .add-dlc-btn:hover { border-color: rgba(255,208,96,0.4); color: #ffd060; }

  .sidebar-footer { padding: 10px 8px; border-top: 1px solid var(--border); }

  /* Main */
  #main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

  /* Game header */
  #game-header {
    padding: 20px 28px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(0,245,255,0.03) 0%, transparent 60%);
  }

  .game-header-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }

  .game-header-left { display: flex; align-items: flex-start; gap: 16px; }

  .game-cover-large {
    width: 60px; height: 80px; object-fit: cover;
    border-radius: 4px; flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  }

  .game-cover-large-placeholder {
    width: 60px; height: 80px; border-radius: 4px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; flex-shrink: 0;
  }

  .game-meta-block { padding-top: 4px; }
  .game-op-label { font-size: 8px; color: var(--muted); letter-spacing: 3px; margin-bottom: 6px; }

  .game-name {
    font-family: var(--font-display);
    font-size: 18px; font-weight: 900;
    color: var(--accent); letter-spacing: 2px;
    text-shadow: 0 0 20px var(--accent-glow);
    line-height: 1.1; margin-bottom: 4px;
  }

  .game-release { font-size: 9px; color: var(--muted); letter-spacing: 2px; }

  /* Stats row */
  .stats-row { display: flex; gap: 24px; align-items: center; }

  .stat-item { text-align: center; }
  .stat-value { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
  .stat-label { font-size: 7px; color: var(--muted); letter-spacing: 2px; margin-top: 2px; }

  /* Ring */
  .ring-wrap { position: relative; width: 72px; height: 72px; }
  .ring-text {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
  }
  .ring-pct { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: var(--accent); }
  .ring-sub { font-size: 7px; color: var(--muted); letter-spacing: 1px; }

  /* Toolbar */
  #toolbar {
    padding: 10px 28px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
    background: rgba(6,6,15,0.5);
    flex-wrap: wrap;
  }

  .filter-btn {
    padding: 4px 10px; font-family: var(--font-mono);
    font-size: 9px; letter-spacing: 2px;
    border-radius: 3px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent; color: var(--muted);
    transition: all 0.15s;
  }
  .filter-btn:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }
  .filter-btn.active {
    background: var(--accent-dim); border-color: rgba(0,245,255,0.35);
    color: var(--accent);
  }

  .search-input {
    padding: 5px 12px; background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text); font-family: var(--font-mono);
    font-size: 10px; letter-spacing: 1px;
    border-radius: 3px; outline: none;
    width: 180px; transition: border-color 0.2s;
  }
  .search-input:focus { border-color: rgba(0,245,255,0.3); }
  .search-input::placeholder { color: var(--muted); }

  /* Mission list */
  #mission-list {
    flex: 1; overflow-y: auto;
    padding: 16px 28px;
  }

  .empty-state {
    text-align: center; color: var(--muted);
    font-size: 10px; letter-spacing: 3px;
    margin-top: 60px;
  }

  .mission-card {
    margin-bottom: 8px; padding: 14px 18px;
    border-radius: 5px; display: flex;
    align-items: center; gap: 14px;
    border: 1px solid; transition: all 0.2s;
    animation: slideUp 0.3s ease both;
    cursor: default;
  }

  .mission-card:hover { filter: brightness(1.08); }

  .mission-card.status-active {
    background: rgba(0,255,136,0.05);
    border-color: rgba(0,255,136,0.2);
  }
  .mission-card.status-completed {
    background: rgba(136,136,136,0.04);
    border-color: rgba(136,136,136,0.12);
    opacity: 0.65;
  }
  .mission-card.status-locked {
    background: rgba(255,208,96,0.04);
    border-color: rgba(255,208,96,0.15);
  }
  .mission-card.status-failed {
    background: rgba(255,45,85,0.05);
    border-color: rgba(255,45,85,0.2);
  }

  .mission-num {
    font-family: var(--font-display);
    font-size: 11px; font-weight: 700;
    color: var(--muted); flex-shrink: 0;
    width: 28px; text-align: right;
    padding-right: 4px; letter-spacing: 0;
    user-select: none;
  }
  .mission-card.status-active .mission-num { color: #667; }
  .mission-card.status-completed .mission-num { color: #445; }

  .drag-handle {
    font-size: 12px; color: rgba(255,255,255,0.15);
    cursor: grab; flex-shrink: 0;
    padding: 0 4px; user-select: none;
    transition: color 0.15s;
  }
  .drag-handle:hover { color: rgba(255,255,255,0.4); }
  .mission-card.dragging {
    opacity: 0.4; border-style: dashed;
  }
  .mission-card.drag-over {
    border-top: 2px solid var(--accent) !important;
    background: rgba(0,245,255,0.03) !important;
  }
  .mission-card { transition: opacity 0.15s, box-shadow 0.3s; }
  /* Avatar placeholder — shown when no image */
  #account-avatar-preview:empty::after,
  #topbar-avatar:empty::after {
    content: '';
    display: block;
    width: 100%; height: 100%;
    background: var(--accent-dim);
    border-radius: 50%;
  }
  #account-avatar-preview:not(:has(img)):not(:empty) { display: flex; align-items: center; justify-content: center; }

  .game-cover-placeholder:empty,
  .game-cover-large-placeholder:empty {
    background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.06) 100%);
    display: flex; align-items: center; justify-content: center;
  }
  .game-cover-placeholder:empty::after {
    content: '◈';
    font-family: var(--font-display);
    font-size: 12px;
    color: rgba(255,255,255,0.15);
  }
  .game-cover-large-placeholder:empty::after {
    content: '◈';
    font-family: var(--font-display);
    font-size: 28px;
    color: rgba(255,255,255,0.12);
  }

  .mission-type-icon { font-size: 14px; flex-shrink: 0; width: 16px; text-align: center; }

  .mission-body { flex: 1; min-width: 0; }

  .mission-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }

  .mission-name {
    font-size: 12px; font-weight: bold;
    letter-spacing: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .mission-card.status-completed .mission-name {
    text-decoration: line-through; color: var(--muted);
  }

  .priority-dot { font-size: 12px; flex-shrink: 0; }

  .mission-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

  .badge {
    font-size: 8px; letter-spacing: 2px;
    padding: 2px 7px; border-radius: 2px;
    border: 1px solid; flex-shrink: 0;
  }
  .badge-active { color: var(--green); border-color: rgba(0,255,136,0.3); background: rgba(0,255,136,0.07); }
  .badge-completed { color: #aaa; border-color: rgba(136,136,136,0.2); background: rgba(136,136,136,0.06); }
  .badge-locked { color: var(--gold); border-color: rgba(255,208,96,0.25); background: rgba(255,208,96,0.06); }
  .badge-failed { color: var(--red); border-color: rgba(255,45,85,0.3); background: rgba(255,45,85,0.07); }
  .badge-type { color: #99a; border-color: rgba(255,255,255,0.08); background: transparent; }

  .mission-date {
    font-size: 8px; color: #99a;
    letter-spacing: 1px; white-space: nowrap;
  }

  .mission-date span { color: rgba(0,245,255,0.5); }

  .mission-notes {
    font-size: 9px; color: #aab;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 220px;
    letter-spacing: 0.5px;
  }

  .mission-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

  .action-btn {
    padding: 3px 8px; font-family: var(--font-mono);
    font-size: 8px; letter-spacing: 1px;
    border-radius: 2px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent; color: var(--muted);
    transition: all 0.15s;
  }
  .action-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }
  .action-btn.active-status { color: var(--green); border-color: rgba(0,255,136,0.3); }
  .action-btn.del { color: rgba(255,80,100,0.7); letter-spacing: 1.5px; }
  .action-btn.del:hover { color: var(--red); border-color: rgba(255,45,85,0.4); background: rgba(255,45,85,0.06); }

  /* ── MODAL ── */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; animation: fadeIn 0.15s ease;
  }
  .modal-overlay.hidden { display: none; }

  .modal {
    background: var(--surface);
    border: 1px solid rgba(0,245,255,0.2);
    border-radius: 6px; padding: 28px 32px;
    min-width: 420px; max-width: 560px; width: 90%;
    box-shadow: 0 0 60px rgba(0,245,255,0.08);
    max-height: 85vh; overflow-y: auto;
  }

  .modal-header {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 22px;
  }

  .modal-title {
    font-family: var(--font-display);
    font-size: 11px; letter-spacing: 4px;
    color: var(--accent);
  }

  .modal-close {
    background: none; border: none;
    color: var(--muted); cursor: pointer;
    font-size: 16px; line-height: 1;
    transition: color 0.15s;
  }
  .modal-close:hover { color: var(--red); }

  .form-row { display: flex; gap: 12px; }
  .form-row .field { flex: 1; }

  .field { margin-bottom: 16px; }

  .modal-actions { display: flex; gap: 8px; margin-top: 20px; }

  /* IGDB search results */
  .igdb-results { margin-top: 10px; max-height: 280px; overflow-y: auto; }

  .igdb-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: 4px;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s; margin-bottom: 4px;
  }
  .igdb-item:hover {
    background: var(--accent-dim);
    border-color: rgba(0,245,255,0.2);
  }

  .igdb-thumb {
    width: 36px; height: 48px; object-fit: cover;
    border-radius: 2px; flex-shrink: 0;
    background: rgba(255,255,255,0.05);
  }

  .igdb-info { flex: 1; min-width: 0; }
  .igdb-name { font-size: 11px; color: var(--text); letter-spacing: 0.5px; margin-bottom: 3px; }
  .igdb-year { font-size: 9px; color: var(--muted); letter-spacing: 1px; }

  .igdb-select-btn {
    font-size: 8px; padding: 4px 10px;
    background: var(--accent-dim); border: 1px solid rgba(0,245,255,0.3);
    color: var(--accent); border-radius: 3px; cursor: pointer;
    font-family: var(--font-mono); letter-spacing: 1px;
    transition: all 0.15s; flex-shrink: 0;
  }
  .igdb-select-btn:hover { background: rgba(0,245,255,0.2); }

  .loading {
    font-size: 9px; color: var(--muted);
    letter-spacing: 3px; text-align: center;
    padding: 20px 0;
  }

  .loading::after {
    content: ''; display: inline-block;
    width: 12px; animation: dots 1.2s infinite;
  }
  @keyframes dots { 0%{content:'.'} 33%{content:'..'} 66%{content:'...'} 100%{content:'.'} }

  /* Scrollbars */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

  select option { background: #0d0d1a; color: var(--text); }

  /* No game selected */
  #no-game {
    flex: 1; display: flex; align-items: center;
    justify-content: center; flex-direction: column;
    gap: 12px; color: var(--muted);
    font-size: 10px; letter-spacing: 3px;
  }

  #no-game .icon { font-size: 36px; opacity: 0.3; margin-bottom: 8px; font-family: var(--font-display); color: var(--accent); }

  /* Auth tabs */
  .auth-tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
  .auth-tab {
    padding: 8px 20px; font-family: var(--font-mono);
    font-size: 9px; letter-spacing: 2px;
    cursor: pointer; border: none; background: none;
    color: var(--muted); border-bottom: 2px solid transparent;
    transition: all 0.15s; margin-bottom: -1px;
  }
  .auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  #login-panel, #signup-panel { animation: fadeIn 0.2s ease; }

  .spinner {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid rgba(0,245,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.7s linear infinite;
    margin-right: 6px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .igdb-config-note {
    font-size: 9px; color: var(--muted); line-height: 1.7;
    padding: 10px 12px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--border); border-radius: 4px;
    margin-top: 8px;
  }
  .igdb-config-note a { color: var(--accent); text-decoration: none; }

  /* ── MOBILE ──────────────────────────────────── */
  @media (max-width: 700px) {

    /* Topbar */
    #topbar {
      padding: 0 10px;
      height: 48px;
      gap: 6px;
    }
    .topbar-logo { font-size: 10px; letter-spacing: 2px; }
    .nav-tab { padding: 4px 8px; font-size: 8px; letter-spacing: 1px; }
    #topbar-user { font-size: 9px !important; }
    .status-dot { display: none; }
    .btn-ghost.btn-sm { font-size: 8px; padding: 4px 8px; }

    /* Layout: stack sidebar above content on mobile */
    #layout {
      flex-direction: column;
      overflow: hidden;
    }

    /* Sidebar becomes a horizontal scrollable strip at the top */
    #sidebar {
      width: 100% !important;
      height: auto;
      border-right: none;
      border-bottom: 1px solid var(--border);
      flex-direction: row;
      overflow-x: auto;
      overflow-y: hidden;
      flex-shrink: 0;
    }
    .sidebar-header {
      display: none; /* hidden on mobile — space is precious */
    }
    #game-list {
      display: flex;
      flex-direction: row;
      gap: 6px;
      padding: 8px 10px;
      overflow-x: auto;
      white-space: nowrap;
      flex: 1;
      -webkit-overflow-scrolling: touch;
    }
    .game-item {
      flex-direction: row;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      border-radius: 20px;
      min-width: auto;
      white-space: nowrap;
      border: 1px solid var(--border);
    }
    .game-thumb { width: 20px; height: 28px; }
    .game-title { font-size: 9px; max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .game-progress-bar { display: none; }
    .game-count { display: none; }
    .game-expand-area { display: none; } /* hide DLC toggle on mobile sidebar */
    .sidebar-footer { display: none; }

    /* Sidebar search on mobile */
    #sidebar > div[style*="border-bottom"] {
      display: none; /* hide sidebar search on mobile; use toolbar search instead */
    }

    /* Game header */
    #game-header {
      padding: 12px 14px 10px;
      flex-wrap: wrap;
      gap: 10px;
    }
    .game-cover-large { width: 48px; height: 64px; }
    .game-cover-large-placeholder { width: 48px; height: 64px; font-size: 24px; }
    #header-title { font-size: 14px; }
    .game-stats { gap: 10px; }
    .stat-value { font-size: 16px; }
    .completion-ring { width: 54px; height: 54px; }
    .ring-pct { font-size: 11px; }

    /* Game op buttons */
    .game-op-btn { padding: 4px 8px; font-size: 7px; }

    /* Toolbar */
    #toolbar {
      padding: 8px 12px;
      gap: 6px;
      flex-wrap: wrap;
    }
    .filter-btn { padding: 4px 8px; font-size: 8px; letter-spacing: 1px; }
    .search-input { font-size: 10px; min-width: 0; flex: 1; }

    /* Mission list */
    #mission-list { padding: 10px 12px; gap: 8px; }

    /* Mission cards — stack vertically */
    .mission-card {
      flex-wrap: wrap;
      padding: 10px 12px;
      gap: 6px;
    }
    .mission-num { width: 20px; font-size: 9px; }
    .drag-handle { display: none; } /* drag not practical on mobile */
    .mission-type-icon { font-size: 12px; width: 14px; }
    .mission-name { font-size: 11px; }
    .mission-body { min-width: 0; flex: 1; }
    .mission-meta { flex-wrap: wrap; gap: 4px; }
    .badge { font-size: 7px; padding: 2px 5px; }
    .mission-date { font-size: 7px; }
    .mission-notes { font-size: 8px; max-width: 100%; }

    /* Action buttons — full width row at bottom of card */
    .mission-actions {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      justify-content: flex-start;
      border-top: 1px solid rgba(255,255,255,0.05);
      padding-top: 8px;
      margin-top: 2px;
    }
    .action-btn { font-size: 8px; padding: 4px 8px; }

    /* Modals — full screen on mobile */
    .modal {
      width: 100vw !important;
      max-width: 100vw !important;
      min-width: 0 !important;
      border-radius: 12px 12px 0 0;
      max-height: 90vh;
      overflow-y: auto;
      margin-bottom: 0;
    }
    .modal-overlay {
      align-items: flex-end !important;
      padding: 0 !important;
    }
    .form-row { flex-direction: column; gap: 0; }

    /* Account panel — full screen slide-in */
    #account-page > div {
      width: 100vw !important;
      height: 100vh;
      border-left: none !important;
    }

    /* Stats page */
    #stats-page { padding: 20px 14px; }
    #account-page { padding: 0; }

    /* IGDB results on mobile */
    .igdb-results { max-height: 180px; }

    /* Import preview */
    #import-preview-list { max-height: 160px; }
  }

  /* Touch-friendly tap targets */
  @media (hover: none) {
    .action-btn { min-height: 32px; min-width: 44px; }
    .filter-btn { min-height: 32px; }
    .btn { min-height: 38px; }
    .game-item { min-height: 44px; }
  }

/* ════════════════════════════════════════════════════════
   STATS PAGE
   ════════════════════════════════════════════════════════ */

#stats-page {
  display: flex;
  flex-direction: column;
  gap: 0;
}

#stats-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Page title ──────────────────────────────────────── */
.stats-page-title {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 5px;
  color: var(--accent);
  margin-bottom: 4px;
  text-shadow: 0 0 20px var(--accent-glow);
}

/* ── Hero numbers ────────────────────────────────────── */
.stats-hero {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}

.stats-hero-item {
  padding: 20px 16px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
  cursor: default;
}

.stats-hero-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-dim) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.stats-hero-item:hover { border-color: var(--accent-glow); transform: translateY(-1px); }
.stats-hero-item:hover::before { opacity: 1; }

.stats-hero-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
  text-shadow: 0 0 20px var(--accent-glow);
  letter-spacing: -1px;
}

.stats-hero-label {
  font-size: 8px;
  letter-spacing: 3px;
  color: var(--text);
  margin-bottom: 2px;
}

.stats-hero-sub {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 1px;
}

/* ── Generic card ────────────────────────────────────── */
.stats-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.stats-card-label {
  font-size: 8px;
  letter-spacing: 4px;
  color: var(--accent);
  margin-bottom: 18px;
  opacity: 0.8;
}

.stats-full { width: 100%; }

.stats-empty {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 2px;
  text-align: center;
  padding: 28px 0;
}

/* ── Two-column layout ───────────────────────────────── */
.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  align-items: start;
}

/* ── Game breakdown rows ─────────────────────────────── */
.stats-game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 4px;
  margin: 0 -6px;
  padding-left: 6px;
  padding-right: 6px;
}

.stats-game-row:last-child { border-bottom: none; }
.stats-game-row:hover { background: rgba(255,255,255,0.03); }

.stats-game-cover {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
}

.stats-cover-placeholder {
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-cover-placeholder::after {
  content: '◈';
  font-family: var(--font-display);
  font-size: 10px;
  color: rgba(255,255,255,0.15);
}

.stats-game-title {
  font-size: 10px;
  color: var(--text);
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.stats-bar-bg {
  height: 4px;
  background: rgba(255,255,255,0.07);
  border-radius: 2px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
  min-width: 2px;
}

.stats-micro {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

/* ── Highlight rows ──────────────────────────────────── */
.stats-highlight-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.stats-highlight-row:last-child { border-bottom: none; }

.stats-highlight-label {
  font-size: 7px;
  letter-spacing: 2px;
  color: var(--muted);
}

.stats-highlight-val {
  font-size: 10px;
  color: var(--text);
  letter-spacing: 0.3px;
}

/* ── Activity feed items ─────────────────────────────── */
.stats-activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  transition: background 0.15s;
}

.stats-activity-item:hover { background: rgba(255,255,255,0.04); }

/* ── Yearly bars ─────────────────────────────────────── */
.stats-year-bars {
  display: flex;
  gap: 0;
  min-width: max-content;
  align-items: flex-end;
  padding-bottom: 36px;
  position: relative;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.stats-year-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 72px;
}

.stats-year-bar-wrap {
  position: relative;
  width: 36px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.stats-year-bar-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--accent);
  opacity: 0.85;
  border-radius: 3px 3px 0 0;
  transition: height 0.7s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 12px var(--accent-glow);
}

.stats-year-bar-fail {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: var(--red);
  opacity: 0.45;
  border-radius: 3px 3px 0 0;
  transition: height 0.7s cubic-bezier(0.4,0,0.2,1);
}

.stats-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.stats-activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.stats-year-label-above {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stats-year-x-label {
  position: absolute;
  bottom: 10px;
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 2px;
  transform: rotate(-45deg);
  transform-origin: top left;
  white-space: nowrap;
}

.stats-year-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stats-year-card {
  min-width: 130px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}

.stats-year-card:hover {
  border-color: var(--accent-glow);
  background: rgba(255,255,255,0.04);
}

.stats-year-card-year {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  line-height: 1;
}

/* ── Responsive ──────────────────────────────────────── */

/* Large desktop — hero fits 5 across */
@media (min-width: 1400px) {
  #stats-page { padding: 40px 52px; }
  .stats-two-col { grid-template-columns: 1fr 420px; }
  .stats-activity-grid { grid-template-columns: repeat(3, 1fr); }
  .stats-year-cards { gap: 16px; }
  .stats-year-card { min-width: 150px; }
}

/* Standard desktop */
@media (min-width: 900px) and (max-width: 1399px) {
  .stats-two-col { grid-template-columns: 1fr 360px; }
  .stats-activity-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet — collapse two-col, hero to 3 */
@media (max-width: 900px) {
  .stats-hero { grid-template-columns: repeat(3, 1fr); }
  .stats-two-col { grid-template-columns: 1fr; }
  .stats-right-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  /* Highlights spans full width in tablet grid */
  .stats-right-col > .stats-card:last-child { grid-column: 1 / -1; }
  .stats-year-bars { justify-content: flex-start; }
  .stats-activity-grid { grid-template-columns: 1fr 1fr; }
}

/* Mobile — single column everything */
@media (max-width: 600px) {
  #stats-page { padding: 20px 14px; }
  .stats-hero {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .stats-hero-item { padding: 14px 12px 12px; }
  .stats-hero-value { font-size: 22px; }
  .stats-two-col { grid-template-columns: 1fr; }
  .stats-right-col { display: flex; flex-direction: column; gap: 12px; }
  .stats-activity-grid { grid-template-columns: 1fr; }
  .stats-year-cards { gap: 10px; }
  .stats-year-card { min-width: 110px; flex: 1; }
  .stats-heatmap-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stats-card { padding: 16px 14px; }
  .stats-card-label { margin-bottom: 14px; }
  /* On mobile the bar chart scrolls horizontally */
  .stats-year-barchart { overflow-x: auto; }
}

/* Year cards are clickable */
.stats-year-card {
  cursor: pointer;
}
.stats-year-card:hover {
  border-color: var(--accent-glow);
  background: rgba(255,255,255,0.04);
  transform: translateY(-1px);
  transition: all 0.15s;
}

/* ════════════════════════════════════════════════════════
   NEW FEATURES — GAME STATUS, DIFFICULTY, SIDEBAR TABS
   ════════════════════════════════════════════════════════ */

/* ── Game status stripe — left edge of sidebar item ─── */
/* Cyan = Playing · dim = Backlog · Gold = Paused · Green = Completed · Red = Abandoned */
.game-status-stripe {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px 0 0 2px;
  transition: background 0.3s ease;
  pointer-events: none;
}

/* ── Difficulty badge on mission cards ───────────────── */
.badge-diff {
  font-size: 8px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  padding: 1px 5px;
  border: 1px solid;
  border-radius: 2px;
  opacity: 0.9;
}