:root {
  --primary: #EBC01C;
  --primary-dark: #c9a418;
  --primary-light: #fdf3c0;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e5e5e5;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --max-w: 1100px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; }
a { color: inherit; }

/* ── Header ── */
header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo-link { display: flex; align-items: center; text-decoration: none; }
.logo-img { height: 40px; width: auto; max-width: 220px; object-fit: contain; display: block; }
@media (max-width: 640px) { .logo-img { height: 32px; max-width: 160px; } }
.header-nav { display: flex; gap: 20px; }
.header-nav a {
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  opacity: .8;
  transition: opacity .15s;
}
.header-nav a:hover { opacity: 1; }

.header-accent {
  height: 4px;
  background: var(--primary);
}

/* ── Footer ── */
footer {
  background: var(--primary);
  color: var(--text);
  text-align: center;
  padding: 28px 24px;
  font-size: .85rem;
}

/* ── Search box ── */
.search-box {
  display: flex;
  gap: 8px;
}
.search-box input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.search-box input:focus {
  border-color: var(--primary);
}
.btn-primary {
  background: var(--primary);
  color: var(--text);
  border: none;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover { background: var(--primary-dark); }

/* ── Hero (homepage) ── */
.hero {
  text-align: center;
  padding: 90px 24px 70px;
  max-width: 680px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
}
.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 36px;
}
.shops-badge {
  margin-top: 20px;
  font-size: .85rem;
  color: var(--text-muted);
}
.shops-badge strong { color: var(--text); }

/* ── Cerca page layout ── */
.search-section {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.search-section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.results-section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 24px 60px;
}

/* Mobile filter toggle — hidden on desktop via media query */
.filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  color: var(--text);
}

/* Results layout: sidebar + main */
.results-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.results-main { flex: 1; min-width: 0; }

/* ── Filters panel ── */
.filters-panel {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 74px;
  overflow: hidden;
}
.filters-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.filters-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.filter-close-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.filter-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .88rem;
  cursor: pointer;
  color: var(--text);
}
.checkbox-label input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.shop-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-muted);
  background: #f3f3f3;
  border-radius: 20px;
  padding: 1px 7px;
}
.shop-row { display: flex; align-items: center; gap: 4px; }
.shop-row .checkbox-label { flex: 1; }
.shop-loading {
  width: 11px; height: 11px; flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.shop-loading[hidden] { display: none; }
.shop-only-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity .15s;
}
.shop-row:hover .shop-only-btn { opacity: 1; }
.shop-only-btn:hover { background: var(--primary-light); color: var(--text); }
.price-row { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.price-bound-label { font-size: .78rem; color: var(--text-muted); width: 20px; flex-shrink: 0; }
.price-row input[type=range] { accent-color: var(--primary); flex: 1; min-width: 0; width: 0; }
.price-val { font-weight: 700; font-size: .85rem; min-width: 44px; text-align: right; flex-shrink: 0; }

/* Mobile backdrop */
.filter-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
}
.filter-backdrop.is-visible { display: block; }

/* ── Result cards ── */
.result-count {
  font-size: .9rem;
  color: var(--text-muted);
}
.results-list { display: flex; flex-direction: column; gap: 10px; }
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  transition: box-shadow .15s;
}
.result-card:hover { box-shadow: var(--shadow); }
.result-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--bg);
}
.result-thumb-empty {
  width: 72px;
  height: 72px;
  background: #f8f8f8;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.result-body { min-width: 0; }
.result-shop {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.result-name {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-offer {
  display: inline-block;
  background: var(--primary-light);
  color: #7a5f00;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}
.result-pricing {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 140px;
}
.result-price {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}
.result-shipping { font-size: .78rem; color: var(--text-muted); }
.result-shipping.free { color: #2e7d32; font-weight: 600; }
.btn-buy {
  margin-top: 8px;
  background: var(--primary);
  color: var(--text);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 700;
  transition: background .15s;
  white-space: nowrap;
  display: inline-block;
}
.btn-buy:hover { background: var(--primary-dark); }

/* ── Results topbar ── */
.results-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  min-height: 28px;
}
.results-topbar .result-count { margin-bottom: 0; }
.sort-info-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: .78rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.sort-info-btn:hover { border-color: var(--primary-dark); color: var(--text); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--border); }
.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.modal-box p {
  font-size: .92rem;
  color: var(--text-muted);
  line-height: 1.65;
}
.modal-box p strong { color: var(--text); }

/* ── Loading / states ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 70px 24px;
  color: var(--text-muted);
}
.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.no-results {
  text-align: center;
  padding: 70px 24px;
  color: var(--text-muted);
}
.error-msg {
  background: #fdecea;
  border: 1px solid #f44336;
  color: #c62828;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ── Game detail page ── */
.game-detail {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.game-header {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
.game-cover {
  width: 220px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.game-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 4px;
  line-height: 1.2;
}
.game-year { color: var(--text-muted); margin-bottom: 24px; font-size: .95rem; }
.game-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  min-width: 80px;
}
.stat span {
  display: block;
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}
.stat strong { font-size: 1.1rem; font-weight: 800; }
.btn-search-game {
  display: inline-block;
  background: var(--primary);
  color: var(--text);
  text-decoration: none;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  transition: background .15s;
}
.btn-search-game:hover { background: var(--primary-dark); }
.game-description { margin-top: 32px; }
.game-description h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.game-description p {
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 760px;
}

/* ── Come funziona ── */
.come-funziona {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.come-funziona-header {
  text-align: center;
  margin-bottom: 40px;
}
.come-funziona-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  margin-bottom: 12px;
}
.come-funziona-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}
.come-funziona-infographic { margin-bottom: 40px; }
.come-funziona-infographic img { display: block; width: 100%; height: auto; }
.come-funziona-cta { text-align: center; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .filter-toggle { display: flex; }
  .filters-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    z-index: 200;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .filters-panel.is-open { transform: translateX(0); }
  .filter-close-btn { display: block; }
  .filters-head { margin-bottom: 4px; }
}

@media (min-width: 769px) {
  /* Prevent JS from showing the toggle on desktop */
  .filter-toggle { display: none !important; }
}

@media (max-width: 640px) {
  .result-card { grid-template-columns: 56px 1fr; }
  .result-pricing {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .game-header { grid-template-columns: 1fr; }
  .game-cover { width: 160px; }
  .search-box { flex-direction: column; }
  .hero { padding: 50px 20px 40px; }
}

/* ── Cookie banner ── */
#cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 9999;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
  font-size: 13px;
  flex-wrap: wrap;
}
#cookie-banner p { flex: 1; min-width: 200px; color: var(--text-muted); margin: 0; }
.cookie-actions { display: flex; gap: 8px; }
#cookie-accept, #cookie-decline {
  padding: 6px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border: none;
}
#cookie-accept { background: var(--primary); color: var(--text); }
#cookie-accept:hover { background: var(--primary-dark); }
#cookie-decline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
#cookie-decline:hover { border-color: var(--text-muted); color: var(--text); }
