* { box-sizing: border-box; }

:root {
  --bg: #0d0f16;
  --panel: #151925;
  --panel-2: #1c2130;
  --line: #262c3d;
  --text: #e7eaf3;
  --muted: #8c93a8;
  --green: #4ade80;
  --gold: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --r1: #b0c3d9;
  --r2: #8847ff;
  --r3: #4b69ff;
  --r4: #8847ff;
  --r5: #eb4b4b;
  --r6: #d32ce6;
  --acc: #ff9d00;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(700px 340px at 12% -5%, rgba(255,157,0,.16), transparent 60%),
    radial-gradient(700px 400px at 95% 10%, rgba(74,222,128,.12), transparent 60%),
    radial-gradient(900px 500px at 50% 115%, rgba(96,165,250,.10), transparent 60%);
  z-index: 0;
}

/* ---------- ТОПБАР ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(13,15,22,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; letter-spacing: .5px; }
.brand__logo { color: var(--acc); font-size: 22px; }
.brand__name b { color: var(--acc); }

.nav { display: flex; gap: 6px; margin-left: 12px; flex: 1; flex-wrap: wrap; }
.nav__btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .18s;
}
.nav__btn:hover { color: var(--text); background: var(--panel-2); }
.nav__btn.is-active { color: #10121a; background: var(--acc); }
.nav__btn--admin.is-active { background: var(--red); color: #fff; }
.nav__btn--admin { color: var(--red); border-color: rgba(248,113,113,.4); }

.wallet { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); padding: 7px 12px; border-radius: 12px; }
.wallet__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.wallet__value { font-weight: 800; color: var(--green); font-size: 16px; min-width: 90px; text-align: right; }

/* ---------- LAYOUT ---------- */
.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 26px 20px 70px; }
.screen { display: none; animation: fade .3s ease; }
.screen.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.title { font-size: 30px; margin: 0 0 6px; letter-spacing: .5px; }
.title span { color: var(--acc); }
.title--sm { font-size: 20px; margin-top: 34px; }
.title--admin span { color: var(--red); }
.subtitle { color: var(--muted); margin: 0 0 24px; }

