:root {
  --bg-primary: #0c0e14;
  --bg-secondary: #131722;
  --bg-card: #181c28;
  --bg-card-hover: #1f2434;
  --border: #262c3e;
  --border-focus: #495475;
  --text-main: #f0f3fa;
  --text-muted: #8c96ac;
  --text-subtle: #5a647c;
  --accent-red: #ff4757;
  --accent-blue: #00d2d3;
  --accent-purple: #9b59b6;
  --accent-amber: #f39c12;
  --accent-green: #2ecc71;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

a:hover {
  color: #9cd1ff;
}

/* Container */
.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: linear-gradient(180deg, #161b26 0%, rgba(19, 23, 34, 0.95) 100%);
  border-bottom: 1px solid var(--border);
  padding: 32px 0 24px;
  position: relative;
  overflow: hidden;
}

.site-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  width: 400px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 71, 87, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.gmtk-badge {
  background: var(--accent-red);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.site-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffffff 40%, #a2b0cb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 820px;
  margin-bottom: 20px;
}

.site-subtitle a {
  color: #58a6ff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-subtitle a:hover {
  color: #a5d6ff;
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill strong {
  color: var(--accent-blue);
}

.video-link-btn {
  margin-left: auto;
  background: rgba(255, 71, 87, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(255, 71, 87, 0.3);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.video-link-btn:hover {
  background: var(--accent-red);
  color: #fff;
}

/* Nav Tabs */
.nav-tabs {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tabs-wrapper {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
  scrollbar-width: none;
}

.tabs-wrapper::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #fff;
  background: var(--bg-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-btn.active .tab-icon {
  color: var(--accent-red);
}

/* Main Content Views */
main {
  flex: 1;
  padding: 32px 0 60px;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: var(--radius-md);
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 400px;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 14px 8px 36px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

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

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.select-custom {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* Gallery Grid */
.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}

.genre-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.genre-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-focus);
  box-shadow: var(--shadow);
}

.genre-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.genre-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.peak-badge {
  background: rgba(0, 210, 211, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(0, 210, 211, 0.3);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.genre-card-stats {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.genre-sparkline-wrapper {
  height: 180px;
  width: 100%;
  margin-top: 6px;
  margin-bottom: 6px;
  position: relative;
}

.genre-card-footer {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-subtle);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

.modal-chart-wrapper {
  height: 320px;
  width: 100%;
  margin-bottom: 24px;
}

.modal-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Games Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.game-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.game-item-card:hover {
  transform: scale(1.04);
  border-color: var(--accent-blue);
}

.game-item-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: #202636;
}

.game-item-info {
  padding: 8px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.game-item-rank {
  font-size: 0.7rem;
  color: var(--accent-amber);
  font-weight: 700;
}

.game-item-title {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Year Scrubber View */
.scrubber-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.year-explorer-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(340px, 1.1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .year-explorer-grid {
    grid-template-columns: 1fr;
  }
}

.year-breakdown-card, .year-games-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

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

.year-chart-scroll-container {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

.year-games-card .games-grid {
  max-height: 560px;
  overflow-y: auto;
}

.timeline-controller {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
}

.current-year-display {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.year-slider {
  width: 100%;
  max-width: 800px;
  margin: 16px auto 10px;
  accent-color: var(--accent-red);
  height: 6px;
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* Compare View */
.compare-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 180px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.compare-chip {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.compare-chip.selected {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
  font-weight: 600;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 24px 0;
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

footer a {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover {
  color: #a5d6ff;
}

/* Responsive */
@media (max-width: 768px) {
  .site-title {
    font-size: 1.6rem;
  }
  .genre-grid {
    grid-template-columns: 1fr;
  }
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .video-link-btn {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}
