/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg-base:       #0a0a0f;
  --bg-surface:    #0f0f18;
  --bg-raised:     #1a1a2e;
  --bg-hover:      #22223a;
  --border:        #1a1a2e;
  --text-primary:  #ffffff;
  --text-secondary:#888888;
  --text-muted:    #444444;
  --accent:        #5c5cff;
  --accent-hover:  #7070ff;
  --radius-sm:     6px;
  --radius-md:     8px;
  --radius-lg:     10px;
  --sidebar-w:     200px;
  --sidebar-w-collapsed: 52px;
  --topbar-h:      48px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* ── Layout shell ───────────────────────────────────────────────── */
.layout { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.2s, min-width 0.2s;
}
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  min-width: var(--sidebar-w-collapsed);
}
.sidebar .logo {
  padding: 0 16px 16px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-decoration: none;
  display: block;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar.collapsed .logo { font-size: 13px; text-align: center; padding: 0 0 16px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: 0 8px 2px;
  white-space: nowrap;
  overflow: hidden;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: var(--bg-raised);
  color: var(--text-primary);
}
.sidebar nav a .icon { font-size: 16px; flex-shrink: 0; }
.sidebar.collapsed nav a .label { display: none; }
.sidebar .section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .section-label { opacity: 0; height: 0; padding: 0; }
.sidebar hr { border: none; border-top: 1px solid var(--border); margin: 8px 16px; }

/* ── Main area ──────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s;
}
.main.sidebar-collapsed { margin-left: var(--sidebar-w-collapsed); }

/* ── Top bar ────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 99;
}
.topbar .search {
  flex: 1;
  max-width: 480px;
  background: var(--bg-raised);
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.topbar .search::placeholder { color: var(--text-muted); }
.topbar .btn-signin {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.topbar .btn-signin:hover { background: var(--accent-hover); }
.topbar .user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }

/* ── Page content ───────────────────────────────────────────────── */
.content { flex: 1; padding: 24px 20px; }

/* ── Section row ────────────────────────────────────────────────── */
.row { margin-bottom: 28px; }
.row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.row-header h2 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.row-header a { color: var(--accent); font-size: 12px; text-decoration: none; }
.row-header a:hover { text-decoration: underline; }
.badge-new {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

/* ── Game grid ──────────────────────────────────────────────────── */
.games-grid { display: grid; gap: 10px; }
.games-grid.large  { grid-template-columns: repeat(5, 1fr); }
.games-grid.medium { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) {
  .games-grid.large  { grid-template-columns: repeat(4, 1fr); }
  .games-grid.medium { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .games-grid.large, .games-grid.medium { grid-template-columns: repeat(3, 1fr); }
  .sidebar { display: none; }
  .main { margin-left: 0 !important; }
}

/* ── Game card ──────────────────────────────────────────────────── */
.game-card {
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, background 0.15s;
}
.game-card:hover { transform: translateY(-2px); background: var(--bg-hover); }
.game-card .thumb {
  aspect-ratio: 4/3;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.game-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.game-card .thumb .emoji { font-size: 36px; }
.game-card .info { padding: 8px 10px 10px; }
.game-card .info .title { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-card .info .cat   { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── Game detail page ───────────────────────────────────────────── */
.game-page { display: flex; gap: 0; flex: 1; }
.game-area { flex: 1; padding: 16px; display: flex; flex-direction: column; min-width: 0; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-secondary); }
.game-frame-wrap {
  background: #000;
  border-radius: var(--radius-lg);
  aspect-ratio: 4/3;
  max-height: calc(100vh - 180px);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.game-frame-wrap iframe {
  width: 100%; height: 100%;
  border: none;
  display: block;
}
.game-frame-wrap .btn-fullscreen {
  position: absolute;
  bottom: 10px; right: 10px;
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.game-frame-wrap .btn-fullscreen:hover { background: rgba(255,255,255,0.16); }
.game-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--bg-hover); }
.topbar .btn-secondary { padding: 5px 12px; font-size: 12px; }
.controls-hint { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.game-info { margin-top: 14px; }
.game-info h1 { font-size: 18px; font-weight: 700; }
.game-info .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.game-info .desc { font-size: 13px; color: var(--text-secondary); margin-top: 8px; line-height: 1.6; }
.game-sidebar {
  width: 160px;
  min-width: 160px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  padding: 16px 12px;
}
.game-sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; }
.related-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  padding: 8px;
  margin-bottom: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.related-card:hover { background: var(--bg-hover); }
.related-card .emoji { font-size: 22px; }
.related-card .rtitle { font-size: 11px; font-weight: 600; }
.related-card .rcat   { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* ── Utility ────────────────────────────────────────────────────── */
.sidebar nav a:visited, .game-card:visited, .related-card:visited { color: inherit; }
.hidden { display: none !important; }
