:root {
  /* Палитра UPGRADE.SIM */
  --bg: #080A10;          /* фон */
  --bg2: #0b0e16;         /* утопленные области внутри панелей */
  --panel: #10141D;       /* панели */
  --panel2: #161b27;      /* приподнятые элементы */
  --line: #1c2230;        /* тонкие границы */
  --text: #e8ecf4;
  --muted: #8a95a8;
  --accent: #FF9D00;      /* оранжевый */
  --accent2: #ffc14d;
  --blue: #4169FF;        /* синий */
  --win: #20D98A;         /* успех */
  --lose: #FF4058;        /* поражение */
  --glass: rgba(16, 20, 29, .72);
  --glass-strong: rgba(16, 20, 29, .86);
  --edge: rgba(255, 255, 255, .07);
  --edge-hi: rgba(255, 255, 255, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --radius: 10px;
  --font-head: "Rajdhani", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 14px/1.45 var(--font-body);
  background:
    radial-gradient(1200px 500px at 50% -120px, rgba(255, 157, 0, 0.045), transparent 70%),
    radial-gradient(800px 400px at 100% 30%, rgba(65, 105, 255, 0.03), transparent 70%),
    var(--bg);
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { margin: 0; font: 700 18px/1.2 var(--font-head); letter-spacing: 0.06em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: rgba(4, 5, 6, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 22px var(--font-head); letter-spacing: 0.08em; color: var(--accent); }
.brand svg { width: 30px; height: 30px; }
.brand span { color: var(--text); }
.brand b { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right .btn { white-space: nowrap; }
.balance {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line);
  font: 700 18px var(--font-head); font-variant-numeric: tabular-nums;
}
/* Иконка виртуальной валюты — единственный источник: /assets/coin-*.webp (1x/2x). */
:root {
  --coin-sm: url("/assets/coin-32.webp");
  --coin-sm: image-set(url("/assets/coin-32.webp") 1x, url("/assets/coin-64.webp") 2x);
  --coin-md: url("/assets/coin-64.webp");
  --coin-md: image-set(url("/assets/coin-64.webp") 1x, url("/assets/coin-128.webp") 2x);
}
.coin {
  display: inline-block; flex: none; width: 22px; height: 22px;
  background: var(--coin-md) center / contain no-repeat;
  filter: drop-shadow(0 0 5px rgba(255, 157, 0, .45));
}
.notice {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 6px 16px; background: var(--bg2); border-bottom: 1px solid var(--line);
}

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px;
  background: var(--panel2); font-weight: 600; transition: background .15s, border-color .15s, opacity .15s, transform .1s;
}
.btn:hover:not(:disabled) { border-color: #2a3240; background: #171b22; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
.btn-primary {
  border: none; color: #1a1205;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  box-shadow: 0 6px 24px rgba(255, 157, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffd77a, #ffb43a); }

/* ---------- Сетка страницы ---------- */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 16px;
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  grid-template-areas: "stage stage" "inv market";
}
.stage { grid-area: stage; }
.history { grid-area: history; }
.inventory { grid-area: inv; align-self: start; }
.market { grid-area: market; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.count { display: inline-block; min-width: 24px; padding: 0 6px; margin-left: 4px; border-radius: 6px; background: var(--panel2); color: var(--accent); font-size: 14px; text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; margin: 0; }

/* ---------- Сцена апгрейда ---------- */
.stage {
  position: relative;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 20px;
  padding: 20px;
  border-radius: 14px; border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.008) 0 2px, transparent 2px 12px),
    var(--panel);
  overflow: hidden;
}
.slot {
  --rc: #5b6b80;
  position: relative; display: flex; flex-direction: column;
  min-height: 330px; padding: 14px; border-radius: 12px;
  background: radial-gradient(120% 80% at 50% 45%, color-mix(in srgb, var(--rc) 15%, transparent), transparent 70%), var(--bg2);
  border: 1px solid color-mix(in srgb, var(--rc) 45%, var(--line));
  transition: border-color .3s, box-shadow .3s;
}
.slot::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 3px; border-radius: 3px;
  background: var(--rc); box-shadow: 0 0 18px var(--rc);
}
.slot-label { font: 700 13px var(--font-head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.slot-body { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.slot-body.multi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: center; }
.slot-empty { color: var(--muted); text-align: center; padding: 20px; border: 1px dashed var(--line); border-radius: 10px; width: 100%; }
.slot-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.slot-foot .price { font-size: 22px; }
.coins-add { margin-top: 10px; }
.coins-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.coins-head b { font: 700 15px var(--font-head); color: var(--accent2); font-variant-numeric: tabular-nums; }
.coins-add input[type="range"] {
  --p: 0%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
}
.coins-add input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.coins-add input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px; border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--accent) 0 var(--p), #0e1116 var(--p) 100%);
}
.coins-add input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; border: 1px solid var(--line); background: #0e1116; }
.coins-add input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
.coins-add input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border: none; border-radius: 50%;
  background: var(--coin-md) center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 157, 0, .6));
}
.coins-add input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border: none; border-radius: 50%;
  background: var(--coin-md) center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 157, 0, .6));
}
body.spinning .coins-add { pointer-events: none; opacity: .5; }

