/* ---------- Base layout ---------- */

:root {
  --bg-0: #020102;
  --bg-1: #0d0304;
  --bg-2: #170405;
  --shell-red: rgba(176, 12, 18, 0.82);
  --shell-red-dark: rgba(70, 0, 4, 0.94);
  --shell-red-soft: rgba(255, 92, 92, 0.18);
  --shell-edge: rgba(255, 145, 145, 0.44);
  --screen-bg: rgba(8, 5, 6, 0.95);
  --screen-edge: rgba(255, 108, 108, 0.45);
  --screen-glow: rgba(255, 63, 63, 0.18);
  --text-strong: #fff7f7;
  --text-main: #f3dede;
  --text-soft: #d8b1b1;
  --text-muted: #a97d7d;
  --accent: #ff5454;
  --accent-2: #ff8d6a;
  --accent-deep: #4d0505;
  --link: #ffb0b0;
  --card-bg: #f4f2ef;
  --card-border: rgba(128, 18, 18, 0.62);
  --card-text: #161012;
  --shadow-1: rgba(0, 0, 0, 0.45);
  --shadow-2: rgba(0, 0, 0, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 26%, rgba(117, 11, 15, 0.36), transparent 26%),
    linear-gradient(135deg, #260605 0%, #100807 42%, #220504 100%);
  color: var(--text-main);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 87%, rgba(203, 21, 26, 0.16) 87% 100%) 0 0 / 96px 96px,
    linear-gradient(0deg, transparent 0 82%, rgba(203, 21, 26, 0.14) 82% 100%) 0 0 / 96px 96px,
    linear-gradient(45deg, transparent 0 47%, rgba(171, 13, 19, 0.18) 47% 53%, transparent 53% 100%) 76vw 0 / 240px 240px,
    repeating-linear-gradient(0deg, rgba(255, 31, 45, 0.025) 0 1px, transparent 1px 6px);
  opacity: 0.85;
  image-rendering: pixelated;
}

/* Root wrapper so we can center things nicely */
.app-root {
  position: relative;
  height: calc(100dvh - 20px);
  min-height: 740px;
  width: min(1122px, calc(100vw - 20px));
  margin: 10px auto;
  padding: clamp(10px, 1.6vw, 18px) clamp(10px, 1.6vw, 18px) clamp(118px, 12vw, 166px);
  border-radius: clamp(24px, 3vw, 38px);
  background:
    radial-gradient(circle at 12% 90%, rgba(255, 23, 28, 0.38), transparent 12%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 12% 35%, rgba(255, 255, 255, 0.1) 36% 37%, transparent 38% 82%, rgba(255, 255, 255, 0.13)),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08), transparent 50%),
    repeating-linear-gradient(90deg, transparent 0 30px, rgba(255, 255, 255, 0.08) 31px 33px, transparent 34px 122px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 7px),
    rgba(187, 10, 17, 0.72);
  border: 1px solid var(--shell-edge);
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.72),
    inset 0 0 0 5px rgba(255, 130, 134, 0.2),
    inset 0 0 0 11px rgba(94, 4, 8, 0.45),
    inset 0 0 45px rgba(255, 20, 34, 0.52),
    inset 0 -24px 46px rgba(0, 0, 0, 0.28),
    0 0 42px rgba(255, 32, 32, 0.16);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.app-root > * {
  position: relative;
  z-index: 1;
}

.app-root::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 42px 34px, rgba(255, 92, 92, 0.55) 0 8px, rgba(65, 4, 5, 0.55) 9px 16px, transparent 17px),
    radial-gradient(circle at calc(100% - 42px) 34px, rgba(255, 92, 92, 0.48) 0 8px, rgba(65, 4, 5, 0.54) 9px 16px, transparent 17px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 8% 90%, rgba(255, 255, 255, 0.14)),
    linear-gradient(0deg, rgba(255, 255, 255, 0.1), transparent 18% 80%, rgba(255, 255, 255, 0.18));
  opacity: 0.62;
}

