:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #101521;
  --surface-2: #171e2f;
  --surface-3: #1e273d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f6fc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #38bdf8;
  --indigo: #818cf8;
  --purple: #c084fc;
  --platinum: #67e8f9;
  --gold: #fbbf24;
  --silver: #cbd5e1;
  --bronze: #d97706;
  --success: #34d399;
  --danger: #f87171;
  --scrollbar-track: #0b0f18;
  --scrollbar-thumb: #2b3548;
  --radius: 16px;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
  ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background:
    radial-gradient(ellipse 80% 45% at 85% -10%, rgba(56, 189, 248, 0.11), transparent 55%),
    radial-gradient(ellipse 65% 40% at 10% 0%, rgba(168, 85, 247, 0.08), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

svg { display: block; }

button, input, select {
  font-family: inherit;
}

/* Login */
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: linear-gradient(180deg, rgba(23, 30, 47, 0.94), rgba(16, 21, 33, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  padding: 32px 24px 28px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: fadeSlideUp 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.brand-badge {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), rgba(56, 189, 248, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 10px 30px rgba(56, 189, 248, 0.12);
}

.login-card h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-subtitle {
  margin: 6px 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form {
  text-align: left;
  display: grid;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.password-row {
  display: flex;
  gap: 8px;
}

.password-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(8, 11, 18, 0.85);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.password-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.icon-btn {
  width: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 120ms ease;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.95); }

.primary-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
  transition: transform 140ms ease, filter 140ms ease;
}

.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.98); }

.error-msg {
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
}

/* App Shell & Topbar */
.app-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(8, 11, 18, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(56, 189, 248, 0.22));
}

.topbar-titles { min-width: 0; }

.topbar-titles h1 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-status {
  margin: 1px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-action-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, transform 120ms ease;
}

.icon-action-btn svg { width: 18px; height: 18px; }
.icon-action-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-action-btn:active { transform: scale(0.93); }
.icon-action-btn.spinning svg { animation: spin 750ms linear infinite; color: var(--accent); }

.main-content {
  padding: 16px;
}

