:root {
  --bg: #090b14;
  --bg2: #0d1020;
  --panel: #12162a;
  --panel2: #181d34;
  --panel3: #212844;
  --line: #1f2540;
  --line2: #2c3458;
  --text: #f1f3fb;
  --muted: #7a83a8;
  --accent: #00e57a;
  --accent-hi: #45ffa6;
  --accent-ink: #03150c;
  --violet: #7b61ff;
  --danger: #ff4560;
  --gold: #ffc93c;
  --radius: 18px;
  --glow: #00e57a;
}

* { box-sizing: border-box; }
html { scrollbar-color: var(--line2) var(--bg); }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 14px/1.4 Rubik, system-ui, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
  overflow-x: clip; /* clip stray glow/particles without breaking position: sticky */
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(1000px 520px at 10% -15%, rgba(123,97,255,.20), transparent 60%),
    radial-gradient(900px 520px at 90% -15%, rgba(0,229,122,.12), transparent 60%),
    radial-gradient(1200px 700px at 50% 120%, rgba(123,97,255,.08), transparent 60%);
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.money { color: var(--accent); }
.count {
  font-size: 12px; font-weight: 700; color: var(--muted); background: var(--panel2);
  padding: 3px 9px; border-radius: 999px; vertical-align: middle; margin-left: 6px;
}

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-hi), var(--accent));
  box-shadow: 0 0 24px rgba(0,229,122,.4), inset 0 -3px 0 rgba(0,0,0,.15);
}
.logo-mark svg { width: 21px; height: 21px; fill: var(--accent-ink); }
.logo-text { font-weight: 900; font-size: 20px; letter-spacing: .4px; font-style: italic; }
.logo-text b { color: var(--accent); font-weight: 900; }
.logo.big .logo-mark { width: 52px; height: 52px; border-radius: 15px; }
.logo.big .logo-mark svg { width: 28px; height: 28px; }
.logo.big .logo-text { font-size: 30px; }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; gap: 32px; padding: 0 28px; height: 72px;
  background: rgba(13,16,32,.88); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px);
}
nav { display: flex; gap: 4px; flex: 1; height: 100%; }
nav button {
  display: flex; align-items: center; gap: 9px; background: none; border: 0; height: 100%;
  padding: 0 16px; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 15px; position: relative;
  transition: color .15s;
}
nav button svg { width: 19px; height: 19px; fill: currentColor; }
nav button:hover { color: var(--text); }
nav button.active { color: var(--text); }
nav button.active::before {
  content: ''; position: absolute; inset: 14px 4px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(0,229,122,.12), rgba(0,229,122,0)); z-index: -1;
}
nav button.active::after {
  content: ''; position: absolute; left: 16px; right: 16px; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--accent); box-shadow: 0 0 14px var(--accent);
}
nav button.active svg { color: var(--accent); fill: var(--accent); }
.account { display: flex; align-items: center; gap: 12px; }
.balance-pill {
  display: flex; align-items: center; gap: 9px; background: var(--panel2);
  border: 1px solid var(--line2); padding: 9px 16px; border-radius: 13px; font-weight: 700;
}
.balance-pill b { color: var(--accent); font-size: 16px; }
.balance-pill svg { width: 19px; height: 19px; fill: var(--accent); }
.balance-pill.bump { animation: bump .5s ease; }
@keyframes bump { 30% { transform: scale(1.08); border-color: var(--accent); } }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--violet), #c05cff);
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line2);
  background: var(--panel2); cursor: pointer; display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Live feed ---------- */
