:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1015;
  color: #f3f5f8;
  --panel: #151a22;
  --panel-2: #1b222d;
  --border: #2d3644;
  --muted: #98a4b5;
  --accent: #7db0ff;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 75% -10%, #202c43 0, transparent 34rem), #0d1015; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.drawer-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 12px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid #28303c;
  background: rgba(13, 16, 21, .92);
  backdrop-filter: blur(18px);
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, #6e9ee8, #435b8c);
  box-shadow: inset 0 1px #ffffff44, 0 10px 30px #0007;
  font-weight: 900;
  font-size: 20px;
}
.brand-block strong { display: block; font-size: 16px; }
.brand-block span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.search-box { display: grid; grid-template-columns: auto minmax(160px, 420px); align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.search-box input, .toolbar select {
  border: 1px solid var(--border);
  background: #10151c;
  color: #eef2f8;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 12px;
  outline: none;
}
.search-box input:focus, .toolbar select:focus { border-color: #628bc9; box-shadow: 0 0 0 3px #628bc922; }

.app-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); max-width: 1500px; margin: 0 auto; }
.sidebar {
  min-height: calc(100vh - 74px);
  padding: 24px 14px;
  border-right: 1px solid #252d38;
}
.primary-nav { display: grid; gap: 7px; }
.primary-nav button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #aeb8c7;
  text-align: left;
  font-weight: 700;
}
.primary-nav button:hover { background: #171d26; color: #fff; }
.primary-nav button.active { border-color: #344967; background: #1b2738; color: #eaf2ff; }
.sidebar-note { margin-top: 28px; padding: 13px; border: 1px solid #28313e; border-radius: 12px; background: #11161d; }
.sidebar-note strong { font-size: 12px; }
.sidebar-note p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

.content { min-width: 0; padding: clamp(18px, 3vw, 36px); }
.hero { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 22px; }
.eyebrow { color: #75a9f5; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.hero h1 { margin: 6px 0 4px; font-size: clamp(27px, 4vw, 42px); line-height: 1; }
.hero p { margin: 0; color: var(--muted); font-size: 13px; }
.library-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stat-pill { min-width: 70px; padding: 8px 10px; border: 1px solid #2b3441; border-radius: 10px; background: #131820; text-align: center; }
.stat-pill strong { display: block; font-size: 16px; }
.stat-pill span { display: block; color: var(--muted); font-size: 9px; margin-top: 2px; }

.toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid #293240;
  border-radius: 12px;
  background: rgba(19, 24, 32, .8);
}
.toolbar label:not(.check-filter) { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.toolbar select { min-width: 150px; }
.check-filter { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid #2d3644; border-radius: 10px; background: #10151c; color: #d7dce5; font-size: 12px; }
.check-filter input { width: 16px; height: 16px; accent-color: #6e9ee8; }
.toolbar-hint { margin-left: auto; align-self: center; color: #778394; font-size: 10px; }

.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.game-card { overflow: hidden; min-width: 0; border: 1px solid #2b3442; border-radius: 14px; background: linear-gradient(180deg, #171d25, #12171e); box-shadow: 0 14px 35px #0002; transition: transform .16s ease, border-color .16s ease; }
.game-card:hover { transform: translateY(-2px); border-color: #45536a; }
.game-cover { position: relative; aspect-ratio: 16/8.6; overflow: hidden; background: linear-gradient(135deg, var(--secondary), var(--accent)); }
.game-cover::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 70% 22%, #ffffff45 0 3px, transparent 4px), linear-gradient(90deg, transparent 49%, #ffffff18 50%, transparent 51%); opacity: .65; }
.cover-grid { position: absolute; inset: 0; background-image: linear-gradient(#0b0e121e 1px, transparent 1px), linear-gradient(90deg, #0b0e121e 1px, transparent 1px); background-size: 12px 12px; }
.cover-mark { position: absolute; left: 16px; bottom: 14px; max-width: calc(100% - 32px); font-size: clamp(18px, 2.5vw, 28px); font-weight: 900; letter-spacing: -.03em; text-shadow: 0 3px 12px #0009; }
.game-card-body { padding: 14px; }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.card-heading h3 { margin: 0; font-size: 16px; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.status-badge { flex: 0 0 auto; padding: 4px 7px; border-radius: 999px; font-size: 9px; font-weight: 900; border: 1px solid #ffffff1b; }
.status-badge.free { background: #23583d; color: #b8f1d0; }
.status-badge.owned { background: #27486f; color: #c5defc; }
.status-badge.membership { background: #543b76; color: #e1cffb; }
.status-badge.trial { background: #6a562c; color: #f8e4a8; }
.status-badge.locked { background: #393d45; color: #c1c6cf; }
.game-description { min-height: 38px; margin: 12px 0; color: #bbc3cf; font-size: 11px; line-height: 1.55; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-row span { padding: 4px 6px; border-radius: 6px; background: #202731; color: #9fabbc; font-size: 9px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 13px; color: #7f8a99; font-size: 9px; }
.card-meta .installed { color: #8dc5ff; }
.card-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.card-actions button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; font-weight: 800; }
.card-actions button.primary { background: #e8edf5; color: #11161d; }
.card-actions button.primary:hover:not(:disabled) { background: #fff; }
.card-actions button:disabled { cursor: not-allowed; opacity: .45; }
.access-note { color: #798494; font-size: 9px; white-space: nowrap; }
.empty-state { padding: 60px 20px; border: 1px dashed #303b49; border-radius: 14px; text-align: center; color: #c7ced8; }
.empty-state p { color: var(--muted); font-size: 11px; }

.player-dialog { width: min(1180px, 96vw); height: min(860px, 94vh); padding: 0; border: 1px solid #374253; border-radius: 16px; background: #0e1218; color: #f2f5fa; box-shadow: 0 30px 100px #000b; }
.player-dialog::backdrop { background: #05070bc9; backdrop-filter: blur(5px); }
.player-header { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #293341; background: #151a22; }
.player-header strong { display: block; }
.player-header span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.player-actions { display: flex; align-items: center; gap: 8px; }
.player-actions a, .player-actions button { min-height: 36px; display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid #354154; border-radius: 8px; background: #202733; color: #e9eef6; text-decoration: none; font-size: 10px; }
.player-dialog iframe { display: block; width: 100%; height: calc(100% - 62px); border: 0; background: #0d1015; }

@media (max-width: 1050px) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-stats { display: none; }
}

@media (max-width: 760px) {
  .topbar { position: static; display: grid; gap: 12px; }
  .search-box { grid-template-columns: 1fr; gap: 5px; }
  .app-layout { display: block; }
  .sidebar { min-height: auto; padding: 8px 12px 0; border-right: 0; }
  .primary-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; overflow-x: auto; }
  .primary-nav button { min-width: 82px; text-align: center; padding: 0 8px; font-size: 11px; }
  .sidebar-note { display: none; }
  .content { padding: 18px 12px 28px; }
  .hero { margin-bottom: 16px; }
  .toolbar { align-items: stretch; }
  .toolbar label:not(.check-filter), .toolbar select { width: 100%; }
  .check-filter { flex: 1 1 100%; }
  .toolbar-hint { display: none; }
  .player-dialog { width: 100vw; height: 100vh; height: 100svh; max-width: none; max-height: none; border: 0; border-radius: 0; }
  .player-actions a { display: none; }
}

@media (max-width: 540px) {
  .game-grid { grid-template-columns: 1fr; }
  .game-cover { aspect-ratio: 16/8; }
  .brand-block { min-width: 0; }
  .hero h1 { font-size: 30px; }
}
