:root {
  color-scheme: dark;
  --bg: #101217;
  --panel: #181b23;
  --panel-2: #202431;
  --line: #2d3342;
  --text: #f3f5f9;
  --muted: #a3adbf;
  --accent: #ffcf4d;
  --green: #47d98b;
  --red: #ff625a;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Браузерное правило [hidden] { display: none } — это обычный UA-стиль с
   нулевой специфичностью, поэтому любой авторский display его перебивает.
   Из-за этого, например, .ghost-button { display: inline-flex } показывал
   кнопку "Открыть" под пустой историей дропа, хотя JS честно ставил
   элементу hidden. Глобальный !important закрывает это для всей разметки. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 207, 77, .13), transparent 28rem),
    linear-gradient(135deg, #0d0f14 0%, #151821 47%, #11131a 100%);
  color: var(--text);
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }

.app {
  min-height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 36px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(13, 15, 20, .88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 205px;
  font-weight: 900;
  text-transform: uppercase;
}

.brand:has(.brand-logo-img) {
  min-width: 0;
}

.brand-logo-img {
  display: block;
  width: auto;
  height: 38px;
  max-width: 220px;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffcf4d, #ff6b4d);
  color: #1a1110;
  box-shadow: 0 10px 24px rgba(255, 154, 61, .22);
}

.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.nav a,
.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.nav a:hover,
.ghost-button:hover,
.primary-button:hover { transform: translateY(-1px); }

.ghost-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: .62;
  transform: none;
}

.nav a.active {
  border-color: rgba(255, 207, 77, .45);
  background: rgba(255, 207, 77, .11);
  color: #ffe59b;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 207, 77, .36);
  border-radius: 8px;
  background: rgba(255, 207, 77, .1);
  white-space: nowrap;
  font-weight: 900;
}

.profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
}

.sound-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}

.sound-toggle svg { width: 20px; height: 20px; }

.sound-toggle:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.22); }

.sound-toggle.is-muted { color: #8ea3ba; border-color: rgba(142, 163, 186, .3); }

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.profile-main {
  min-width: 0;
}

.leaderboard-panel {
  position: sticky;
  top: 82px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(24, 27, 35, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.compact-head {
  align-items: flex-start;
}

.leader-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.leader-tabs button {
  min-height: 36px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: var(--text);
  background: #11141b;
  cursor: pointer;
}

.leader-tabs button.active {
  border-color: rgba(255, 207, 77, .48);
  background: rgba(255, 207, 77, .12);
  color: #ffe59b;
}

.leader-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 8px;
  background: #11141b;
}

.leader-rank {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(255, 207, 77, .12);
  color: #ffdf86;
  font-weight: 900;
  font-size: 12px;
}

.leader-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leader-name-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
}

.leader-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.leader-balance-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.leader-balance-line b {
  color: #ffdf86;
  font-weight: 700;
}

.leader-drop-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.leader-drop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.leader-value {
  color: #ffdf86;
  font-size: 13px;
  white-space: nowrap;
}

.leader-skin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 24px;
  flex: 0 0 auto;
  color: #ffdf86;
  overflow: hidden;
}

.leader-skin-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 24px;
  color: inherit;
}

.leader-skin-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.35));
}

.leader-name-line .leader-avatar {
  /* Higher specificity than the base .avatar rule (34px) so this stays
     the small, tight-to-the-nickname size instead of being overridden
     by cascade order and overflowing/clipping in the panel. */
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  font-size: 9px;
  border-radius: 5px;
}

.leader-skin-icon svg {
  width: 34px;
  height: 22px;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.35));
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(145deg, #4da3ff, #a36cff);
  color: white;
  font-weight: 900;
  overflow: hidden;
}

.avatar:has(img) {
  background: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar.big {
  width: 82px;
  height: 82px;
  font-size: 28px;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 14, .72);
  backdrop-filter: blur(6px);
}

.settings-modal[hidden] { display: none; }

.settings-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: linear-gradient(135deg, #1d2029, #171a22);
  box-shadow: var(--shadow);
}

.settings-card h2 {
  margin: 0;
  font-size: 24px;
}

.settings-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.settings-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.settings-card input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 11px 12px;
  background: #11141b;
  color: var(--text);
  outline: none;
}

.settings-avatar-wrap {
  position: relative;
  justify-self: start;
}

.settings-avatar-btn {
  border: 2px solid rgba(255,255,255,.18);
  cursor: pointer;
  padding: 0;
}