.live { display: flex; align-items: stretch; background: var(--bg2); border-bottom: 1px solid var(--line); }
.live-badge {
  flex: 0 0 auto; writing-mode: vertical-rl; transform: rotate(180deg); display: flex; align-items: center;
  justify-content: center; gap: 7px; padding: 0 12px; font-size: 11px; font-weight: 800; letter-spacing: 2.5px;
  color: var(--accent); border-left: 1px solid var(--line);
  background: linear-gradient(0deg, rgba(0,229,122,.06), transparent);
}
.live-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.feed { display: flex; gap: 6px; padding: 8px; overflow: hidden; flex: 1; min-height: 108px;
  mask-image: linear-gradient(90deg, #000 85%, transparent); }
.feed-item {
  position: relative; flex: 0 0 auto; width: 148px; height: 92px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(0deg, color-mix(in srgb, var(--rc) 22%, var(--panel)) 0%, var(--panel) 70%);
  border-top: 2px solid var(--rc); animation: slidein .6s cubic-bezier(.2,.9,.3,1.1);
}
.feed-item::before {
  content: ''; position: absolute; left: 50%; top: 38%; width: 110px; height: 70px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--rc), transparent); opacity: .35;
}
.feed-item img { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); height: 50px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
.feed-item .fi-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 9px 6px; font-size: 10.5px; line-height: 1.25; }
.feed-item .fi-skin { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .fi-w { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .fi-hover {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(9,11,20,.93); opacity: 0; transition: opacity .2s; font-size: 11.5px; gap: 3px;
}
.feed-item:hover .fi-hover { opacity: 1; }
.feed-item.lose { filter: grayscale(.9) brightness(.55); }
@keyframes slidein { from { width: 0; opacity: 0; margin-left: -6px; transform: scale(.6); } }

main { width: 100%; max-width: 1400px; margin: 0 auto; padding: 26px; flex: 1; }

/* ---------- Buttons / inputs ---------- */
.btn {
  background: var(--panel2); border: 1px solid var(--line2); padding: 10px 18px;
  border-radius: 12px; cursor: pointer; font-weight: 600; transition: .15s;
}
.btn:hover { border-color: #46507a; background: var(--panel3); }
.btn.ghost { background: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink); border: 0; box-shadow: 0 6px 24px -6px rgba(0,229,122,.6);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: rgba(255,69,96,.12); border-color: rgba(255,69,96,.35); color: #ff8b9b; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.more { display: block; margin: 16px auto 0; }
input, select {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 10px 14px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
input.narrow { width: 90px; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h2, .panel h3 { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ph-title { display: flex; align-items: center; gap: 10px; }
.ph-title h3 { font-size: 17px; }
.ph-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line2);
}
.ph-icon svg { width: 18px; height: 18px; fill: currentColor; }
.ph-icon.accent { color: var(--accent); background: rgba(0,229,122,.1); border-color: rgba(0,229,122,.25); }

/* ---------- Auth ---------- */
.auth-card {
  max-width: 430px; margin: 60px auto; padding: 38px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 22px; text-align: center;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.7), 0 0 0 1px rgba(0,229,122,.05);
}
.auth-card form { display: grid; gap: 10px; margin: 16px 0; }
.tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin-top: 22px; }
.tab { flex: 1; background: none; border: 0; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--panel3); color: var(--text); }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ================= UPGRADE STAGE ================= */
.stage {
  position: relative; display: grid; grid-template-columns: 1fr 440px 1fr; gap: 24px; align-items: stretch;
  border-radius: 26px; padding: 28px; overflow: hidden; isolation: isolate;
  background: linear-gradient(180deg, #11152a 0%, #0b0e1c 100%);
  border: 1px solid var(--line);
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.8);
}
.stage::before {
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .55;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(55% 75% at 50% 50%, #000, transparent);
}
.stage-glow {
  position: absolute; left: 50%; top: 50%; width: 900px; height: 520px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--glow), transparent); opacity: .16; z-index: -1;
  transition: background .6s, opacity .6s; pointer-events: none;
}
.stage.result-win .stage-glow { opacity: .35; background: radial-gradient(closest-side, var(--accent), transparent); }
.stage.result-lose .stage-glow { opacity: .3; background: radial-gradient(closest-side, var(--danger), transparent); }

