:root{
  --bg:#0e1726; --panel:#152033; --panel2:#1c2a44; --accent:#36d399; --accent2:#ffd400;
  --text:#eaf0fb; --muted:#9fb0cc; --btn:#27406b; --btn-h:#34598f; --danger:#d0021b;
}
*{box-sizing:border-box;}
html,body{margin:0;height:100%;}
body{
  background:linear-gradient(160deg,#0e1726,#10203b 60%,#0c1a30);
  color:var(--text); font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  -webkit-user-select:none; user-select:none; min-height:100%;
}
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 20px; background:rgba(20,32,51,.85); backdrop-filter:blur(6px);
  border-bottom:2px solid #2a3c5e; position:sticky; top:0; z-index:20;
}
.brand{font-size:22px; font-weight:800; letter-spacing:1px;}
.top-right{font-size:16px; background:var(--panel2); padding:6px 14px; border-radius:20px;}
.top-right b{color:var(--accent2); font-size:18px;}

.layout{display:flex; gap:16px; padding:16px; align-items:stretch;}
.stage-wrap{flex:1.4; display:flex; flex-direction:column; gap:8px; min-width:0;}
.stage-pair{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.stage-col{display:flex; flex-direction:column; gap:6px; min-width:0;}
.stage-label{font-size:14px; font-weight:800; color:var(--accent2); text-align:center;}
.stage{
  position:relative; width:100%; height:560px; border-radius:18px; overflow:hidden;
  background:radial-gradient(circle at 50% 40%, #16243d, #0b1424);
  border:2px solid #2a3c5e; box-shadow:0 10px 40px rgba(0,0,0,.4);
}
.stage canvas{display:block; width:100%; height:100%; touch-action:none;}
.stage-hint{color:var(--muted); font-size:13px; text-align:center;}

.side{flex:1; min-width:340px; max-width:460px; display:flex; flex-direction:column; gap:12px;}
.tabs{display:flex; gap:8px;}
.tab{
  flex:1; padding:12px 8px; border:none; border-radius:14px 14px 0 0; cursor:pointer;
  background:var(--panel); color:var(--muted); font-size:15px; font-weight:700; transition:.15s;
}
.tab.active{background:var(--accent); color:#06231a;}
.panel{
  display:none; background:var(--panel); border-radius:0 0 16px 16px; padding:16px;
  border:2px solid #2a3c5e; border-top:none; max-height:560px; overflow:auto;
}
.panel.active{display:block;}
.panel h3{margin:0 0 8px; font-size:18px;}
.muted{color:var(--muted); font-size:14px; line-height:1.5;}

.btn{
  background:var(--btn); color:var(--text); border:none; border-radius:12px;
  padding:10px 14px; font-size:15px; font-weight:700; cursor:pointer; transition:.12s;
}
.btn:hover{background:var(--btn-h);}
.btn:disabled{opacity:.45; cursor:not-allowed;}
.btn-primary{background:var(--accent); color:#06231a;}
.btn-primary:hover{filter:brightness(1.08);}

.move-buttons{display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px 0;}
.move-btn{padding:12px 0; font-size:16px; font-weight:800; box-shadow:0 1px 3px rgba(0,0,0,.25);}
.move-btn:hover{filter:brightness(1.08);}
.face-legend{display:flex; flex-wrap:wrap; gap:10px; margin:6px 0 2px;}
.legend-chip{display:flex; flex-direction:column; align-items:center; gap:4px; font-size:12px; color:var(--muted);}
.legend-face{width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:17px; font-weight:800; box-shadow:0 1px 3px rgba(0,0,0,.3);}
.play-actions{display:flex; gap:10px; margin-top:8px;}
.play-actions .btn{flex:1;}

/* 解题 */
.loading,.err{padding:14px; border-radius:12px; background:var(--panel2);}
.err{color:#ffb4b4; border:1px solid var(--danger); line-height:1.6;}
.solve-summary{margin-bottom:10px; font-size:14px;}
.solve-group{background:var(--panel2); border-radius:12px; padding:10px; margin-bottom:10px;}
.solve-g-name{font-weight:800; color:var(--accent2); font-size:15px;}
.solve-g-tip{color:var(--muted); font-size:13px; margin:3px 0 8px;}
.solve-chips{display:flex; flex-wrap:wrap; gap:6px;}
.chip{
  background:var(--btn); border-radius:10px; padding:6px 9px; font-weight:800; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; min-width:48px; font-size:15px;
}
.chip small{font-weight:500; font-size:10px; color:var(--muted); margin-top:2px;}
.chip.done{opacity:.4;}
.chip:hover{background:var(--btn-h);}
.solve-controls{display:flex; flex-wrap:wrap; gap:8px; margin-top:6px;}
.solve-controls .btn{flex:1; min-width:120px;}

/* 图片输入 */
.is-tabs{display:flex; gap:8px; margin-bottom:10px;}
.is-tab{background:var(--panel2); border:none; color:var(--muted); padding:8px 12px; border-radius:10px; cursor:pointer; font-weight:700;}
.is-tab.active{background:var(--accent); color:#06231a;}
.is-tip{font-size:13px; color:var(--muted); line-height:1.6; margin:6px 0;}
.is-upload{margin:8px 0;}
.is-thumbs{display:flex; gap:6px; flex-wrap:wrap; margin-top:6px;}
.is-thumb{width:60px; height:60px; object-fit:cover; border-radius:8px; border:2px solid transparent; cursor:pointer;}
.is-thumb.active{border-color:var(--accent);}
.is-canvas-wrap{position:relative; background:#0b1424; border-radius:12px; overflow:hidden; display:flex; align-items:center; justify-content:center; min-height:200px;}
#is-canvas{max-width:100%; cursor:crosshair; touch-action:none;}
.is-canvas-hint{position:absolute; color:var(--muted); font-size:14px; pointer-events:none;}
.is-captures{display:flex; flex-wrap:wrap; gap:8px; margin:10px 0;}
.is-cap{background:var(--panel2); border-radius:10px; padding:8px; text-align:center;}
.is-cap-title{font-size:13px; margin-bottom:4px;}
.is-grid3{display:grid; grid-template-columns:repeat(3,22px); gap:2px; margin:0 auto;}
.is-cell{width:22px; height:22px; border-radius:4px; display:flex; align-items:center; justify-content:center; font-size:11px; color:#000; font-weight:800; cursor:pointer; border:1px solid #00000055;}
.is-del{margin-top:5px; width:100%; background:var(--danger); color:#fff; border:none; border-radius:8px; padding:4px; font-size:12px; cursor:pointer;}
.is-msg{font-size:13px; margin-top:8px; min-height:18px; color:var(--accent2);}
.is-msg.err{color:#ffb4b4;}
.is-picker{position:fixed; z-index:50; display:flex; gap:4px; background:#fff; padding:6px; border-radius:10px; box-shadow:0 6px 20px rgba(0,0,0,.4);}
.is-picker button{width:26px; height:26px; border:none; border-radius:6px; cursor:pointer; border:1px solid #0003;}
.is-manual-faces{display:grid; grid-template-columns:repeat(3,1fr); gap:10px;}
.is-mface{background:var(--panel2); border-radius:10px; padding:8px; text-align:center;}
.is-mface-title{font-size:13px; font-weight:700; margin-bottom:4px;}

/* 闯关 */
.wb-hud{display:flex; gap:10px; margin-bottom:12px;}
.wb-stat{flex:1; background:var(--panel2); border-radius:12px; padding:10px; text-align:center;}
.wb-num{display:block; font-size:24px; font-weight:800; color:var(--accent2);}
.wb-stat span:last-child{font-size:12px; color:var(--muted);}
.wb-goalbox{background:linear-gradient(135deg,#1d3a2c,#16314a); border-radius:12px; padding:12px; margin-bottom:12px;}
.wb-goal-title{font-weight:800; color:var(--accent);}
.wb-goal-live{margin:6px 0; font-weight:700;}
.wb-goal-btns{display:flex; gap:8px;}
.wb-levels{display:flex; flex-direction:column; gap:10px;}
.wb-level{background:var(--panel2); border-radius:12px; padding:12px; border:2px solid transparent;}
.wb-level.active{border-color:var(--accent);}
.wb-level.locked{opacity:.5;}
.wb-level-name{font-weight:800; font-size:15px;}
.wb-level-desc{color:var(--muted); font-size:13px; margin:4px 0; line-height:1.5;}
.wb-level-stars{font-size:16px; margin-bottom:6px;}
.wb-tip{margin-top:14px; color:var(--muted); font-size:12px; line-height:1.6;}

.wb-toast{position:fixed; left:50%; bottom:30px; transform:translateX(-50%) translateY(20px); background:#000a; color:#fff; padding:12px 20px; border-radius:20px; opacity:0; transition:.25s; z-index:60; font-size:14px;}
.wb-toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

.wb-celebrate{position:fixed; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; z-index:80; pointer-events:none; background:radial-gradient(circle,#0008,transparent 70%);}
.wb-emoji{font-size:80px; animation:pop .5s ease;}
.wb-banner-txt{font-size:34px; font-weight:900; color:var(--accent2); text-shadow:0 2px 10px #000;}
.wb-stars{font-size:30px; margin:6px;}
.wb-gain{font-size:22px; color:var(--accent); font-weight:800;}
.wb-confetti{position:absolute; top:-20px; width:10px; height:14px; border-radius:2px; animation:fall 1.6s linear forwards;}
@keyframes pop{0%{transform:scale(0);}70%{transform:scale(1.2);}100%{transform:scale(1);}}
@keyframes fall{to{transform:translateY(110vh) rotate(540deg); opacity:0;}}

.foot{text-align:center; color:var(--muted); font-size:12px; padding:14px;}
.foot code{background:var(--panel2); padding:2px 6px; border-radius:6px;}

@media (max-width:920px){
  .layout{flex-direction:column;}
  .side{max-width:none;}
  .stage-pair{grid-template-columns:1fr;}
  .stage{height:420px;}
  .panel{max-height:none;}
}

/* 顶部称号 */
.top-title{margin-left:8px; color:var(--accent2); font-weight:800; font-size:13px;}

/* 奖励商店 */
.rw-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; margin-top:10px;}
.rw-card{background:var(--panel2); border:1px solid #2a3c5e; border-radius:12px; padding:14px; display:flex; flex-direction:column; align-items:center; text-align:center; gap:6px;}
.rw-card.owned{border-color:var(--accent);}
.rw-icon{font-size:40px; line-height:1;}
.rw-swatch{display:flex; gap:3px; margin-bottom:2px;}
.rw-swatch i{width:16px; height:16px; border-radius:4px; display:inline-block; border:1px solid #0003;}
.rw-name{font-weight:800; font-size:15px;}
.rw-desc{font-size:12px; color:var(--muted); min-height:32px;}
.rw-cost{font-size:13px; color:var(--accent); font-weight:700;}
.rw-owned{font-size:12px; color:var(--accent2); font-weight:700;}
.rw-card .btn{margin-top:4px; width:100%;}

/* 顶栏背景音乐按钮与音量条 */
.btn-music{background:var(--panel2); color:var(--text); border:1px solid #2a3c5e; border-radius:8px; padding:4px 10px; font-size:13px; font-weight:700; cursor:pointer; margin-right:6px; transition:all .15s;}
.btn-music:hover{border-color:var(--accent);}
.btn-music.on{background:var(--accent); color:#fff; border-color:var(--accent); animation:musicPulse 1.6s ease-in-out infinite;}
@keyframes musicPulse{0%,100%{box-shadow:0 0 0 0 #7aa7ff55;}50%{box-shadow:0 0 0 6px #7aa7ff00;}}
.music-vol{width:70px; height:4px; accent-color:var(--accent); cursor:pointer; vertical-align:middle; margin-right:10px;}
