/* POLISH_20260921 — visual refresh + mobile-first tweaks. Layered after
   style.css / restyle.css so it wins on any conflict. Intentionally
   scoped: doesn't rename or restructure existing DOM, only re-styles the
   established selectors + adds a few new component classes used by
   polish.js (legend, icon-slider, off-floor row). Uses a small shadcn-
   inspired token layer for consistency. No emoji, no cartoonish icons. */

:root {
  /* Neutral surface palette — a bit warmer than plain slate. */
  --tp-bg:            #0b0d13;
  --tp-surface:       #14171f;
  --tp-surface-2:     #1a1e28;
  --tp-surface-3:     #232833;
  --tp-border:        rgba(255,255,255,0.06);
  --tp-border-strong: rgba(255,255,255,0.12);
  /* Text scale */
  --tp-fg:            #e6eaf2;
  --tp-fg-muted:      #9aa3b4;
  --tp-fg-dim:        #64707f;
  /* Accents */
  --tp-accent:        #f5c86a;      /* single amber accent, calmer than pure gold */
  --tp-accent-strong: #ffd47a;
  --tp-accent-fg:     #14171f;      /* text over the accent */
  --tp-danger:        #ef6b6b;
  --tp-success:       #7fc98a;
  /* Shape / spacing / motion */
  --tp-radius-sm:     6px;
  --tp-radius:        8px;
  --tp-radius-lg:     12px;
  --tp-shadow-1:      0 1px 2px rgba(0,0,0,0.35), 0 6px 20px rgba(0,0,0,0.35);
  --tp-motion:        160ms cubic-bezier(.2,.7,.2,1);
}

/* --- Sidebar ------------------------------------------------------------- */
#leaderboard.side-panel {
  background: var(--tp-surface) !important;
  border-right: 1px solid var(--tp-border) !important;
  color: var(--tp-fg);
}
#leaderboard .side-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--tp-border);
}
#leaderboard .side-label,
#leaderboard .side-head,
#leaderboard .drawer-title {
  color: var(--tp-fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10.5px;
  font-weight: 600;
}

/* Map dropdown */
#leaderboard #map-select {
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border);
  color: var(--tp-fg);
  border-radius: var(--tp-radius);
  padding: 8px 10px;
  width: 100%;
  transition: border-color var(--tp-motion);
}
#leaderboard #map-select:hover { border-color: var(--tp-border-strong); }
#leaderboard #map-select:focus-visible {
  outline: none;
  border-color: var(--tp-accent);
  box-shadow: 0 0 0 3px rgba(245,200,106,0.18);
}

/* Player counts */
#leaderboard .side-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#leaderboard .qstat {
  background: var(--tp-surface-2);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius);
  padding: 10px 12px;
  display: flex; flex-direction: column;
}
#leaderboard .qstat-value { font-size: 22px; font-weight: 700; color: var(--tp-fg); }
#leaderboard .qstat-label { font-size: 11px; color: var(--tp-fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* --- Legend (new, injected by polish.js) --------------------------------- */
.tp-legend-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 4px 0;
  color: var(--tp-fg-muted);
  font: 600 10.5px/1.4 var(--tp-font, inherit);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--tp-motion);
}
.tp-legend-toggle:hover { color: var(--tp-fg); }
.tp-legend-toggle-caret {
  display: inline-block;
  width: 12px;
  color: var(--tp-accent);
  font-size: 12px;
  line-height: 1;
}
.tp-legend-body { padding-top: 6px; }
.tp-legend {
  display: flex; flex-direction: column; gap: 8px;
  padding-top: 4px;
}
.tp-legend-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
  color: var(--tp-fg);
}
.tp-legend-swatch {
  width: 18px; height: 18px; flex: 0 0 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tp-legend-swatch svg { width: 18px; height: 18px; }
.tp-legend-note { color: var(--tp-fg-muted); font-size: 11px; margin-top: 4px; }
.tp-legend-bar {
  width: 42px; height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--tp-danger) 0%, #f7c66a 40%, var(--tp-success) 100%);
}
.tp-legend-badge {
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border);
  color: var(--tp-accent);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}
.tp-team-chips {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.tp-team-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 4px;
  background: var(--tp-surface-3);
}
.tp-team-chip svg { width: 12px; height: 12px; }
.tp-bot-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
  margin-top: 6px;
}
.tp-legend-row-mini {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--tp-fg);
}
.tp-legend-swatch-sm { width: 14px; height: 14px; flex: 0 0 14px; }
.tp-legend-swatch-sm svg { width: 14px; height: 14px; }
.tp-legend-txt { color: var(--tp-fg); }

/* --- Floating tools (top-right + bottom-right zoom) --------------------- */
.floating-tools, .floating-zoom {
  background: rgba(20,23,31,0.9);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg);
  padding: 4px;
  backdrop-filter: blur(8px);
  box-shadow: var(--tp-shadow-1);
}
.tool-btn {
  background: transparent !important;
  border-radius: var(--tp-radius-sm) !important;
  color: var(--tp-fg-muted) !important;
  transition: background var(--tp-motion), color var(--tp-motion) !important;
}
.tool-btn:hover { background: var(--tp-surface-3) !important; color: var(--tp-fg) !important; }
.tool-btn[data-active="true"] {
  background: rgba(245,200,106,0.14) !important;
  color: var(--tp-accent-strong) !important;
}
.tool-divider { background: var(--tp-border) !important; }
.tool-zoom-label #zoom-label { color: var(--tp-fg); font-weight: 600; font-size: 12px; }

