:root {
  --bg: #1b2838;
  --bg-2: #16202d;
  --panel: #213040;
  --panel-2: #2a3f55;
  --border: #324862;
  --text: #c7d5e0;
  --text-dim: #8f98a0;
  --accent: #66c0f4;
  --accent-2: #1a9fff;
  --green: #5ba32b;
  --gold: #f0c14b;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.small { font-size: 12px; }
a { color: var(--accent); }

/* Header + tabs */
header {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px; background: var(--bg-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 19px; font-weight: 700; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 600;
}
.tab:hover { background: var(--panel); color: var(--text); }
.tab.active { background: var(--panel-2); color: #fff; border-color: var(--accent); }
.tab img { width: 22px; height: 22px; border-radius: 4px; }

/* ---------------- Dashboard ---------------- */
#dashboard { padding: 28px 24px; max-width: 1100px; margin: 0 auto; }
.dash-hero h1 { margin: 0 0 4px; font-size: 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 22px 0; }
.pcard {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; position: relative; overflow: hidden;
}
.pcard .rank { position: absolute; top: 12px; right: 14px; font-size: 26px; opacity: .8; }
.pcard .phead { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pcard .phead img { width: 56px; height: 56px; border-radius: 8px; }
.pcard .pname { font-size: 17px; font-weight: 700; }
.pcard .pstat { font-size: 13px; color: var(--text-dim); }
.pcard .big { font-size: 30px; font-weight: 800; color: var(--gold); line-height: 1; }
.pcard .big span { font-size: 14px; color: var(--text-dim); font-weight: 600; }
.pcard .substat { display: flex; gap: 18px; margin-top: 12px; font-size: 13px; }
.pcard .substat b { color: var(--text); }
.pcard .toplist { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.pcard .toprow { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; color: var(--text-dim); }
.pcard .toprow img { width: 18px; height: 18px; border-radius: 3px; }
.pcard .toprow .tname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .view-btn {
  margin-top: 14px; width: 100%; padding: 9px; border: none; border-radius: var(--radius);
  background: var(--accent-2); color: #fff; font-weight: 700; cursor: pointer; font-size: 14px;
}
.pcard .view-btn:hover { background: var(--accent); }
.pcard.gold { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.private-flag { margin-top: 10px; font-size: 12px; color: #ffb454; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 820px) { .dash-grid { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.panel h2 { margin: 0 0 2px; font-size: 17px; }
.shared-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.shared-item { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 9px; font-size: 12px; }
.shared-item img { width: 22px; height: 22px; border-radius: 3px; }
.shared-item .sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-person { margin-top: 12px; }
.recent-person .who { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.recent-person .who img { width: 20px; height: 20px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.recent-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); padding: 2px 0; }
.recent-row img { width: 18px; height: 18px; border-radius: 3px; }
.recent-row b { color: var(--accent); }

/* ---------------- Profile / achievements ---------------- */
.layout { display: flex; min-height: calc(100vh - 55px); }
#sidebar { width: 300px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border); padding: 14px; overflow-y: auto; max-height: calc(100vh - 55px); }
#profile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
#profile-head img { width: 40px; height: 40px; border-radius: 6px; }
#profile-head .pn { font-weight: 700; }
#game-search { width: 100%; padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); margin-bottom: 10px; }
.sidebar-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; padding: 0 4px; font-size: 12px; }
.sidebar-controls .toggle, .controls .toggle { margin: 0; display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text); }
#completed-count { font-size: 11px; white-space: nowrap; }
#content { flex: 1; padding: 22px 28px; overflow-y: auto; max-height: calc(100vh - 55px); }

.game-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; margin-bottom: 2px; }
.game-item:hover { background: var(--panel); }
.game-item.active { background: var(--panel-2); }
.game-item img { width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0; background: var(--panel); }
.game-item .g-meta { min-width: 0; }
.game-item .g-name { font-size: 13px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-item .g-sub { font-size: 11px; margin-top: 2px; }
.game-item .g-time { color: var(--text-dim); }
.game-item .g-prog { color: var(--accent); }
.game-item .g-eta { color: var(--gold); }
.game-item .g-eta.past { color: var(--text-dim); }
.game-item .g-done { color: var(--green); font-weight: 700; }
.game-item.completed .g-name { color: var(--text-dim); }

.placeholder { color: var(--text-dim); text-align: center; margin-top: 80px; font-size: 16px; }
#game-header h2 { margin: 0 0 8px; }
.progress-bar { height: 10px; background: var(--bg-2); border-radius: 5px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }
.progress-text { font-size: 13px; color: var(--text-dim); }
.eta-line { margin-top: 10px; padding: 10px 14px; font-size: 13px; background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: var(--radius); }
.eta-line.muted { border-left-color: var(--border); }
.eta-line strong { color: var(--gold); font-size: 15px; }
.low-conf { color: #ffb454; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0; }
.controls select, .controls #ach-search { padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.controls #ach-search { flex: 1; min-width: 160px; }
.note { background: #3a2f1a; border: 1px solid var(--gold); color: var(--gold); padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }

.ach { display: flex; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.ach.done { opacity: 0.62; }
.ach img.ach-icon { width: 54px; height: 54px; border-radius: 6px; flex-shrink: 0; background: var(--bg-2); }
.ach-body { flex: 1; min-width: 0; }
.ach-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ach-title h3 { margin: 0; font-size: 15px; }
.ach-desc { color: var(--text-dim); font-size: 13px; margin: 4px 0 10px; }
.ach-desc.hidden-ach { font-style: italic; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge.done { background: var(--green); color: #fff; }
.badge.todo { background: var(--panel-2); color: var(--accent); border: 1px solid var(--accent); }
.badge.ultra-rare { background: #b13bff; color: #fff; }
.badge.rare { background: #1a9fff; color: #fff; }
.badge.uncommon { background: #3a6e8f; color: #fff; }
.badge.common { background: var(--panel-2); color: var(--text-dim); }
.guides { display: flex; gap: 8px; flex-wrap: wrap; }
.guides a { font-size: 12px; font-weight: 600; text-decoration: none; padding: 6px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-2); color: var(--text); }
.guides a:hover { background: var(--panel-2); }
.guides a.yt { border-color: #ff4d4d; }
.guides a.yt:hover { background: #3a1f1f; }

.loading { position: fixed; inset: 0; background: rgba(11,16,24,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--text-dim); text-align: center; margin-top: 40px; }
.error-banner { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #5a1f1f; border: 1px solid #ff6b6b; color: #ffd5d5; padding: 12px 18px; border-radius: var(--radius); z-index: 60; max-width: 90%; }
