:root {
  --background: #0b0e14;
  --surface: #151a24;
  --surface-hover: #1e2530;
  --accent: #e63946;
  --accent-hover: color-mix(in srgb, var(--accent) 82%, white);
  --text: #f2f2f2;
  --text-dim: rgba(255, 255, 255, 0.6);
  --text-dimmer: rgba(255, 255, 255, 0.4);
  --border: rgba(255, 255, 255, 0.1);
  --site-max-width: 1200px;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  max-width: var(--site-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem 0.75rem;
  flex: 1;
}

/* Header banner */
.header-banner {
  position: relative;
  max-width: calc(var(--site-max-width) - 1.5rem);
  width: calc(100% - 1.5rem);
  margin: 0 auto;
  aspect-ratio: 3 / 1;
  overflow: hidden;
  background: var(--background);
}
@media (min-width: 640px) {
  .header-banner { aspect-ratio: 4 / 1; }
}
.header-banner img.background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.header-banner img.logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}

/* Topbar (above the header banner): search + messages + user menu */
.topbar {
  background: var(--background);
}
.topbar-inner {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: var(--surface-hover);
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.user-menu {
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  border: none;
  background: var(--surface-hover);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.5rem 0.75rem 0.5rem 0.5rem;
  cursor: pointer;
  touch-action: manipulation;
}
.user-menu-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
}
.avatar-circle {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-menu-btn .chevron {
  transition: transform 0.15s;
}
.user-menu-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  min-width: 10rem;
  padding: 0.4rem;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.user-menu-dropdown a {
  padding: 0.5rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-dim);
}
.user-menu-dropdown a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Site nav: page title + hamburger menu button, all screen sizes */
.site-nav {
  position: relative;
  width: 100%;
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 1rem 0.75rem;
  background: var(--background);
}
.site-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.site-nav-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}
.site-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background-color: var(--surface-hover);
  border: none;
  border-radius: 0.5rem;
  color: var(--text);
}
.site-nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}
.site-nav-dropdown {
  position: absolute;
  right: 0.75rem;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  z-index: 20;
}
.site-nav-dropdown a {
  display: block;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-weight: 600;
}
.site-nav-dropdown a:hover {
  background: var(--surface-hover);
}
.site-nav-dropdown a.active {
  background: var(--accent);
  color: #fff;
}

/* Buttons & inputs */
.btn {
  display: inline-block;
  border: none;
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: center;
}
.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover {
  background: var(--accent-hover);
}
.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-block {
  display: block;
  width: 100%;
}

