/* Snooker - the styling.  A dark room with a lit table, which is what a match looks like.
   [hidden] is declared FIRST and with !important: any later class rule that sets `display`
   would otherwise win over it and leave an invisible panel swallowing every click. */
[hidden] { display: none !important; }

:root {
  --bg: #0e1114; --panel: #171b20; --panel2: #1e242a; --line: #2b333b;
  --ink: #e8edf2; --dim: #98a4b0; --faint: #6d7a86;
  --cloth: #16663b; --gold: #d9a441; --warn: #e0663d; --good: #4fbf7a;
  --red: #b41616; --yellow: #e6c41b; --green: #0b6f32; --brown: #6f4521;
  --blue: #164ba5; --pink: #e57a8c; --black: #161513; --white: #f2efe8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.top {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px 10px; border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 21px; letter-spacing: 0.02em; font-weight: 650; }
.sub { margin: 0; color: var(--dim); font-size: 13px; flex: 1 1 240px; }
.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.ghost:hover { border-color: var(--gold); color: var(--gold); }
.ghost.small { font-size: 12px; padding: 4px 9px; }

.wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px 20px 28px; }
@media (max-width: 940px) { .wrap { grid-template-columns: 1fr; } }

.stage { position: relative; min-width: 0; }
#table {
  width: 100%; height: auto; aspect-ratio: 16 / 10; display: block;
  background: #0a0d10; border: 1px solid var(--line); border-radius: 10px; touch-action: none;
}
.warn { color: var(--warn); margin: 8px 0 0; font-size: 13px; }
.flash {
  position: absolute; left: 12px; right: 12px; bottom: 58px; margin: 0;
  background: rgba(20,24,29,0.94); border: 1px solid var(--gold); color: var(--gold);
  padding: 9px 12px; border-radius: 8px; font-size: 13px;
}
.viewbar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.vb {
  background: var(--panel); color: var(--dim); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 13px; font: inherit; font-size: 13px; cursor: pointer;
}
.vb.on { color: var(--ink); border-color: var(--gold); background: var(--panel2); }
.vb.skip { margin-left: auto; color: var(--gold); }

