:root{
  --red:#EE1515; --red-dark:#B00d0d; --gold:#F8D030;
}

/* DARK THEME (default) */
[data-theme="dark"]{
  --bg-grad:
    radial-gradient(circle at 20% 10%, rgba(238,21,21,.18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(248,208,48,.15), transparent 45%),
    linear-gradient(160deg, #2b0a3d, #160823);
  --text:#f4ecff;
  --text-soft:rgba(244,236,255,.6);
  --panel:rgba(255,255,255,.05);
  --panel-border:rgba(255,255,255,.10);
  --input-bg:rgba(0,0,0,.3);
  --input-border:rgba(255,255,255,.2);
  --divider:rgba(255,255,255,.1);
  --card-ink:#1a1024;
  --count-bg:#1a1024;
}

/* LIGHT THEME */
[data-theme="light"]{
  --bg-grad:
    radial-gradient(circle at 20% 10%, rgba(238,21,21,.10), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(248,208,48,.16), transparent 48%),
    linear-gradient(160deg, #fef6ff, #eef1fb);
  --text:#241533;
  --text-soft:rgba(36,21,51,.55);
  --panel:rgba(255,255,255,.7);
  --panel-border:rgba(36,21,51,.10);
  --input-bg:#ffffff;
  --input-border:rgba(36,21,51,.2);
  --divider:rgba(36,21,51,.12);
  --card-ink:#1a1024;
  --count-bg:#241533;
}

*{box-sizing:border-box;}
body{
  margin:0;
  font-family:'Bricolage Grotesque', sans-serif;
  color:var(--text);
  background:var(--bg-grad);
  min-height:100vh;
  transition:background .35s ease, color .35s ease;
}
.app-root{max-width:1100px; margin:0 auto; padding:0 16px 60px;}

/* toast */
.toast{
  position:fixed; top:16px; left:50%; transform:translateX(-50%);
  background:var(--gold); color:#3a2a00; font-weight:800; font-size:14px;
  padding:10px 20px; border-radius:30px; z-index:100;
  box-shadow:0 6px 20px rgba(0,0,0,.3);
  animation:toastIn .3s ease;
}
@keyframes toastIn{from{opacity:0; transform:translate(-50%,-10px);}to{opacity:1; transform:translate(-50%,0);}}

/* header */
.header{
  display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:10px;
  padding:18px 4px;
}
.title-wrap{display:flex; align-items:center; gap:10px;}
.poke-icon{
  font-size:30px; color:var(--red);
  filter:drop-shadow(0 0 6px rgba(238,21,21,.6));
  animation:spin 6s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg);}}
.title{
  font-weight:800; font-size:clamp(22px,4vw,34px); margin:0;
  background:linear-gradient(90deg,#ff3b3b,#ffb300,#0aa2d6,#a326e0,#ff2f88);
  background-size:300% 100%;
  -webkit-background-clip:text; background-clip:text; color:transparent;
  animation:rainbow 8s linear infinite;
  letter-spacing:-1px;
}
@keyframes rainbow{to{background-position:300% 0;}}
.header-right{display:flex; align-items:center; gap:8px; flex-wrap:wrap;}
.wallet{
  font-family:'JetBrains Mono',monospace; font-size:13px; font-weight:800;
  background:rgba(34,197,94,.15); border:1px solid rgba(34,197,94,.5);
  color:#16a34a; padding:5px 12px; border-radius:20px;
}
.counter{
  font-family:'JetBrains Mono',monospace; font-size:12px;
  background:rgba(248,208,48,.18); border:1px solid rgba(248,208,48,.5);
  color:#a17a00; padding:5px 10px; border-radius:20px; font-weight:700;
}
[data-theme="dark"] .counter{color:var(--gold);}
.icon-btn{
  background:var(--panel); border:1px solid var(--panel-border); color:var(--text);
  font-size:16px; cursor:pointer; width:34px; height:34px; border-radius:9px;
  display:inline-flex; align-items:center; justify-content:center;
}
.icon-btn:hover{filter:brightness(1.1);}
.login-btn{
  background:var(--red); color:#fff; border:none; padding:8px 16px;
  border-radius:8px; font-weight:700; cursor:pointer; font-family:inherit;
  box-shadow:0 3px 0 var(--red-dark);
}
.login-btn:active{transform:translateY(2px); box-shadow:0 1px 0 var(--red-dark);}
.user-box{display:flex; align-items:center; gap:8px;}
.uname{font-size:13px; font-weight:700;}
.ghost-btn{background:transparent; border:1px solid var(--input-border); color:var(--text); padding:6px 12px; border-radius:8px; cursor:pointer; font-family:inherit; font-size:12px;}

/* guest bar */
.guest-bar{
  display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px;
  background:var(--panel); border:1px solid var(--panel-border);
  border-radius:12px; padding:12px 16px; margin-bottom:18px; font-size:13px;
}
.link-btn{background:none;border:none;color:var(--red);cursor:pointer;font-weight:700;font-family:inherit;font-size:13px;}

/* pack zone */
.pack-zone{
  background:var(--panel); border:1px solid var(--panel-border);
  border-radius:18px; padding:28px 16px; margin-bottom:28px; text-align:center;
  min-height:340px; display:flex; align-items:center; justify-content:center;
}
.pack-idle{display:flex; flex-direction:column; align-items:center; gap:16px;}
.booster{
  width:150px; height:220px; border-radius:12px; cursor:pointer; position:relative;
  overflow:hidden;
  background:linear-gradient(150deg,#ff3b3b 0%,#c20d0d 40%,#ffd23b 40%,#f8a800 100%);
  border:3px solid #fff; box-shadow:0 12px 30px rgba(0,0,0,.45);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  transition:transform .2s;
}
.booster:hover{transform:translateY(-6px) rotate(-2deg);}
.booster.disabled{filter:grayscale(.7) brightness(.8); cursor:not-allowed;}
.booster.disabled:hover{transform:none;}
.booster-shine{
  position:absolute; inset:0;
  background:linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);
  transform:translateX(-100%); animation:sweep 3s infinite;
}
@keyframes sweep{0%,60%{transform:translateX(-100%);}100%{transform:translateX(100%);}}
.booster-txt{font-weight:800; font-size:20px; color:#fff; text-shadow:0 2px 4px rgba(0,0,0,.4); letter-spacing:1px; z-index:1;}
.booster-icon{font-size:44px; color:#fff; z-index:1;}
.booster-price{
  position:absolute; bottom:8px; z-index:1; background:#fff; color:#c20d0d;
  font-weight:800; font-size:13px; padding:2px 10px; border-radius:20px;
  font-family:'JetBrains Mono',monospace;
}
.rip-btn{
  background:var(--gold); color:#3a2a00; border:none; padding:12px 28px;
  border-radius:12px; font-weight:800; font-size:16px; cursor:pointer; font-family:inherit;
  box-shadow:0 4px 0 #b89500; transition:transform .1s;
}
.rip-btn:active{transform:translateY(3px); box-shadow:0 1px 0 #b89500;}
.rip-btn:disabled{background:#b6b6b6; color:#555; box-shadow:0 4px 0 #8a8a8a; cursor:not-allowed;}
.econ-note{font-size:12px; color:var(--text-soft); max-width:420px; line-height:1.5;}
.stats-row{display:flex; gap:16px; font-size:13px; color:var(--text-soft); font-family:'JetBrains Mono',monospace; flex-wrap:wrap; justify-content:center;}
.stats-row b{color:var(--gold);}
[data-theme="light"] .stats-row b{color:#a17a00;}

.reveal-zone{display:flex; flex-direction:column; align-items:center; gap:20px; width:100%;}
.ripping{font-size:20px; font-weight:800; animation:pulse 1s infinite;}
@keyframes pulse{50%{opacity:.4;}}
.reveal-cards{display:flex; gap:12px; flex-wrap:wrap; justify-content:center;}
.reveal-slot{animation:flipin .5s cubic-bezier(.2,.9,.3,1.3) both;}
@keyframes flipin{from{opacity:0; transform:rotateY(90deg) scale(.6);}to{opacity:1; transform:none;}}
.card-placeholder{
  width:150px; height:210px; border-radius:12px; border:2px dashed var(--input-border);
  display:flex; align-items:center; justify-content:center; font-size:40px; opacity:.35;
}

/* collection */
.coll-head{display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:10px;}
.coll-head h2{font-weight:800; font-size:22px; margin:0;}
.controls{display:flex; gap:8px;}
.sel{
  background:var(--input-bg); color:var(--text); border:1px solid var(--input-border);
  padding:7px 10px; border-radius:8px; font-family:inherit; font-size:13px; cursor:pointer;
}
.sell-hint{font-size:12px; color:var(--text-soft); margin-bottom:14px;}
.empty{text-align:center; padding:50px 20px; color:var(--text-soft); font-size:16px;}
.grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:14px;}

/* card — always light-faced for readability in both themes */
.pkcard{
  position:relative; border-radius:12px; border:3px solid #9ca3af;
  background:linear-gradient(160deg,#fefefe,#e8e6f0);
  padding:8px; color:var(--card-ink); transition:transform .15s ease;
  transform-style:preserve-3d; overflow:hidden; cursor:pointer;
  box-shadow:0 6px 16px rgba(0,0,0,.35);
}
.pkcard.holo{background:linear-gradient(160deg,#fff8ff,#ffe9fb);}
.pkcard.rare{background:linear-gradient(160deg,#fffdf0,#fff2c8);}
.holo-shine{
  position:absolute; inset:0; pointer-events:none; mix-blend-mode:color-dodge;
  background:radial-gradient(circle at var(--gx,50%) var(--gy,50%),
    rgba(255,0,200,.6), rgba(0,200,255,.5) 30%, rgba(255,230,0,.4) 55%, transparent 75%);
  opacity:.55;
}
.newbadge{
  position:absolute; top:6px; right:-26px; background:var(--red); color:#fff;
  font-size:10px; font-weight:800; padding:2px 30px; transform:rotate(38deg); z-index:3;
  box-shadow:0 1px 3px rgba(0,0,0,.4);
}
.pk-top{display:flex; justify-content:space-between; align-items:center; font-size:11px; font-weight:800;}
.pk-name{max-width:100px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.pk-hp{color:var(--red); font-family:'JetBrains Mono',monospace;}
.pk-img-wrap{
  background:radial-gradient(circle,#f4f0ff,#d8d2e8); border-radius:8px;
  margin:5px 0; aspect-ratio:1/1; display:flex; align-items:center; justify-content:center;
  border:1px solid rgba(0,0,0,.08);
}
.pk-img{width:88%; height:88%; object-fit:contain;}
.pk-types{display:flex; gap:4px; flex-wrap:wrap; margin-bottom:4px;}
.pk-type{
  font-size:9px; font-weight:800; color:#fff; padding:2px 7px; border-radius:20px;
  text-transform:uppercase; text-shadow:0 1px 1px rgba(0,0,0,.3);
}
.pk-foot{display:flex; justify-content:space-between; align-items:center; font-size:10px; font-weight:800; font-family:'JetBrains Mono',monospace;}
.pk-dex{opacity:.55;}
.pk-count{background:var(--count-bg); color:#fff; padding:1px 6px; border-radius:10px;}
.sell-btn{
  margin-top:6px; width:100%; background:#16a34a; color:#fff; border:none;
  padding:6px; border-radius:8px; font-weight:800; font-size:11px; cursor:pointer;
  font-family:'JetBrains Mono',monospace; transition:filter .1s;
}
.sell-btn:hover{filter:brightness(1.1);}
.sell-btn:active{transform:translateY(1px);}

/* footer */
.footer{text-align:center; margin-top:50px; padding-top:24px; border-top:1px solid var(--divider); font-size:12px; color:var(--text-soft);}
.footer a{color:var(--gold); font-weight:700; text-decoration:none;}
[data-theme="light"] .footer a{color:#a17a00;}
.footer a:hover{text-decoration:underline;}

@media(max-width:560px){
  .booster{width:120px; height:180px;}
  .grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr));}
  .guest-bar{flex-direction:column; align-items:stretch;}
}