:root {
  --bg: #12131a;
  --panel: #1b1d27;
  --panel2: #232634;
  --line: #2f3344;
  --text: #e7e8ee;
  --muted: #9aa0b4;
  --accent: #e0a84b;
  --accent2: #7aa2ff;
  --danger: #ff6b6b;
  --common: #c9ccd6;
  --uncommon: #a8c3d6;
  --rare: #e3c46d;
  --mythic: #f0753c;
  --special: #c38bf0;
  --radius: 10px;
  --card-w: 180px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent2); }
button.primary { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
input, select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
input[type=search] { flex: 1; min-width: 220px; }
input.num { width: 72px; }
a { color: var(--accent2); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.setsym { width: 30px; height: 37px; flex-shrink: 0; filter: drop-shadow(0 1px 3px rgba(224,168,75,.35)); }
h1 { font-size: 18px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 6px; }
.tab.active { background: var(--accent); color: #1b1300; border-color: var(--accent); font-weight: 600; }
.view { display: none; padding: 16px 20px 60px; }
.view.active { display: block; }

/* ---------- filters ---------- */
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.frow { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.frow:last-child { margin-bottom: 0; }
.frow.wrap { flex-wrap: wrap; gap: 18px; }
.fgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fgroup > label:first-child { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  padding: 4px 9px; border-radius: 999px; font-size: 12px; background: var(--panel2);
  border: 1px solid var(--line); user-select: none; display: inline-flex; align-items: center; gap: 4px;
}
.chip.on { background: #3a3220; border-color: var(--accent); color: #ffe0a6; }
.chip img { width: 16px; height: 16px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--accent2); color: #08122c; border-color: var(--accent2); }
.check { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }
.dash { color: var(--muted); }
.resultbar { display: flex; justify-content: space-between; margin: 12px 2px 8px; color: var(--muted); }

/* ---------- table ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.cards { width: 100%; border-collapse: collapse; }
.cards th, .cards td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.cards th { background: var(--panel); position: sticky; top: 0; font-size: 12px; color: var(--muted); cursor: default; }
.cards th[data-sort] { cursor: pointer; }
.cards th.sorted { color: var(--accent); }
.cards td.r, .cards th.r { text-align: right; }
.cards tbody tr { cursor: pointer; }
.cards tbody tr:hover { background: var(--panel2); }
.cards td.type { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.name { font-weight: 600; }
.est { color: var(--muted); font-size: 11px; margin-left: 2px; cursor: help; }
.r-common { color: var(--common); } .r-uncommon { color: var(--uncommon); }
.r-rare { color: var(--rare); } .r-mythic { color: var(--mythic); } .r-special, .r-bonus { color: var(--special); }
.incbar { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.incbar i { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); }
.mana { display: inline-flex; gap: 1px; vertical-align: middle; }
.mana img { width: 15px; height: 15px; }
.slotpill { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); }
.gc { font-size: 10px; color: #1b1300; background: var(--accent); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.fire-hot { color: #ff8a3d; }
.fire-cold { color: #74a7ff; }
.more { text-align: center; margin-top: 12px; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); gap: 14px; }
.gcard { position: relative; cursor: pointer; }
.gcard img, .ph {
  width: 100%; aspect-ratio: 488 / 680; border-radius: 4.75% / 3.5%; display: block; background: var(--panel2);
  object-fit: cover;
}
.ph { display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: var(--muted); border: 1px dashed var(--line); }
.gcard .badge {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.75); border-radius: 6px; padding: 2px 6px;
  font-size: 12px; font-weight: 600;
}
.gcard .cap { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }

/* ---------- hover preview & modal ---------- */
.hover-preview {
  position: fixed; width: 250px; border-radius: 12px; pointer-events: none; z-index: 50;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-body {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; max-width: 980px; width: 100%;
  max-height: 92vh; overflow: auto; padding: 22px; position: relative;
}
.close { position: absolute; top: 10px; right: 12px; font-size: 22px; line-height: 1; background: none; border: none; }
.detail { display: grid; grid-template-columns: auto 1fr; gap: 24px; }
.detail .imgs { display: flex; gap: 10px; }
.detail .imgs img { width: 300px; border-radius: 14px; }
.detail h2 { margin: 0 0 4px; }
.detail .tl { color: var(--muted); margin-bottom: 10px; }
.detail pre { white-space: pre-wrap; font-family: inherit; background: var(--panel2); padding: 10px; border-radius: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.links { display: flex; gap: 10px; flex-wrap: wrap; }
.links a { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; text-decoration: none; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } .detail .imgs img { width: 100%; } }

/* ---------- simulator ---------- */
.simbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.packnav { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.pack { min-height: 120px; }

/* top row: three featured cards centred, playtest card off to the side */
.pack-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 24px; }
.featured { grid-column: 2; display: flex; gap: 26px; justify-content: center; }
.playtest-side { grid-column: 3; justify-self: start; padding-top: 6px; }
.pack-rest {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px;
  margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line);
}
@media (max-width: 1100px) { .pack-rest { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); } }
@media (max-width: 900px) {
  .pack-top { grid-template-columns: 1fr; }
  .featured, .playtest-side { grid-column: 1; justify-self: center; }
}

.pslot { perspective: 1400px; cursor: pointer; min-width: 0; }
.pslot.lg { width: clamp(190px, 21vw, 290px); }
.pslot.xs { width: 92px; }
.pslot .flip {
  position: relative; transform-style: preserve-3d; aspect-ratio: 488 / 680; border-radius: 4.75% / 3.5%;
  transition: transform .75s cubic-bezier(.2, .7, .2, 1), box-shadow .4s;
  transform: rotateY(0deg);
}
.pslot.revealed .flip { transform: rotateY(180deg); }
.pslot .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 4.75% / 3.5%; overflow: hidden; }
.pslot .front { transform: rotateY(180deg); }
.pslot .face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pslot .front .ph { height: 100%; }
.pslot:hover .flip { box-shadow: 0 6px 22px rgba(0,0,0,.55); }
.pslot.lg:hover .flip { transform: rotateY(180deg) translateY(-4px); }
.pslot.lg:not(.revealed):hover .flip { transform: translateY(-4px); }

.pslot .label { font-size: 11px; color: var(--muted); margin-top: 5px; display: flex; justify-content: space-between; gap: 6px; }
.pslot .label > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pslot .label b { color: var(--text); font-weight: 600; }
.pslot .label .rar { text-transform: capitalize; flex-shrink: 0; }
.pslot.lg .label { font-size: 13px; }
.pslot.lg .label.main { margin-top: 10px; }
.pslot.xs .label { justify-content: center; text-align: center; }
.pslot:not(.revealed) .label.main, .pslot:not(.revealed) .label .rar { visibility: hidden; }
.pslot.is-ph .front img { filter: grayscale(.4) brightness(.75); }
.pslot.is-ph .front::after {
  content: "?"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800; color: #f3dfb6; text-shadow: 0 2px 8px #000;
}
.pslot.xs.is-ph { cursor: help; }

/* rare / mythic glow after reveal; little pop when a featured card flips */
.pslot.revealed.r-mythic .flip { box-shadow: 0 0 22px rgba(240,117,60,.65); }
.pslot.revealed.r-rare .flip { box-shadow: 0 0 16px rgba(227,196,109,.5); }
.pslot.pop { animation: pop .75s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* fresh pack: lower cards are dealt in, then the top row flips one by one */
.pack.fresh .pack-rest .pslot, .pack.fresh .playtest-side .pslot { animation: deal .38s ease-out both; animation-delay: calc(var(--d) * 28ms); }
.pack.fresh .featured .pslot { animation: deal .45s ease-out both; animation-delay: calc(var(--d) * 90ms); }
.pack.fresh .featured .pslot.pop { animation: pop .75s ease-out; }
@keyframes deal { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }

.foiltag { color: #f6a5ff; font-weight: 700; }

/* session pulls browser */
.pullbrowser { margin-top: 18px; }
.pb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pb-head h3 { margin: 0 6px 0 0; }
.pb-head .chip small { color: var(--muted); }
.pull-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.pcard { position: relative; cursor: pointer; min-width: 0; }
.pcard .pimg { position: relative; border-radius: 4.75% / 3.5%; overflow: hidden; aspect-ratio: 488 / 680; background: var(--panel2); }
.pcard .pimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .pimg .ph { height: 100%; }
.pcard:hover .pimg { box-shadow: 0 6px 18px rgba(0,0,0,.5); transform: translateY(-2px); transition: transform .15s; }
.pcard .cnt {
  position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.8); border: 1px solid var(--accent);
  color: #ffe0a6; border-radius: 6px; padding: 0 6px; font-size: 12px; font-weight: 700;
}
.pcard .cap { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 4px; }
.pcard .cap > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


.session { margin-top: 26px; }
.session h2 { margin: 0 0 10px; font-size: 16px; }
.session h3 { font-size: 13px; color: var(--muted); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); }
.sessioncols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.pulls { margin: 0; padding-left: 22px; }
.pulls li { padding: 3px 0; cursor: pointer; }
.pulls li:hover .name { color: var(--accent); }
.pulls .meta { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- odds ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 16px; }
.packspec { margin: 0 0 8px; color: var(--muted); }
.note { color: var(--muted); font-size: 12px; }
.oddsgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 12px 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
legend { color: var(--accent); padding: 0 6px; }
fieldset label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
fieldset input { width: 90px; text-align: right; }
.sum { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.sum.bad { color: var(--danger); }
.status-list { margin: 6px 0 12px; color: var(--muted); }
.status-list li { margin: 2px 0; }
details summary { cursor: pointer; color: var(--accent2); }
.live { color: #5fd38d; font-weight: 600; }
.pslot.xs .label > * { white-space: normal; line-height: 1.3; }

/* ---------- footer ---------- */
.sitefoot { border-top: 1px solid var(--line); margin-top: 20px; padding: 18px 20px 28px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.sitefoot p { margin: 0 0 6px; max-width: 980px; }
.sitefoot a { color: var(--muted); text-decoration: underline; }
.sitefoot a:hover { color: var(--text); }
