/* ============================================================
 * 帝王消消乐 · 深空紫 + 鎏金主题
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: #0b0716; color: #f0ecff;
  user-select: none; -webkit-user-select: none;
}
#starfield { position: fixed; inset: 0; z-index: 0; }
#app { position: relative; z-index: 1; height: 100%; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: block; width: 100%; padding: 13px 18px; margin: 8px 0;
  border-radius: 14px; font-size: 16px; font-weight: 700; letter-spacing: 2px;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(160deg, #ffe9a8, #e8b64c 55%, #c98f2a);
  color: #3a2503; box-shadow: 0 6px 22px rgba(232,182,76,.35), inset 0 1px 0 rgba(255,255,255,.55);
}
.btn-gold {
  background: linear-gradient(160deg, #6a48d8, #5330c0);
  color: #fff; box-shadow: 0 6px 18px rgba(106,72,216,.4);
}
.btn-ghost {
  background: rgba(255,255,255,.06); color: #cfc6ee;
  border: 1px solid rgba(255,255,255,.14);
}
.btn-lg { padding: 16px; font-size: 18px; }
.btn-mini { display: inline-block; width: auto; margin: 0; padding: 6px 14px; font-size: 12px; letter-spacing: 1px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 19px;
  background: rgba(255,255,255,.07); color: #e9e2ff; border: 1px solid rgba(255,255,255,.12);
}
.icon-btn:active { transform: scale(.92); }

/* ---------- 屏幕容器 ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 2; }

/* ---------- 认证屏 ---------- */
#screen-auth { align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: min(400px, 94vw); padding: 36px 30px 30px; border-radius: 26px; text-align: center;
  background: linear-gradient(170deg, rgba(46,32,88,.72), rgba(22,14,46,.82));
  border: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(14px);
  box-shadow: 0 24px 80px rgba(0,0,0,.55), 0 0 60px rgba(124,77,255,.12);
  animation: rise .6s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