.settings-avatar-btn:hover {
  border-color: rgba(255, 207, 77, .55);
}

.settings-avatar-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 2;
  width: 246px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: #202431;
  box-shadow: var(--shadow);
}

.settings-avatar-menu[hidden] { display: none; }

.settings-avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.settings-avatar-option {
  width: 68px;
  height: 68px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
}

.settings-avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.settings-avatar-option.active,
.settings-avatar-option:hover {
  border-color: rgba(255, 207, 77, .7);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.primary-button {
  background: linear-gradient(135deg, #ffcf4d, #ff8a3d);
  color: #1b1307;
  font-weight: 900;
  border-color: rgba(255, 255, 255, .15);
}

.ghost-button {
  border-color: rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .04);
}

main {
  width: min(1420px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 36px) 42px;
}

.ticker {
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: #171a22;
}

.ticker-track {
  display: flex;
  gap: 10px;
  width: max-content;
  padding: 12px 0;
  animation: ticker 60s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    animation: none;
  }

  .drop-mini {
    transition: border-color .25s ease, background-color .25s ease, box-shadow .25s ease;
  }

  .drop-mini:hover {
    transform: none;
  }

  .drop-mini-face {
    transition: none;
  }
}

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.drop-mini {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  width: 280px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: #202431;
  overflow: hidden;
  transition:
    transform .25s ease,
    border-color .25s ease,
    background-color .25s ease,
    box-shadow .25s ease;
  transform-origin: center center;
}

.drop-mini:hover {
  transform: scale(1.04);
  border-color: color-mix(in srgb, var(--rarity-color, #fff) 42%, rgba(255,255,255,.16));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--rarity-color, #fff) 24%, transparent),
    0 10px 22px rgba(0,0,0,.28);
  z-index: 2;
}

/* Curtain reveal: the front face (skin + price) sits on top and, on hover
   or tap, rises out of view like a curtain lifting, uncovering the panel
   behind it that says who won the drop and where it came from. */
.drop-mini-face {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  background: #202431;
  transition: transform .5s cubic-bezier(.65,0,.35,1), box-shadow .35s ease;
}

.drop-mini:hover .drop-mini-face,
.drop-mini.is-open .drop-mini-face {
  background: color-mix(in srgb, var(--rarity-color, #fff) 14%, #202431);
  transform: translateY(-100%);
  box-shadow: 0 10px 14px -6px rgba(0,0,0,.4);
}

.drop-mini-curtain {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  text-align: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--rarity-color, #fff) 22%, #12141c), #0d0f16);
}

.drop-mini-curtain-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 1px;
  border-radius: 50%;
  overflow: hidden;
  background: #1b1f2a;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.drop-mini-curtain-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drop-mini-curtain-player {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.25;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.drop-mini-curtain-source {
  max-width: 100%;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (prefers-reduced-motion: reduce) {
  .drop-mini-face {
    transition: none;
  }
}

.drop-mini-media {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 64px;
  height: 44px;
}

.drop-mini-media > img,
.drop-mini-media > .skin-fallback {
  grid-area: 1 / 1;
}

.drop-mini-media img {
  width: 64px;
  height: 44px;
  object-fit: contain;
}

.drop-mini-media .skin-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 44px;
  color: var(--rarity-color, inherit);
}

.drop-mini-media .skin-fallback[hidden],
.skin-fallback[hidden] {
  display: none !important;
}

.drop-mini-media .skin-fallback svg {
  width: 100%;
  height: 100%;
}

.drop-mini-text {
  min-width: 0;
  flex: 1;
}

.drop-mini-text strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drop-mini-text span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.hero,
.case-hero,
.profile-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255,207,77,.18), transparent 45%),
    linear-gradient(135deg, #1d2029, #171a22);
  box-shadow: var(--shadow);
}

.profile-head { grid-template-columns: auto minmax(0, 1fr) auto; }

h1, h2, h3, p { margin-top: 0; }

.hero h1,
.case-hero h1,
.profile-head h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1;
}

.hero p,
.case-hero p,
.profile-head p,
.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.case-odds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.case-odds span {
  display: grid;
  gap: 2px;
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--rarity-color) 42%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--rarity-color) 13%, transparent);
}

.case-odds b {
  color: var(--rarity-color);
  font-size: 14px;
}

.case-odds small {
  color: var(--muted);
  font-size: 11px;
}

.case-not-found {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 12px 0;
}

.case-not-found p {
  max-width: 46ch;
}

.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 82px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(24, 27, 35, .88);
}

