/* ========== RESET & BASE ========== */
html {
  scrollbar-width: none;
}
html::-webkit-scrollbar {
  display: none;
}

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

:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --transition: 0.2s ease;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --container: 1440px;
}

/* ========== DARK THEME (default) ========== */
[data-theme="dark"] {
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-tertiary: #1A1A1A;
  --bg-card: #141414;
  --bg-card-hover: #1C1C1C;
  --bg-input: #141414;
  --border: #252525;
  --border-hover: #353535;
  --text-primary: #F2F2F2;
  --text-secondary: #8A8A8A;
  --text-tertiary: #555555;
  --accent: #FF8C00;
  --accent-hover: #FFA033;
  --accent-soft: rgba(255,140,0,0.15);
  --green: #00C853;
  --green-soft: rgba(0,200,83,0.12);
  --red: #FF3D3D;
  --red-soft: rgba(255,61,61,0.12);
  --orange: #FF8C00;
  --orange-soft: rgba(255,140,0,0.12);
  --overlay: rgba(0,0,0,0.8);
  --shadow-card: 0 2px 12px rgba(255,140,0,0.08);
  color-scheme: dark;
}

/* ========== LIGHT THEME ========== */
[data-theme="light"] {
  --bg-primary: #F5F0EB;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #FFF3E6;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FFF8F0;
  --bg-input: #FFF3E6;
  --border: #E8DDD0;
  --border-hover: #D4C4B0;
  --text-primary: #1A1200;
  --text-secondary: #7A6B55;
  --text-tertiary: #A69880;
  --accent: #E07800;
  --accent-hover: #C06800;
  --accent-soft: rgba(224,120,0,0.1);
  --green: #00A849;
  --green-soft: rgba(0,168,73,0.08);
  --red: #E03030;
  --red-soft: rgba(224,48,48,0.08);
  --orange: #E07800;
  --orange-soft: rgba(224,120,0,0.08);
  --overlay: rgba(0,0,0,0.4);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
  color-scheme: light;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.link {
  color: var(--accent);
  font-weight: 500;
}
.link:hover { color: var(--accent-hover); }

/* ========== HEADER ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo__img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
}

.logo__text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.search {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 40px;
  padding: 0 80px 0 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border var(--transition);
}

.search__input::placeholder {
  color: var(--text-tertiary);
}

.search__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font);
  pointer-events: none;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255,140,0,0.35);
}

.btn--outline {
  border: 1px solid var(--border);
  color: var(--text-primary);
  background: transparent;
}
.btn--outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn--ghost {
  color: var(--text-secondary);
  background: transparent;
}
.btn--ghost:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.btn--sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn--lg {
  padding: 12px 24px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn--social {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  border: 1px solid var(--border);
  justify-content: center;
}
.btn--social:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-hover);
}

.btn--telegram { }
.btn--google { }

/* ========== BURGER ========== */
.burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.burger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}
.burger.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ========== MOBILE MENU ========== */
.mobile-menu {
  display: none;
  position: fixed;
  inset: 64px 0 0 0;
  background: var(--bg-secondary);
  z-index: 99;
  padding: 16px;
  overflow-y: auto;
}
.mobile-menu.active { display: block; }

/* ========== CATEGORIES ========== */
.categories {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.categories__wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.categories__track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 4px 0;
  flex: 1;
}
.categories__track::-webkit-scrollbar { display: none; }

.categories__arrow {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  z-index: 2;
}
.categories__arrow:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}
.categories__arrow--left { margin-right: 8px; }
.categories__arrow--right { margin-left: 8px; }

.category-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: all var(--transition);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-chip img {
  flex-shrink: 0;
  border-radius: 4px;
}

.category-chip:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  border-color: var(--border);
}

.category-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ========== SUB-NAV ========== */
.sub-nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.sub-nav:has(.sub-nav__tabs:empty) {
  display: none;
}

.sub-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sub-nav__tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.sub-nav__tabs::-webkit-scrollbar { display: none; }

.sub-nav__tab {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.sub-nav__tab:hover {
  color: var(--text-primary);
}
.sub-nav__tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sub-nav__controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.results-count {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Sort dropdown */
.sort-dropdown {
  position: relative;
}

.sort-dropdown__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-input);
  transition: all var(--transition);
}
.sort-dropdown__btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.sort-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: 4px;
  animation: fadeIn 0.15s ease;
}
.sort-dropdown__menu.open { display: block; }

.sort-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.sort-dropdown__item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.sort-dropdown__item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== MAIN ========== */
.main {
  padding: 24px 0 48px;
  min-height: 60vh;
}

/* ========== PRODUCT GRID ========== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* ========== PRODUCT CARD ========== */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card);
}

