:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1d232c;
  --line: #2a313c;
  --text: #e6edf3;
  --muted: #8b96a5;
  --accent: #3fb6ff;
  --good: #3fcf8e;
  --warn: #f0b429;
  --bad: #ff6b6b;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

header.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
header.top .brand { font-weight: 800; letter-spacing: .02em; }
header.top .brand span { color: var(--accent); }
header.top .spacer { flex: 1; }
main { padding: 20px; max-width: 1700px; margin: 0 auto; }

button, .btn { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #04121c; font-weight: 650; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 3px 8px; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; min-height: 90px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; }
.pill.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.guess { border-style: dashed; }
.error { color: var(--bad); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; z-index: 50; }

/* school picker */
.picker { position: relative; }
.picker .results { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; max-height: 320px; overflow: auto; z-index: 20; }
.picker .results div { padding: 7px 10px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.picker .results div:hover, .picker .results div.on { background: var(--line); }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255,255,255,.25); flex: none; }

/* match list */
.matches { display: grid; gap: 10px; }
.match { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; align-items: center; }

/* prep */
.sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.sides > section { min-width: 0; }
.table-wrap { overflow-x: auto; }
@media (max-width: 1100px) { .sides { grid-template-columns: 1fr; } }
.side-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.side-head .tri { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.stack { display: grid; gap: 14px; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress div { height: 100%; width: 40%; background: var(--accent); animation: slide 1.1s infinite ease-in-out; }
@keyframes slide { from { margin-left: -40%; } to { margin-left: 100%; } }

.colors { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.colors .choices { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.colors .choices button.sw { width: 28px; height: 28px; padding: 0; border-radius: 7px; border: 2px solid transparent; }
.colors .choices button.sw.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }
.colors input[type=color] { width: 34px; height: 30px; padding: 0 2px; }
.jersey { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
  font-size: 20px; border: 1px solid rgba(255,255,255,.2); }
.jerseys { display: flex; gap: 10px; align-items: end; }
.jerseys figure { margin: 0; text-align: center; font-size: 11px; color: var(--muted); }

table.roster { width: 100%; border-collapse: collapse; font-size: 14px; }
table.roster th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); background: var(--panel); }
table.roster td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.roster tr.hidden td { opacity: .35; }
table.roster td.num { font-weight: 800; font-size: 17px; width: 38px; text-align: center; }
table.roster td.stat { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.face { width: 40px; height: 50px; border-radius: 6px; object-fit: cover; object-position: top; background: var(--panel-2);
  display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 13px; }
[contenteditable] { outline: none; border-radius: 4px; padding: 1px 3px; }
[contenteditable]:hover { background: var(--panel-2); }
[contenteditable]:focus { background: var(--bg); box-shadow: 0 0 0 1px var(--accent); }
.hints { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.coach { display: flex; gap: 10px; align-items: center; }
.coach img, .coach .face { width: 34px; height: 42px; }

/* login */
.login { max-width: 340px; margin: 12vh auto; }

/* ---------------------------------------------------------------- court */
.floor { display: grid; gap: 8px; }
.benches { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.coachbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; }
.benches .coachbar:last-child { flex-direction: row-reverse; text-align: right; }
.coachbar img { width: 34px; height: 42px; border-radius: 6px; object-fit: cover; object-position: top; }
.coach-team { font-weight: 800; letter-spacing: .03em; }
.coach-name { color: var(--muted); font-size: 13px; }
.court { display: grid; grid-template-columns: 1fr 10px 1fr; background: #1f5f3a; border: 3px solid #e8eef0;
  border-radius: 6px; padding: 10px; gap: 0; }
.net { background: repeating-linear-gradient(0deg, #e8eef0 0 6px, #9aa5ad 6px 9px); border-radius: 3px; margin: -10px 0; }
.half { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); gap: 6px; padding: 0 8px; }
.half.left { border-right: 2px dashed rgba(255,255,255,.35); }   /* attack line side */
.half.right { border-left: 2px dashed rgba(255,255,255,.35); }
.tile { position: relative; background: rgba(8, 20, 14, .55); border: 2px solid transparent; border-radius: 10px;
  padding: 8px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px;
  align-items: center; min-height: 64px; cursor: pointer; user-select: none; }
.tile:hover { border-color: rgba(255,255,255,.35); }
.tile.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,182,255,.35); }
.tile.flag { border-color: var(--warn); border-style: dashed; }
.tile.serving { box-shadow: inset 0 0 0 2px #ffe066; }
.tile-photo { grid-row: span 2; width: 40px; height: 50px; object-fit: cover; object-position: top; border-radius: 6px; }
.tile-num { grid-row: span 2; width: 58px; height: 58px; border-radius: 10px; display: grid; place-items: center;
  font-size: 30px; font-weight: 900; border: 1px solid rgba(255,255,255,.25); }
.tile:has(.tile-photo) { grid-template-columns: auto auto 1fr; }
.tile-photo + .tile-num { grid-row: span 2; width: 46px; height: 46px; font-size: 24px; }
.tile-name { font-weight: 750; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: #c9d4cd; }
.tile-pos { opacity: .7; }
.tile-role { border: 1px solid rgba(255,255,255,.3); border-radius: 5px; padding: 0 5px; font-weight: 700; }
.ball { color: #ffe066; font-size: 15px; }

/* ------------------------------------------------------------- operator */
.status { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; }
.status-side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-side:last-child { justify-content: flex-end; }
.set-no { font-size: 20px; font-weight: 800; }
.under { display: grid; grid-template-columns: 1fr minmax(320px, 1.2fr) 1fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .under { grid-template-columns: 1fr; } }
.bench { display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 9px; border-radius: 8px; }
.chip.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(63,182,255,.35); }
.chip.lib { border-style: dashed; }
.chip.used { opacity: .45; }
.prompts { display: grid; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.prompt { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; background: var(--panel-2); border-left: 4px solid var(--line); }
.prompt.required { border-left-color: var(--bad); }
.prompt.likely { border-left-color: var(--warn); }
.prompt.maybe { border-left-color: var(--accent); }
kbd { font: 700 13px ui-monospace, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.warning { color: var(--warn); }
.editbar { background: rgba(240,180,41,.12); border: 1px solid var(--warn); color: var(--warn); border-radius: 8px;
  padding: 8px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.log { display: grid; gap: 2px; }
.keys { border-top: 1px solid var(--line); padding-top: 8px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; }
.modal .panel { min-width: 340px; }
.lineup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #1f5f3a; padding: 10px; border-radius: 8px; }
.lineup-grid.left { border-right: 6px solid #e8eef0; }
.lineup-grid.right { border-left: 6px solid #e8eef0; }
.lineup-slot { background: rgba(8,20,14,.55); border: 2px solid transparent; border-radius: 8px; padding: 8px; min-height: 64px;
  cursor: pointer; position: relative; }
.lineup-slot.selected { border-color: var(--accent); }
.lineup-slot button { position: absolute; top: 4px; right: 4px; }

/* -------------------------------------------------------------- display */
body.display { overflow: hidden; }
body.display #root { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 14px 18px; }
body.display .floor { grid-template-rows: auto 1fr; min-height: 0; }
body.display .court { min-height: 0; }
body.display .tile { min-height: 0; padding: 10px 12px; }
body.display .tile-num { width: 9vh; height: 9vh; font-size: 5.4vh; }
body.display .tile-photo { width: 8vh; height: 10vh; }
body.display .tile-photo + .tile-num { width: 7vh; height: 7vh; font-size: 4.2vh; }
body.display .tile-name { font-size: 3.2vh; }
body.display .tile-meta { font-size: 1.8vh; }
body.display .coachbar { padding: 8px 14px; }
body.display .coachbar img { width: 5vh; height: 6vh; }
body.display .coach-team { font-size: 2.6vh; }
body.display .coach-name { font-size: 2.2vh; color: var(--text); }
body.display .tile.flag { border-color: #ffe066; border-style: solid; box-shadow: 0 0 0 3px rgba(255,224,102,.35); }
.dhead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.dstatus { display: flex; gap: 10px; align-items: center; }
.dhead .dstatus:last-child { justify-content: flex-end; }
.dteam { font-size: 3.4vh; font-weight: 900; letter-spacing: .03em; }
.dsets { font-size: 3.4vh; font-weight: 900; color: var(--accent); }
.dset { font-size: 2.6vh; font-weight: 800; color: var(--muted); letter-spacing: .1em; }
.dfoot { display: flex; gap: 12px; align-items: center; }
.changes { flex: 1; display: flex; gap: 22px; font-size: 2.2vh; font-weight: 650; overflow: hidden; white-space: nowrap; }
.display-wait { display: grid; place-content: center; gap: 10px; height: 100vh; text-align: center; }