.app-root::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.02), transparent 20%),
    radial-gradient(circle at 20% 80%, rgba(255, 83, 83, 0.08), transparent 18%),
    radial-gradient(circle at 84% 18%, rgba(255, 83, 83, 0.08), transparent 16%);
}

.device-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.device-shell::before,
.device-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.device-shell::before {
  inset: 18px 18px auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  opacity: 0.45;
}

.device-shell::after {
  inset: auto 18px 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 120, 120, 0.25), transparent);
  opacity: 0.5;
}

.device-shell-led {
  position: absolute;
  left: clamp(18px, 2vw, 34px);
  bottom: clamp(84px, 9vw, 126px);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #fff9d5 0 12%, #ffaf4d 24%, #ff4a4a 44%, #8b0000 74%, #340000 100%);
  box-shadow:
    0 0 8px rgba(255, 90, 90, 0.95),
    0 0 22px rgba(255, 46, 46, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  animation: powerPulse 1.9s ease-in-out infinite;
}

.device-shell-led-label {
  position: absolute;
  left: clamp(38px, 3vw, 56px);
  bottom: clamp(82px, 9vw, 124px);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffdede;
  text-shadow: 0 0 10px rgba(255, 96, 96, 0.3);
}

.device-shell-pokeball {
  position: absolute;
  top: clamp(16px, 2vw, 24px);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #111 0 2px, transparent 2px),
    linear-gradient(180deg, #fff 0 50%, #d11a1a 50% 100%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 0 12px rgba(255, 56, 56, 0.34);
}

.device-shell-pokeball::before {
  content: "";
  position: absolute;
  inset: 7px 0 auto;
  height: 3px;
  background: #111;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.device-shell-pokeball::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.device-shell-pokeball-left {
  left: clamp(20px, 2vw, 36px);
}

.device-shell-pokeball-right {
  right: clamp(20px, 2vw, 36px);
}

.device-shell-dpad {
  position: absolute;
  left: clamp(84px, 8vw, 118px);
  bottom: clamp(36px, 4vw, 68px);
  width: 78px;
  height: 78px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 50%, #030000 0 7px, #1f0101 8px 13px, transparent 14px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 24%),
    linear-gradient(180deg, #1f0000, #050000);
  box-shadow:
    inset 0 1px 0 rgba(255, 134, 134, 0.18),
    inset 0 -6px 12px rgba(0, 0, 0, 0.72),
    0 0 0 1px rgba(255, 62, 62, 0.22),
    0 7px 14px rgba(0, 0, 0, 0.52),
    0 0 24px rgba(255, 44, 44, 0.18);
}

.device-shell-dpad::before,
.device-shell-dpad::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 79, 79, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 25%),
    linear-gradient(180deg, #2b0101, #080000);
  box-shadow:
    inset 0 1px 0 rgba(255, 120, 120, 0.16),
    inset 0 -5px 7px rgba(0, 0, 0, 0.58),
    0 2px 4px rgba(0, 0, 0, 0.45);
}

.device-shell-dpad::before {
  left: 50%;
  top: 8px;
  width: 22px;
  height: 62px;
  transform: translateX(-50%);
  border-radius: 8px;
}

.device-shell-dpad::after {
  left: 8px;
  top: 50%;
  width: 62px;
  height: 22px;
  transform: translateY(-50%);
  border-radius: 8px;
}

.device-shell-button {
  position: absolute;
  bottom: clamp(56px, 6vw, 88px);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 121, 121, 0.46);
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 145, 145, 0.34), transparent 19%),
    radial-gradient(circle at 58% 64%, rgba(0, 0, 0, 0.86), transparent 58%),
    linear-gradient(180deg, #640606, #160000 74%);
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.55),
    inset 0 8px 11px rgba(255, 58, 58, 0.1),
    inset 0 -8px 12px rgba(0, 0, 0, 0.72),
    0 0 0 2px rgba(0, 0, 0, 0.78),
    0 8px 16px rgba(0, 0, 0, 0.48),
    0 0 22px rgba(255, 56, 56, 0.22);
}

.device-shell-button::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 205, 205, 0.82);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 1.38rem;
  font-weight: 700;
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(255, 86, 86, 0.28);
}