/* --- Floor switcher pills ---------------------------------------------- */
.floor-switcher {
  background: rgba(20,23,31,0.9) !important;
  border: 1px solid var(--tp-border) !important;
  border-radius: var(--tp-radius-lg) !important;
  padding: 4px !important;
  backdrop-filter: blur(8px);
  box-shadow: var(--tp-shadow-1);
}
.floor-switcher .floor-btn {
  background: transparent !important;
  color: var(--tp-fg-muted) !important;
  border-radius: var(--tp-radius-sm) !important;
  padding: 6px 10px !important;
  border: none !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  transition: background var(--tp-motion), color var(--tp-motion) !important;
  min-width: 36px;
}
.floor-switcher .floor-btn:hover { background: var(--tp-surface-3) !important; color: var(--tp-fg) !important; }
.floor-switcher .floor-btn.active {
  background: rgba(245,200,106,0.16) !important;
  color: var(--tp-accent-strong) !important;
}

/* --- Settings drawer --------------------------------------------------- */
.settings-drawer {
  background: var(--tp-surface) !important;
  border-left: 1px solid var(--tp-border) !important;
  box-shadow: -10px 0 40px rgba(0,0,0,0.45);
}
.drawer-head, .drawer-foot {
  background: var(--tp-surface-2) !important;
  border-bottom: 1px solid var(--tp-border) !important;
}
.drawer-foot { border-top: 1px solid var(--tp-border) !important; border-bottom: 0 !important; }
.drawer-title { color: var(--tp-fg) !important; font-weight: 600 !important; letter-spacing: 0.02em !important; }
.btn-primary {
  background: var(--tp-accent) !important;
  color: var(--tp-accent-fg) !important;
  border-radius: var(--tp-radius) !important;
  font-weight: 700 !important;
  transition: filter var(--tp-motion) !important;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent !important;
  color: var(--tp-fg-muted) !important;
  border: 1px solid var(--tp-border) !important;
  border-radius: var(--tp-radius) !important;
  transition: background var(--tp-motion), color var(--tp-motion) !important;
}
.btn-ghost:hover { background: var(--tp-surface-3) !important; color: var(--tp-fg) !important; }

/* --- Top bar ------------------------------------------------------------ */
#topbar {
  background: var(--tp-surface) !important;
  border-bottom: 1px solid var(--tp-border) !important;
}
.brand-name { color: var(--tp-fg) !important; letter-spacing: 0.14em !important; }
.brand-sub  { color: var(--tp-accent) !important; letter-spacing: 0.14em !important; }
.brand-sep  { color: var(--tp-fg-dim) !important; }

/* --- Closest-loot + event feed ---------------------------------------- */
.closest-loot, .event-feed {
  background: rgba(20,23,31,0.9) !important;
  border: 1px solid var(--tp-border) !important;
  border-radius: var(--tp-radius-lg) !important;
  backdrop-filter: blur(6px);
}

/* --- Icon-size slider (new, injected by polish.js) -------------------- */
.tp-icon-slider {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
}
.tp-icon-slider input[type=range] { flex: 1; accent-color: var(--tp-accent); }
.tp-icon-slider .tp-icon-slider-val {
  min-width: 42px; text-align: right;
  color: var(--tp-accent); font-weight: 700; font-size: 12px;
}
.tp-icon-slider button {
  width: 28px; height: 28px;
  border-radius: var(--tp-radius-sm);
  background: var(--tp-surface-3);
  border: 1px solid var(--tp-border);
  color: var(--tp-fg);
  cursor: pointer;
  transition: background var(--tp-motion);
}
.tp-icon-slider button:hover { background: var(--tp-border-strong); }

/* --- MOBILE (up to 720px): sidebar becomes a bottom-sheet, settings same */
@media (max-width: 720px) {
  #leaderboard.side-panel {
    /* Take over the bottom half with a drag handle at top. */
    left: 0 !important; right: 0 !important;
    top: auto !important; bottom: 0 !important;
    width: 100% !important;
    max-height: 72vh !important;
    height: auto !important;
    border-right: 0 !important;
    border-top: 1px solid var(--tp-border) !important;
    border-radius: var(--tp-radius-lg) var(--tp-radius-lg) 0 0 !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6) !important;
    overflow-y: auto !important;
    padding-top: 16px !important;
    /* Sidebar hidden by default; toggled visible by menu button. */
    transform: translateY(100%);
    transition: transform var(--tp-motion);
  }
  #leaderboard.side-panel.open { transform: translateY(0); }
  #leaderboard.side-panel::before {
    content: "";
    position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 44px; height: 4px; border-radius: 999px;
    background: var(--tp-border-strong);
  }
  #sidebar-backdrop {
    position: fixed; inset: 0; z-index: 9;
    background: rgba(0,0,0,0.5);
    opacity: 0; pointer-events: none;
    transition: opacity var(--tp-motion);
  }
  #sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }

  .settings-drawer {
    top: auto !important; bottom: 0 !important;
    left: 0 !important; right: 0 !important;
    width: 100% !important;
    max-height: 88vh !important; height: auto !important;
    border-left: 0 !important; border-top: 1px solid var(--tp-border) !important;
    border-radius: var(--tp-radius-lg) var(--tp-radius-lg) 0 0 !important;
    transform: translateY(100%);
  }
  .settings-drawer.open { transform: translateY(0); }

  /* Bigger tap targets. */
  .tool-btn { min-width: 44px !important; min-height: 44px !important; }
  .floor-switcher .floor-btn { min-height: 40px !important; padding: 8px 12px !important; }

  /* Move floating tools higher so nav gestures don't fight them. */
  .floating-tools, .floating-zoom { padding: 6px !important; }
}
