:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  background: #10171b;
  color: #eef5f4;
  --surface: #172126;
  --surface-raised: #1d2c31;
  --surface-strong: #24383e;
  --line: #3e555b;
  --line-strong: #668087;
  --cyan: #57d8ef;
  --cyan-soft: #9eeaf4;
  --gold: #e6b85c;
  --green: #67cc91;
  --red: #e47d78;
  --muted: #a8b8bb;
  --brand-bar-height: 126px;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  scrollbar-width: none;
}

* { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

body {
  background-color: #10171b;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 24px 24px;
}

button { font: inherit; letter-spacing: 0; }

button {
  color: #e6f3f2;
  background: #223238;
  border: 1px solid #526970;
  border-radius: 4px;
  cursor: pointer;
}

button:hover:not(:disabled) { border-color: var(--cyan); color: #fff; }
button:focus-visible { outline: 2px solid var(--cyan-soft); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: 0.48; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(16, 23, 27, 0.94);
  border: 1px solid #31434a;
  overflow: hidden;
}

.app-shell > * { min-width: 0; }

.brand-bar {
  height: var(--brand-bar-height);
  min-height: var(--brand-bar-height);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: minmax(42px, 1fr) 40px;
  align-items: center;
  column-gap: 16px;
  row-gap: 8px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(22, 32, 37, 0.98);
}

.brand {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand > div { min-width: 0; overflow: hidden; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  background: #2d3432;
  color: var(--gold);
  font: 600 1.35rem/1 "Segoe UI", sans-serif;
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 600; color: #fff; }
.brand h1, .brand p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 0.72rem; }
.brand p.identity-ready { color: var(--green); }

.welfare-nav {
  height: 38px;
  padding: 0 16px;
  white-space: nowrap;
  color: #f4d27a;
  border-color: #b9862d;
  background: #3a3020;
  animation: welfare-nav-flash 1.7s ease-in-out infinite;
}
.welfare-nav.active {
  color: #fff5cf;
  border-color: #ffe39a;
  background: #6d5121;
}

.feature-nav {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.mini-program-promo {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-program-promo strong {
  margin-left: 3px;
  color: #f2f7f6;
  font-weight: 600;
}

.primary-nav {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: center;
  width: min(100%, 650px);
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.primary-nav button { height: 38px; padding: 0 12px; white-space: nowrap; }
.primary-nav button.active {
  background: #155f70;
  border-color: var(--cyan);
  color: #fff;
}
@keyframes welfare-nav-flash {
  0%, 100% { box-shadow: 0 0 0 rgba(230, 184, 92, 0); }
  50% { box-shadow: 0 0 14px rgba(230, 184, 92, 0.72); }
}

.page-section { min-height: 0; }
.page-section[hidden] { display: none; }

.page-section[data-page="exchange"] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - var(--brand-bar-height));
}
.page-section[data-page="welfare"] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: calc(100vh - var(--brand-bar-height));
}
.page-section[data-page="vip"] {
  position: relative;
  display: block;
  height: calc(100vh - var(--brand-bar-height));
  padding: 18px;
  overflow: hidden;
}
.page-section[data-page="storage"] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - var(--brand-bar-height));
  padding: 18px;
}
.page-section[data-page="exchange"][hidden],
.page-section[data-page="welfare"][hidden],
.page-section[data-page="vip"][hidden],
.page-section[data-page="storage"][hidden] { display: none; }

.secondary-nav,
.ranking-tabs,
.ranking-toolbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(25, 37, 42, 0.96);
}
.secondary-nav button,
.ranking-tabs button { min-width: 104px; height: 32px; padding: 0 14px; }
.secondary-nav button.active,
.ranking-tabs button.active,
.segmented button.active {
  background: #176579;
  border-color: var(--cyan);
  color: #fff;
}
.exchange-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  align-content: start;
  gap: 14px;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.exchange-card {
  min-height: 188px;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #42575c;
  border-radius: 6px;
  background: var(--surface);
}
.exchange-card:hover { border-color: #708a8f; background: #19262b; }

.offer-media {
  min-height: 188px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-right: 1px solid #3a4c51;
  background: #111b1f;
}
.offer-media img { width: 100%; height: 100%; object-fit: contain; padding: 14px; }
.offer-image-fallback {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border: 1px solid #59737a;
  background: #243238;
  color: var(--gold);
  font-size: 2rem;
}

.offer-content {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(34px, 1fr) auto auto auto;
  gap: 7px;
  padding: 13px 14px;
}
.offer-heading { min-width: 0; display: flex; align-items: center; gap: 8px; }
.offer-heading h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 0.98rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reward-badge {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--gold);
  border-radius: 3px;
  color: var(--gold);
  font-size: 0.66rem;
}
.reward-badge.pal { border-color: var(--green); color: var(--green); }
.reward-badge.exp { border-color: var(--cyan); color: var(--cyan); }
.offer-description {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}
.offer-reward, .offer-cost { margin: 0; font-size: 0.78rem; }
.offer-reward { color: var(--cyan-soft); }
.offer-cost { color: var(--gold); }
.redeem-button { width: 100%; height: 32px; background: #1e6d58; border-color: var(--green); }
.welfare-claim-button.ready:not(:disabled) {
  color: #201b0e;
  background: #e6b85c;
  border-color: #ffe39a;
  box-shadow: 0 0 12px rgba(230, 184, 92, 0.4);
}
.welfare-card .offer-content {
  grid-template-rows: auto minmax(30px, 1fr) auto auto auto auto;
}
.welfare-requirement { color: var(--gold); }
.welfare-card-progress {
  height: 5px;
  overflow: hidden;
  border: 1px solid #475b5f;
  background: #111b1f;
}
.welfare-card-progress span {
  display: block;
  height: 100%;
  background: var(--gold);
  transition: width 180ms ease;
}

.vip-placeholder { display: none !important; }
.vip-summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.vip-summary strong { color: var(--gold); letter-spacing: 0; }
.vip-summary span { color: var(--cyan-soft); }
.vip-tier-section {
  position: absolute;
  inset: 90px 18px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}
.vip-tier-section .exchange-grid {
  min-height: 100%;
  padding: 8px 18px 18px;
  overflow: visible;
}
.vip-tier-title {
  margin: 0 0 10px;
  color: var(--cyan-soft);
  font-size: 1rem;
  font-weight: 700;
}
.vip-tier-empty { min-height: 120px; }
.personal-settings-nav { margin-left: 4px; }
.personal-settings-page { padding: 28px 0; }
.personal-settings-summary { margin: 0; }
.dungeon-escape-button { margin-left: auto; min-height: 34px; padding: 0 14px; border: 1px solid var(--gold); background: transparent; color: var(--gold); cursor: pointer; }
.dungeon-escape-button:hover:not(:disabled) { background: rgba(223, 184, 89, 0.12); }
.dungeon-escape-button:disabled { opacity: 0.55; cursor: not-allowed; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-dialog .secondary-button { border: 1px solid var(--line-strong); background: transparent; color: #c7d3d4; }
.reward-badge.vip { border-color: var(--gold); color: var(--gold); }
.storage-summary { margin-bottom: 14px; }
.storage-summary strong { color: var(--cyan-soft); }
.storage-card { grid-template-columns: minmax(0, 1fr); }
.storage-card .offer-content {
  min-height: 188px;
  grid-template-rows: auto minmax(30px, 1fr) auto auto auto auto;
}
.storage-source { color: var(--cyan-soft); }
.storage-created { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ranking-page {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: calc(100vh - var(--brand-bar-height));
}
.ranking-page.pvp-mode { grid-template-rows: auto minmax(0, 1fr); }
.ranking-toolbar {
  min-height: 40px;
  padding: 4px 12px;
  background: rgba(29, 44, 49, 0.9);
  border-bottom: 1px solid rgba(102, 128, 135, 0.45);
}
.segmented {
  width: min(100%, 550px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.segmented button { height: 30px; padding: 0 10px; border-radius: 0; font-size: 0.88rem; }
.segmented button + button { border-left: 0; }
.ranking-tabs[hidden] { display: none; }
.ranking-tabs {
  min-height: 40px;
  flex-wrap: nowrap;
  gap: 5px;
  padding: 4px 12px;
  background: rgba(25, 37, 42, 0.9);
}
.ranking-tabs button { min-width: 94px; height: 28px; padding: 0 10px; font-size: 0.88rem; }

.table-region {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px 18px;
  scrollbar-color: #536f76 #182328;
  scrollbar-width: thin;
}
table {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(102, 128, 135, 0.42);
  border-collapse: collapse;
  table-layout: fixed;
  background: rgba(23, 33, 38, 0.72);
}
th, td {
  height: 39px;
  padding: 7px 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40px;
  background: #25363b;
  border-bottom: 1px solid var(--line-strong);
  color: #c4d2d4;
  font-size: 0.78rem;
  font-weight: 500;
}
td { border-bottom: 1px solid rgba(96, 123, 129, 0.24); font-size: 0.84rem; }
tbody tr:nth-child(even) { background: rgba(57, 75, 79, 0.22); }
tbody tr:hover { background: rgba(52, 99, 108, 0.38); }
.rank-column { width: 72px; }
td:nth-child(2) { color: #fff; }
tr.rank-1 td:first-child { color: #f0ca68; }
tr.rank-2 td:first-child { color: #d5e0e1; }
tr.rank-3 td:first-child { color: #d59668; }
td.highlight { color: var(--cyan-soft); background: rgba(58, 139, 151, 0.14); }
.pvp-gold-value,
td.pvp-gold-value {
  color: #f7d77a;
  background-color: rgba(151, 106, 21, 0.2);
  background-image: repeating-linear-gradient(135deg,
    rgba(255, 242, 181, 0.12) 0 2px, transparent 2px 8px);
}

.section-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  font-size: 0.88rem;
}
.table-region > .section-empty { position: absolute; inset: 40px 0 0; min-height: 0; }
.section-empty[hidden] { display: none; }

/* The card list and ranking table are the intentional scroll surfaces. */
.exchange-grid::-webkit-scrollbar,
.table-region::-webkit-scrollbar {
  width: 7px;
  height: 7px;
  display: block;
}
.exchange-grid::-webkit-scrollbar-track,
.table-region::-webkit-scrollbar-track { background: #182328; }
.exchange-grid::-webkit-scrollbar-thumb,
.table-region::-webkit-scrollbar-thumb {
  min-height: 28px;
  border: 1px solid #182328;
  border-radius: 4px;
  background: #536f76;
}
.exchange-grid::-webkit-scrollbar-thumb:hover,
.table-region::-webkit-scrollbar-thumb:hover { background: #78939a; }

.unavailable {
  min-height: calc(100vh - var(--brand-bar-height));
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}
.unavailable-symbol {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 1px solid #52656a;
  color: var(--gold);
  font-size: 1.45rem;
}
.unavailable h2 { margin: 8px 0 0; color: #e4ecec; font-size: 1.05rem; font-weight: 500; }
.unavailable p { margin: 0; color: var(--muted); font-size: 0.84rem; }

.result-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0 22px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #192429;
  color: #edf6f5;
}
.result-dialog::backdrop { background: rgba(3, 8, 10, 0.74); }
.dialog-accent { height: 4px; margin: 0 -22px 18px; background: var(--red); }
.result-dialog.success .dialog-accent { background: var(--green); }
.result-dialog h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.result-dialog p { min-height: 44px; margin: 12px 0 18px; color: #c7d3d4; line-height: 1.6; }
.result-dialog button { width: 100%; height: 34px; }

@media (max-width: 720px) {
  .brand-bar { padding: 10px 12px; column-gap: 10px; }
  .mini-program-promo { font-size: 0.68rem; }
  .welfare-nav { padding-left: 12px; padding-right: 12px; }
  .dungeon-escape-button { margin-left: 0; width: 100%; }
  .primary-nav {
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 0 1px 3px;
    scrollbar-width: thin;
  }
  .primary-nav button { flex: 0 0 104px; min-width: 104px; }
  .secondary-nav, .ranking-tabs { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .ranking-toolbar { justify-content: flex-start; overflow-x: auto; padding: 12px 12px 10px; }
  .segmented { grid-template-columns: repeat(5, 82px); }
  .ranking-tabs { min-height: 54px; padding: 10px 12px 12px; }
  .ranking-tabs button { min-width: 112px; }
  .table-region { padding: 12px 10px 18px; }
  table { min-width: 760px; }
  .ranking-page.pvp-mode table { min-width: 0; }
  .exchange-grid { grid-template-columns: 1fr; padding: 10px; }
  .exchange-card { grid-template-columns: 104px minmax(0, 1fr); }
  .exchange-card.storage-card { grid-template-columns: minmax(0, 1fr); }
  .offer-media { min-height: 176px; }
  th, td { height: 44px; padding-left: 10px; padding-right: 10px; }
  th:nth-child(6), td:nth-child(6) { display: none; }
}

@media (max-width: 560px) {
  :root { --brand-bar-height: 158px; }
  .brand-bar {
    grid-template-rows: minmax(42px, 1fr) 40px 22px;
    row-gap: 6px;
  }
  .mini-program-promo {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: center;
    font-size: 0.72rem;
    text-align: center;
  }
}

@media (max-width: 430px) {
  .brand-mark { width: 36px; height: 36px; }
  .brand h1 { font-size: 1rem; }
  .exchange-card { grid-template-columns: 88px minmax(0, 1fr); }
  .offer-content { padding-left: 10px; padding-right: 10px; }
}
