:root {
  --bg: #0b1026;
  --bg2: #141a3a;
  --panel: rgba(20, 26, 58, 0.92);
  --panel-line: rgba(124, 58, 237, 0.35);
  --txt: #eef1ff;
  --muted: #9aa3c7;
  --accent: #7c3aed;
  --accent2: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --gold: #fbbf24;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#game-root { position: fixed; inset: 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* 顶部条 */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
.home-link {
  pointer-events: auto; color: var(--txt); text-decoration: none;
  background: rgba(11,16,38,0.6); border: 1px solid var(--panel-line);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; backdrop-filter: blur(6px);
}
.who { font-size: 13px; color: var(--muted); pointer-events: none; }

/* HUD */
#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.hud-top {
  position: absolute; top: 54px; left: 10px; right: 10px;
  display: flex; gap: 8px; justify-content: space-between;
}
.hud-cell {
  background: rgba(11,16,38,0.55); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 6px 10px; text-align: center; min-width: 64px;
  backdrop-filter: blur(6px);
}
.hud-cell .lbl { display: block; font-size: 10px; color: var(--muted); }
.hud-cell span:last-child { font-size: 16px; font-weight: 700; }

#wind-box {
  position: absolute; top: 100px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: rgba(11,16,38,0.5); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 5px 12px; backdrop-filter: blur(6px); font-size: 14px;
}
#wind-box .lbl { font-size: 11px; color: var(--muted); }
#wind-arrow { font-size: 18px; }

#combo {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%,-50%);
  font-size: 40px; font-weight: 900; color: var(--gold);
  text-shadow: 0 2px 12px rgba(251,191,36,0.6); animation: pop .25s ease;
}
@keyframes pop { from { transform: translate(-50%,-50%) scale(.6); } to { transform: translate(-50%,-50%) scale(1); } }

#health-wrap {
  position: absolute; left: 10px; right: 10px; bottom: 158px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(11,16,38,0.5); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 6px 10px; backdrop-filter: blur(6px);
}
#health-wrap .lbl { font-size: 11px; color: var(--muted); }
.bar { flex: 1; height: 10px; background: #2a3160; border-radius: 999px; overflow: hidden; }
#health-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--accent2)); transition: width .1s linear; }
#tension-lbl { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }

#btn-quit {
  position: absolute; left: 10px; top: 100px; pointer-events: auto;
}

/* 触屏控件 */
#joystick {
  position: absolute; left: 18px; bottom: 24px; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(124,58,237,0.12);
  border: 2px solid var(--panel-line); pointer-events: auto; touch-action: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(124,58,237,0.55); border: 2px solid #fff3;
}
#reel {
  position: absolute; right: 18px; bottom: 24px; display: flex; flex-direction: column; gap: 10px;
  pointer-events: auto;
}
.reel-btn {
  width: 96px; height: 56px; border-radius: 16px; border: 2px solid var(--panel-line);
  background: rgba(11,16,38,0.7); color: var(--txt); font-size: 16px; font-weight: 700;
  backdrop-filter: blur(6px);
}
.reel-btn.pull { background: rgba(124,58,237,0.35); }
.reel-btn:active { transform: scale(.95); background: rgba(124,58,237,0.6); }
.reel-btn.act { transform: scale(.95); background: rgba(124,58,237,0.68); border-color: var(--accent2); }
.reel-btn { touch-action: none; }

/* 动态摇杆：默认作为提示，按下时跟随手指位置 */
#joystick { opacity: .55; transition: opacity .15s; }
#hint {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  font-size: 11px; color: var(--muted); white-space: nowrap;
}

/* 弹层 */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; padding: 18px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(124,58,237,0.18), rgba(11,16,38,0.86));
  backdrop-filter: blur(4px); overflow: auto;
}
.modal {
  width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--panel-line); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); text-align: center;
}
.modal.wide { max-width: 480px; }
.modal h2 { margin: 4px 0 14px; font-size: 22px; }
.modal h3 { margin: 14px 0 8px; font-size: 15px; color: var(--muted); }

.logo-ring {
  width: 96px; height: 96px; margin: 0 auto 10px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 46px;
  background: radial-gradient(circle at 50% 35%, rgba(124,58,237,0.5), rgba(34,211,238,0.15));
  border: 2px solid var(--panel-line); box-shadow: 0 0 30px rgba(124,58,237,0.4);
}
.logo-ring.small { width: 72px; height: 72px; font-size: 34px; }

