/* Modern Reset & Base */
:root {
  /* Premium Color System */
  --c-bg-app: #fdfdfd;
  --c-bg-sidebar: #ffffff;
  --c-bg-card: #ffffff;

  --c-text-primary: #1a1a1a;
  --c-text-secondary: #525252;
  --c-text-tertiary: #9ca3af;

  --c-accent: #2563eb;
  /* Royal Blue */
  --c-accent-hover: #1d4ed8;
  --c-accent-surface: #eff6ff;

  --c-border: #f3f4f6;
  --c-border-hover: #e5e7eb;

  --c-tag-bg: #f3f4f6;
  --c-tag-text: #4b5563;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Spacing */
  --space-2: 0.5rem;
  /* 8px */
  --space-3: 0.75rem;
  /* 12px */
  --space-4: 1rem;
  /* 16px */
  --space-5: 1.25rem;
  /* 20px */
  --space-6: 1.5rem;
  /* 24px */
  --space-8: 2rem;
  /* 32px */

  /* Layout */
  --sidebar-w: 280px;
  --header-h: 64px;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --trans-base: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--c-bg-app);
  color: var(--c-text-primary);
  margin: 0;
  height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Layout Structure */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--c-bg-sidebar);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 20;
}

.brand {
  margin-bottom: var(--space-8);
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-text-primary);
}

.brand .subtitle {
  margin-top: 2px;
  color: var(--c-text-tertiary);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Sidebar Search */
.search-container {
  margin-bottom: var(--space-6);
}

input[type="search"] {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  padding-left: 2.5rem;
  /* Space for icon */
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--c-bg-app) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E") no-repeat 0.75rem center / 1rem;
  transition: var(--trans-base);
  color: var(--c-text-primary);
}

input[type="search"]:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-surface);
  background-color: #fff;
}

/* Filters */
.filters-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.filter-group h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-tertiary);
  margin: 0 0 var(--space-3) 0;
  font-weight: 600;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.9rem;
  color: var(--c-text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 6px;
  transition: var(--trans-base);
}

.checkbox-label:hover {
  background: var(--c-bg-app);
  color: var(--c-text-primary);
}

.checkbox-label input {
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--c-accent);
  border: 1px solid var(--c-border-hover);
  border-radius: 4px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--c-bg-app);
}

.top-bar {
  height: var(--header-h);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  /* Keeps layout consistent if we add border later */
  flex-shrink: 0;
}

.results-count {
  font-size: 0.9rem;
  color: var(--c-text-secondary);
  font-weight: 500;
}

/* Grid */
.game-grid {
  flex: 1;
  padding: 0 var(--space-6) var(--space-6) var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
  overflow-y: auto;
  align-content: start;
  /* Don't stretch rows */
}

/* Card Design */
.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: var(--space-4);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: var(--trans-base);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--c-border-hover);
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--c-text-primary);
  line-height: 1.3;
}

/* Card Meta (Year, Platforms) */
.card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--c-text-secondary);
}

.card-meta .separator {
  color: var(--c-text-tertiary);
  font-size: 0.7rem;
}

/* Card Tags */
.card-tags {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: var(--space-2);
}

.tag {
  background: var(--c-tag-bg);
  color: var(--c-tag-text);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.card:hover .tag {
  background: #eef2f6;
  /* Slightly darker on hover */
}

.tag.more {
  background: transparent;
  color: var(--c-text-tertiary);
  border: 1px dashed var(--c-border-hover);
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--c-text-tertiary);
  font-size: 1rem;
  border: 2px dashed var(--c-border);
  border-radius: 12px;
  margin-top: var(--space-4);
}

/* Loading State */
.loading-filters {
  font-size: 0.85rem;
  color: var(--c-text-tertiary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.6;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: var(--space-4);
  }

  .main-content {
    overflow: visible;
  }

  .game-grid {
    grid-template-columns: 1fr;
    padding: var(--space-4);
  }
}

/* --- Detail Page Styles (Restored & Adapted) --- */

.detail-container {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-8);
  background: transparent;
  min-height: 100vh;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--c-text-tertiary);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: var(--space-6);
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  width: fit-content;
  box-shadow: var(--shadow-sm);
  transition: var(--trans-base);
}

.back-link:hover {
  color: var(--c-text-primary);
  border-color: var(--c-border-hover);
  transform: translateY(-1px);
}

.game-header {
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--c-border);
  padding-bottom: var(--space-4);
}

.game-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 var(--space-2) 0;
  letter-spacing: -0.02em;
  color: var(--c-text-primary);
}

.game-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.meta-item strong {
  display: block;
  font-size: 0.75rem;
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.meta-item {
  font-size: 0.9rem;
  color: var(--c-text-primary);
}

.detail-section,
.section-group {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-6);
}

.detail-section h2 {
  font-size: 1rem;
  margin: 0 0 var(--space-4) 0;
  color: var(--c-text-tertiary);
  /* Changed to tertiary for consistent headers */
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Overview Card Specifics */
.overview-section .game-header {
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
}

.student-section {
  background: var(--c-bg-app);
  padding: var(--space-6);
  border-radius: 8px;
  border: 1px solid var(--c-border);
}

/* Responsive Detail */
@media (max-width: 768px) {
  .detail-container {
    padding: var(--space-4);
  }

  .game-header h1 {
    font-size: 1.5rem;
  }
}

/* Themed Sections */
:root {
  --theme-design: #4b5563;
  --theme-design-bg: #f9fafb;
  --theme-culture: #7c3aed;
  --theme-culture-bg: #fcfaff;
  --theme-student: #2563eb;
  --theme-student-bg: #f0f7ff;
  --theme-education: #ea580c;
  --theme-education-bg: #fffbf7;
}

.section-group {
  overflow: hidden;
  padding: 0;
}

.group-header {
  background: var(--c-bg-app);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.group-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text-primary);
  text-transform: none;
  /* Override default section h2 uppercasing if inherited */
  letter-spacing: normal;
}

.group-icon {
  font-size: 1.2rem;
}

.group-content {
  padding: var(--space-6);
}

/* Theme Variants */
.theme-design .group-header {
  background: var(--theme-design-bg);
}

.theme-design .group-icon {
  color: var(--theme-design);
}

.theme-culture .group-header {
  background: var(--theme-culture-bg);
}

.theme-culture .group-icon {
  color: var(--theme-culture);
}

.theme-student .group-header {
  background: var(--theme-student-bg);
}

.theme-student .group-icon {
  color: var(--theme-student);
}

.theme-education .group-header {
  background: var(--theme-education-bg);
}

.theme-education .group-icon {
  color: var(--theme-education);
}

/* Inner Questions */
.question-block {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px dashed var(--c-border);
}

.question-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.question-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-tertiary);
  margin-bottom: 4px;
  font-weight: 600;
}

.question-answer {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--c-text-primary);
}