* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c1b22; color: #f4f1ea;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif; font-size: 14px; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 9px 16px; background: rgba(255,255,255,.14); color: inherit; transition: background .15s, transform .1s; }
button:hover { background: rgba(255,255,255,.24); }
button:active { transform: scale(.97); }
button.primary { background: #f2a23a; color: #2a1a05; font-weight: 700; }
button.primary:hover { background: #ffb650; }
input { border: 1px solid rgba(255,255,255,.2); border-radius: 10px; padding: 10px 12px; background: rgba(0,0,0,.35); color: inherit; outline: none; width: 100%; }
input:focus { border-color: #f2a23a; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #3b3550, #17161d); z-index: 20; }
.card { width: min(420px, 90vw); padding: 32px; border-radius: 20px; background: rgba(255,255,255,.07); backdrop-filter: blur(8px); text-align: center; display: grid; gap: 12px; }
.card h1 { margin: 0; font-size: 30px; }
.sub { margin: 0; opacity: .75; }
.warn { margin: 0; color: #ffc46b; font-size: 13px; }
.err { margin: 0; color: #ff7b7b; min-height: 1.2em; font-size: 13px; }

/* 大厅 */
#lobbyTitle { position: fixed; left: 32px; top: 24px; max-width: 46vw; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
#lobbyTitle h1 { margin: 0 0 6px; font-size: 30px; }
#hello { font-size: 16px; }
#medalBox { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.medal { padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.3); font-size: 12px; opacity: .45; }
.medal.got { opacity: 1; background: rgba(242,162,58,.3); outline: 1px solid rgba(242,162,58,.7); }
.tip { margin-top: 10px; font-size: 12px; opacity: .6; }
#editor { position: fixed; right: 0; top: 0; bottom: 0; width: min(460px, 52vw); padding: 18px 18px 0; background: rgba(22,21,30,.82); backdrop-filter: blur(10px); display: flex; flex-direction: column; }
#editor h2 { margin: 0 0 10px; font-size: 18px; }
#editorRows { flex: 1; overflow-y: auto; padding-right: 6px; }
.row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.row > label { flex: 0 0 68px; padding-top: 5px; opacity: .85; }
.opts { display: flex; flex-wrap: wrap; gap: 5px; }
.sw { width: 26px; height: 26px; border-radius: 50%; padding: 0; border: 2px solid rgba(255,255,255,.25); }
.sw.none { background: transparent; font-size: 11px; width: auto; padding: 0 9px; border-radius: 13px; }
.txt { padding: 4px 10px; border-radius: 13px; font-size: 12.5px; border: 2px solid transparent; }
.sw.on, .txt.on { border-color: #f2a23a; box-shadow: 0 0 0 2px rgba(242,162,58,.35); }
.txt.on, .sw.none.on { background: rgba(242,162,58,.28); }
.editorBtns { display: flex; gap: 10px; padding: 14px 0; }
.editorBtns .primary { flex: 1; font-size: 16px; padding: 12px; }

/* 游戏内 */
#status { position: fixed; left: 14px; top: 14px; width: 250px; box-sizing: border-box; padding: 12px 14px; border-radius: 14px; background: rgba(18,18,26,.62); backdrop-filter: blur(6px); line-height: 1.7; }
#roomInfo { font-size: 12px; opacity: .75; }
#bodyBar { display: flex; gap: 3px; margin: 4px 0 6px; }
#bodyBar i { flex: 1; height: 9px; border-radius: 3px; background: rgba(255,255,255,.15); }
#bodyBar i.on { outline: 2px solid #fff; }
#alert { font-size: 12.5px; color: #ffd27a; line-height: 1.45; }
#alert.danger { color: #ff8a8a; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .45; } }
#help { position: fixed; left: 14px; bottom: 14px; max-width: calc(100vw - 370px); padding: 8px 12px; border-radius: 12px; background: rgba(18,18,26,.5); font-size: 12px; line-height: 1.6; opacity: .85; }
#help b { color: #ffd27a; }
#leaveBtn { position: fixed; left: 276px; top: 14px; font-size: 12px; padding: 7px 12px; background: rgba(18,18,26,.62); }
#progress { position: fixed; left: calc(50% - 160px - 150px); bottom: 110px; width: 320px; text-align: center; text-shadow: 0 1px 4px #000; }
#progress .track { height: 10px; border-radius: 5px; background: rgba(0,0,0,.45); overflow: hidden; margin-top: 4px; }
#progressFill { height: 100%; width: 0; background: #f2a23a; }
#toasts { position: fixed; left: 0; right: 320px; top: 70px; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast { padding: 12px 22px; border-radius: 14px; background: linear-gradient(135deg, #f2a23a, #e2622f); color: #2a1205; font-weight: 700; font-size: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.4); animation: pop 4s forwards; }
@keyframes pop { 0% { transform: scale(.5); opacity: 0; } 8% { transform: scale(1.08); opacity: 1; } 14% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
#floats { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font-size: 20px; font-weight: 700; text-shadow: 0 2px 4px #000, 0 0 2px #000; white-space: nowrap; }

#chat { position: fixed; right: 0; top: 0; bottom: 0; width: 320px; display: flex; flex-direction: column; background: rgba(18,18,26,.72); backdrop-filter: blur(8px); border-left: 1px solid rgba(255,255,255,.08); }
#chatHead { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
#chatCount { font-weight: 400; font-size: 12px; opacity: .7; margin-left: 6px; }
#resetBar { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.08); display: grid; gap: 5px; }
#resetBtn { width: 100%; font-size: 13px; padding: 7px 10px; }
#resetBtn.on { background: #f2a23a; color: #2a1a05; font-weight: 700; }
#resetInfo { font-size: 12px; opacity: .7; text-align: center; }
#chatLog { flex: 1; overflow-y: auto; padding: 10px 14px; line-height: 1.55; word-break: break-word; }
.msg { margin-bottom: 4px; }
.msg .who { color: #8fd0ff; font-weight: 700; }
.msg.me .who { color: #ffd27a; }
.msg.ghost { opacity: .75; font-style: italic; }
.msg.sys { color: #c9c2ad; font-size: 12.5px; }
#chatInput { margin: 10px; width: auto; }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }

/* 房间按钮 */
.roomBtns { display: flex; gap: 8px; }
.roomBtns input { flex: 1; min-width: 0; padding: 8px 10px; }
#lobbyErr { padding-bottom: 8px; }
.barRow { display: flex; gap: 8px; }
.barRow #resetBtn { flex: 1; width: auto; }
#friendsBtn { font-size: 13px; padding: 7px 10px; white-space: nowrap; }
#friendsBtn.hot { background: #e2622f; color: #fff; }
#afkBanner { position: fixed; left: calc(50% - 160px); transform: translateX(-50%); top: 120px; padding: 12px 22px; border-radius: 14px; background: rgba(18,18,26,.82); font-size: 16px; font-weight: 700; color: #ffd27a; animation: blink 1.6s infinite; z-index: 5; }

/* 好友面板 */
button.mini { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
button.mini.hot { background: #e2622f; color: #fff; }
#friends { position: fixed; width: 310px; max-height: 62vh; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 16px; background: rgba(22,21,30,.9); backdrop-filter: blur(10px); box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 8; }
#friends.lobby { left: 24px; bottom: 24px; }
#friends.lobby #frClose { display: none; }
#friends.game { right: 334px; top: 14px; }
#frHead { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
#frCount { font-weight: 400; font-size: 12px; opacity: .7; margin-left: 4px; }
#frList { overflow-y: auto; min-height: 30px; }
.frRow { display: flex; align-items: center; gap: 5px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.frRow.req { background: rgba(242,162,58,.14); padding: 6px 8px; border-radius: 8px; border: 0; margin-bottom: 4px; }
.frInfo { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.frName { font-weight: 700; }
.frRow.req .frName { flex: 1; font-weight: 400; font-size: 13px; }
.frStatus { font-size: 11.5px; opacity: .65; width: 100%; padding-left: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd068; flex: none; }
.frRow.off .dot { background: #666; }
.frRow.off .frName { opacity: .55; }
.frEmpty { font-size: 12.5px; opacity: .65; line-height: 1.5; padding: 4px 0; }
#frAdd { display: flex; gap: 6px; }
#frAdd input, #frChatInput { padding: 6px 9px; font-size: 13px; }
#frChat { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; }
#frChatHead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
#frChatLog { height: 120px; overflow-y: auto; font-size: 13px; line-height: 1.5; word-break: break-word; }
#frChatLog .mine { color: #ffd27a; }
.addFr { padding: 0 6px; margin: 0 4px 0 0; font-size: 12px; border-radius: 6px; line-height: 1.4; }

/* 邀请与提示 */
#invites { position: fixed; left: 50%; transform: translateX(-50%); top: 16px; display: grid; gap: 8px; z-index: 30; }
.invite { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: #2d2a3c; box-shadow: 0 6px 24px rgba(0,0,0,.5); outline: 2px solid #f2a23a; }
#tips { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; display: grid; justify-items: center; gap: 6px; pointer-events: none; z-index: 30; }
.tipItem { padding: 8px 16px; border-radius: 12px; background: rgba(18,18,26,.9); font-size: 13.5px; animation: pop 4s forwards; max-width: 80vw; }
.roomBtns + .roomBtns { margin-top: 8px; }
#privLabel { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; opacity: .9; }
#privLabel input { width: 16px; height: 16px; padding: 0; accent-color: #f2a23a; cursor: pointer; }

/* LOGO */
.logo { display: block; width: 340px; max-width: 42vw; height: auto; margin: -8px 0 6px -10px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
.card .logo { width: 300px; max-width: 80%; margin: 0 auto 4px; }

/* 付费饰品 */
.premHead { margin: 16px 0 2px; padding: 8px 10px; border-radius: 10px; background: linear-gradient(90deg, rgba(242,162,58,.32), rgba(242,162,58,.06)); font-weight: 700; }
.premNote { font-size: 12px; opacity: .65; padding: 4px 2px 6px; }
.row.prem > label { flex-basis: 96px; font-size: 13px; }
.row.prem.locked > label { color: #ffc46b; }

/* 账号 */
.tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(0,0,0,.3); }
.tabs button { flex: 1; background: transparent; font-size: 13px; padding: 7px 4px; }
.tabs button.on { background: rgba(255,255,255,.16); font-weight: 700; }
#authForm, #pwForm { display: grid; gap: 12px; }
#acctBar { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; }
#pwHint.need { color: #ffc46b; }
#pwModal { background: rgba(10,10,16,.72); z-index: 25; }

/* 举报与屏蔽 */
.msg .who.click { cursor: pointer; }
.msg .who.click:hover { text-decoration: underline; }
.msg .acts { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
#blockInfo { float: right; font-weight: 400; }

/* 英文界面：文字更长，标签列放宽一些 */
html[lang="en"] .row > label { flex-basis: 108px; font-size: 13px; }
html[lang="en"] .row.prem > label { flex-basis: 132px; font-size: 12.5px; }
html[lang="en"] #status { width: 270px; }
html[lang="en"] #leaveBtn { left: 298px; }
.langBtn { opacity: .85; }
#acctBar { flex-wrap: wrap; row-gap: 4px; max-width: 420px; }
#acctBar button { white-space: nowrap; }
#pwHint { flex-basis: 100%; }
#pwHint:empty { display: none; }

/* ---------------- 触屏操作 ---------------- */
#touchUI, #touchHelp, #lobbyFr { display: none; }
body.touch #touchUI { display: block; }
body.touch #help { display: none; }
body.touch #touchHelp { display: block; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(6px + env(safe-area-inset-bottom)); max-width: 70vw; padding: 4px 10px; border-radius: 10px; background: rgba(18,18,26,.5); font-size: 11px; opacity: .75; text-align: center; pointer-events: none; }
#stick { position: fixed; left: calc(22px + env(safe-area-inset-left)); bottom: calc(34px + env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.3); touch-action: none; z-index: 6; }
#knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: rgba(255,255,255,.55); pointer-events: none; }
.tbtn { position: fixed; width: 66px; height: 66px; padding: 0; border-radius: 50%; font-size: 26px; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.3); touch-action: none; user-select: none; -webkit-user-select: none; z-index: 6; }
.tbtn:active { background: rgba(242,162,58,.6); }
#jumpBtn { right: calc(26px + env(safe-area-inset-right)); bottom: calc(46px + env(safe-area-inset-bottom)); }
#dumpBtn { right: calc(104px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 56px; height: 56px; font-size: 22px; }
#chatToggle { display: none; right: calc(14px + env(safe-area-inset-right)); top: calc(12px + env(safe-area-inset-top)); width: 46px; height: 46px; font-size: 20px; z-index: 9; }
body.touch, body.touch #c { touch-action: none; overscroll-behavior: none; }
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch input { -webkit-user-select: text; user-select: text; }

/* ---------------- 窄屏（手机）布局 ---------------- */
@media (max-width: 760px) {
  /* 游戏内：聊天栏默认收起，点 💬 从右侧滑出 */
  #chat { width: min(320px, 86vw); transform: translateX(100%); transition: transform .2s; z-index: 8; padding-top: env(safe-area-inset-top); }
  body.chatOpen #chat { transform: none; }
  #chatToggle { display: block; }
  body:not(.touch) #chatToggle { display: none; }
  body:not(.touch) #chat { transform: none; width: 220px; }
  #status { width: min(250px, 62vw) !important; font-size: 12.5px; padding: 8px 10px; line-height: 1.5; left: calc(8px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top)); }
  #leaveBtn { left: auto !important; right: calc(68px + env(safe-area-inset-right)); top: calc(14px + env(safe-area-inset-top)); }
  #progress { left: 50%; transform: translateX(-50%); width: min(300px, 70vw); bottom: 190px; }
  #toasts { right: 0; }
  #afkBanner { left: 50%; width: 80vw; font-size: 13px; text-align: center; }
  #friends.game { right: 8px; left: 8px; width: auto; top: 64px; }
  #help { max-width: calc(100vw - 20px); }

  /* 大厅：形象编辑器放到下半屏，小人在上半屏 */
  #editor { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 56vh; padding: 12px 12px 0; border-radius: 16px 16px 0 0; }
  #editor h2 { font-size: 15px; margin-bottom: 6px; }
  #lobbyTitle { left: 12px; top: calc(8px + env(safe-area-inset-top)); max-width: 62vw; }
  #lobbyTitle .logo { width: 170px; max-width: 46vw; margin: 0 0 2px -4px; }
  #lobbyTitle .tip, #medalBox { display: none; }
  #hello { font-size: 13px; }
  #acctBar { font-size: 11px; max-width: 60vw; }
  #friends.lobby { left: 8px; right: 8px; top: calc(56px + env(safe-area-inset-top)); bottom: auto; width: auto; max-height: 40vh; padding: 10px; font-size: 12.5px; display: none; }
  body.frOpen #friends.lobby { display: flex; }
  #friends.lobby #frClose { display: inline-block; }
  #lobbyFr { display: block; position: fixed; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); z-index: 7; font-size: 13px; padding: 7px 12px; background: rgba(18,18,26,.7); }
  #lobbyFr.hot { background: #e2622f; color: #fff; }
  .row > label { flex-basis: 62px !important; font-size: 12.5px; }
  .row.prem > label { flex-basis: 88px !important; }
  .card { padding: 22px 18px; }
}
/* 横屏的手机：屏幕很矮，操作说明和状态栏再收一点 */
@media (max-height: 480px) {
  #touchHelp { display: none !important; }
  #stick { width: 112px; height: 112px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  #status { line-height: 1.4; }
  #alert { font-size: 11.5px; }
}

/* 音乐开关 */
.barRow .musicBtn { font-size: 13px; padding: 7px 10px; }
