* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #12131a;
  --panel: #1b1d27;
  --panel2: #232633;
  --accent: #f4c542;
  --green: #4caf50;
  --red: #ff4b4b;
  --txt: #eceff6;
  --muted: #8b8fa3;
}

html, body {
  background: var(--bg);
  color: var(--txt);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100%;
  overflow-x: hidden;
}

/* ============ АНИМИРОВАННЫЙ ФОН ============ */
.bg-skins {
  position: fixed;
  inset: -10vh 0 0 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 600px at 15% -10%, rgba(244,197,66,0.10), transparent 60%),
    radial-gradient(900px 700px at 85% 110%, rgba(139,92,246,0.14), transparent 60%),
    linear-gradient(160deg, #14151d 0%, #101118 60%, #0c0d13 100%);
}

.bg-skin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.35;
}
.bg-skin-img {
  width: 78%;
  height: auto;
  max-height: 66%;
  object-fit: contain;
  animation: floatSpin 14s ease-in-out infinite alternate;
}
.bg-skin-name {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.75;
  text-align: center;
  padding: 0 6px;
}
@keyframes floatSpin {
  0%   { transform: translateY(0) rotate(0deg) scale(1); }
  25%  { transform: translateY(-26vh) rotate(90deg) scale(1.1); }
  50%  { transform: translateY(-50vh) rotate(180deg) scale(1); }
  75%  { transform: translateY(-26vh) rotate(270deg) scale(0.9); }
  100% { transform: translateY(0) rotate(360deg) scale(1); }
}

/* ============ ШАПКА ============ */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 26px;
  background: rgba(18, 19, 26, 0.85);
  border-bottom: 2px solid var(--accent);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.logo {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 18px rgba(244, 197, 66, 0.5);
}
.logo span { color: var(--accent); }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  background: var(--panel2);
  border: 1px solid #3a3e50;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 15px;
}
.stat b { color: var(--accent); }
.stat.luck b { color: var(--green); }

/* ссылка на колесо апгрейда */
.wheel-link {
  display: block;
  margin: 0 0 14px;
  padding: 13px 16px;
  background: linear-gradient(90deg, rgba(0, 229, 255, 0.1), rgba(180, 77, 255, 0.1));
  border: 1px dashed var(--neon, #00e5ff);
  border-radius: 14px;
  color: #7de9ff;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  text-align: center;
  transition: 0.15s;
}
.wheel-link:hover {
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.35);
  transform: translateY(-1px);
  color: #fff;
}

/* ============ РАСКЛАДКА ============ */
.layout {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  padding: 22px;
  max-width: 1340px;
  margin: 0 auto;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}
.sec-title {
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin: 18px 0 12px;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
}

/* ============ КЕЙСЫ ============ */
.case-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.case-card {
  background: var(--panel);
  border: 2px solid #333748;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.case-card:hover { transform: translateY(-5px); border-color: var(--accent); }
.case-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(244, 197, 66, 0.35);
}
.case-card canvas { width: 100%; max-width: 150px; height: auto; }
.case-name { font-size: 13px; margin: 6px 0; font-weight: 700; }
.case-price { color: var(--accent); font-weight: 800; font-size: 15px; }

/* ============ КНОПКИ ============ */
.actions { display: flex; gap: 12px; margin: 18px 0 14px; align-items: stretch; }
.selected-case {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 130px;
  padding: 8px 16px;
  background: var(--panel);
  border: 2px solid #333748;
  border-radius: 14px;
  font-size: 12px;
  color: var(--muted);
}
.selected-case b { font-size: 17px; color: var(--accent); }
.btn-open {
  flex: 1;
  background: linear-gradient(135deg, #ffd257, #e0a800);
  color: #241c00;
  border: none;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 6px 22px rgba(244, 197, 66, 0.35);
}
.btn-open:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.08); }
.btn-open:disabled { background: #3a3e50; color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn-fast {
  background: var(--panel2);
  color: var(--txt);
  border: 2px solid #3a3e50;
  font-size: 15px;
  font-weight: 700;
  padding: 16px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.2s;
}
.btn-fast:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-fast:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Canvas-игра с кейсом ============ */
.game-wrap {
  position: relative;
  background: linear-gradient(180deg, #1e2130, #14151d);
  border: 2px solid #333748;
  border-radius: 18px;
  overflow: hidden;
}
.game-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(500px 100px at 50% 100%, rgba(244, 197, 66, 0.16), transparent 70%);
  pointer-events: none;
}
#game { display: block; width: 100%; height: 150px; }

