:root {
  color-scheme: dark;
  --ink: #f5f4df;
  --muted: #b6c1b3;
  --panel: rgba(7, 18, 29, 0.82);
  --panel-strong: rgba(12, 34, 54, 0.94);
  --orange: #ff7a1a;
  --orange-2: #f6b24d;
  --cyan: #70e7ff;
  --green: #0d7c42;
  --line: rgba(255, 122, 26, 0.92);
  --border: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 16% 18%, rgba(66, 175, 132, 0.32), transparent 28%),
    radial-gradient(circle at 88% 10%, rgba(255, 122, 26, 0.22), transparent 24%),
    linear-gradient(135deg, #06131f 0%, #0d2330 42%, #2a1735 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.14;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

.app-shell {
  width: min(1320px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--orange-2);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: -0.04em; }
h1 { font-size: clamp(1.8rem, 4.2vw, 3.6rem); line-height: 0.95; }
h2 { font-size: 1.3rem; }

.subtitle {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(2, 8, 16, 0.36);
  color: #dbe6d7;
  font-size: 0.86rem;
}

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.cue-dot   { background: #fff8ee; }
.target-dot{ background: #d6253a; }   /* 红球 */
.ghost-dot { background: #ffd20a; }   /* 彩球（黄） */

.simulator-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(2, 14, 24, 0.86), rgba(20, 43, 61, 0.76));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(18px);
}

.table-wrap {
  min-width: 0;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.06), transparent 34%), #07101a;
}

.table-svg {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  user-select: none;
}

.table-back {
  fill: #0a1622;
  stroke: rgba(255, 230, 180, 0.22);
  stroke-width: 2;
}

.rail {
  fill: url("#railWood");
  stroke: rgba(255, 230, 180, 0.18);
  stroke-width: 2;
}

.cushion {
  fill: url("#railCushion");
  opacity: 0.85;
}

.felt {
  fill: url("#feltGlow");
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 2;
  filter: url("#softShadow");
}

.grid-line {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-dasharray: 6 8;
  stroke-width: 1.2;
}

/* 斯诺克发球区线条与圆点 */
.snk-line {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.6;
  fill: none;
}
.snk-arc {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.6;
  fill: none;
}
.snk-spot {
  fill: rgba(255, 255, 255, 0.85);
}

.pocket {
  fill: #020307;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 3;
}

.diamond-hit {
  fill: rgba(255, 255, 255, 0.95);
  stroke: rgba(12, 23, 38, 0.9);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.16s ease, fill 0.16s ease;
}

.diamond-hit.is-hot,
.direction-active .diamond-hit:hover {
  fill: #ffefe1;
  stroke: var(--orange);
}

.diamond-text {
  fill: #172234;
  font-size: 14px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.route-segment {
  stroke: var(--line);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 7px rgba(255, 122, 26, 0.55));
  fill: none;
}

.route-guide {
  stroke: rgba(112, 231, 255, 0.62);
  stroke-width: 2;
  stroke-dasharray: 8 10;
  fill: none;
}

.impact {
  fill: rgba(255, 255, 255, 0.92);
  stroke: var(--orange);
  stroke-width: 4;
}

.ball {
  cursor: grab;
  filter: url("#ballShadow");
}
.ball:active { cursor: grabbing; }

.ball-label {
  fill: #102033;
  font-size: 12px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  color: #dce7d8;
  font-size: 0.86rem;
  font-weight: 800;
}

select, input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 11px 12px;
  color: #0d1a25;
  background: #f2f5ed;
  font: inherit;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.16);
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  color: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

button:hover { transform: translateY(-1px); filter: brightness(1.08); }

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button {
  background: linear-gradient(135deg, #ff6a00, #f4a31f);
  box-shadow: 0 12px 28px rgba(255, 106, 0, 0.28);
}
.primary-button.is-active {
  background: linear-gradient(135deg, #20d0ff, #1d856c);
}

.secondary-button, .ghost-button {
  background: rgba(255, 255, 255, 0.12);
}
.ghost-button { padding: 10px 12px; color: #d8e4d4; }

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.readout div {
  padding: 12px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-strong);
}
.readout span { display: block; color: var(--muted); font-size: 0.72rem; }
.readout strong { display: block; margin-top: 4px; color: #fff7e6; font-size: 1.35rem; }

.hint {
  min-height: 48px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 16px;
  color: #eaf3e7;
  line-height: 1.55;
  background: rgba(255, 122, 26, 0.12);
  border: 1px solid rgba(255, 122, 26, 0.25);
}

.path-info {
  padding: 14px 16px;
  border: 1px solid rgba(112, 231, 255, 0.16);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15, 36, 63, 0.9), rgba(18, 45, 74, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.table-path-info { margin: 0 18px 18px; }

.path-info h3 { margin: 0 0 12px; color: #eef8ff; font-size: 0.95rem; letter-spacing: 0.02em; }

.path-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin: 0 0 10px;
}
.path-stats div { display: flex; gap: 8px; color: #eef8ff; font-size: 0.86rem; line-height: 1.45; }
.path-stats dt { min-width: 72px; color: #ffffff; font-weight: 900; }
.path-stats dd { margin: 0; color: #d5e5f0; font-weight: 800; }

.path-points {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: #f7fbff;
  font-size: 0.86rem;
  line-height: 1.45;
}
.path-empty { color: var(--muted); font-size: 0.86rem; line-height: 1.6; }

.ball-forms {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}
.ball-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}
.ball-title { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-width: 1080px) {
  .hero, .simulator-card { grid-template-columns: 1fr; }
  .simulator-card { display: flex; flex-direction: column; }
  .hero { align-items: start; flex-direction: column; }
  .legend { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .app-shell { width: min(100vw - 16px, 1320px); padding-top: 12px; }
  .simulator-card, .control-panel { padding: 10px; border-radius: 20px; }
  .action-row, .readout, .path-stats, .coords { grid-template-columns: 1fr; }
}