.side {
  position: relative; display: flex; flex-direction: column; border-radius: 22px; padding: 20px;
  background: linear-gradient(180deg, rgba(24,29,52,.75), rgba(13,16,32,.75));
  border: 1px solid var(--line2); min-height: 420px; overflow: hidden;
  transition: border-color .4s, box-shadow .4s, transform .4s, opacity .4s;
}
.side::before {
  content: ''; position: absolute; left: 50%; top: 46%; width: 340px; height: 340px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--sc, transparent), transparent); opacity: .3; pointer-events: none;
  transition: background .4s;
}
.side::after {
  content: ''; position: absolute; left: 24px; right: 24px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--sc, var(--line2)); box-shadow: 0 0 16px var(--sc, transparent); transition: background .4s;
}
.side-head { position: relative; display: flex; justify-content: space-between; align-items: center; }
.side-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.8px; color: var(--muted); }
.side-count {
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; background: rgba(255,255,255,.05);
  color: var(--text);
}
.side-body {
  position: relative; flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; align-content: center;
  justify-content: center; min-height: 250px;
}
.side-body .empty { color: var(--muted); text-align: center; font-weight: 500; }
.empty-ico {
  width: 96px; height: 96px; margin: 0 auto 14px; border-radius: 28px; display: grid; place-items: center;
  border: 2px dashed var(--line2); color: var(--line2);
}
.empty-ico svg { width: 40px; height: 40px; fill: currentColor; }
.side-foot { position: relative; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.sum span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.sum b { font-size: 24px; font-weight: 800; color: var(--accent); letter-spacing: -.5px; }
.bal-add {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600;
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 11px; padding: 0 0 0 12px;
}
.bal-add input { width: 96px; border: 0; background: none; padding: 9px 12px 9px 0; text-align: right; font-weight: 700; }
.clear-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-weight: 600; padding: 6px; }
.clear-btn:hover { color: var(--danger); }

.stage.spinning .side { opacity: .9; }
.side.win { border-color: var(--accent); box-shadow: 0 0 60px -10px rgba(0,229,122,.6) inset, 0 0 40px -10px rgba(0,229,122,.6); transform: scale(1.02); }
.side.lose { border-color: var(--danger); box-shadow: 0 0 60px -10px rgba(255,69,96,.5) inset; }
.side.lose .big-item img { animation: burnout 1s forwards; }
@keyframes burnout { to { filter: grayscale(1) brightness(.35); transform: scale(.88) rotate(-4deg); } }
.side.win .big-item img { animation: winpop .8s cubic-bezier(.2,1.4,.4,1); }
@keyframes winpop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } }

