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

body {
  min-height: 100vh;
  overscroll-behavior: none;
  background:
    radial-gradient(1200px 700px at 50% -10%, #241a4d 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 110%, #0d3b4a 0%, transparent 55%),
    #07060f;
  color: #e8e9ff;
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 44px;
}

/* ---------- 标题 ---------- */
.head { text-align: center; margin-bottom: 14px; }

.head h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 46px);
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow:
    0 0 6px #fff,
    0 0 18px #ff2d95,
    0 0 42px #ff2d95,
    0 0 80px #b14dff;
}

.head h1 span {
  color: #7af5ff;
  text-shadow:
    0 0 6px #fff,
    0 0 18px #00e6ff,
    0 0 44px #00e6ff;
  margin-left: 10px;
}

.tag {
  margin: 8px 0 0;
  font-size: 13px;
  letter-spacing: 3px;
  color: #9aa3d8;
  text-transform: uppercase;
}

/* ---------- 舞台 ---------- */
.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #05040c;
  border: 1px solid #2c2b52;
  box-shadow:
    0 0 0 1px rgba(255, 45, 149, .25),
    0 0 34px rgba(255, 45, 149, .22),
    0 0 80px rgba(0, 230, 255, .16),
    0 22px 60px rgba(0, 0, 0, .6);
}

#game {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 640;
  touch-action: none;
  cursor: none;
}

/* 扫描线 */
.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .045) 0px,
    rgba(255, 255, 255, .045) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.vig {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, .62) 100%);
}

/* ---------- 覆盖层 ---------- */
.ov {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 16, .82);
  backdrop-filter: blur(3px);
  padding: 20px;
}

.ov.show { display: flex; }

.panel {
  width: min(560px, 100%);
  text-align: center;
  animation: pop .22s ease-out;
}

@keyframes pop {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.panel h2 {
  margin: 0 0 6px;
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 28px #ff2d95, 0 0 60px #b14dff;
}

.panel h2.cyan { text-shadow: 0 0 10px #fff, 0 0 28px #00e6ff, 0 0 60px #0090ff; }
.panel h2.red  { text-shadow: 0 0 10px #fff, 0 0 28px #ff3b3b, 0 0 60px #ff7a00; }

.panel .sub {
  margin: 0 0 18px;
  font-size: 14px;
  color: #a6adda;
  letter-spacing: 1px;
}

.panel .stat {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 14px 0 18px;
  flex-wrap: wrap;
}

.panel .stat div {
  font-size: 12px;
  color: #8f97c8;
  letter-spacing: 1px;
}

.panel .stat b {
  display: block;
  font-size: 24px;
  color: #7af5ff;
  text-shadow: 0 0 14px rgba(0, 230, 255, .8);
  font-variant-numeric: tabular-nums;
}

.modes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 4px 0 16px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid #4a4a86;
  background: linear-gradient(180deg, #1b1b36 0%, #14142a 100%);
  color: #dfe3ff;
  font: inherit;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 11px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}

.btn:hover { transform: translateY(-2px); border-color: #7af5ff; box-shadow: 0 0 18px rgba(0, 230, 255, .35); }
.btn:active { transform: translateY(0); }

.btn.mode { padding: 9px 16px; font-size: 13px; }
.btn.mode.on {
  border-color: #ff2d95;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 45, 149, .5), inset 0 0 16px rgba(255, 45, 149, .22);
}

.btn.primary {
  padding: 14px 34px;
  font-size: 16px;
  border-color: #ff2d95;
  background: linear-gradient(180deg, #ff2d95 0%, #b8287f 100%);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
  box-shadow: 0 0 26px rgba(255, 45, 149, .55);
}

.howto {
  margin: 18px 0 0;
  font-size: 12.5px;
  line-height: 1.9;
  color: #8f97c8;
  text-align: left;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 14px 16px;
}

.howto b { color: #ffd23f; }

/* ---------- 底部栏 ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.keys {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: #8f97c8;
}

.keys b { color: #7af5ff; font-weight: 700; }

.mute {
  appearance: none;
  border: 1px solid #4a4a86;
  background: #14142a;
  color: #cfd4ff;
  font: inherit;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.mute:hover { border-color: #7af5ff; color: #fff; }

.ctrls { display: flex; align-items: center; gap: 10px; }

/* ---------- 语言选择器（右上角） ---------- */
.lang {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 60;
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(10, 8, 26, .55);
  border: 1px solid rgba(122, 245, 255, .25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lang-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #8f97c8;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}
.lang-btn:hover { color: #fff; }
.lang-btn.on {
  color: #04121a;
  background: linear-gradient(180deg, #7af5ff 0%, #00e6ff 100%);
  box-shadow: 0 0 16px rgba(0, 230, 255, .6);
}
@media (max-width: 640px) {
  .lang { top: 8px; right: 8px; }
  .lang-btn { padding: 5px 9px; font-size: 12px; }
}

/* 全屏时让画布等比居中铺满 */
.stage:fullscreen { display: flex; align-items: center; justify-content: center; }
.stage:fullscreen #game { width: auto; height: 100%; }

/* ---------- 说明 ---------- */
.doc {
  margin-top: 30px;
  border-top: 1px solid #26254a;
  padding-top: 20px;
}

.doc h2 {
  font-size: 16px;
  letter-spacing: 2px;
  color: #ff7ad9;
  margin: 0 0 12px;
}

.doc ul {
  margin: 0;
  padding-left: 20px;
  color: #9aa3d8;
  font-size: 13.5px;
  line-height: 2;
}

.doc b { color: #dfe3ff; }

/* ---------- 排行榜 ---------- */
.lb { max-height: 44vh; overflow-y: auto; margin: 10px 0; text-align: left; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: 8px; font-size: 13px; }
.lb-row:nth-child(odd) { background: rgba(255, 255, 255, .04); }
.lb-me { background: rgba(255, 210, 63, .18) !important; color: #ffd23f !important; font-weight: 800; box-shadow: inset 3px 0 0 #ffd23f; }
.lb-you { display:inline-block; margin-left:6px; padding:0 6px; border-radius:6px; background:#ffd23f; color:#1a1530; font-size:11px; font-weight:800; line-height:1.7; vertical-align:middle; }
.lb-rank { width: 30px; text-align: center; color: #7af5ff; font-weight: 700; flex: 0 0 auto; }
.lb-name { flex: 1 1 auto; color: #e8e9ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { color: #9aa3d8; font-size: 11px; margin-left: 6px; }
.lb-score { width: 104px; text-align: right; color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.lb-save { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.lb-input {
  flex: 1 1 auto; max-width: 240px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid #4a4a86; background: #14142a; color: #dfe3ff; font: inherit;
}
.lb-input:focus { outline: none; border-color: #7af5ff; }

@media (max-width: 640px) {
  .keys { gap: 10px; font-size: 11px; }
  .keys span { font-size: 11px; }
  .wrap { padding: 14px 10px 32px; }
  .head { margin-bottom: 10px; }
  .ctrls { gap: 8px; }
  .ctrls .mute { padding: 11px 15px; font-size: 13px; }
}

/* 移动端伪全屏：iOS Safari 不支持 requestFullscreen 时的兜底铺满方案 */
.stage.fs-mobile {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100dvh;
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage.fs-mobile #game {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 960 / 640;
}