.device-shell-button-a {
  right: clamp(132px, 11vw, 190px);
}

.device-shell-button-a::after {
  content: "A";
}

.device-shell-button-b {
  right: clamp(196px, 16vw, 270px);
}

.device-shell-button-b::after {
  content: "B";
}

.device-shell-button-select,
.device-shell-button-start {
  bottom: clamp(18px, 2vw, 36px);
  width: 40px;
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(180deg, #340000, #150000);
}

.device-shell-button-select {
  right: clamp(172px, 16vw, 248px);
}

.device-shell-button-select::after {
  content: "SELECT";
  inset: auto auto -22px 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
}

.device-shell-button-start {
  right: clamp(116px, 11vw, 182px);
}

.device-shell-button-start::after {
  content: "START";
  inset: auto auto -22px 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
}

.device-shell-speaker {
  position: absolute;
  right: clamp(22px, 2vw, 44px);
  bottom: clamp(18px, 2vw, 40px);
  width: clamp(66px, 7vw, 92px);
  height: clamp(62px, 6vw, 88px);
  border-radius: 16px;
  background:
    radial-gradient(circle, rgba(5, 0, 0, 0.98) 0 2px, transparent 2.5px) 7px 7px / 11px 11px,
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 22%),
    linear-gradient(180deg, #210000, #060000);
  box-shadow:
    inset 0 0 0 1px rgba(255, 96, 96, 0.16),
    inset 0 0 14px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(0, 0, 0, 0.7),
    0 8px 16px rgba(0, 0, 0, 0.42);
  opacity: 0.9;
}

/* ---------- Hero / header ---------- */

.app-header {
  flex: 0 0 auto;
  padding: 16px 6px 18px;
}

.app-header-inner {
  position: relative;
  max-width: 960px;
  min-height: 108px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 18px 132px;
  border-radius: 24px;
  border: 1px solid rgba(255, 116, 116, 0.34);
  background:
    linear-gradient(180deg, rgba(20, 0, 0, 0.86), rgba(0, 0, 0, 0.94)),
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.08), transparent 26%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 0 0 7px rgba(0, 0, 0, 0.68),
    inset 0 0 24px rgba(255, 61, 61, 0.1),
    0 14px 34px rgba(0, 0, 0, 0.42);
}

.app-header-inner::before,
.app-header-inner::after {
  content: "";
  position: absolute;
  top: 32px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #f8f8f8 0 2px, #101010 2px 4px, transparent 4px),
    linear-gradient(180deg, #f6f6f6 0 46%, #111 46% 56%, #cf1717 56% 100%);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow:
    28px 0 0 -1px rgba(0, 0, 0, 0.9),
    28px 0 0 0 rgba(255, 255, 255, 0.2),
    56px 0 0 -1px rgba(207, 23, 23, 0.95),
    84px 0 0 -1px rgba(0, 0, 0, 0.9),
    0 0 12px rgba(255, 58, 58, 0.3);
}

.app-header-inner::before {
  left: 34px;
}

.app-header-inner::after {
  right: 118px;
}

/* Little logo pill on the left */
.logo-pill {
  position: absolute;
  left: 28px;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 45%),
    linear-gradient(180deg, rgba(69, 0, 0, 0.95), rgba(19, 0, 0, 0.96));
  border: 1px solid rgba(255, 126, 126, 0.45);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 0 18px rgba(255, 56, 56, 0.14);
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, #ff8a8a, #ff3030, #5a0000, #ff8a8a);
}

.logo-text {
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-strong);
}