.home-leaderboard {
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(17, 20, 27, .72);
  overflow: hidden;
}

.home-leaderboard .panel-head {
  padding: 12px;
}

.home-leaderboard .leader-list {
  padding: 12px;
}

.panel-title {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}

.section-head h2,
.panel-head h2 { margin: 0; }

.section-head span {
  color: var(--muted);
  font-size: 14px;
}

.search,
.auth-card input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 11px 12px;
  background: #11141b;
  color: var(--text);
  outline: none;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-row .search { flex: 1; min-width: 0; }

.price-filter {
  position: relative;
  flex: 0 0 auto;
}

.price-filter .icon-button {
  height: 100%;
}

.price-filter .icon-button.active {
  border-color: rgba(255, 207, 77, .48);
  color: #ffe59b;
}

.price-filter-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
  display: grid;
  gap: 4px;
  width: 190px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: #202431;
  box-shadow: var(--shadow);
}

.price-filter-menu[hidden] { display: none; }

.price-filter-menu button {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.price-filter-menu button:hover { background: rgba(255,255,255,.06); }

.price-filter-menu button.active {
  border-color: rgba(255, 207, 77, .48);
  background: rgba(255, 207, 77, .12);
  color: #ffe59b;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #202431;
  cursor: pointer;
  text-align: left;
}

.category-list button.active {
  border-color: rgba(255, 207, 77, .48);
  background: rgba(255, 207, 77, .12);
}

.content {
  display: grid;
  gap: 20px;
  align-self: start;
  min-width: 0;
}

.case-catalog {
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.case-category-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.case-category-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.case-category-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #ffe59b;
  white-space: nowrap;
}

.case-category-head span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.case-category-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 207, 77, .45), rgba(255, 207, 77, .08) 55%, transparent);
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.case-card {
  min-height: 246px;
  display: grid;
  grid-template-rows: 112px auto auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent), var(--panel);
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.case-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 207, 77, .4);
  background: linear-gradient(180deg, rgba(255,207,77,.1), transparent), var(--panel-2);
}

.case-art {
  display: grid;
  place-items: center;
  min-height: 112px;
}

.case-box {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  height: 82px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--case-a), var(--case-b));
  box-shadow: inset 0 -16px 0 rgba(0,0,0,.17), 0 16px 34px rgba(0,0,0,.28);
  transform: perspective(260px) rotateX(7deg) rotateY(-14deg);
}

.case-box img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 12px 18px rgba(0,0,0,.32));
}

.case-name {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.case-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.price {
  color: #ffdf86;
  font-weight: 900;
}

.rarity-strip {
  display: flex;
  gap: 4px;
}

.rarity-strip i {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: var(--rarity);
}

/* Free time-gated cases (homepage) */
.free-cases {
  margin-bottom: 4px;
}

.free-cases-head {
  justify-content: center;
  text-align: center;
}

.free-case-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.free-case-card {
  position: relative;
  flex: 0 1 190px;
}

.free-case-card.is-cooldown {
  opacity: .68;
}

.free-case-card.is-cooldown:hover {
  transform: none;
  border-color: rgba(255,255,255,.08);
}

.free-case-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .01em;
  background: rgba(10, 12, 18, .72);
  border: 1px solid rgba(255,255,255,.14);
  color: var(--muted);
}

.free-case-card.is-ready .free-case-badge {
  color: #123018;
  background: #7ce38b;
  border-color: rgba(124, 227, 139, .6);
}

.free-case-price {
  color: #7ce38b;
}

.roulette-panel,
.inventory-panel,
.drop-pool {
  min-width: 0;
  margin-top: 20px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(24, 27, 35, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.drop-pool { padding: 16px; }

.roulette-list {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  overflow: hidden;
}

.roulette-window {
  position: relative;
  margin: 0;
  height: 176px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: #10131a;
  contain: layout paint;
}

.roulette-window.compact {
  height: 132px;
}

.roulette-window::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: var(--marker-left, 50%);
  width: 3px;
  transform: translateX(-50%);
  background: var(--accent);
  box-shadow: 0 0 18px rgba(255,207,77,.9);
}

.roulette-window::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: calc(var(--marker-left, 50%) - 34px);
  width: 68px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,207,77,.08), transparent);
}

.roulette-track {
  display: flex;
  gap: 10px;
  height: 100%;
  padding: 12px;
  width: max-content;
  max-width: none;
  transform: translateX(0);
  transition: transform 4.4s cubic-bezier(.12,.72,.12,1);
  will-change: transform;
}