.product-card__image {
  position: relative;
  width: 100%;
  padding-top: 51.5%; /* shorter height for wider cards */
  background: var(--bg-tertiary);
  overflow: hidden;
}

.product-card__image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.product-card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge--hot {
  background: var(--red);
  color: #fff;
}
.badge--new {
  background: var(--green);
  color: #fff;
}
.badge--sale {
  background: var(--orange);
  color: #fff;
}
.badge--type {
  background: rgba(0,0,0,0.6);
  color: #fff;
  backdrop-filter: blur(4px);
}

.product-card__body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card__game {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.product-card__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.product-card__tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.product-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  overflow: hidden;
}

.product-card__footer .btn {
  flex-shrink: 0;
}

.product-card__price {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.product-card__price-currency {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.product-card__price-note {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.product-card__seller {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.product-card__seller-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.product-card__seller-rating {
  color: var(--green);
  font-weight: 600;
}

/* ========== LOAD MORE ========== */
.load-more {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}

/* ========== MODALS ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}
.modal--wide {
  max-width: 720px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-tertiary);
  transition: all var(--transition);
}
.modal__close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal__title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal__subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.modal__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-group__input {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
}
.input-group__input::placeholder { color: var(--text-tertiary); }
.input-group__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.modal__divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-tertiary);
  font-size: 13px;
}
.modal__divider::before,
.modal__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.modal__socials {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal__footer-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 20px;
}

.modal__error {
  color: #ef4444;
  font-size: 13px;
  margin: 0 0 8px;
  padding: 8px 12px;
  background: rgba(239,68,68,0.1);
  border-radius: var(--radius-sm);
}

/* ========== USER PROFILE ========== */
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-profile__name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

/* ========== PRODUCT DETAIL ========== */
.product-detail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.product-detail__image {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
  width: 100%;
  padding-top: 56.25%; /* 9/16 = 56.25% */
}
.product-detail__image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.product-detail__info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-detail__game {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
}

.product-detail__title {
  font-size: 20px;
  font-weight: 800;
}

.product-detail__desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.product-detail__price {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0;
}

.product-detail__seller {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.product-detail__seller-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
}

.product-detail__seller-info {
  display: flex;
  flex-direction: column;
}

.product-detail__seller-name {
  font-weight: 600;
  font-size: 14px;
}

.product-detail__seller-stats {
  font-size: 12px;
  color: var(--text-secondary);
}

.product-detail__actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.product-detail__actions .btn {
  flex: 1;
  justify-content: center;
}

/* ========== THEME TOGGLE ========== */
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* ========== FOOTER ========== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding-top: 48px;
}

.footer__inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 32px;
}

.footer__desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.6;
}

.footer__socials {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.footer__social {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.footer__social:hover {
  background: var(--accent);
  color: #fff;
}

.footer__title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.footer__link {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: color var(--transition);
}
.footer__link:hover {
  color: var(--accent);
}

.footer__bottom {
  display: flex;
  justify-content: space-between;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ========== PAYMENT ========== */
.payment-summary {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

.payment-summary__image {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.payment-summary__image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.payment-summary__info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.payment-summary__title {
  font-size: 15px;
  font-weight: 700;
}

.payment-summary__game {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.payment-summary__price {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
}

.payment-methods {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.payment-method:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.payment-method.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.payment-method__icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  color: var(--accent);
}

.payment-method__icon img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
}

.payment-method__icon img.sbp-icon {
  margin-left: 3px;
}

.payment-method__icon img.cryptobot-icon {
  transform: scale(1.5);
}

.payment-method--balance {
  border-color: rgba(255,140,0,0.35);
  background: linear-gradient(135deg, rgba(255,140,0,0.08), rgba(255,140,0,0.02));
  position: relative;
}
.payment-method--balance::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,140,0,0.2);
}
.payment-method--balance:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255,140,0,0.14), rgba(255,140,0,0.04));
}
.payment-method--balance.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255,140,0,0.22), rgba(255,140,0,0.06));
  box-shadow: 0 0 0 3px var(--accent-soft), 0 8px 24px rgba(255,140,0,0.15);
}
.payment-method__icon--balance img {
  transform: scale(1.6);
}
#payBalanceAmount {
  color: var(--accent);
  font-weight: 700;
}

.payment-method strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.payment-method small {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.payment-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 16px;
  line-height: 1.5;
}

.payment-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 0;
}

.payment-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== SKELETON LOADING ========== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== PROFILE ========== */
.profile-section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 12px;
}