.logo-star {
  width: 84px; height: 84px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
  font-size: 42px; color: #ffe9a8; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #8a5cff, #4a2a9e 70%);
  box-shadow: 0 0 44px rgba(150,100,255,.55), inset 0 2px 8px rgba(255,255,255,.35);
  animation: starPulse 2.6s ease-in-out infinite;
}
@keyframes starPulse { 50% { box-shadow: 0 0 70px rgba(170,130,255,.8), inset 0 2px 8px rgba(255,255,255,.35); } }
.logo-title { font-size: 34px; letter-spacing: 10px; text-indent: 10px;
  background: linear-gradient(120deg, #ffe9a8, #f5c86b 50%, #fff3cf); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-sub { margin: 10px 0 22px; font-size: 13px; color: #b9aee0; letter-spacing: 3px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; background: rgba(0,0,0,.28); border-radius: 12px; padding: 4px; }
.tab { flex: 1; padding: 10px; border-radius: 9px; font-size: 15px; color: #9d92c7; background: transparent; transition: all .2s; }
.tab.active { background: linear-gradient(160deg, #ffe9a8, #e0aa3e); color: #3a2503; font-weight: 700; }
.auth-form input {
  width: 100%; padding: 14px 16px; margin: 7px 0; border-radius: 12px; font-size: 15px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.13); color: #f0ecff; outline: none;
}
.auth-form input:focus { border-color: #a377ff; box-shadow: 0 0 0 3px rgba(124,77,255,.18); }
.divider { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; color: #7e73ab; font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.12); }
.hint { margin-top: 14px; font-size: 12px; color: #877cb4; line-height: 1.6; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: linear-gradient(180deg, rgba(20,13,44,.92), rgba(20,13,44,.55));
  border-bottom: 1px solid rgba(255,255,255,.07); backdrop-filter: blur(10px);
}
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: 4px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.profile-chip { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: #3a2503;
  background: linear-gradient(140deg, #ffe9a8, #d09a35); box-shadow: 0 0 18px rgba(232,182,76,.35);
}
.pname { font-size: 14px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvip { font-size: 10px; color: #ffe9a8; border: 1px solid #e0aa3e; border-radius: 6px; padding: 1px 6px; margin-top: 2px; display: inline-block; }
.chip {
  display: flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 20px; font-size: 13px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.1); white-space: nowrap;
}
.chip b { font-size: 13px; }
.chip-gold .ic { color: #f5c86b; } .chip-gold b { color: #ffe9a8; }
.chip-star .ic { color: #c08bff; } .chip-star b { color: #e6d6ff; }
.chip-life .ic { color: #ff6b8a; letter-spacing: -1px; font-size: 11px; }
.chip-life b { color: #ffb3c4; font-size: 11px; }
.guest-banner {
  padding: 8px 16px; font-size: 12px; color: #d9c88f; text-align: center;
  background: rgba(232,182,76,.08); border-bottom: 1px solid rgba(232,182,76,.18);
}
.guest-banner a { color: #ffe9a8; }

/* ---------- 关卡地图 ---------- */
.level-wrap { flex: 1; overflow-y: auto; padding: 18px 16px 90px; }
.level-head { text-align: center; margin-bottom: 18px; }
.level-head h2 { font-size: 22px; letter-spacing: 8px; color: #ffe9a8; }
.level-head p { font-size: 12px; color: #9d92c7; margin-top: 6px; letter-spacing: 2px; }
#level-path { max-width: 560px; margin: 0 auto; position: relative; }
.lv-node {
  display: flex; align-items: center; gap: 16px; padding: 12px 14px; margin: 10px 0;
  border-radius: 18px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.08);
  transition: transform .12s, background .2s; position: relative;
}
.lv-node.open:active { transform: scale(.98); }
.lv-node.current {
  background: linear-gradient(150deg, rgba(124,77,255,.22), rgba(232,182,76,.1));
  border-color: rgba(180,140,255,.45); box-shadow: 0 0 26px rgba(124,77,255,.18);
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 40px rgba(150,110,255,.32); } }
.lv-node.locked { opacity: .45; filter: saturate(.4); }
.lv-orb {
  width: 62px; height: 62px; flex: none; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; position: relative;
  background: radial-gradient(circle at 32% 28%, #4a3591, #241650 72%);
  border: 1.5px solid rgba(180,140,255,.5); box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.lv-node.current .lv-orb { border-color: #f5c86b; box-shadow: 0 0 22px rgba(245,200,107,.4); }
.lv-num { font-size: 20px; font-weight: 800; color: #ffe9a8; line-height: 1; }
.lv-starname { font-size: 10px; color: #b9aee0; margin-top: 2px; letter-spacing: 1px; }
.lv-orb-end { background: radial-gradient(circle at 32% 28%, #9a7435, #3d2a10 72%); border-color: #e0aa3e; }
.lv-orb-end .lv-starname { font-size: 22px; color: #ffe9a8; }
.lv-info { min-width: 0; }
.lv-name { font-size: 16px; font-weight: 700; }
.lv-stars { color: #f5c86b; font-size: 13px; letter-spacing: 2px; }
.lv-goals { font-size: 12px; color: #9d92c7; margin-top: 4px; }
.lv-lock { margin-left: auto; font-size: 20px; }
.lv-end { display: flex; align-items: center; gap: 16px; padding: 12px 14px; margin: 10px 0; border-radius: 18px; opacity: .55; }

/* ---------- 底部导航 ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; z-index: 5;
  background: linear-gradient(0deg, rgba(14,9,32,.97), rgba(20,13,44,.88));
  border-top: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(12px);
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; background: transparent; color: #8d82b8; padding: 6px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; transition: color .2s;
}
.nav-ic { font-size: 21px; }
.nav-btn.active { color: #ffe9a8; }

/* ---------- 商城 ---------- */
.shop-wrap { flex: 1; overflow-y: auto; padding: 16px 16px 40px; }
.shop-section { max-width: 640px; margin: 0 auto 26px; }
.shop-sec-title {
  display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700;
  color: #ffe9a8; margin-bottom: 6px; letter-spacing: 2px;
}
.shop-sec-title .ic { color: #c08bff; }
.shop-sec-title .btn-mini { margin-left: auto; }
.shop-note { font-size: 12px; color: #9d92c7; line-height: 1.7; margin-bottom: 12px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shop-card {
  position: relative; padding: 18px 14px; border-radius: 18px; text-align: center;
  background: linear-gradient(165deg, rgba(58,42,108,.5), rgba(26,17,56,.65));
  border: 1px solid rgba(255,255,255,.09); transition: transform .12s;
}
.shop-card:active { transform: scale(.97); }
.shop-card.wide { grid-column: 1 / -1; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.sc-tag {
  position: absolute; top: -8px; right: 12px; font-size: 10px; padding: 3px 10px; border-radius: 10px;
  background: linear-gradient(120deg, #ff8f6b, #e2452b); color: #fff; font-weight: 700; letter-spacing: 1px;
}
.sc-icon { font-size: 30px; margin-bottom: 6px; }
.sc-name { font-size: 16px; font-weight: 700; margin: 4px 0; }
.sc-desc { font-size: 11.5px; color: #a99ede; line-height: 1.5; min-height: 34px; }
.sc-price { font-size: 15px; color: #ffe9a8; font-weight: 800; margin: 8px 0 4px; }
.shop-card .btn { margin: 4px 0 0; padding: 10px; font-size: 14px; }

/* ---------- 游戏屏 ---------- */
#screen-game { background: radial-gradient(120% 90% at 50% 0%, rgba(74,53,145,.35), rgba(11,7,22,.2)); }
#game-hud { display: flex; align-items: center; gap: 12px; padding: 10px 14px 4px; }
.hud-mid { flex: 1; min-width: 0; }
.hud-level { font-size: 15px; font-weight: 700; color: #ffe9a8; letter-spacing: 1px; }
.hud-goals { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; min-height: 26px; }
.goal-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.12); padding: 3px 10px 3px 4px; border-radius: 16px;
}
.goal-chip i {
  font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: rgba(0,0,0,.55); font-weight: 800;
}
.goal-chip .tile-ic { background: linear-gradient(135deg, #3a2c6e, #241650); color: #f5c86b; }
.goal-chip.done { opacity: .45; } .goal-chip.done::after { content: '✓'; color: #7fe07f; }
.hud-moves-wrap { text-align: center; min-width: 76px; }
.hud-moves-label { font-size: 11px; color: #9d92c7; letter-spacing: 2px; }
.hud-moves { font-size: 34px; font-weight: 900; color: #fff; line-height: 1.1; text-shadow: 0 2px 12px rgba(124,77,255,.5); }
.hud-moves.danger { color: #ff6b8a; animation: blink .7s infinite; }
@keyframes blink { 50% { opacity: .4; } }
.hud-scorebar { display: flex; align-items: center; gap: 10px; padding: 2px 16px 6px; }
/* ── 狂热槽 ── */
.fever-wrap { display: flex; align-items: center; gap: 7px; padding: 2px 16px 7px; }
.fever-ic { font-size: 13px; color: #f5c86b; text-shadow: 0 0 8px rgba(245,200,107,.8); }
.fever-track { flex: 1; height: 8px; border-radius: 6px; background: rgba(0,0,0,.42); border: 1px solid rgba(245,200,107,.22); overflow: hidden; }
.fever-fill { height: 100%; width: 0; border-radius: 6px; transition: width .35s ease;
  background: linear-gradient(90deg, #b8862f, #ffe9a8 60%, #ffd76b);
  box-shadow: 0 0 10px rgba(255,214,107,.65); }
.fever-txt { font-size: 10.5px; letter-spacing: 2px; color: #b9aee0; min-width: 64px; text-align: right; }
.fever-wrap.on .fever-track { border-color: rgba(255,220,140,.8); box-shadow: 0 0 14px rgba(255,200,80,.55); }
.fever-wrap.on .fever-fill { background: linear-gradient(90deg, #ff9d3c, #ffe9a8 50%, #fff7dc); animation: kc-fever-pulse .5s infinite; }
.fever-wrap.on .fever-txt { color: #ffd76b; font-weight: 900; }
@keyframes kc-fever-pulse { 50% { filter: brightness(1.35); } }
.scorebar-track {
  flex: 1; height: 12px; border-radius: 8px; position: relative;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.1);
}
.scorebar-fill {
  height: 100%; border-radius: 8px; width: 0; transition: width .4s ease;
  background: linear-gradient(90deg, #7c4dff, #e8b64c);
  box-shadow: 0 0 12px rgba(232,182,76,.5);
}
.score-star {
  position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 15px; color: #55496e; transition: all .3s;
}
.score-star.s1 { left: 52%; } .score-star.s2 { left: 76%; } .score-star.s3 { left: 97%; }
.score-star.lit { color: #f5c86b; text-shadow: 0 0 12px rgba(245,200,107,.9); transform: translate(-50%, -50%) scale(1.25); }
.scorebar-val { font-size: 14px; font-weight: 800; color: #ffe9a8; min-width: 64px; text-align: right; }
.canvas-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; position: relative; }
/* 鎏金雕花棋盘边框 */
.canvas-wrap::before {
  content: ""; position: absolute; inset: 12px; border-radius: 22px; pointer-events: none;
  border: 1.5px solid rgba(245,200,107,.4);
  box-shadow: inset 0 0 0 4px rgba(124,77,255,.14), inset 0 0 26px rgba(245,200,107,.1);
}
.canvas-wrap::after {
  content: "✦"; position: absolute; top: 0px; left: 50%; transform: translateX(-50%);
  color: rgba(245,200,107,.75); font-size: 13px; pointer-events: none;
  text-shadow: 0 0 10px rgba(245,200,107,.9);
}
#board { border-radius: 18px; touch-action: none; box-shadow: 0 18px 60px rgba(0,0,0,.5), 0 0 40px rgba(124,77,255,.1); }
.combo-pop {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%);
  font-size: 44px; font-weight: 900; letter-spacing: 8px; pointer-events: none;
  background: linear-gradient(120deg, #ffe9a8, #ff9de2, #9ad0ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(255,220,140,.6)); animation: comboAnim .9s ease forwards;
}
.combo-pop.mega { font-size: 58px; }
.combo-pop.big { letter-spacing: 10px; }
@keyframes comboAnim {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%, -55%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(.9); }
}
#booster-bar {
  display: flex; gap: 10px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  justify-content: center;
}
.booster-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 86px; padding: 9px 12px; border-radius: 16px;
  background: linear-gradient(165deg, rgba(58,42,108,.55), rgba(26,17,56,.7));
  border: 1px solid rgba(255,255,255,.12); color: #e9e2ff;
}
.booster-btn.none { opacity: .45; }
.booster-btn.active { border-color: #f5c86b; box-shadow: 0 0 18px rgba(245,200,107,.35); }
.b-ic { font-size: 22px; } .b-name { font-size: 11px; color: #b9aee0; }
.b-n {
  position: absolute; top: -7px; right: -5px; min-width: 20px; height: 20px; border-radius: 10px;
  background: linear-gradient(140deg, #ff8f6b, #e2452b); color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
#booster-bar.hammering .booster-btn:first-child { animation: glow 1.2s infinite; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(5,3,12,.66); backdrop-filter: blur(6px); padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(400px, 94vw); max-height: 86vh; overflow-y: auto; text-align: center;
  padding: 28px 24px 20px; border-radius: 24px;
  background: linear-gradient(170deg, #2e2058, #170f36);
  border: 1px solid rgba(255,255,255,.12); box-shadow: 0 30px 90px rgba(0,0,0,.6);
  animation: popIn .28s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes popIn { from { transform: scale(.82); opacity: 0; } }
.m-head { font-size: 23px; font-weight: 800; letter-spacing: 4px; margin-bottom: 8px; color: #ffe9a8; }
.m-lose-head { color: #ff9db1; }
.m-tag { font-size: 13px; color: #b9aee0; margin-bottom: 14px; line-height: 1.7; }
.m-goals {
  font-size: 14px; color: #e9e2ff; background: rgba(0,0,0,.28); border-radius: 12px;
  padding: 12px; margin-bottom: 14px; line-height: 1.8;
}
.m-bless { font-size: 13px; color: #cfc6ee; margin-bottom: 14px; }
.m-bless.off { opacity: .45; }
.m-bless input { transform: translateY(1px); margin-right: 4px; accent-color: #e8b64c; }
.win-stars { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.ws { font-size: 44px; color: #453a68; transition: all .3s; }
.ws.lit { color: #f5c86b; text-shadow: 0 0 26px rgba(245,200,107,.85); animation: starIn .5s cubic-bezier(.2,1.6,.4,1); }
.ws.s2.lit { animation-delay: .18s; } .ws.s3.lit { animation-delay: .36s; }
@keyframes starIn { from { transform: scale(0) rotate(-120deg); } }
.win-score { font-size: 28px; font-weight: 900; margin: 6px 0; }
.win-coins { font-size: 15px; color: #ffe9a8; margin: 8px 0 16px; }
.win-coins b { font-size: 20px; }
.lose-sub { font-size: 14px; color: #b9aee0; margin: 6px 0 14px; line-height: 1.7; }
.new-record { color: #ffe9a8; font-weight: 800; margin-bottom: 8px; letter-spacing: 2px; }
.fortune { font-size: 17px; line-height: 2; color: #ffe9a8; margin: 14px 0; letter-spacing: 1px; }
.fortune-note { font-size: 11px; color: #7e73ab; margin-bottom: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.07); }
.tgl { padding: 7px 26px; border-radius: 20px; font-size: 13px; background: rgba(255,255,255,.08); color: #9d92c7; }
.tgl.on { background: linear-gradient(140deg, #ffe9a8, #e0aa3e); color: #3a2503; font-weight: 700; }
.set-info { font-size: 12px; color: #8d82b8; line-height: 1.8; margin: 14px 0 6px; text-align: left; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 96px; left: 0; right: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  max-width: 86vw; padding: 11px 22px; border-radius: 22px; font-size: 14px; text-align: center;
  background: rgba(28,19,58,.94); border: 1px solid rgba(255,255,255,.16); color: #f0ecff;
  box-shadow: 0 10px 34px rgba(0,0,0,.5); opacity: 0; transform: translateY(12px); transition: all .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- 窄屏适配 ---------- */
@media (max-width: 480px) {
  .profile-meta { display: none; }
  .chip { padding: 6px 8px; font-size: 12px; }
  .logo-title { font-size: 28px; letter-spacing: 7px; }
  .hud-moves { font-size: 27px; }
  .combo-pop { font-size: 36px; } .combo-pop.mega { font-size: 46px; }
}
@media (max-height: 700px) {
  .hud-moves { font-size: 26px; }
  #booster-bar { padding-top: 6px; }
}