/* 5 дорожек — столбиком во всю ширину, 10 — двумя ровными колонками по
   пять: в обоих случаях сетка без «хвоста» из одинокой дорожки. */
.spin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 10px;
  min-width: 0;
}

.spin-grid.count-1,
.spin-grid.count-5 { grid-template-columns: minmax(0, 1fr); }
.spin-grid.count-10 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.spin-lane {
  position: relative;
  min-width: 0;
}

.spin-lane-index {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(10, 12, 18, .82);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.roulette-window.compact .skin-card {
  flex-basis: 128px;
  min-height: 0;
  grid-template-rows: 42px auto auto;
  gap: 6px;
  padding: 10px;
}

.roulette-window.compact .skin-card svg,
.roulette-window.compact .skin-media img {
  height: 40px;
}

.roulette-window.compact .skin-card strong {
  min-height: 0;
  -webkit-line-clamp: 1;
}

/* Дорожка встала: выпавший предмет светится цветом редкости, соседи гаснут. */
.roulette-window .skin-card {
  transition: opacity .35s ease, filter .35s ease, box-shadow .35s ease;
}

.roulette-window.is-settled .skin-card:not(.is-winner) {
  opacity: .32;
  filter: saturate(.5);
}

.roulette-window .skin-card.is-winner {
  border-color: var(--rarity-color);
  box-shadow:
    0 0 0 1px var(--rarity-color),
    0 0 26px -4px var(--rarity-color),
    inset 0 0 22px -10px var(--rarity-color);
}

.multi-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  min-width: 0;
}

.skin-card {
  flex: 0 0 152px;
  display: grid;
  grid-template-rows: 58px auto auto auto;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(180deg, color-mix(in srgb, var(--rarity-color) 22%, transparent), transparent 70%), #1b1f2a;
  border-top: 4px solid var(--rarity-color);
  text-align: center;
}

.skin-card svg {
  width: 100%;
  height: 54px;
  color: var(--rarity-color);
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.28));
}

.skin-media {
  display: grid;
  place-items: center;
  min-width: 0;
}

.skin-media img {
  width: 100%;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.28));
}

.skin-media span {
  width: 100%;
}

.skin-media .skin-fallback {
  color: var(--rarity-color);
}

.skin-card strong {
  min-height: 30px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 13px;
  line-height: 1.15;
}

.skin-card span {
  color: #ffdf86;
  font-weight: 900;
  font-size: 13px;
}

.skin-card small {
  min-height: 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.skin-card .skin-media .skin-fallback {
  color: var(--rarity-color);
  font-weight: inherit;
  font-size: inherit;
}

.spin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 18px 18px;
}

.spin-actions.is-free-case {
  justify-content: center;
}

.quick-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.quick-toggle input { width: 18px; height: 18px; }

.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 230px));
  justify-content: center;
  align-items: start;
  gap: 16px;
  padding: 4px 18px 20px;
  min-width: 0;
}

.result-list.single-result {
  grid-template-columns: minmax(190px, 240px);
}

.result-tools {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

.reward-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--rarity-color) 36%, rgba(255,255,255,.1));
  border-radius: 8px;
  background: #11141b;
}

.reward-card h3 {
  margin: 0;
  color: #ffdf86;
  font-size: 14px;
  text-align: center;
  text-transform: uppercase;
}

.reward-card .skin-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  flex: none;
}

.reward-price {
  color: #ffdf86;
  font-weight: 900;
  text-align: center;
}

.reward-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.reward-actions button {
  min-width: 0;
  white-space: nowrap;
}

.reward-card.sold {
  opacity: .72;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.inventory-item .ghost-button {
  width: 100%;
  margin-top: 8px;
}

.skin-card-wrap {
  position: relative;
}

.favorite-star {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 50%;
  background: rgba(10, 12, 20, .62);
  color: rgba(255,255,255,.55);
  cursor: pointer;
  transition: transform .15s ease, color .15s ease, border-color .15s ease, background .15s ease;
}

.favorite-star:hover {
  transform: translateY(-1px) scale(1.05);
  color: #ffdf86;
  border-color: rgba(255,223,134,.4);
}

.favorite-star.active {
  color: #ffdf86;
  border-color: rgba(255,223,134,.55);
  background: rgba(255,223,134,.14);
}

.inventory-item.is-favorite .skin-card {
  box-shadow: 0 0 0 1px rgba(255,223,134,.35) inset;
}

.history-list {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.history-actions {
  display: flex;
  justify-content: center;
  padding: 0 16px 16px;
}

.history-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 88px;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: #11141b;
}

.history-rarity {
  width: 6px;
  height: 100%;
  min-height: 42px;
  border-radius: 999px;
  background: var(--rarity-color);
  box-shadow: 0 0 16px color-mix(in srgb, var(--rarity-color) 55%, transparent);
}

.history-row strong,
.history-row span {
  display: block;
}

.history-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.history-row b {
  color: #ffdf86;
  white-space: nowrap;
}

.history-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
  font-size: 12px;
}

