/* ── Catppuccin Mocha ── */
:root {
  --rosewater: #f5e0dc;
  --flamingo: #f2cdcd;
  --pink: #f5c2e7;
  --mauve: #cba6f7;
  --red: #f38ba8;
  --maroon: #eba0ac;
  --peach: #fab387;
  --yellow: #f9e2af;
  --green: #a6e3a1;
  --teal: #94e2d5;
  --sky: #89dceb;
  --sapphire: #74c7ec;
  --blue: #89b4fa;
  --lavender: #b4befe;
  --text: #cdd6f4;
  --subtext1: #bac2de;
  --subtext0: #a6adc8;
  --overlay2: #9399b2;
  --overlay1: #7f849c;
  --overlay0: #6c7086;
  --surface2: #585b70;
  --surface1: #45475a;
  --surface0: #313244;
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
}

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

body {
  background: var(--base);
  color: var(--text);
  font-family:
    ui-monospace, "Cascadia Code", "Fira Mono", "Consolas", monospace;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Background ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 50% 35% at 15% 25%,
      rgba(137, 180, 250, 0.05) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse 45% 30% at 85% 65%,
      rgba(166, 227, 161, 0.04) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 40% 25% at 50% 90%,
      rgba(203, 166, 247, 0.04) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(180, 190, 254, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 190, 254, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* ── Page top bar ── */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(88, 91, 112, 0.3);
  background: rgba(24, 24, 37, 0.8);
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--overlay1);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}

.back::before {
  content: "←";
  transition: transform 0.2s;
}
.back:hover {
  color: var(--lavender);
}
.back:hover::before {
  transform: translateX(-3px);
}

.topbar-title {
  font-family: "Trebuchet MS", "Arial Black", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.topbar-title span {
  color: var(--green);
}

/* ── Stats bar ── */
.statsbar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  padding: 12px 28px;
  background: rgba(17, 17, 27, 0.5);
  border-bottom: 1px solid rgba(88, 91, 112, 0.2);
  font-size: 0.75rem;
  color: var(--subtext0);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-value {
  font-weight: 600;
  color: var(--text);
}

.stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-playing {
  background: var(--green);
}
.dot-planning {
  background: var(--blue);
}
.dot-completed {
  background: var(--teal);
}
.dot-paused {
  background: var(--yellow);
}
.dot-dropped {
  background: var(--red);
}
.dot-total {
  background: var(--mauve);
}
.dot-hours {
  background: var(--peach);
}

.statsbar-divider {
  width: 1px;
  height: 14px;
  background: var(--surface2);
}

/* avg completion bar */
.avg-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.avg-bar-label {
  font-size: 0.72rem;
  color: var(--subtext0);
}

.avg-bar {
  width: 100px;
  height: 5px;
  background: var(--surface0);
  border-radius: 999px;
  overflow: hidden;
}

.avg-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--teal));
  transition: width 0.6s ease;
  width: 0%;
}

/* ── App layout ── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 95px);
}

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 24px 18px;
  border-right: 1px solid rgba(88, 91, 112, 0.25);
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: calc(100vh - 95px);
  overflow-y: auto;
}

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

.filter-label {
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--overlay0);
  margin-bottom: 2px;
}

/* Search */
.search-wrapper {
  position: relative;
}

.searchbar {
  width: 100%;
  background: rgba(49, 50, 68, 0.6);
  border: 1px solid rgba(88, 91, 112, 0.4);
  border-radius: 8px;
  padding: 7px 10px 7px 30px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.searchbar::placeholder {
  color: var(--overlay0);
}
.searchbar:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(49, 50, 68, 0.9);
}

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--overlay1);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Filter buttons */
.filter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  color: var(--subtext1);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  transition: all 0.15s ease;
  text-align: left;
}

.filter-btn:hover {
  background: rgba(88, 91, 112, 0.25);
  color: var(--text);
}

.filter-btn.active {
  background: rgba(88, 91, 112, 0.35);
  border-color: rgba(88, 91, 112, 0.5);
  color: var(--text);
}

.filter-btn .btn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.7;
}

