/* ===== PriceRadar design tokens: change these to restyle the whole app ===== */
:root {
  /* Moody navy */
  --bg: #0a0f1e;
  --surface: #111a30;
  --surface-2: #18233f;
  --border: #22304f;
  /* Text */
  --text: #eef1f7;
  --text-2: #a3aec6;
  --text-3: #6f7b96;
  /* Neon orange */
  --accent: #ff9a3c;
  --accent-hover: #ffb066;
  --accent-text: #1a0d02;
  --accent-glow: rgba(255, 140, 50, 0.45);
  --accent-tint: rgba(255, 154, 60, 0.09);
  --good: #4ade80;
  --good-bg: rgba(74, 222, 128, 0.12);
  /* Chart */
  --series-1: #3987e5; /* official stores */
  --series-2: #ff9a3c; /* resellers */
  --chart-surface: #111a30;
  --grid: #1f2b48;
  /* Shape + type */
  --radius: 8px;
  --radius-sm: 5px;
  --gap: 16px;
  --font: "Space Grotesk", system-ui, "Segoe UI", sans-serif;
  --font-display: "Unbounded", "Segoe UI Black", sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(255, 140, 50, 0.07), transparent 70%),
    radial-gradient(800px 600px at -10% 10%, rgba(57, 135, 229, 0.06), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font: 700 24px/1.2 var(--font-display); letter-spacing: -0.01em; }
h2 { font: 600 17px/1.3 var(--font-display); letter-spacing: -0.01em; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.mono { font-family: var(--font-mono); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--accent-text); }

button, .btn {
  font: 500 14px var(--font);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--text); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); box-shadow: 0 0 18px var(--accent-glow); }
button:disabled { opacity: .6; cursor: default; }
input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
input[type="checkbox"] { accent-color: var(--accent); }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--gap); flex-wrap: wrap;
  padding: 12px 24px;
  /* Room for the iPhone notch / status bar when installed as an app */
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  background: rgba(10, 15, 30, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font: 800 18px var(--font-display); color: var(--text); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.brand:hover { color: var(--text); }
.search { display: flex; gap: 8px; flex: 1 1 260px; max-width: 480px; }
.search input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 13px; }
.nav { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.nav a { color: var(--text-2); font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--accent); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: var(--accent-text);
  font: 700 11px/18px var(--font-mono); text-align: center;
}
body.home .topbar .search { display: none; }

/* ===== Layout ===== */
.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 72px; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.empty { text-align: center; padding: 40px 16px; color: var(--text-3); }
.error { color: #ff7a6b; }
.loading { color: var(--text-3); padding: 24px 0; font-family: var(--font-mono); font-size: 13px; }
.loading::before { content: "> "; color: var(--accent); }

/* Small uppercase mono label, e.g. "■ AAA DEALS — BIGGEST DISCOUNTS" */
.eyebrow {
  font: 500 12px var(--font-mono);
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--text-3);
  display: flex; align-items: center; gap: 12px;
  margin: 0;
}
.eyebrow::before { content: ""; width: 8px; height: 8px; background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); flex: none; }
.eyebrow-link { font: 500 12px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }

/* ===== Home hero ===== */
.hero { padding: 24px 0 8px; }
.hero-label {
  font: 600 12px var(--font-mono);
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px 6px;
}
.wordmark {
  font: 900 clamp(46px, 11vw, 124px)/0.95 var(--font-display);
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--text);
}
.wordmark span { color: var(--accent); text-shadow: 0 0 28px var(--accent-glow), 0 0 4px rgba(255, 154, 60, .6); }
.hero-sub { color: var(--text-2); max-width: 520px; margin: 20px 0 32px; font-size: 16px; }
.hero-search { position: relative; }
.hero-search input {
  width: 100%;
  padding: 18px 20px;
  font: 400 18px var(--font-mono);
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 0 22px var(--accent-glow), inset 0 0 12px rgba(255, 140, 50, .06);
}
.hero-search input::placeholder { color: var(--text-3); }
.hero-search input:focus { box-shadow: 0 0 30px var(--accent-glow), inset 0 0 12px rgba(255, 140, 50, .08); }

