* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0d10; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: #e8e6e3;
  user-select: none;
  -webkit-user-select: none;
}
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,12,16,.72) 0%, rgba(6,7,10,.92) 100%);
  backdrop-filter: blur(3px);
}
.hidden { display: none !important; }

.panel {
  background: linear-gradient(160deg, #171b22 0%, #10131a 100%);
  border: 1px solid #2c3442;
  border-radius: 14px;
  padding: 28px 32px;
  width: min(440px, 92vw);
  box-shadow: 0 18px 60px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.04);
}
.title {
  font-size: 44px; letter-spacing: 6px; text-align: center;
  color: #f4f1ea;
  text-shadow: 0 0 22px rgba(255,120,60,.35), 0 2px 0 #000;
  margin-bottom: 2px;
}
.subtitle { text-align: center; color: #8b93a1; font-size: 13px; margin-bottom: 22px; letter-spacing: 1px; }
h2 { text-align: center; margin-bottom: 16px; letter-spacing: 2px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: #8b93a1; margin-bottom: 6px; }
input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #333c4d; background: #0d1015; color: #e8e6e3;
  font-size: 15px; outline: none;
}
input:focus { border-color: #e07b39; }

.btn {
  padding: 11px 16px; border-radius: 9px; border: 1px solid #3a4456;
  background: linear-gradient(180deg, #232a36, #1a202a);
  color: #e8e6e3; font-size: 15px; cursor: pointer; letter-spacing: 1px;
  transition: all .12s ease;
}
.btn:hover { filter: brightness(1.2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, #ff8c42, #d95f18);
  border-color: #ff9d5c; color: #fff; font-weight: 600;
  box-shadow: 0 4px 18px rgba(224,123,57,.35);
}
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 8px 12px; }
.btn.tiny { font-size: 12px; padding: 4px 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }

.join-row { display: flex; gap: 8px; margin: 6px 0 14px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }
.code-input { flex: 1 !important; }
.help-box {
  font-size: 12px; color: #7d8593; line-height: 1.7;
  border-top: 1px dashed #2c3442; padding-top: 12px; margin-top: 6px;
}
.help-box b { color: #a8b0bd; }
.error-text { color: #ff7b6b; font-size: 13px; min-height: 18px; margin-top: 8px; text-align: center; }
.muted { color: #8b93a1; font-size: 13px; text-align: center; }

.code-display {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: #0d1015; border: 1px solid #333c4d; border-radius: 10px;
  padding: 12px; margin-bottom: 16px;
}
.code-display span { color: #8b93a1; font-size: 13px; }
.code-display b { font-size: 30px; letter-spacing: 8px; color: #ffcf87; }

.player-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.player-row {
  display: flex; align-items: center; gap: 10px;
  background: #0d1015; border: 1px solid #262e3c; border-radius: 8px; padding: 8px 12px;
  font-size: 14px;
}
.player-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.player-row .tag { margin-left: auto; font-size: 12px; color: #8b93a1; }
.tips { font-size: 12px; color: #6f7885; line-height: 1.8; margin-top: 10px; text-align: center; }

/* ---------- 升级卡 ---------- */
#levelup { flex-direction: column; gap: 20px; background: rgba(8,9,13,.55); }
.levelup-title {
  font-size: 26px; letter-spacing: 4px; color: #ffd97a;
  text-shadow: 0 0 18px rgba(255,200,80,.5); animation: pulse 1.2s ease infinite;
}
@keyframes pulse { 50% { transform: scale(1.05); } }
.cards { display: flex; gap: 16px; padding: 0 12px; flex-wrap: wrap; justify-content: center; }
.card {
  width: 200px; min-height: 240px; border-radius: 14px; padding: 18px 16px;
  background: linear-gradient(165deg, #1d232e, #12161e);
  border: 2px solid #3a4456; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
}
.card:hover { transform: translateY(-6px) scale(1.03); box-shadow: 0 14px 40px rgba(0,0,0,.5); }
.card.r1 { border-color: #4da3ff; box-shadow: 0 0 18px rgba(77,163,255,.25); }
.card.r2 { border-color: #c792ea; box-shadow: 0 0 22px rgba(199,146,234,.35); }
.card .icon { font-size: 46px; margin: 14px 0 10px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
.card .name { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: #f4f1ea; }
.card .desc { font-size: 13px; color: #9aa2b0; line-height: 1.6; flex: 1; }
.card .rarity { font-size: 11px; margin-top: 10px; letter-spacing: 2px; }
.card.r0 .rarity { color: #8b93a1; }
.card.r1 .rarity { color: #4da3ff; }
.card.r2 .rarity { color: #c792ea; }
.card .key { font-size: 11px; color: #5b6472; margin-top: 8px; border: 1px solid #333c4d; padding: 1px 7px; border-radius: 5px; }

/* ---------- 结算 ---------- */
.over-stats { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 18px; }
.over-row {
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  background: #0d1015; border-radius: 8px; padding: 9px 12px; border: 1px solid #262e3c;
}
.over-row .name { flex: 1; }
.over-row .stat { color: #ffcf87; font-weight: 600; }
.over-row.dead { opacity: .65; }

.dead-banner {
  position: fixed; top: 18vh; left: 50%; transform: translateX(-50%);
  z-index: 15; background: rgba(120,10,10,.82); border: 1px solid #ff5d5d;
  padding: 14px 28px; border-radius: 12px; font-size: 20px; letter-spacing: 2px;
  color: #ffd7d7; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}

#toasts {
  position: fixed; top: 76px; right: 14px; z-index: 30;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(20,24,32,.92); border: 1px solid #333c4d; border-left: 3px solid #e07b39;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; color: #d7dbe2;
  animation: slideIn .2s ease, fadeOut .4s ease 3.4s forwards;
  max-width: 280px;
}
.toast.sys { border-left-color: #4da6ff; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }

.pause-hint {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 15; color: #ffd97a; font-size: 13px; letter-spacing: 2px;
  text-shadow: 0 1px 4px #000;
}
.mute-btn { position: fixed; right: 12px; bottom: 12px; z-index: 40; opacity: .75; }

/* Esc 菜单 */
#escMenu { z-index: 45; }
.esc-note { text-align: center; color: #ffb27a; font-size: 13px; margin-bottom: 14px; }

@media (max-width: 700px) {
  .cards { flex-direction: column; align-items: center; }
  .card { width: min(340px, 88vw); min-height: 0; flex-direction: row; text-align: left; gap: 12px; padding: 14px; }
  .card .icon { margin: 0; font-size: 34px; }
  .card .key { display: none; }
}
