:root { --ink: #2a1e3a; --cream: #fff4e0; --paper: #fffaf2; --char: #8a4ad0; --act: #e8503a; --item: #2a8ae8; --loc: #2aa86a; --gold: #ffc43a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 20% 10%, #ffe6c8, transparent 40%), radial-gradient(circle at 90% 80%, #d8ecff, transparent 45%), var(--cream); color: var(--ink); font-family: "Fredoka", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
.btn { border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); padding: 10px 16px; font-weight: 700; font-size: 16px; box-shadow: 0 4px 0 var(--ink); transition: transform .06s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 20px; padding: 14px 22px; }
.btn.a { background: linear-gradient(#ffd86a, #ffb020); }
.btn.b { background: linear-gradient(#a8d8ff, #5aa8f0); }
.btn.c { background: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border-width: 2px; }
.btn.on { background: var(--gold); }

/* menu */
.menu { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; }
.family { display: flex; gap: 10px; font-size: 48px; }
.family span { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; background: var(--c); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink); animation: bob 2.4s ease-in-out infinite; }
.family span:nth-child(2) { animation-delay: .3s; } .family span:nth-child(3) { animation-delay: .6s; } .family span:nth-child(4) { animation-delay: .9s; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }
.menu h1 { margin: 10px 0 0; font-size: clamp(34px, 7vw, 60px); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink), 0 0 30px #ffb020; letter-spacing: .03em; }
.menu .sub { margin: 0 0 10px; font-weight: 600; }
.menu .col { display: flex; flex-direction: column; gap: 10px; width: min(340px, 90vw); }

.page { padding: 16px; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; padding: 18px; box-shadow: 0 6px 0 var(--ink); line-height: 1.7; }
.picker h3 { margin: 4px 0 8px; }
.heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.hero { background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 10px; cursor: pointer; box-shadow: 0 4px 0 var(--ink); text-align: center; }
.hero.sel { background: #fff2c0; box-shadow: 0 4px 0 var(--ink), 0 0 0 4px var(--gold); }
.hero .pv { font-size: 12.5px; line-height: 1.45; margin-top: 4px; color: #5a4a6a; }
.hero .spv { font-weight: 700; color: #d8304a; }
.av { width: 64px; height: 64px; border-radius: 50%; background: var(--c); border: 3px solid var(--ink); display: inline-grid; place-items: center; font-size: 38px; position: relative; flex: none; }
.av.big { width: 96px; height: 96px; font-size: 58px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { flex: 1; min-width: 180px; border: 3px solid var(--ink); border-radius: 12px; padding: 9px 12px; font: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* cards */
.card { position: relative; width: 150px; min-height: 210px; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper); padding: 8px 8px 18px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; text-align: center; transition: transform .12s; }
.card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 58px; border-radius: 10px 10px 0 0; background: var(--tc); opacity: .9; }
.t-character { --tc: var(--char); } .t-action { --tc: var(--act); } .t-item { --tc: var(--item); } .t-location { --tc: var(--loc); }
.card .cost { position: absolute; left: -10px; top: -10px; width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc21a 60%, #e89a10); border: 3px solid var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 17px; z-index: 2; }
.card .cost.cheaper { background: radial-gradient(circle at 35% 30%, #d8ffd0, #4ad86a); } .card .cost.pricier { background: radial-gradient(circle at 35% 30%, #ffd8d0, #ff6a5a); }
.card .sig { position: absolute; right: 4px; top: 4px; font-size: 10px; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 0 4px; z-index: 2; }
.card .art { position: relative; font-size: 44px; line-height: 1; margin-top: 8px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.card .nm { position: relative; font-weight: 700; font-size: 15px; margin-top: 8px; line-height: 1.15; }
.card .ty { font-size: 11px; color: #fff; background: var(--tc); border-radius: 8px; padding: 0 8px; margin: 3px 0 5px; }
.card .fx { font-size: 11.5px; line-height: 1.35; color: #4a3a5a; }
.card .id { position: absolute; bottom: 3px; right: 7px; font-size: 9px; opacity: .45; }
.card.dim { filter: grayscale(.6) brightness(.95); }
.card.small { width: 116px; min-height: 160px; padding: 6px 6px 14px; }
.card.small::before { height: 46px; } .card.small .art { font-size: 34px; } .card.small .nm { font-size: 13px; } .card.small .fx { font-size: 10px; }

/* the battle */
.game { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto auto; gap: 8px; padding: 8px; max-width: 1200px; margin: 0 auto; }
.side { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; padding: 8px 12px; box-shadow: 0 4px 0 var(--ink); }
.side.active { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px var(--gold); }
.hero-box { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 280px; }
.hero-box .info { flex: 1; }
.spbar { position: relative; height: 22px; background: #f0e0e0; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; margin: 2px 0; }
.spbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff8a9a, #e8304a); transition: width .4s; }
.spbar span { position: relative; font-weight: 700; font-size: 13px; padding-left: 8px; line-height: 16px; }
.en { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.en i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--ink); background: #ddd; }
.en i.on { background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc21a); }
.en span { font-size: 12px; font-weight: 700; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { font-size: 11px; font-weight: 700; border: 2px solid var(--ink); border-radius: 10px; padding: 0 6px; background: #fff; }
.chip.bad { background: #ffe0e0; } .chip.good { background: #dcffe0; } .chip.sh { background: #e0f0ff; }
.counts { font-size: 13px; font-weight: 700; text-align: right; }
.board-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mini { width: 48px; height: 52px; border: 3px solid var(--ink); border-radius: 12px; background: var(--tc); display: grid; place-items: center; font-size: 24px; position: relative; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.mini small { position: absolute; bottom: -8px; right: -8px; background: #fff; border: 2px solid var(--ink); border-radius: 50%; width: 22px; height: 22px; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.pop { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 20px; font-weight: 700; animation: pop 1.1s ease-out forwards; -webkit-text-stroke: 1px #fff; }
.pop.neg { color: #e8304a; } .pop.pos { color: #2aa84a; }
@keyframes pop { 0% { transform: translate(-50%, 6px) scale(.6); opacity: 0; } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.3); } 100% { transform: translate(-50%, -26px) scale(1); opacity: 0; } }
.mid { display: grid; grid-template-columns: 130px 130px 1fr auto; gap: 10px; align-items: center; background: rgba(255,255,255,.55); border: 3px dashed rgba(42,30,58,.35); border-radius: 18px; padding: 8px; min-height: 190px; }
.loc, .spot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.loc .empty { width: 116px; height: 160px; border: 3px dashed rgba(42,30,58,.4); border-radius: 14px; display: grid; place-items: center; text-align: center; font-size: 12px; color: #8a7a9a; padding: 8px; }
.lbl { font-size: 12px; font-weight: 700; }
.spot .fly { animation: fly .5s ease-out; }
@keyframes fly { from { transform: translateY(60px) scale(.6) rotate(-8deg); opacity: 0; } }
.log { font-size: 13px; line-height: 1.5; max-height: 170px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.log div:last-child { font-weight: 700; }
.endt { white-space: nowrap; }
.hand { display: flex; justify-content: flex-start; gap: 0; padding: 6px 4px 14px; overflow-x: auto; min-height: 120px; }
.hand .card:first-child { margin-left: auto; } .hand .card:last-child { margin-right: auto; }
.hand .card + .card { margin-left: -18px; }
.hand .card { flex: none; transform: rotate(calc(var(--i) * 2deg)) translateY(calc(var(--i) * var(--i) * 2px)); }
.hand .card:hover { transform: translateY(-14px) scale(1.04); z-index: 3; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(42,30,58,.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.preview { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview .card { transform: scale(1.35); margin: 50px 0 40px; cursor: default; }
.preview .btn.ghost { background: #fff; }
.preview .note { background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 4px 10px; font-weight: 700; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pass { background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; padding: 26px; text-align: center; box-shadow: 0 8px 0 var(--ink); max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pass h2 { margin: 6px 0; }
#toast { position: fixed; top: 14px; left: 50%; transform: translate(-50%, -20px); background: var(--ink); color: #fff; padding: 8px 18px; border-radius: 20px; font-weight: 700; opacity: 0; transition: .2s; z-index: 30; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .mid { grid-template-columns: 1fr 1fr; }
  .mid .log { grid-column: 1 / -1; max-height: 90px; }
  .mid .endt { grid-column: 1 / -1; }
  .card { width: 128px; min-height: 186px; } .card .fx { font-size: 10.5px; }
  .hand { justify-content: flex-start; }
  .hand .card { transform: none; }
  .hand .card + .card { margin-left: -40px; }
}
.hero .av { display: grid; margin: 0 auto 4px; } .hero b { display: block; }
.page > .btn.ghost:first-child { align-self: flex-start; }
.game { grid-template-columns: minmax(0, 1fr); }
.pass { width: min(420px, 100%); }
@media (max-width: 760px) { .hero-box { min-width: 0; } .side { padding: 6px 8px; } .av { width: 52px; height: 52px; font-size: 30px; } .mid { min-height: 0; } }

/* ---------- rarity ---------- */
:root { --r-common: #9aa3b5; --r-rare: #2a8ae8; --r-epic: #9b4ae0; --r-legendary: #f0a800; }
.r-common { --rc: var(--r-common); } .r-rare { --rc: var(--r-rare); } .r-epic { --rc: var(--r-epic); } .r-legendary { --rc: var(--r-legendary); } .r-hero { --rc: #e8503a; }
.card .gem { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%) rotate(45deg); width: 16px; height: 16px; background: var(--rc); border: 3px solid var(--ink); border-radius: 3px; z-index: 2; }
.card.r-rare { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--r-rare) inset; }
.card.r-epic { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--r-epic) inset, 0 0 14px rgba(155,74,224,.45); }
.card.r-legendary { box-shadow: 0 4px 0 var(--ink), 0 0 0 3px var(--r-legendary) inset, 0 0 18px rgba(240,168,0,.6); background: linear-gradient(135deg, #fffaf0, #fff1c8 45%, #fffaf0 55%, #ffeab0); background-size: 250% 250%; animation: foil 4s ease-in-out infinite; }
@keyframes foil { 50% { background-position: 100% 100%; } }
.card.locked { filter: grayscale(1) opacity(.42); }
.card.locked::after { content: '🔒'; position: absolute; top: 64px; left: 50%; transform: translateX(-50%); font-size: 30px; }
.card .cnt { position: absolute; right: -8px; bottom: 14px; background: var(--ink); color: #fff; border-radius: 10px; padding: 0 7px; font-weight: 700; font-size: 13px; z-index: 3; }
.card .badge { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); background: #ff4a6a; color: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 0 8px; font-size: 11px; font-weight: 700; white-space: nowrap; z-index: 3; }
i.g { display: inline-block; width: 11px; height: 11px; transform: rotate(45deg); background: var(--rc); border: 2px solid var(--ink); border-radius: 2px; margin: 0 6px 0 2px; vertical-align: -1px; }

/* ---------- menu, pages ---------- */
.wallet { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; font-weight: 700; }
.wallet span { background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 3px 12px; }
.wallet .fp { background: #ffe0ea; }
.menu .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.pk { background: linear-gradient(#ffb0c8, #ff6a9a); position: relative; }
.btn .dot { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 12px; background: #e8304a; color: #fff; border: 2px solid var(--ink); font-size: 14px; margin-left: 4px; }
.btn.sm { padding: 6px 10px; font-size: 14px; box-shadow: 0 3px 0 var(--ink); border-width: 2px; }
.btn.ghost.sm { box-shadow: none; }
.btn.hb { font-size: 20px; padding: 2px 8px; }
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar h2 { margin: 0; flex: 1; font-size: 24px; }
.note { margin: 0; font-weight: 600; color: #5a4a6a; }
.filters { display: flex; flex-direction: column; gap: 6px; }
.reward { font-size: 20px; font-weight: 700; color: #b07800; }

/* ---------- shop ---------- */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.packcard { background: var(--paper); border: 3px solid var(--ink); border-radius: 18px; padding: 12px; box-shadow: 0 5px 0 var(--ink); text-align: center; display: flex; flex-direction: column; gap: 8px; }
.packcard p { margin: 0; font-size: 13px; min-height: 34px; }
.packart, .bigpack { position: relative; border: 3px solid var(--ink); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.35); overflow: hidden; background: var(--pk); }
.packart { height: 150px; } .packart span { font-size: 56px; } .packart b { font-size: 18px; }
.packart::after, .bigpack::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.45) 45%, transparent 60%); background-size: 250% 100%; animation: shine 2.8s linear infinite; }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.p-basic { --pk: linear-gradient(160deg, #ff7a5a, #ff3a7a 60%, #a03ad8); }
.p-jeff { --pk: linear-gradient(160deg, #5aa0ff, #3a5ad8); } .p-erin { --pk: linear-gradient(160deg, #ff8ab8, #d8407a); }
.p-josh { --pk: linear-gradient(160deg, #5ad88a, #1a8a5a); } .p-jasper { --pk: linear-gradient(160deg, #ffd04a, #f08a10); }

/* ---------- opening a pack ---------- */
.opening { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; background: radial-gradient(circle, #3a2a5a, #1a1030); color: #fff; }
.opening .hint { font-size: 20px; font-weight: 700; margin: 0; }
.bigpack { width: 220px; height: 310px; cursor: pointer; animation: wobble 1.6s ease-in-out infinite; box-shadow: 0 0 40px rgba(255,200,120,.5); }
.bigpack span { font-size: 90px; } .bigpack b { font-size: 22px; }
@keyframes wobble { 25% { transform: rotate(-3deg) scale(1.02); } 75% { transform: rotate(3deg) scale(1.02); } }
.bigpack.torn { animation: tear .55s ease-in forwards; }
@keyframes tear { 30% { transform: scale(1.15) rotate(-4deg); } 100% { transform: scale(1.6); opacity: 0; filter: brightness(3); } }
.reveal { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; perspective: 900px; }
.flip { position: relative; width: 150px; height: 214px; cursor: pointer; transform-style: preserve-3d; transition: transform .55s; animation: deal .45s ease-out; }
@keyframes deal { from { translate: 0 -90px; scale: .5; rotate: -12deg; } }
.flip .back, .flip .card { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip .back { border: 3px solid var(--ink); border-radius: 14px; background: repeating-linear-gradient(45deg, #5a3ab0 0 12px, #4a2a98 12px 24px); display: grid; place-items: center; font-size: 50px; box-shadow: 0 0 0 3px var(--rc) inset, 0 0 18px var(--rc); }
.flip.r-epic .back { animation: pulse 1s ease-in-out infinite; } .flip.r-legendary .back { animation: pulse .6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--rc) inset, 0 0 40px var(--rc); } }
.flip .card { transform: rotateY(180deg); width: 150px; color: var(--ink); }
.flip.open { transform: rotateY(180deg); }
.flip.open.r-legendary .card, .flip.open.r-epic .card { animation: glow 1.2s ease-out; }
@keyframes glow { from { box-shadow: 0 0 0 0 var(--rc), 0 0 80px 30px var(--rc); } }
.opening.flash { animation: flash .7s ease-out; }
@keyframes flash { 0% { background: #fff6c0; } }
.summary { text-align: center; } .summary p { font-size: 18px; font-weight: 700; }
.opening .btn.ghost { color: #fff; border-color: #fff; }

/* ---------- decks ---------- */
.decklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.decktile { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 10px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.decktile.sel { background: #fff2c0; box-shadow: 0 4px 0 var(--ink), 0 0 0 4px var(--gold); }
.decktile.bad { opacity: .75; }
.decktile .av { width: 52px; height: 52px; font-size: 30px; }
.dinfo { flex: 1; display: flex; flex-direction: column; min-width: 150px; } .dinfo small { color: #5a4a6a; font-weight: 600; }
.decktile .row { width: 100%; justify-content: flex-end; }
.decktile.quick { border-style: dashed; }
.heroes.small { grid-template-columns: repeat(4, 1fr); } .heroes.small .hero { padding: 8px 4px; }

/* ---------- deck editor ---------- */
.editor { max-width: 1300px; }
.dname { flex: 1; min-width: 160px; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 12px; font: inherit; font-weight: 700; }
.edwrap { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.deckside { position: sticky; top: 8px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 10px; box-shadow: 0 4px 0 var(--ink); display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 20px); }
.dhead { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.okc { color: #1a8a4a; font-weight: 700; } .badc { color: #c0284a; font-weight: 700; }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; height: 70px; align-items: end; }
.curve .bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.curve .bar i { width: 100%; background: linear-gradient(#ffd86a, #ffb020); border: 2px solid var(--ink); border-radius: 4px 4px 0 0; min-height: 2px; }
.curve .bar span { position: absolute; top: 0; font-size: 11px; font-weight: 700; } .curve .bar small { font-size: 11px; font-weight: 700; }
.dlist { overflow-y: auto; display: flex; flex-direction: column; gap: 3px; min-height: 60px; }
.drow { display: flex; align-items: center; gap: 6px; border: 2px solid var(--ink); border-left: 8px solid var(--tc); border-radius: 8px; padding: 2px 6px; background: #fff; cursor: pointer; font-size: 13px; font-weight: 600; }
.drow:hover { background: #ffe8e8; } .drow.over { background: #ffd0d8; }
.drow .dc { width: 22px; height: 22px; border-radius: 50%; background: #ffc21a; border: 2px solid var(--ink); display: grid; place-items: center; font-size: 12px; flex: none; }
.drow .dn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .drow .dx { font-weight: 700; }
.deckmain { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.deckmain .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid .card { width: auto; }
@media (max-width: 760px) {
  .edwrap { grid-template-columns: 1fr; }
  .deckside { position: static; max-height: none; } .dlist { max-height: 220px; }
  .flip, .flip .card { width: 120px; } .flip { height: 180px; }
  .bigpack { width: 180px; height: 250px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
}