/* ---------- КЕЙСЫ ---------- */
.cases-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.case-card {
  position: relative;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  overflow: hidden;
  transition: .2s;
}
.case-card:hover { transform: translateY(-5px); border-color: var(--acc); box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.case-card__art {
  height: 120px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 52px;
  margin-bottom: 12px;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
}
.case-card__name { font-weight: 700; font-size: 15px; }
.case-card__price { color: var(--acc); font-weight: 800; margin: 6px 0 12px; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: .16s;
}
.btn:hover:not(:disabled) { border-color: var(--acc); color: var(--acc); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--green { background: var(--green); border-color: var(--green); color: #08210f; }
.btn--green:hover:not(:disabled) { color: #08210f; filter: brightness(1.08); }
.btn--gold { background: var(--gold); border-color: var(--gold); color: #231a00; }
.btn--gold:hover:not(:disabled) { color: #231a00; filter: brightness(1.08); }
.btn--red { background: var(--red); border-color: var(--red); color: #2a0808; }
.btn--red:hover:not(:disabled) { color: #2a0808; }
.btn--block { width: 100%; }

.feed { display: flex; flex-wrap: wrap; gap: 10px; }
.feed__item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--r1);
  padding: 7px 11px; border-radius: 8px; font-size: 13px;
}
.feed__item b { color: var(--acc); }

/* ---------- КАЗИНО ---------- */
.subtabs { display: flex; gap: 8px; margin: 18px 0 22px; flex-wrap: wrap; }
.subtab {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 20px; border-radius: 999px; font-weight: 700; font-size: 14px; cursor: pointer; transition: .18s;
}
.subtab:hover { color: var(--text); }
.subtab.is-active { background: var(--acc); color: #17120a; border-color: var(--acc); }

.game { display: none; }
.game.is-active { display: block; animation: fade .3s ease; }

.panel {
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.panel__title { margin: 22px 0 12px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.panel__title:first-child { margin-top: 0; }

.controls { display: flex; align-items: flex-end; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.controls--wrap { flex-wrap: wrap; }
.controls--center { justify-content: center; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.field--wide { flex: 1; min-width: 220px; }

input, select {
  background: #0f121b; border: 1px solid var(--line); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font-size: 15px; font-family: inherit; outline: none;
}
input:focus, select:focus { border-color: var(--acc); }
input[type="number"] { width: 150px; }
.input { width: 100%; }

.hint { color: var(--muted); font-size: 13px; margin-top: 12px; line-height: 1.5; }

/* ---------- КРАШ ---------- */
.panel { position: relative; }
#crashCanvas { width: 100%; height: auto; display: block; border-radius: 12px; background: #0b0e16; border: 1px solid var(--line); }
.crash-hud { position: absolute; top: 42px; left: 0; right: 0; text-align: center; pointer-events: none; }
.crash-multi { font-size: 54px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 4px 20px rgba(0,0,0,.6); }
.crash-multi.is-hot { color: var(--green); }
.crash-multi.is-dead { color: var(--red); animation: shake .3s; }
.crash-state { color: var(--muted); font-size: 14px; margin-top: 4px; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

/* ---------- АПГРЕЙД ---------- */
.up-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.up-slot h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.up-arrow { font-size: 34px; color: var(--acc); }
.slot {
  min-height: 130px; border-radius: 14px; border: 2px dashed var(--line);
  display: grid; place-items: center; text-align: center; padding: 12px; background: #0f121b;
}
.slot__icon { font-size: 42px; }
.slot__name { font-weight: 700; font-size: 14px; margin-top: 6px; }
.slot__price { color: var(--acc); font-size: 13px; font-weight: 700; }

.up-controls { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; margin-top: 20px; }
.chance { color: var(--green); font-weight: 800; padding-bottom: 12px; }
.ring { position: relative; width: 86px; height: 86px; margin-left: auto; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring__bg { fill: none; stroke: var(--line); stroke-width: 10; }
.ring__fg { fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 163; transition: .3s; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 15px; }

/* ---------- КОНТРАКТ ---------- */
.contract-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; min-height: 150px; }
.cslot {
  border: 2px dashed var(--line); border-radius: 14px; padding: 12px; text-align: center;
  background: #0f121b; display: grid; place-items: center; min-height: 140px; position: relative;
}
.cslot.is-empty { color: #3b4157; font-size: 26px; }
.cslot__x { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--red); font-weight: 900; }

/* ---------- МИНЁР ---------- */
.miner-top { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { background: #0f121b; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; flex: 1; min-width: 130px; }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat b { font-size: 18px; color: var(--green); }
.miner-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(56px, 1fr)); gap: 10px; }
.rock {
  aspect-ratio: 1; border-radius: 12px; background: #10131c; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 26px; cursor: pointer; transition: .15s; user-select: none;
}
.rock:hover { border-color: var(--gold); transform: scale(1.05); }
.rock.is-broken { opacity: .3; cursor: default; transform: none; }
.rock__pop { animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- ПРОФИЛЬ ---------- */
.profile-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 860px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-head { display: flex; gap: 16px; align-items: center; }
.avatar {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; font-weight: 900; color: #10121a;
  background: linear-gradient(135deg, var(--acc), var(--gold));
}
.nick { font-size: 22px; font-weight: 800; background: transparent; border: 1px solid transparent; padding: 4px 8px; width: 100%; }
.nick:hover { border-color: var(--line); }
.nick:focus { border-color: var(--acc); background: #0f121b; }
.profile-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; padding-left: 8px; }
.profile-meta b { color: var(--text); }
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.promo-row { display: flex; gap: 10px; }
.promo-row .input { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #0f121b; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.chip--muted { color: var(--muted); border-style: dashed; }
.chip--ok { border-color: var(--green); color: var(--green); }
.chip--admin { border-color: var(--red); color: var(--red); }

.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.item-card {
  background: linear-gradient(170deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center;
  position: relative; overflow: hidden;
}
.item-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--rarity, var(--r1)); }
.item-card__icon { font-size: 40px; }
.item-card__name { font-weight: 700; font-size: 13px; margin-top: 6px; }
.item-card__price { color: var(--acc); font-weight: 800; font-size: 14px; margin-top: 4px; }
.item-card__rar { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.item-card .btn { margin-top: 10px; width: 100%; }
.empty { color: var(--muted); padding: 18px; text-align: center; grid-column: 1 / -1; }

/* ---------- АДМИН ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

/* ---------- МОДАЛКА / РУЛЕТКА ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(5,6,10,.9); display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__box { width: min(980px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.reel {
  position: relative; height: 170px; overflow: hidden; border-radius: 12px;
  background: #0b0e16; border: 1px solid var(--line);
}
.reel::after, .reel::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 90px; z-index: 3; pointer-events: none;
}
.reel::before { left: 0; background: linear-gradient(90deg, #0b0e16, transparent); }
.reel::after { right: 0; background: linear-gradient(-90deg, #0b0e16, transparent); }
.reel__line { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 4; box-shadow: 0 0 12px var(--red); }
.reel__track { display: flex; height: 100%; align-items: center; gap: 10px; padding-left: 50%; will-change: transform; }
.reel__cell {
  min-width: 128px; height: 140px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-top: 4px solid var(--r1);
  display: grid; place-items: center; text-align: center; padding: 8px; font-size: 13px;
}
.reel__cell i { font-size: 34px; font-style: normal; }
.reel__cell b { display: block; font-size: 12px; }
.reel-result { text-align: center; margin: 18px 0 4px; min-height: 30px; font-size: 19px; font-weight: 800; }
.reel-result small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 4px; }

/* ---------- ТОСТЫ ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--green);
  padding: 12px 16px; border-radius: 10px; font-size: 14px; max-width: 320px;
  animation: slide .25s ease; box-shadow: 0 10px 26px rgba(0,0,0,.5);
}
.toast--err { border-left-color: var(--red); }
.toast--gold { border-left-color: var(--gold); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .up-grid { grid-template-columns: 1fr; }
  .up-arrow { transform: rotate(90deg); text-align: center; }
  .title { font-size: 23px; }
}