.hero-text {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: min(330px, 100%);
  min-height: 56px;
  padding: 8px 26px 7px;
  align-items: center;
  text-align: center;
  border-radius: 8px;
  border: 2px solid #df1d26;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 7px, 100% 7px, 100% calc(100% - 7px), calc(100% - 8px) calc(100% - 7px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 7px), 0 calc(100% - 7px), 0 7px, 8px 7px);
  background:
    linear-gradient(180deg, rgba(7, 4, 4, 0.94), rgba(0, 0, 0, 0.96)),
    repeating-linear-gradient(90deg, rgba(255, 46, 46, 0.14) 0 3px, transparent 3px 7px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 36%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 0 18px rgba(255, 44, 44, 0.1),
    0 0 18px rgba(255, 50, 50, 0.18);
}

.hero-text::before,
.hero-text::after {
  content: "";
  position: absolute;
  top: 15px;
  width: 18px;
  height: 23px;
  background:
    linear-gradient(#e3222d 0 0) 0 0 / 6px 5px no-repeat,
    linear-gradient(#e3222d 0 0) 6px 5px / 6px 5px no-repeat,
    linear-gradient(#e3222d 0 0) 12px 10px / 6px 5px no-repeat,
    linear-gradient(#e3222d 0 0) 6px 15px / 6px 5px no-repeat,
    linear-gradient(#e3222d 0 0) 0 20px / 6px 5px no-repeat;
}

.hero-text::before {
  left: 8px;
}

.hero-text::after {
  right: 8px;
  transform: scaleX(-1);
}

.page-title {
  margin: 0;
  font-size: 1.42rem;
  font-weight: 900;
  letter-spacing: 0;
  color: #fff8f8;
  text-transform: uppercase;
  font-family: "Courier New", ui-monospace, monospace;
  line-height: 0.92;
  text-shadow: 2px 2px 0 #000;
}

.page-subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-soft);
  max-width: 520px;
}

@media (min-width: 768px) {
  .page-title {
    font-size: 1.55rem;
  }
}

/* ---------- Main content ---------- */

main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 970px;
  width: calc(100% - 42px);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 18px);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 112, 112, 0.06), transparent 20%),
    linear-gradient(180deg, rgba(5, 4, 5, 0.98), rgba(0, 0, 0, 0.99));
  border: 4px solid #0d0e0d;
  border-radius: 24px;
  box-shadow:
    inset 0 0 0 2px #cd1b22,
    inset 0 0 0 7px #030303,
    0 0 0 3px rgba(255, 50, 60, 0.55),
    inset 0 0 34px var(--screen-glow),
    0 14px 32px rgba(0, 0, 0, 0.85);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  contain: paint;
  will-change: scroll-position;
  scrollbar-color: rgba(255, 74, 74, 0.72) rgba(9, 2, 3, 0.88);
  scrollbar-width: thin;
}

main::-webkit-scrollbar {
  width: 9px;
}

main::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(8, 1, 2, 0.88);
  box-shadow: inset 0 0 0 1px rgba(255, 75, 75, 0.12);
}

main::-webkit-scrollbar-thumb {
  border: 2px solid rgba(8, 1, 2, 0.88);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 135, 135, 0.95), rgba(151, 8, 13, 0.95));
  box-shadow: 0 0 10px rgba(255, 42, 42, 0.28);
}

main::-webkit-scrollbar-corner {
  background: transparent;
}

main::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 16%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.02), transparent 24%, transparent 78%, rgba(255, 80, 80, 0.02));
  opacity: 0.75;
}

main > * {
  position: relative;
  z-index: 1;
}

/* ---------- Toolbar: sticky search + filters + sort ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 0 14px;
  background: linear-gradient(to bottom, rgba(3, 1, 2, 0.98), rgba(3, 1, 2, 0.92));
  border-bottom: 1px solid rgba(255, 110, 110, 0.2);
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
  min-width: 0;
}

.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Game toggle buttons */

.game-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(10, 5, 6, 0.88);
  border: 1px solid rgba(255, 115, 115, 0.42);
  box-shadow: inset 0 0 12px rgba(255, 80, 80, 0.08);
}

.toggle-btn {
  border: none;
  background: transparent;
  color: #eecfcf;
  font-size: 0.74rem;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.toggle-btn:hover {
  background-color: rgba(255, 92, 92, 0.24);
  transform: translateY(-1px);
}

.toggle-active {
  background: linear-gradient(to right, #ff5a5a, #9f0000);
  color: #fff8f8;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 14px rgba(255, 62, 62, 0.22);
}

/* Search input */

#searchInput {
  flex: 1 1 160px;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 109, 109, 0.48);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 20%),
    rgba(9, 5, 6, 0.95);
  color: var(--text-strong);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease,
    background-color 120ms ease;
}

