/* ===== 穹狼 · 局域网聊天室 深色主题 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --rail-bg: #14171b;
  --side-bg: #1c2026;
  --main-bg: #21262c;
  --panel: #262c33;
  --panel-2: #2b323a;
  --border: #333a43;
  --text: #e6e9ec;
  --muted: #8b939e;
  --accent: #46a06e;
  --accent-2: #3a8a5e;
  --danger: #d95f4b;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--main-bg);
  color: var(--text);
  overflow: hidden;
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.app { display: flex; height: 100vh; }

/* ---------- 图标栏 ---------- */
.rail {
  width: 64px; background: var(--rail-bg);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0; gap: 4px; flex-shrink: 0;
}
.rail-logo, .brand-logo, .join-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #4bb583, #2f7d55);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff; margin-bottom: 8px;
}
.rail-btn {
  width: 52px; padding: 7px 0 5px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 17px; color: var(--muted);
}
.rail-btn span { font-size: 11px; }
.rail-btn:hover { background: var(--panel); color: var(--text); }
.rail-btn.active { background: var(--panel-2); color: var(--text); }
.rail-spacer { flex: 1; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 264px; background: var(--side-bg); flex-shrink: 0;
  display: flex; flex-direction: column; border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.brand-logo { margin: 0; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.side-section { margin-top: 14px; }
.side-title {
  font-size: 12px; color: var(--muted); padding: 0 6px 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.online-count { font-weight: 400; }

.side-item {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 9px; text-align: left; color: var(--text);
}
.side-item:hover { background: var(--panel); }
.side-item.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.side-item i { font-style: normal; font-size: 17px; width: 22px; text-align: center; }
.side-item-text { flex: 1; min-width: 0; }
.side-item-text b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item-text span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item em { font-style: normal; font-size: 10px; color: var(--muted); background: var(--panel-2); padding: 2px 6px; border-radius: 8px; flex-shrink: 0; }

.user-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; width: 100%; text-align: left; }
.user-row:hover { background: var(--panel); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* 访问地址卡片 */
.addr-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-top: 18px; }
.addr-title { font-size: 12px; color: var(--muted); }
.addr-url { font-size: 14px; font-weight: 700; color: #7fd1a4; margin: 6px 0 4px; word-break: break-all; }
.addr-desc { font-size: 11px; color: var(--muted); line-height: 1.5; }
.addr-copy {
  width: 100%; margin-top: 10px; padding: 7px 0; border-radius: 8px;
  background: var(--panel-2); font-size: 12px; color: var(--text);
}
.addr-copy:hover { background: #333b44; }

.me-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.me-name { font-size: 13px; font-weight: 600; }
.me-status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 2px; }

/* ---------- 主聊天区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.chat-title { font-size: 17px; font-weight: 700; }
.chat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chat-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 14px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
}
.chip:hover { background: var(--panel-2); }
.addr-pill {
  font-size: 11px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px;
  display: inline-flex; align-items: center; gap: 6px;
}
.addr-pill b { color: #7fd1a4; font-weight: 600; }
.mini-copy { font-size: 11px; color: var(--text); background: var(--panel-2); border-radius: 8px; padding: 2px 8px; }
.mini-copy:hover { background: #39414b; }
.conn-pill { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.conn-pill.off .dot { background: var(--danger); }
.conn-pill.off { color: var(--danger); }

/* 消息区 */
.messages { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 78%; }
.msg .avatar { width: 36px; height: 36px; }
.msg-body { min-width: 0; }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; }
.msg-name { font-weight: 600; font-size: 12px; }
.msg-bubble {
  background: var(--panel-2); border-radius: 4px 14px 14px 14px;
  padding: 9px 13px; line-height: 1.6; word-break: break-word; white-space: pre-wrap;
}
.msg.own { align-self: flex-end; flex-direction: row-reverse; }
.msg.own .msg-meta { flex-direction: row-reverse; }
.msg.own .msg-bubble { background: #2e5c45; border-radius: 14px 4px 14px 14px; }
.msg-system {
  align-self: center; font-size: 12px; color: var(--muted);
  background: rgba(255,255,255,0.05); padding: 4px 14px; border-radius: 12px;
}
.msg-private-tag { font-size: 10px; color: #e0b13d; border: 1px solid #e0b13d55; border-radius: 8px; padding: 1px 6px; }

/* ---------- 输入区 ---------- */
.composer { border-top: 1px solid var(--border); padding: 8px 16px 10px; position: relative; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tool {
  font-size: 12px; color: var(--muted); padding: 5px 10px;
  border-radius: 8px; background: var(--panel);
}
.tool:hover { color: var(--text); background: var(--panel-2); }
.tool-sep { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }

.input-row { display: flex; gap: 10px; align-items: flex-end; }
#input {
  flex: 1; resize: none; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 14px;
  font-family: inherit; line-height: 1.5; max-height: 120px; outline: none;
}
#input:focus { border-color: var(--accent); }
.send-btn {
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 12px; padding: 12px 22px; flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-2); }
.input-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; padding: 0 2px; }

/* 表情面板 */
.emoji-panel {
  display: none; position: absolute; bottom: 100%; left: 16px; margin-bottom: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px; grid-template-columns: repeat(8, 1fr); gap: 2px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45); z-index: 20; width: 320px;
}
.emoji-panel.open { display: grid; }
.emoji-panel button { font-size: 20px; padding: 5px; border-radius: 8px; }
.emoji-panel button:hover { background: var(--panel); }

/* ---------- 加入弹窗 ---------- */
.join-mask {
  position: fixed; inset: 0; background: rgba(10,12,14,0.82); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.join-mask.hidden { display: none; }
.join-card {
  background: var(--side-bg); border: 1px solid var(--border); border-radius: 18px;
  padding: 34px 36px; width: 360px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.join-logo { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; margin: 0; }
.join-card h1 { font-size: 19px; }
.join-card p { font-size: 12px; color: var(--muted); }
.join-card input {
  width: 100%; margin-top: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px; color: var(--text); font-size: 14px; outline: none;
  text-align: center;
}
.join-card input:focus { border-color: var(--accent); }
.join-card button {
  width: 100%; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  border-radius: 10px; padding: 11px 0; margin-top: 4px;
}
.join-card button:hover { background: var(--accent-2); }
.join-status { font-size: 12px; color: var(--danger); min-height: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 20px; border-radius: 12px; font-size: 13px; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 特效层 ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.fx-confetti {
  position: absolute; top: -14px; width: 8px; height: 14px; border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(108vh) rotate(720deg); opacity: .9; }
}
.fx-rainbow {
  position: absolute; inset: 0;
  background: linear-gradient(120deg, rgba(255,0,0,.16), rgba(255,165,0,.16), rgba(255,255,0,.16), rgba(0,200,0,.16), rgba(0,120,255,.16), rgba(160,0,255,.16));
  animation: rainbow-fade 2.4s ease forwards;
}
@keyframes rainbow-fade {
  0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; }
}
.fx-rocket {
  position: absolute; bottom: -90px; font-size: 64px;
  animation: rocket-fly 2.6s cubic-bezier(.3,.7,.4,1) forwards;
  filter: drop-shadow(0 0 14px rgba(255,150,60,.7));
}
@keyframes rocket-fly {
  0% { transform: translateY(0) rotate(-12deg); opacity: 1; }
  100% { transform: translateY(-118vh) translateX(10vw) rotate(8deg); opacity: 0; }
}
.fx-like {
  position: absolute; bottom: 90px; font-size: 30px;
  animation: like-float 2s ease-out forwards;
}
@keyframes like-float {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-46vh) scale(1.25); opacity: 0; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #3a424b; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* 小屏适配 */
@media (max-width: 900px) {
  .rail { display: none; }
  .sidebar { width: 220px; }
}
@media (max-width: 680px) {
  .sidebar { display: none; }
}

/* ---------- 老师权限相关 ---------- */
.role-badge {
  font-size: 10px; color: #e0b13d; border: 1px solid #e0b13d66;
  border-radius: 8px; padding: 0 5px; margin-left: 4px; flex-shrink: 0;
}
.muted-badge {
  font-size: 10px; color: var(--danger); border: 1px solid #d95f4b66;
  border-radius: 8px; padding: 0 5px; margin-left: 4px; flex-shrink: 0;
}
.admin-actions { display: none; gap: 4px; flex-shrink: 0; }
.user-row:hover .admin-actions { display: inline-flex; }
.admin-btn {
  font-size: 11px; padding: 2px 7px; border-radius: 7px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border);
}
.admin-btn:hover { color: var(--text); background: #39414b; }
.admin-btn.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

/* 游戏开关（老师可见） */
.game-toggle {
  padding: 5px 11px; border-radius: 14px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--accent); color: #7fd1a4;
}
.game-toggle.off { border-color: var(--danger); color: var(--danger); }

/* 游戏被禁止时学生端按钮置灰 */
.chip.disabled, .tool.disabled, .side-item.game.disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* 游戏邀请消息 */
.msg-game {
  align-self: center; width: auto; max-width: 90%;
  background: linear-gradient(135deg, #2b323a, #263030);
  border: 1px solid var(--accent); border-radius: 14px;
  padding: 10px 18px; text-align: center; font-size: 13px; line-height: 1.6;
}
.msg-game b { color: #7fd1a4; }
.msg-game .msg-game-time { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* 我被禁言时输入区提示 */
.composer.muted #input { background: #2a2222; border-color: var(--danger); }
.muted-tip {
  display: none; font-size: 12px; color: var(--danger);
  padding: 4px 2px 8px;
}
.composer.muted .muted-tip { display: block; }

/* ---------- 球球大作战 全屏游戏层 ---------- */
.game-mask {
  position: fixed; inset: 0; background: #181c21; z-index: 120;
  display: none;
}
.game-mask.open { display: block; }
#gameCanvas { position: absolute; inset: 0; cursor: crosshair; }

.game-hud {
  position: absolute; top: 16px; left: 16px;
  background: rgba(20,23,27,0.82); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 16px; font-size: 13px;
  display: flex; flex-direction: column; gap: 5px; color: var(--text);
}
.game-hud b { color: #7fd1a4; font-size: 15px; margin: 0 2px; }
.boost-on { color: #f7b731; font-size: 12px; display: none; }

.game-board {
  position: absolute; top: 16px; right: 76px; min-width: 170px;
  background: rgba(20,23,27,0.82); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; font-size: 12px;
}
.board-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.board-row { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; }
.board-row.me { color: #7fd1a4; }
.board-row b { color: #e0b13d; }

.game-tip {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--muted); background: rgba(20,23,27,0.75);
  padding: 7px 18px; border-radius: 16px; border: 1px solid var(--border);
  white-space: nowrap;
}
.game-exit {
  position: absolute; top: 16px; right: 16px;
  background: var(--danger); color: #fff; font-size: 13px;
  padding: 8px 16px; border-radius: 10px;
}
.game-exit:hover { filter: brightness(1.15); }
.game-msg {
  position: absolute; top: 72px; left: 50%; transform: translateX(-50%);
  font-size: 14px; color: #fff; background: rgba(20,23,27,0.85);
  border: 1px solid var(--accent); padding: 8px 22px; border-radius: 14px;
  opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap;
}
.game-msg.show { opacity: 1; }

/* ---------- 道具栏 ---------- */
.inv-row { display: flex; gap: 10px; margin-top: 2px; }
.inv-item {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 14px; background: rgba(255,255,255,0.06);
  padding: 3px 8px; border-radius: 8px; border: 1px solid var(--border);
}
.inv-item b { color: #7fd1a4; font-size: 13px; }
.inv-item i {
  font-style: normal; font-size: 10px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 2px;
}
