:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1d212b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --text-dim: #9aa0ac;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.15);
  --upcoming: #f0a84e;
  --released: #4ecb8e;
  --danger: #e05a5a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); }

.hidden { display: none !important; }

.fallback-banner {
  background: #1f2a3a;
  color: #8fb4f0;
  border-bottom: 1px solid #2d3f5c;
  padding: 8px 20px;
  font-size: 13px;
  text-align: center;
}
.fallback-banner code {
  background: rgba(0,0,0,0.25);
  padding: 2px 6px;
  border-radius: 4px;
}
.fallback-banner.no-key {
  background: #3a2a12;
  color: #f0c98a;
  border-bottom-color: #5c451f;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}
.tagline {
  font-size: 12px;
  color: var(--text-dim);
}

.nav-controls, .view-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.period-label {
  font-weight: 600;
  font-size: 15px;
  min-width: 160px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.spinning { animation: spin 0.8s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.pill-btn, .text-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.pill-btn:hover { background: var(--accent-soft); }
.text-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 4px;
}

.segmented {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
}
.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.status-bar {
  padding: 8px 24px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.status-bar.error { color: var(--danger); }

.filter-panel {
  position: absolute;
  top: 70px;
  right: 24px;
  width: 280px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
  z-index: 30;
  padding: 14px;
}
.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.filter-panel-header h3 { margin: 0; font-size: 14px; }

.filter-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.filter-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.filter-section-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
}
.segmented-block {
  width: 100%;
}
.segmented-block .seg-btn {
  flex: 1;
  padding: 7px 6px;
  font-size: 12px;
}

.genre-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.genre-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 2px;
  border-radius: 6px;
}
.genre-item:hover { background: rgba(255,255,255,0.04); }
.genre-loading { color: var(--text-dim); font-size: 13px; }
.filter-panel-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  text-align: right;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
}

#app-main {
  padding: 20px 24px 60px;
  max-width: 1400px;
  margin: 0 auto;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 110px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s;
}
.day-cell:hover { border-color: var(--accent); }
.day-cell.outside { opacity: 0.35; }
.day-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.day-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.day-cell.today .day-num { color: var(--accent); }

.day-games {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.game-pill {
  font-size: 11px;
  background: var(--bg-card);
  border-radius: 5px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid var(--released);
}
.game-pill.upcoming { border-left-color: var(--upcoming); }

.more-link {
  font-size: 11px;
  color: var(--text-dim);
}

.day-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}

.day-header {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.game-card {
  display: flex;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  align-items: center;
}

.game-cover {
  width: 90px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-card);
  flex-shrink: 0;
}

.game-info { flex: 1; min-width: 0; }

.game-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
}
.game-title a { color: var(--text); text-decoration: none; }
.game-title a:hover { color: var(--accent); }

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.tag.status-released { color: var(--released); border-color: var(--released); }
.tag.status-upcoming { color: var(--upcoming); border-color: var(--upcoming); }
.tag.hot {
  color: #ff8a65;
  border-color: #ff8a65;
  background: rgba(255, 138, 101, 0.12);
  font-weight: 700;
}

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

.load-more-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 12px;
}

/* Week calendar: same grid, taller cells, more room per day */
.month-grid.week-grid .day-cell {
  min-height: 220px;
}

/* Flat list / cards / detail: shared date grouping */
.flat-list {
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.date-section {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.date-section .day-header {
  max-width: 900px;
  margin: 0 auto 10px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  max-width: 1400px;
}

.big-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s;
}
.big-card:hover { border-color: var(--accent); }

.big-card-media {
  aspect-ratio: 16 / 9;
  background: var(--bg-card);
  overflow: hidden;
}
.big-card-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.big-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.big-card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

/* Cards grid inside date sections needs the shared max-width container */
.date-section .cards-grid {
  max-width: 1400px;
  margin: 0 auto;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Detail needs more room than the shared 900px date-section container. */
.date-section:has(.detail-section) {
  max-width: 1000px;
}
.date-section:has(.detail-section) .day-header {
  max-width: 1000px;
}

.detail-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.detail-counter {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 40px;
  text-align: center;
}

.detail-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-hero {
  aspect-ratio: 21 / 9;
  background: var(--bg-card);
  overflow: hidden;
}
.detail-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-thumbs {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.detail-thumb {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.55;
  border: 2px solid transparent;
  transition: opacity 0.15s, border-color 0.15s;
}
.detail-thumb:hover { opacity: 0.85; }
.detail-thumb.active {
  opacity: 1;
  border-color: var(--accent);
}

.detail-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-title-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.detail-cover {
  width: 80px;
  height: 106px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-card);
  flex-shrink: 0;
}

.detail-title-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
.detail-title a { color: var(--text); text-decoration: none; }
.detail-title a:hover { color: var(--accent); }

.detail-description {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0;
  white-space: pre-line;
}

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .nav-controls, .view-controls { justify-content: center; }
  .day-cell { min-height: 70px; }
  .game-pill { display: none; }
  .day-cell.has-games::after {
    content: attr(data-count) " release(s)";
    font-size: 10px;
    color: var(--text-dim);
  }
  .detail-hero { aspect-ratio: 16 / 9; }
  .detail-title-row { flex-direction: column; align-items: center; text-align: center; }
}