.btn-primary {
  display: inline-block; border: none; border-radius: 12px; padding: 12px 18px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { transform: scale(.97); }
.btn-primary.block, .btn-ghost.block { display: block; width: 100%; margin-top: 10px; }
.btn-ghost {
  border: 1px solid var(--panel-line); background: rgba(124,58,237,0.12);
  color: var(--txt); border-radius: 12px; padding: 10px 14px; font-size: 14px; cursor: pointer;
}
.btn-ghost:active { transform: scale(.97); }

/* 菜单 */
.menu-inner { width: 100%; max-width: 460px; margin: auto; }
.menu-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.menu-head .logo-ring { margin: 0; }
.menu-head h1 { margin: 0; font-size: 26px; }
.menu-head .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.profile-card {
  background: rgba(124,58,237,0.1); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; text-align: left;
}
.pf-name { font-size: 18px; font-weight: 800; }
.pf-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 13px; color: var(--muted); }
.badge { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 999px; font-weight: 700; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.mode-btn {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: rgba(20,26,58,0.8); border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 12px; color: var(--txt); cursor: pointer;
}
.mode-btn b { font-size: 16px; }
.mode-btn span { font-size: 11px; color: var(--muted); }
.mode-btn:active { transform: scale(.98); border-color: var(--accent2); }
.mode-btn.tut { grid-column: 1 / -1; border-color: var(--accent2); background: rgba(34,211,238,0.12); }

/* 实时指引横幅 */
#guide {
  position: absolute; top: 138px; left: 50%; transform: translateX(-50%);
  max-width: 88%; background: rgba(11,16,38,0.85); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 9px 14px; font-size: 13px; line-height: 1.55;
  text-align: center; color: var(--txt); backdrop-filter: blur(6px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
}

.skins h3 { color: var(--muted); }
.skin-row { display: flex; gap: 10px; }
.skin-opt {
  flex: 1; border: 2px solid var(--panel-line); border-radius: 14px; padding: 10px 6px;
  text-align: center; cursor: pointer; background: rgba(20,26,58,0.7);
}
.skin-opt .em { font-size: 30px; display: block; }
.skin-opt .nm { font-size: 12px; margin-top: 4px; }
.skin-opt.sel { border-color: var(--accent2); background: rgba(34,211,238,0.12); }

.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.menu-actions .btn-ghost { flex: 1 1 40%; }

/* 结算 */
.res-score { font-size: 52px; font-weight: 900; color: var(--gold); margin: 6px 0; }
.res-stats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; color: var(--muted); font-size: 13px; }
.res-stats span { background: rgba(124,58,237,0.12); padding: 4px 10px; border-radius: 999px; }
.res-sr { margin: 12px 0; font-size: 15px; }
.res-sr .up { color: var(--good); } .res-sr .down { color: var(--bad); }
.res-ach { color: var(--gold); font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-primary, .modal-actions .btn-ghost { flex: 1; }

/* 排行榜 */
.board-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.btab { border: 1px solid var(--panel-line); background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.btab.active { background: var(--accent); color: #fff; }
.board-list { list-style: none; padding: 0; margin: 0 0 12px; max-height: 46vh; overflow: auto; text-align: left; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.board-list .rk { width: 26px; text-align: center; color: var(--muted); font-weight: 700; }
.board-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { color: var(--gold); font-weight: 700; }
.board-list .me { background: rgba(34,211,238,0.1); border-radius: 8px; }

/* QTE */
.qte-card { width: 100%; max-width: 360px; text-align: center; }
.qte-track { position: relative; height: 38px; background: #2a3160; border-radius: 999px; margin: 14px 0 12px; overflow: hidden; }
#qte-zone { position: absolute; top: 0; bottom: 0; width: 22%; background: linear-gradient(90deg, #22d3ee, #34d399); border-radius: 999px; }
#qte-needle { position: absolute; top: -4px; bottom: -4px; width: 4px; background: #fff; border-radius: 2px; left: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* 提示 */
.toast {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(11,16,38,0.9); border: 1px solid var(--panel-line);
  color: var(--txt); padding: 10px 16px; border-radius: 999px; z-index: 50; font-size: 14px;
  animation: pop .2s ease;
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.info-grid .it { background: rgba(124,58,237,0.1); border: 1px solid var(--panel-line); border-radius: 10px; padding: 10px; }
.info-grid .it.on { border-color: var(--gold); }
.info-grid .it .t { font-weight: 700; }
.info-grid .it .d { font-size: 11px; color: var(--muted); }
.how-list { text-align: left; color: var(--muted); font-size: 13px; line-height: 1.7; }
.how-list b { color: var(--txt); }

@media (min-width: 760px) {
  #joystick { width: 150px; height: 150px; }
  .reel-btn { width: 110px; height: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  #combo { animation: none; }
  .toast { animation: none; }
}
