:root {
  --bg: #0b0e13;
  --panel: rgba(16, 20, 27, 0.96);
  --panel-2: #161b24;
  --border: #262d3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --faint: #5b6373;
  --accent: #22d3ee;
  --accent-ink: #062a31;
  --good: #4ade80;
  --bad: #f87171;
  --amber: #fbbf24;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }

.xhair-overlay { position: fixed; left: 50%; top: 50%; width: 64px; height: 64px; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; }

/* 分段切换 */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { border: none; background: none; color: var(--muted); padding: 6px 16px; border-radius: 6px; }
.seg button:hover { background: var(--panel-2); color: var(--text); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.menu-left .mode-seg { margin-bottom: 14px; }
.mode-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.mode-row > span:first-child { color: var(--muted); font-size: 13px; }
.mode-row .note { margin: 0; }
.sys-btn { margin-top: 10px; }
.quick-ball { margin: -6px 0 18px; }

/* HUD */
#hud { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 5; pointer-events: none; }
.hud-item { background: rgba(10, 13, 18, 0.7); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; min-width: 96px; text-align: center; }
.hud-label { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.hud-item .num { font-size: 22px; font-weight: 600; }
#hud-raw { position: fixed; bottom: 12px; left: 14px; font-size: 12px; color: var(--faint); z-index: 5; pointer-events: none; }
#countdown { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 96px; font-weight: 700; color: var(--text);
  text-shadow: 0 4px 24px rgba(0,0,0,.6); z-index: 6; pointer-events: none; font-variant-numeric: tabular-nums; }

/* 覆盖层 & 面板 */
.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(5, 7, 10, 0.66); backdrop-filter: blur(6px); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px 28px; max-height: calc(100vh - 32px); overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); width: 100%; }
h1 { margin: 0; font-size: 34px; letter-spacing: 0.01em; }
h1 small { display: block; font-size: 15px; color: var(--accent); font-weight: 500; margin-top: 4px; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); margin: 10px 0 18px; }
.note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.error { color: var(--bad); font-size: 13px; margin: 10px 0 0; }

button { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: #3a4354; background: #1c2230; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: #4fdcf2; }
button.big { padding: 11px 22px; font-size: 15px; }
button.link { background: none; border: none; color: var(--muted); padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--text); }
kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 12px; }

.menu-panel { max-width: 1000px; display: grid; grid-template-columns: 340px 1fr; gap: 32px; }
.menu-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hint-list { color: var(--muted); font-size: 12.5px; line-height: 1.9; padding-left: 18px; margin: 18px 0 0; }
.sens-summary { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; font-size: 13px; line-height: 1.7; color: var(--muted); }
.sens-summary b { color: var(--text); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .t-label { font-size: 12px; color: var(--muted); }
.tile .t-value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .t-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; line-height: 1.4; }

.chart-block { margin-bottom: 14px; }
canvas.trend { width: 100%; height: 130px; display: block; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }

/* 设置 */
.settings-panel { max-width: 980px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-foot { margin-top: 12px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px 16px; margin: 0; min-width: 0; }
legend { padding: 0 6px; color: var(--accent); font-weight: 600; }
.field { display: block; margin-top: 10px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field output { color: var(--text); margin-left: 6px; font-variant-numeric: tabular-nums; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check > span { margin: 0; color: var(--text); }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field.inline > span { margin: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=number], select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
input[type=number] { width: 100%; }
input[type=color] { width: 44px; height: 28px; border: 1px solid var(--border); border-radius: 6px; background: none; padding: 0; }

.sens-row { display: grid; grid-template-columns: 32px 1fr 92px 32px; gap: 8px; align-items: center; }
.sens-row button { padding: 5px 0; }
.sens-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.sens-info > div { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.sens-info b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.sens-info span { font-size: 11.5px; color: var(--muted); }

.xhair-wrap { display: grid; grid-template-columns: 1fr 120px; gap: 14px; }
#xhair-preview { width: 120px; height: 120px; border-radius: 10px; border: 1px solid var(--border);
  background: linear-gradient(135deg, #3c4452, #1a1f28 55%, #6b7280); align-self: start; margin-top: 10px; }

.pause-panel { max-width: 520px; }
.pause-panel .menu-actions { margin-top: 18px; }

/* 结算 */
.results-panel { max-width: 1060px; }
.results-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.score-label { color: var(--muted); font-size: 13px; }
.score-big { font-size: 56px; font-weight: 700; line-height: 1.1; color: var(--accent); }
.formula { color: var(--muted); font-size: 13px; }
.badge { background: var(--amber); color: #3a2a00; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; margin-left: 6px; }
.section-title { margin-top: 4px; }
.replay canvas { width: 100%; height: 380px; display: block; background: #0e1219; border: 1px solid var(--border); border-radius: 10px; }
.replay-bar { display: grid; grid-template-columns: auto auto 1fr 110px; gap: 10px; align-items: center; margin-top: 10px; }
.replay-bar #btn-play { min-width: 84px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.lg-path { width: 18px; height: 2px; background: rgba(34, 211, 238, .7); }
.lg-hit { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.lg-miss { width: 9px; height: 9px; background: linear-gradient(45deg, transparent 42%, var(--bad) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, var(--bad) 42% 58%, transparent 58%); }
.lg-ball { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--accent); }
.lg-area { width: 14px; height: 9px; border: 1px dashed rgba(34, 211, 238, .5); }

#tooltip { position: fixed; z-index: 50; pointer-events: none; background: #0a0d12; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 9px; font-size: 12px; line-height: 1.5; color: var(--text); white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#tooltip .muted { color: var(--muted); }

@media (max-width: 860px) {
  .menu-panel, .settings-grid { grid-template-columns: 1fr; }
  .replay-bar { grid-template-columns: auto auto 1fr; }
  .replay-bar #play-time { grid-column: 1 / -1; }
}