.mini {
  --rc: #5b6b80; aspect-ratio: 4/3; border-radius: 8px; padding: 4px;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--rc) 30%, transparent), transparent 70%), var(--panel2);
  border-bottom: 2px solid var(--rc);
}

.big-item { --rc: #5b6b80; width: 100%; text-align: center; animation: pop .35s ease-out; }
.big-img { height: 170px; display: flex; align-items: center; justify-content: center; }
.big-img .skin-img { filter: drop-shadow(0 10px 22px color-mix(in srgb, var(--rc) 55%, transparent)); }
.big-weapon { font-size: 13px; color: var(--muted); margin-top: 4px; }
.big-name { font: 700 22px/1.15 var(--font-head); letter-spacing: .02em; }
.big-meta { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.rarity-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--rc); box-shadow: 0 0 6px var(--rc); margin-right: 4px; }
.rarity { color: var(--rc); font-weight: 600; }
.big-float { font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.big-item .float-bar { max-width: 220px; margin: 0 auto; }

/* Колесо шанса — стили в css/wheel.css */
.wheel-wrap { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.mult { font: 700 16px var(--font-head); color: var(--accent); letter-spacing: .08em; }
.upgrade-actions { display: flex; gap: 8px; }
.mult.blocked { color: #ff8a96; font-size: 13px; letter-spacing: .02em; text-align: center; max-width: 300px; }
.btn-upgrade { width: 220px; padding: 14px; font: 700 20px var(--font-head); letter-spacing: .14em; text-transform: uppercase; }
.btn-quick { width: 54px; padding: 0; display: grid; place-items: center; color: var(--accent2); border-color: #3a3220; background: #14110a; }
.btn-quick svg { width: 22px; height: 22px; fill: currentColor; filter: drop-shadow(0 0 6px rgba(255, 157, 0, .5)); }
.btn-quick:hover:not(:disabled) { border-color: var(--accent); background: #1d170b; }
.toggles { display: flex; gap: 16px; }

/* Настройки прокрутки */
.spin-settings { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.seg { display: flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); }
.seg button {
  border: none; background: none; padding: 5px 12px; border-radius: 6px;
  font: 700 13px var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel2); color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.switch { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line);
  transition: background .2s, border-color .2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: transform .2s, background .2s;
}
.switch input:checked + .switch-track { background: rgba(255, 157, 0, .18); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.link-btn { border: none; background: none; padding: 0; font-size: 12px; color: var(--muted); text-decoration: underline dotted; }
.link-btn:hover { color: var(--accent2); }
body.spinning .spin-settings { pointer-events: none; opacity: .5; }

/* Окно подтверждения */
.modal { position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); animation: fade .15s ease-out; }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 420px; padding: 20px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .7); animation: pop .2s ease-out; }
.confirm-text { margin: 14px 0 18px; display: flex; flex-direction: column; gap: 8px; }
.cf-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.cf-row span { color: var(--muted); flex-shrink: 0; }
.cf-row b { text-align: right; font-weight: 600; }
.cf-chance { color: var(--win); font: 700 18px var(--font-head) !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { min-width: 110px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Результат апгрейда ----------
   JS ставит data-result="win|lose" и класс .result-in. Всё появляется переходами opacity/transform
   с cubic-bezier, а при снятии .result-in так же плавно гаснет — без резких скачков и мерцания. */

/* Затемнение (неудача) и мягкое зелёное свечение (успех) поверх сцены, колесо остаётся над ними. */
.stage::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  transition: opacity .8s cubic-bezier(.22, .61, .36, 1);
}
.stage[data-result="win"]::before { background: radial-gradient(40% 55% at 50% 45%, rgba(32, 217, 138, .06), transparent 70%); }
.stage[data-result="lose"]::before { background: radial-gradient(40% 55% at 50% 45%, rgba(255, 64, 88, .05), transparent 70%); }
.stage.result-in::before { opacity: 1; }


/* Успех */
.stage[data-result="win"] .cr-title { color: var(--win); text-shadow: 0 0 18px rgba(32, 217, 138, .65); }
.stage[data-result="win"] .cr-sub { color: #c9ffd9; }
.stage.result-in[data-result="win"] .slot-target {
  border-color: var(--win); box-shadow: 0 0 0 1px var(--win), 0 0 50px rgba(32, 217, 138, .3), inset 0 0 40px rgba(32, 217, 138, .08);
}
.stage.result-in[data-result="win"] .slot-give .slot-body > * { animation: consume .8s cubic-bezier(.5, 0, .75, 0) forwards; }

/* Неудача */
.stage[data-result="lose"] .cr-title { color: var(--lose); text-shadow: 0 0 18px rgba(255, 64, 88, .6); }
.stage[data-result="lose"] .cr-sub { color: #ffc3ca; }
.stage.result-in[data-result="lose"] .slot-give .slot-body > * { animation: crumble 1s cubic-bezier(.55, 0, .8, .2) forwards; }
.stage.result-in[data-result="lose"] .slot-target .big-item { filter: grayscale(.85) brightness(.55); opacity: .65; }
.big-item { transition: filter .8s ease, opacity .8s ease; }
.slot { transition: border-color .7s ease, box-shadow .7s ease; }
.slot-empty { animation: fade .5s ease both; }
body.spinning .slot-give { box-shadow: 0 0 30px rgba(255, 157, 0, .18); }

/* Появление выигранного скина: мягкое увеличение из вспышки и блик по картинке. */
.big-item.reveal { animation: reveal 1s cubic-bezier(.2, .9, .25, 1) both; }
.big-img { position: relative; }
.big-item.reveal .big-img::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .45) 50%, transparent 65%);
  transform: translateX(-120%); animation: sweep 1s ease-out .35s forwards;
  -webkit-mask: radial-gradient(closest-side, #000 60%, transparent); mask: radial-gradient(closest-side, #000 60%, transparent);
}

.particle {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 2px;
  pointer-events: none; z-index: 6; opacity: 0;
  animation: fly 1.25s cubic-bezier(.12, .75, .3, 1) var(--delay, 0ms) forwards;
}
.particle.from-slot { top: 42%; width: 5px; height: 5px; }

@keyframes ripple-win { from { opacity: .9; box-shadow: 0 0 0 0 rgba(32, 217, 138, .7); } to { opacity: 0; box-shadow: 0 0 0 30px rgba(32, 217, 138, 0); } }
@keyframes ripple-lose { from { opacity: .8; box-shadow: 0 0 0 0 rgba(255, 64, 88, .6); } to { opacity: 0; box-shadow: 0 0 0 22px rgba(255, 64, 88, 0); } }
@keyframes reveal {
  0% { opacity: 0; transform: scale(.82) translateY(10px); filter: brightness(2.4) blur(6px); }
  55% { opacity: 1; transform: scale(1.05); filter: brightness(1.3) blur(0); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes sweep { to { transform: translateX(120%); } }
@keyframes consume { to { opacity: 0; transform: translateY(-18px) scale(.9); filter: brightness(1.8) blur(3px); } }
@keyframes thud { 15% { transform: translateY(3px) scale(.992); } 35% { transform: translateX(-4px); } 55% { transform: translateX(3px); } 75% { transform: translateX(-1.5px); } }
@keyframes fly {
  0% { opacity: 0; transform: translate(0, 0) scale(.4); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(300deg) scale(1); }
}
@keyframes pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes crumble { 30% { filter: grayscale(1) brightness(.7); } to { opacity: 0; transform: translateY(30px) rotate(-6deg) scale(.85); filter: grayscale(1) blur(2px); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- Карточки ---------- */
.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.inventory .grid { max-height: 760px; overflow-y: auto; padding-right: 2px; }
.card {
  --rc: #b0c3d9;
  position: relative; display: flex; flex-direction: column;
  padding: 8px 10px 9px; border-radius: 9px; cursor: pointer; overflow: hidden;
  background:
    radial-gradient(90% 60% at 50% 42%, color-mix(in srgb, var(--rc) 13%, transparent), transparent 75%),
    linear-gradient(180deg, var(--panel2), #090b0e);
  border: 1px solid var(--line);
  transition: transform .15s ease, border-color .15s, box-shadow .2s;
  user-select: none;
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: var(--rc); box-shadow: 0 0 12px var(--rc);
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--rc) 60%, var(--line)); box-shadow: 0 8px 24px rgba(0, 0, 0, .35), 0 0 22px color-mix(in srgb, var(--rc) 25%, transparent); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(255, 157, 0, .35); }
.card.selected::after {
  content: "✓"; position: absolute; top: 6px; right: 8px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent); color: #1a1205;
}
.card-top { display: flex; gap: 4px; min-height: 18px; }
.wear-tag, .st-tag { font: 700 11px/18px var(--font-head); letter-spacing: .06em; padding: 0 5px; border-radius: 4px; }
.wear-tag { background: rgba(255, 255, 255, .07); color: var(--muted); }
.st-tag { background: rgba(207, 106, 50, .2); color: #ff8c4a; }
.card-img { aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; margin: 2px 0 4px; }
.skin-img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5));
  transition: transform .25s ease;
}
.skin-img.big { max-height: 170px; }
.card:hover .skin-img { transform: scale(1.06) rotate(-2deg); }
.card-weapon { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name { font: 700 15px/1.15 var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.float-bar {
  position: relative; height: 4px; margin: 6px 0 4px; border-radius: 2px;
  background: linear-gradient(90deg, #20d98a 0 7%, #9be04a 7% 15%, #e0c84a 15% 38%, #e08a3e 38% 45%, #e04a4a 45% 100%);
  opacity: .85;
}
.float-bar i { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; background: #fff; box-shadow: 0 0 4px #000; }
.card-bottom { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.float-val { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.price { font: 700 15px var(--font-head); color: var(--accent2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.price::before { content: ""; display: inline-block; width: 1.05em; height: 1.05em; margin-right: .28em; background: var(--coin-sm) center / contain no-repeat; vertical-align: -.17em; }

.sell-btn, .buy-hint {
  position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 6px; border-radius: 6px; border: none;
  font: 700 13px var(--font-head); letter-spacing: .08em; text-transform: uppercase; text-align: center;
  opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s;
}
.sell-btn { background: rgba(255, 64, 88, .9); color: #fff; }
.buy-hint { background: rgba(32, 217, 138, .9); color: #062012; pointer-events: none; }
.card:hover .sell-btn, .card:hover .buy-hint, .card:focus-within .sell-btn { opacity: 1; transform: none; }

/* Большие списки: браузер не рисует карточки за пределами экрана. */
#marketGrid .card { content-visibility: auto; contain-intrinsic-size: auto 210px; }
.card-img .skin-img, .big-img .skin-img, .h-thumb .skin-img, .mini .skin-img, .skin-head .skin-img { aspect-ratio: 4 / 3; }
.info-btn {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 22px; border-radius: 6px;
  border: 1px solid var(--line); background: rgba(7, 8, 11, .8); color: var(--muted);
  font-size: 14px; line-height: 1; opacity: 0; transition: opacity .15s, color .15s, border-color .15s;
}
.card:hover .info-btn, .info-btn:focus-visible { opacity: 1; }
.info-btn:hover { color: var(--accent2); border-color: var(--accent); }
.card.selected .info-btn { right: 32px; }
.market-count { margin: -4px 0 8px; font-size: 12px; }
.market-loading { display: flex; justify-content: center; padding: 16px; }
.market-loading[hidden] { display: none; }
.spinner.small { width: 24px; height: 24px; border-width: 2px; margin: 12px auto; }

/* Окно скина: все варианты износа */
.modal-wide { max-width: 560px; --rc: #5b6b80; border-top: 3px solid var(--rc); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-close { border: none; background: none; color: var(--muted); font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--panel2); }
.skin-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 8px 0 14px;
  background: radial-gradient(60% 70% at 50% 45%, color-mix(in srgb, var(--rc) 14%, transparent), transparent 70%); }
.skin-head .skin-img { max-height: 180px; width: auto; filter: drop-shadow(0 10px 22px color-mix(in srgb, var(--rc) 45%, transparent)); }
.skin-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.skin-meta .rarity { margin-right: 8px; }
.wear-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.wear-row {
  display: grid; grid-template-columns: 34px 1fr auto auto 96px; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; text-align: left;
  border: 1px solid var(--line); border-left: 3px solid var(--rc); background: var(--bg2);
  transition: border-color .15s, background .15s;
}
.wear-row:hover:not(:disabled) { background: var(--panel2); border-color: color-mix(in srgb, var(--rc) 50%, var(--line)); }
.wear-row:disabled { opacity: .45; cursor: not-allowed; }
.wr-name { font-size: 13px; font-weight: 600; }
.wr-action { font: 700 12px var(--font-head); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); text-align: right; }
.wear-row:disabled .wr-action { color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
@media (max-width: 560px) {
  .wear-row { grid-template-columns: 30px 1fr auto; }
  .wear-row .float-val, .wear-row .wr-action { display: none; }
}

/* ---------- Фильтры ---------- */
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); }
.tab { border: none; background: none; padding: 6px 14px; border-radius: 7px; font: 700 15px var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tab.active { background: var(--panel2); color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.mult-buttons { display: flex; gap: 4px; }
.mult-buttons[hidden] { display: none; }
.mult-buttons button { border: 1px solid var(--line); background: var(--panel2); border-radius: 6px; padding: 5px 9px; font: 700 14px var(--font-head); color: var(--accent2); }
.mult-buttons button:hover { border-color: var(--accent); }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filters input[type="search"], .filter-row select, .filter-row input[type="number"] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); outline: none; min-width: 0;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-row input[type="number"] { width: 90px; }
.check { display: flex; align-items: center; gap: 6px; color: #ff8c4a; font-weight: 600; font-size: 13px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg2); padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.active { color: #1a1205; background: var(--accent); border-color: var(--accent); }
.sentinel { height: 1px; }

/* ---------- История ---------- */
.history-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.history-list .empty { width: 100%; padding: 10px; }
.h-row {
  flex: 0 0 auto; scroll-snap-align: start;
  display: grid; grid-template-columns: 54px 16px 54px minmax(0, 170px) auto; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line);
  border-left: 3px solid var(--lose);
  animation: pop .3s ease-out;
}
.h-row.win { border-left-color: var(--win); }
.h-thumb { --rc: #5b6b80; position: relative; height: 42px; display: grid; place-items: center; border-radius: 6px; background: radial-gradient(circle, color-mix(in srgb, var(--rc) 30%, transparent), transparent 70%); border-bottom: 2px solid var(--rc); }
.h-thumb .skin-img { max-height: 40px; }
.h-thumb em { position: absolute; right: 2px; top: 0; font-size: 10px; font-style: normal; color: var(--accent2); }
.h-row.lose .tgt .skin-img { filter: grayscale(.85) brightness(.7); }
.h-arrow { color: var(--muted); text-align: center; }
.h-info { min-width: 0; }
.h-info b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-info span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.h-res { font: 700 15px var(--font-head); color: var(--lose); text-align: right; display: flex; flex-direction: column; line-height: 1.1; }
.h-row.win .h-res { color: var(--win); }
.h-res small { font: 500 10px var(--font-body); color: var(--muted); }

/* ---------- Подвал, тост, загрузка ---------- */
.footer { max-width: 1440px; margin: 0 auto; padding: 4px 16px 28px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.footer span { flex: 1 1 300px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 50; max-width: calc(100% - 32px);
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 9px; background: #161b27; border: 1px solid #232a35; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loader { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); color: var(--muted); transition: opacity .3s, visibility .3s; }
.loader.hidden { opacity: 0; visibility: hidden; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #1c222c; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .stage { grid-template-columns: 1fr 1fr; }
  .wheel-wrap { grid-column: 1 / -1; order: -1; }
  .wheel { --w: 320px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "inv" "market"; }
  .inventory .grid { max-height: 420px; }
}
@media (max-width: 560px) {
  .layout { padding: 10px 16px; gap: 12px; }
  /* В шапке телефона не хватает места: от логотипа остаётся значок (он же ссылка на главную). */
  .topbar { gap: 8px; }
  .topbar .brand span { display: none; }
  .topbar-right { gap: 6px; }
  .balance { font-size: 16px; padding: 6px 9px; gap: 6px; }
  .balance .coin { width: 18px; height: 18px; }
  .topbar .btn { padding: 6px 10px; font-size: 12px; }
  .stage { padding: 12px; gap: 10px; }
  .slot { min-height: 230px; padding: 10px; }
  .big-img, .skin-img.big { height: auto; max-height: 110px; }
  .big-name { font-size: 17px; }
  .slot-foot .price { font-size: 17px; }
  .wheel { --w: clamp(220px, calc(100vw - 64px), 300px); }
  .btn-upgrade { width: auto; flex: 1; }
  .upgrade-actions { width: min(300px, 100%); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  .card-name { font-size: 14px; }
  .sell-btn { opacity: 1; transform: none; position: static; margin-top: 6px; padding: 4px; font-size: 11px; }
  .h-row { grid-template-columns: 44px 12px 44px minmax(0, 130px) auto; }
  .filter-row select { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.history[hidden] { display: none !important; }
.calc[hidden] { display: none !important; }