#searchInput::placeholder {
  color: #c78f8f;
}

#searchInput:focus {
  border-color: #ff7979;
  box-shadow: 0 0 0 1px rgba(255, 121, 121, 0.34), 0 0 16px rgba(255, 70, 70, 0.12);
  background-color: #060304;
}

/* Sort dropdown + last updated */

.sort-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

#sortSelect {
  padding: 5px 28px 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 111, 111, 0.48);
  background: rgba(9, 5, 6, 0.96);
  color: var(--text-strong);
  font-size: 0.78rem;
}

#lastUpdated {
  font-size: 0.72rem;
  color: var(--text-soft);
}

/* ---------- Products grid container ---------- */

/* Vertical stack of groups (heading + subgrid) */
#productsGrid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Group heading (e.g., Pokémon / MTG) */
.products-group-title {
  margin: 14px 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffd3d3;
  text-shadow: 0 0 10px rgba(255, 70, 70, 0.14);
}

/* Actual grid for the cards inside each group */
.products-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

/* Empty state */

#emptyState {
  margin-top: 40px;
  padding: 28px 20px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    rgba(8, 5, 6, 0.92);
  border: 1px dashed rgba(255, 121, 121, 0.62);
  text-align: center;
  color: #f0d0d0;
  font-size: 0.95rem;
}

.hidden {
  display: none;
}

/* ---------- Product cards ---------- */

.product-card {
  position: relative;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 190px 318px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 318px;
  min-height: 0;
  padding: 10px 9px 9px;
  border-radius: 3px;
  background: var(--card-bg);
  border: 2px solid #191919;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.86),
    2px 2px 0 #0b0b0b,
    0 7px 16px rgba(0, 0, 0, 0.32);
  transition: transform 130ms ease, box-shadow 130ms ease,
    background-color 130ms ease;
  overflow: hidden;
}

