* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120d1c;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; color: #fff; }
#app, #app canvas { position: fixed; inset: 0; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; border-radius: 10px; }
.screen { position: fixed; z-index: 10; display: flex; flex-direction: column; gap: 12px; }
.panel-left { left: 5vw; top: 50%; transform: translateY(-50%); width: min(420px, 90vw); max-height: 94vh; overflow: auto;
  background: rgba(20,12,30,.82); padding: 24px; border-radius: 18px; border: 2px solid #ff9a3c; }
.center { inset: 0; align-items: center; justify-content: center; background: rgba(15,8,25,.55); }
h1 { margin: 0; color: #ffcf5a; text-shadow: 0 3px 0 #b3401a; font-size: 34px; }
h2 { margin: 0 0 6px; color: #ffcf5a; }
.sub { margin: 0; color: #f3d9b9; }
.note { color: #bba; font-size: 13px; max-width: 360px; text-align: center; }
label { display: flex; gap: 10px; align-items: center; }
input { flex: 1; padding: 8px; border-radius: 8px; border: none; font-size: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row > span { width: 42px; flex: none; color: #f3d9b9; }
.opt { padding: 8px 22px; background: #3a2b4d; color: #fff; font-size: 16px; }
.opt.on { background: #ff7a2f; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; }
.sw.on { border-color: #fff; }
.big { padding: 14px 22px; font-size: 20px; background: linear-gradient(#ff9a3c, #e2531c);
  color: #fff; font-weight: bold; box-shadow: 0 4px 0 #8a2d0c; }
.big:active { transform: translateY(2px); }
.mode { width: min(420px, 90vw); display: flex; flex-direction: column; }
.mode small { font-size: 13px; font-weight: normal; opacity: .9; margin-top: 4px; }
.small { padding: 8px 16px; background: #3a2b4d; color: #fff; font-size: 15px; }

#hud, #marketHud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hudTop, #mkTop { position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 22px; background: rgba(0,0,0,.55); padding: 8px 20px; border-radius: 12px; font-size: 18px; }
#hudHands { position: absolute; bottom: 44px; left: 16px; display: flex; flex-direction: column; gap: 6px; }
.hand { background: rgba(0,0,0,.6); padding: 6px 12px; border-radius: 8px; }
#hudHelp, #hudHelp2 { position: absolute; bottom: 12px; left: 16px; right: 16px; font-size: 13px; opacity: .8; }
#recipes { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.65); padding: 8px 12px;
  border-radius: 10px; max-width: 380px; pointer-events: auto; font-size: 13px; }
#recipes ul { padding-left: 18px; margin: 6px 0 0; line-height: 1.6; }
#mkHint { position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); padding: 8px 18px; border-radius: 10px; font-size: 18px; }
#mkHint:empty { display: none; }

.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(10,5,20,.6); }
.card { background: #2a1d3a; border: 2px solid #ff9a3c; border-radius: 18px; padding: 22px;
  width: min(460px, 92vw); display: flex; flex-direction: column; gap: 10px; max-height: 90vh; overflow: auto; }
#rating { font-size: 64px; font-weight: bold; color: #ffcf5a; text-align: center; }
#stars { font-size: 30px; text-align: center; color: #ffcf5a; letter-spacing: 4px; }
#resultStats { line-height: 1.7; }
.review { background: rgba(255,255,255,.07); padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.shopItem { display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.07); padding: 8px 12px; border-radius: 8px; }
.shopItem button { padding: 6px 14px; background: #ff7a2f; color: #fff; }
#shopMsg { min-height: 40px; color: #f3d9b9; line-height: 1.5; }

#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: rgba(0,0,0,.75); padding: 8px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s;
  pointer-events: none; }
#toast.show { opacity: 1; }

/* 3D 场景里的标签 */
.lbl { font-size: 11px; background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.timer { font-size: 12px; font-weight: bold; padding: 2px 8px; border-radius: 6px; background: #444; }
.timer.done { background: #2e9e4a; } .timer.burn { background: #b22; }
.bubble { background: #fff; color: #222; border-radius: 10px; padding: 4px 8px; font-size: 13px;
  text-align: center; min-width: 80px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.bubble b { display: block; }
.bubble .adds { font-size: 11px; color: #b4521c; }
.bar { height: 5px; background: #ddd; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #3c3; }
.bubble.mad { background: #ffb3b3; }
.pname { font-size: 12px; font-weight: bold; color: #ffcf5a; text-shadow: 0 1px 2px #000; }

.rowBtns { display: flex; gap: 10px; }
.toggle { width: min(420px, 90vw); }
.list { display: flex; flex-direction: column; gap: 6px; }
.shopItem small { opacity: .75; }
.shopItem button:disabled { background: #555; cursor: default; }
.shopItem button.on { background: #2e9e4a; }
.colorChip { display: inline-block; width: 22px; height: 14px; border-radius: 4px; margin-right: 8px; vertical-align: middle; }
#hudEvent { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(200,40,30,.85);
  padding: 8px 20px; border-radius: 12px; font-size: 20px; font-weight: bold; white-space: nowrap; }
#hudEvent:empty { display: none; }
.shout { background: #ffcf5a; color: #3a1a00; font-weight: bold; font-size: 13px; padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.shout:empty { display: none; }
.awards { background: rgba(255,207,90,.12); border-radius: 8px; padding: 8px 10px; line-height: 1.7; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 10px; background: #3a2b4d; color: #fff; font-size: 13px; }
.chip.on { background: #ff7a2f; }
.note.left { text-align: left; margin: 0; }
.modal.left { justify-content: flex-start; padding-left: 5vw; background: rgba(10,5,20,.25); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 12px; background: #3a2b4d; color: #fff; font-size: 14px; }
.tab.on { background: #ff7a2f; }
#vpOverlay { position: absolute; inset: 0; display: flex; }
.vp { flex: 1; position: relative; }
.vp + .vp { border-left: 3px solid rgba(0,0,0,.7); }
.xhair { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border: 2px solid rgba(255,255,255,.85); border-radius: 50%; }
.prompt { position: absolute; left: 50%; top: calc(50% + 22px); transform: translateX(-50%);
  background: rgba(0,0,0,.65); padding: 4px 12px; border-radius: 8px; white-space: nowrap; font-weight: bold; }
.prompt:empty { display: none; }
.vpHand { position: absolute; left: 12px; bottom: 44px; background: rgba(0,0,0,.6); padding: 6px 12px; border-radius: 8px; }
.shopItem.pv { cursor: pointer; border: 2px solid transparent; }
.shopItem.pv:hover { background: rgba(255,255,255,.12); }
.shopItem.sel { border-color: #ff9a3c; background: rgba(255,154,60,.15); }
.panel-left.side { width: min(460px, 92vw); align-items: stretch; }
.panel-left.side .mode, .panel-left.side .toggle { width: 100%; }
.panel-left.side .note { max-width: none; text-align: left; }

/* 联机大厅 */
.onCol { display: flex; flex-direction: column; gap: 12px; }
.orLine { display: flex; align-items: center; gap: 10px; color: #c9b3d9; font-size: 14px; }
.orLine::before, .orLine::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.2); }
.joinBox { background: rgba(0,0,0,.22); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.joinTitle { color: #f3d9b9; font-size: 15px; font-weight: bold; }
.joinRow { display: flex; gap: 10px; }
.joinRow input { font-size: 20px; letter-spacing: 3px; text-align: center; min-width: 0; }
.joinRow .big { padding: 10px 22px; font-size: 18px; flex: none; }
.roomCode { font-size: 46px; font-weight: bold; letter-spacing: 10px; text-align: center; color: #ffcf5a;
  background: rgba(0,0,0,.25); border-radius: 12px; padding: 6px 0; }
.roomCode::before { content: '房间号'; display: block; font-size: 14px; letter-spacing: 2px; color: #f3d9b9; font-weight: normal; }
.addrBox { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: #c9b3d9; text-align: center; }
.addrBox b { font-size: 16px; color: #fff; user-select: all; }
.peerLine { margin: 0; text-align: center; font-size: 15px; }
#onlineHost .big:disabled { opacity: .45; cursor: not-allowed; }
#onEventToggle { align-self: flex-start; }
.waitBox { background: rgba(0,0,0,.22); border-radius: 12px; padding: 18px; text-align: center; }
.waitBox p { margin: 10px 0 0; }
.spinner { width: 34px; height: 34px; margin: 0 auto; border-radius: 50%; border: 4px solid rgba(255,255,255,.2);
  border-top-color: #ffcf5a; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 背景音乐开关 */
#musicBtn { position: fixed; top: 12px; left: 12px; z-index: 50; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(20,12,30,.62); color: #fff; font-size: 20px; line-height: 40px; padding: 0; }
#musicBtn.off { opacity: .55; text-decoration: line-through; }

/* 新手教程 */
#tutPanel { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); width: min(560px, 92vw);
  background: rgba(20,12,30,.86); border: 2px solid #ffcf5a; border-radius: 14px; padding: 12px 16px; color: #fff;
  text-align: center; pointer-events: auto; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.tutStep { font-size: 13px; color: #ffcf5a; letter-spacing: 1px; }
.tutText { font-size: 18px; line-height: 1.5; margin-top: 4px; }
.tutText b { color: #ffcf5a; }
.tutText kbd { display: inline-block; min-width: 22px; padding: 0 6px; margin: 0 2px; border-radius: 5px; background: #fff; color: #3a1a00;
  font: bold 14px/22px sans-serif; box-shadow: 0 2px 0 #b98a3a; }
.tutBtns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; }
.tutSkip { font-size: 12px; opacity: .6; margin-top: 6px; }
#btnTutorial.new::after { content: '推荐'; margin-left: 6px; font-size: 11px; background: #ff5a3c; border-radius: 6px; padding: 1px 5px; }
#hudEvent { z-index: 2; }

/* ================= 手机 / 平板 ================= */
body { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body.touch { -webkit-user-select: none; user-select: none; }
body.touch input { -webkit-user-select: text; user-select: text; }
body.touch .kbOnly, body.touch #hudHelp, body.touch #hudHelp2, body.touch .tutSkip { display: none !important; }
#app canvas { touch-action: none; }
#touchCtl { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
#joy { position: absolute; left: calc(18px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom));
  width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35);
  pointer-events: auto; touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: rgba(255,207,90,.85); box-shadow: 0 3px 10px rgba(0,0,0,.4); }
#tcBtns { position: absolute; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 12px; pointer-events: auto; touch-action: none; }
#tcUse { width: 118px; height: 118px; border-radius: 50%; background: linear-gradient(#ff9a3c, #e2531c); color: #fff;
  box-shadow: 0 5px 0 #8a2d0c; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; }
#tcUse b { font-size: 20px; }
#tcUse small { font-size: 12px; max-width: 100px; line-height: 1.2; opacity: .95; }
#tcUse.idle { filter: grayscale(.6) brightness(.8); }
#tcUse:active, .tcRound:active { transform: translateY(3px); }
.tcRound { width: 64px; height: 64px; border-radius: 50%; background: rgba(20,12,30,.72); color: #fff; font-size: 16px;
  border: 2px solid rgba(255,255,255,.35); }
#tcShouts { position: absolute; right: 0; bottom: 132px; display: flex; flex-direction: column; gap: 6px; }
#tcShouts button { padding: 10px 14px; background: #ffcf5a; color: #3a1a00; font-weight: bold; font-size: 15px; white-space: nowrap; }
#tcExit { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right));
  height: 40px; padding: 0 14px; border-radius: 20px; background: rgba(200,50,40,.88); color: #fff; font-size: 15px; font-weight: bold;
  border: 2px solid rgba(255,255,255,.5); pointer-events: auto; white-space: nowrap; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
#tcExit:active { transform: translateY(2px); }
body.touch #recipes { right: 130px; }
#rotateHint { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  body.touch.playing #rotateHint { display: block; position: fixed; left: 50%; top: 46%; transform: translate(-50%, -50%); z-index: 9;
    background: rgba(0,0,0,.7); padding: 10px 18px; border-radius: 12px; pointer-events: none; animation: hintFade 4s forwards; }
}
@keyframes hintFade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* 小屏幕：菜单居中、字号和间距缩小 */
@media (max-width: 700px), (max-height: 520px) {
  .panel-left { left: 50%; transform: translate(-50%, -50%); width: min(440px, 94vw); max-height: 92vh; padding: 16px; gap: 9px;
    overflow-y: auto; touch-action: pan-y; }
  .screen.side { gap: 9px; }
  h1 { font-size: 24px; } h2 { font-size: 20px; }
  .big { padding: 11px 16px; font-size: 17px; }
  .mode, .toggle { width: 100%; }
  .mode small { font-size: 12px; }
  .card { padding: 16px; max-height: 92vh; touch-action: pan-y; }
  .modal.left { justify-content: center; padding-left: 0; }
  #rating { font-size: 46px; } #stars { font-size: 24px; }
  #hudTop, #mkTop { font-size: 14px; gap: 10px; padding: 6px 12px; top: 8px; max-width: calc(100vw - 150px); flex-wrap: wrap; justify-content: center; }
  #hudEvent { font-size: 15px; white-space: normal; max-width: 86vw; top: 48px; text-align: center; }
  #toast { top: 50px; max-width: 86vw; text-align: center; }
  #recipes { max-width: 60vw; top: 8px; }
  #tutPanel { top: 48px; padding: 8px 12px; width: min(520px, 70vw); }
  .tutText { font-size: 15px; }
  #musicBtn { top: 8px; left: 8px; width: 36px; height: 36px; line-height: 36px; font-size: 17px; }
  .roomCode { font-size: 36px; }
}
@media (max-height: 520px) {
  #joy { width: 124px; height: 124px; }
  #tcUse { width: 100px; height: 100px; }
  #tcUse b { font-size: 17px; }
  .tcRound { width: 54px; height: 54px; font-size: 14px; }
  #tcShouts { bottom: 112px; }
}
/* 手机横屏：高度很矮，按钮说明小字收起来，一屏放下整个菜单 */
@media (max-height: 460px) {
  .panel-left { padding: 12px 16px; gap: 7px; }
  .screen.side { gap: 7px; }
  h1 { font-size: 21px; }
  .mode small { display: none; }
  .big { padding: 9px 14px; font-size: 16px; box-shadow: 0 3px 0 #8a2d0c; }
  .small { padding: 7px 12px; font-size: 14px; }
  .roomCode { font-size: 30px; letter-spacing: 6px; }
  #charScreen .row { gap: 6px; }
  .sw { width: 26px; height: 26px; }
  .note { font-size: 12px; }
}
/* 触屏时“手里拿着什么”挪到摇杆上方，不被挡住 */
body.touch .vpHand { bottom: 178px !important; left: 18px !important; }
@media (max-height: 520px) { body.touch .vpHand { bottom: 150px !important; } }
/* 手机竖屏：捏人、商城的面板放到下半屏，上半屏露出人物 */
@media (orientation: portrait) and (max-width: 600px) {
  #charScreen.panel-left { top: auto; bottom: 10px; transform: translateX(-50%); max-height: 56vh; }
  #storeScreen.modal.left { align-items: flex-end; padding-bottom: 10px; background: none; }
  #storeScreen .card { max-height: 56vh; }
}
@media (max-width: 600px) {
  body.touch #recipes { top: 64px; right: 8px; }
  #hudTop, #mkTop { max-width: calc(100vw - 110px); }
}