.view-panel {
  animation: fadeSlideUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 720px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

.kpi-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, rgba(23, 30, 47, 0.9), rgba(16, 21, 33, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  opacity: 0.85;
}

.kpi-cyan::after { background: linear-gradient(90deg, #38bdf8, transparent); }
.kpi-indigo::after { background: linear-gradient(90deg, #818cf8, transparent); }
.kpi-purple::after { background: linear-gradient(90deg, #c084fc, transparent); }
.kpi-gold::after { background: linear-gradient(90deg, #fbbf24, transparent); }

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi-ico {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  color: var(--accent);
}

.kpi-indigo .kpi-ico { color: var(--indigo); }
.kpi-purple .kpi-ico { color: var(--purple); }
.kpi-gold .kpi-ico { color: var(--gold); }
.kpi-ico svg { width: 15px; height: 15px; }

.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

@media (min-width: 760px) {
  .charts-grid {
    grid-template-columns: 1fr 1fr;
  }
  .chart-wide {
    grid-column: 1 / -1;
  }
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

.panel-caption {
  font-size: 0.74rem;
  color: var(--muted);
}

.svg-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-val {
  fill: var(--text);
  font-size: 10px;
  font-weight: 700;
}

.chart-axis {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.chart-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 12px 0;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.donut-svg {
  width: 118px;
  height: 118px;
  flex-shrink: 0;
}

.donut-total {
  fill: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.donut-caption {
  fill: var(--muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.donut-legend {
  flex: 1;
  min-width: 170px;
  display: grid;
  gap: 8px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.donut-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.donut-ico svg { width: 100%; height: 100%; }

.donut-legend-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.donut-name { font-weight: 700; font-size: 0.82rem; }
.donut-sub { font-size: 0.72rem; color: var(--muted); }
.donut-pct { font-size: 0.82rem; color: var(--silver); }

.tier-bars {
  display: grid;
  gap: 10px;
}

.tier-bar-row {
  display: grid;
  gap: 5px;
}

.tier-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.tier-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--silver);
  font-weight: 600;
}

.tier-dot-lg {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.tier-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.tier-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 380ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Home Sections */
.home-section {
  margin-bottom: 24px;
}

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

.section-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
}

.btn-ico svg { width: 15px; height: 15px; }

.h-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}

.almost-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 150ms ease;
}

.almost-card:hover { border-color: var(--border-strong); }
.almost-card:active { transform: scale(0.97); }

.almost-cover {
  width: 44px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.almost-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 5px;
}

.almost-name {
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.almost-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.almost-pct {
  color: var(--accent);
  font-weight: 800;
}

/* Provider Badges */
.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--prov-color);
  background: var(--prov-bg);
  border: 1px solid var(--prov-border);
  white-space: nowrap;
}

.prov-ico {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.prov-ico svg { width: 100%; height: 100%; }

/* Achievement Cards */
.ach-list {
  display: grid;
  gap: 9px;
}

.ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  transition: transform 130ms ease, border-color 150ms ease, background 150ms ease;
}

button.ach-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
button.ach-card:active { transform: scale(0.985); }

.ach-card.tier-platinum { border-left-color: var(--platinum); }
.ach-card.tier-gold { border-left-color: var(--gold); }
.ach-card.tier-silver { border-left-color: var(--silver); }
.ach-card.tier-bronze { border-left-color: var(--bronze); }
.ach-card.locked { opacity: 0.62; }
.ach-card.locked .ach-icon.no-locked-art { filter: grayscale(100%); }

.ach-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

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

.ach-top-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.ach-game {
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ach-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
}

.ach-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 3px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ach-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.pts-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.72rem;
}

.rarity-tag {
  font-size: 0.68rem;
  color: var(--muted);
}

.ach-hidden-spoiler {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--purple);
  background: rgba(192, 132, 252, 0.1);
  border: 1px dashed rgba(192, 132, 252, 0.35);
  border-radius: 8px;
  padding: 4px 8px;
  margin-top: 3px;
  cursor: pointer;
}

.ach-hidden-spoiler svg { width: 13px; height: 13px; }

/* Toolbar & Filters */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-ico {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

.search-ico svg { width: 17px; height: 17px; }

.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.94rem;
  outline: none;
  transition: border-color 150ms ease;
}

.search-input:focus { border-color: var(--accent); }

.filter-pills, .dialog-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar,
.dialog-filters::-webkit-scrollbar { display: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 140ms ease;
}

.pill .prov-ico { width: 14px; height: 14px; }

.pill.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent);
  color: var(--text);
}

.pill:active { transform: scale(0.95); }

.select-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.84rem;
}

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.results-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

/* Library Grid (Covers 2:3) */
.library-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 560px) {
  .library-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 820px) {
  .library-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}

.lib-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.lib-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.lib-card:active { transform: scale(0.97); }

.lib-cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  width: 100%;
  background: linear-gradient(145deg, var(--surface-2), #0d121d);
  overflow: hidden;
}

.lib-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lib-cover-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  gap: 8px;
}

.lib-cover-placeholder svg {
  width: 34px;
  height: 34px;
  opacity: 0.45;
  margin: 0 auto;
}

.lib-badges-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.fav-chip {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(8, 11, 18, 0.78);
  color: var(--gold);
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}

.fav-chip svg { width: 13px; height: 13px; }

.playtime-chip {
  margin-left: auto;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(8, 11, 18, 0.8);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 700;
}

.lib-ach-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 8px 6px;
  background: linear-gradient(to top, rgba(8, 11, 18, 0.94), transparent);
  display: grid;
  gap: 4px;
}

.lib-ach-strip-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--silver);
}

.lib-card-body {
  padding: 10px 11px 11px;
  display: grid;
  gap: 4px;
}