.result-bar {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 16px;
  text-align: center;
  background: var(--panel);
  border: 2px solid #333748;
  animation: popIn 0.3s ease;
}
.result-bar.win { border-color: var(--green); color: var(--green); }
.result-bar.fail { border-color: var(--red); color: var(--red); }
.hidden { display: none !important; }

/* ============ АПГРЕЙДЫ ============ */
.upgrades {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.up-card {
  background: var(--panel);
  border: 2px solid #333748;
  border-radius: 14px;
  padding: 14px;
}
.up-name { font-weight: 800; margin-bottom: 8px; }
.up-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.up-info b { color: var(--accent); }
.btn-up {
  width: 100%;
  background: var(--green);
  color: #06210a;
  border: none;
  font-weight: 900;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s;
}
.btn-up:hover:not(:disabled) { filter: brightness(1.12); }
.btn-up:disabled { background: #3a3e50; color: var(--muted); cursor: not-allowed; }

/* ============ ИНВЕНТАРЬ ============ */
.right {
  background: rgba(27, 29, 39, 0.88);
  border: 2px solid #333748;
  border-radius: 18px;
  padding: 8px 16px 18px;
  align-self: start;
  backdrop-filter: blur(6px);
}
.inv-count { font-size: 14px; color: var(--muted); }

/* Шапка инвентаря: заголовок + кнопка «Продать всё» */
.inv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.inv-head .sec-title { flex: 1; min-width: 0; }
.btn-sell-all {
  background: linear-gradient(180deg, #f7d060, #e0a418);
  color: #1a1408;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(244, 197, 66, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-sell-all:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn-sell-all:active:not(:disabled) { transform: translateY(0); }
.btn-sell-all:disabled { background: #3a3e50; color: var(--muted); cursor: not-allowed; box-shadow: none; }
.inv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}
.inv-grid::-webkit-scrollbar { width: 8px; }
.inv-grid::-webkit-scrollbar-thumb { background: #3a3e50; border-radius: 8px; }
.inv-item {
  background: var(--panel2);
  border-left: 5px solid var(--muted);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  animation: popIn 0.25s ease;
}
.inv-item .em img {
  width: 100%;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}
.inv-item .nm { font-size: 11px; font-weight: 700; margin: 4px 0; }
.inv-item .pr { font-size: 13px; color: var(--accent); font-weight: 800; }
.inv-empty { color: var(--muted); text-align: center; font-size: 14px; padding: 30px 6px; }

/* ============ ПОПАР ВЫПАДЕНИЯ ============ */
.popup {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 10, 0.88);
  backdrop-filter: blur(6px);
}
.popup-card {
  background: linear-gradient(180deg, #232633, #16171f);
  border: 2px solid #3a3e50;
  border-radius: 20px;
  padding: 26px;
  text-align: center;
  width: min(470px, 92vw);
  animation: popIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.7);
}
.popup-rarity { font-weight: 900; letter-spacing: 3px; font-size: 14px; margin-bottom: 8px; }
#popupCanvas { width: 100%; height: auto; }
.popup-name { font-size: 22px; font-weight: 900; margin: 6px 0; }
.popup-price { font-size: 26px; font-weight: 900; color: var(--accent); margin-bottom: 16px; }
.popup-btns { display: flex; gap: 12px; }
.btn-keep, .btn-sell {
  flex: 1;
  border: none;
  padding: 14px;
  font-size: 16px;
  font-weight: 900;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.15s;
}
.btn-keep { background: var(--green); color: #06210a; }
.btn-sell { background: var(--accent); color: #241c00; }
.btn-keep:hover, .btn-sell:hover { filter: brightness(1.12); transform: translateY(-2px); }

/* ============ ПОДВАЛ ============ */
.foot {
  position: relative;
  z-index: 5;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px;
  border-top: 1px solid #2a2d3b;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
