/* Volleyball - styles.  One page, no framework, no external font.
   Note on [hidden]: nothing here sets `display` on a class that is also toggled with `hidden`,
   because any class rule that sets display beats [hidden] and leaves an invisible panel that
   still eats every click. */
:root {
  --ink: #eef2f8;
  --dim: #9fb0c6;
  --bg: #0a0e16;
  --panel: #131a27;
  --edge: #24304a;
  --home: #2f6fd0;
  --away: #e2622a;
  --good: #45c47a;
  --bad: #e8604f;
  --warn: #e8b84f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; min-height: 100%;
}
[hidden] { display: none !important; }

.bar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 16px; background: #0d1320; border-bottom: 1px solid var(--edge);
}
.bar h1 { margin: 0; font-size: 19px; letter-spacing: .04em; }
.score { display: flex; align-items: center; gap: 16px; }
.score .sets, .score .pts { display: flex; align-items: center; gap: 8px; }
.score b { font-variant-numeric: tabular-nums; font-size: 22px; }
.score .pts b { font-size: 30px; }
.score i { font-style: normal; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.score .serve { display: flex; align-items: center; gap: 7px; color: var(--dim); font-size: 13px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--dim); }
.dot.home { background: var(--home); }
.dot.away { background: var(--away); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tools label { color: var(--dim); font-size: 12px; display: flex; align-items: center; gap: 5px; }
select, button, input[type="range"] { font: inherit; }
select, button {
  background: #1b2436; color: var(--ink); border: 1px solid var(--edge);
  border-radius: 7px; padding: 5px 10px; cursor: pointer;
}
button:hover, select:hover { border-color: #3b5480; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--home); outline-offset: 2px; }

main { flex: 1; display: flex; gap: 14px; padding: 14px; align-items: flex-start; min-height: 0; }
.stage { position: relative; flex: 1 1 auto; min-width: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9;
  background: #0a1018; border: 1px solid var(--edge); border-radius: 10px;
}
.prompt {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgba(10, 14, 22, .88); border: 1px solid var(--edge);
  border-radius: 10px; padding: 10px 18px; text-align: center; min-width: 240px;
}
.prompt > div:first-child { font-size: 22px; letter-spacing: .12em; font-weight: 700; }
.timing { position: relative; height: 12px; margin: 8px 0 5px; background: #1b2436; border-radius: 6px; overflow: hidden; }
.timing .fill { height: 100%; width: 0; background: var(--home); }
.timing .sweet { position: absolute; left: 42%; top: 0; width: 16%; height: 100%; background: rgba(69, 196, 122, .34); }
.hint { color: var(--dim); font-size: 12px; }
.message {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(10, 14, 22, .92); border: 1px solid var(--edge);
  border-radius: 8px; padding: 7px 14px; font-size: 14px; max-width: 92%; text-align: center;
}
.message.good { border-color: var(--good); }
.message.bad { border-color: var(--bad); }

.side { width: 310px; flex: 0 0 310px; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 12px 14px; }
.panel h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); }
.panel h2 small { float: right; text-transform: none; letter-spacing: 0; font-weight: 400; }
.panel h2 + h2 { margin-top: 14px; }
.note { margin: 8px 0 0; color: var(--dim); font-size: 12px; }
.note b { color: var(--ink); font-weight: 600; }
.big { margin: 4px 0 0; font-size: 30px; font-variant-numeric: tabular-nums; }

.rotgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rotcell {
  background: #1b2436; border: 1px solid var(--edge); border-radius: 7px;
  padding: 7px 4px; text-align: center;
}
.rotcell b { display: block; font-size: 17px; }
.rotcell span { color: var(--dim); font-size: 11px; }
.rotcell.server { border-color: var(--home); background: #16233c; }
.rotcell.libero { border-color: var(--good); }

.slider { display: block; margin: 9px 0; color: var(--dim); font-size: 12px; }
.slider span { float: right; color: var(--ink); }
.slider input { width: 100%; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 7px; color: var(--dim); font-size: 12px; margin: 10px 0; }
.feas { margin: 6px 0 10px; font-size: 12px; }
.feas.ok { color: var(--good); }
.feas.warn { color: var(--warn); }
#aimBox button { width: 100%; }

.help {
  position: fixed; inset: 0; background: rgba(4, 7, 12, .82);
  display: flex; align-items: flex-start; justify-content: center; padding: 24px; overflow: auto;
  z-index: 20;
}
.helpinner {
  position: relative; max-width: 780px; background: var(--panel);
  border: 1px solid var(--edge); border-radius: 12px; padding: 22px 26px;
}
.helpinner h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .09em; color: var(--dim); margin: 20px 0 8px; }
.helpinner h2:first-of-type { margin-top: 0; }
.helpinner p, .helpinner li { font-size: 13.5px; color: #cdd8e8; }
.helpinner b { color: var(--ink); }
.helpinner ul { padding-left: 20px; }
.close {
  position: absolute; right: 10px; top: 8px; border: 0; background: transparent;
  color: var(--dim); font-size: 26px; line-height: 1; padding: 2px 8px;
}

@media (max-width: 900px) {
  main { flex-direction: column; }
  .side { width: 100%; flex: 0 0 auto; }
  .tools { margin-left: 0; }
  .score { flex-wrap: wrap; gap: 6px 14px; }
}
@media (max-width: 600px) {
  /* keep the court visible under the prompt and message on a phone */
  .prompt { bottom: 6px; padding: 4px 10px; min-width: 170px; }
  .prompt > div:first-child { font-size: 15px; }
  .timing { height: 9px; margin: 4px 0 3px; }
  .hint { font-size: 11px; }
  .message { top: 6px; padding: 4px 10px; font-size: 12px; }
}
