/* === SteamDB-inspired Dark Theme === */
:root,
[data-theme="dark"] {
  --bg-primary: #1b2838;
  --bg-secondary: #16202d;
  --bg-tertiary: #1e3044;
  --bg-hover: #243447;
  --text-primary: #ebebeb;
  --text-secondary: #8f98a0;
  --text-muted: #5a6772;
  --accent-blue: #67c1f5;
  --accent-green: #a3cf06;
  --accent-red: #d94126;
  --price-sale: #a3cf06;
  --price-regular: #8f98a0;
  --border-color: #2a3f50;
  --badge-blue: #1a9fff;
  --badge-green: #4c6b22;
  --badge-purple: #7b2d8b;
  --badge-default: #4c6b22;
  --health-bg: #3d2200;
  --health-border: #b36b00;
  --health-text: #ffb74d;
  --font-base: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8eaed;
  --bg-hover: #dde0e4;
  --text-primary: #1a1a1a;
  --text-secondary: #5f6368;
  --text-muted: #9aa0a6;
  --accent-blue: #1a73e8;
  --accent-green: #188038;
  --accent-red: #d93025;
  --price-sale: #188038;
  --price-regular: #5f6368;
  --border-color: #dadce0;
  --badge-blue: #1a73e8;
  --badge-green: #188038;
  --badge-purple: #7b2d8b;
  --badge-default: #188038;
  --health-bg: #fff3cd;
  --health-border: #ffc107;
  --health-text: #856404;
}

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

body {
  font-family: var(--font-base);
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* === Modal (Age Gate) === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
  max-width: 420px;
  text-align: center;
}
.modal-content h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}
.modal-content p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* === Buttons === */
.btn {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-base);
  font-size: 13px;
  transition: background 0.15s;
}
.btn:hover {
  background: var(--bg-hover);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--accent-blue);
  color: #000;
  border-color: var(--accent-blue);
  font-weight: 600;
}
.btn-primary:hover {
  background: #8ed4f8;
}
.btn-secondary {
  background: transparent;
}
.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 12px;
}

/* === Header === */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 48px;
  gap: 1.5rem;
}
.logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-blue);
  text-decoration: none;
  white-space: nowrap;
}
.main-nav {
  display: flex;
  gap: 0.25rem;
}
.nav-link {
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 4px;
  transition:
    color 0.15s,
    background 0.15s;
}
.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-link.active {
  color: var(--accent-blue);
}
.search-box {
  margin-left: auto;
  position: relative;
}
.search-box input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 13px;
  width: 260px;
  outline: none;
}
.search-box input::placeholder {
  color: var(--text-muted);
}
.search-box input:focus {
  border-color: var(--accent-blue);
}

/* === Main Content === */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* === Stats Bar === */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}
.stat-item strong {
  color: var(--text-primary);
}

/* === View Header with Sort === */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.view-header .section-title {
  margin-bottom: 0;
}

/* === Sort Controls === */
.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sort-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.sort-select,
.filter-input,
.filter-select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 12px;
  outline: none;
}
.sort-select:focus,
.filter-input:focus,
.filter-select:focus {
  border-color: var(--accent-blue);
}
.sort-select,
.filter-select {
  cursor: pointer;
}
.filter-input {
  width: 80px;
}

/* === Section Title === */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

/* === Data Table === */
.table-container {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}
.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(42, 63, 80, 0.5);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background 0.1s;
}
.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.col-rank {
  width: 40px;
  text-align: center;
}
.col-change {
  width: 55px;
  text-align: center;
}
.col-thumb {
  width: 60px;
}
.col-title {
  min-width: 200px;
}
.col-maker {
  width: 150px;
}
.col-price {
  width: 100px;
  text-align: right;
}
.col-regular {
  width: 100px;
  text-align: right;
}
.col-discount {
  width: 80px;
  text-align: center;
}
.col-date {
  width: 100px;
  text-align: right;
  color: var(--text-secondary);
  font-size: 12px;
}

/* === Thumbnail === */
.item-thumb {
  width: 50px;
  height: 70px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--bg-tertiary);
}

/* === Title Link === */
.item-title-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 500;
}
.item-title-link:hover {
  text-decoration: underline;
}
.item-maker {
  color: var(--text-secondary);
  font-size: 12px;
}