.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.side.turn { border-color: var(--gold); background: var(--panel2); }
.pname { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.pts { font-size: 32px; font-weight: 650; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hi { font-size: 11px; color: var(--faint); }
.strip {
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--dim);
  padding: 0 2px;
}
.strip b { color: var(--ink); font-variant-numeric: tabular-nums; }

.onbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.dot {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  vertical-align: -2px; margin-right: 8px; background: var(--red);
  box-shadow: inset -2px -3px 5px rgba(0,0,0,0.45), inset 2px 3px 5px rgba(255,255,255,0.18);
}
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.dot.green { background: var(--green); } .dot.brown { background: var(--brown); }
.dot.blue { background: var(--blue); } .dot.pink { background: var(--pink); }
.dot.black { background: var(--black); } .dot.any { background: linear-gradient(135deg,#e6c41b,#164ba5); }
.dot.free { background: linear-gradient(135deg,#d9a441,#e57a8c); }
.onname { font-size: 17px; font-weight: 600; text-transform: capitalize; }
.snook { color: var(--warn); font-size: 12px; letter-spacing: 0.08em; margin-left: 8px; }
.why { margin: 6px 0 0; font-size: 12px; color: var(--dim); line-height: 1.45; }

.group {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.group.free { border-color: var(--gold); }
.group h2 {
  margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--dim); font-weight: 600;
}
.rule { color: var(--faint); text-transform: none; letter-spacing: 0; font-weight: 400; }
.noms { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.nom {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; font: inherit;
  font-size: 12px; cursor: pointer; color: var(--ink); background: var(--panel2);
}
.nom.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.nom.yellow { border-left: 4px solid var(--yellow); }
.nom.green { border-left: 4px solid var(--green); }
.nom.brown { border-left: 4px solid var(--brown); }
.nom.blue { border-left: 4px solid var(--blue); }
.nom.pink { border-left: 4px solid var(--pink); }
.nom.black { border-left: 4px solid #4a4a46; }

.row { display: flex; align-items: center; gap: 10px; font-size: 13px; margin: 6px 0; }
.row span { color: var(--dim); min-width: 62px; }
.row input[type=range] { flex: 1; accent-color: var(--gold); min-width: 0; }
.row b { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.row select {
  flex: 1; background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13px;
}
.row.small { font-size: 12px; }
.mini { margin: 4px 0; font-size: 12px; color: var(--dim); }
.tiprow { display: flex; gap: 12px; align-items: center; margin: 8px 0; }
.tippad {
  width: 86px; height: 86px; flex: none; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 34% 30%, #ffffff, #cfd3d8 62%, #9aa1a8);
  border: 1px solid var(--line); cursor: crosshair; touch-action: none;
}
.tipdot {
  position: absolute; width: 13px; height: 13px; border-radius: 50%; background: #1d5fbf;
  border: 2px solid #eef2f6; transform: translate(-50%, -50%); left: 50%; top: 30%;
  pointer-events: none;
}
.tiptext { flex: 1; min-width: 0; }
.fire {
  width: 100%; margin-top: 8px; background: var(--cloth); color: #eafaf0;
  border: 1px solid #1e8b52; border-radius: 8px; padding: 10px; font: inherit;
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.fire:hover { background: #1a7d48; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--dim); margin-top: 8px; }
.check em { color: var(--faint); font-style: italic; }
.btnrow { display: flex; gap: 8px; }
.btnrow .ghost { flex: 1; }
.dpad {
  position: relative; height: 74px; border: 1px solid var(--line); border-radius: 6px;
  background: linear-gradient(180deg, #17492f, #0f3421); cursor: crosshair; touch-action: none;
  overflow: hidden;
}
.darc {
  position: absolute; left: 50%; bottom: -74px; width: 148px; height: 148px;
  margin-left: -74px; border: 1px solid rgba(230,235,240,0.6); border-radius: 50%;
}
.values { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; }
.val { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.swatch.red { background: var(--red); } .swatch.yellow { background: var(--yellow); }
.swatch.green { background: var(--green); } .swatch.brown { background: var(--brown); }
.swatch.blue { background: var(--blue); } .swatch.pink { background: var(--pink); }
.swatch.black { background: #33322e; }
.vname { flex: 1; color: var(--dim); }
.vnum { font-variant-numeric: tabular-nums; }
.log { max-height: 190px; overflow-y: auto; font-size: 12px; }
.entry { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(43,51,59,0.6); }
.entry .who { color: var(--faint); flex: none; min-width: 62px; }
.entry .what { color: var(--dim); }
.entry.foul .what { color: var(--warn); }
.entry.score .what { color: var(--good); }

.modal {
  position: fixed; inset: 0; background: rgba(6,8,10,0.82); display: flex;
  align-items: center; justify-content: center; padding: 18px; z-index: 40; overflow-y: auto;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; max-width: 460px; width: 100%;
}
.card.wide { max-width: 780px; max-height: 88vh; overflow-y: auto; }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h3 { margin: 18px 0 6px; font-size: 13px; color: var(--gold); letter-spacing: 0.03em; }
.card ul { margin: 6px 0; padding-left: 18px; }
.card li { margin: 5px 0; font-size: 13px; color: var(--dim); line-height: 1.5; }
.card li b, .card p b { color: var(--ink); }
.card p { font-size: 13px; color: var(--dim); line-height: 1.55; }
.card .big { font-size: 30px; color: var(--ink); font-weight: 650; margin: 4px 0; }
.card button {
  margin-top: 14px; background: var(--cloth); color: #eafaf0; border: 1px solid #1e8b52;
  border-radius: 8px; padding: 9px 18px; font: inherit; cursor: pointer;
}
#foulopts button {
  display: block; width: 100%; margin: 6px 0 0; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px; font: inherit;
  font-size: 13px; cursor: pointer;
}
#foulopts button:hover { border-color: var(--gold); }
.foot { border-top: 1px solid var(--line); padding: 14px 20px 26px; }
.foot p { margin: 0; font-size: 12px; color: var(--faint); }
.foot a { color: var(--dim); }
