/* 泡泡星球 Online —— 深夜星空主题 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: hsl(222 47% 7%);
  --panel: hsl(222 42% 10% / .92);
  --card: hsl(222 42% 10%);
  --border: hsl(222 25% 18%);
  --text: hsl(210 30% 93%);
  --muted: hsl(216 18% 62%);
  --primary: hsl(187 82% 55%);
  --primary-fg: hsl(222 47% 8%);
  --secondary: hsl(222 30% 16%);
  --pink: #ff7ad9;
  --cyan: #4fd8e8;
  --yellow: #ffd94f;
  --mint: #5ad19a;
  --red: #ff5a6a;
  --r-R: #9db4c0; --r-S: #5ad19a; --r-SR: #4fa8ff; --r-SSR: #c07cff; --r-UR: #ffb340;
  --radius: 14px;
}
html { color-scheme: dark; }
body {
  font-family: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1px 1px at 34% 8%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 58% 22%, rgba(159,216,255,.5), transparent 60%),
    radial-gradient(1px 1px at 76% 12%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1px 1px at 88% 30%, rgba(255,214,245,.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 45% 40%, rgba(255,255,255,.25), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
input, select { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.rarity-R { color: var(--r-R); } .rarity-S { color: var(--r-S); } .rarity-SR { color: var(--r-SR); }
.rarity-SSR { color: var(--r-SSR); } .rarity-UR { color: var(--r-UR); }
.b-rarity-R { border-color: #9db4c055 !important; } .b-rarity-S { border-color: #5ad19a66 !important; }
.b-rarity-SR { border-color: #4fa8ff66 !important; } .b-rarity-SSR { border-color: #c07cff66 !important; }
.b-rarity-UR { border-color: #ffb34088 !important; }
.text-yellow { color: var(--yellow); } .text-cyan { color: var(--cyan); } .text-pink { color: var(--pink); }
.text-mint { color: var(--mint); } .text-red { color: var(--red); } .muted { color: var(--muted); }
.bold { font-weight: 800; } .num { font-variant-numeric: tabular-nums; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100dvh; }
.sidenav {
  width: 200px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--panel); backdrop-filter: blur(8px);
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 12px 8px;
}
.sidenav .brand { font-size: 18px; font-weight: 800; padding: 8px 10px 4px; }
.sidenav .brand span { color: var(--cyan); }
.sidenav .brand-sub { font-size: 11px; color: var(--muted); padding: 0 10px 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; border-radius: 12px; font-size: 14px; font-weight: 600;
  color: var(--muted); transition: background .15s, color .15s; text-align: left;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--secondary); color: var(--text); }
.nav-item.active { background: hsl(187 82% 55% / .15); color: var(--primary); }
.sidenav .spacer { flex: 1; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--panel); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); padding: 8px 14px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.topbar .lvl-badge {
  width: 36px; height: 36px; border-radius: 50%; background: hsl(187 82% 55% / .2);
  border: 1px solid hsl(187 82% 55% / .5); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.expbar { width: 90px; height: 6px; border-radius: 4px; background: var(--secondary); overflow: hidden; }
.expbar i { display: block; height: 100%; background: var(--yellow); transition: width .3s; }
.stat-pill { display: flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 700; }
.stat-pill svg { width: 16px; height: 16px; }
.content { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 14px 90px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
.page-title { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.page-title .sub { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 48px; border-radius: 12px; background: var(--primary); color: var(--primary-fg);
  font-weight: 800; transition: opacity .15s;
}
.btn-primary:hover:not(:disabled) { opacity: .9; }
.btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--secondary); font-weight: 700; transition: background .15s;
}
.btn-ghost:hover:not(:disabled) { background: hsl(222 30% 22%); }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ===== 泡泡 ===== */
.bubble-stage {
  position: relative; width: 100%; height: 62dvh; min-height: 380px;
  border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: var(--card);
}
.bubble {
  position: absolute; border-radius: 50%; transition: transform .1s;
  animation: bubble-float 3.2s ease-in-out infinite; touch-action: manipulation;
}
.bubble:active { transform: scale(.88) !important; }
@keyframes bubble-float {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -12px; }
}
.pop-ring {
  position: absolute; border-radius: 50%; pointer-events: none;
  animation: pop-burst .35s ease-out forwards;
}
@keyframes pop-burst {
  from { scale: .4; opacity: 1; }
  to { scale: 1.6; opacity: 0; }
}
.float-text {
  position: absolute; pointer-events: none; font-weight: 800; font-size: 18px;
  animation: float-up 1s ease-out forwards;
}
@keyframes float-up {
  0% { translate: 0 0; opacity: 0; }
  15% { opacity: 1; }
  100% { translate: 0 -56px; opacity: 0; }
}

