/* Cardboard Empire — warm wood-and-lamplight card shop. */
:root {
  --bg: #1a1410; --panel: #241c15; --panel-2: #2e241b; --line: #443627;
  --ink: #f3ead9; --dim: #a89877; --accent: #e8a33d; --good: #7fce8f; --bad: #e88a7a;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; background: radial-gradient(ellipse 120% 60% at 50% -10%, #2a2015, var(--bg) 70%); color: var(--ink); font: 16px/1.5 var(--sans); min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  position: sticky; top: 0; z-index: 50;
  background: rgba(26, 20, 16, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hub-link { color: var(--dim); text-decoration: none; font-size: .78rem; font-weight: 700; }
.app-title { font-weight: 800; letter-spacing: -.02em; }
.money { margin-left: auto; font-family: var(--mono); font-weight: 800; font-size: 1.1rem; color: var(--accent); }

main { max-width: 640px; margin: 0 auto; padding: 0 .9rem calc(3.5rem + env(safe-area-inset-bottom)); }
h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin: 1.4rem 0 .6rem; }
.hint { color: var(--dim); font-size: .82rem; }

.offline-note { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; margin: .5rem 0; font-size: .88rem; }
.hidden { display: none !important; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .6rem; }
.act {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink);
  font: inherit; text-align: left; padding: .8rem .9rem; cursor: pointer;
  display: flex; flex-direction: column; gap: .15rem; min-height: 64px; touch-action: manipulation;
}
.act:active { border-color: var(--accent); }
.act:disabled { opacity: .55; }
.act b { font-size: .92rem; }
.act span { color: var(--dim); font-size: .74rem; }

.markup-row { display: flex; align-items: center; gap: .8rem; }
#markup { flex: 1; accent-color: var(--accent); height: 2.2rem; touch-action: pan-y; }
.markup-label { font-family: var(--mono); font-weight: 800; color: var(--accent); min-width: 7.5rem; text-align: right; }
.inv-value { float: right; color: var(--good); font-size: .78rem; font-weight: 700; }

.shelves {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .5rem;
  background: linear-gradient(180deg, #221a12, #1d150e); border: 1px solid var(--line);
  border-radius: 14px; padding: .7rem; min-height: 110px;
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, .5);
}
.shelf-card { position: relative; border: 1px solid var(--line); background: #171009; border-radius: 8px; padding: 0; overflow: hidden; cursor: pointer; aspect-ratio: 5/4; }
.shelf-card img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-touch-callout: none; }
.shelf-card .noart { display: grid; place-items: center; height: 100%; font-weight: 900; color: var(--dim); font-size: 1.4rem; }
.sc-price {
  position: absolute; bottom: 3px; right: 3px; background: rgba(20, 12, 4, .82); color: var(--accent);
  font-family: var(--mono); font-weight: 700; font-size: .62rem; border-radius: 6px; padding: .1rem .3rem;
}

.upg {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
  font: inherit; text-align: left; padding: .65rem .85rem; cursor: pointer; margin-bottom: .45rem;
  display: flex; flex-direction: column; gap: .1rem; touch-action: manipulation;
}
.upg:disabled { opacity: .5; cursor: default; }
.upg b { font-size: .88rem; }
.upg span { color: var(--dim); font-size: .74rem; }

.log { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; color: var(--dim); max-height: 220px; overflow-y: auto; }
.log div:first-child { color: var(--ink); }
.disclaimer { margin-top: 1.6rem; }

.card-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(12, 8, 4, .85); display: grid; place-items: center; padding: 1rem; cursor: pointer; }
.card-overlay.hidden { display: none; }
.card-overlay img { max-width: min(92vw, 340px); width: 100%; border-radius: 4.5%/3.5%; box-shadow: 0 14px 40px rgba(0, 0, 0, .6); }

@media (max-width: 420px) { .actions { grid-template-columns: 1fr; } }

/* ---- Real packs & the bulk box ---- */
.pack-act { gap: .45rem; }
#set-select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font: inherit; font-size: 16px; padding: .5rem .55rem; min-height: 42px;
}
.chipbtn {
  align-self: flex-start; border: 1px solid var(--accent); background: rgba(232, 163, 61, .14); color: var(--accent);
  border-radius: 999px; font: inherit; font-weight: 800; font-size: .82rem; padding: .35rem .95rem; cursor: pointer;
}
.chipbtn:disabled { opacity: .45; }
.pack-reveal {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; margin-top: .6rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .55rem;
}
.pull { position: relative; border: 1px solid var(--line); background: #171009; border-radius: 6px; padding: 0; overflow: hidden; cursor: pointer; aspect-ratio: 5/4; animation: pull-in .3s backwards; }
.pull img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pull span { position: absolute; bottom: 2px; right: 2px; background: rgba(20, 12, 4, .85); color: var(--dim); font-family: var(--mono); font-size: .56rem; border-radius: 4px; padding: 0 .25rem; }
.pull.hit { border-color: var(--accent); }
.pull.hit span { color: var(--accent); font-weight: 700; }
@keyframes pull-in { from { transform: translateY(-14px) scale(.7); opacity: 0; } }
.bulkbox { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: .55rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .8rem; font-size: .84rem; color: var(--dim); }
.bulkbox b { color: var(--ink); font-weight: 700; }

/* ---- The product wall ---- */
#product-select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font: inherit; font-size: 16px; padding: .5rem .55rem; min-height: 42px;
}
.sealed-wall { display: flex; flex-direction: column; gap: .45rem; }
.sealed-row {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .8rem;
}
.sr-name { font-size: .88rem; }
.sr-meta { color: var(--dim); font-size: .74rem; font-family: var(--mono); flex: 1; }

