:root {
  --ui-line: #dfe5eb;
  --ui-line-strong: #cbd5df;
  --ui-surface-muted: #f7f9fb;
  --ui-text-soft: #718091;
  --ui-focus: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
  --ui-shadow-soft: 0 8px 24px rgba(21, 33, 48, .07);
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

button,
a,
input,
select,
textarea { -webkit-tap-highlight-color: transparent; }

button,
a,
input,
select,
textarea { transition: border-color .18s ease, color .18s ease, background-color .18s ease, box-shadow .18s ease, opacity .18s ease; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  box-shadow: var(--ui-focus);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select,
textarea { border-color: var(--ui-line-strong); }

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):hover,
select:hover,
textarea:hover { border-color: #aebbc8; }

.header { box-shadow: 0 1px 0 rgba(19, 28, 40, .04); }
.header-inner { min-width: 0; }
.desktop-nav { min-width: 0; }
.desktop-nav a,
.desktop-nav button { min-height: 44px; }
.language-select,
.currency-select,
.profile-btn { min-height: 38px; }

.listing,
.product-buy-panel,
.product-detail-content,
.product-side-info,
.product-recommendations,
.store-route-product,
.member-order,
.wallet-action,
.coupon-item { border-color: var(--ui-line); }

.listing:hover,
.store-route-product:hover,
.product-recommend-grid button:hover,
.member-order:hover { border-color: var(--ui-line-strong); box-shadow: var(--ui-shadow-soft); }

.listing-main,
.member-order-body,
.saved-item-main { border-radius: inherit; }
.listing-body { padding: 12px 13px 13px; }
.listing-foot { margin-top: 10px; padding-top: 9px; }
.listing-tags { margin-top: 6px; }

.market-controls { min-height: 48px; }
.market-body { gap: 24px; }
.filter-panel { padding-right: 20px; }
.game-filter { min-height: 44px; padding-top: 12px; padding-bottom: 12px; }

.modal-backdrop {
  background: rgba(9, 13, 19, .58);
  backdrop-filter: blur(4px);
}

.modal {
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 24px 64px rgba(8, 15, 24, .24);
}

.modal-close {
  display: grid;
  place-items: center;
  border-radius: 4px;
}
.modal-close:hover { color: var(--ink); background: var(--ui-surface-muted); }

.modal-close:not(.is-back),
.saved-item .saved-item-remove {
  display: grid;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid #c6a451;
  border-radius: 6px;
  color: #e6c873;
  background: #121315;
  box-shadow: 0 4px 12px rgba(18, 19, 21, .16), inset 0 0 0 1px rgba(255, 226, 145, .05);
}
.modal-close:not(.is-back) .ui-icon,
.saved-item .saved-item-remove .ui-icon { width: 18px; height: 18px; stroke-width: 2.2; }
.modal-close:not(.is-back):hover { border-color: #e0c36f; color: #ffe39a; background: #202124; }
.saved-item .saved-item-remove:hover { border-color: #d96a71; color: #ffadb2; background: #241719; }
.modal-close:not(.is-back):active,
.saved-item .saved-item-remove:active { transform: translateY(1px); }
.modal-close:not(.is-back):focus-visible,
.saved-item .saved-item-remove:focus-visible { outline: 2px solid #d9b85f; outline-offset: 2px; }

.saved-item { min-width: 0; padding: 8px 10px; overflow: hidden; }
.saved-item-main { width: 0; min-width: 0; flex: 1 1 0; overflow: hidden; }
.saved-item-main span { min-width: 0; overflow: hidden; }
.saved-item .saved-item-remove {
  width: 32px;
  height: 32px;
  min-width: 32px;
  margin-left: 2px;
  flex: 0 0 32px;
  border-radius: 5px;
}
.saved-item .saved-item-remove .ui-icon { width: 15px; height: 15px; }

.modal-close.is-back,
.account-route-back.qikswap-back-button,
.seller-route-back.qikswap-back-button,
.product-breadcrumb .qikswap-back-button,
.product-market-return.qikswap-back-button,
.store-route-breadcrumb .qikswap-back-button,
.presale-chat-head > .qikswap-back-button,
.support-head > .qikswap-back-button {
  display: inline-flex;
  min-height: 40px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #c6a451;
  border-radius: 6px;
  color: #e6c873;
  background: #121315;
  box-shadow: 0 4px 12px rgba(18, 19, 21, .16), inset 0 0 0 1px rgba(255, 226, 145, .05);
  font-weight: 700;
  line-height: 1;
}
.modal-close.is-back { width: 40px; height: 40px; padding: 0; }
.qikswap-back-button > span { display: grid; width: 20px; height: 20px; flex: none; place-items: center; }
.qikswap-back-button .ui-icon,
.modal-close.is-back .ui-icon { width: 18px; height: 18px; stroke-width: 2.2; }
.qikswap-back-button > b { color: inherit; font-size: 13px; font-weight: 700; white-space: nowrap; }
.modal-close.is-back:hover,
.account-route-back.qikswap-back-button:hover,
.seller-route-back.qikswap-back-button:hover,
.product-breadcrumb .qikswap-back-button:hover,
.product-market-return.qikswap-back-button:hover,
.store-route-breadcrumb .qikswap-back-button:hover,
.presale-chat-head > .qikswap-back-button:hover,
.support-head > .qikswap-back-button:hover {
  border-color: #e0c36f;
  color: #ffe39a;
  background: #202124;
}
.qikswap-back-button:active,
.modal-close.is-back:active { transform: translateY(1px); }
.qikswap-back-button:focus-visible,
.modal-close.is-back:focus-visible { outline: 2px solid #d9b85f; outline-offset: 2px; }
.modal-actions { margin-top: 18px; }
.modal-actions button { min-height: 42px; }
.product-unavailable-state + .product-market-return { display: none; }
.message-detail-modal > .modal-close,
.presale-modal > .modal-close,
.presale-seller-modal > .modal-close { display: none; }

.message-modal {
  width: min(860px, 100%);
  padding: 24px;
  border-color: var(--ui-line);
  background: #fff;
}

.message-inbox { min-width: 0; padding: 0; }
.message-inbox-head { min-height: 68px; padding-right: 52px; }
.message-inbox-head h2 { margin-top: 6px; }
.message-inbox-actions { flex: none; }
.message-icon-action,
.message-inbox-link { min-height: 40px; }
.message-icon-action:hover,
.message-inbox-link:hover { border-color: var(--blue); color: var(--theme-accent-contrast, #fff); background: var(--blue); }
.message-search {
  height: 42px;
  margin: 4px 0 12px;
  border-color: var(--ui-line);
  background: #fff;
}
.message-search:focus-within { border-color: var(--blue); box-shadow: var(--ui-focus); }
.message-thread-list {
  max-height: min(58vh, 540px);
  padding: 2px;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.message-thread {
  min-height: 70px;
  padding: 11px 12px;
  border-color: transparent;
  border-bottom-color: var(--ui-line);
  border-radius: 4px;
}
.message-thread:last-child { border-bottom-color: transparent; }
.message-thread:hover { border-color: var(--ui-line); box-shadow: 0 4px 14px rgba(21, 33, 48, .06); }
.message-thread.unread {
  border-left-color: transparent;
  background: color-mix(in srgb, var(--theme-accent-soft, #f7f3e8) 36%, #fff);
}
.message-thread-avatar { border-radius: 6px; }
.message-thread mark { color: #fff; background: #d8324d; }
.message-empty { border-color: var(--ui-line-strong); border-radius: 5px; background: var(--ui-surface-muted); }

.chat-log { border-color: var(--ui-line); scrollbar-color: #bdc7d1 transparent; }
.chat-message p { border-color: var(--ui-line); box-shadow: 0 2px 7px rgba(21, 33, 48, .04); }
.chat-composer textarea { border-color: var(--ui-line-strong); }
.chat-composer button { min-height: 44px; }

.account-route-page,
.seller-route-page,
.store-route-page,
.product-page { background-color: #f5f7f9; }
.account-route-content,
.seller-route-content { padding-top: 24px; }
.account-route-page .member-center,
.seller-route-page .seller-center { box-shadow: var(--ui-shadow-soft); }
.account-route-page .member-main,
.seller-route-page .seller-main { min-width: 0; }
.account-route-context,
.seller-route-context { box-shadow: inset 0 -1px 0 rgba(20, 33, 48, .02); }

.member-summary,
.seller-metrics,
.inventory-summary { overflow: hidden; }
.member-summary > div,
.seller-metrics > div,
.inventory-summary > div { min-width: 0; }
.member-order-body { transition: background-color .18s ease; }
.member-order-body:hover { background: var(--ui-surface-muted); }
.order-tabs { scrollbar-width: none; }
.order-tabs::-webkit-scrollbar { display: none; }

.product-main-grid,
.product-detail-layout { gap: 20px; }
.product-buy-panel,
.product-detail-section,
.product-recommendations { padding: 22px; }
.product-buy-actions button { min-height: 44px; }
.product-variant { min-height: 56px; }
.product-variant.selected { color: var(--ink); background: var(--theme-accent-soft, #f7f3e8); }
.product-thumbs { scrollbar-width: thin; }

.store-route-tools,
.seller-page-head,
.member-head { min-width: 0; }
.store-route-product { overflow: hidden; }
.store-route-product-title { overflow-wrap: anywhere; }
.store-route-category button,
.store-route-sort-tabs button { min-height: 42px; }

.seller-route-page .seller-form input,
.seller-route-page .seller-form select,
.seller-route-page .seller-form textarea,
.seller-route-page .accounts-textarea { border-color: var(--ui-line-strong); }
.seller-route-page .wizard-actions button,
.seller-route-page .modal-actions button,
.seller-route-page .view-store { min-height: 42px; }
.seller-route-page .seller-product-list article,
.seller-route-page .seller-order-table > div,
.seller-route-page .account-table > div { border-color: var(--ui-line); }

.mobile-nav {
  box-shadow: 0 -4px 18px rgba(20, 30, 42, .08);
  isolation: isolate;
}
.mobile-nav a,
.mobile-nav button { position: relative; min-height: 56px; }
.mobile-nav a:active,
.mobile-nav button:active { background: var(--ui-surface-muted); }

@media (max-width: 900px) {
  .shell,
  .product-page-shell,
  .account-route-shell,
  .seller-route-shell,
  .store-route-shell { max-width: 100%; }
  .modal { max-height: calc(100dvh - 24px); }
  .product-main-grid,
  .product-detail-layout { gap: 15px; }
}

@media (max-width: 620px) {
  body.message-modal-open .mobile-nav {
    z-index: 130;
  }
  body.message-modal-open .modal-backdrop {
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding: 0;
    align-items: stretch;
    background: #fff;
    backdrop-filter: none;
  }
  .modal.message-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    padding: calc(18px + env(safe-area-inset-top)) 15px calc(18px + env(safe-area-inset-bottom));
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .message-modal #modalContent,
  .message-modal .message-inbox { height: 100%; min-height: 0; }
  .message-modal .message-inbox { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
  .message-modal .modal-close { top: calc(9px + env(safe-area-inset-top)); right: 10px; }
  .message-inbox-head { min-height: 62px; padding-right: 52px; }
  .message-inbox-actions { margin-top: 10px; }
  .message-search { margin-top: 10px; }
  .message-thread-list { min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; }
  .message-thread { min-height: 80px; padding: 9px 7px; grid-template-columns: 44px minmax(0, 1fr) 58px; gap: 9px; }
  .message-thread-meta { min-width: 58px; }
  .message-thread-copy small,
  .message-thread-copy em { max-width: 100%; }

  body.message-detail-open .modal-backdrop,
  body.presale-detail-open .modal-backdrop {
    bottom: calc(68px + env(safe-area-inset-bottom));
    padding: 0;
    align-items: stretch;
    background: #f3f6f8;
    backdrop-filter: none;
  }
  body.message-detail-open .mobile-nav,
  body.presale-detail-open .mobile-nav { z-index: 130; }
  .modal.message-detail-modal,
  .modal.presale-modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    padding: 0;
    margin: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .message-detail-modal .modal-close:not(.is-back),
  .presale-modal .modal-close:not(.is-back) {
    top: calc(12px + env(safe-area-inset-top));
    right: 10px;
    left: auto;
    width: 40px;
    height: 40px;
    font-size: 26px;
  }
  .message-detail-modal .modal-close.is-back,
  .presale-modal .modal-close.is-back {
    top: calc(12px + env(safe-area-inset-top));
    right: auto;
    left: 8px;
  }
  .product-breadcrumb .qikswap-back-button,
  .store-route-breadcrumb .qikswap-back-button,
  .presale-chat-head > .qikswap-back-button,
  .support-head > .qikswap-back-button { width: 40px; height: 40px; padding: 0; }
  .product-breadcrumb .qikswap-back-button > b,
  .store-route-breadcrumb .qikswap-back-button > b,
  .presale-chat-head > .qikswap-back-button > b,
  .support-head > .qikswap-back-button > b { display: none; }
  .message-detail-modal #modalContent,
  .message-detail-modal .support-shell { width: 100%; max-width: 100%; height: 100%; min-height: 0; overflow: hidden; }
  .message-detail-modal .support-shell {
    display: flex;
    padding-top: calc(10px + env(safe-area-inset-top));
    flex-direction: column;
    overflow: hidden;
    background: #fff;
  }

  .presale-modal #modalContent,
  .presale-modal .presale-chat { width: 100%; max-width: 100%; height: 100%; min-height: 0; overflow: hidden; }

  .modal:not(.message-modal):not(.message-detail-modal):not(.presale-modal) { padding: 21px 15px; }
  .section-top { gap: 14px; }
  .market-body { gap: 18px; }
  .listing:hover { transform: none; }
  .listing-body { padding: 11px 12px 12px; }
  .product-buy-panel,
  .product-detail-section,
  .product-recommendations { padding: 16px; }
  .product-buy-actions { grid-template-columns: minmax(0, 1fr) 82px; }
  .account-route-content,
  .seller-route-content { padding-top: 16px; }
  .account-route-page .member-main,
  .seller-route-page .seller-main { padding-right: 15px; padding-left: 15px; }
  button,
  a,
  input,
  select,
  textarea { touch-action: manipulation; }
}

@media (max-width: 820px) {
  .account-route-back.qikswap-back-button,
  .seller-route-back.qikswap-back-button { width: 42px; height: 42px; padding: 0; }
}

@media (max-width: 380px) {
  .message-thread { grid-template-columns: 40px minmax(0, 1fr) 52px; gap: 7px; }
  .message-thread-avatar { width: 40px; height: 40px; }
  .message-thread-meta { min-width: 52px; }
  .message-thread-product { width: 48px; height: 38px; }
  .message-thread-title i { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .message-thread time { font-size: 10px; }
  .product-buy-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Six fixed orb positions keep the challenge readable while each four-faced
   core rotates independently in either direction. */
.auth-modal { width: min(440px, 100%); }
.auth-captcha { display: grid; gap: 10px; }
.auth-captcha-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.auth-captcha-head > span { min-width: 0; }
.auth-captcha-head b,
.auth-captcha-head small { display: block; }
.auth-captcha-head b { color: var(--ink); font-size: 13px; }
.auth-captcha-head small { margin-top: 3px; color: #8793a0; font-size: 11px; line-height: 1.45; }
.auth-captcha-head button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  padding: 0;
  place-items: center;
  border: 1px solid var(--blue);
  border-radius: 5px;
  color: var(--blue);
  background: var(--theme-accent-soft, #f7f3e8);
}
.auth-captcha-head button .ui-icon { width: 18px; height: 18px; }
.auth-captcha-stage {
  position: relative;
  display: grid;
  min-height: 76px;
  padding: 15px 18px;
  grid-template-columns: repeat(6, 42px);
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid #6b5b32;
  border-radius: 6px;
  color: #f2ce72;
  background: #0d0e10;
  box-shadow: inset 0 0 0 1px rgba(209, 167, 65, .09), inset 0 -18px 34px rgba(0, 0, 0, .28);
  isolation: isolate;
  perspective: 520px;
  user-select: none;
}
.auth-captcha-stage::before {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: 12px;
  left: 12px;
  height: 1px;
  content: "";
  background: rgba(209, 167, 65, .11);
}
.captcha-orb {
  position: relative;
  display: block;
  width: 42px;
  height: 42px;
  border: 1px solid #d1a741;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 27%, #34312a 0 7%, #171719 34%, #09090a 73%);
  box-shadow: 0 0 0 2px rgba(209, 167, 65, .08), inset -7px -8px 11px rgba(0, 0, 0, .72), inset 5px 5px 9px rgba(255, 224, 143, .08);
  perspective: 150px;
}
.captcha-orb::after {
  position: absolute;
  top: 7px;
  left: 9px;
  width: 9px;
  height: 5px;
  border-top: 1px solid rgba(255, 231, 168, .48);
  border-radius: 50%;
  content: "";
  transform: rotate(-23deg);
}
.captcha-orb-spinner {
  position: absolute;
  inset: 5px;
  transform-style: preserve-3d;
  animation: captcha-orb-spin var(--spin-duration, 5s) linear var(--spin-delay, 0s) infinite;
  animation-direction: var(--spin-direction, normal);
}
.captcha-orb-face {
  position: absolute;
  display: grid;
  inset: 0;
  place-items: center;
  border: 1px solid rgba(209, 167, 65, .38);
  border-radius: 50%;
  backface-visibility: hidden;
  color: #f0c95f;
  background: radial-gradient(circle at 38% 32%, #28251f, #0d0d0e 72%);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .65);
  font: 800 17px/1 "Space Grotesk", sans-serif;
  font-style: normal;
  text-align: center;
  text-shadow: 0 0 8px rgba(209, 167, 65, .34);
}
.captcha-orb-face.face-front { transform: rotateY(0deg) translateZ(15px); }
.captcha-orb-face.face-right { transform: rotateY(90deg) translateZ(15px); }
.captcha-orb-face.face-back { transform: rotateY(180deg) translateZ(15px); }
.captcha-orb-face.face-left { transform: rotateY(270deg) translateZ(15px); }
.auth-captcha-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--ui-line-strong, #cfd8e1);
  border-radius: 5px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 16px !important;
  font-weight: 750;
  text-align: center;
  text-transform: uppercase;
}
.auth-captcha-input:focus { border-color: var(--blue); box-shadow: var(--ui-focus); }
.auth-captcha-loading { display: grid; min-height: 72px; place-items: center; color: #788697; font-size: 12px; }

@keyframes captcha-orb-spin { to { transform: rotateY(360deg); } }

.auth-form-message {
  padding: 10px 12px;
  border: 1px solid #e6b9b9;
  border-radius: 4px;
  color: #9d2f2f;
  background: #fff4f4;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}
.auth-form-message.success {
  border-color: color-mix(in srgb, var(--blue) 42%, #dce3eb);
  color: var(--theme-accent-dark, #765816);
  background: var(--theme-accent-soft, #f7f1e3);
}

@media (max-width: 620px) {
  .auth-captcha-stage { min-height: 70px; padding: 13px 10px; grid-template-columns: repeat(6, 38px); gap: 6px; }
  .captcha-orb { width: 38px; height: 38px; }
  .captcha-orb-spinner { inset: 5px; }
  .captcha-orb-face { font-size: 16px; }
  .captcha-orb-face.face-front { transform: rotateY(0deg) translateZ(13px); }
  .captcha-orb-face.face-right { transform: rotateY(90deg) translateZ(13px); }
  .captcha-orb-face.face-back { transform: rotateY(180deg) translateZ(13px); }
  .captcha-orb-face.face-left { transform: rotateY(270deg) translateZ(13px); }
}

/* Agreement step four stays compact while the legal text remains scrollable. */
.agreement-panel > div { max-height: 208px; margin-top: 12px; padding: 13px; }
.agreement-check { margin-top: 12px; }

@media (max-width: 620px) {
  :root { --mobile-nav-height: 68px; --mobile-nav-safe-bottom: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom)) !important; }
  .mobile-nav {
    position: fixed !important;
    z-index: 200;
    inset: auto 0 0 !important;
    height: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom));
    min-height: calc(var(--mobile-nav-height) + var(--mobile-nav-safe-bottom));
    padding: 0 env(safe-area-inset-right, 0px) var(--mobile-nav-safe-bottom) env(safe-area-inset-left, 0px);
    box-sizing: border-box;
  }
  .mobile-nav a,
  .mobile-nav button {
    height: var(--mobile-nav-height);
    min-height: var(--mobile-nav-height);
    padding: 6px 2px 4px;
    justify-content: center;
    box-sizing: border-box;
  }
  .mobile-nav .nav-icon-shell { flex: 0 0 25px; }
}