.lib-card-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lib-card-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Segmented Control (Achievements) */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.seg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.seg-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.2));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.seg-ico svg { width: 16px; height: 16px; }

.recent-groups {
  display: grid;
  gap: 18px;
}

.recent-group-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Achievements by Game */
.ach-games-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 680px) {
  .ach-games-grid { grid-template-columns: repeat(2, 1fr); }
}

.game-ach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: transform 130ms ease, border-color 150ms ease, background 150ms ease;
}

.game-ach-card:hover { background: var(--surface-2); border-color: var(--border-strong); }
.game-ach-card:active { transform: scale(0.985); }

.game-ach-card.is-platinum {
  border-color: rgba(103, 232, 249, 0.45);
  box-shadow: 0 0 22px rgba(103, 232, 249, 0.08);
}

.game-ach-thumb {
  width: 50px;
  height: 70px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.game-ach-thumb-empty {
  width: 50px;
  height: 70px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--muted-2);
  flex-shrink: 0;
}

.game-ach-thumb-empty svg { width: 22px; height: 22px; }

.game-ach-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.game-ach-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.game-ach-name {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pct-pill {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.pct-pill.done { color: var(--platinum); }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 320ms ease;
}

.progress-fill.done {
  background: linear-gradient(90deg, #22d3ee, #34d399);
}

.game-ach-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--muted);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(10, 14, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}

.nav-item {
  position: relative;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 150ms ease;
}

.nav-item.active { color: var(--accent); }
.nav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 34px;
  height: 2.5px;
  border-radius: 0 0 4px 4px;
  background: var(--accent);
}

.nav-icon { width: 22px; height: 22px; }
.nav-icon svg { width: 100%; height: 100%; }

/* Native Modal Dialogs */
.app-dialog {
  width: min(700px, calc(100vw - 20px));
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.65);
}

@media (max-width: 600px) {
  .app-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
  }
}

.app-dialog:modal { overscroll-behavior: contain; }

.app-dialog::backdrop {
  background: rgba(4, 6, 12, 0.8);
  backdrop-filter: blur(6px);
}

.dialog-sheet {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.dialog-game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dialog-mini-cover {
  width: 48px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.dialog-title-wrap { min-width: 0; }

.dialog-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.dialog-title-wrap h2 {
  margin: 6px 0 2px;
  font-size: 1.15rem;
  line-height: 1.25;
}

.dialog-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.close-btn svg { width: 18px; height: 18px; }

.dialog-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.dialog-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #34d399);
}

.dialog-achievements {
  display: grid;
  gap: 8px;
}

/* Library Detail Modal Hero */
.lib-hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 16px;
}

.lib-hero-bg {
  position: absolute;
  inset: -20px;
  background-size: cover;
  background-position: center;
  filter: blur(22px) brightness(0.32);
  transform: scale(1.1);
}

.lib-hero-content {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.lib-hero-cover {
  width: 96px;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.lib-hero-meta {
  flex: 1;
  min-width: 0;
}

.lib-hero-meta h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  line-height: 1.2;
}

.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--silver);
}

.lib-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lib-stat-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.lib-stat-box span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
}

.lib-stat-box strong {
  display: block;
  font-size: 0.96rem;
  margin-top: 2px;
}

.lib-ach-callout {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.32);
  border-radius: 14px;
  padding: 13px;
  display: grid;
  gap: 10px;
}

.lib-ach-callout-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.lib-ach-preview-icons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lib-ach-preview-icons img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.lib-desc-box {
  background: rgba(8, 11, 18, 0.45);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--silver);
}

.lib-desc-content.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lib-desc-content p { margin: 0 0 8px; }
.lib-desc-content p:last-child { margin-bottom: 0; }

.lib-extra-meta {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.lib-extra-meta strong { color: var(--silver); }

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(16, 21, 33, 0.5);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 60;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