.history-row em.lost {
  color: #ff8b8b;
}

.history-row em.sold,
.history-row em.upgraded {
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-grid.wide {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin: 20px 0;
}

.stat {
  padding: 14px;
  border-radius: 8px;
  background: #11141b;
  border: 1px solid rgba(255,255,255,.07);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px clamp(14px, 3vw, 36px) 26px;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer p { margin: 0; }

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
}

.site-footer-links a { color: #ffdf86; }
.site-footer-links a:hover { text-decoration: underline; }

.footer-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.footer-logo:hover .brand-mark,
.footer-logo:hover .footer-logo-img { transform: translateY(-1px); }

.footer-logo .brand-mark { transition: transform .15s ease; }

.footer-logo-img {
  display: block;
  width: auto;
  height: 38px;
  max-width: 160px;
  object-fit: contain;
  transition: transform .15s ease;
}

.auth-page .site-footer {
  width: min(420px, 100%);
  border-top: none;
  padding: 0;
  margin-top: 4px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 18px;
  align-content: center;
  padding: 24px;
}

.auth-brand { min-width: 0; }

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: rgba(24, 27, 35, .92);
  box-shadow: var(--shadow);
}

.auth-card h1 { margin-bottom: 2px; }
.auth-card label { display: grid; gap: 7px; color: var(--muted); }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card a { color: #ffdf86; }

.empty {
  padding: 34px 16px;
  color: var(--muted);
  text-align: center;
}

.empty.compact {
  padding: 18px 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 36px));
  display: none;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: #202431;
  box-shadow: var(--shadow);
}

.toast.active { display: block; }