.product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  background:
    linear-gradient(#d51d28 0 0) left 2px top 0 / 9px 2px no-repeat,
    linear-gradient(#d51d28 0 0) left 0 top 2px / 2px 9px no-repeat,
    linear-gradient(#d51d28 0 0) right 2px top 0 / 9px 2px no-repeat,
    linear-gradient(#d51d28 0 0) right 0 top 2px / 2px 9px no-repeat,
    linear-gradient(#d51d28 0 0) left 2px bottom 0 / 9px 2px no-repeat,
    linear-gradient(#d51d28 0 0) left 0 bottom 2px / 2px 9px no-repeat,
    linear-gradient(#d51d28 0 0) right 2px bottom 0 / 9px 2px no-repeat,
    linear-gradient(#d51d28 0 0) right 0 bottom 2px / 2px 9px no-repeat,
    linear-gradient(#050505 0 0) left 8px top 0 / 2px 6px no-repeat,
    linear-gradient(#050505 0 0) right 8px top 0 / 2px 6px no-repeat,
    linear-gradient(#050505 0 0) left 8px bottom 0 / 2px 6px no-repeat,
    linear-gradient(#050505 0 0) right 8px bottom 0 / 2px 6px no-repeat;
  pointer-events: none;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 120, 120, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

/* ---------- Image treatment (white TCG backgrounds) ---------- */

.product-image {
  width: 100%;
  border-radius: 8px;
  background-color: #ffffff; /* keep this white so TCG images blend */
  padding: 8px;
  object-fit: contain;
  height: clamp(100px, 10vw, 122px);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35);
}

/* ---------- Text inside the card ---------- */

.product-name {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.22;
  color: var(--card-text);
}

/* Set chip + set text */

.set-chip {
  display: inline-block;
  margin-top: 2px;
  margin-bottom: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 700;
  background: linear-gradient(180deg, rgba(255, 237, 237, 0.98), rgba(249, 213, 213, 0.96));
  color: #961616;
  border: 1px solid rgba(191, 88, 88, 0.28);
}

.product-set {
  margin: 0;
  font-size: 0.62rem;
  color: #4e3333;
}

/* Price row */

.product-price-row {
  margin: 3px 0 0;
  font-size: 0.68rem;
  font-weight: 800;
  color: #1f1717;
}

/* Meta: updated timestamp */

.product-meta {
  margin: 0;
  font-size: 0.58rem;
  color: #7b5a5a;
}

.product-meta.price-stale {
  color: #a53b3b;
  font-weight: 600;
}

/* TCGplayer link */

.product-link {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.62rem;
  font-weight: 900;
  color: #a01212;
  text-decoration: none;
}

.product-link::after {
  content: "↗";
  font-size: 0.8em;
}

.product-link:hover {
  text-decoration: underline;
}

/* ---------- Footer ---------- */

.app-footer {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 12px;
  z-index: 2;
  width: min(520px, calc(100% - 392px));
  padding: 5px 10px;
  border: 1px solid rgba(255, 117, 117, 0.16);
  border-radius: 999px;
  background: rgba(5, 2, 3, 0.52);
  transform: translateX(-50%);
}

.app-footer p {
  max-width: 1120px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.app-footer a {
  color: var(--link);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ---------- Admin / status styles (admin.html) ---------- */

.admin-quick-add {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 113, 113, 0.22);
  border-radius: 12px;
  background: rgba(8, 5, 6, 0.74);
}

.set-intake {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 121, 121, 0.16);
}

.selected-set-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.selected-set-tools.hidden {
  display: none;
}

.quick-add-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(76px, 96px) minmax(100px, 126px) auto;
  gap: 10px;
  align-items: end;
}

.quick-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-size: 0.78rem;
  color: #f0d0d0;
}

.quick-field input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 112, 112, 0.26);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    rgba(7, 4, 5, 0.96);
  color: #fff7f7;
  font-size: 0.9rem;
}

.quick-field input::placeholder {
  color: #c99090;
}

.quick-field input:focus,
.quick-field select:focus {
  border-color: rgba(255, 127, 127, 0.68);
  box-shadow: 0 0 0 1px rgba(255, 127, 127, 0.24), 0 0 14px rgba(255, 74, 74, 0.1);
  outline: none;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-secondary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 20%),
    linear-gradient(180deg, #5a0808, #2f0202);
}

.button-secondary:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 20%),
    linear-gradient(180deg, #7a0f0f, #3d0303);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.barcode-upload-input {
  display: none;
}

.lookup-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(8, 5, 6, 0.78);
  border: 1px solid rgba(255, 112, 112, 0.18);
}

.lookup-preview img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
}

.lookup-preview-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff0f0;
}

.lookup-preview-details span {
  color: #e7bcbc;
  font-size: 0.85rem;
}

.lookup-results {
  display: grid;
  width: 100%;
  gap: 8px;
}

.lookup-result {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255, 111, 111, 0.22);
  border-radius: 10px;
  background: rgba(8, 5, 6, 0.9);
  color: #fff2f2;
  text-align: left;
  cursor: pointer;
}

.lookup-result:hover {
  background: rgba(44, 7, 7, 0.95);
}

.scanner-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scanner-panel video {
  width: min(100%, 420px);
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: #000000;
  border: 1px solid rgba(255, 112, 112, 0.22);
}

.status-message {
  margin-top: 10px;
  font-size: 0.9rem;
}

.status-message.success {
  color: #4ade80;
}

.status-message.error {
  color: #fca5a5;
}

/* Basic table styling for admin page */

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 0.9rem;
  color: #f4dede;
}

.admin-table th,
.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 117, 117, 0.12);
}

.admin-table th {
  text-align: left;
  font-weight: 600;
  color: #f0d8d8;
  background-color: rgba(8, 5, 6, 0.96);
}

.admin-table input {
  width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 112, 112, 0.22);
  font-size: 0.85rem;
  background-color: rgba(7, 4, 5, 0.96);
  color: #fff7f7;
}