/* ===== Deal cards ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--gap); }
.deal-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.deal-card:hover { color: var(--text); border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, .35), 0 0 16px rgba(255, 140, 50, .15); }
.deal-img { position: relative; aspect-ratio: 460 / 215; background: var(--surface-2); }
.deal-img img { width: 100%; height: 100%; object-fit: cover; }
.deal-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--accent); color: var(--accent-text);
  font: 700 12px var(--font-mono);
  padding: 2px 7px; border-radius: 3px;
  box-shadow: 0 0 10px var(--accent-glow);
}
.deal-body { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; flex: 1; }
.deal-body .title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.deal-body .price-row { margin-top: auto; }
.deal-body .store { font: 400 11px var(--font-mono); color: var(--text-3); letter-spacing: .04em; }

.price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font: 700 18px var(--font-mono); color: var(--accent); }
.old { font: 400 13px var(--font-mono); color: var(--text-3); text-decoration: line-through; }
.off { font: 700 12px var(--font-mono); color: var(--accent); }

/* ===== Lists (search results) ===== */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 14px; color: var(--text); padding: 10px 14px; transition: border-color .15s; }
.list-item:hover { color: var(--text); border-color: var(--accent); }
.list-item img { width: 120px; flex: none; aspect-ratio: 231 / 87; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .price { font-size: 16px; }

/* ===== Game page ===== */
.game-head { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.game-head img { width: 300px; max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.game-head h1 { font-size: 30px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); margin-top: 24px; }
.tile .label { font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.tile .value { font: 700 26px var(--font-mono); color: var(--accent); margin: 6px 0 2px; }
.wish-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wish-form input { width: 120px; font-family: var(--font-mono); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.num strong { font-family: var(--font-mono); }
tbody tr:hover td { background: rgba(255, 255, 255, .02); }
.best td { background: var(--accent-tint); }
.best td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 3px;
  background: var(--surface-2); color: var(--text-2);
  font: 500 11px var(--font-mono); white-space: nowrap;
}
.tag.match { background: var(--good-bg); color: var(--good); }
.store-name { display: flex; align-items: center; gap: 8px; }
.store-name img { width: 16px; height: 16px; }
.hit { color: var(--good); font-weight: 600; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 20px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font: 500 11px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ===== Price alerts ===== */
.accent { color: var(--accent); }
button.link {
  background: none; border: none; padding: 4px 0;
  color: var(--text-3); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
button.link:hover { color: var(--accent); box-shadow: none; }
button.big { padding: 12px 20px; font-size: 15px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); font: 500 12px var(--font-mono); white-space: nowrap;
}
.pill.hit { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 12px rgba(255, 140, 50, .2); }

/* Segmented control: [All-time low | My price] */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.seg button { border: none; background: none; padding: 6px 12px; font-size: 13px; color: var(--text-2); border-radius: 3px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.target-input { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.target-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.target-input input { border: none; background: none; width: 110px; font-family: var(--font-mono); box-shadow: none !important; }
.target-input span { padding: 0 10px 0 2px; font: 500 12px var(--font-mono); color: var(--text-3); }
.small-input input { width: 84px; padding: 5px 8px; font-size: 13px; }

/* Alert box on the game page */
.alert-card { border-color: var(--border); background: linear-gradient(135deg, rgba(255, 140, 50, .06), transparent 50%), var(--surface); }
.alert-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.alert-icon {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center;
  border-radius: 50%; border: 2px solid var(--border); color: var(--text-3); font-size: 22px;
}
.alert-icon.on { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 16px var(--accent-glow); }
.alert-text { flex: 1 1 280px; min-width: 0; }
.alert-text .eyebrow { margin-bottom: 6px; }
.alert-text h2 { margin-bottom: 6px; }
.alert-text .rule { font-family: var(--font-mono); color: var(--accent); margin-left: 6px; }
.alert-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.target-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.target-form label { color: var(--text-2); font-size: 14px; }

/* Wishlist page */
.wish-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.wish-header .eyebrow { margin-bottom: 8px; }
.wish-header h1 { font-size: 34px; margin: 0; }
.wish-options { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; font-size: 14px; color: var(--text-2); }
.wish-options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.wish-list { display: flex; flex-direction: column; gap: 12px; }
.wish-item {
  display: grid; grid-template-columns: 200px 1fr auto; gap: 20px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 18px 12px 12px; transition: border-color .15s;
}
.wish-item:hover { border-color: #33456e; }
.wish-item.is-hit { border-color: var(--accent); box-shadow: 0 0 20px rgba(255, 140, 50, .14); background: linear-gradient(90deg, var(--accent-tint), transparent 60%), var(--surface); }
.wish-cover img { width: 100%; aspect-ratio: 460 / 215; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.wish-main { min-width: 0; }
.wish-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.wish-title { color: var(--text); font-weight: 600; font-size: 16px; }
.wish-title:hover { color: var(--accent); }
.wish-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat .label, .wish-side .label { font: 500 10px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
.stat .val { font: 700 16px var(--font-mono); color: var(--text); }
.stat .val a { color: var(--accent); }
.stat .sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wish-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

/* ===== Chart ===== */
.chart { position: relative; background: var(--chart-surface); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis text { fill: var(--text-3); font: 11px var(--font-mono); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--chart-surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .end-label { font-size: 12px; fill: var(--text-2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); white-space: nowrap;
}
.tooltip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); }
details summary { cursor: pointer; color: var(--text-2); }

/* ===== Toasts ===== */
.toasts { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: calc(100vw - 32px); }
.toast {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}

@media (max-width: 640px) {
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .page { padding: 20px 16px 64px; }
  .nav { margin-left: 0; width: 100%; }
  .list-item img { width: 84px; }
  .tile .value { font-size: 22px; }
  .hero-search input { font-size: 15px; padding: 15px 16px; }
  .game-head h1 { font-size: 22px; }
  .alert-actions { align-items: stretch; width: 100%; }
  .alert-actions .link { align-self: center; }
  .wish-item { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .wish-side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .wish-side .label { width: 100%; }
}