@media (max-width: 900px) {
  .topbar {
    align-items: center;
    flex-wrap: wrap;
    row-gap: 10px;
    padding-top: 8px;
  }
  .brand {
    order: 0;
    flex: 1 1 100%;
    min-width: 0;
    justify-content: center;
    overflow: hidden;
  }
  .brand-logo-img {
    height: 44px;
    max-width: min(220px, 100%);
  }
  .wallet { order: 1; margin-left: 0; }
  .sound-toggle { order: 2; }
  .profile-link { order: 3; margin-left: auto; }
  .nav {
    order: 4;
    flex-basis: 100%;
    justify-content: center;
  }
  .hero,
  .case-hero,
  .profile-head { grid-template-columns: 1fr; }
  .profile-head {
    justify-items: center;
    text-align: center;
  }
  .profile-actions { justify-content: center; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .profile-layout { grid-template-columns: 1fr; }
  .leaderboard-panel { position: static; }
  .drop-mini {
    width: 236px;
  }
  .drop-mini-face {
    padding: 10px 12px;
    gap: 9px;
    min-height: 92px;
  }
  .drop-mini-media {
    width: 54px;
    height: 38px;
  }
  .drop-mini-media img,
  .drop-mini-media .skin-fallback {
    width: 54px;
    height: 38px;
  }
  .drop-mini-text strong { font-size: 12px; }
  .drop-mini-text span { font-size: 11px; }
}

@media (max-width: 560px) {
  .nav a, .ghost-button, .primary-button { padding: 9px 10px; }
  .ticker-track {
    gap: 7px;
    padding: 8px 0;
    animation-duration: 48s;
  }
  .drop-mini {
    width: 210px;
  }
  .drop-mini-face {
    padding: 8px 9px;
    gap: 7px;
    min-height: 86px;
  }
  .drop-mini-media {
    width: 46px;
    height: 32px;
  }
  .drop-mini-media img,
  .drop-mini-media .skin-fallback {
    width: 46px;
    height: 32px;
  }
  .drop-mini-curtain-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
  .drop-mini-curtain-player { font-size: 12px; }
  .drop-mini-curtain-source { font-size: 11px; }
  .drop-mini-text strong { font-size: 11px; }
  .drop-mini-text span { font-size: 10px; }
  .case-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-card {
    min-height: 220px;
    padding: 12px;
    grid-template-rows: 96px auto auto;
  }
  .case-name { font-size: 15px; }
  .roulette-window { margin: 12px; }
  .roulette-list .roulette-window { margin: 0; }
  .roulette-list { padding: 12px; }
  .spin-grid,
  .spin-grid.count-10 { grid-template-columns: minmax(0, 1fr); }
  .skin-card { flex-basis: 132px; }
  .result-list { padding: 0 12px 12px; }
  .history-row {
    grid-template-columns: 8px minmax(0, 1fr);
  }
  .history-row b,
  .history-row em {
    grid-column: 2;
    text-align: left;
  }
}

/* ===========================================================================
   Upgrade game (/upgrade)
   =========================================================================== */

.upgrade-panel { margin-top: 20px; }

.upgrade-banner {
  margin: 16px 20px 0;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}

.upgrade-banner.win { color: var(--green); background: rgba(71,217,139,.12); border: 1px solid rgba(71,217,139,.35); }
.upgrade-banner.lose { color: var(--red); background: rgba(255,98,90,.12); border: 1px solid rgba(255,98,90,.35); }

.upgrade-columns {
  display: grid;
  grid-template-columns: 1fr 260px 1fr;
  gap: 20px;
  padding: 20px;
  min-width: 0;
}

.upgrade-col {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

.upgrade-window {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  background: #10131a;
  padding: 12px;
  min-height: 150px;
}

.upgrade-window-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.upgrade-window-head strong { color: #ffdf86; }

.upgrade-window-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.upgrade-window-item,
.upgrade-window-slot {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  display: grid;
  place-items: center;
  padding: 4px;
  min-width: 0;
}

.upgrade-window-item {
  border-color: color-mix(in srgb, var(--rarity-color) 45%, rgba(255,255,255,.1));
  cursor: pointer;
}

.upgrade-window-item .skin-media,
.upgrade-window-item img,
.upgrade-window-item svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.upgrade-window-single { display: grid; place-items: center; }

.upgrade-window-single .skin-card { width: 100%; flex: none; box-sizing: border-box; }

.upgrade-window-slot.large {
  width: 100%;
  min-height: 130px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: 8px;
}

.upgrade-stake-row { display: grid; gap: 6px; }

.upgrade-stake-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.upgrade-stake-label strong { color: #ffdf86; }

.upgrade-stake-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.upgrade-pick-panel {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(24, 27, 35, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upgrade-pick-panel .panel-head { padding: 16px 16px 0; }

.upgrade-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px 0;
}

.upgrade-filters select,
.upgrade-filters input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
  flex: 1;
  min-width: 90px;
}

.upgrade-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 16px;
  max-height: 420px;
  overflow-y: auto;
}

.upgrade-pick-item {
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 0;
  cursor: pointer;
  min-width: 0;
}

.upgrade-pick-item .skin-card { width: 100%; flex: none; box-sizing: border-box; }

.upgrade-pick-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.upgrade-pick-item:disabled { opacity: .55; cursor: not-allowed; }

.upgrade-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 13px;
}

.upgrade-pager button[disabled] { opacity: .4; cursor: not-allowed; }

.upgrade-center {
  display: grid;
  justify-items: center;
  gap: 12px;
  align-content: start;
  text-align: center;
  min-width: 0;
}

.upgrade-wheel {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}

.upgrade-wheel-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from -90deg, #5a6574 0deg 180deg, #3d4552 180deg 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 17px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 18px), #000 calc(100% - 17px));
  filter: drop-shadow(0 0 10px rgba(0,0,0,.4));
}

.upgrade-wheel-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.upgrade-wheel-tick {
  position: absolute;
  left: 50%;
  top: 0;
  width: 3px;
  height: 20px;
  margin-left: -1.5px;
  transform-origin: 50% 100px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(0,0,0,.55);
}

.upgrade-wheel-needle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 82px;
  margin-left: -2px;
  margin-top: -82px;
  transform-origin: 50% 100%;
  border-radius: 3px 3px 0 0;
  background: #fff;
  transform: rotate(180deg);
  z-index: 3;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}

.upgrade-wheel-needle::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  margin-left: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid #fff;
}

.upgrade-wheel-core {
  position: relative;
  z-index: 2;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  gap: 2px;
  transition: box-shadow .3s ease;
}

.upgrade-wheel-core strong { font-size: 24px; }
.upgrade-wheel-core span { color: var(--muted); font-size: 11px; }

