:root {
  --bg: #0b0a10;
  --card: #15131d;
  --line: #2a2536;
  --gold: #e8b34b;
  --text: #f2eee6;
  --dim: #9a93a8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(120% 90% at 50% 0%, #1a1526 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

#app { max-width: 520px; margin: 0 auto; padding: 18px 16px 28px; }

.head { text-align: center; margin: 6px 0 18px; }
.title { font-size: 26px; font-weight: 800; letter-spacing: 1.5px; }
.title span { color: var(--gold); }
.sub { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}

.counters { display: flex; gap: 8px; }
.counter { flex: 1; text-align: center; }
.counter b { display: block; font-size: 22px; color: var(--gold); }
.counter span { font-size: 11px; color: var(--dim); }

.connect { display: flex; justify-content: center; margin-bottom: 14px; }

.buy { text-align: center; }
.price { font-size: 18px; margin-bottom: 6px; }
.price b { color: var(--gold); }
.hint { color: var(--dim); font-size: 13px; margin: 0 0 14px; }
.err { color: #ff7a7a; font-size: 13px; margin: 12px 0 0; }

button.big {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #f0c766, #d09a2c);
  color: #221a06;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
button.big:disabled { background: #2c2738; color: var(--dim); cursor: default; }

button.ghost {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  cursor: pointer;
}

.mine h2 { font-size: 15px; margin: 0 0 12px; color: var(--dim); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { border-radius: 12px; overflow: hidden; background: #100e18; border: 1px solid var(--line); }
.tile img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; }
.tile .cap { padding: 6px; font-size: 11px; text-align: center; }
.tile .cap b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .cap i { color: var(--gold); font-style: normal; font-size: 10px; }

.foot { color: #6d6679; font-size: 11px; text-align: center; margin-top: 18px; }

.stage, .reveal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: radial-gradient(70% 50% at 50% 45%, #241b33 0%, #08070c 75%);
}

.stage-text { color: var(--dim); font-size: 14px; min-height: 20px; }

.box { position: relative; width: 180px; height: 160px; animation: sway 2.4s ease-in-out infinite; }

.box .body {
  position: absolute;
  left: 10px;
  bottom: 0;
  width: 160px;
  height: 112px;
  border-radius: 10px;
  background: linear-gradient(160deg, #3a2f52, #1d1730);
  border: 1px solid #4b3f68;
  box-shadow: inset 0 -18px 30px rgba(0, 0, 0, .45);
}

.box .body::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 22px;
  height: 100%;
  margin-left: -11px;
  background: linear-gradient(180deg, var(--gold), #a8752a);
  opacity: .85;
}

.box .lid {
  position: absolute;
  left: 0;
  bottom: 104px;
  width: 180px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(160deg, #4a3c67, #2a2140);
  border: 1px solid #5a4a7a;
  transform-origin: 50% 100%;
}

.box .glow {
  position: absolute;
  left: 50%;
  bottom: 70px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: #fff6da;
  opacity: 0;
  box-shadow: 0 0 40px 20px rgba(232, 179, 75, .8);
}

.spark {
  position: absolute;
  left: 50%;
  bottom: 90px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
}

@keyframes sway {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-8px) rotate(1.5deg); }
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-7px, 0) rotate(-4deg); }
  40% { transform: translate(7px, -3px) rotate(4deg); }
  60% { transform: translate(-5px, 2px) rotate(-3deg); }
  80% { transform: translate(6px, -2px) rotate(3deg); }
}

@keyframes lid-off {
  to { transform: translate(20px, -150px) rotate(38deg); opacity: 0; }
}

@keyframes burst {
  0% { opacity: 0; transform: scale(.2); }
  35% { opacity: 1; transform: scale(1.6); }
  100% { opacity: 0; transform: scale(3.4); }
}

@keyframes fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.3); }
}

.box.opening { animation: shake .5s ease-in-out 2; }
.box.opening .lid { animation: lid-off .7s ease-out 1s forwards; }
.box.opening .glow { animation: burst 1.1s ease-out 1.05s forwards; }
.box.opening .spark { animation: fly 1.1s ease-out 1.1s forwards; }

.s1 { --dx: -90px; --dy: -120px; }
.s2 { --dx: 80px; --dy: -140px; }
.s3 { --dx: -130px; --dy: -40px; }
.s4 { --dx: 120px; --dy: -60px; }
.s5 { --dx: -40px; --dy: -170px; }
.s6 { --dx: 45px; --dy: -175px; }

.prize { text-align: center; animation: pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.prize img {
  width: min(78vw, 320px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 20px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 60px rgba(232, 179, 75, .35);
}
.prize-name { font-size: 20px; font-weight: 700; margin-top: 14px; }
.prize-rarity { color: var(--gold); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; }

.reveal button { max-width: 320px; }

@keyframes pop {
  from { opacity: 0; transform: scale(.75); }
  to { opacity: 1; transform: scale(1); }
}