input, textarea, select {
  width: 100%;
  background: var(--background);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-card {
  max-width: 26rem;
  margin: 4rem auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 2rem;
}
.form-card h1 {
  margin-top: 0;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.error {
  color: #f87171;
  font-size: 0.875rem;
}
.hint {
  color: var(--text-dimmer);
  font-size: 0.75rem;
}

/* Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}
@media (min-width: 768px) {
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}
@media (min-width: 1280px) {
  .game-grid { grid-template-columns: repeat(5, 1fr); }
}

.game-card {
  display: block;
  background: var(--surface);
  overflow: hidden;
  border-radius: 0.375rem;
  position: relative;
}
.game-card .card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.game-card:hover .card-overlay {
  opacity: 1;
}
.game-card .card-overlay .card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.3;
}
.game-card .card-overlay .card-title-year {
  font-weight: 400;
  color: var(--text-dim);
}
.game-card .card-overlay .card-category {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 1rem;
  padding: 0.15rem 0.55rem;
  margin: 0.3rem 0 0;
  line-height: 1.3;
}
.game-card .card-overlay .card-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.game-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-hover);
}
.game-card .no-image {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dimmer);
  font-size: 0.875rem;
}
.game-card .rating-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0, 0, 0, 0.7);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 0.25rem;
  padding: 0.1rem 0.4rem;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 3rem 0;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.tag {
  background: var(--surface);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}
.pill {
  background: var(--surface-hover);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}
.pill-accent {
  background: var(--accent);
  font-weight: 600;
}

/* Game detail */
.game-tagline {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
}
.game-main-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.5rem;
}
.game-main-row > div {
  min-width: 0;
}
@media (min-width: 768px) {
  .game-main-row { grid-template-columns: 460px 1fr; }
}
.game-hero-cover {
  position: relative;
  width: 100%;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--surface);
}
.game-hero-cover img {
  display: block;
  width: 100%;
  height: auto;
}
.game-description {
  margin: 1rem 0 0;
  white-space: pre-line;
  color: var(--text-dim);
}
.edit-icon-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.edit-icon-btn:hover {
  background: var(--accent);
}
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.tag-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-decoration: none;
}
.tag-chip:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.tag-chip svg {
  color: var(--accent);
  flex-shrink: 0;
}
.tag-chip-toggle {
  font: inherit;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
.tag-chip-toggle:hover {
  background: var(--surface-hover);
  color: var(--accent);
}
.similar-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .similar-cards { grid-template-columns: repeat(2, 1fr); }
}
.similar-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem;
}
.similar-card:hover {
  background: var(--surface-hover);
}
.similar-card img,
.similar-card .no-image {
  width: 64px;
  height: 64px;
  border-radius: 0.375rem;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-hover);
}
.similar-card-text {
  min-width: 0;
}
.similar-card-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  overflow-wrap: break-word;
}
.similar-card-tagline {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-dimmer);
  overflow-wrap: break-word;
}
.game-detail-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.loan-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
}
.buy-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.1rem;
}
.buy-links a {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}
.buy-links a:hover {
  text-decoration: underline;
}
.stat-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.6rem;
  margin: 0.75rem 0 1rem;
}
.stat-chip {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}
.stat-chip svg {
  color: var(--accent);
  flex-shrink: 0;
}
.stat-chip > div {
  min-width: 0;
}
.stat-chip .stat-value {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-chip .stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dimmer);
  line-height: 1.2;
  overflow-wrap: break-word;
}
@media (max-width: 480px) {
  .stat-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.4rem;
  }
  .stat-chip {
    padding: 0.4rem 0.5rem;
    gap: 0.35rem;
  }
  .stat-chip svg {
    width: 14px;
    height: 14px;
  }
  .stat-chip .stat-value {
    font-size: 0.8rem;
  }
  .stat-chip .stat-label {
    font-size: 0.62rem;
  }
}
.detail-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (min-width: 640px) {
  .detail-columns { grid-template-columns: 1fr 1fr; }
}
.expansions-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.expansions-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
}
.expansions-list-item a {
  color: var(--text);
}
.expansion-add-btn {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px solid var(--accent);
  border-radius: 0.375rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
.expansion-add-btn:hover {
  background: var(--accent);
  color: #fff;
}
.section-label {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dimmer);
  margin-bottom: 0.4rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  padding-top: 6rem;
  overflow-y: auto;
  z-index: 50;
}
@media (max-width: 640px) {
  .modal-backdrop { padding: 1rem; padding-top: 1.5rem; padding-bottom: 1.5rem; }
}
.modal {
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.25rem;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
}
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  border-bottom: 2px solid var(--border);
}
.tab {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: none;
  color: var(--text-dim);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}
.tab-panel {
  animation: none;
}
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dimmer);
  font-size: 0.75rem;
  margin: 1rem 0;
}
.divider hr {
  flex: 1;
  border: none;
  border-top: 1px solid var(--border);
}
.field-row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(2, 1fr);
}
.field-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dimmer);
  margin-bottom: 0.25rem;
}
@media (min-width: 480px) {
  .field-row-3 { grid-template-columns: repeat(3, 1fr); }
}
.search-results {
  max-height: 22rem;
  overflow-y: auto;
  margin-top: 0.75rem;
}
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 0.25rem;
  font-size: 0.9rem;
}
.search-result-item:hover {
  background: var(--surface-hover);
}

/* Footer */
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer-inner {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 2rem;
}
.site-footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.site-footer-title {
  font-weight: 700;
  color: var(--accent);
}
.site-footer-tagline {
  font-size: 0.8rem;
  color: var(--text-dimmer);
  max-width: 24rem;
}
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-dim);
}
.site-footer-links a:hover {
  color: var(--text);
}
.site-footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  padding-bottom: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-dimmer);
}
.site-footer-bottom a {
  color: var(--text-dim);
  text-decoration: underline;
}
.site-footer-bottom a:hover {
  color: var(--text);
}
.bgg-badge {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 0.25rem;
  padding: 0.2rem 0.45rem;
  line-height: 0;
  text-decoration: none;
}
.bgg-badge img {
  display: block;
  height: 18px;
  width: auto;
}
