:root {
  --bg: #070814;
  --card: #12152a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f1ff;
  --muted: #9a96b5;
  --gold: #ffd36a;
  --common: #8d93a8;
  --uncommon: #3dce7a;
  --rare: #4aa3ff;
  --epic: #b06bff;
  --legendary: #ffc14a;
  --mythic: #ff4d6d;
  --divine: #7cf7ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", system-ui, sans-serif;
  background:
    radial-gradient(900px 420px at 80% -10%, rgba(176, 107, 255, 0.22), transparent 60%),
    radial-gradient(700px 380px at -10% 20%, rgba(74, 163, 255, 0.16), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { max-width: 560px; margin: 0 auto; padding: 14px 14px 96px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.03em; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.coins {
  background: linear-gradient(180deg, #2a2414, #1a160d);
  border: 1px solid rgba(255, 211, 106, 0.35);
  color: var(--gold);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tabs {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(532px, calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(12, 14, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 6px;
  backdrop-filter: blur(12px);
  z-index: 20;
}
.tab {
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 8px 4px 7px;
  color: var(--muted);
}
.tab b { display: block; font-size: 12px; font-weight: 700; }
.tab.on { background: #222648; color: white; }

.screen { display: none; }
.screen.on { display: block; animation: rise 0.35s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.grid { display: grid; gap: 10px; }
.case {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent), var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}
.case:active { transform: scale(0.985); }
.case .emo { font-size: 34px; }
.case h3 { margin: 0; font-size: 16px; }
.case p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.price { font-weight: 800; color: var(--gold); font-size: 14px; }
.free-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.pill {
  border: 1px solid var(--line);
  background: #171a31;
  border-radius: 16px;
  padding: 12px;
  text-align: left;
}
.pill small { display: block; color: var(--muted); font-size: 12px; }
.pill b { font-size: 15px; }
.pill.ready { border-color: rgba(61, 206, 122, 0.5); }

.stage {
  background: #0c0e1c;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px 0 16px;
  overflow: hidden;
  position: relative;
}
.pointer {
  position: absolute;
  left: 50%;
  top: 8px;
  bottom: 8px;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(var(--gold), transparent 12%, transparent 88%, var(--gold));
  z-index: 2;
  pointer-events: none;
}
.pointer:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--gold);
}
.viewport { overflow: hidden; height: 118px; }
.reel {
  display: flex;
  height: 118px;
  will-change: transform;
}
.cell {
  width: 96px;
  flex: 0 0 96px;
  margin: 8px 5px;
  border-radius: 16px;
  background: #171a2e;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
}
.cell .emo { font-size: 34px; }
.cell .nm { font-size: 10px; color: var(--muted); max-width: 84px; text-align: center; white-space: nowrap; overflow: hidden; }
.cell:after {
  content: "";
  position: absolute;
  inset: auto 10px 6px;
  height: 3px;
  border-radius: 99px;
  background: var(--tone, var(--common));
  box-shadow: 0 0 10px var(--tone, var(--common));
}
.r-common { --tone: var(--common); }
.r-uncommon { --tone: var(--uncommon); }
.r-rare { --tone: var(--rare); }
.r-epic { --tone: var(--epic); }
.r-legendary { --tone: var(--legendary); }
.r-mythic { --tone: var(--mythic); }
.r-divine { --tone: var(--divine); }

.flash {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0;
  z-index: 5;
}
.flash.go { animation: flash 0.7s ease; }
@keyframes flash {
  0% { opacity: 0; }
  25% { opacity: 0.55; }
  100% { opacity: 0; }
}

.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 8px;
  background: #262a4a;
  font-weight: 800;
}
.btn.main {
  background: linear-gradient(180deg, #7a5cff, #5436e0);
  box-shadow: 0 8px 20px rgba(84, 54, 224, 0.35);
}
.btn:disabled { opacity: 0.45; }
.case-head { margin: 4px 0 10px; }
.case-head h2 { margin: 0; font-size: 22px; }
.weights { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip {
  font-size: 12px;
  background: #171a31;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
}
.back {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0 0 8px;
}

.drop {
  margin-top: 12px;
  border-radius: 18px;
  padding: 14px;
  background: #14182d;
  border: 1px solid var(--line);
  display: none;
}
.drop.show { display: block; animation: pop 0.45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.drop h3 { margin: 0 0 8px; }
.loot { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.loot .cell { flex: 0 0 92px; height: 96px; margin: 0; }
.sum { margin-top: 8px; color: var(--muted); font-size: 13px; }
.sum b { color: var(--text); }

.list { display: grid; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--tone, var(--common));
  border-radius: 16px;
  padding: 10px;
  text-align: left;
  width: 100%;
}
.item .emo { font-size: 26px; }
.item h3 { margin: 0; font-size: 15px; }
.item p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet.on { display: flex; }
.panel {
  width: min(560px, 100%);
  background: #121528;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px 24px;
  animation: sheet 0.28s ease;
}
@keyframes sheet { from { transform: translateY(24px); } }
.panel h2 { margin: 0; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.row .btn { flex: 1; }
.danger { background: #5a2433 !important; }
.note { color: var(--muted); font-size: 13px; line-height: 1.4; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
}
.bar { height: 8px; background: #232742; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #7a5cff, #ffd36a); width: 0; }
.stat { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stat:last-child { border-bottom: 0; }
.rank { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.toast {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%) translateY(-20px);
  background: #222648;
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 14px;
  opacity: 0;
  z-index: 40;
  transition: 0.25s ease;
  max-width: 90%;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.spinning .reel { filter: saturate(1.15); }