/* Sort select */
.sort-select {
  width: 100%;
  background: rgba(49, 50, 68, 0.6);
  border: 1px solid rgba(88, 91, 112, 0.4);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237f849c'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.sort-select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ── Main content ── */
.content {
  flex: 1;
  padding: 24px 28px;
  overflow-x: hidden;
}

section.game-section {
  margin-bottom: 36px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-family: "Trebuchet MS", "Arial Black", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.section-heading .section-count {
  font-size: 0.7rem;
  color: var(--overlay1);
  background: rgba(88, 91, 112, 0.3);
  border-radius: 999px;
  padding: 1px 8px;
}

.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(88, 91, 112, 0.4), transparent);
}

/* Section accent colours */
.game-section[data-status="Playing"] .section-heading h2 {
  color: var(--green);
}
.game-section[data-status="Planning"] .section-heading h2 {
  color: var(--blue);
}
.game-section[data-status="Ongoing"] .section-heading h2 {
  color: var(--sky);
}
.game-section[data-status="Completed"] .section-heading h2 {
  color: var(--teal);
}
.game-section[data-status="Paused"] .section-heading h2 {
  color: var(--yellow);
}
.game-section[data-status="Dropped"] .section-heading h2 {
  color: var(--red);
}

/* ── Game list ── */
.game-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Game entry ── */
.game-entry {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.game-card {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(
    135deg,
    rgba(49, 50, 68, 0.55),
    rgba(24, 24, 37, 0.7)
  );
  border: 1px solid rgba(88, 91, 112, 0.3);
  padding: 10px 14px;
  border-radius: 10px;
  transition:
    background 0.15s,
    transform 0.15s,
    border-color 0.15s;
}

.game-entry.open .game-card {
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
  background: linear-gradient(
    135deg,
    rgba(69, 71, 90, 0.65),
    rgba(49, 50, 68, 0.8)
  );
}

.game-card:hover {
  background: linear-gradient(
    135deg,
    rgba(69, 71, 90, 0.6),
    rgba(49, 50, 68, 0.75)
  );
  transform: translateY(-1px);
  border-color: rgba(127, 132, 156, 0.4);
}

.cover {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
  border: 1px solid rgba(88, 91, 112, 0.4);
}

.main-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fav {
  color: var(--yellow);
  font-size: 0.85rem;
  display: none;
  filter: drop-shadow(0 0 3px rgba(249, 226, 175, 0.4));
}

.fav.active {
  display: inline;
}

.title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stars {
  font-size: 0.8rem;
  color: var(--peach);
  letter-spacing: 1px;
}

.status-badge {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(88, 91, 112, 0.3);
  color: var(--overlay2);
  width: fit-content;
}

/* side info */
.side-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 110px;
  flex-shrink: 0;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.platinum {
  font-size: 13px;
  filter: drop-shadow(0 0 4px rgba(180, 200, 255, 0.7));
}

.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--surface0);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--teal));
  transition: width 0.3s ease;
}

.progress-value {
  font-size: 0.7rem;
  color: var(--subtext0);
  white-space: nowrap;
}
.last-played {
  font-size: 0.68rem;
  color: var(--overlay1);
  white-space: nowrap;
}

/* ── Details panel ── */
.game-details {
  background: rgba(17, 17, 27, 0.7);
  border: 1px solid rgba(88, 91, 112, 0.3);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 14px 18px;
  font-size: 0.8rem;
  color: var(--subtext0);
  display: none;
  backdrop-filter: blur(8px);
}

.game-entry.open .game-details {
  display: block;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px 16px;
}

.details-grid strong {
  color: var(--subtext1);
  font-weight: 500;
}

.details-grid .notes {
  grid-column: 1 / -1;
  margin-top: 8px;
  line-height: 1.5;
  padding-top: 8px;
  border-top: 1px solid rgba(88, 91, 112, 0.2);
  color: var(--subtext1);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--overlay0);
  font-size: 0.85rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface2);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--overlay0);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
}

@media (max-width: 700px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid rgba(88, 91, 112, 0.25);
    flex-direction: row;
    flex-wrap: wrap;
  }
  .app {
    flex-direction: column;
  }
  .avg-bar-wrap {
    display: none;
  }
}