.big-item { position: relative; text-align: center; width: 100%; }
.big-item img {
  position: relative; width: 100%; max-width: 320px; height: 190px; object-fit: contain;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.6)); animation: pop .45s cubic-bezier(.2,1.3,.4,1);
}
.big-item .bi-weapon { position: relative; color: var(--muted); font-size: 13px; margin-top: 8px; font-weight: 500; }
.big-item .bi-skin { position: relative; font-weight: 800; font-size: 19px; }
.big-item .bi-tags { position: relative; display: flex; gap: 5px; justify-content: center; margin-top: 8px; }
.float-anim img { animation: pop .45s cubic-bezier(.2,1.3,.4,1), float 4s ease-in-out .45s infinite; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
@keyframes float { 50% { transform: translateY(-8px); } }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.mini-item {
  position: relative; padding: 8px 6px 6px; border-radius: 12px; text-align: center; font-size: 11px; font-weight: 700;
  background: linear-gradient(0deg, color-mix(in srgb, var(--rc) 25%, var(--panel)), var(--panel) 75%);
  border: 1px solid var(--line2); animation: pop .3s ease;
}
.mini-item img { width: 100%; height: 56px; object-fit: contain; }
.mini-item .p { color: var(--accent); }

/* ---------- Wheel ---------- */
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; position: relative; }
.wheel-wrap { position: relative; width: 400px; height: 400px; --arc1: #45ffa6; --arc2: #00c46a; }
.wheel-halo {
  position: absolute; inset: 30px; border-radius: 50%;
  box-shadow: 0 0 80px -10px color-mix(in srgb, var(--arc2) 50%, transparent);
  transition: box-shadow .4s;
}
.wheel { position: relative; width: 100%; height: 100%; display: block; overflow: visible; }
.wheel-outer { fill: rgba(13,16,32,.6); stroke: var(--line2); stroke-width: 1.5; }
.wheel .tick { stroke: #2a3256; stroke-width: 2; stroke-linecap: round; transition: stroke .2s; }
.wheel .tick.major { stroke: #424c7a; stroke-width: 3; }
.wheel .tick.in { stroke: color-mix(in srgb, var(--arc1) 70%, #fff); }
.wheel-track { fill: none; stroke: #161b30; stroke-width: 24; }
.wheel-arc {
  fill: none; stroke: url(#arcGrad); stroke-width: 24;
  filter: drop-shadow(0 0 10px var(--arc2));
  transform-origin: 200px 200px; transform: rotate(90deg);
  transition: stroke-dasharray .45s cubic-bezier(.3,1.2,.5,1), transform .45s cubic-bezier(.3,1.2,.5,1);
}
.wheel-inner { fill: url(#innerGrad); }
.wheel-inner-ring { fill: none; stroke: rgba(255,255,255,.06); stroke-width: 1.5; }
.pointer { position: absolute; inset: 0; pointer-events: none; will-change: transform; }
.pointer i {
  position: absolute; left: 50%; top: 14px; width: 26px; height: 40px; margin-left: -13px; background: #fff;
  clip-path: polygon(50% 100%, 0 0, 100% 0); filter: drop-shadow(0 0 10px #fff);
}
.pointer::after {
  content: ''; position: absolute; left: 50%; top: 28px; width: 4px; height: 26px; margin-left: -2px;
  background: linear-gradient(#fff, transparent); opacity: .5; border-radius: 2px;
}
.wheel-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.chance { font-size: 58px; font-weight: 900; letter-spacing: -2px; line-height: 1; transition: color .3s, text-shadow .3s; font-variant-numeric: tabular-nums; }
.chance small { font-size: 28px; margin-left: 2px; color: var(--muted); }
.chance-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 2.5px; font-weight: 700; margin-top: 8px; }
.roll { margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--muted); min-height: 16px; font-variant-numeric: tabular-nums; }
.wheel-wrap.win { --arc1: #6dffbb; --arc2: #00e57a; }
.wheel-wrap.win .chance { color: var(--accent); text-shadow: 0 0 30px rgba(0,229,122,.8); }
.wheel-wrap.win .chance small { color: var(--accent); }
.wheel-wrap.lose { --arc1: #ff7a8d; --arc2: #ff2e4d; }
.wheel-wrap.lose .chance { color: var(--danger); text-shadow: 0 0 30px rgba(255,69,96,.7); }
.wheel-wrap.lose .chance small { color: var(--danger); }
.wheel-wrap.shake { animation: shake .5s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translate(-1px, 0); } 20%, 80% { transform: translate(3px, 1px); }
  30%, 50%, 70% { transform: translate(-5px, -1px); } 40%, 60% { transform: translate(5px, 1px); }
}
.burst { position: absolute; left: -100px; top: -100px; width: 600px; height: 600px; pointer-events: none; z-index: 3; }

.controls { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 13px; padding: 4px; }
.seg button {
  display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 14px; border-radius: 10px;
  cursor: pointer; color: var(--muted); font-weight: 700; font-size: 13px; transition: .15s;
}
.seg button svg { width: 15px; height: 15px; fill: currentColor; }
.seg button.active { background: var(--panel3); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.seg button.active svg { fill: var(--accent); }
.sound-btn {
  width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line2); background: var(--bg2);
  display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.sound-btn.off { color: var(--muted); }
.sound-btn svg { width: 19px; height: 19px; }

.mults { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mults button {
  background: rgba(255,255,255,.03); border: 1px solid var(--line2); border-radius: 10px;
  padding: 8px 12px; cursor: pointer; font-weight: 800; font-size: 13px; transition: .15s;
}
.mults button:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,229,122,.08); transform: translateY(-1px); }
.mults button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 18px -4px var(--accent); }

.upgrade-btn {
  position: relative; overflow: hidden; width: 100%; padding: 19px; border: 0; border-radius: 16px; cursor: pointer;
  font-size: 19px; font-weight: 900; text-transform: uppercase; letter-spacing: 3px; color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: 0 12px 40px -10px rgba(0,229,122,.75), inset 0 -4px 0 rgba(0,0,0,.15), inset 0 2px 0 rgba(255,255,255,.35);
  transition: transform .12s, filter .15s;
}
.upgrade-btn::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); transform: skewX(-20deg);
  animation: shine 3s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.upgrade-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.upgrade-btn:active { transform: translateY(1px) scale(.99); }
.upgrade-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; transform: none; }
.upgrade-btn:disabled::after { display: none; }

/* ---------- Pickers / grids ---------- */
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.picker .grid { max-height: 620px; overflow-y: auto; padding: 2px 4px 2px 2px; align-content: start; }
.picker .panel-head input[type=search] { width: 210px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 14px; }
.chips button {
  border: 1px solid var(--line2); background: none; border-radius: 999px; padding: 6px 13px;
  font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; transition: .15s;
}
.chips button:hover { color: var(--text); }
.chips button.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; }
.grid .empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 0; }
.grid::-webkit-scrollbar { width: 6px; }
.grid::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

.item {
  position: relative; border-radius: 15px; padding: 10px 11px 13px; cursor: pointer; overflow: hidden;
  background: linear-gradient(0deg, color-mix(in srgb, var(--rc) 20%, #12162a) 0%, #161b31 55%, #171c33 100%);
  border: 1px solid var(--line2); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.item::before {
  content: ''; position: absolute; left: 50%; top: 40%; width: 150px; height: 100px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, var(--rc), transparent); opacity: .3; transition: opacity .2s, transform .2s;
}
.item::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--rc); box-shadow: 0 0 14px var(--rc); }
.item:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--rc) 55%, var(--line2)); box-shadow: 0 12px 30px -14px var(--rc); }
.item:hover::before { opacity: .55; transform: translate(-50%, -50%) scale(1.15); }
.item:hover img { transform: scale(1.07) rotate(-2deg); }
.item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, 0 10px 30px -12px rgba(0,229,122,.7); }
.item.disabled { opacity: .3; pointer-events: none; }
.item img {
  position: relative; display: block; width: 100%; height: 88px; object-fit: contain; margin: 12px 0 8px;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.55)); transition: transform .25s;
}
.item .tags { position: absolute; top: 9px; left: 9px; right: 9px; display: flex; gap: 4px; z-index: 1; }
.tag-wear, .tag-st {
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: rgba(255,255,255,.08); color: #aab2d4;
  letter-spacing: .3px;
}
.tag-st { color: #ff9b3d; background: rgba(255,155,61,.14); }
.item .w { position: relative; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.item .s { position: relative; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .p { position: relative; font-weight: 800; color: var(--accent); margin-top: 6px; font-size: 15px; }
.item .x {
  position: absolute; right: 10px; bottom: 13px; font-size: 11px; font-weight: 800; color: var(--muted);
  background: rgba(0,0,0,.3); padding: 2px 6px; border-radius: 6px;
}
.item .action { position: relative; margin-top: 9px; width: 100%; padding: 8px; font-size: 12.5px; border-radius: 10px; }
.item .check {
  position: absolute; top: 9px; right: 9px; width: 21px; height: 21px; border-radius: 7px; z-index: 2;
  border: 1px solid var(--line2); background: var(--bg2); display: grid; place-items: center;
}
.item.selected .check { background: var(--accent); border-color: var(--accent); }
.item.selected .check::after { content: ''; width: 9px; height: 5px; border: solid var(--accent-ink); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.table .btn { padding: 6px 10px; font-size: 12px; border-radius: 9px; }
.table .avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 13px; }
.place { font-weight: 900; color: var(--muted); font-size: 16px; }
.place.p1 { color: var(--gold); text-shadow: 0 0 12px rgba(255,201,60,.6); } .place.p2 { color: #cfd6ea; } .place.p3 { color: #e09a5c; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--panel2); margin-left: 6px; font-weight: 700; }
.tag.admin { color: var(--gold); }
.tag.banned { color: var(--danger); }

/* ---------- Admin ---------- */
.admin-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 24px; }
.rig-panel { border-color: rgba(255,201,60,.25); }
.rig-panel h3 { color: var(--gold); }
.rig-panel p { margin: 0; }
.rig-presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.rig-presets button {
  border: 1px solid var(--line2); background: var(--bg2); border-radius: 9px; padding: 8px 0;
  font-weight: 800; font-size: 12.5px; cursor: pointer;
}
.rig-presets button:hover { border-color: var(--gold); color: var(--gold); }
.rig-presets button.active { background: var(--gold); border-color: var(--gold); color: #1a1300; }
.rig-inputs { flex-wrap: nowrap; }
.rig-inputs label { flex: 1; display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.rig-inputs input { width: 100%; min-width: 0; }
.tag.rig { color: var(--gold); background: rgba(255,201,60,.12); margin-left: 0; }
.admin-tools .panel { display: grid; gap: 10px; align-content: start; }
.adm-results { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.adm-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--bg2);
  border-radius: 11px; border-left: 3px solid var(--rc);
}
.adm-row img { width: 60px; height: 40px; object-fit: contain; }
.adm-row .n { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-row .btn { padding: 6px 12px; font-size: 12px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--bg2); padding: 30px 26px; margin-top: 48px; }
.footer-top { max-width: 1348px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-stats { display: flex; gap: 32px; }
.footer-stats div { text-align: right; }
.footer-stats b { display: block; font-size: 22px; color: var(--accent); font-weight: 800; }
.footer-stats span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.disclaimer {
  max-width: 1348px; margin: 20px auto 0; color: var(--muted); font-size: 13px; line-height: 1.6;
  padding: 14px 18px; border: 1px dashed var(--line2); border-radius: 14px;
}
.disclaimer b { color: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 140px);
  background: var(--panel3); border: 1px solid var(--line2); padding: 15px 24px; border-radius: 15px;
  transition: transform .35s cubic-bezier(.2,.9,.3,1.25); z-index: 50; font-weight: 700; max-width: calc(100% - 32px);
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.7); border-left: 4px solid var(--accent);
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--danger); }

/* ---------- Mobile-only elements (hidden on desktop) ---------- */
.picker-tabs { display: none; }
.mobile-bar { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .stage { grid-template-columns: 1fr 1fr; }
  .center { grid-column: 1 / -1; order: -1; }
  .pickers, .admin-tools { grid-template-columns: 1fr; }
}

/* Touch devices: no sticky hover lifts */
@media (hover: none) {
  .item:hover, .mults button:hover, .upgrade-btn:hover { transform: none; }
  .item:hover img { transform: none; }
  .item:active { transform: scale(.97); }
  .feed-item .fi-hover { display: none; }
}

@media (max-width: 760px) {
  :root { --tabbar: 64px; --radius: 16px; }
  body { font-size: 13px; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  input, select { font-size: 16px; } /* stops iOS zoom on focus */

  /* Header: compact, nav moves to a bottom tab bar */
  .topbar {
    height: 56px; padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top));
    gap: 10px; backdrop-filter: none; background: rgba(13,16,32,.97);
  }
  .logo-text { display: none; }
  .logo-mark { width: 34px; height: 34px; border-radius: 10px; }
  .account { margin-left: auto; gap: 8px; }
  .balance-pill { padding: 7px 12px; border-radius: 11px; }
  .balance-pill b { font-size: 15px; }
  .user-chip span { display: none; }
  .avatar, .icon-btn { width: 34px; height: 34px; border-radius: 10px; }

  nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(13,16,32,.97); border-top: 1px solid var(--line);
    backdrop-filter: blur(14px); gap: 0; justify-content: space-around;
  }
  nav button {
    flex: 1; flex-direction: column; gap: 3px; height: 52px; padding: 0; font-size: 10.5px; font-weight: 600;
    border-radius: 12px;
  }
  nav button svg { width: 22px; height: 22px; }
  nav button.active::before { inset: 2px 6px; border-radius: 12px; }
  nav button.active::after { top: 0; bottom: auto; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; }

  /* Feed */
  .live-badge { padding: 0 7px; font-size: 9px; letter-spacing: 2px; }
  .feed { min-height: 78px; padding: 6px; gap: 5px; }
  .feed-item { width: 104px; height: 66px; border-radius: 10px; }
  .feed-item img { height: 36px; top: 4px; }
  .feed-item .fi-info { font-size: 9.5px; padding: 3px 7px 5px; }

  main { padding: 12px; }
  #page-upgrade { padding-bottom: 84px; } /* room for the floating upgrade bar */

  /* Upgrade stage: two compact cards on top, wheel below */
  .stage {
    grid-template-columns: 1fr 1fr; grid-template-areas: "left right" "center center";
    gap: 10px; padding: 10px; border-radius: 20px;
  }
  .side-left { grid-area: left; }
  .side-right { grid-area: right; }
  .center { grid-area: center; order: 0; gap: 12px; padding-top: 4px; }
  .side { min-height: 0; padding: 12px; border-radius: 16px; }
  .side::before { width: 180px; height: 180px; }
  .side::after { left: 14px; right: 14px; }
  .side-label { font-size: 9.5px; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-head { gap: 6px; }
  .side-count { font-size: 10.5px; padding: 3px 7px; }
  .side-body { min-height: 150px; gap: 5px; }
  .side-body .empty { font-size: 11.5px; }
  .empty-ico { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 8px; }
  .empty-ico svg { width: 24px; height: 24px; }
  .big-item img { height: 92px; }
  .big-item .bi-weapon { font-size: 11px; margin-top: 4px; }
  .big-item .bi-skin { font-size: 13.5px; line-height: 1.2; }
  .big-item .bi-tags { margin-top: 5px; }
  .mini-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .mini-item { padding: 4px 2px 3px; border-radius: 8px; font-size: 9.5px; }
  .mini-item img { height: 30px; }
  .side-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .sum span { font-size: 9.5px; }
  .sum b { font-size: 17px; }
  .bal-add { justify-content: space-between; font-size: 11px; padding-left: 9px; }
  .bal-add input { width: 70px; padding: 6px 9px 6px 0; font-size: 16px; }
  .clear-btn { align-self: flex-start; padding: 0; font-size: 12px; }

  .wheel-wrap { width: min(86vw, 360px); height: auto; aspect-ratio: 1; }
  .wheel-halo { inset: 7.5%; }
  .pointer i { top: 3.5%; width: 6.5%; height: 10%; margin-left: -3.25%; }
  .pointer::after { top: 7%; height: 6.5%; }
  .chance { font-size: clamp(36px, 12vw, 52px); }
  .chance small { font-size: .5em; }
  .chance-label { font-size: 10.5px; margin-top: 6px; }
  .roll { font-size: 11px; margin-top: 6px; }
  .burst { left: -25%; top: -25%; width: 150%; height: 150%; }

  .controls { width: 100%; }
  .seg { flex: 1; }
  .seg button { flex: 1; justify-content: center; padding: 10px; }
  .mults { display: grid; grid-template-columns: repeat(6, 1fr); width: 100%; gap: 5px; }
  .mults button { padding: 10px 0; font-size: 12.5px; }
  .upgrade-btn { padding: 17px; font-size: 17px; border-radius: 15px; }

  /* Pickers become two tabs */
  .picker-tabs {
    display: flex; position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 15; margin: 12px -12px 0;
    padding: 8px 12px; background: rgba(9,11,20,.95); backdrop-filter: blur(10px); gap: 6px;
  }
  .picker-tabs button {
    flex: 1; padding: 11px 8px; border-radius: 12px; border: 1px solid var(--line2); background: var(--panel);
    font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer;
  }
  .picker-tabs button span {
    display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--panel3);
    font-size: 11px; margin-left: 4px;
  }
  .picker-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .picker-tabs button.active span { background: rgba(0,0,0,.18); color: var(--accent-ink); }
  .pickers { margin-top: 8px; gap: 0; }
  .pickers[data-tab="inv"] .picker-targets, .pickers[data-tab="targets"] .picker-inv { display: none; }
  .picker { padding: 12px; border-radius: 18px; }
  .picker .panel-head { margin-bottom: 10px; }
  .picker .ph-title { display: none; }
  .picker .panel-head .row { width: 100%; flex-wrap: nowrap; }
  .picker .panel-head input[type=search] { flex: 1; width: auto; min-width: 0; }
  .picker .grid { max-height: none; overflow: visible; padding: 0; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 10px; padding: 0 12px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: 0 0 auto; padding: 7px 13px; }

  /* Cards: 3 per row */
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .item { padding: 7px 7px 9px; border-radius: 12px; }
  .item::before { width: 90px; height: 64px; }
  .item img { height: 54px; margin: 14px 0 4px; }
  .item .tags { top: 6px; left: 6px; right: 6px; gap: 3px; }
  .tag-wear, .tag-st { font-size: 9px; padding: 1px 5px; border-radius: 5px; }
  .item .w { font-size: 9.5px; }
  .item .s { font-size: 11.5px; }
  .item .p { font-size: 12.5px; margin-top: 3px; }
  .item .x { right: 6px; bottom: 9px; font-size: 9.5px; padding: 1px 4px; }
  .item .action { padding: 7px 4px; font-size: 11.5px; margin-top: 6px; }
  .item .check { top: 6px; right: 6px; width: 18px; height: 18px; border-radius: 6px; }
  .grid .empty { padding: 40px 0; }

  /* Shop / inventory / top / admin */
  .panel { padding: 14px; }
  .panel-head h2 { font-size: 20px; }
  .panel-head .row { width: 100%; }
  #page-shop .panel-head .row input[type=search] { flex: 1 1 100%; }
  #page-shop .panel-head .row input.narrow { flex: 1; width: auto; min-width: 0; }
  #page-shop .panel-head .row select { flex: 1; }
  #page-inventory .panel-head .row { justify-content: space-between; }
  #page-inventory .panel-head .row #inv-total { flex: 1 1 100%; }
  #page-inventory .panel-head .row .btn { flex: 1; }
  .table th, .table td { padding: 10px 8px; font-size: 12.5px; }
  .admin-tools { gap: 12px; margin-bottom: 12px; }

  .auth-card { margin: 24px auto; padding: 26px 20px; }
  .logo.big .logo-text { display: inline; font-size: 24px; }

  .footer { padding: 22px 16px; margin-top: 24px; }
  .footer-top .logo-text { display: inline; }
  .footer-stats { gap: 18px; width: 100%; justify-content: space-between; }
  .footer-stats div { text-align: left; }
  .disclaimer { font-size: 12px; }

  .toast { bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); width: max-content; text-align: center; }

  /* Floating upgrade bar when the wheel is scrolled away */
  .mobile-bar {
    display: flex; position: fixed; left: 10px; right: 10px; z-index: 35;
    bottom: calc(var(--tabbar) + 10px + env(safe-area-inset-bottom));
    align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 18px;
    background: rgba(24,29,52,.96); border: 1px solid var(--line2); backdrop-filter: blur(12px);
    box-shadow: 0 16px 40px -10px rgba(0,0,0,.8);
    transform: translateY(0); transition: transform .3s cubic-bezier(.2,.9,.3,1.2), opacity .3s;
  }
  /* Hide in place (not pushed off-screen): off-screen fixed elements make iOS Safari
     extend the page and shift the fixed header/tab bar. */
  .mobile-bar { transition: transform .25s ease, opacity .25s ease, visibility 0s; }
  .mobile-bar[hidden] {
    display: flex !important; transform: translateY(12px) scale(.97); opacity: 0; visibility: hidden;
    pointer-events: none; transition: transform .2s ease, opacity .2s ease, visibility 0s .2s;
  }
  .mb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .mb-info b { font-size: 20px; font-weight: 900; line-height: 1.1; }
  .mb-info span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-bar .upgrade-btn { width: auto; padding: 14px 22px; font-size: 14px; letter-spacing: 2px; border-radius: 13px; }
}

@media (max-width: 380px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mults button { font-size: 11px; }
  .balance-pill svg { display: none; }
}