.profile-stats__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.profile-stat {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-stat__value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.profile-stat__label {
  font-size: 12px;
  color: var(--text-secondary);
}

.profile-orders {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  gap: 12px;
}

.profile-order__product {
  font-weight: 600;
  font-size: 14px;
}

.profile-order__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status--paid { color: #22c55e; }
.status--pending { color: #f59e0b; }

/* Header avatar */
.user-profile__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.user-profile__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-profile__avatar-letter {
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  text-transform: uppercase;
}

.user-profile__name {
  cursor: pointer;
}
.user-profile__name:hover {
  color: var(--accent);
}

/* Profile page */
.profile-page {
  max-width: 800px;
  margin: 0 auto;
}

.profile-page__header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.profile-page__avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.profile-page__avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-page__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-page__avatar-letter {
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  text-transform: uppercase;
}

.profile-page__avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.profile-page__avatar-edit:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.profile-page__username {
  font-size: 24px;
  font-weight: 800;
}

.profile-page__date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-stat--balance {
  position: relative;
}

.profile-topup-btn {
  margin-top: 8px;
  width: 100%;
}

.topup-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.topup-preset {
  flex: 1;
  min-width: 70px;
  justify-content: center;
}

/* ========== MESSENGER ========== */
.messenger-page {
  max-width: 800px;
  margin: 0 auto;
}

.messenger__title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 16px;
}

.messenger__items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.messenger__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.messenger__item:hover {
  background: var(--bg-tertiary);
}

.messenger__item-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.messenger__item-icon svg {
  color: #fff;
}

.messenger__item-body {
  flex: 1;
  min-width: 0;
}

.messenger__item-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messenger__item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messenger__item-time {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.messenger__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  gap: 8px;
  padding: 40px;
  text-align: center;
}

.messenger__empty svg {
  opacity: 0.3;
}

/* Chat panel inside messenger */
.messenger__chat-wrap {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  height: calc(100vh - 200px);
  min-height: 400px;
  max-height: 700px;
}

.messenger__chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.messenger__chat-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat__messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat__messages::-webkit-scrollbar { display: none; width: 0; height: 0; }

.chat__msg {
  background: var(--bg-tertiary);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px;
  max-width: 75%;
  align-self: flex-start;
  animation: msgSlideIn 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.chat__msg--own {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  animation: msgSlideInRight 0.16s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.chat__msg--own .chat__msg-name,
.chat__msg--own .chat__msg-time {
  color: rgba(255,255,255,0.7);
}

.chat__msg--admin {
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
}

.chat__msg-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.chat__msg-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.chat__msg--own .chat__msg-name {
  color: rgba(255,255,255,0.85);
}

.chat__msg-time {
  font-size: 10px;
  color: var(--text-secondary);
}

.chat__msg-text {
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat__step {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255,140,0,0.08), rgba(255,140,0,0.02));
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat__step-prompt {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}
.chat__step-prompt b, .chat__step-prompt strong { color: var(--accent); }
.chat__step-prompt code {
  background: rgba(255,140,0,0.15);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: monospace;
}
.chat__step-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-style: italic;
}
.chat__step-hint a { color: var(--accent); }
.chat__step-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.chat__step-row .chat__input { flex: 1; }

.chat__input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}

.chat__input:focus {
  border-color: var(--accent);
}

.chat__form .btn {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes msgSlideInRight {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .header__nav { display: none; }
  .burger { display: flex; }
  .footer__inner {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
  .search { max-width: none; }
  .search__kbd { display: none; }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .header__inner { height: 56px; }
  .footer__inner {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .footer__bottom {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
  }
  .product-detail {
    flex-direction: column;
  }
  .sub-nav .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-bottom: 8px;
  }
  .sub-nav__controls {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
  .logo__text { display: none; }
}

/* ── Quantity modal (stars/steam) ───────────────────── */
.input-group__hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.qty-summary {
  margin-top: 16px;
  border-radius: 12px;
  background: var(--bg-secondary);
  padding: 14px 16px;
}
.qty-error {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(227, 52, 47, .08);
  border: 1px solid rgba(227, 52, 47, .25);
  color: #e3342f;
  font-size: 13px;
}
.qty-continue {
  width: 100%;
  margin-top: 18px;
}
#quantityModal .modal { max-width: 460px; }
#quantityModal input[type=number]::-webkit-outer-spin-button,
#quantityModal input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#quantityModal input[type=number] { -moz-appearance: textfield; }

/* ── Closed-order banner in chat ────────────────────────── */
.chat-banner {
  margin: 0;
  padding: 14px 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  border-top: 1px solid var(--border, #e2e8f0);
}
.chat-banner--success { background: rgba(34, 197, 94, .10); color: #15803d; }
.chat-banner--refunded { background: rgba(245, 158, 11, .10); color: #b45309; }
.chat-banner--failed { background: rgba(100, 116, 139, .10); color: #475569; }
