:root {
  --border: #d8d8d8;
  --muted: #666;
  --bg: #fff;
  --bg2: #f7f7f7;
  --shadow: 0 8px 20px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: #111; }

.page { width: 100%; }

/* Logo/title placeholder (reserved space) */
.logoWrap { display: flex; justify-content: center; padding: 18px 18px 0; }
.logoArea {
  width: 800px;
  height: 200px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* Main content with 100px left/right buffer */
.mainWrap {
  padding: 18px 100px 22px;
}

.top { display: flex; gap: 20px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
.searchArea { flex: 0 1 800px; min-width: 280px; max-width: 800px; }
.label { display: block; font-size: 14px; margin-bottom: 8px; color: var(--muted); }

.inputWrap { position: relative; }
#cardInput {
  width: 100%;
  padding: 12px 70px 12px 12px; /* space for spinner + clear */
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
}

/* 5-color Magic spinner (WUBRG) */
.spinner {
  position: absolute;
  right: 46px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(
    #f7f7f7 0 20%,
    #1a63ff 20% 40%,
    #111111 40% 60%,
    #d21d1d 60% 80%,
    #1f8a2b 80% 100%
  );
  /* Make it a ring */
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
          mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 0);
  animation: spin 0.8s linear infinite;
  opacity: 0.95;
  z-index: 3190;
}
.spinner.hidden { display: none; }

@keyframes spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

#clearBtn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  z-index: 3200;
}

.suggestions {  z-index: 3000;

  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
  display: none;
}
.suggestions.show { display: block; }
.suggestions li {
  padding: 10px 12px;
  cursor: pointer;
  border-top: 1px solid #eee;
}
.suggestions li:first-child { border-top: none; }
.suggestions li:hover { background: #efefef; }

.message { margin-top: 10px; color: var(--muted); min-height: 20px; }

/* Card panel always present to avoid layout shift */
.cardPanel {
  width: 320px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg);
  min-height: 520px; /* reserved space */
}
.cardName { font-weight: 700; margin-bottom: 10px; }
.cardName.placeholder { color: var(--muted); font-weight: 600; }

/* Reserve image space + scale image to 66% */
.cardImageWrap {
  width: 66%;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg2);
  aspect-ratio: 488 / 680;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cardImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cardImage.placeholderImg { opacity: 0; }

.adSlot {
  margin: 18px 0;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--bg2);
}

.linksMessage {
  color: var(--muted);
  margin: 0 0 12px;
  min-height: 18px;
}

/* Fixed-width category columns (300px), count depends on available width */
.linksRoot {
  display: grid;
  grid-template-columns: repeat(auto-fit, 300px);
  gap: 18px 24px;
  justify-content: center;
}

.category {
  width: 300px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: var(--bg);
}
.categoryTitle { margin: 0 0 10px; font-size: 16px; }
.linkList { margin: 0; padding-left: 18px; }
.linkList a { color: #0b57d0; text-decoration: none; }
.linkList a:hover { text-decoration: underline; }
.linkList a.disabled { color: var(--muted); pointer-events: none; text-decoration: none; }
.category.disabledCat { opacity: 0.75; }
.category.disabledCat .categoryTitle::after { content: " (not applicable)"; font-weight: 400; color: var(--muted); }
.sponsored { font-size: 12px; color: var(--muted); margin: 0 0 8px; }

@media (max-width: 980px) {
  .mainWrap { padding: 18px 18px 22px; } /* reduce buffer on smaller screens */
  .top { display: flex; gap: 20px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }
  .cardPanel { width: 100%; min-height: 0; }
  .cardImageWrap { width: 66%; max-width: 240px; }
}

@media (max-width: 860px) {
  .logoArea { width: 100%; }
}


/* ===== v17 layout + UX overrides ===== */
.top {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.formRow { width: 100%; display: flex; justify-content: center; }
.displayRow { width: 100%; display: flex; gap: 24px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }

/* Fixed input width */
.searchArea { width: 600px; max-width: none; }
#cardInput { width: 600px; }

/* Suggestions overlay */
.inputWrap { position: relative; }
.suggestions {
  margin: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 3000;
}
/* Ensure it stays scrollable */
.suggestions { max-height: 360px; overflow-y: auto; }

/* Logo image */
.logoArea {
  width: 800px;
  height: 200px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logoImg { width: 100%; height: 100%; object-fit: contain; }

/* Card image: no 66% shrink, no forced aspect box */
.cardPanel { width: 320px; min-height: 0; }
.cardImageWrap { width: 100%; border-radius: 10px; border: 1px solid var(--border); background: var(--bg2); overflow: hidden; }
.cardImage { display: block; width: 100%; height: auto; }

@media (max-width: 700px) {
  .searchArea, #cardInput { width: 100%; }
  .logoArea { width: 100%; }
  .cardPanel { width: 100%; }
}


/* ===== v19 input overlay fix ===== */
.inputWrap { width: 600px; }
#cardInput {
  position: relative;
  z-index: 1;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg);
}
.spinner, #clearBtn { z-index: 5; }


/* ===== v20: lock card image box + align logo with card image box ===== */
:root {
  --card-panel-width: 320px;
  --card-panel-padding: 12px;
  --card-panel-border: 1px;
  --card-image-box-height: 410px; /* stable layout */
  --card-name-height: 28px;
  --card-name-gap: 12px;
}

/* Keep controls inside the input visually */
#cardInput { box-sizing: border-box; }
.inputWrap { width: 600px; }
#clearBtn, .spinner { position: absolute; top: 50%; transform: translateY(-50%); }
#clearBtn { right: 8px; }
.spinner { right: 46px; }

/* Lock card name to a single line so panel height doesn't jump */
.cardName {
  height: var(--card-name-height);
  line-height: var(--card-name-height);
  margin: 0 0 var(--card-name-gap);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Lock the card image box size */
.cardImageWrap {
  width: 100%;
  height: var(--card-image-box-height);
}
.cardImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Align logo area to the card image box (not the name row) */
.logoArea {
  width: 553px;                /* matches your TitleImage.png width */
  height: var(--card-image-box-height);
  margin-top: calc(var(--card-name-height) + var(--card-name-gap));
  border: 0;                   /* remove dashed border now that you have a real logo */
  background: transparent;
}
.logoImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}


/* ===== v21: narrower overall width + masonry-style category columns ===== */
.mainWrap{
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 22px;
}

/* Masonry columns for categories (variable height; no equal-height blocks) */
.linksRoot{
  display: block;
  column-width: 300px;
  column-gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.category{
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 18px;
  vertical-align: top;
}
