:root {
  --h: 330px;   /* case height on the shelf */
  --ch: 290px;  /* case height in the crate */
  --paper: #efe6d0;
  --marker: 'Permanent Marker', 'Comic Sans MS', cursive;
  --type: 'Special Elite', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: #0d0906 url(assets/store.jpg) center / cover fixed;
  color: #eee;
  font-family: var(--type);
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 30%, rgba(0,0,0,.15), rgba(0,0,0,.65));
}
button { font: inherit; cursor: pointer; }

.app {
  position: relative;
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px;
  max-width: 1480px; margin: 0 auto; padding: 28px;
}

/* ---------- cork board ---------- */
.cork {
  background: url(assets/cork.jpg) center / 300px;
  border: 14px solid #3a2414;
  border-image: url(assets/wood.jpg) 40 / 14px round;
  box-shadow: 0 18px 40px rgba(0,0,0,.6), inset 0 0 30px rgba(0,0,0,.45);
  padding: 18px 16px 24px;
  align-self: start;
  min-height: calc(100vh - 56px);
}
.cork-title {
  font-family: var(--marker); color: #222; font-size: 26px; text-align: center;
  background: var(--paper); padding: 6px 10px; margin: 0 6px 22px; transform: rotate(-2deg);
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  position: relative;
}
.sets { display: flex; flex-direction: column; gap: 26px; align-items: center; }
.polaroid {
  position: relative; width: 168px; padding: 10px 10px 8px;
  background: #fbfaf5; color: #1d1d1d; border: 0;
  box-shadow: 0 6px 14px rgba(0,0,0,.45), 0 1px 0 rgba(0,0,0,.1);
  transform: rotate(var(--r, 0deg)); transition: transform .2s ease, box-shadow .2s ease;
  text-align: center;
}
.polaroid:hover { transform: rotate(0deg) scale(1.04); box-shadow: 0 12px 24px rgba(0,0,0,.5); }
.polaroid.active { outline: 3px solid #e3b23c; outline-offset: 2px; }
.polaroid .photo {
  height: 104px; background: #14100c; display: flex; align-items: flex-end; justify-content: center;
  gap: 2px; padding: 8px 6px 6px; overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0,0,0,.8);
}
.polaroid .photo img { height: 100%; width: 8px; object-fit: fill; flex: none; }
.polaroid .photo .empty { color: #6b5b4b; font-family: var(--marker); font-size: 34px; align-self: center; }
.polaroid .caption { font-family: var(--marker); font-size: 21px; margin-top: 6px; line-height: 1.1; overflow-wrap: anywhere; }
.polaroid .caption small { display: block; font-family: var(--type); font-size: 11px; color: #777; }
.pin {
  position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0 2px, var(--pin, #c0302a) 3px 60%, #0006 100%);
  box-shadow: 0 3px 4px rgba(0,0,0,.5);
}
.polaroid .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: #222; color: #fff; font-size: 14px; line-height: 22px; padding: 0; opacity: 0;
}
.polaroid:hover .del { opacity: .85; }
.polaroid.new .photo { background: repeating-linear-gradient(45deg, #ebe6d8, #ebe6d8 8px, #e2dccb 8px 16px); box-shadow: none; }

/* ---------- jewel cases ---------- */
.case {
  position: relative; flex: none;
  height: var(--h); aspect-ratio: 321 / 4203;
  filter: drop-shadow(3px 5px 4px rgba(0,0,0,.55));
  user-select: none; -webkit-user-drag: element;
}
/* the insert window of frame.png: x 42-285, y 105-4110 of 321x4203 */
.case .insert { position: absolute; left: 13.084%; top: 2.498%; width: 75.701%; height: 95.289%; }
.case .frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.case img { -webkit-user-drag: none; }

/* ---------- display shelf ---------- */
.display {
  position: relative;
  background: url(assets/wood.jpg) center / 520px;
  border-radius: 6px 6px 3px 3px;
  padding: 64px 290px 0 36px;
  box-shadow:
    0 22px 40px rgba(0,0,0,.6),
    inset 0 30px 50px rgba(0,0,0,.65),
    inset 18px 0 30px rgba(0,0,0,.5), inset -18px 0 30px rgba(0,0,0,.5);
}
.tag {
  position: absolute; top: -16px; left: calc(50% - 145px); transform: translateX(-50%) rotate(-1.5deg);
  background: linear-gradient(#f2ead6, #e4d8bd); color: #1b1b1b;
  font-family: var(--marker); font-size: 36px; padding: 6px 30px 4px; white-space: nowrap;
  box-shadow: 0 5px 12px rgba(0,0,0,.5);
  clip-path: polygon(0 4%, 3% 0, 30% 3%, 60% 0, 97% 2%, 100% 8%, 99% 60%, 100% 96%, 70% 100%, 40% 97%, 4% 100%, 1% 92%);
  z-index: 2;
}
.tag::before, .tag::after {
  content: ""; position: absolute; top: -4px; width: 46px; height: 20px;
  background: rgba(235, 225, 190, .6); box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.tag::before { left: -10px; transform: rotate(-24deg); }
.tag::after { right: -10px; transform: rotate(22deg); }
.tag #set-name { cursor: text; }
.tag small { font-family: var(--type); font-size: 15px; color: #6d5a3d; margin-left: 10px; }
.tag.full { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-52%) rotate(-3deg); } 75% { transform: translateX(-48%) rotate(0deg); } }

.shelf-row {
  position: relative; display: flex; align-items: flex-end; gap: 5px;
  min-height: calc(var(--h) + 8px);
}
.shelf-row .case { cursor: grab; transition: transform .15s ease; }
.shelf-row .case:hover { transform: translateY(-6px); }
.shelf-row .case.dragging { opacity: .25; }
.shelf-row .hint {
  align-self: center; margin: auto; font-family: var(--marker); font-size: 26px; color: #d8c49c; opacity: .7;
  text-align: center;
}
.shelf-row .marker {
  position: absolute; bottom: 0; width: 4px; height: var(--h); margin-left: -4.5px;
  background: #e3b23c; border-radius: 2px; box-shadow: 0 0 12px #e3b23c; pointer-events: none;
}
.board {
  height: 30px; margin: 0 -290px 0 -36px; position: relative;
  background: url(assets/wood.jpg) 0 40% / 520px;
  box-shadow: 0 -2px 0 rgba(255,220,170,.18) inset, 0 -10px 18px rgba(0,0,0,.45), 0 12px 18px rgba(0,0,0,.6);
  border-radius: 0 0 3px 3px;
}
.board::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(255,210,150,.14), rgba(0,0,0,.35));
}

/* ---------- note ---------- */
.note {
  position: absolute; top: 46px; right: 30px; width: 232px; padding: 34px 20px 34px;
  background: linear-gradient(170deg, #f3ecd9, #e2d5b6); color: #1f1f1f;
  transform: rotate(1.5deg);
  box-shadow: 0 10px 22px rgba(0,0,0,.5);
  clip-path: polygon(-30px -40px, calc(100% + 30px) -40px, calc(100% + 30px) 0, 100% 0, 100% 94%, 95% 100%, 90% 94%, 85% 100%, 80% 94%, 75% 100%, 70% 94%, 65% 100%, 60% 94%, 55% 100%, 50% 94%, 45% 100%, 40% 94%, 35% 100%, 30% 94%, 25% 100%, 20% 94%, 15% 100%, 10% 94%, 5% 100%, 0 94%, 0 0, -30px 0);
}
.note h3 { margin: 0 0 12px; font-weight: normal; font-size: 22px; letter-spacing: .5px; }
.note input {
  width: 100%; font: 19px var(--type); padding: 7px 8px; background: rgba(255,255,255,.35);
  border: 2px solid #2a2a2a; border-radius: 2px; color: #111; outline: none;
}
.note input:focus { background: rgba(255,255,255,.65); }
/* masking tape over the top edge, matching the tape on the set tag */
.tape {
  position: absolute; top: -13px; left: 50%; width: 104px; height: 30px; margin-left: -52px;
  transform: rotate(-3deg);
  background:
    linear-gradient(rgba(255,255,255,.28), transparent 35%, transparent 70%, rgba(80,60,20,.08)),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(255,255,255,.06) 3px 4px),
    rgba(235, 225, 190, .72);
  clip-path: polygon(3% 0, 97% 0, 100% 14%, 97.5% 28%, 100% 43%, 98% 57%, 100% 72%, 97.5% 86%, 99% 100%,
    2% 100%, 0 86%, 2.5% 72%, 0 57%, 2% 43%, 0 28%, 2.5% 14%);
}
.stamp {
  display: block; margin: 16px auto 0; background: transparent; padding: 3px 18px;
  font-family: var(--marker); font-size: 30px; border: 3px solid; border-radius: 6px;
  transform: rotate(-4deg); opacity: .88; transition: transform .1s, opacity .1s;
}
.stamp:hover { opacity: 1; transform: rotate(-4deg) scale(1.06); }
.stamp:active { transform: rotate(-4deg) scale(.96); }
.stamp.red { color: #b3261e; border-color: #b3261e; box-shadow: inset 0 0 0 2px rgba(179,38,30,.2); }
.stamp.ink { color: #1c2a4a; border-color: #1c2a4a; font-size: 22px; transform: rotate(3deg); margin-top: 20px; }
.stamp.ink:hover { transform: rotate(3deg) scale(1.06); }
.tools { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.tools .stamp { margin: 0; font-size: 18px; padding: 2px 9px; color: #2f5a2a; border-color: #2f5a2a; }
.tools .stamp + .stamp { transform: rotate(3deg); }
.tools .stamp + .stamp:hover { transform: rotate(3deg) scale(1.06); }
.tools + #export { margin-top: 14px; }
.stamp:disabled { opacity: .35; cursor: default; }

/* ---------- crate ---------- */
.crate { position: relative; height: 380px; margin: 0 6px; }
.crate-back {
  position: absolute; left: 14px; right: 14px; top: 50px; bottom: 30px;
  background: linear-gradient(#1b1b1b, #070707 40%);
  border-radius: 10px 10px 4px 4px;
  box-shadow: inset 0 3px 0 #333, inset 0 0 40px #000, 0 20px 30px rgba(0,0,0,.6);
}
.crate-row {
  position: absolute; inset: 0 48px 0 48px;
  display: flex; align-items: flex-start; gap: 3px;
  padding-top: 70px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
}
.crate-row::-webkit-scrollbar { display: none; }
.crate-row .case { --h: var(--ch); cursor: pointer; transition: transform .2s ease; }
.crate-row .case:hover { transform: translateY(-86px); }
.crate-row .case.shelved { filter: drop-shadow(3px 5px 4px rgba(0,0,0,.55)) brightness(.5); }
.crate-row .case.shelved:hover { filter: drop-shadow(3px 5px 4px rgba(0,0,0,.55)) brightness(.85); }
.sticker {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%) rotate(-8deg);
  background: #f4d23c; color: #222; font: 13px var(--marker); padding: 3px 5px; white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,.5); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.case.shelved .sticker { background: #9ad06a; }
.crate-row .case:hover .sticker { opacity: 1; }
.case .trash {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 20px; height: 20px;
  border-radius: 50%; border: 0; padding: 0; background: #b3261e; color: #fff; font-size: 13px; line-height: 20px;
  opacity: 0;
}
.crate-row .case:hover .trash { opacity: .9; }
.crate-front {
  position: absolute; left: 0; right: 0; bottom: 0; height: 210px; pointer-events: none;
  border-style: solid; border-width: 52px 58px 34px;
  border-image: url(assets/crate.png) 85 90 58 fill / 52px 58px 34px round stretch;
  filter: drop-shadow(0 -4px 8px rgba(0,0,0,.5));
}
.crate-label {
  position: absolute; bottom: -26px; left: 0; right: 0; text-align: center; font-size: 13px; color: #b9a78a; opacity: .8;
}
.crate.drop-target .crate-back { box-shadow: inset 0 3px 0 #e3b23c, inset 0 0 40px #000; }

/* ---------- dig sheet ---------- */
.sheet {
  width: min(980px, calc(100vw - 40px)); max-height: calc(100vh - 60px);
  background: linear-gradient(175deg, #f5efdf, #e7dcc1); color: #1b1b1b;
  border: 0; padding: 30px 34px 34px; box-shadow: 0 30px 80px rgba(0,0,0,.8);
  font-family: var(--type);
}
.sheet::backdrop { background: rgba(5,3,2,.72); backdrop-filter: blur(2px); }
.sheet .close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 32px; color: #555; }
.sheet h2 { font-family: var(--marker); font-weight: normal; font-size: 32px; margin: 0 0 4px; }
.sheet .sub { color: #6a5a40; margin: 0 0 18px; }
.sheet .back { border: 0; background: none; color: #6a5a40; padding: 0; margin-bottom: 10px; text-decoration: underline; }
.results { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 26px; }
.results li { break-inside: avoid; }
.results button {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px dashed #b9a985;
  background: none; padding: 9px 4px; font-size: 17px;
}
.results button:hover { background: rgba(227,178,60,.25); }
.results .yr { color: #8a7a5c; }
.loading { font-size: 18px; padding: 30px 0; text-align: center; color: #6a5a40; }
.loading::after { content: "…"; animation: dots 1s steps(3) infinite; display: inline-block; width: 1em; text-align: left; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } }
.err { color: #b3261e; }
.cands { display: flex; flex-direction: column; gap: 12px; }
.cand { display: grid; grid-template-columns: 90px minmax(0, 640px); gap: 14px; align-items: center; }
.cand > img { width: 90px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.cand .meta { font-size: 13px; color: #6a5a40; margin-bottom: 5px; }
.strip {
  display: block; width: 100%; padding: 0; border: 2px solid transparent; background: #000; margin-bottom: 5px;
  line-height: 0;
}
.strip:hover { border-color: #e3b23c; }
.strip canvas { width: 100%; height: auto; }
.editor .big { width: 100%; background: #000; line-height: 0; margin: 6px 0 16px; box-shadow: 0 3px 10px rgba(0,0,0,.4); }
.editor .big canvas { width: 100%; height: auto; image-rendering: auto; }
.editor .row { display: grid; grid-template-columns: 1fr 70px; gap: 24px; align-items: start; }
.editor .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.editor label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: #5a4a30; }
.editor input[type=text] { font: 17px var(--type); padding: 6px 8px; border: 2px solid #2a2a2a; background: rgba(255,255,255,.45); }
.editor input[type=range] { accent-color: #8a5a20; }
.editor .actions { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; margin-top: 6px; }
.editor .actions .stamp { margin: 0; font-size: 24px; }
.btn { border: 2px solid #2a2a2a; background: rgba(255,255,255,.4); padding: 6px 14px; font-size: 15px; }
.btn:hover { background: rgba(255,255,255,.75); }
.editor .preview { --h: 330px; display: flex; justify-content: center; }
.more { margin: 18px auto 0; display: block; }

@media (max-width: 1100px) {
  :root { --h: 300px; --ch: 270px; }
  .app { grid-template-columns: 1fr; }
  .cork { min-height: 0; }
  .sets { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .display { padding-right: 36px; padding-bottom: 0; }
  .board { margin-right: -36px; }
  .note { position: relative; top: auto; right: auto; margin: 30px auto 40px; }
  .tag { left: 50%; }
}
