:root {
  --blue: #3a86ff;
  --red: #e63946;
  --bg: #0d1220;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; color: #eef2f8; }

canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.panel {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; z-index: 10;
  background: radial-gradient(1200px 600px at 50% 20%, #1b2740 0%, #0d1220 60%);
}
.logo { text-align: center; }
.logo h1 { font-size: 52px; letter-spacing: 6px; background: linear-gradient(90deg, var(--red), #ffd166, var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo p { color: #8fa3c8; letter-spacing: 2px; margin-top: 6px; font-size: 13px; }
.logo-ball { width: 46px; height: 46px; margin: 0 auto 8px; border-radius: 50%; background: radial-gradient(circle at 32% 30%, #fff, #c9d5e6 70%); box-shadow: 0 0 28px rgba(255,255,255,0.35); display: flex; align-items: center; justify-content: center; color: #334; font-size: 30px; }

.menu-card {
  width: min(420px, 90vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  display: flex; flex-direction: column; gap: 12px;
  backdrop-filter: blur(8px);
}
label { font-size: 13px; color: #b9c6dd; display: flex; flex-direction: column; gap: 6px; }
input {
  background: rgba(0,0,0,0.3); border: 1px solid var(--line); color: #eef2f8;
  border-radius: 10px; padding: 11px 14px; font-size: 15px; outline: none;
}
input:focus { border-color: var(--blue); }
.btn {
  background: rgba(255,255,255,0.08); color: #eef2f8;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; cursor: pointer; transition: 0.15s;
}
.btn:hover { background: rgba(255,255,255,0.16); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(90deg, #2f6fe0, #3a86ff); border: none; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.icon { width: 46px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.ai-row { justify-content: center; }
.ai-label {
  flex-direction: row; align-items: center; gap: 10px;
  font-size: 14px; color: #cfe0ff;
}
.ai-label select {
  background: rgba(0,0,0,0.3); border: 1px solid var(--line); color: #eef2f8;
  border-radius: 10px; padding: 9px 12px; font-size: 14px; outline: none; cursor: pointer;
}
.ai-label select:focus { border-color: var(--blue); }
.status { min-height: 20px; font-size: 13px; color: #ffd166; text-align: center; opacity: 0.9; }
.tips { width: min(620px, 92vw); text-align: center; color: #7f90ad; font-size: 12px; line-height: 1.8; }

.room-panel { background: radial-gradient(900px 500px at 50% 30%, #16233c 0%, #0d1220 65%); z-index: 20; }
.room-panel h2 { letter-spacing: 3px; color: #cfe0ff; }
.room-code {
  font-size: 58px; font-weight: 800; letter-spacing: 16px; color: #ffd166;
  background: rgba(0,0,0,0.35); border: 1px dashed rgba(255,209,102,0.5);
  border-radius: 14px; padding: 10px 28px; text-align: center;
}
.room-panel p { color: #b9c6dd; }
.room-panel .small { color: #7f90ad; text-align: center; line-height: 1.8; }

#hud {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 22px; z-index: 5;
  background: rgba(10, 15, 26, 0.72); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 22px; backdrop-filter: blur(6px); pointer-events: none;
}
.player-box { display: flex; align-items: center; gap: 12px; min-width: 140px; }
.player-box.right { justify-content: flex-end; }
.player-box span { font-weight: 600; font-size: 15px; }
.score { font-size: 30px; font-weight: 800; color: #fff; min-width: 34px; text-align: center; }
#hudP1 { color: #ff8b96; }
#hudP2 { color: #8ec5ff; }
.center { position: relative; width: 44px; text-align: center; }
.vs { color: #6d7f9e; font-size: 12px; letter-spacing: 2px; }
.serve-dot {
  position: absolute; top: -7px; width: 8px; height: 8px; border-radius: 50%;
  background: #ffd166; box-shadow: 0 0 8px #ffd166; transition: left 0.3s;
}

#phaseBanner, #pointToast {
  position: fixed; left: 50%; transform: translateX(-50%);
  font-weight: 800; letter-spacing: 4px; z-index: 6; opacity: 0; transition: opacity 0.25s;
  pointer-events: none; text-shadow: 0 2px 12px rgba(0,0,0,0.8); text-align: center;
}
#phaseBanner { top: 92px; font-size: 26px; color: #cfe0ff; }
#pointToast { top: 140px; font-size: 22px; color: #ffd166; }

#hintBar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: #9fb1cf; z-index: 5; pointer-events: none;
  background: rgba(10,15,26,0.6); padding: 7px 16px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08); white-space: nowrap;
}
#hintBar b { color: #ffd166; }
#netInfo {
  position: fixed; top: 14px; left: 14px; font-size: 12px; color: #8fa3c8;
  background: rgba(10,15,26,0.6); padding: 5px 10px; border-radius: 10px; z-index: 5; pointer-events: none;
}

.overlay {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 22, 0.72); backdrop-filter: blur(4px);
}
.overlay-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 34px; text-align: center; display: flex; flex-direction: column; gap: 12px; min-width: 300px;
}
.overlay-card h2 { color: #ffd166; letter-spacing: 3px; }
.overlay-card p { color: #b9c6dd; }

@media (max-width: 720px) {
  .logo h1 { font-size: 34px; }
  #hintBar { white-space: normal; width: 92%; text-align: center; }
  .player-box { min-width: 92px; }
}
