:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel-2: #1e242c;
  --line: #2a313b;
  --text: #e6e9ee;
  --muted: #99a3b0;
  --accent: #5fe0ff;
  --accent-ink: #06232c;
  --warn: #ffb86b;
  --radius: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
h2 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }

/* projector mode: pure black, nothing but the overlay canvas */
html.projector, html.projector body { background: #000; overflow: hidden; }
html.projector #app { display: none; }

.app { display: grid; gap: 14px; padding: 12px; max-width: 1760px; margin: 0 auto; }
@media (min-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr) 420px; align-items: start; }
  .stage { position: sticky; top: 12px; }
  .panel { max-height: calc(100vh - 24px); overflow-y: auto; padding-right: 2px; }
}
.stage, .panel { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.table-wrap { position: relative; width: 100%; }
#table { display: block; width: 100%; touch-action: none; border-radius: 6px; cursor: grab; outline-offset: 3px; }
#table.dragging { cursor: grabbing; }
.planning { position: absolute; left: 10px; bottom: 10px; padding: 3px 10px; border-radius: 99px; background: rgba(15,18,22,.86); border: 1px solid var(--line); font-size: 12px; color: var(--accent); }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.result { min-height: 1.4em; margin: -4px 0 0; color: var(--muted); font-size: 13px; }

.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }

.btn, .seg button, .tabs button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 12px; cursor: pointer; min-height: 36px;
}
.btn:hover, .seg button:hover, .tabs button:hover { border-color: #46515f; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 12px; }
:is(button, select, input, canvas, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; min-width: 44px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button[aria-pressed="true"] { background: #23404a; border-color: var(--accent); color: var(--accent); position: relative; z-index: 1; }

.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; }
.tabs button[aria-selected="true"] { background: #23404a; border-color: var(--accent); color: var(--accent); }

/* setup */
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
label { display: block; font-size: 12px; color: var(--muted); }
select {
  display: block; width: 100%; margin-top: 3px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 6px; min-height: 36px;
}
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-bottom: 10px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); min-height: 30px; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); }
@media (max-width: 460px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .checks { grid-template-columns: 1fr; }
}

/* ball chips and badges */
.tray { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 0; border: 2px solid transparent; background: none; border-radius: 50%; cursor: pointer; width: 38px; height: 38px; display: grid; place-items: center; }
.chip[aria-pressed="false"] { opacity: .32; filter: grayscale(.6); }
.chip[aria-pressed="false"]:hover { opacity: .6; }
.ball {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  box-shadow: inset -3px -4px 6px rgba(0,0,0,.35), inset 2px 2px 4px rgba(255,255,255,.3), 0 0 0 1px rgba(0,0,0,.5);
  flex: none;
}
.ball i { font-style: normal; font-weight: 700; font-size: 11px; line-height: 1; color: #111; background: #f7f4e8; border-radius: 50%; width: 17px; height: 17px; display: grid; place-items: center; }
.ball.sm { width: 22px; height: 22px; }
.ball.sm i { width: 13px; height: 13px; font-size: 8.5px; }

/* run-out list */
.shots { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.shot {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; text-align: left;
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; cursor: pointer; min-height: 44px;
}
.shot:hover { border-color: #46515f; }
.shot[aria-current="true"] { border-color: var(--accent); background: #1f313a; }
.shot .n { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; width: 1.4em; }
.shot .what { font-weight: 600; }
.shot .pct { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }
.shot .line { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; }
.shot .lead { display: flex; align-items: center; gap: 8px; grid-row: 1 / 3; }
.summary { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; }
.summary b { font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }
.note { color: var(--warn); font-size: 13px; margin-top: 8px; }

/* how to hit it */
.faces { display: grid; grid-template-columns: 1fr 1.7fr; gap: 12px; margin-bottom: 12px; align-items: start; }
figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center; }
figcaption { font-size: 12.5px; color: var(--text); }
.face { width: 100%; max-width: 150px; height: auto; display: block; }
.face.wide { max-width: 250px; }
.face.touch { touch-action: none; cursor: crosshair; }
.gauge { position: relative; height: 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.gauge span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2b8fb0, var(--accent)); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 2px 0 4px; }
.speedline { font-size: 13px; margin-bottom: 10px; }
.lines { margin: 0 0 10px; padding-left: 18px; }
.lines li { margin-bottom: 3px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.chances { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.chances div { background: var(--panel-2); border-radius: 6px; padding: 6px 10px; }
.chances small { display: block; color: var(--muted); font-size: 11px; }
.chances b { font-size: 18px; font-variant-numeric: tabular-nums; }
.alts { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.alt { width: 100%; display: flex; gap: 8px; align-items: center; text-align: left; font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; min-height: 40px; }
.alt[aria-pressed="true"] { border-color: var(--accent); background: #1f313a; }
.alt .sub { color: var(--muted); font-size: 12px; }
.alt .grow { flex: 1; min-width: 0; }
.slider { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: center; margin: 12px 0; color: var(--text); }
.slider input { width: 100%; accent-color: var(--accent); min-height: 32px; }
.slider span { grid-column: 1 / 3; color: var(--muted); font-size: 12.5px; }

/* projector */
.projector-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.handle {
  position: fixed; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(255,255,255,.15); color: #fff; font: 700 11px/30px system-ui, sans-serif; text-align: center;
  touch-action: none; cursor: move; z-index: 5;
}
.handle:focus-visible { outline: 2px solid #ffe600; }
.proj-hint { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); color: #fff; font: 13px system-ui, sans-serif; z-index: 6; text-align: center; }
