body {
  font-family: Georgia, serif;
  background: #2b2b2b url("page-bg.jpg") center center / cover no-repeat fixed;
  text-align: center;
  padding: 20px;
}

.grid {
  position: relative;
  width: min(95vw, 1800px, calc((100vh - 160px) * (1920 / 1439)));
  aspect-ratio: 1920 / 1439; /* matches template.png exactly */
  margin: 0 auto;
  background-image: url("template.png");
  background-size: 100% 100%;
}

.grid-st {
  background-image: url("templateST.png");
}

.box {
  position: absolute;
  cursor: pointer;
  overflow: hidden;
  /* left/top/width/height are set inline per box, in script.js,
     as percentages matching each card-back slot in template.png */
}

.box:hover {
  outline: 3px solid #d4af37;
  outline-offset: -3px;
}

.box img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.controls {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.controls button { margin: 4px; padding: 6px 12px; }

#downloadBtn {
  display: inline-block;
  background: #333;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 20px;
  border: 2px solid #d4af37;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  transition: background 0.15s, border-color 0.15s;
}

#downloadBtn:hover {
  background: #4a4a4a;
  border-color: #e5c458;
}

.credit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

div.credit {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.credit a {
  color: #fff;
  text-decoration: underline;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.credit .x-logo {
  height: 26px;
  width: auto;
}

.cta-button {
  display: inline-block;
  background: #333;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  text-decoration: none;
  padding: 10px 20px;
  border-radius: 20px;
  border: 2px solid #d4af37;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
  transition: background 0.15s, border-color 0.15s;
}

.cta-button:hover {
  background: #4a4a4a;
  border-color: #e5c458;
}
#codeBox { width: 500px; max-width: 90%; margin-top: 10px; }

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000; /* must beat .box .label's z-index:1, or labels bleed through */
}
.modal.hidden { display: none; }

.modal-content {
  background: white;
  width: 1100px;
  max-width: 95%;
  height: 90vh; /* fixed, not max-height -- keeps the window size stable while typing a search */
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  padding: 12px;
  border-bottom: 1px solid #ccc;
}
.modal-header input { flex: 1; padding: 10px; font-size: 16px; }
.modal-header #clearBtn {
  margin-left: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.modal-header #clearBtn:disabled {
  opacity: 0.4;
  cursor: default;
}
.modal-header button { margin-left: 8px; font-size: 22px; cursor: pointer; }

.card-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 12px;
}
.card-list img {
  width: 100%;
  cursor: pointer;
  border: 1px solid transparent;
}
.card-list img:hover { border-color: #333; }