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

:root {
  --bg: #0e0e10;
  --surface: #1c1c1e;
  --card: #2c2c2e;
  --border: #38383a;
  --red: #e60012;
  --green: #34c759;
  --yellow: #ff9f0a;
  --text: #f2f2f7;
  --text-2: #8e8e93;
  --radius: 12px;
  --gap: 1.25rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1rem;
  font-weight: 700;
}

.logo { flex-shrink: 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.last-updated {
  font-size: 0.78rem;
  color: var(--text-2);
}

.platform-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem;
}

.nav-link {
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { background: var(--red); color: #fff; }

/* ── Buttons ── */
.btn {
  padding: 0.4rem 1.1rem;
  border-radius: 8px;
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #c8000f; }
.btn-primary:disabled { opacity: 0.45; cursor: default; }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #3a3a3c; }
.btn-secondary.active {
  background: rgba(52, 199, 89, 0.15);
  color: var(--green);
  border-color: rgba(52, 199, 89, 0.4);
}

/* ── Layout ── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ── Hero ── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

/* ── Counter card ── */
.counter-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  border: 1px solid var(--border);
}

.counter-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 0.25rem;
}

.counter-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.platform-counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  text-align: left;
}

.platform-count-name {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-2);
  margin-bottom: 0.15rem;
}

#count-hac, #count-bee, #sale-count {
  font-size: clamp(3rem, 6vw, 5rem);
  font-weight: 900;
  line-height: 1;
  color: var(--text-2);
  transition: color 0.4s, text-shadow 0.4s;
}

#count-hac.tier-decent, #sale-count.tier-decent { color: var(--yellow); }
#count-hac.tier-good,   #sale-count.tier-good   { color: var(--green); }
#count-hac.tier-great,  #sale-count.tier-great  { color: var(--green); text-shadow: 0 0 50px rgba(52, 199, 89, 0.4); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.loading-pulse { animation: pulse 1.4s ease-in-out infinite; }

.trend {
  font-size: 2.25rem;
  font-weight: 700;
  align-self: center;
  margin-top: 0.25rem;
}
.trend.up   { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--text-2); }

.badge {
  display: inline-block;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.75rem;
}
.badge.good {
  background: rgba(52, 199, 89, 0.12);
  color: var(--green);
  border: 1px solid rgba(52, 199, 89, 0.3);
}
.badge.normal {
  background: rgba(142, 142, 147, 0.08);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ── Settings card ── */
.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-card h2 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
}

/* ── Tier legend ── */
.tier-legend {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tier-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text-2);
}

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

.tier-rubbish-dot { background: var(--text-2); }
.tier-decent-dot  { background: var(--yellow); }
.tier-good-dot    { background: var(--green); }
.tier-great-dot   { background: var(--green); box-shadow: 0 0 6px rgba(52,199,89,0.7); }

/* ── Email subscribe ── */
.bot-field { display: none; }
.email-subscribe {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.email-subscribe input[type="email"] {
  flex: 1;
  min-width: 0;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.84rem;
  outline: none;
}

.email-subscribe input[type="email"]::placeholder { color: var(--text-2); }
.email-subscribe input[type="email"]:focus { border-color: var(--red); }

.email-subscribe select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
}

.email-subscribe select:focus { border-color: var(--red); }

.subscribe-status {
  font-size: 0.78rem;
  min-height: 1.2em;
}

.subscribe-status.ok  { color: var(--green); }
.subscribe-status.err { color: #ff4444; }

/* ── Platform filter checkboxes ── */
.platform-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.platform-filters-label {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-right: 0.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: var(--card);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--red);
  border-color: var(--red);
}

.checkbox-label input[type="checkbox"]::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: none;
}

.checkbox-label input[type="checkbox"]:checked::after {
  display: block;
}

.platform-warning {
  font-size: 0.8rem;
  color: var(--yellow);
  display: none;
}

/* ── History card ── */
.history-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem 1.75rem 1.5rem;
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

.history-range {
  font-size: 0.75rem;
  color: var(--text-2);
}

.sparkline-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sparkline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sparkline-label-sm {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  width: 48px;
  flex-shrink: 0;
}

#sparkline-hac, #sparkline-bee {
  display: block;
  flex: 1;
  height: 50px;
}

#sparkline {
  display: block;
  width: 100%;
  height: 70px;
}

.sparkline-tooltip {
  position: fixed;
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── Sale filter toggle ── */
.sale-filter {
  display: flex;
  gap: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem;
  width: fit-content;
  margin-bottom: 0.875rem;
}

.sale-filter-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.sale-filter-btn:hover  { color: var(--text); }
.sale-filter-btn.active { background: var(--red); color: #fff; }

.full-price-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0,0,0,0.65);
  color: var(--text-2);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Genre filters ── */
.genre-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.genre-pill {
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.genre-pill:hover {
  border-color: rgba(230, 0, 18, 0.5);
  color: var(--text);
}

.genre-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ── Load sentinel / spinner ── */
.load-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin-top: 0.5rem;
}

.load-spinner {
  display: none;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-2);
  font-size: 0.84rem;
}

.load-spinner.visible { display: flex; }

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Games section ── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.875rem;
}