/* ===== 战斗 ===== */
.battle-field {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 20px 16px 12px; min-height: 230px; position: relative;
}
.fighter { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 130px; flex-shrink: 0; }
.fighter .hpbar { width: 100%; height: 10px; border-radius: 6px; background: var(--secondary); overflow: hidden; }
.fighter .hpbar i { display: block; height: 100%; transition: width .5s; }
.fighter svg.avatar { width: 96px; height: 96px; }
.vs { font-weight: 800; font-size: 18px; color: var(--muted); padding-bottom: 60px; user-select: none; }
.lunge-r { animation: lunge-r .35s ease-out; } .lunge-l { animation: lunge-l .35s ease-out; }
@keyframes lunge-r { 0%,100% { translate: 0 0; } 40% { translate: 28px 0; } }
@keyframes lunge-l { 0%,100% { translate: 0 0; } 40% { translate: -28px 0; } }
.shake { animation: shake .25s ease-out; }
@keyframes shake { 0%,100% { translate: 0 0; } 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.dmg-float { position: absolute; font-weight: 800; white-space: nowrap; animation: float-up 1s ease-out forwards; pointer-events: none; }
.battle-log { height: 72px; overflow-y: auto; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.battle-log .cur { color: var(--text); }

/* ===== 装备 ===== */
.slot {
  border: 1px dashed var(--border); border-radius: 12px; min-height: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10px; color: var(--muted); padding: 6px; transition: background .15s;
}
.slot.filled { border-style: solid; background: hsl(222 30% 16% / .5); color: var(--text); cursor: pointer; }
.slot.filled:hover { background: var(--secondary); }
.slot svg, .equip-cell svg { width: 32px; height: 32px; }
.equip-cell {
  border: 1px solid var(--border); border-radius: 12px; min-height: 76px; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; background: hsl(222 30% 16% / .5); transition: background .15s;
}
.equip-cell:hover { background: var(--secondary); }
.glow { animation: glow-pulse 2s ease-in-out infinite; }
@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px currentColor); }
  50% { filter: drop-shadow(0 0 12px currentColor); }
}

/* ===== 弹窗 / Toast ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 380px; background: hsl(222 45% 9%); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px; max-height: 85dvh; overflow-y: auto;
}
.modal h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.modal h3 svg { width: 44px; height: 44px; }
.modal-close { position: absolute; }
#toasts { position: fixed; top: 14px; left: 50%; translate: -50% 0; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 380px); }
.toast {
  background: hsl(222 45% 11%); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  animation: toast-in .25s ease-out; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: #5ad19a66; } .toast.err { border-color: #ff5a6a66; }
.toast svg { width: 26px; height: 26px; flex-shrink: 0; }
@keyframes toast-in { from { translate: 0 -12px; opacity: 0; } to { translate: 0 0; opacity: 1; } }

/* ===== 排行榜 ===== */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-no { width: 30px; text-align: center; font-weight: 800; }

/* ===== 移动端 ===== */
.bottomnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--panel); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: repeat(7, 1fr);
}
.bottomnav button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 54px; justify-content: center; font-size: 10px; font-weight: 600; color: var(--muted);
}
.bottomnav button svg { width: 20px; height: 20px; }
.bottomnav button.active { color: var(--primary); }

@media (max-width: 860px) {
  .sidenav { display: none; }
  .bottomnav { display: grid; }
  .grid4 { grid-template-columns: repeat(4, 1fr); }
  .fighter { width: 110px; }
  .fighter svg.avatar { width: 84px; height: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .bubble, .pop-ring, .float-text, .lunge-r, .lunge-l, .shake, .glow, .toast { animation: none !important; }
}

/* SVG 尺寸兜底：按钮图标与角色头像 */
.btn-primary svg, .btn-ghost svg { width: 18px; height: 18px; flex-shrink: 0; }
svg.avatar { width: 100%; height: auto; display: block; }

/* ===== 弹幕层 ===== */
.dm-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; }
.dm-item {
  position: absolute; right: -10px; white-space: nowrap; font-size: 13px; font-weight: 600;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); padding: 2px 10px;
  background: hsla(222 30% 10%/.35); border-radius: 99px;
  animation: dmFly 9s linear forwards;
}
@keyframes dmFly { from { transform: translateX(0); } to { transform: translateX(calc(-100vw - 100%)); } }

/* ===== 世界聊天面板 ===== */
.chat-panel {
  position: fixed; right: 16px; bottom: 76px; z-index: 45;
  width: min(340px, calc(100vw - 24px)); height: min(440px, 62vh);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chat-body { flex: 1; overflow-y: auto; padding: 10px 12px; }
.chat-foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-foot input { flex: 1; margin: 0; min-height: 40px; }
.chat-msg { margin-bottom: 10px; }
.chat-msg.mine { text-align: right; }
.chat-bubble {
  display: inline-block; max-width: 85%; text-align: left; word-break: break-word;
  background: var(--secondary); border-radius: 12px; padding: 7px 11px; font-size: 13px; margin-top: 3px;
}
.chat-msg.mine .chat-bubble { background: var(--primary); color: var(--primary-fg); }

/* ===== 顶栏图标按钮 ===== */
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--secondary); color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }
.chat-dot {
  position: absolute; top: 5px; right: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--red);
}

/* ===== 底部导航（10 项可横滑） ===== */
@media (max-width: 860px) {
  .bottomnav { display: flex; overflow-x: auto; scrollbar-width: none; }
  .bottomnav::-webkit-scrollbar { display: none; }
  .bottomnav button { flex: 1 0 58px; }
  .chat-panel { bottom: 66px; }
}

/* 页面标题内联按钮 */
.page-title .btn-ghost { vertical-align: middle; }

@media (prefers-reduced-motion: reduce) {
  .dm-item { animation: none !important; opacity: 0; }
}
