  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;700&display=swap');

  :root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --accent-orange: #f97316;
    --accent-purple: #a855f7;
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-pink: #ec4899;
    --accent-cyan: #06b6d4;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dim: #475569;
    --border: #1e293b;
    --border-subtle: #161625;
    --ny-color: #3b82f6;
    --xyne-color: #a855f7;
    --nc-color: #22c55e;
    --hs-color: #f59e0b;
    --jp-color: #e11d48;
    --gold: #fbbf24;
    --silver: #94a3b8;
    --bronze-color: #cd7f32;
  }

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

  html { overflow-x: hidden; }

  body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    -webkit-font-smoothing: antialiased;
  }

  body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
      radial-gradient(ellipse at 20% 50%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
      radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
      radial-gradient(ellipse at 50% 80%, rgba(34, 197, 94, 0.04) 0%, transparent 50%);
    z-index: 0;
    animation: bgPulse 10s ease-in-out infinite alternate;
  }

  @keyframes bgPulse { 0% { opacity: 0.5; } 100% { opacity: 1; } }

  .container { position: relative; z-index: 1; max-width: 1300px; margin: 0 auto; padding: 24px 20px; }

  /* Header */
  .header { text-align: center; padding: 40px 0 24px; }
  .header h1 {
    font-size: 2.4rem; font-weight: 900;
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-purple), var(--accent-blue));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px; margin-bottom: 8px;
  }
  .header .subtitle { color: var(--text-secondary); font-size: 0.95rem; font-weight: 400; }

  .live-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444; padding: 4px 14px; border-radius: 20px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 12px;
  }
  .live-dot {
    width: 6px; height: 6px; background: #ef4444; border-radius: 50%;
    animation: livePulse 1.5s ease-in-out infinite;
  }
  @keyframes livePulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.3; transform: scale(0.7); } }

  /* Utilisation Gauge */
  .utilisation-gauge {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    padding: 20px 28px 16px; margin: 16px 0 20px; text-align: center;
  }
  .gauge-amounts { font-size: 1.4rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
  .gauge-utilised { color: #2DC653; }
  .gauge-sep { color: rgba(255,255,255,0.3); margin: 0 4px; }
  .gauge-budget { color: var(--accent-orange); }
  .gauge-label { font-size: 0.65rem; font-weight: 600; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 2px; margin-left: 10px; vertical-align: middle; }
  .gauge-amounts-usd { font-size: 0.75rem; color: rgba(255,255,255,0.35); margin-top: 2px; font-family: 'JetBrains Mono', monospace; }
  .gauge-bar-wrap { display: flex; align-items: center; gap: 12px; margin: 12px 0 8px; }
  .gauge-bar-track { flex: 1; height: 18px; background: rgba(255,255,255,0.06); border-radius: 9px; overflow: visible; position: relative; }
  .gauge-bar-fill { height: 100%; border-radius: 9px; transition: width 0.8s ease, background 0.5s ease; min-width: 2px; position: relative; z-index: 1; }
  .gauge-bar-possible { position:absolute; top:0; left:0; height:100%; border-radius:9px; background:rgba(255,255,255,0.06); z-index:0; transition: width 0.8s; }
  .gauge-bar-marker { position: absolute; top: -3px; bottom: -3px; width: 2px; background: rgba(255,255,255,0.3); border-radius: 1px; }
  .gauge-pct { font-size: 1.1rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; min-width: 48px; }
  .gauge-sub { font-size: 0.72rem; color: rgba(255,255,255,0.45); display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
  .gauge-dot { opacity: 0.3; }
  .gauge-beyond { color: rgba(168,85,247,0.6); cursor: help; font-style: italic; }

  /* Stats (legacy) */
  .stats-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 24px 0; }
  .stat-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
    padding: 20px; text-align: center; transition: all 0.3s;
  }
  .stat-card:hover { border-color: rgba(168, 85, 247, 0.3); transform: translateY(-2px); }
  .stat-value { font-size: 1.6rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
  .stat-label { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 6px; font-weight: 500; }
  .stat-value.orange { color: var(--accent-orange); }
  .stat-value.purple { color: var(--accent-purple); }
  .stat-value.blue { color: var(--accent-blue); }
  .stat-value.green { color: var(--accent-green); }

  /* Team Battle */
  /* Leaderboard Section at Top */
  .leaderboard-section { margin: 20px 0; }
  .lb-dual {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  }
  .lb-section { margin-bottom: 24px; }
  .lb-section-title {
    font-size: 0.75rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
  }
  .lb-section-title::before {
    content: ''; flex: 1; height: 1px; background: var(--border);
  }
  .lb-section-title::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
  }

  /* Team Battle Mini (compact for top) */
  .team-battle-mini {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 16px; margin-bottom: 16px;
  }
  .team-mini-row {
    display: flex; justify-content: space-around; gap: 8px;
  }
  .team-mini-ny, .team-mini-nc, .team-mini-xyne, .team-mini-hs, .team-mini-jp {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    flex: 1; padding: 6px 4px; border-radius: 8px;
    background: var(--bg-secondary);
  }
  .team-mini-name {
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  }
  .team-mini-ny .team-mini-name { color: var(--ny-color); }
  .team-mini-nc .team-mini-name { color: var(--nc-color); }
  .team-mini-xyne .team-mini-name { color: var(--xyne-color); }
  .team-mini-hs .team-mini-name { color: var(--hs-color); }
  .team-mini-jp .team-mini-name { color: var(--jp-color); }
  .team-mini-pct {
    font-size: 0.9rem; font-weight: 800; font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
  }

  .team-battle {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px; margin: 20px 0; position: relative; overflow: hidden;
  }
  .team-battle::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--ny-color), var(--nc-color), var(--xyne-color), var(--hs-color), var(--jp-color)); }
  .team-battle h2 { text-align: center; font-size: 0.8rem; font-weight: 700; margin-bottom: 20px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 3px; }
  .team-vs { display: flex; align-items: center; justify-content: center; gap: 20px; }
  .team-side { flex: 1; text-align: center; }
  .team-name { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; letter-spacing: 1px; }
  .team-name.ny { color: var(--ny-color); }
  .team-name.xyne { color: var(--xyne-color); }
  .team-name.nc { color: var(--nc-color); }
  .team-name.hs { color: var(--hs-color); }
  .team-name.jp { color: var(--jp-color); }
  .team-pct { font-size: 2rem; font-weight: 900; font-family: 'JetBrains Mono', monospace; }
  .team-details { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }
  .team-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; }
  .team-bar-row { display: flex; align-items: center; gap: 10px; }
  .team-bar-label { font-size: 0.65rem; font-weight: 700; min-width: 40px; width: 40px; text-align: right; letter-spacing: 0.5px; }
  .team-bar-track { flex: 1; height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
  .team-bar-fill { height: 100%; border-radius: 3px; transition: width 1s ease; }
  .team-bar-fill.ny { background: linear-gradient(90deg, var(--ny-color), #60a5fa); }
  .team-bar-fill.xyne { background: linear-gradient(90deg, #c084fc, var(--xyne-color)); }
  .team-bar-fill.nc { background: linear-gradient(90deg, var(--nc-color), #4ade80); }
  .team-bar-fill.hs { background: linear-gradient(90deg, var(--hs-color), #fbbf24); }
  .team-bar-fill.jp { background: linear-gradient(90deg, var(--jp-color), #fb7185); }
  .team-bar-value { font-size: 0.7rem; font-family: 'JetBrains Mono', monospace; color: var(--text-dim); width: 40px; }

  /* Setup Section */
  .setup-section {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px;
    margin: 20px 0; overflow: hidden;
  }
  .setup-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; cursor: pointer; user-select: none; transition: background 0.2s;
  }
  .setup-header:hover { background: var(--bg-card-hover); }
  .setup-header h3 { font-size: 0.9rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
  .setup-header .badge {
    font-size: 0.6rem; font-weight: 700; padding: 3px 8px; border-radius: 4px;
    background: rgba(34, 197, 94, 0.15); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.3);
    text-transform: uppercase; letter-spacing: 1px;
  }
  .setup-chevron { color: var(--text-dim); transition: transform 0.3s; font-size: 0.8rem; }
  .setup-section.open .setup-chevron { transform: rotate(180deg); }
  .setup-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
  .setup-section.open .setup-body { max-height: 600px; }
  .setup-body-inner { padding: 0 24px 24px; }
  .setup-method {
    padding: 16px; border-radius: 10px; border: 1px solid var(--border-subtle);
    background: var(--bg-secondary); margin-bottom: 12px;
  }
  .setup-method:last-child { margin-bottom: 0; }
  .setup-method h4 { font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
  .setup-method h4 .tag {
    font-size: 0.55rem; font-weight: 700; padding: 2px 6px; border-radius: 3px;
    background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); text-transform: uppercase; letter-spacing: 0.5px;
  }
  .setup-method p { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.7; }
  .setup-method ol { font-size: 0.78rem; color: var(--text-secondary); line-height: 2; padding-left: 20px; margin-top: 8px; }
  .setup-method ol code {
    background: var(--bg-primary); padding: 2px 6px; border-radius: 4px;
    font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  }
  .setup-method .download-btn {
    display: inline-block; padding: 8px 18px; margin-top: 10px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white; font-size: 0.78rem; font-weight: 700; border-radius: 8px;
    text-decoration: none; transition: all 0.2s;
  }
  .setup-method .download-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3); }
  .setup-method .bookmarklet-link {
    display: inline-block; padding: 6px 14px; margin-top: 8px;
    background: var(--bg-primary); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.75rem; font-weight: 600; border-radius: 6px;
    text-decoration: none; cursor: grab;
  }
  .setup-note {
    display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 14px;
    background: rgba(251, 191, 36, 0.06); border: 1px solid rgba(251, 191, 36, 0.15);
    border-radius: 8px; font-size: 0.72rem; color: var(--text-secondary); line-height: 1.5;
  }
  .setup-note .note-icon { flex-shrink: 0; font-size: 0.85rem; }

  /* Actions */
  .actions { display: flex; gap: 8px; margin: 24px 0 16px; flex-wrap: wrap; align-items: center; }
  .btn {
    padding: 9px 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card);
    color: var(--text-primary); font-family: 'Inter', sans-serif; font-size: 0.8rem;
    font-weight: 600; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
    white-space: nowrap;
  }
  .btn:hover { transform: translateY(-1px); border-color: var(--accent-purple); }
  .btn.primary { background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue)); border: none; }
  .btn.primary:hover { box-shadow: 0 4px 20px rgba(168, 85, 247, 0.3); }
  .btn.danger { border-color: rgba(239, 68, 68, 0.2); color: rgba(239, 68, 68, 0.7); font-size: 0.75rem; }
  .btn.danger:hover { background: rgba(239, 68, 68, 0.1); }
  .btn.secondary { background: transparent; color: var(--text-secondary); font-size: 0.75rem; }

  /* Tabs */
  .board-tabs {
    display: flex; gap: 0; margin: 20px 0 8px; justify-content: center;
  }
  .board-tab {
    padding: 10px 28px; border: 1px solid var(--border); background: var(--bg-secondary);
    color: var(--text-secondary); font-family: 'Inter', sans-serif; font-size: 0.8rem;
    font-weight: 700; cursor: pointer; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px;
  }
  .board-tab:first-child { border-radius: 10px 0 0 10px; }
  .board-tab:last-child { border-radius: 0 10px 10px 0; }
  .board-tab.active {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border-color: var(--accent-purple); color: white;
  }
  .board-tab:hover:not(.active) { border-color: var(--accent-purple); color: var(--text-primary); }

  .tabs {
    display: flex; gap: 2px; margin: 8px 0 16px; background: var(--bg-secondary);
    padding: 3px; border-radius: 10px; border: 1px solid var(--border);
  }
  .tab {
    flex: 1; padding: 8px 14px; border: none; background: transparent; color: var(--text-dim);
    font-family: 'Inter', sans-serif; font-size: 0.78rem; font-weight: 600; cursor: pointer;
    border-radius: 7px; transition: all 0.2s;
  }
  .tab:hover { color: var(--text-secondary); }
  .tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

  /* Main Tabs */
  .main-tabs {
    display: flex; gap: 2px; margin: 0 0 20px; background: var(--bg-secondary);
    padding: 3px; border-radius: 12px; border: 1px solid var(--border);
  }
  .main-tab {
    flex: 1; padding: 10px 18px; border: none; background: transparent; color: var(--text-dim);
    font-family: 'Inter', sans-serif; font-size: 0.85rem; font-weight: 700; cursor: pointer;
    border-radius: 9px; transition: all 0.2s; text-transform: uppercase; letter-spacing: 1px;
  }
  .main-tab:hover { color: var(--text-secondary); }
  .main-tab.active { background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue)); color: white; box-shadow: 0 2px 12px rgba(168, 85, 247, 0.3); }

  /* Leaderboard */
  .leaderboard { display: flex; flex-direction: column; gap: 6px; }
  .lb-row {
    display: grid; grid-template-columns: 32px 1fr 60px 60px;
    align-items: center; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 14px; transition: all 0.3s; cursor: pointer;
    animation: slideIn 0.4s ease backwards; gap: 6px;
  }
  .lb-row .lb-plans { display: none; }
  .lb-row .lb-usage-bar { display: none; }
  .lb-row:hover { border-color: rgba(168, 85, 247, 0.3); background: var(--bg-card-hover); }
  @keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  .lb-row.rank-1 { border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.04); }
  .lb-row.rank-2 { border-color: rgba(148, 163, 184, 0.2); background: rgba(148, 163, 184, 0.02); }
  .lb-row.rank-3 { border-color: rgba(205, 127, 50, 0.2); background: rgba(205, 127, 50, 0.02); }

  .lb-position { font-size: 1.1rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
  .lb-position.p1 { color: var(--gold); }
  .lb-position.p2 { color: var(--silver); }
  .lb-position.p3 { color: var(--bronze-color); }
  .lb-position.px { color: var(--text-dim); }

  .lb-user-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .lb-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lb-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .lb-team-tag {
    font-size: 0.6rem; font-weight: 700; padding: 2px 7px; border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
  }
  .lb-team-tag.ny { background: rgba(59, 130, 246, 0.12); color: var(--ny-color); border: 1px solid rgba(59, 130, 246, 0.25); }
  .lb-team-tag.xyne { background: rgba(168, 85, 247, 0.12); color: var(--xyne-color); border: 1px solid rgba(168, 85, 247, 0.25); }
  .lb-team-tag.nc { background: rgba(34, 197, 94, 0.12); color: var(--nc-color); border: 1px solid rgba(34, 197, 94, 0.25); }
  .lb-team-tag.hs { background: rgba(245, 158, 11, 0.12); color: var(--hs-color); border: 1px solid rgba(245, 158, 11, 0.25); }
  .lb-team-tag.jp { background: rgba(225, 29, 72, 0.12); color: var(--jp-color); border: 1px solid rgba(225, 29, 72, 0.25); }
  .lb-plan-tag {
    font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 3px;
    text-transform: uppercase; letter-spacing: 0.5px;
  }
  .lb-plan-tag.max5 { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
  .lb-plan-tag.max20 { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
  .lb-outdated-tag {
    font-size: 0.5rem; font-weight: 600; padding: 1px 5px; border-radius: 3px;
    background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2);
    cursor: help;
  }

  .lb-rank-badge { font-size: 0.6rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
  .rank-mythic { background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(249, 115, 22, 0.2)); color: #ff6b6b; border: 1px solid rgba(239, 68, 68, 0.4); text-shadow: 0 0 6px rgba(239, 68, 68, 0.3); }
  .rank-legendary { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); border: 1px solid rgba(249, 115, 22, 0.3); }
  .rank-diamond { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
  .rank-platinum { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); border: 1px solid rgba(168, 85, 247, 0.3); }
  .rank-gold { background: rgba(251, 191, 36, 0.15); color: var(--gold); border: 1px solid rgba(251, 191, 36, 0.3); }
  .rank-silver { background: rgba(148, 163, 184, 0.15); color: var(--silver); border: 1px solid rgba(148, 163, 184, 0.2); }
  .rank-bronze { background: rgba(205, 127, 50, 0.15); color: var(--bronze-color); border: 1px solid rgba(205, 127, 50, 0.2); }

  .lb-plans { font-size: 0.8rem; color: var(--text-secondary); text-align: center; font-family: 'JetBrains Mono', monospace; }
  .lb-plans .sub { color: var(--text-dim); font-size: 0.65rem; }
  .lb-updated { font-size: 0.62rem; color: var(--text-dim); margin-top: 2px; }

  .my-status-card { position: relative; padding: 2px; border-radius: 14px; margin-bottom: 16px; background: linear-gradient(135deg, var(--accent-orange), var(--accent-purple), var(--accent-blue)); }
  .my-status-card-inner { background: var(--bg-card); border-radius: 12px; padding: 16px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
  .my-status-name { font-size: 1.1rem; font-weight: 800; }
  .my-status-pct { font-size: 1.3rem; font-weight: 900; font-family: 'JetBrains Mono', monospace; }
  .my-status-rank-info { font-size: 0.75rem; color: var(--text-secondary); }
  .my-status-next { font-size: 0.72rem; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
  .my-status-next-bar { width: 80px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
  .my-status-next-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue)); }
  .my-status-financial { font-size: 0.75rem; color: var(--text-secondary); display: flex; gap: 12px; flex-wrap: wrap; }
  .my-status-financial .spent { color: var(--accent-orange); font-weight: 600; }
  .my-status-financial .remaining { color: var(--accent-green); }
  .my-status-financial .urgency { color: var(--accent-pink); font-weight: 600; }
  .my-status-change { font-size: 0.65rem; color: var(--text-dim); text-decoration: underline; cursor: pointer; margin-left: auto; }
  .my-status-change:hover { color: var(--text-secondary); }

  /* Staleness */
  .lb-row.stale { opacity: 0.5; }
  .lb-row.stale:hover { opacity: 0.8; }
  .lb-stale-tag { font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: rgba(239,68,68,0.15); color: #ef4444; margin-left: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
  .lb-stale-tag.inactive { background: rgba(100,100,120,0.15); color: #64748b; }
  .lb-row.my-row { border-color: rgba(59, 130, 246, 0.5); background: rgba(59, 130, 246, 0.08); }
  .lb-me-tag { font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: rgba(59,130,246,0.2); color: #60a5fa; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle; }

  /* Streak */
  .lb-streak { font-size: 0.65rem; color: #ff6b35; font-weight: 700; margin-left: 4px; }

  /* Rank progress */
  .rank-progress { display: inline-block; width: 40px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; vertical-align: middle; margin-left: 4px; }
  .rank-progress-fill { display: block; height: 100%; border-radius: 2px; transition: width 0.5s; }

  .lb-usage-bar { position: relative; height: 22px; background: var(--bg-primary); border-radius: 6px; overflow: hidden; }
  .lb-usage-fill { height: 100%; border-radius: 6px; transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1); }
  .lb-usage-fill.low { background: linear-gradient(90deg, #1e40af, var(--accent-blue)); }
  .lb-usage-fill.mid { background: linear-gradient(90deg, #7c3aed, var(--accent-purple)); }
  .lb-usage-fill.high { background: linear-gradient(90deg, #c2410c, var(--accent-orange)); }
  .lb-usage-fill.max { background: linear-gradient(90deg, #dc2626, #ef4444); animation: maxPulse 2s ease-in-out infinite; }
  .lb-usage-fill.overflow { background: linear-gradient(90deg, #ef4444, #f97316, #ef4444); background-size: 200% 100%; animation: overflowShift 2s linear infinite; }
  @keyframes overflowShift { 0% { background-position: 0% 0; } 100% { background-position: 200% 0; } }
  .extra-usage-tag { font-size: 0.55rem; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); border: 1px solid rgba(249, 115, 22, 0.25); margin-left: 4px; }
  @keyframes maxPulse { 0%, 100% { box-shadow: 0 0 6px rgba(239, 68, 68, 0.3); } 50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.6); } }

  .lb-pct { font-size: 1rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; text-align: right; }

  .fire-icon { display: inline-block; animation: fireFlicker 0.5s ease-in-out infinite alternate; }
  @keyframes fireFlicker { from { transform: scale(1) rotate(-3deg); } to { transform: scale(1.1) rotate(3deg); } }

  /* Empty state */
  .empty-state { text-align: center; padding: 48px 20px; color: var(--text-dim); }
  .empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
  .empty-state p { font-size: 0.85rem; }

  /* Modal */
  .modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 1000;
    align-items: center; justify-content: center;
  }
  .modal-overlay.active { display: flex; }
  .modal {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px; width: 90%; max-width: 420px; animation: modalIn 0.3s ease;
  }
  @keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
  .modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 20px; }
  .form-group { margin-bottom: 14px; }
  .form-group label { display: block; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
  .form-group input, .form-group select {
    width: 100%; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font-family: 'Inter', sans-serif;
    font-size: 0.85rem; outline: none; transition: border-color 0.2s;
  }
  .form-group input:focus, .form-group select:focus { border-color: var(--accent-purple); }
  .form-group select option { background: var(--bg-card); color: var(--text-primary); }
  .modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

  /* Toast */
  .toast {
    position: fixed; bottom: 24px; right: 12px; left: 12px; background: var(--bg-card);
    border: 1px solid var(--accent-green); color: var(--text-primary); padding: 12px 20px;
    border-radius: 10px; font-size: 0.85rem; font-weight: 600; z-index: 2000;
    max-width: 400px; margin-left: auto;
    animation: toastIn 0.4s ease, toastOut 0.4s ease 2.5s forwards;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }
  @keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(20px); } }

  .refresh-bar { display: none; }

  .confetti-piece { position: fixed; z-index: 3000; pointer-events: none; }

  .last-updated { text-align: center; color: var(--text-dim); font-size: 0.7rem; margin-top: 24px; padding-bottom: 40px; }

  .spacer { flex: 1; }

  /* Sparkline column */
  .lb-sparkline { display: flex; align-items: center; justify-content: center; }
  .lb-sparkline svg { display: block; }

  /* Detail Panel */
  .detail-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); z-index: 499;
  }
  .detail-overlay.open { display: block; }
  .detail-panel {
    position: fixed; top: 0; right: -520px; width: 500px; height: 100vh;
    background: var(--bg-secondary); border-left: 1px solid var(--border);
    z-index: 500; transition: right 0.3s ease; overflow-y: auto; padding: 0;
  }
  .detail-panel.open { right: 0; }
  .detail-panel-header {
    padding: 24px 24px 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: flex-start;
    position: sticky; top: 0; background: var(--bg-secondary); z-index: 1;
  }
  .detail-panel-close {
    background: none; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-secondary); cursor: pointer; padding: 6px 10px;
    font-size: 0.8rem; transition: all 0.2s;
  }
  .detail-panel-close:hover { border-color: var(--accent-purple); color: var(--text-primary); }
  .detail-user-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
  .detail-user-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .detail-body { padding: 20px 24px 40px; }
  .detail-section { margin-bottom: 28px; }
  .detail-section-title {
    font-size: 0.7rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
  }
  .detail-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
  .detail-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .detail-stat {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 12px; text-align: center;
  }
  .detail-stat-value { font-size: 1.2rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
  .detail-stat-label { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
  .detail-chart-container {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 16px; overflow: hidden;
  }
  .detail-chart-container svg { width: 100%; height: auto; display: block; }
  .detail-config { margin-top: 16px; }
  .detail-config label { font-size: 0.72rem; color: var(--text-secondary); margin-right: 8px; }
  .detail-config select {
    padding: 6px 10px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); font-size: 0.78rem;
  }

  /* Tooltip */
  .chart-tooltip {
    position: absolute; pointer-events: none; z-index: 600;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 0.72rem; font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary); box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    white-space: nowrap; display: none;
  }
  .chart-tooltip.visible { display: block; }

  /* History table */
  .detail-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
  .detail-table th {
    text-align: left; padding: 8px 10px; color: var(--text-dim); font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; font-size: 0.6rem;
    border-bottom: 1px solid var(--border);
  }
  .detail-table td {
    padding: 6px 10px; border-bottom: 1px solid var(--border-subtle);
    font-family: 'JetBrains Mono', monospace; color: var(--text-secondary);
  }
  .detail-table tr:hover td { background: var(--bg-card-hover); color: var(--text-primary); }
  .detail-table-wrap { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }

  /* Per-user reset pill in leaderboard rows */
  .lb-reset {
    font-size: 0.6rem; font-weight: 700; font-family: 'JetBrains Mono', monospace;
    padding: 2px 8px; border-radius: 4px; white-space: nowrap;
    letter-spacing: 0.3px; display: inline-flex; align-items: center; gap: 4px;
  }
  .lb-reset.session {
    background: rgba(6, 182, 212, 0.1); color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.25);
  }
  .lb-reset.weekly {
    background: rgba(34, 197, 94, 0.1); color: var(--accent-green);
    border: 1px solid rgba(34, 197, 94, 0.25);
  }
  /* Estimated indicator */
  .reset-estimated {
    position: relative; cursor: help;
    width: 12px; height: 12px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.5rem; font-weight: 900; font-style: italic; font-family: serif;
    border-radius: 50%; background: rgba(251, 191, 36, 0.15); color: var(--gold);
    border: 1px solid rgba(251, 191, 36, 0.3); flex-shrink: 0;
  }
  .reset-estimated .reset-tooltip {
    display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
    padding: 8px 12px; font-size: 0.65rem; font-family: 'Inter', sans-serif;
    font-style: normal; font-weight: 500;
    color: var(--text-secondary); white-space: nowrap; z-index: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4); margin-bottom: 6px;
  }
  .reset-estimated:hover .reset-tooltip { display: block; }


  /* Countdown */
  .countdown-bar {
    display: flex; gap: 12px; margin-bottom: 16px;
  }
  .countdown-card {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px; text-align: center;
  }
  .countdown-label { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; font-weight: 700; }
  .countdown-value { font-size: 1rem; font-weight: 800; font-family: 'JetBrains Mono', monospace; color: var(--accent-cyan); }
  .countdown-sub { font-size: 0.6rem; color: var(--text-dim); margin-top: 2px; }

  /* Team detail clickable */
  .team-side.clickable { cursor: pointer; border-radius: 8px; padding: 8px; transition: background 0.2s; }
  .team-side.clickable:hover { background: var(--bg-card-hover); }

  /* Leaderboard rows clickable */
  .lb-row.clickable { cursor: pointer; }

  /* FAB (mobile only) */
  .fab { display: none; }
  .fab-menu { display: none; }

  /* Mobile */
  @media (max-width: 768px) {
    html, body { overflow-x: hidden; width: 100%; }
    .container { padding: 8px; max-width: 100vw; overflow: hidden; }
    .lb-dual { grid-template-columns: 1fr; }
    .header { padding: 16px 0 10px; }
    .header h1 { font-size: 1.5rem; }
    .header .subtitle { font-size: 0.8rem; }

    /* Leaderboard section at top - mobile */
    .leaderboard-section { margin: 10px 0; }
    .lb-section { margin-bottom: 16px; }
    .lb-section-title { font-size: 0.65rem; margin-bottom: 8px; }
    .team-battle-mini { padding: 8px 10px; margin-bottom: 12px; }
    .team-mini-pct { font-size: 0.75rem; }
    .team-mini-name { font-size: 0.55rem; }

    /* Compact stats: single row, 4 items */
    .stats-bar { grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0; }
    .stat-card { padding: 8px 4px; border-radius: 10px; }
    .stat-value { font-size: 0.9rem; }
    .stat-label { font-size: 0.5rem; margin-top: 2px; letter-spacing: 0.5px; }

    /* Compact team battle */
    .team-battle { padding: 10px 8px; margin: 10px 0; overflow: hidden; }
    .team-battle h2 { font-size: 0.65rem; margin-bottom: 8px; }
    .team-vs { flex-direction: row; gap: 4px; }
    .team-side { min-width: 0; flex: 1; }
    .team-name { font-size: 0.65rem; }
    .team-pct { font-size: 0.85rem; }
    .team-details { display: none; }
    .team-bars { margin-top: 8px; }
    .team-bar-track { height: 4px; }
    .team-bar-value { display: none; }
    .team-bar-label { font-size: 0.6rem; min-width: 32px; width: 32px; }
    .team-bar-row { gap: 6px; }

    /* Hide setup section on mobile */
    .setup-section { display: none; }

    /* Hide action buttons, use FAB instead */
    .actions { display: none; }
    .mobile-hide { display: none !important; }

    /* Show FAB */
    .fab {
      display: flex; align-items: center; justify-content: center;
      position: fixed; bottom: 24px; right: 16px; width: 48px; height: 48px;
      background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
      border: none; border-radius: 50%; color: white; font-size: 1.4rem;
      cursor: pointer; z-index: 900; box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
      transition: transform 0.2s;
    }
    .fab:hover { transform: scale(1.1); }
    .fab.open { transform: rotate(45deg); }

    .fab-menu {
      position: fixed; bottom: 80px; right: 16px; z-index: 899;
      flex-direction: column; gap: 8px; align-items: flex-end;
    }
    .fab-menu.open { display: flex; }
    .fab-menu-item {
      padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border);
      border-radius: 10px; color: var(--text-primary); font-size: 0.8rem; font-weight: 600;
      cursor: pointer; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
      font-family: 'Inter', sans-serif; transition: all 0.2s;
    }
    .fab-menu-item:hover { border-color: var(--accent-purple); }

    .main-tabs { margin: 0 0 12px; }
    .main-tab { padding: 8px 12px; font-size: 0.72rem; }

    /* Tighter tabs */
    .board-tabs { margin: 8px 0 4px; }
    .board-tab { padding: 7px 12px; font-size: 0.68rem; }
    .tabs { margin: 4px 0 8px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .tab { padding: 6px 8px; font-size: 0.68rem; flex: 0 0 auto; }

    /* Leaderboard rows */
    .lb-row {
      grid-template-columns: 28px 1fr 50px;
      padding: 10px 8px; gap: 4px;
    }
    .lb-row .lb-sparkline { display: none; }
    .lb-row .lb-plans { display: none; }
    .lb-row .lb-usage-bar { display: none; }

    /* Detail panel mobile */
    .detail-panel { width: 100%; right: -100%; }
    .detail-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .lb-pct { font-size: 0.85rem; }
    .lb-name { font-size: 0.8rem; }
    .lb-team-tag, .lb-rank-badge { font-size: 0.5rem; padding: 1px 4px; }
    .lb-position { font-size: 0.85rem; }
    .lb-meta { gap: 4px; }
    .lb-updated { font-size: 0.55rem; }

    /* Modals */
    .modal { width: 95%; padding: 20px; }
  }

  @media (max-width: 480px) {
    .header h1 { font-size: 1.1rem; }
    .header .subtitle { font-size: 0.7rem; }
    .stats-bar { gap: 3px; }
    .stat-value { font-size: 0.8rem; }
    .stat-card { padding: 6px 3px; }
    .stat-label { font-size: 0.45rem; }
    .team-pct { font-size: 0.75rem; }
    .team-name { font-size: 0.6rem; }
    .board-tab { padding: 6px 10px; font-size: 0.65rem; }
    .lb-row { grid-template-columns: 24px 1fr 46px; padding: 8px 6px; }
    .detail-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .lb-name { font-size: 0.75rem; }
    .lb-pct { font-size: 0.8rem; }
    .lb-position { font-size: 0.8rem; }
  }