/* === Price === */
.price-current {
  color: var(--price-sale);
  font-weight: 700;
  white-space: nowrap;
}
.price-regular {
  color: var(--price-regular);
  text-decoration: line-through;
  font-size: 12px;
  white-space: nowrap;
}
.price-normal {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
}
.price-point {
  color: var(--accent-blue);
  font-size: 11px;
  white-space: nowrap;
}
.price-ends {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.price-detail-line {
  margin-top: 0.35rem;
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Discount Badge === */
.discount-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--badge-default);
}
.discount-badge.best-ever {
  background: var(--badge-blue);
}
.discount-badge.best-match {
  background: var(--badge-green);
}
.discount-badge.best-year {
  background: var(--badge-purple);
}

/* === Rank Change Indicators === */
.rank-change {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.rank-up {
  color: var(--accent-green);
}
.rank-down {
  color: var(--accent-red);
}
.rank-same {
  color: var(--text-muted);
}
.rank-new {
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 700;
}

/* === Price Badge (detail page) === */
.price-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  margin-left: 0.5rem;
}
.price-badge.best-ever {
  background: var(--badge-blue);
}
.price-badge.best-match {
  background: var(--badge-green);
}

/* === Term Badge (detail page tags) === */
.term-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  margin: 2px;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 32px;
  text-align: center;
}
.page-btn.active {
  background: var(--accent-blue);
  color: #000;
  border-color: var(--accent-blue);
  font-weight: 600;
}
.page-ellipsis {
  color: var(--text-muted);
  font-size: 13px;
  padding: 0 0.25rem;
  user-select: none;
}

/* === Search Results === */
.search-results {
  min-height: 200px;
}
.placeholder-text {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}
.search-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border-bottom: 1px solid rgba(42, 63, 80, 0.5);
  cursor: pointer;
  transition: background 0.1s;
}
.search-item:hover {
  background: var(--bg-hover);
}
.search-item-info {
  flex: 1;
}
.search-item-title {
  color: var(--accent-blue);
  font-weight: 500;
}
.search-item-maker {
  color: var(--text-secondary);
  font-size: 12px;
}
.search-item-price {
  text-align: right;
  white-space: nowrap;
}

/* === Item Detail === */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.detail-thumb-frame {
  width: 200px;
  aspect-ratio: 5 / 7;
  flex-shrink: 0;
  border-radius: 4px;
  background: var(--bg-tertiary);
  overflow: hidden;
}
.detail-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.detail-info {
  flex: 1;
}
.detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.detail-maker {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.detail-terms {
  margin-bottom: 0.75rem;
}

.price-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.price-block .current-price {
  font-size: 24px;
  font-weight: 700;
  color: var(--price-sale);
}
.price-block .regular-price {
  color: var(--price-regular);
  text-decoration: line-through;
  margin-left: 0.75rem;
}
.price-block .discount-info {
  margin-top: 0.5rem;
  font-size: 13px;
  color: var(--text-secondary);
}
.price-block .dmm-link {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.4rem 1rem;
  background: var(--accent-blue);
  color: #000;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 13px;
}
.price-block .dmm-link:hover {
  background: #8ed4f8;
}

.detail-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

/* === Meta Table (detail page) === */
.meta-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}
.meta-table th {
  text-align: left;
  padding: 0.35rem 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  width: 120px;
  border-bottom: 1px solid rgba(42, 63, 80, 0.3);
}
.meta-table td {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(42, 63, 80, 0.3);
}

/* === Sample Image Gallery === */
.sample-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}
.sample-img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
  transition:
    transform 0.15s,
    opacity 0.15s;
  background: var(--bg-tertiary);
}
.sample-img:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

/* Lightbox overlay for enlarged image */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
}
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

/* Price chart container */
#price-chart {
  width: 100%;
  min-height: 250px;
}

/* === Loading === */
.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* === Footer === */
.site-footer {
  max-width: 1400px;
  margin: 2rem auto 0;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.footer-note {
  margin-top: 0.5rem;
}

/* === Theme Toggle === */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s;
}
.theme-toggle:hover {
  color: var(--text-primary);
}

/* === Health Banner === */
.health-banner {
  background: var(--health-bg);
  border: 1px solid var(--health-border);
  color: var(--health-text);
  padding: 0.5rem 1rem;
  font-size: 12px;
  text-align: center;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

/* === Filter Panel === */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 12px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.filter-group label {
  color: var(--text-secondary);
  white-space: nowrap;
}
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--text-secondary);
}
.filter-checkbox input {
  cursor: pointer;
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 0;
  }
  .search-box {
    width: 100%;
    margin-left: 0;
  }
  .search-box input {
    width: 100%;
  }
  .stats-bar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .detail-header {
    flex-direction: column;
  }
  .detail-thumb-frame {
    width: 100%;
    max-width: 300px;
  }
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .col-change {
    width: 40px;
  }
  .col-maker {
    display: none;
  }
}
