/* ============================================================
 * 霓虹蛇大作战 —— UI 样式
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #070b12;
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}

#textOverlay {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 2;
}

#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%);
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud {
  position: fixed; inset: 0;
  pointer-events: none;
  color: #e8ecf4;
  z-index: 5;
}
#hud button { pointer-events: auto; }

#topLeft {
  position: absolute; top: 14px; left: 14px;
  display: flex; gap: 10px; align-items: center;
}
#scoreLine {
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.3px;
}
#muteBtn {
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e8ecf4;
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer; font-size: 15px;
}
#muteBtn:hover { background: rgba(30,40,60,0.8); }

#rendererBadge {
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(72,219,251,0.45);
  color: #48dbfb;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
}
/* 联机延迟徽章：绿色<80ms，黄色<200ms，红色更高 */
#pingBadge {
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(255,255,255,0.2);
  color: #9fb3d8;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.5px;
}
#pingBadge.good { color: #69db7c; border-color: rgba(105,219,124,0.5); }
#pingBadge.mid { color: #feca57; border-color: rgba(254,202,87,0.5); }
#pingBadge.bad { color: #ff6b81; border-color: rgba(255,107,129,0.5); }

#leaderboard {
  position: absolute; top: 14px; right: 14px;
  width: 196px;
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}
.lb-title {
  font-size: 12px; color: #8fa3c8;
  letter-spacing: 3px;
  margin-bottom: 6px; text-align: center;
}
#lbList { list-style: none; font-size: 12.5px; }
#lbList li {
  display: flex; align-items: center; gap: 6px;
  padding: 2.5px 0;
  color: #c6d2e8;
}
#lbList li.me { color: #ffe479; font-weight: 700; }
#lbList .rk { width: 18px; color: #66799c; font-size: 11px; flex: none; }
#lbList .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#lbList .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lbList .sc { color: #9fb3d8; font-variant-numeric: tabular-nums; }
#lbList li.me .sc { color: #ffe479; }

#bottomRight { position: absolute; right: 14px; bottom: 14px; opacity: 0.92; }
#minimap { border-radius: 50%; }

#hint {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  color: rgba(232,236,244,0.55);
  background: rgba(10,15,26,0.5);
  padding: 6px 14px;
  border-radius: 20px;
}

#feed {
  position: absolute; top: 58px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.feed-item {
  background: rgba(10,15,26,0.78);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 12.5px;
  color: #c6d2e8;
  animation: feedIn 0.25s ease, feedOut 0.5s ease 3.4s forwards;
}
@keyframes feedIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes feedOut { to { opacity: 0; transform: translateY(-6px); } }

#toast {
  position: absolute; top: 34%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px; font-weight: 800;
  color: #ffe479;
  text-shadow: 0 0 18px rgba(255,228,121,0.65);
  opacity: 0;
  pointer-events: none;
}
#toast.show { animation: toastPop 1.6s ease forwards; }
@keyframes toastPop {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.6); }
  12%  { opacity: 1; transform: translate(-50%,-50%) scale(1.08); }
  22%  { transform: translate(-50%,-50%) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------------- 覆盖层 ---------------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5,8,14,0.62);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.panel {
  background: linear-gradient(160deg, rgba(19,26,44,0.96), rgba(12,17,30,0.96));
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 20px;
  padding: 38px 44px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  min-width: 350px;
}

.title {
  font-size: 42px; font-weight: 900; letter-spacing: 3px;
  background: linear-gradient(90deg, #48dbfb, #7d5fff, #f368e0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(93,124,255,0.45));
}
.subtitle { color: #8fa3c8; letter-spacing: 6px; font-size: 14px; margin: 6px 0 26px; }

#nameInput {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e8ecf4;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 15px;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
}
#nameInput:focus {
  border-color: #48dbfb;
  box-shadow: 0 0 0 3px rgba(72,219,251,0.15);
}
#roomInput {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #9fe8c8;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}
#roomInput:focus {
  border-color: #12b886;
  box-shadow: 0 0 0 3px rgba(18,184,134,0.15);
}

#swatches {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 22px;
}
.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.sel {
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
  transform: scale(1.15);
}

