@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700;900&display=swap');

:root {
  --cyan: #00f0ff;
  --magenta: #ff2bd6;
  --purple: #8a2bff;
  --yellow: #ffe14d;
  --bg: #05010d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Orbitron', 'Segoe UI', 'Microsoft YaHei', sans-serif;
  color: #dff6ff;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

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

#scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5,1,13,.75) 100%);
}

.hidden { display: none !important; }

/* ---------- 屏幕层 ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center;
  background: rgba(5,1,13,.45);
  backdrop-filter: blur(2px);
}

.logo {
  font-size: clamp(42px, 9vw, 84px);
  font-weight: 900; line-height: 1.05; letter-spacing: .12em;
  color: #fff;
  text-shadow: 0 0 8px var(--cyan), 0 0 24px var(--cyan), 0 0 60px rgba(0,240,255,.6);
  animation: logoPulse 2.4s ease-in-out infinite;
}
.logo span {
  color: var(--magenta);
  text-shadow: 0 0 8px var(--magenta), 0 0 24px var(--magenta), 0 0 60px rgba(255,43,214,.6);
}
@keyframes logoPulse {
  50% { text-shadow: 0 0 12px var(--cyan), 0 0 40px var(--cyan), 0 0 90px rgba(0,240,255,.8); }
}
.tagline { color: #9fd8e8; letter-spacing: .35em; font-size: 13px; opacity: .85; }

.menu-box { display: flex; flex-direction: column; gap: 12px; width: min(320px, 84vw); margin-top: 10px; }
.divider { color: #5f7f95; font-size: 12px; letter-spacing: .3em; margin: 6px 0; }

input {
  background: rgba(0, 20, 30, .6);
  border: 1px solid rgba(0, 240, 255, .45);
  color: #eafcff; outline: none;
  padding: 12px 14px; font-size: 15px; font-family: inherit;
  letter-spacing: .08em; text-align: center;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
input:focus { border-color: var(--cyan); box-shadow: 0 0 14px rgba(0,240,255,.45); }
input::placeholder { color: #48707f; }

.btn {
  cursor: pointer; border: none; font-family: inherit;
  padding: 13px 30px; font-size: 16px; font-weight: 700; letter-spacing: .18em;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.btn:active { transform: scale(.96); }
.btn.primary {
  background: linear-gradient(90deg, rgba(0,240,255,.16), rgba(255,43,214,.16));
  color: var(--cyan);
  border: 1px solid var(--cyan);
  text-shadow: 0 0 8px rgba(0,240,255,.8);
  box-shadow: 0 0 16px rgba(0,240,255,.25), inset 0 0 12px rgba(0,240,255,.12);
}
.btn.primary:hover { box-shadow: 0 0 28px rgba(0,240,255,.55), inset 0 0 18px rgba(0,240,255,.2); filter: brightness(1.25); }
.btn.ghost {
  background: transparent; color: #6f93a5;
  border: 1px solid #2a4a5a; font-size: 13px; padding: 10px 22px;
}
.btn.ghost:hover { color: var(--cyan); border-color: var(--cyan); }

.hint { color: #5f8296; font-size: 12px; letter-spacing: .1em; line-height: 1.7; }

/* ---------- 难度选择 ---------- */
.diff-label { color: #5f7f95; font-size: 12px; letter-spacing: .3em; }
.diff-row { display: flex; gap: 8px; }
.diff-btn {
  flex: 1; cursor: pointer; padding: 10px 0; font-family: inherit;
  font-size: 14px; font-weight: 700; letter-spacing: .15em;
  background: rgba(0, 20, 30, .6); color: #5f8296;
  border: 1px solid #2a4a5a;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: all .15s;
}
.diff-btn:hover { color: var(--cyan); border-color: rgba(0,240,255,.5); }
.diff-btn.active {
  color: var(--cyan); border-color: var(--cyan);
  text-shadow: 0 0 8px rgba(0,240,255,.8);
  box-shadow: 0 0 12px rgba(0,240,255,.3), inset 0 0 10px rgba(0,240,255,.12);
}

/* ---------- 大厅 ---------- */
.room-title { font-size: 26px; letter-spacing: .2em; color: #fff; text-shadow: 0 0 14px var(--cyan); }
.room-title span { color: var(--yellow); text-shadow: 0 0 12px var(--yellow); }
#players { list-style: none; display: flex; flex-direction: column; gap: 8px; min-width: 240px; }
#players li {
  padding: 10px 18px; letter-spacing: .12em;
  border: 1px solid rgba(0,240,255,.4); background: rgba(0,30,45,.5);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
#players li.host::after { content: ' ★房主'; color: var(--yellow); font-size: 12px; }
#players li.empty { color: #3d5c6d; border-style: dashed; }

/* ---------- 倒计时 ---------- */
#count-num {
  font-size: clamp(90px, 22vw, 180px); font-weight: 900; color: #fff;
  text-shadow: 0 0 20px var(--magenta), 0 0 70px var(--magenta);
  animation: countPop .7s ease-out;
}
@keyframes countPop {
  0% { transform: scale(2.2); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#score-box { position: absolute; top: 18px; left: 0; right: 0; text-align: center; }
#score {
  font-size: clamp(34px, 6vw, 52px); font-weight: 900; color: #fff;
  text-shadow: 0 0 10px var(--cyan), 0 0 34px rgba(0,240,255,.7);
}
#combo {
  margin-top: 2px; font-size: 15px; letter-spacing: .25em; color: var(--magenta);
  text-shadow: 0 0 10px var(--magenta);
}
#combo.bump { animation: comboBump .18s ease-out; }
@keyframes comboBump { 50% { transform: scale(1.35); } }

#race-bars { position: absolute; top: 16px; left: 16px; display: flex; flex-direction: column; gap: 7px; width: min(300px, 44vw); }
.race-row { display: flex; align-items: center; gap: 8px; }
.race-name { font-size: 11px; width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #bfefff; letter-spacing: .05em; }
.race-track { flex: 1; height: 7px; background: rgba(10,20,40,.8); border: 1px solid rgba(0,240,255,.25); }
.race-fill { height: 100%; width: 0%; transition: width .15s linear; }
.race-fill.me { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.race-fill.op { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.race-score { font-size: 11px; width: 52px; text-align: right; color: #8fb9c9; }
.race-row.dead .race-name, .race-row.dead .race-score { color: #ff4d6d; text-decoration: line-through; }

#btn-mute {
  position: absolute; top: 14px; right: 14px; pointer-events: auto;
  width: 42px; height: 42px; cursor: pointer;
  background: rgba(0,25,40,.6); color: var(--cyan);
  border: 1px solid rgba(0,240,255,.5); font-size: 19px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
#btn-mute.off { color: #476b7c; text-decoration: line-through; }

/* ---------- 判定弹字 ---------- */
#popup {
  position: fixed; left: 50%; top: 34%; transform: translateX(-50%);
  z-index: 12; pointer-events: none;
  font-size: clamp(22px, 4.5vw, 36px); font-weight: 900; letter-spacing: .2em;
  opacity: 0;
}
#popup.show { animation: popFloat .55s ease-out; }
#popup.perfect { color: var(--yellow); text-shadow: 0 0 12px var(--yellow), 0 0 40px rgba(255,225,77,.7); }
#popup.boost { color: var(--magenta); text-shadow: 0 0 12px var(--magenta), 0 0 40px rgba(255,43,214,.7); }
#popup.good { color: var(--cyan); text-shadow: 0 0 10px rgba(0,240,255,.8); }
#popup.bad { color: #7d8f9c; text-shadow: 0 0 8px rgba(125,143,156,.5); font-size: clamp(16px, 3vw, 24px); }
@keyframes popFloat {
  0% { opacity: 0; transform: translateX(-50%) scale(.5) translateY(20px); }
  25% { opacity: 1; transform: translateX(-50%) scale(1.15) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-46px); }
}

/* ---------- 结算 ---------- */
#result-title {
  font-size: clamp(40px, 9vw, 76px); font-weight: 900; letter-spacing: .15em; color: #fff;
  text-shadow: 0 0 16px var(--cyan), 0 0 60px rgba(0,240,255,.7);
}
#result-title.lose { text-shadow: 0 0 16px #ff4d6d, 0 0 60px rgba(255,77,109,.7); }
#result-rows { display: flex; flex-direction: column; gap: 10px; min-width: min(340px, 84vw); }
.result-row {
  display: flex; justify-content: space-between; gap: 20px;
  padding: 12px 20px; letter-spacing: .1em; font-size: 15px;
  border: 1px solid rgba(0,240,255,.35); background: rgba(0,25,40,.55);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.result-row .r-name { color: #bfefff; }
.result-row .r-stat { color: #7d9fb2; font-size: 12px; margin-left: 8px; }
.result-row.winner { border-color: var(--yellow); box-shadow: 0 0 18px rgba(255,225,77,.3); }
.result-row.winner .r-name { color: var(--yellow); }

/* ---------- 加载 ---------- */
.loading-text { font-size: 16px; letter-spacing: .2em; color: #bfefff; text-shadow: 0 0 10px rgba(0,240,255,.6); }
.loading-bar {
  width: min(320px, 80vw); height: 8px;
  background: rgba(10,20,40,.8); border: 1px solid rgba(0,240,255,.4);
}
#loading-fill { height: 100%; width: 0%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); transition: width .15s linear; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  z-index: 40; padding: 12px 26px; font-size: 14px; letter-spacing: .1em;
  background: rgba(10, 5, 25, .92); color: var(--yellow);
  border: 1px solid var(--yellow); box-shadow: 0 0 18px rgba(255,225,77,.35);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