.admin-table select {
  width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 112, 112, 0.22);
  font-size: 0.85rem;
  background-color: rgba(7, 4, 5, 0.96);
  color: #fff7f7;
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
  min-width: 220px;
}

.admin-table th:nth-child(2),
.admin-table td:nth-child(2) {
  min-width: 150px;
}

.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
  min-width: 120px;
}

.admin-table th:nth-child(7),
.admin-table th:nth-child(8),
.admin-table td:nth-child(7),
.admin-table td:nth-child(8) {
  white-space: nowrap;
}

.admin-updated-cell {
  min-width: 150px;
  color: #c58f8f;
  font-size: 0.78rem;
}

.admin-table button {
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  background: linear-gradient(180deg, #ff6969, #9e1111);
  color: #fff7f7;
}

.admin-table button:hover {
  background: linear-gradient(180deg, #ff7b7b, #b41818);
}

/* ---------- Generic button class (if needed) ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 14px;
  border: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(180deg, #ff6a6a, #a30e0e);
  color: #fff7f7;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.button:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 18%),
    linear-gradient(180deg, #ff7a7a, #bb1515);
}

@media (max-width: 860px) {
  .app-root {
    height: calc(100dvh - 12px);
    min-height: 720px;
    width: min(100vw - 12px, 1510px);
    margin: 6px auto;
    padding: 8px 8px 112px;
    border-radius: 24px;
  }

  .device-shell-led {
    left: 14px;
    bottom: 98px;
  }

  .device-shell-led-label {
    left: 34px;
    bottom: 95px;
    font-size: 0.66rem;
  }

  .device-shell-dpad {
    left: 26px;
    bottom: 28px;
    width: 62px;
    height: 62px;
    border-radius: 16px;
  }

  .device-shell-dpad::before {
    top: 7px;
    width: 18px;
    height: 48px;
  }

  .device-shell-dpad::after {
    left: 7px;
    width: 48px;
    height: 18px;
  }

  .device-shell-button {
    width: 42px;
    height: 42px;
    bottom: 34px;
  }

  .device-shell-button-a {
    right: 78px;
  }

  .device-shell-button-b {
    right: 122px;
  }

  .device-shell-button-select {
    right: 112px;
  }

  .device-shell-button-start {
    right: 64px;
  }

  .device-shell-button-select::after,
  .device-shell-button-start::after {
    font-size: 0.6rem;
    bottom: -18px;
  }

  .device-shell-speaker {
    right: 14px;
    bottom: 16px;
    width: 58px;
    height: 58px;
  }

  .app-footer {
    width: min(420px, calc(100% - 216px));
  }

  .app-header-inner {
    flex-direction: column;
    align-items: stretch;
    min-height: 156px;
    padding: 38px 12px 14px;
  }

  .app-header-inner::before {
    left: 22px;
    top: 18px;
  }

  .app-header-inner::after {
    right: 104px;
    top: 18px;
  }

  .logo-pill {
    left: 18px;
    bottom: auto;
    top: 16px;
  }

  .hero-text {
    width: min(238px, 100%);
    margin: 0 auto;
  }

  .toolbar {
    align-items: stretch;
    padding-top: 8px;
    padding-bottom: 10px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar-right {
    justify-content: stretch;
  }

  .game-toggle {
    width: 100%;
  }

  .game-toggle .toggle-btn {
    flex: 1 1 0;
    text-align: center;
  }

  #searchInput {
    width: 100%;
    flex-basis: 100%;
  }

  .sort-label {
    width: 100%;
    justify-content: space-between;
  }

  #sortSelect {
    flex: 1 1 auto;
    min-width: 0;
  }

  #lastUpdated {
    width: 100%;
    text-align: center;
  }

  .quick-add-grid {
    grid-template-columns: 1fr 86px;
  }

  .selected-set-tools {
    grid-template-columns: 1fr;
  }

  .quick-field-wide,
  .quick-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .app-root {
    height: calc(100dvh - 8px);
    min-height: 0;
    width: min(100vw - 8px, 1510px);
    margin: 4px auto;
    padding: 6px 6px 142px;
    border-radius: 20px;
  }

  .app-header {
    padding: 8px 4px 8px;
  }

  .app-header-inner {
    min-height: 156px;
    padding: 46px 10px 12px;
    border-radius: 22px;
  }

  .app-header-inner::before {
    left: auto;
    right: 92px;
    top: 18px;
  }

  .app-header-inner::after {
    display: none;
  }

  .logo-pill {
    left: 22px;
    top: 16px;
    padding: 5px 10px;
  }

  .hero-text {
    width: min(238px, 100%);
    padding: 10px 14px;
  }

  .page-title {
    font-size: 1.2rem;
  }

  .page-subtitle {
    max-width: none;
    font-size: 0.72rem;
  }

  main {
    width: 100%;
    padding: 10px;
    border-width: 6px;
    border-radius: 20px;
    -webkit-overflow-scrolling: touch;
  }

  main::-webkit-scrollbar {
    width: 6px;
  }

  .products-subgrid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .product-card {
    contain-intrinsic-size: 368px 154px;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    height: 154px;
    gap: 5px 10px;
    padding: 9px 8px;
    align-items: start;
  }

  .product-image {
    grid-row: 1 / span 7;
    align-self: start;
    height: 108px;
    padding: 6px;
  }

  .product-name {
    margin-top: 0;
    -webkit-line-clamp: 2;
    font-size: 0.72rem;
    line-height: 1.16;
  }

  .set-chip {
    margin: 0;
    padding: 2px 7px;
    font-size: 0.56rem;
  }

  .product-set,
  .product-meta,
  .product-link {
    font-size: 0.6rem;
    margin-top: 0;
  }

  .product-price-row {
    font-size: 0.64rem;
    line-height: 1.2;
  }

  .toolbar {
    gap: 8px;
  }

  .toggle-btn {
    padding: 5px 8px;
    font-size: 0.68rem;
  }

  #searchInput {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .sort-label {
    font-size: 0.68rem;
  }

  #sortSelect {
    font-size: 0.72rem;
  }

  #lastUpdated {
    font-size: 0.62rem;
  }

  .device-shell-pokeball {
    display: none;
  }

  .device-shell-led {
    left: 16px;
    bottom: 94px;
    width: 14px;
    height: 14px;
  }

  .device-shell-led-label {
    left: 36px;
    bottom: 92px;
    font-size: 0.58rem;
  }

  .device-shell-dpad {
    left: 24px;
    bottom: 18px;
    width: 64px;
    height: 64px;
  }

  .device-shell-button {
    width: 38px;
    height: 38px;
    bottom: 26px;
  }

  .device-shell-button-a {
    right: 28px;
  }

  .device-shell-button-b {
    right: 78px;
  }

  .device-shell-button-select,
  .device-shell-button-start {
    bottom: 13px;
    width: 32px;
    height: 10px;
  }

  .device-shell-button-select {
    left: calc(50% - 42px);
    right: auto;
  }

  .device-shell-button-start {
    left: calc(50% + 10px);
    right: auto;
  }

  .device-shell-button::after {
    font-size: 1.06rem;
  }

  .device-shell-button-select::after,
  .device-shell-button-start::after {
    display: grid;
    bottom: -12px;
    font-size: 0.48rem;
    letter-spacing: 0.03em;
  }

  .device-shell-speaker {
    left: 50%;
    right: auto;
    bottom: 34px;
    width: 56px;
    height: 52px;
    border-radius: 12px;
    background-size: 9px 9px, auto, auto;
    transform: translateX(-50%);
  }

  .app-footer {
    left: 50%;
    right: auto;
    bottom: 92px;
    width: min(246px, calc(100% - 104px));
    padding: 4px 8px;
  }

  .app-footer p {
    font-size: 0.58rem;
    line-height: 1.18;
  }
}

@media (hover: none), (pointer: coarse) {
  .product-card,
  .toggle-btn {
    transition: none;
  }

  .product-card:hover,
  .toggle-btn:hover {
    transform: none;
  }
}

@keyframes powerPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.82;
  }
  50% {
    transform: scale(1.09);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .device-shell-led {
    animation: none;
  }
}