.game-card {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.18s, border-color 0.18s;
  display: flex;
  flex-direction: column;
}
.game-card:hover {
  transform: translateY(-3px);
  border-color: rgba(230, 0, 18, 0.5);
}

.card-image {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: linear-gradient(135deg, #2c2c2e, #1c1c1e);
  flex-shrink: 0;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-info {
  padding: 0.625rem 0.75rem 0.75rem;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.discount-badge {
  position: absolute;
  top: -1.25rem;
  right: 0.5rem;
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.game-card h3 {
  font-size: 0.84rem;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0.35rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.prices {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: auto;
}

.price-now {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--green);
}

.price-was {
  font-size: 0.72rem;
  color: var(--text-2);
  text-decoration: line-through;
}

.game-meta {
  font-size: 0.68rem;
  color: var(--text-2);
  margin-top: 0.3rem;
  text-transform: capitalize;
}

/* ── Error banner ── */
.error-banner {
  background: rgba(230, 0, 18, 0.08);
  border: 1px solid rgba(230, 0, 18, 0.25);
  color: #ff4444;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.84rem;
  display: none;
}

/* ── Modal ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.open { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background 0.15s;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.8); }

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.modal-banner {
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.modal-banner.is-loading {
  height: 200px;
  background: linear-gradient(90deg, var(--card) 25%, var(--border) 50%, var(--card) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.modal-banner img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  background: var(--card);
}

.strip-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--text-2);
  font-size: 0.78rem;
  width: 100%;
}

.strip-error {
  padding: 0.75rem 1rem;
  color: var(--text-2);
  font-size: 0.78rem;
  font-style: italic;
}

.nintendo-error {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
}

.nintendo-error-gif {
  width: 240px;
  max-width: 100%;
  border-radius: var(--radius);
}

.nintendo-error-text {
  color: var(--text-2);
  font-size: 1rem;
}

.modal-image-strip {
  display: flex;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  overflow-x: auto;
  scrollbar-width: thin;
}

.modal-image-strip:empty { display: none; }

.strip-thumb {
  flex-shrink: 0;
  width: 80px;
  height: 52px;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.55;
  transition: opacity 0.15s, border-color 0.15s;
}

.strip-thumb.active {
  border-color: var(--red);
  opacity: 1;
}

.strip-thumb:hover { opacity: 0.85; }

.strip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.modal-publisher {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-top: 0.2rem;
}

.modal-rating {
  background: rgba(142, 142, 147, 0.08);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.modal-categories {
  font-size: 0.8rem;
  color: var(--text-2);
  text-transform: capitalize;
}

.modal-description {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}

.modal-features {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.feature-pill {
  background: rgba(142, 142, 147, 0.08);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.72rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.modal-prices {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.modal-price-now {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--green);
}

.modal-price-was {
  font-size: 0.9rem;
  color: var(--text-2);
  text-decoration: line-through;
}

/* Make game cards look clickable */
.game-card { cursor: pointer; }

.loading-text {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-2);
  padding: 3rem 0;
  font-size: 0.9rem;
}

/* ── Wishlist section ── */
.wishlist-section { }

#wishlist-signup {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.wishlist-signup-cta {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.wishlist-signup-label {
  font-size: 0.84rem;
  color: var(--text-2);
}

.wishlist-signup-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.wishlist-signup-form input[type=email] {
  flex: 1;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  color: var(--text);
  font-size: 0.84rem;
}

.wishlist-signup-form input[type=email]:focus {
  outline: none;
  border-color: var(--red);
}

.wishlist-signup-status {
  font-size: 0.78rem;
  min-height: 1rem;
}
.wishlist-signup-status.ok  { color: var(--green); }
.wishlist-signup-status.err { color: var(--red); }

.wishlist-signup-active {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.84rem;
  color: var(--text-2);
  flex-wrap: wrap;
}

.wishlist-signup-check {
  color: var(--green);
  font-weight: 700;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.btn-link:hover { color: var(--text); }

.wishlist-sale-label {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: rgba(52, 199, 89, 0.12);
  color: var(--green);
  border: 1px solid rgba(52, 199, 89, 0.3);
  display: none;
}

.wishlist-sale-label.visible { display: inline-block; }

.game-card.not-on-sale { opacity: 0.45; }
.game-card.not-on-sale:hover { opacity: 0.75; }

.on-sale-ribbon {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--green);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ── Heart / wishlist button on cards ── */
.wishlist-toggle {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0,0,0,0.55);
  border: none;
  color: var(--text-2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}

.wishlist-toggle:hover         { background: rgba(0,0,0,0.8); color: var(--text); }
.wishlist-toggle.wishlisted    { color: var(--red); background: rgba(0,0,0,0.7); }

.wishlist-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.wishlist-card:hover .wishlist-remove { opacity: 1; }
.wishlist-remove:hover { background: var(--red); }

/* card-image needs relative positioning for the button overlay */
.card-image { position: relative; }

/* Modal actions row */
.modal-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .site-header { padding: 0.875rem 1rem; }
  main { padding: 1rem; }
  .hero { grid-template-columns: 1fr; }
  .last-updated { display: none; }

  .modal-banner img { height: 160px; }
  .platform-counts { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
}