.upgrade-wheel.result-win .upgrade-wheel-core { box-shadow: 0 0 0 5px rgba(71,217,139,.55); }
.upgrade-wheel.result-lose .upgrade-wheel-core { box-shadow: 0 0 0 5px rgba(255,98,90,.55); }

.upgrade-mult-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.upgrade-mult-row button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.upgrade-mult-row button:hover { border-color: var(--accent); }
.upgrade-mult-row button:disabled { opacity: .55; cursor: not-allowed; }

.upgrade-go { width: 100%; max-width: 220px; }

.upgrade-summary {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  min-height: 16px;
  max-width: 260px;
}

.upgrade-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 14, .72);
  backdrop-filter: blur(6px);
}

.upgrade-modal[hidden] { display: none; }

.upgrade-modal-card {
  width: min(340px, 100%);
}

.upgrade-modal-card .reward-card {
  box-shadow: 0 18px 48px rgba(0,0,0,.45);
}

@media (max-width: 980px) {
  .upgrade-columns { grid-template-columns: 1fr; padding: 16px; }
  .upgrade-center { order: -1; }
  .upgrade-banner { margin: 12px 16px 0; }
}

/* ---------------------------------------------------------------------- */
/* Contracts                                                               */
/* ---------------------------------------------------------------------- */

.contract-panel { margin-top: 20px; }

.contract-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.contract-rule {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(24, 27, 35, .92);
}

.contract-rule strong {
  color: #ffdf86;
  font-size: 14px;
}

.contract-rule span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.contract-slots-wrap { padding: 20px 20px 0; }

.contract-slots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.contract-slots .upgrade-window-item,
.contract-slots .upgrade-window-slot {
  aspect-ratio: 1;
}

.contract-info-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px 20px 0;
  text-align: center;
}

.contract-info-cell {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: #10131a;
}

.contract-info-cell span {
  color: var(--muted);
  font-size: 12px;
}

.contract-info-cell strong {
  color: #ffdf86;
  font-size: 16px;
}

.contract-info-cell-center {
  display: grid;
  place-items: center;
  background: rgba(255, 207, 77, .08);
  border-color: rgba(255, 207, 77, .25);
}

.contract-info-cell-center span {
  color: #ffe59b;
  font-weight: 700;
  font-size: 13px;
}

.contract-inventory-row {
  padding: 20px;
  min-width: 0;
}

.contract-inv-panel { width: 100%; }

.contract-sign-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  min-width: 0;
  align-items: start;
}

.contract-stake-col {
  display: grid;
  align-content: start;
  gap: 14px;
  padding-bottom: 16px;
}

.contract-sign-col {
  display: grid;
  align-content: start;
  gap: 0;
  min-width: 0;
}

.contract-stake-row { padding: 0 16px; }

.contract-range-preview {
  margin: 0 16px;
  padding: 14px;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: 8px;
  text-align: center;
}

.contract-range-preview p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.contract-range-values {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 14px;
}

.contract-range-values b { color: #ffdf86; }

.contract-sign-panel { margin: 0 20px 20px; padding-bottom: 0; }

.contract-signature-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.contract-palette {
  display: flex;
  gap: 8px;
}

.contract-color {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25);
  background: var(--swatch);
  cursor: pointer;
}

.contract-color.active {
  border-color: #ffdf86;
  box-shadow: 0 0 0 2px rgba(255,223,134,.35);
}

.contract-tool-buttons {
  display: flex;
  gap: 8px;
}

.contract-tool-buttons .ghost-button.active {
  border-color: rgba(255, 207, 77, .48);
  color: #ffe59b;
}

.contract-signature-square {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.contract-canvas {
  display: block;
  width: 100%;
  max-width: 460px;
  max-height: 360px;
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.14);
  background: #10131a;
  touch-action: none;
  cursor: crosshair;
}

.contract-sign-actions {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  text-align: center;
}

.contract-fx {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
}

.contract-fx-item {
  position: fixed;
  z-index: 71;
  border-radius: 8px;
  pointer-events: none;
  will-change: transform, opacity;
}

.contract-fx-item img,
.contract-fx-item svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.45));
}

.contract-fx-burst {
  position: fixed;
  z-index: 69;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,223,134,.9), rgba(255,223,134,0) 70%);
  pointer-events: none;
  opacity: 0;
}

@media (max-width: 980px) {
  .contract-inventory-row { padding: 16px; }
  .contract-sign-columns { grid-template-columns: 1fr; padding: 16px; }
  .contract-rules { grid-template-columns: 1fr; }
  .contract-info-row { grid-template-columns: 1fr; }
  .contract-slots { grid-template-columns: repeat(5, 1fr); }
}

