/* ============================================================
   星际内鬼 — 样式
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #070a14;
  --panel: rgba(18, 24, 44, 0.9);
  --panel-line: #2f3e63;
  --accent: #7ee0ff;
  --danger: #ff5b5b;
  --gold: #ffd60a;
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: #eaf0ff;
  user-select: none;
  -webkit-user-select: none;
}
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #070a14; }
.hidden { display: none !important; }

/* ---------- 覆盖层通用 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 14, 0.75); backdrop-filter: blur(4px);
  padding: 20px;
}

/* ---------- 主菜单 ---------- */
.menu-card {
  background: linear-gradient(160deg, #141b34, #0d1226);
  border: 1px solid var(--panel-line);
  border-radius: 20px; padding: 28px 32px; width: min(720px, 96vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  text-align: center;
}
.menu-card h1 { font-size: 40px; letter-spacing: 2px; }
.menu-card h1 .sub { color: var(--accent); font-size: 18px; letter-spacing: 4px; display:block; margin-top:4px; opacity:.8; }
.tagline { color: #9fb0d6; margin: 8px 0 20px; }
.menu-main { display: flex; gap: 24px; align-items: center; justify-content: center; flex-wrap: wrap; }
.preview-box { background: #0a0f22; border: 1px solid var(--panel-line); border-radius: 16px; padding: 8px; }
.picker-box { flex: 1; min-width: 260px; text-align: left; }
.picker-box h3 { font-size: 14px; color: #9fb0d6; margin: 10px 0 8px; font-weight: 600; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: transform .1s; box-shadow: inset -4px -6px 0 rgba(0,0,0,0.25);
}
.swatch:hover { transform: scale(1.1); }
.swatch.sel { border-color: #fff; transform: scale(1.12); }
.hats .hat-opt {
  background: #1a2340; color: #cdd7f5; border: 1px solid var(--panel-line);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.hats .hat-opt.sel { background: var(--accent); color: #08121a; border-color: var(--accent); font-weight: 700; }
.big-btn {
  margin-top: 22px; background: linear-gradient(180deg, #ffd60a, #f0a808);
  color: #2a1e00; border: none; border-radius: 14px; padding: 14px 40px;
  font-size: 20px; font-weight: 800; cursor: pointer; letter-spacing: 1px;
  box-shadow: 0 6px 0 #a86f00; transition: transform .05s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #a86f00; }
.help { margin-top: 18px; font-size: 13px; color: #8496bf; line-height: 1.7; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#hud button { pointer-events: auto; }

#top-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(520px, 90vw); }
#taskbar {
  position: relative; height: 22px; background: #10182e; border: 1px solid var(--panel-line);
  border-radius: 12px; overflow: hidden;
}
#taskbar-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, #21d07a, #7ee0ff); transition: width .3s; }
#taskbar-text { position: relative; z-index: 2; display: block; text-align: center; line-height: 22px; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#alive-text { text-align: center; margin-top: 6px; font-size: 13px; color: #cdd7f5; text-shadow: 0 1px 3px #000; }

#role-panel {
  position: absolute; top: 12px; left: 12px; background: var(--panel);
  border: 1px solid var(--panel-line); border-radius: 12px; padding: 10px 14px; min-width: 180px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.role-head { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
#ghost-tag { color: #b9c6ef; font-weight: 500; }
#task-list { list-style: none; font-size: 13px; }
#task-list li { padding: 2px 0; color: #dfe7ff; }
#task-list li.done { color: #21d07a; text-decoration: line-through; opacity: .8; }

#banner {
  position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
  font-size: 26px; font-weight: 800; text-shadow: 0 2px 10px #000; text-align: center;
  padding: 10px 20px; white-space: nowrap;
}
#banner.show { animation: pop .3s ease; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

#bottom-right { position: absolute; right: 16px; bottom: 16px; text-align: right; }
#kill-info { font-size: 14px; color: var(--danger); font-weight: 700; margin-bottom: 6px; text-shadow: 0 1px 3px #000; }
#action-hint { font-size: 13px; color: #cdd7f5; margin-bottom: 8px; text-shadow: 0 1px 3px #000; min-height: 16px; }
#action-btns { display: flex; gap: 10px; justify-content: flex-end; }
.act-btn {
  background: linear-gradient(180deg, #2ea8ff, #1a72d8); color: #fff; border: none;
  border-radius: 50%; width: 74px; height: 74px; font-size: 15px; font-weight: 800;
  cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.4); border: 2px solid rgba(255,255,255,0.3);
}
.act-btn.danger { background: linear-gradient(180deg, #ff5b5b, #c81e1e); }
.act-btn:active { transform: translateY(3px); }

/* ---------- 聊天 ---------- */
.chat-hud {
  position: absolute; left: 12px; bottom: 12px; width: min(320px, 42vw);
  pointer-events: none;
}
#chat-log {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 160px; overflow: hidden; font-size: 12px;
  text-shadow: 0 1px 3px #000;
}
.chat-line { color: #dfe7ff; line-height: 1.35; word-break: break-word; }
.chat-line .chat-who { font-weight: 700; }
.chat-line.system { color: var(--gold); font-weight: 700; }
.chat-line.dead { opacity: .6; font-style: italic; }

/* 会议内的聊天区 */
.meeting-chat { margin-top: 14px; border-top: 1px solid var(--panel-line); padding-top: 12px; }
.chat-scroll {
  height: 130px; overflow-y: auto; background: #0a1024; border: 1px solid var(--panel-line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 4px;
}
.chat-scroll .chat-line { color: #cdd7f5; }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chat-quick button {
  background: #1a2340; color: #cdd7f5; border: 1px solid var(--panel-line);
  border-radius: 14px; padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.chat-quick button:hover { background: #24305a; }
.chat-input-row { display: flex; gap: 8px; }
#chat-input {
  flex: 1; background: #0a1024; border: 1px solid var(--panel-line); border-radius: 10px;
  padding: 9px 12px; color: #eaf0ff; font-size: 14px; outline: none;
}
#chat-input:focus { border-color: var(--accent); }
#chat-input:disabled { opacity: .5; }
#chat-send {
  background: linear-gradient(180deg,#2ea8ff,#1a72d8); color: #fff; border: none;
  border-radius: 10px; padding: 0 18px; font-size: 14px; font-weight: 700; cursor: pointer;
}
#chat-send:disabled { opacity: .5; cursor: default; }

/* ---------- 任务小游戏 ---------- */
.mg-card {
  background: #121a30; border: 1px solid var(--panel-line); border-radius: 16px;
  width: min(460px, 94vw); padding: 0; overflow: hidden;
}
.mg-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: #0e1530; border-bottom: 1px solid var(--panel-line);
  font-size: 17px; font-weight: 700;
}
.x-btn { background: transparent; color: #9fb0d6; border: none; font-size: 20px; cursor: pointer; }
#minigame-body { padding: 24px; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.mg-hint { font-size: 13px; color: #9fb0d6; text-align: center; }
.mg-done { font-size: 28px; font-weight: 800; color: #21d07a; }

/* 接线 */
.mg-wiring { position: relative; display: flex; justify-content: space-between; width: 100%; height: 220px; }
.wire-col { display: flex; flex-direction: column; justify-content: space-between; height: 100%; z-index: 2; }
.wire-node { width: 40px; height: 40px; border-radius: 8px; cursor: grab; border: 2px solid rgba(255,255,255,0.3); }
.wire-node.done { opacity: .5; cursor: default; }
.wire-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

/* 刷卡 */
.mg-swipe { width: 100%; }
.swipe-track { position: relative; height: 70px; background: #0a1024; border: 2px dashed var(--panel-line); border-radius: 12px; overflow: hidden; }
.swipe-card { position: absolute; top: 8px; left: 4px; width: 54px; height: 54px; background: linear-gradient(180deg,#ffd60a,#e0a000); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: grab; }

/* 点击网格 */
.mg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.grid-cell { aspect-ratio: 1; font-size: 28px; background: #0a1024; border: 1px solid var(--panel-line); border-radius: 12px; cursor: pointer; }
.grid-cell.cleared { background: #123a24; color: #21d07a; }

/* 进度 / 按住 */
.mg-progress { width: 100%; text-align: center; }
.progress-bar { height: 26px; background: #0a1024; border: 1px solid var(--panel-line); border-radius: 13px; overflow: hidden; margin: 10px 0; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #21d07a, #7ee0ff); transition: width .05s; }
.progress-label { font-size: 14px; color: #cdd7f5; }
.hold-btn { background: linear-gradient(180deg,#2ea8ff,#1a72d8); color:#fff; border:none; border-radius:12px; padding:14px 30px; font-size:16px; font-weight:700; cursor:pointer; }

/* ---------- 会议 ---------- */
.meeting-card {
  background: linear-gradient(160deg, #16233f, #0c1226); border: 1px solid var(--panel-line);
  border-radius: 18px; width: min(680px, 96vw); max-height: 92vh; overflow-y: auto; padding: 22px;
}
.meeting-card h2 { text-align: center; margin-bottom: 6px; }
.meeting-info { display: flex; justify-content: space-between; color: #9fb0d6; font-size: 13px; margin-bottom: 14px; }
#meeting-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.vote-card {
  background: #0e1530; border: 2px solid var(--panel-line); border-radius: 12px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; cursor: pointer; color: #eaf0ff;
  transition: border-color .1s, transform .1s;
}
.vote-card:hover:not(.locked):not(.disabled) { border-color: var(--accent); transform: translateY(-2px); }
.vote-card.myvote { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.vote-card.disabled { opacity: .6; cursor: default; }
.vote-card.locked { cursor: default; }
.vote-name { font-size: 13px; margin-top: 4px; }
.vote-tally { color: var(--danger); font-size: 12px; height: 16px; letter-spacing: -2px; }
.meeting-foot { display: flex; justify-content: center; margin-top: 16px; }
.skip-btn { background: #2a3557; color: #cdd7f5; border: 1px solid var(--panel-line); border-radius: 10px; padding: 10px 26px; font-size: 15px; cursor: pointer; }
.skip-btn.myvote { background: var(--gold); color: #2a1e00; font-weight: 700; }
#meeting-result { text-align: center; margin-top: 16px; font-size: 18px; font-weight: 700; color: var(--gold); }

/* ---------- 结算 ---------- */
.result-card {
  background: linear-gradient(160deg, #16233f, #0c1226); border: 1px solid var(--panel-line);
  border-radius: 18px; padding: 32px 40px; text-align: center; width: min(460px, 94vw);
}
.result-card h1 { font-size: 38px; margin-bottom: 10px; }
.result-card p { margin: 8px 0; color: #cdd7f5; }
.result-card .imps { color: var(--danger); font-weight: 700; }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .menu-card h1 { font-size: 30px; }
  .act-btn { width: 64px; height: 64px; font-size: 13px; }
  #role-panel { min-width: 140px; font-size: 12px; }
}