/* ---- Hustle, boost badge, the books ---- */
.boost-badge { color: var(--good); font-size: .72rem; font-weight: 800; }
.stats-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.stats-row .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .8rem; }
.stats-row .stat b { display: block; font-family: var(--mono); font-size: .95rem; }
.stats-row .stat span { color: var(--dim); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; }
.stats-row .stat.best b { color: var(--accent); font-family: var(--sans); }

/* ---- Market vs your price on every tile ---- */
.sc-mkt {
  position: absolute; top: 3px; left: 3px; background: rgba(20, 12, 4, .82); color: var(--dim);
  font-family: var(--mono); font-size: .56rem; border-radius: 6px; padding: .08rem .28rem;
}

/* ---- Active campaign indicator ---- */
.upg.active { border-color: var(--good); background: rgba(127, 206, 143, .08); }
.upg.active b { color: var(--good); }

/* ---- Wall of fame ---- */
.top-list { display: flex; flex-direction: column; gap: .4rem; }
.top-row {
  display: flex; align-items: baseline; gap: .6rem; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .55rem .8rem; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.top-row:active { border-color: var(--accent); }
.tr-rank { color: var(--accent); font-weight: 900; font-family: var(--mono); }
.tr-name { flex: 1; font-weight: 700; font-size: .9rem; }
.tr-how { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; border-radius: 99px; padding: .12rem .5rem; }
.tr-how.opened { background: rgba(232, 163, 61, .15); color: var(--accent); }
.tr-how.sold { background: rgba(127, 206, 143, .15); color: var(--good); }
.tr-price { font-family: var(--mono); font-weight: 800; color: var(--good); }

/* ---- Special Guest glow ---- */
.pull.sg { border-color: #c9a3ff; box-shadow: 0 0 10px rgba(201, 163, 255, .7); animation: pull-in .3s backwards, sg-pulse 1.6s infinite alternate; }
.pull.sg span { color: #dcc5ff; font-weight: 800; }
@keyframes sg-pulse { from { box-shadow: 0 0 8px rgba(201, 163, 255, .5); } to { box-shadow: 0 0 16px rgba(201, 163, 255, .95); } }

/* ---- Bonus sheet / promo slot ---- */
.pull.bn { border-color: #6fc7c7; box-shadow: 0 0 8px rgba(111, 199, 199, .55); }
.pull.bn span { color: #a8e8e8; font-weight: 700; }

/* ---- WPN status ---- */
.wpn-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; }
.wpn-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.wpn-bar { height: 8px; background: #171009; border: 1px solid var(--line); border-radius: 99px; margin: .5rem 0; overflow: hidden; }
.wpn-fill { height: 100%; background: linear-gradient(90deg, #a86f2a, var(--accent)); }
.wpn-perks { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--dim); font-size: .8rem; }
.wpn-perks li { margin: .12rem 0; }

/* ---- Display case vs back binder ---- */
.shelf-card.display { border-color: var(--accent); }
.shelf-card:not(.display) { opacity: .55; }
.more-tile { display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; color: var(--dim); font-size: .68rem; aspect-ratio: 5/4; padding: .2rem; text-align: center; }

/* ---- Order quantity chips ---- */
.qty-row { display: flex; gap: .4rem; align-items: center; width: 100%; }
.qty {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--dim); border-radius: 999px;
  font: inherit; font-weight: 800; font-size: .8rem; padding: .35rem .6rem; cursor: pointer;
  min-height: 38px; min-width: 44px; touch-action: manipulation;
}
.qty.sel { border-color: var(--accent); background: rgba(232, 163, 61, .14); color: var(--accent); }
.qty-row .chipbtn { margin-left: auto; min-width: 5.2rem; }

/* ---- Mobile tap targets ---- */
.chipbtn { min-height: 40px; touch-action: manipulation; }
@media (max-width: 420px) {
  .pack-reveal { grid-template-columns: repeat(5, 1fr); gap: .3rem; padding: .45rem; }
  .sealed-row .chipbtn { width: 100%; }
}
