:root {
  --bg: #0d0f1a; --bg2: #151829; --card: #1b1f36; --card2: #232848;
  --pri: #8b5cf6; --pri2: #6d28d9; --acc: #f472b6; --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
  --txt: #e5e7f5; --txt2: #9aa0c3; --line: #2b3054;
  --maxw: 960px;            /* 桌面端内容宽度，按断点递增 */
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--txt); font: 15px/1.6 "PingFang SC","Microsoft YaHei",sans-serif; -webkit-tap-highlight-color: transparent; }
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(620px 420px at 12% -5%, rgba(139,92,246,.14), transparent 60%),
              radial-gradient(520px 380px at 88% 105%, rgba(244,114,182,.09), transparent 60%); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--card2); }
a { color: var(--pri); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; }
input, select, textarea { font: inherit; background: var(--bg2); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--pri); }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 14px calc(92px + env(safe-area-inset-bottom)); }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(13,15,26,.92); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.logo { font-size: 20px; font-weight: 800; background: linear-gradient(90deg,var(--pri),var(--acc)); -webkit-background-clip: text; background-clip: text; color: transparent; flex-shrink: 0; }
.topbar-in .spacer { flex: 1; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 5px 14px; font-size: 13px; color: var(--txt2); white-space: nowrap; flex-shrink: 0; }
.chip b { color: var(--warn); }
.chip[onclick]:hover { border-color: var(--pri); color: var(--txt); background: var(--card2); }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; padding: 9px 16px; font-weight: 600; background: var(--card2); color: var(--txt); transition: .15s; }
.btn:hover { filter: brightness(1.15); }
.btn.pri { background: linear-gradient(90deg,var(--pri2),var(--pri)); color: #fff; }
.btn.acc { background: linear-gradient(90deg,#be185d,var(--acc)); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:active { transform: scale(.97); }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; display: none; }
.btn.loading .spin { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* 底部标签栏 */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: rgba(21,24,41,.97); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; color: var(--txt2); padding: 12px 0 14px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: .12s; }
.tabbar button:active { transform: scale(.94); }
.tabbar button.on { color: var(--pri); }
.tabbar .ico { font-size: 20px; line-height: 1; }

/* 卡片与列表 */
.section { padding: 16px 0 4px; }
.section h2 { font-size: 17px; margin-bottom: 10px; }
.hero { margin-top: 14px; border-radius: 16px; padding: 22px; background: linear-gradient(120deg,var(--pri2),#312e81 60%,#0f172a); }
.hero h1 { font-size: 22px; }
.hero p { color: #c7d2fe; font-size: 13px; margin-top: 4px; }
.gamebar { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; }
.gamebar::-webkit-scrollbar { display: none; }
.gchip { flex-shrink: 0; background: var(--card); border: 1px solid var(--line); color: var(--txt2); border-radius: 99px; padding: 6px 14px; font-size: 13px; }
.gchip.on { background: var(--pri); border-color: var(--pri); color: #fff; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 12px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; gap: 12px; cursor: pointer; transition: .15s; animation: rise .4s ease both; }
.pcard:hover { transform: translateY(-2px); border-color: var(--pri); }
.pcard:active { transform: scale(.985); }
.gchip:active, .txrow:active, .listrow:active, .hcard:active { opacity: .75; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pcard, .hcard { animation: none; } }
.pcard img { width: 54px; height: 54px; border-radius: 50%; flex-shrink: 0; }
.favstar { align-self: flex-start; font-size: 20px; color: var(--txt2); cursor: pointer; padding: 2px 4px; user-select: none; transition: .15s; }
.favstar.on { color: var(--warn); }
.favstar:hover { transform: scale(1.25); }

/* 在线聊天 */
.chatbox { max-height: min(300px, 42vh); min-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; -webkit-overflow-scrolling: touch; }
.cmsg { display: flex; }
.cmsg .bub { max-width: 78%; background: var(--card2); border-radius: 4px 12px 12px 12px; padding: 7px 10px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.cmsg.me { justify-content: flex-end; }
.cmsg.me .bub { background: var(--pri); color: #fff; border-radius: 12px 4px 12px 12px; }
.ctime { font-size: 10px; opacity: .55; margin-top: 2px; }
.reddot { display: inline-block; min-width: 16px; height: 16px; border-radius: 8px; background: #e5484d; color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 3px; margin-right: 6px; vertical-align: 1px; }
.pcard .name { font-weight: 700; }
.pcard .meta { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.tagrow { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag { font-size: 11px; background: var(--card2); color: var(--acc); border-radius: 6px; padding: 2px 8px; }
.price { color: var(--warn); font-weight: 700; font-size: 13px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 4px; vertical-align: 1px; }
.dot.off { background: var(--txt2); }
.stars { color: var(--warn); font-size: 13px; }

/* 大厅 */
.hcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; animation: rise .4s ease both; }
.hcard .info { flex: 1; min-width: 180px; }
.hcard .budget { font-size: 18px; font-weight: 800; color: var(--warn); }
.empty { text-align: center; color: var(--txt2); padding: 40px 0; }

/* 订单 */
.ocard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.ocard .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ocard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.badge { font-size: 12px; border-radius: 6px; padding: 2px 9px; font-weight: 600; }
.badge.pending { background: #3b2f0b; color: var(--warn); }
.badge.ongoing { background: #14263b; color: #60a5fa; }
.badge.player_done { background: #14263b; color: #60a5fa; }
.badge.completed { background: #0d3321; color: var(--ok); }
.badge.cancelled { background: #36141a; color: var(--bad); }
.badge.active { background: #0d3321; color: var(--ok); }
.badge.banned { background: #36141a; color: var(--bad); }

/* 钱包/流水 */
.balcard { background: linear-gradient(120deg,var(--pri2),#4c1d95); border-radius: 16px; padding: 18px; margin: 14px 0; }
.balcard .num { font-size: 30px; font-weight: 800; }
.txrow { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.txrow .amt.plus { color: var(--ok); } .txrow .amt.minus { color: var(--bad); }
.txrow .sub { font-size: 12px; color: var(--txt2); }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 90; display: none; align-items: flex-end; justify-content: center; }
.mask.on { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); animation: up .25s ease; }
@media (min-width: 640px) { .mask { align-items: center; } .modal { border-radius: 18px; } }
@media (max-width: 639px) { input, select, textarea { font-size: 16px; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.modal .x { background: none; color: var(--txt2); font-size: 22px; line-height: 1; }
.fld { margin-bottom: 12px; }
.fld label { display: block; font-size: 13px; color: var(--txt2); margin-bottom: 5px; }
.frow { display: flex; gap: 10px; }
.frow > * { flex: 1; }
.tabs2 { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs2 button { flex: 1; padding: 8px; border-radius: 10px; background: var(--card); color: var(--txt2); }
.tabs2 button.on { background: var(--pri); color: #fff; }
.review { border-bottom: 1px dashed var(--line); padding: 8px 0; font-size: 13px; }
.review .sub { color: var(--txt2); font-size: 12px; }

/* Toast */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast-item { background: var(--card2); border: 1px solid var(--line); border-left: 4px solid var(--pri); border-radius: 10px; padding: 10px 18px; font-size: 14px; animation: up .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast-item.err { border-left-color: var(--bad); }
.toast-item.ok { border-left-color: var(--ok); }

/* 开关 */
.switch { position: relative; width: 46px; height: 26px; background: var(--card2); border-radius: 99px; transition: .2s; border: 1px solid var(--line); flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--txt2); transition: .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { left: 22px; background: #fff; }
.listrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 2px; border-bottom: 1px solid var(--line); }

/* ---------- 我的页面 ---------- */
#view-me { max-width: 720px; margin: 0 auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; }
.me-account { padding: 14px; }
.balcard .balhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #c7d2fe; }
.balcard .balhead .tag { font-size: 11px; background: rgba(255,255,255,.14); border-radius: 99px; padding: 2px 9px; }
.balcard { border: 1px solid rgba(139,92,246,.45); box-shadow: 0 12px 28px rgba(76,29,149,.35), inset 0 1px 0 rgba(255,255,255,.12);
  background: radial-gradient(120% 130% at 100% 0%, rgba(244,114,182,.28), transparent 55%), linear-gradient(120deg,var(--pri2),#4c1d95); }
.balcard .num { display: flex; align-items: baseline; gap: 4px; margin: 6px 0 2px; }
.balcard .num .cur { font-size: 18px; font-weight: 700; opacity: .85; }
.balacts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.balacts .btn { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.balacts .btn:hover { background: rgba(255,255,255,.26); filter: none; }
.me-idrow { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.me-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-weight: 800; color: #fff; background: linear-gradient(135deg,var(--pri),var(--acc)); box-shadow: 0 4px 12px rgba(139,92,246,.4); }
.me-name { font-weight: 700; font-size: 15px; }
.me-role { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.me-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 13px; color: var(--txt2); border-bottom: 1px dashed var(--line); }
.me-line span:last-child { color: var(--txt); text-align: right; word-break: break-all; }
.me-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.me-actions .btn { flex: 1; min-width: 100px; }
.empty { padding: 28px 12px; font-size: 13px; }
.panel .listrow:last-child { border-bottom: none; }
.panel .ocard { background: transparent; border: none; border-radius: 0; border-bottom: 1px solid var(--line); padding: 12px 2px; margin-bottom: 0; }
.panel .ocard:last-child { border-bottom: none; }
.tabbar button:hover { color: var(--txt); }
.tabbar button.on .ico { filter: drop-shadow(0 0 8px rgba(139,92,246,.65)); }
@media (min-width: 640px) {
  .balcard { padding: 22px; }
  .balcard .num { font-size: 36px; }
}

/* ---------- 桌面端适配 ---------- */
/* 平板及以上：筛选标签换行，任何宽度都不再被裁切 */
@media (min-width: 640px) {
  .gamebar { flex-wrap: wrap; overflow: visible; gap: 10px; }
  #pgrid .empty { grid-column: 1 / -1; }
}

/* 宽屏：底部整行移动底栏改为居中悬浮胶囊导航 */
@media (min-width: 768px) {
  .wrap { padding-bottom: 112px; }
  .tabbar {
    left: 50%; right: auto; transform: translateX(-50%);
    bottom: 18px; width: auto; min-width: 460px;
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    border: 1px solid var(--line); border-radius: 14px;
    background: rgba(21,24,41,.92);
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
  .tabbar button { flex: 1; flex-direction: row; gap: 7px; padding: 9px 24px; font-size: 14px; border-radius: 10px; }
  .tabbar button:hover { color: var(--txt); background: rgba(139,92,246,.10); }
  .tabbar button.on { color: #fff; background: rgba(139,92,246,.22); }
  .tabbar button.on:hover { background: rgba(139,92,246,.28); }
  .tabbar button:active { transform: none; }
  .tabbar .ico { font-size: 17px; }
  .gchip { cursor: pointer; }
  .gchip:hover { border-color: var(--pri); color: var(--txt); }
  .pgrid { gap: 14px; }
}

/* 桌面端：放宽留白、统一「我的」页宽度并双栏排布 */
@media (min-width: 1024px) {
  .wrap { padding-left: 24px; padding-right: 24px; }
  .topbar-in { padding: 14px 24px; }
  .hero { padding: 26px 28px; }
  .section { padding-top: 20px; }

  #view-me { max-width: 100%; margin: 0; }
  #meBody {
    display: grid;
    grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
    column-gap: 22px;
    align-items: start;
  }
  #meBody > .balcard { grid-column: 1; grid-row: 1; margin: 8px 0 0; }
  #meBody > #playerZone { grid-column: 1; grid-row: 2; }
  #meBody > .me-acc { grid-column: 1; grid-row: 3; }
  #meBody > .me-fav { grid-column: 2; grid-row: 1; padding-top: 8px; }
  #meBody > .me-orders { grid-column: 2; grid-row: 2 / span 2; }

  .modal { max-width: 620px; }
}
@media (min-width: 1280px) {
  :root { --maxw: 1120px; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
@media (min-width: 1600px) {
  :root { --maxw: 1280px; }
  body { font-size: 16px; }
  .hero h1 { font-size: 26px; }
  .section h2 { font-size: 18px; }
  #meBody { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); column-gap: 26px; }
}
@media (min-width: 2200px) { :root { --maxw: 1440px; } }

button:focus-visible, .gchip:focus-visible, .chip:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
