:root {
  --bg: #0b0d11;
  --panel: #111419;
  --panel-2: #171b21;
  --line: #2a3039;
  --line-strong: #3b4350;
  --text: #f2f4f7;
  --muted: #9aa3af;
  --quiet: #69727e;
  --accent: #75a7d8;
  --accent-strong: #9ac4eb;
  --platinum: #d2b56d;
  --danger: #d07b7b;
  --success: #7bad8f;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { min-height: 100vh; margin: 0; background: var(--bg); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgb(11 13 17 / 94%);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 8px; box-shadow: 0 8px 22px rgb(0 0 0 / 32%); }
.brand strong { display: block; font-size: 17px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 3px; color: var(--quiet); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.connection { padding-right: 16px; color: var(--quiet); font-size: 13px; border-right: 1px solid var(--line); }
.connection.is-online { color: var(--success); }
.connection.is-error { color: var(--danger); }

.page { width: min(1680px, calc(100% - 64px)); margin: 0 auto; padding: 54px 0 88px; }

.profile-panel {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 64px;
  align-items: center;
  min-height: 218px;
  padding: 38px 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.profile-identity { min-width: 0; display: flex; align-items: center; gap: 30px; }
.profile-copy { min-width: 0; }
.avatar { position: relative; width: 116px; height: 116px; flex: 0 0 auto; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; background: #1d222a; color: var(--muted); font-size: 34px; font-weight: 700; box-shadow: 0 16px 38px rgb(0 0 0 / 32%); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar img:not([src]) { display: none; }
.avatar--small { width: 58px; height: 58px; font-size: 18px; }
.eyebrow { margin: 0 0 9px; color: var(--accent-strong); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { text-wrap: pretty; }
h1 { margin: 0; overflow: hidden; font-size: clamp(32px, 3.2vw, 46px); line-height: 1.08; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
#profile-subtitle { margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.profile-provider { width: max-content; max-width: 100%; display: flex; align-items: center; gap: 9px; margin-top: 17px; color: var(--text); font-size: 12px; font-weight: 750; letter-spacing: .04em; text-decoration: none; text-transform: uppercase; }
.profile-provider[hidden] { display: none; }
.profile-provider img { width: 18px; height: 18px; object-fit: contain; }
.profile-provider small { overflow: hidden; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; text-overflow: ellipsis; text-transform: none; white-space: nowrap; }
.profile-provider:hover span { color: var(--accent-strong); }

.profile-stats { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(210px, 1.4fr); }
.profile-stats > div { min-width: 120px; padding: 3px 26px; border-left: 1px solid var(--line); }
.profile-stats strong { display: block; font-size: 30px; letter-spacing: -.03em; }
.profile-stats span { display: block; margin-top: 6px; color: var(--quiet); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.profile-stats small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.profile-stats .platinum-value { color: var(--platinum); }

.library-section { margin-top: 58px; }
.library-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.library-heading h2 { margin: 0; font-size: 38px; letter-spacing: -.035em; }
.library-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 19px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease;
}
.button:hover { border-color: #566171; background: var(--panel-2); }
.button:disabled { opacity: .5; cursor: wait; }
.button--primary { border-color: #7ba8d2; background: #7ba8d2; color: #081018; }
.button--primary:hover { border-color: var(--accent-strong); background: var(--accent-strong); }
.button--secondary, .button--ghost { background: var(--panel); }
.icon-button { min-width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--panel); color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--panel-2); }

.status-filters { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.status-filter { min-width: max-content; min-height: 56px; padding: 0 22px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 14px; font-weight: 650; cursor: pointer; }
.status-filter span { margin-left: 6px; color: var(--quiet); font-variant-numeric: tabular-nums; }
.status-filter:hover { color: var(--text); }
.status-filter.is-active { border-bottom-color: var(--accent); color: var(--text); }
.status-filter.is-active span { color: var(--accent-strong); }

.toolbar { min-height: 84px; display: grid; grid-template-columns: minmax(280px, 440px) auto 1fr; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.search-field input { width: 100%; height: 48px; padding: 0 15px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); font-size: 14px; }
.search-field input::placeholder { color: var(--quiet); }
.sort-field { display: flex; align-items: center; gap: 11px; color: var(--quiet); font-size: 13px; }
.sort-field select { height: 48px; padding: 0 36px 0 13px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); font-size: 14px; }
.result-count { justify-self: end; margin: 0; color: var(--quiet); font-size: 13px; }

.games-list { display: grid; }
.game-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 176px minmax(300px, 1fr) minmax(250px, 350px) minmax(250px, auto);
  gap: 30px;
  align-items: center;
  min-height: 238px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  transition: background 140ms ease;
}
.game-row:hover { background: var(--panel); }
.game-cover { position: relative; width: 152px; height: 202px; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: #171b21; color: #4f5864; font-size: 38px; font-weight: 700; box-shadow: 0 16px 38px rgb(0 0 0 / 42%); }
.game-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; filter: saturate(1.08) contrast(1.04); transition: opacity 200ms ease; }
.game-cover img.is-loaded { opacity: 1; }
.game-main { min-width: 0; }
.game-title { margin: 0; overflow: hidden; font-size: 22px; line-height: 1.3; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.game-details { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 13px; color: var(--quiet); font-size: 14px; }
.game-status { color: var(--accent-strong); font-weight: 700; }
.game-status--platinados { color: var(--platinum); }
.game-status--dropados { color: var(--danger); }
.game-status--concluidos { color: var(--success); }
.game-interest { margin-top: 18px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.game-interest strong { color: var(--text); }

.game-progress { min-width: 0; padding-right: 20px; }
.progress-header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.progress-header span { color: var(--quiet); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.progress-header strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.progress-track { height: 4px; overflow: hidden; background: #272d35; }
.progress-value { height: 100%; background: var(--accent); }
.progress-value--platinum { background: var(--platinum); }
.progress-empty { color: var(--quiet); font-size: 14px; }

.row-actions { display: flex; justify-content: flex-end; gap: 10px; }
.row-action { min-height: 46px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 4px; background: transparent; color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; }
.row-action:hover { background: var(--panel-2); }
.row-action--secondary { color: var(--muted); }
.row-action--danger { color: var(--danger); }
.row-action--platinum { color: var(--platinum); }

.empty-state { max-width: 460px; margin: 58px auto 0; padding: 30px 20px; text-align: center; }
.empty-state h3 { margin: 0; font-size: 17px; }
.empty-state p { margin: 9px 0 20px; color: var(--muted); font-size: 12px; }

.dialog {
  width: min(92vw, 470px);
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 28px 80px rgb(0 0 0 / 60%);
}
.dialog::backdrop { background: rgb(4 6 9 / 78%); backdrop-filter: blur(3px); }
.dialog-card { width: 100%; max-height: calc(100dvh - 26px); display: flex; flex-direction: column; gap: 17px; margin: 0; padding: 24px; overflow-y: auto; overscroll-behavior: contain; }
.dialog-card--wide { width: 100%; }
#settings-dialog { width: min(92vw, 610px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.dialog--confirm p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 13px; }
.icon-button--close { flex: 0 0 auto; font-size: 19px; }
.field { display: grid; gap: 7px; color: #c4cad2; font-size: 11px; font-weight: 650; }
.field input, .field select { width: 100%; height: 43px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 13px; }
.field input::placeholder { color: #555e69; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: none; }
.form-help { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.settings-section { display: grid; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-section h3 { margin: 0; color: var(--text); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.profile-settings-row { display: flex; align-items: center; gap: 14px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.advanced-settings { border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.advanced-settings summary { width: max-content; color: var(--accent-strong); font-size: 11px; cursor: pointer; }
.connection-advanced { padding: 2px 0 0; border-bottom: 0; }
.connection-advanced .field { margin-top: 14px; }
.provider-status { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.advanced-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 16px; }
.dialog-actions { position: sticky; bottom: -24px; display: flex; justify-content: flex-end; gap: 9px; margin-top: 2px; padding: 16px 0 0; background: var(--panel-2); border-top: 1px solid var(--line); }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: flex; align-items: center; gap: 10px; max-width: min(430px, calc(100vw - 32px)); padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 4px; background: #1a1f26; color: var(--text); box-shadow: 0 16px 42px rgb(0 0 0 / 40%); font-size: 12px; }
.toast[hidden] { display: none; }
.toast.is-error { border-color: #704249; }
.toast-spinner { width: 18px; height: 2px; overflow: hidden; background: #3a424d; }
.toast-spinner::after { content: ""; display: block; width: 50%; height: 100%; background: var(--accent); animation: loading 700ms ease-in-out infinite alternate; }
.toast-spinner[hidden] { display: none; }
@keyframes loading { from { transform: translateX(0); } to { transform: translateX(100%); } }

@media (max-width: 1050px) {
  .profile-panel { grid-template-columns: 1fr; gap: 24px; }
  .profile-stats { border-top: 1px solid var(--line); padding-top: 20px; }
  .profile-stats > div:first-child { border-left: 0; padding-left: 0; }
  .game-row { grid-template-columns: 154px minmax(220px, 1fr) minmax(190px, 260px); }
  .game-cover { width: 144px; height: 192px; }
  .row-actions { grid-column: 2 / -1; justify-content: flex-start; margin-top: -8px; }
}

@media (max-width: 720px) {
  .topbar { height: auto; min-height: 72px; padding: 12px 16px; }
  .brand small, .connection { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 42px; padding-inline: 12px; font-size: 12px; }
  .page { width: min(100% - 28px, 1680px); padding-top: 28px; }
  .profile-panel { padding: 24px; }
  .profile-identity { align-items: flex-start; }
  .avatar { width: 82px; height: 82px; }
  .profile-provider { align-items: flex-start; flex-wrap: wrap; }
  .profile-provider small { width: 100%; white-space: normal; }
  .profile-stats { grid-template-columns: 1fr 1fr; gap: 16px 0; }
  .profile-stats > div { padding: 0 14px; }
  .profile-stats > div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .library-section { margin-top: 36px; }
  .library-heading { align-items: flex-start; }
  .library-actions { max-width: 250px; }
  .library-actions .button { flex: 1 1 auto; }
  .toolbar { grid-template-columns: 1fr auto; padding: 12px 0; }
  .search-field { grid-column: 1 / -1; }
  .result-count { grid-column: 2; grid-row: 2; }
  .game-row { grid-template-columns: 112px 1fr; gap: 18px; min-height: 174px; padding: 16px 4px; }
  .game-cover { width: 104px; height: 140px; }
  .game-progress { grid-column: 2; padding-right: 0; }
  .row-actions { grid-column: 2; margin-top: 0; flex-wrap: wrap; }
  .advanced-grid { grid-template-columns: 1fr; }
  .dialog-card { padding: 20px 16px; }
  .dialog-actions { bottom: -20px; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
