:root {
  --bg: #070a10;
  --panel: rgba(16, 22, 34, 0.92);
  --line: rgba(120, 170, 255, 0.18);
  --text: #e8f0ff;
  --muted: #8fa3c0;
  --accent: #4ec9ff;
  --accent2: #ff6b9a;
  --ok: #4ee5a0;
  --warn: #ffcc55;
  --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(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(circle at 50% 40%, #131c2b 0%, #070a10 70%);
}

.hidden { display: none !important; }

/* ── 遮罩层 ─────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 30%, rgba(24, 36, 56, 0.85), rgba(4, 6, 10, 0.94));
  backdrop-filter: blur(6px);
  z-index: 20;
}

.modal { background: rgba(4, 7, 12, 0.78); }

.panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  max-height: 92vh;
  overflow-y: auto;
}

.widePanel { width: min(760px, 100%); }

h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 2px;
  background: linear-gradient(100deg, #9fe8ff, #4ec9ff 40%, #ff8ab8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h1 .dot { color: var(--accent); -webkit-text-fill-color: var(--accent); }

h2 { margin: 0 0 14px; font-size: 19px; letter-spacing: 1px; }

.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.tiny { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 12px 0 0; }
.label { color: var(--muted); font-size: 12px; letter-spacing: 2px; }

/* ── 表单 ───────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }

input, select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 22, 0.9);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: rgba(78, 201, 255, 0.65); box-shadow: 0 0 0 3px rgba(78, 201, 255, 0.12); }
#joinCode { width: 96px; text-align: center; letter-spacing: 3px; text-transform: uppercase; }

/* ── 按钮 ───────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(38, 52, 76, 0.95), rgba(20, 28, 42, 0.95));
  color: var(--text);
  border-radius: 11px;
  padding: 11px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s, border-color .15s, filter .15s;
}
.btn:hover { border-color: rgba(78, 201, 255, 0.5); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, #3fc0ff, #1f7fd6);
  border-color: rgba(140, 220, 255, 0.7);
  color: #04121f;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(48, 160, 255, 0.28);
}
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; margin-bottom: 10px; }
.actions { display: flex; gap: 10px; align-items: center; }
.actions .btn { flex: 1; }
.joinrow { display: flex; gap: 8px; flex: 1; }

.msg { min-height: 18px; margin-top: 10px; font-size: 12px; color: var(--warn); }
.msg.err { color: #ff7a8a; }
.msg.ok { color: var(--ok); }

/* ── 大厅 ───────────────────────────────── */
.lobbyHead { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 6px; }
.code {
  font-size: 40px;
  letter-spacing: 10px;
  font-weight: 800;
  background: linear-gradient(100deg, #9fe8ff, #4ec9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; line-height: 1.6; }

.playerList { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.playerList li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 14px;
}
.playerList .swatch { width: 12px; height: 12px; border-radius: 50%; }
.playerList .tag { margin-left: auto; font-size: 12px; color: var(--muted); }
.playerList .tag.ready { color: var(--ok); }
.playerList .tag.host { color: var(--warn); }

/* ── HUD ────────────────────────────────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.hudTop { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 14px; gap: 10px; }

.hudLeft { min-width: 180px; }
.lvRow { display: flex; align-items: baseline; gap: 10px; font-size: 12px; color: var(--muted); }
.lv { font-size: 15px; color: var(--text); font-weight: 700; }
.lv b { color: var(--accent); }
.blades { color: var(--muted); }
.hpRow { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.hpBar { width: 160px; height: 9px; border-radius: 5px; background: rgba(255,255,255,0.10); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.hpBar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff4d6d, #ff8a5b 60%, #ffd166); transition: width .18s ease; }
.hpBar.low i { animation: hpPulse .8s infinite; }
@keyframes hpPulse { 50% { filter: brightness(1.6); } }
.hpRow span { font-size: 11px; color: var(--muted); min-width: 26px; }
.expBar { width: 160px; height: 6px; margin-top: 6px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; }
.expBar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #4ec9ff, #8ef0c8); transition: width .12s linear; }
.stats { margin-top: 5px; font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.hudCenter { text-align: center; }
.timer { font-size: 20px; font-weight: 700; letter-spacing: 2px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.alive { font-size: 12px; color: var(--muted); letter-spacing: 1px; }

.hudRight { min-width: 130px; }
.board { list-style: none; margin: 0; padding: 0; font-size: 12px; text-align: right; color: var(--muted); }
.board li { padding: 2px 0; white-space: nowrap; }
.board li.me { color: var(--text); font-weight: 700; }
.board li.dead { opacity: .38; text-decoration: line-through; }
.board .dotc { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.board .lvb { margin-left: 6px; color: var(--accent); font-weight: 700; }

.killFeed { position: fixed; left: 14px; top: 96px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.killFeed div { background: rgba(8,12,18,.66); padding: 4px 8px; border-radius: 7px; animation: feedIn .2s ease; }
@keyframes feedIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

.roomTag { position: fixed; right: 14px; bottom: 12px; font-size: 12px; pointer-events: none; color: rgba(150, 175, 210, .55); letter-spacing: 2px; }
.pauseBtn {
  position: fixed; left: 14px; bottom: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(10,16,26,.75);
  color: var(--muted); font-size: 15px; cursor: pointer; pointer-events: auto;
}
.pauseBtn.quitBtn {
  left: 56px; width: auto; padding: 0 12px; border-radius: 17px;
  font-size: 12px; letter-spacing: 1px; white-space: nowrap;
}

/* ── 升级卡片 ───────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 14px;
  background: linear-gradient(180deg, rgba(28, 40, 60, .9), rgba(12, 18, 28, .95));
  cursor: pointer;
  transition: transform .1s, border-color .15s, box-shadow .15s;
  min-height: 148px;
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover { transform: translateY(-3px); border-color: rgba(78,201,255,.6); box-shadow: 0 14px 30px rgba(0,0,0,.45); }
.card .rarity { font-size: 11px; letter-spacing: 2px; }
.card .name { font-size: 17px; font-weight: 700; }
.card .desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; flex: 1; }
.card .key { position: absolute; top: 10px; right: 12px; font-size: 11px; color: rgba(255,255,255,.28); }
.card.common { border-color: rgba(159,179,200,.35); }
.card.rare { border-color: rgba(90,209,255,.5); box-shadow: inset 0 0 30px rgba(90,209,255,.08); }
.card.epic { border-color: rgba(199,155,255,.6); box-shadow: inset 0 0 34px rgba(199,155,255,.12); }

/* ── 结算 ───────────────────────────────── */
.resultList { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.resultList li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 11px;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 13px;
}
.resultList .rank { width: 22px; color: var(--muted); font-weight: 700; }
.resultList .score { margin-left: auto; color: var(--accent); font-weight: 700; }
.resultList li.win { border-color: rgba(78,229,160,.55); background: rgba(78,229,160,.08); }

/* ── 触摸摇杆 ───────────────────────────── */
.stick {
  position: fixed; left: 26px; bottom: 26px;
  width: 124px; height: 124px; border-radius: 50%;
  border: 1px solid rgba(120, 170, 255, .25);
  background: radial-gradient(circle, rgba(60, 100, 160, .18), rgba(10, 16, 26, .35));
  z-index: 15; touch-action: none;
}
.stick i {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(150, 220, 255, .9), rgba(50, 130, 210, .75));
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}

@media (max-width: 560px) {
  .panel { padding: 18px; }
  h1 { font-size: 24px; }
  .cards { grid-template-columns: 1fr; }
  .card { min-height: 0; }
  .hudLeft { min-width: 130px; }
  .expBar { width: 120px; }
  .hudRight { min-width: 96px; }
  .code { font-size: 32px; letter-spacing: 6px; }
}
