:root {
  --bg: #050a18;
  --navy: #0b1a3d;
  --blue: #1d3e8a;
  --gold: #ffd23f;
  --orange: #ff6b1a;
  --green: #4cff7a;
  --red: #ff4d5e;
  --text: #f5f7ff;
  --muted: #9aa7c7;
  --panel: rgba(9, 17, 40, 0.86);
  --line: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "WenQuanYi Zen Hei", sans-serif;
  --display: "Arial Black", "Helvetica Neue", Impact, var(--font);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

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

button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------- 通用屏幕 ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(5, 10, 24, 0.55), rgba(5, 10, 24, 0.88));
}
.screen.show { display: flex; animation: fadeIn 0.25s ease; }
.screen.dim { background: rgba(3, 6, 16, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.screen.scroll {
  background: linear-gradient(180deg, rgba(5, 10, 24, 0.9), rgba(5, 10, 24, 0.97));
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.panel.wide { width: min(560px, 100%); margin: auto 0; }
.panel h2 { margin: 4px 0 14px; font-size: 22px; }

.btn {
  display: block;
  width: 100%;
  padding: 15px 18px;
  margin: 10px 0 0;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.97); filter: brightness(1.15); }
.btn.primary {
  background: linear-gradient(135deg, #ff8a1f, #ff3d5e 60%, #b832ff);
  border: 0;
  box-shadow: 0 10px 30px rgba(255, 70, 80, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.ghost { background: transparent; color: var(--muted); }

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  font-size: 13px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  font-size: 26px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn.small { width: 36px; height: 36px; font-size: 12px; letter-spacing: -2px; }

.screen-head {
  width: min(960px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.screen-head h2 { margin: 0; font-size: 20px; }

.hint { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ---------- 加载 ---------- */
#loading { background: var(--bg); }
.loading-ball {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb070, #e2621c 55%, #9a3f0c);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  animation: dribble 0.6s cubic-bezier(.5, 0, .5, 1) infinite alternate;
}
.loading-text { margin-top: 18px; color: var(--muted); }
@keyframes dribble { from { transform: translateY(-30px); } to { transform: translateY(20px) scaleY(0.92); } }

/* ---------- 首页 ---------- */
.home-wrap { width: min(440px, 100%); text-align: center; }
.badge-line {
  display: inline-block;
  font: 900 11px var(--display);
  letter-spacing: 3px;
  color: var(--gold);
  padding: 6px 12px;
  border: 1px solid rgba(255, 210, 63, 0.4);
  border-radius: 999px;
}
.logo { margin: 14px 0 6px; line-height: 0.9; }
.logo span {
  display: block;
  font: 900 clamp(64px, 20vw, 108px) var(--display);
  letter-spacing: 2px;
  background: linear-gradient(180deg, #ffffff 20%, #ffd23f 60%, #ff7a1a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 18px rgba(255, 120, 30, 0.45));
  font-style: italic;
}
.logo em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: clamp(22px, 7vw, 30px);
  font-weight: 900;
  letter-spacing: 10px;
  text-indent: 10px;
}
.tagline { color: var(--muted); margin: 10px 0 22px; }
.home-btns .btn { font-size: 18px; padding: 17px; }
.home-best { margin-top: 14px; color: var(--gold); font-size: 14px; min-height: 20px; }
.settings { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--gold); color: #1a1300; font-weight: 800; }

.rules-list { text-align: left; padding-left: 18px; margin: 0 0 8px; line-height: 1.65; font-size: 14px; color: #dfe6ff; }
.rules-list li { margin-bottom: 6px; }
.rules-list b { color: var(--gold); }

/* ---------- 选球员 ---------- */
.shooter-grid {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding-bottom: 20px;
}
.shooter-card {
  position: relative;
  text-align: left;
  border-radius: 18px;
  padding: 12px 12px 14px;
  background: linear-gradient(160deg, var(--c1), #0a1430 75%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
  transition: transform 0.12s ease;
}
.shooter-card:active { transform: scale(0.97); }
.shooter-card::after {
  content: attr(data-num);
  position: absolute;
  right: -6px;
  top: -18px;
  font: 900 92px var(--display);
  color: rgba(255, 255, 255, 0.07);
  pointer-events: none;
}
.shooter-card img { width: 72%; display: block; margin: 0 auto 4px; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.45)); }
.shooter-card .cn { font-weight: 900; font-size: 16px; }
.shooter-card .en { font: 900 10px var(--display); letter-spacing: 1px; color: rgba(255, 255, 255, 0.65); margin-top: 2px; text-transform: uppercase; }
.shooter-card .trait { margin-top: 8px; font-size: 12px; color: var(--gold); font-weight: 800; }
.shooter-card .style { font-size: 11.5px; color: #c8d2ee; line-height: 1.45; margin-top: 4px; min-height: 50px; }
.shooter-card .best { position: absolute; left: 10px; top: 10px; font-size: 11px; background: rgba(0, 0, 0, 0.45); padding: 2px 8px; border-radius: 999px; color: var(--gold); }
.bars { margin-top: 8px; display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); }
.bar i { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); position: relative; overflow: hidden; }
.bar i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: linear-gradient(90deg, var(--gold), var(--orange)); border-radius: 3px; }

/* ---------- 花球架 ---------- */
.money-wrap { width: min(480px, 100%); text-align: center; }
.money-player { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 6px; }
.money-player img { width: 64px; }
.money-player .t { text-align: left; }
.money-player .t b { display: block; font-size: 17px; }
.money-player .t span { font-size: 12px; color: var(--muted); }
.money-court { width: 100%; height: auto; display: block; margin: 8px 0; }
.money-court .spot { cursor: pointer; }

/* ---------- 榜单 ---------- */
.board-phase { font: 900 12px var(--display); letter-spacing: 3px; color: var(--gold); }
.board-sub { color: var(--muted); font-size: 14px; margin: -6px 0 12px; line-height: 1.5; }
.board-list { list-style: none; padding: 0; margin: 0 0 6px; text-align: left; }
.board-list li {
  display: grid;
  grid-template-columns: 28px 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.05);
}
.board-list li.me { background: linear-gradient(90deg, rgba(255, 138, 31, 0.35), rgba(255, 61, 94, 0.15)); border: 1px solid rgba(255, 160, 60, 0.5); }
.board-list li.out { opacity: 0.55; }
.board-list li.cut { border-bottom: 2px dashed rgba(255, 210, 63, 0.6); }
.board-list .pl { font: 900 16px var(--display); color: var(--muted); text-align: center; }
.board-list img { width: 40px; }
.board-list .nm b { display: block; font-size: 15px; }
.board-list .nm span { font-size: 11px; color: var(--muted); }
.board-list .sc { font: 900 22px var(--display); }
.board-list .sc.wait { font-size: 12px; color: var(--muted); font-family: var(--font); font-weight: 600; }
.board-btns .btn { margin-top: 10px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; display: none; }
.hud.show { display: block; }
.hud button { pointer-events: auto; }
.hud-top {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.hud-score, .hud-time {
  background: rgba(5, 10, 24, 0.62);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px 12px 6px;
  min-width: 74px;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hud-time { margin-left: auto; min-width: 86px; }
.hud .label { font-size: 10px; color: var(--muted); letter-spacing: 2px; }
.hud .value { font: 900 26px var(--display); font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud-time.low .value { color: var(--red); animation: pulse 0.5s ease infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.hud-score .value.bump { animation: bump 0.35s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--gold); } }
.hud-target { position: absolute; left: 50%; transform: translateX(-50%); top: 2px; font-size: 12px; color: var(--gold); text-align: center; white-space: nowrap; text-shadow: 0 1px 4px #000; }

.hud-dots {
  position: absolute;
  top: calc(66px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(5, 10, 24, 0.5);
}
.hud-dots .grp { display: flex; gap: 3px; align-items: center; }
.hud-dots .grp.cur { outline: 1px solid rgba(255, 210, 63, 0.8); outline-offset: 3px; border-radius: 4px; }
.hud-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); display: block; }
.hud-dots i.money { box-shadow: 0 0 0 1.5px #ff4d5e, 0 0 0 3px #3b82f6; width: 7px; height: 7px; }
.hud-dots i.deep { box-shadow: 0 0 0 2px #6dff3c; }
.hud-dots i.made { background: var(--orange); }
.hud-dots i.money.made { background: #fff; }
.hud-dots i.deep.made { background: #6dff3c; }
.hud-dots i.miss { background: rgba(255, 255, 255, 0.06); opacity: 0.6; }

.hud-spot {
  position: absolute;
  top: calc(92px + var(--safe-top));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: #e6ecff;
  text-shadow: 0 1px 6px #000;
}
.hud-spot b { color: var(--gold); }

.hud-jersey {
  position: absolute;
  left: 10px;
  bottom: calc(12px + var(--safe-bottom));
  width: 74px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 4px #000;
}
.hud-jersey canvas { width: 74px; height: auto; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6)); }
.hud-streak {
  position: absolute;
  left: 92px;
  bottom: calc(20px + var(--safe-bottom));
  font: 900 13px var(--font);
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3d00, #ffb300);
  box-shadow: 0 0 18px rgba(255, 100, 0, 0.7);
  display: none;
}
.hud-streak.show { display: block; animation: fire 0.6s ease infinite alternate; }
@keyframes fire { to { box-shadow: 0 0 28px rgba(255, 170, 0, 0.95); } }

/* 力度条 */
.meter {
  position: absolute;
  right: max(16px, 7vw);
  top: 50%;
  width: 18px;
  height: min(42vh, 300px);
  transform: translateY(-40%);
  border-radius: 10px;
  background: rgba(5, 10, 24, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.55);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.meter.show { opacity: 1; }
.meter-zone { position: absolute; left: 0; right: 0; background: rgba(76, 255, 122, 0.45); }
.meter-perfect { position: absolute; left: 0; right: 0; background: #b6ffcb; box-shadow: 0 0 10px #4cff7a; }
.meter-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(0deg, #ffffff, #ffd23f); opacity: 0.9; }
.meter-mark { position: absolute; left: -2px; right: -2px; height: 3px; background: #fff; box-shadow: 0 0 6px #fff; display: none; }
.meter.good { border-color: var(--green); }
.meter.perfect { border-color: #fff; box-shadow: 0 0 22px var(--green); }
.meter.bad { border-color: var(--red); }

.feedback {
  position: absolute;
  left: 0;
  right: 0;
  top: 62%;
  text-align: center;
  font: 900 26px var(--font);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  opacity: 0;
}
.feedback.show { animation: fb 0.9s ease forwards; }
.feedback.perfect { color: var(--green); }
.feedback.good { color: #fff; }
.feedback.bad { color: #ffb3ba; }
@keyframes fb { 0% { opacity: 0; transform: scale(0.6); } 15% { opacity: 1; transform: scale(1.1); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

.popups { position: absolute; inset: 0; }
.pop {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font: 900 40px var(--display);
  white-space: nowrap;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7);
  animation: pop 1.1s ease forwards;
}
.pop small { display: block; font: 900 15px var(--font); letter-spacing: 2px; text-align: center; }
.pop.money { color: var(--gold); }
.pop.deep { color: #7dff4a; }
.pop.miss { color: rgba(255, 255, 255, 0.7); font-size: 22px; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); } 35% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -40px); } }

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 900 110px var(--display);
  color: #fff;
  text-shadow: 0 6px 30px rgba(255, 120, 30, 0.8);
  pointer-events: none;
}
.countdown span { animation: cd 0.8s ease forwards; }
@keyframes cd { 0% { opacity: 0; transform: scale(2); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(0.8); } }

.hint-bar {
  position: absolute;
  left: 50%;
  bottom: calc(130px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(5, 10, 24, 0.7);
  border: 1px solid var(--line);
  font-size: 14px;
  white-space: nowrap;
  display: none;
  animation: hint 1.4s ease infinite alternate;
}
.hint-bar.show { display: block; }
@keyframes hint { to { transform: translate(-50%, -6px); } }

.practice-bar {
  position: absolute;
  left: 96px;
  right: 10px;
  bottom: calc(12px + var(--safe-bottom));
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.practice-bar.show { display: flex; }
.practice-stats { font-size: 13px; font-weight: 800; text-shadow: 0 1px 4px #000; }
.practice-spots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.practice-spots button {
  pointer-events: auto;
  padding: 7px 9px;
  font-size: 12px;
  border-radius: 10px;
  background: rgba(5, 10, 24, 0.7);
  border: 1px solid var(--line);
}
.practice-spots button.on { background: var(--gold); color: #1a1300; font-weight: 800; }

/* ---------- 结算 ---------- */
.end-score { font: 900 84px var(--display); line-height: 1; margin: 8px 0 4px; }
.end-score small { font-size: 22px; color: var(--muted); margin-left: 6px; }
.end-line { color: #dfe6ff; font-size: 14px; }
.end-racks { display: flex; justify-content: center; gap: 6px; margin: 14px 0 6px; flex-wrap: wrap; }
.end-racks .r { background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 6px 8px; font-size: 11px; color: var(--muted); min-width: 48px; }
.end-racks .r b { display: block; font: 900 17px var(--display); color: #fff; }
.end-note { color: var(--gold); font-size: 14px; min-height: 20px; margin-top: 4px; }

.touch { position: fixed; inset: 0; z-index: 5; touch-action: none; display: none; }
.touch.show { display: block; }

.rotate-tip { display: none; }

@media (min-width: 900px) {
  .meter { right: 22%; }
}
@media (max-height: 520px) {
  .hud-dots { top: calc(52px + var(--safe-top)); }
  .hud-spot { top: calc(76px + var(--safe-top)); }
  .meter { height: 52vh; }
  .hint-bar { bottom: 70px; }
}