/* ---------------------------------------------------------------------- */
/* Дуэли (/duels)                                                          */
/* ---------------------------------------------------------------------- */

.duel-page {
  padding: clamp(16px, 3vw, 36px);
  display: grid;
  gap: 22px;
}

.duel-guest-gate {
  display: grid;
  gap: 12px;
  justify-items: start;
  max-width: 480px;
  margin: 60px auto;
  text-align: center;
  justify-items: center;
}

/* `display: grid` above and the browser's built-in `[hidden] { display: none }`
   have equal specificity — without this, the later (author) rule wins and the
   [hidden] attribute set by duel.js is silently ignored, so this block would
   show even for a logged-in player. Same issue below for .duel-battle. */
.duel-guest-gate[hidden] { display: none; }

.duel-guest-gate p { color: var(--muted); }

.duel-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.duel-search,
.duel-sort {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
}

.duel-search { flex: 1 1 260px; min-width: 200px; }
.duel-create-button { margin-left: auto; }

.duel-lobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.duel-lobby-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.duel-lobby-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.duel-lobby-cases {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.duel-lobby-case-icon,
.duel-lobby-case-extra {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
}

.duel-lobby-case-icon img { width: 100%; height: 100%; object-fit: contain; }
.duel-case-thumb-fallback { width: 100%; height: 100%; background: var(--panel-2); display: block; }

.duel-lobby-case-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.duel-lobby-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.duel-empty-note {
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
}

.duel-pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.duel-page-button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-width: 36px;
  padding: 6px 10px;
  cursor: pointer;
}

.duel-page-button.active {
  background: var(--accent);
  color: #1a1300;
  border-color: var(--accent);
}

/* --- модалки (создание / ожидание / результат) --- */

.duel-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 14, .72);
  backdrop-filter: blur(6px);
}

.duel-modal[hidden] { display: none; }

.duel-modal-card {
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.duel-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.duel-case-list {
  display: grid;
  gap: 8px;
  max-height: 42vh;
  overflow-y: auto;
}

.duel-case-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 10px;
}

.duel-case-row-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  display: grid;
  place-items: center;
}

.duel-case-row-thumb img { width: 100%; height: 100%; object-fit: contain; }
.duel-case-row-name { font-size: 14px; }
.duel-case-row-price { font-size: 13px; color: var(--muted); white-space: nowrap; }

.duel-case-row-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.duel-step-button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.duel-case-row-qty {
  min-width: 22px;
  text-align: center;
  font-weight: 700;
}

.duel-modal-summary {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.duel-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.duel-wait-card {
  text-align: center;
  justify-items: center;
}

.duel-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: duel-spin 0.9s linear infinite;
}

@keyframes duel-spin {
  to { transform: rotate(360deg); }
}

.duel-wait-timer { color: var(--muted); }

/* --- экран боя --- */

.duel-battle {
  display: grid;
  gap: 16px;
}

.duel-battle[hidden] { display: none; }

.duel-battle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.duel-battle-columns {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: start;
}

.duel-battle-vs {
  align-self: center;
  font-size: 24px;
}

.duel-battle-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.duel-side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.duel-side-total { color: var(--muted); font-size: 14px; }
.duel-side-total strong { color: var(--text); }

/* Live spin per side reuses .roulette-window/.roulette-track/.skin-card as-is
   (see case.html / openMany() in app.js) so it looks and animates exactly
   like a normal case opening — just narrower (.compact) to fit the column. */
.duel-battle-side .roulette-window { margin: 0; }

.duel-history {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.duel-drop-card {
  border: 1px solid color-mix(in srgb, var(--rarity-color, #fff) 42%, rgba(255,255,255,.16));
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 4px;
  text-align: center;
  background: color-mix(in srgb, var(--rarity-color, #fff) 10%, var(--panel-2));
}

.duel-drop-card img {
  width: 100%;
  height: 48px;
  object-fit: contain;
}

.duel-drop-name {
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-drop-value {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

.duel-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.duel-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width .3s ease;
}

/* --- результат --- */

.duel-result-card { text-align: center; }

.duel-result-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.duel-result-players > div {
  background: var(--panel-2);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.duel-result-players .is-winner {
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.duel-result-summary { color: var(--muted); }

@media (max-width: 720px) {
  .duel-battle-columns { grid-template-columns: 1fr; }
  .duel-battle-vs { display: none; }
  .duel-result-players { grid-template-columns: 1fr; }
}
