:root{
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 76px;
  --sidebar-bg: #05060d;
  --sidebar-text: #8b93b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #131a2e;
  --bg: #0a0d18;
  --bg-card: #121729;
  --bg-elev: #171e37;
  --border: #232b4a;
  --text: #eef1fb;
  --text-dim: #8891b5;
  --accent: #2f7dff;
  --accent-dark: #1c63e0;
  --accent-2: #38d9ff;
  --star: #ffb020;
  --radius: 14px;
  --topbar-h: 66px;
  --icon-sm: 14px;
  --icon-md: 18px;
  --icon-lg: 22px;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.35);
  --card-shadow-hover: 0 14px 26px rgba(47,125,255,0.28);
}

*{ box-sizing: border-box; }
html{
  scroll-behavior: smooth;
  /* Keeps anchor targets and keyboard focus clear of the sticky topbar. */
  scroll-padding-top: calc(var(--topbar-h) + 12px);
}
@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  *, *::before, *::after{
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
body{
  margin:0;
  font-family: "Chakra Petch", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(47,125,255,0.10), transparent 40%),
    radial-gradient(circle at 90% 20%, rgba(56,217,255,0.06), transparent 35%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a{ color:inherit; text-decoration:none; }
button{ font-family: inherit; cursor:pointer; }
img{ max-width:100%; display:block; }

:focus-visible{
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ---------- Icons (Lucide sprite) ---------- */
.icon-sprite{ display:none; }
.icon{
  width: var(--icon-md);
  height: var(--icon-md);
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm{ width: var(--icon-sm); height: var(--icon-sm); }
.icon-lg{ width: var(--icon-lg); height: var(--icon-lg); }

.skip-link{
  position:fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color:#fff;
  font-weight:700;
  padding: 10px 18px;
  border-radius: 0 0 10px 10px;
  transition: top .15s ease;
}
.skip-link:focus{ top: 0; }

.app-shell{
  display:flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  background: linear-gradient(180deg, #05060d 0%, #070a17 55%, #0a1128 100%);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  position: sticky;
  top:0;
  height: 100vh;
  overflow-y:auto;
  z-index: 60;
  scrollbar-width: thin;
  transition: width .18s ease;
}
.sidebar::-webkit-scrollbar{ width:6px; }
.sidebar::-webkit-scrollbar-thumb{ background:#232b4a; border-radius:4px; }

.sidebar .logo{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 18px 16px;
  font-family: "Russo One", "Segoe UI", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight:400;
  color:#fff;
  white-space:nowrap;
  overflow:hidden;
  flex-shrink:0;
}
.logo-bolt{ width: var(--icon-lg); height: var(--icon-lg); color: var(--accent-2); }
.logo-text strong{
  background: linear-gradient(135deg, #4fa4ff, #1c7dff);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}

.sidebar-toggle{
  display:none;
  background:none;
  border:none;
  color: var(--sidebar-text);
  padding: 4px 16px 12px;
  text-align:left;
}
.sidebar-toggle:hover{ color:#fff; }

.side-nav{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding: 4px 10px 20px;
}
.side-nav-group-label{
  color: #5c5e74;
  font-size: 0.72rem;
  font-weight:700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 14px 10px 6px;
}
.cat-pill{
  display:flex;
  align-items:center;
  gap:12px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--sidebar-text);
  padding: 9px 10px 9px 7px;
  border-radius: 0 10px 10px 0;
  font-size: 0.9rem;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  transition: background .12s, color .12s, border-color .12s;
  text-align:left;
  width:100%;
}
.cat-pill:hover{ background: var(--sidebar-hover); color: #fff; }
.cat-pill.active{
  background: linear-gradient(90deg, rgba(47,125,255,0.22), rgba(47,125,255,0.04));
  border-left-color: var(--accent);
  color: var(--sidebar-text-active);
  box-shadow: inset 0 0 20px rgba(47,125,255,0.12);
}
.cat-pill.active .cat-pill-icon{ color: var(--accent-2); }
.cat-pill-icon{
  width: var(--icon-md);
  height: var(--icon-md);
  flex-shrink:0;
}
.cat-pill-label{
  flex:1;
  overflow:hidden;
  text-overflow:ellipsis;
}
.cat-pill-count{
  font-size: 0.72rem;
  color: #5c5e74;
  font-weight:700;
  flex-shrink:0;
}

.sidebar-scrim{
  position:fixed;
  inset:0;
  background: rgba(10,10,20,0.5);
  z-index:55;
}
.sidebar-scrim[hidden]{ display:none; }

/* ---------- Main column ---------- */
.main-col{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.topbar{
  position: sticky;
  top:0;
  z-index: 40;
  height: var(--topbar-h);
  display:flex;
  align-items:center;
  gap:14px;
  padding: 0 24px;
  background: rgba(10,13,24,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.mobile-menu-btn{
  display:none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width:38px; height:38px;
  border-radius:10px;
  flex-shrink:0;
}

.search-wrap{
  flex:1;
  max-width: 460px;
  position: relative;
}
.search-icon{
  position:absolute;
  left:14px;
  top:50%;
  transform:translateY(-50%);
  color: var(--text-dim);
  pointer-events:none;
}
#searchInput{
  width:100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 40px 10px 42px;
  border-radius: 999px;
  font-size: 0.95rem;
  outline:none;
  transition: border-color .15s, box-shadow .15s;
}
#searchInput:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,125,255,0.2); }
#searchInput::placeholder{ color: var(--text-dim); }
.clear-search{
  position:absolute;
  right:10px;
  top:50%;
  transform:translateY(-50%);
  display:flex;
  align-items:center;
  justify-content:center;
  background:none;
  border:none;
  color: var(--text-dim);
  padding:4px;
}
.clear-search .icon{ width: var(--icon-sm); height: var(--icon-sm); }
.clear-search:hover{ color: var(--text); }
/* display:flex above would otherwise defeat the [hidden] attribute. */
.clear-search[hidden]{ display:none; }

.nav-fav-btn{
  display:flex;
  align-items:center;
  gap:6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight:600;
  flex-shrink:0;
  margin-left:auto;
}
.nav-fav-btn:hover{ border-color: var(--accent); color: #fff; }
.nav-fav-btn .star{ color: var(--star); fill: currentColor; }
.fav-label{ display:inline; }

/* ---------- Hero ---------- */
.hero{
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 40px 32px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #05060d 0%, #0a1230 55%, #060814 100%);
  border: 1px solid var(--border);
}
.hero-glow{
  position:absolute;
  top:-70px; right:-70px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(47,125,255,0.5), transparent 70%);
  filter: blur(6px);
  pointer-events:none;
  animation: heroGlowPulse 7s ease-in-out infinite;
}
@keyframes heroGlowPulse{
  0%,100%{ opacity:0.75; }
  50%{ opacity:1; }
}
.hero-glow::after{
  content:"";
  position:absolute;
  bottom:-220px; left:-160px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(56,217,255,0.35), transparent 70%);
  filter: blur(6px);
}
.hero-content{ position:relative; z-index:1; max-width: 620px; }
.hero-kicker{
  display:inline-block;
  font-size: 0.72rem;
  font-weight:800;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  background: rgba(56,217,255,0.12);
  border: 1px solid rgba(56,217,255,0.3);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.hero-title{
  margin: 0 0 10px;
  font-family: "Russo One", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight:400;
  letter-spacing: 0.01em;
  line-height:1.15;
  color: #fff;
}
.hero-title em{
  font-style: normal;
  background: linear-gradient(135deg, #4fa4ff, #1c7dff);
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
}
.hero-sub{
  margin:0;
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 46ch;
}

.hero-actions{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap: 16px 24px;
  margin-top: 24px;
}
.hero-cta{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color:#04101f;
  font-weight:800;
  font-size: 0.98rem;
  padding: 13px 26px;
  min-height: 44px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(47,125,255,0.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.hero-cta:hover{ transform: translateY(-2px); box-shadow: 0 14px 30px rgba(47,125,255,0.45); }
.hero-cta:focus-visible{ outline: 2px solid #fff; outline-offset: 3px; }
.hero-cta-arrow{ transition: transform .15s ease; }
.hero-cta:hover .hero-cta-arrow{ transform: translateX(3px); }

.hero-stats{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap: 6px 16px;
  margin:0;
  padding:0;
  list-style:none;
  color: var(--text-dim);
  font-size: 0.88rem;
}
.hero-stat{ display:flex; align-items:center; gap:6px; }
.hero-stat::before{
  content:"";
  width:5px; height:5px;
  border-radius:50%;
  background: var(--accent-2);
  flex-shrink:0;
}
.hero-stat strong{ color:#fff; font-weight:800; }

/* ---------- Main / grid ---------- */
#mainContent{
  max-width: 1400px;
  width:100%;
  margin: 0 auto;
  padding: 20px 24px 60px;
}
.grid-header{
  display:flex;
  align-items: baseline;
  gap:12px;
  margin-bottom: 16px;
  flex-wrap:wrap;
}
.grid-header h2{
  font-family: "Russo One", "Segoe UI", system-ui, sans-serif;
  font-size: 1.3rem;
  margin:0;
  font-weight:400;
  letter-spacing: 0.01em;
}
.result-count{
  color: var(--text-dim);
  font-size: 0.9rem;
}

.rail{ margin-bottom: 28px; }
.rail-title{
  font-family: "Russo One", "Segoe UI", system-ui, sans-serif;
  font-size: 1rem;
  margin: 0 0 12px;
  font-weight:400;
  letter-spacing: 0.01em;
}
.rail-row{
  display:flex;
  gap:14px;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom: 6px;
  min-height: 190px;
  scroll-behavior: smooth;
}
.rail-row .game-card{ width: 150px; flex-shrink:0; }

.game-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.game-card{
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow:hidden;
  cursor:pointer;
  box-shadow: var(--card-shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: 150px 210px;
}
.game-card::before{
  content:"";
  position:absolute;
  top:0; left:0; right:0; height:3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity:0;
  transition: opacity .15s;
  z-index:3;
}
.game-card:hover{
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
  border-color: rgba(47,125,255,0.4);
}
.game-card:hover::before{ opacity:1; }
.game-card:focus-visible{
  border-color: rgba(47,125,255,0.4);
}
.game-card:focus-visible::before{ opacity:1; }
.game-card:focus-visible .play-badge{
  opacity:1;
  background: rgba(20,21,31,0.28);
}

/* ---------- Loading skeleton ---------- */
.skeleton-card{
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.skeleton-thumb{
  aspect-ratio: 1/1;
  background: var(--bg-elev);
}
.skeleton-line{
  height: 10px;
  border-radius: 5px;
  background: var(--bg-elev);
}
.skeleton-line-title{ width: 78%; margin-bottom: 8px; }
.skeleton-line-sub{ width: 46%; height: 8px; }
.skeleton-thumb,
.skeleton-line{
  background-image: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  background-repeat: no-repeat;
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
}
@keyframes skeletonShimmer{
  from{ background-position: 200% 0; }
  to{ background-position: -200% 0; }
}
.ribbon-badge{
  position:absolute;
  top:8px; left:8px;
  z-index:2;
  display:flex;
  align-items:center;
  gap:4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color:#04101f;
  font-size: 0.62rem;
  font-weight:800;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(47,125,255,0.45);
}
.ribbon-badge .icon{
  width: var(--icon-sm);
  height: var(--icon-sm);
  fill: currentColor;
}
.game-thumb-wrap{
  position:relative;
  aspect-ratio: 1/1;
  background: var(--bg);
  overflow:hidden;
}
.game-thumb-wrap.thumb-fallback{
  background: linear-gradient(135deg, #2f7dff, #38d9ff);
  display:flex;
  align-items:center;
  justify-content:center;
}
.thumb-fallback-label{
  color:#fff;
  font-weight:700;
  font-size: 0.9rem;
  text-align:center;
  padding: 0 10px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.game-thumb-wrap img{
  width:100%;
  height:100%;
  object-fit: cover;
  transition: transform .25s;
}
.game-card:hover .game-thumb-wrap img{ transform: scale(1.06); }
.play-badge{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(20,21,31,0.0);
  opacity:0;
  transition: opacity .15s, background .15s;
}
.game-card:hover .play-badge{
  opacity:1;
  background: rgba(20,21,31,0.28);
}
.play-badge span{
  width:44px; height:44px;
  border-radius:50%;
  background: var(--accent);
  display:flex; align-items:center; justify-content:center;
  color:#fff;
  box-shadow: 0 6px 16px rgba(47,125,255,0.55);
}
.play-badge .icon{
  width: var(--icon-lg);
  height: var(--icon-lg);
  fill: currentColor;
  /* Optical centering: the triangle's visual mass sits left of its box. */
  margin-left: 2px;
}
.fav-star{
  position:absolute;
  top:8px; right:8px;
  width:28px; height:28px;
  border-radius:50%;
  background: rgba(10,13,24,0.75);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  border:none;
  color: #9aa3c8;
  display:flex; align-items:center; justify-content:center;
  z-index:2;
}
.fav-star .icon{ width: var(--icon-sm); height: var(--icon-sm); }
.fav-star:hover{ color: var(--star); }
/* Filled star reads as "saved", outline as "not saved" — state without color alone. */
.fav-star.active{ color: var(--star); }
.fav-star.active .icon{ fill: currentColor; }

.game-info{ padding: 10px 12px 8px; }
.game-title{
  font-size: 0.88rem;
  font-weight:700;
  margin:0 0 4px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.game-cat{
  font-size: 0.74rem;
  color: var(--text-dim);
  margin:0;
}

.card-votes{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 6px 12px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.vote-btn{
  display:flex;
  align-items:center;
  gap:4px;
  background:none;
  border:none;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight:600;
  padding: 2px 4px;
  border-radius:6px;
  transition: color .15s, background .15s;
}
.vote-btn:hover{ background: var(--bg-elev); }
.vote-btn.up.active{ color: #2ecc71; }
.vote-btn.down.active{ color: #ff4d6a; }
.vote-btn.active .vote-icon{ fill: currentColor; }
.vote-btn .vote-icon{ width: var(--icon-sm); height: var(--icon-sm); }

.empty-state{
  text-align:center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.load-more-btn{
  display:block;
  margin: 32px auto 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight:700;
  transition: border-color .15s, color .15s;
}
.load-more-btn:hover{ border-color: var(--accent); color: var(--accent-dark); }
.load-more-btn[hidden]{ display:none; }

.site-footer{
  border-top: 1px solid var(--border);
  padding: 24px 24px 40px;
  text-align:center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---------- Player overlay ---------- */
.player-overlay{
  position: fixed;
  inset:0;
  z-index: 100;
  background: #05060d;
  display:flex;
  flex-direction:column;
}
.player-overlay[hidden]{
  display:none;
}
.player-bar{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 10px 16px;
  border-bottom: 1px solid #1c2340;
  background: #0d1120;
  flex-shrink:0;
}
.player-title{
  flex:1;
  font-family: "Russo One", "Segoe UI", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight:400;
  margin:0;
  color:#fff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.player-actions{ display:flex; gap:8px; }
.player-btn{
  background: #171e37;
  border: 1px solid #2a3358;
  color: #eee;
  width:44px; height:44px;
  border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  font-size:0.9rem;
  font-weight:600;
  flex-shrink:0;
}
.player-btn:hover{ border-color: var(--accent); }
.player-back{
  width:auto;
  padding: 0 14px;
  gap:6px;
}
.player-fav.active{ color: var(--star); border-color: var(--star); }
.player-fav.active .icon{ fill: currentColor; }
.player-close:hover{ border-color: #ff4d6a; color: #ff4d6a; }

.player-frame-wrap{
  flex:1;
  position:relative;
  background:#000;
  min-height:0;
}
.player-frame{
  width:100%;
  height:100%;
  border:none;
  display:block;
}
.player-loading{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  color: var(--text-dim);
  font-size: 0.95rem;
  pointer-events:none;
}
.player-info{
  padding: 12px 16px 20px;
  border-top: 1px solid #1c2340;
  background: #0d1120;
  flex-shrink:0;
  max-height: 22vh;
  overflow-y:auto;
}
.player-info p{
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height:1.5;
}
.player-tags{ display:flex; flex-wrap:wrap; gap:6px; }
.player-tags span{
  background: #171e37;
  border: 1px solid #2a3358;
  padding: 3px 10px;
  border-radius:999px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (min-width: 981px){
  .sidebar.collapsed{ width: var(--sidebar-w-collapsed); }
  .sidebar.collapsed .logo-text,
  .sidebar.collapsed .side-nav-group-label,
  .sidebar.collapsed .cat-pill-label,
  .sidebar.collapsed .cat-pill-count{ display:none; }
  .sidebar.collapsed .cat-pill{ justify-content:center; }
  .sidebar-toggle{ display:block; }
}

@media (max-width: 980px){
  .sidebar{
    position: fixed;
    left:0; top:0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 260px;
  }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-toggle{ display:none; }
  .mobile-menu-btn{ display:flex; align-items:center; justify-content:center; }
}

@media (max-width: 640px){
  .topbar{ gap:10px; padding: 0 12px; }
  .fav-label{ display:none; }
  #mainContent{ padding: 16px 12px 50px; }
  .game-grid{ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap:12px; }
  .player-info{ max-height: 30vh; }
  .hero{ padding: 26px 20px; border-radius: 16px; }
  .hero-sub{ font-size: 0.9rem; }
  .hero-actions{ margin-top: 20px; gap: 14px; }
  .hero-cta{ width:100%; justify-content:center; }
  .hero-stats{ font-size: 0.82rem; }
}