.btn {
  display: block; width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: #e8ecf4;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
  margin-top: 10px;
}
.btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(90deg, #22a6f2, #7d5fff);
  border: none;
  box-shadow: 0 6px 24px rgba(64,120,255,0.4);
}
.btn.primary:hover { filter: brightness(1.1); }

/* 单机/联机双按钮并排 */
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin-top: 10px; }
.btn.online {
  background: linear-gradient(90deg, #0ea56e, #12b886);
  border: none;
  box-shadow: 0 6px 24px rgba(18,184,134,0.35);
}
.btn.online:hover { filter: brightness(1.1); }

.tips { margin-top: 20px; font-size: 12px; line-height: 1.9; color: #7488ab; }

/* ---------------- 模式选择 ---------------- */
#modeCards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.mode-card {
  text-align: left;
  border: 1.5px solid rgba(255,255,255,0.09);
  border-radius: 12px;
  padding: 9px 14px;
  cursor: pointer;
  background: rgba(255,255,255,0.04);
  transition: 0.13s;
}
.mode-card:hover { background: rgba(255,255,255,0.08); }
.mode-card .mc-name { font-size: 15px; font-weight: 700; color: #e8ecf4; }
.mode-card .mc-desc { font-size: 11px; color: #8fa3c8; margin-top: 2px; }
.mode-card.sel { background: rgba(255,255,255,0.09); }
.mode-card.sel.accent-cyan  { border-color: #48dbfb; box-shadow: 0 0 12px rgba(72,219,251,0.25); }
.mode-card.sel.accent-gold  { border-color: #feca57; box-shadow: 0 0 12px rgba(254,202,87,0.25); }
.mode-card.sel.accent-red   { border-color: #ff6b81; box-shadow: 0 0 12px rgba(255,107,129,0.25); }
.mode-card.sel .mc-name { color: #fff; }

/* ---------------- 模式信息条（顶中） ---------------- */
#modeChip {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
#modeChip .timer {
  font-size: 24px; font-weight: 800;
  color: #fff; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(0,0,0,0.6);
}
#modeChip .timer.finale { color: #ffe479; animation: finaleFlash 1s infinite; }
#modeChip .timer.finale::after {
  content: ' 双倍得分!';
  font-size: 13px; color: #ff6b81; vertical-align: 4px;
}
@keyframes finaleFlash { 50% { opacity: 0.55; } }
#modeChip .safe-wrap {
  width: 180px; padding: 5px 10px 7px;
  background: rgba(10,15,26,0.72);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
#modeChip .safe-label { font-size: 10.5px; color: rgba(255,150,160,0.9); margin-bottom: 4px; }
#modeChip .safe-track {
  height: 7px; border-radius: 4px;
  background: rgba(255,255,255,0.09); overflow: hidden;
}
#modeChip .safe-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #ff9f43, #ff6b81);
  transition: width 0.4s linear;
}

/* ---------------- 道具栏（左下） ---------------- */
#powerBar {
  position: absolute; left: 14px; bottom: 52px;
  display: flex; gap: 6px;
}
.power-chip {
  display: flex; align-items: center; gap: 5px;
  background: rgba(10,15,26,0.75);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 4px 11px;
  font-size: 12px; font-weight: 700;
}
.power-chip.shield { color: #48dbfb; }
.power-chip.magnet { color: #a18bff; }
.power-chip.speed  { color: #feca57; }
.power-chip .pv { color: #e8ecf4; font-variant-numeric: tabular-nums; }

/* ---------------- 重生横幅 ---------------- */
#respawnBanner {
  position: absolute; top: 38%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(10,15,26,0.78);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 16px;
  padding: 22px 40px;
}
#respawnBanner .rb-title {
  font-size: 22px; font-weight: 800;
  color: #ff6b81; margin-bottom: 8px;
}
#respawnText { font-size: 14px; font-weight: 700; color: #e8ecf4; }

h2#deathTitle { font-size: 26px; color: #ff6b81; margin-bottom: 18px; }
.stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; margin-bottom: 20px;
}
.stat {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 6px;
}
.stat .v { font-size: 20px; font-weight: 800; color: #fff; }
.stat .k { font-size: 11px; color: #8fa3c8; margin-top: 3px; }
