
:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --line:rgba(15,23,42,.14);
  --btn:#ffffff;
  --btnText:#0f172a;
  --primary:#2563eb;
  --danger:#dc2626;
  --shadow: 0 18px 40px rgba(2,6,23,.10);
  --radius:18px;
  --pad:14px;
}

html[data-theme="dark"]{
  --bg:#0b1220;
  --card:#0f1b2e;
  --text:#e5e7eb;
  --muted:#a5b4fc;
  --line:rgba(226,232,240,.14);
  --btn:#101f36;
  --btnText:#e5e7eb;
  --shadow: 0 20px 50px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app{ max-width: 1280px; margin: 0 auto; padding: 14px; }

.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand .site{ font-weight: 900; letter-spacing:.4px; }
.brand .title{ font-weight: 900; font-size: 18px; margin-top:2px; }
.ver{ font-weight: 900; opacity:.8; font-size: 12px; padding-left:8px; }

.top-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }

.grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 14px;
  align-items:start;
}
@media (max-width: 1000px){
  .grid{ grid-template-columns: 1fr; }
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
}

.card-hd{
  display:flex; align-items:flex-start; justify-content:space-between; gap:12px;
  margin-bottom: 10px;
}
.card h2{ margin:0; font-size:18px; }
.muted{ color: var(--muted); font-weight: 700; }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.field{ flex:1; min-width: 220px; }
label{ display:block; font-weight: 900; margin: 0 0 6px; }
input{
  width:100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.02);
  color: var(--text);
}
html[data-theme="dark"] input{ background: rgba(255,255,255,.04); }
.hint{ margin-top:6px; color: var(--muted); font-size: 12px; font-weight:700; }
.ok{ margin-top:8px; font-weight: 900; }

.btn{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  font-weight: 900;
  min-height: 44px;
}
.btn:hover{ filter: brightness(0.98); }
.btn-primary{
  composes: btn;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(37,99,235,.35);
  background: rgba(37,99,235,.12);
  color: var(--text);
  font-weight: 900;
  min-height: 44px;
}
.btn-danger{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(220,38,38,.35);
  background: rgba(220,38,38,.12);
  color: var(--text);
  font-weight: 900;
  min-height: 44px;
}

.btn-team{
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  font-weight: 1000;
  letter-spacing: .6px;
  min-width: 88px;
  min-height: 48px;
}
.btn-team.us.active{ background:#16a34a; color:#fff; border-color:#15803d; }
.btn-team.opp.active{ background:#dc2626; color:#fff; border-color:#b91c1c; }
.btn-team:not(.active){ opacity:.92; }

.banner{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 900;
  background: rgba(0,0,0,.03);
}
html[data-theme="dark"] .banner{ background: rgba(255,255,255,.05); }

.team-row{ align-items:center; }
.mode-row .spacer{ flex:1; }

.modebtn.active, .split.active, .qbtn.active{
  border-width: 2px;
  box-shadow: 0 12px 24px rgba(0,0,0,.12);
}

.subhd{ margin-top: 10px; font-weight: 1000; letter-spacing:.4px; }
.player-grid{
  margin-top: 8px;
  display:grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 8px;
}
@media (max-width: 740px){
  .player-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.player-btn{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.02);
  padding: 8px 8px;
  min-height: 54px;
  font-weight: 1000;
  display:flex; flex-direction:column; justify-content:center; align-items:center;
}
html[data-theme="dark"] .player-btn{ background: rgba(255,255,255,.05); }
.player-btn.active{ outline: 3px solid rgba(37,99,235,.35); }
.player-btn .num{ font-size: 16px; line-height: 1; }
.player-btn .name{ font-size: 10px; font-weight: 900; opacity:.86; margin-top:3px; text-align:center; }

.stat-grid{
  margin-top: 8px;
  display:grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 8px;
}
@media (max-width: 740px){
  .stat-grid{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.stat-btn{
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.02);
  padding: 10px 10px;
  min-height: 52px;
  font-weight: 1000;
  text-align:center;
}
html[data-theme="dark"] .stat-btn{ background: rgba(255,255,255,.05); }
.stat-btn:hover{ filter: brightness(0.98); }

.loghd{ display:flex; justify-content:space-between; align-items:center; margin-top: 12px; font-weight: 1000; }
.log{
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 220px;
  overflow:auto;
  background: rgba(0,0,0,.02);
}
html[data-theme="dark"] .log{ background: rgba(255,255,255,.04); }
.log .item{
  padding: 10px 10px;
  border-bottom: 1px dashed rgba(0,0,0,.12);
  font-weight: 800;
  display:flex;
  justify-content:space-between;
  gap:10px;
}
html[data-theme="dark"] .log .item{ border-bottom-color: rgba(255,255,255,.12); }
.log .item:last-child{ border-bottom:none; }
.log .item .meta{ opacity:.85; font-weight:900; }

.sheet .tables{ margin-top: 12px; display:grid; grid-template-columns: 1fr; gap:12px; }
.table-wrap h3{ margin: 0 0 8px; }
.table{
  width:100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow:hidden;
}
.table th, .table td{
  padding: 10px 8px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  text-align:center;
  font-weight: 900;
}
html[data-theme="dark"] .table th, html[data-theme="dark"] .table td{ border-bottom-color: rgba(255,255,255,.10); }
.table th{
  background: rgba(0,0,0,.04);
  text-transform: uppercase;
  letter-spacing: .35px;
  font-size: 12px;
}
html[data-theme="dark"] .table th{ background: rgba(255,255,255,.06); }
.table td:first-child, .table th:first-child{ text-align:left; padding-left: 12px; }

.totals-grid{
  margin-top: 10px;
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:10px;
}
@media (max-width: 980px){ .totals-grid{ grid-template-columns: 1fr; } }
.tot-card{
  border:1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(0,0,0,.02);
}
html[data-theme="dark"] .tot-card{ background: rgba(255,255,255,.04); }
.tot-card h4{
  margin:0 0 6px;
  font-size: 13px;
  letter-spacing:.4px;
  text-transform:uppercase;
  opacity:.9;
}
.tot-row{
  display:flex; justify-content:space-between; gap:10px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(0,0,0,.10);
}
html[data-theme="dark"] .tot-row{ border-bottom-color: rgba(255,255,255,.10); }
.tot-row:last-child{ border-bottom:none; }
.tot-row b{ font-weight: 1000; }

/* modal */
.modal{
  position:fixed; inset:0;
  background: rgba(2,6,23,.55);
  display:flex; align-items:center; justify-content:center;
  padding: 14px;
}
.modal-card{
  width:min(860px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.modal-hd{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.modal-title{ font-weight: 1000; font-size: 16px; }
.modal-bd{ margin-top: 10px; }


/* Ensure modal is hidden unless opened */
.modal[hidden]{ display:none !important; }


/* ---- COMPACT BUTTON UPDATE (v1.2) ---- */
.btn{
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}
.btn-team{
  min-height: 42px;
  min-width: 76px;
  padding: 8px 10px;
  font-size: 13px;
}
.qbtn{
  min-height: 36px;
  min-width: 56px;
  font-size: 12px;
}
.modebtn{
  min-height: 38px;
  font-size: 13px;
}
.player-btn{
  min-height: 48px;
  padding: 6px;
}
.player-btn .num{ font-size: 14px; }
.player-btn .name{ font-size: 9px; }

.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
}
.stat-btn{
  min-height: 46px;
  font-size: 12px;
  padding: 8px;
}

/* tighten card spacing */
.card{ padding: 12px; }
.row{ gap: 8px; }


/* v1.4 layout tightening */
.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
}
.log{
  max-height: 260px;
}


/* -------- GLOBAL COMPACT BUTTON PASS (v1.5) -------- */
.btn,
.btn-primary,
.btn-danger{
  min-height: 36px !important;
  padding: 6px 8px !important;
  font-size: 12px !important;
  border-radius: 10px !important;
}

.btn-team{
  min-height: 38px !important;
  min-width: 68px !important;
  padding: 6px 8px !important;
  font-size: 12px !important;
}

.qbtn{
  min-height: 32px !important;
  min-width: 48px !important;
  font-size: 11px !important;
}

.modebtn{
  min-height: 34px !important;
  font-size: 12px !important;
}

.player-btn{
  min-height: 44px !important;
  padding: 4px !important;
}
.player-btn .num{ font-size: 13px !important; }
.player-btn .name{ font-size: 8px !important; }

.stat-btn{
  min-height: 40px !important;
  font-size: 11px !important;
  padding: 6px !important;
}

/* tighten headers */
.subhd{ font-size: 13px; }


/* -------- PRINT SHEET -------- */
@media print{
  body{ background:#fff !important; }
  .topbar, .card:not(.print-only), .modal{ display:none !important; }
  .print-sheet{ display:block !important; }
  .print-sheet h1{ margin:0 0 6px; }
  .print-sheet h2{ margin:14px 0 6px; }
  .print-sheet h3{ margin:12px 0 6px; }
  .print-sheet .meta{ font-weight:900; margin-bottom:10px; }
  .print-sheet .qhdr{ margin-top: 14px; border-top:2px solid #000; padding-top:8px; }
  .print-sheet table{ width:100%; border-collapse:collapse; }
  .print-sheet th, .print-sheet td{ border:1px solid #000; padding:6px 6px; font-size:12px; }
  .print-sheet th{ background:#eee; text-transform:uppercase; letter-spacing:.3px; }
}


/* -------- v1.7: print-preview look + scroll -------- */
.modal-bd{
  max-height: 72vh;
  overflow: auto;
  padding-right: 6px;
}

.print-sheet{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: #000;
}
.print-sheet h1{ font-size: 16px; }
.print-sheet h2{ font-size: 14px; }
.print-sheet h3{ font-size: 13px; }
.print-sheet .meta{ font-size: 12px; }
.print-sheet th, .print-sheet td{ font-size: 11px; padding: 4px 5px; }
.print-sheet .qhdr{ border-top: 2px solid #000; padding-top: 6px; margin-top: 10px; }

/* Even smaller controls */
.btn, .btn-primary, .btn-danger{
  min-height: 32px !important;
  padding: 5px 7px !important;
  font-size: 11px !important;
  border-radius: 9px !important;
}
.btn-team{
  min-height: 34px !important;
  min-width: 62px !important;
  padding: 5px 7px !important;
  font-size: 11px !important;
}
.qbtn{
  min-height: 30px !important;
  min-width: 44px !important;
  font-size: 10px !important;
}
.player-btn{ min-height: 40px !important; }
.player-btn .num{ font-size: 12px !important; }
.player-btn .name{ font-size: 8px !important; }
.stat-btn{ min-height: 36px !important; font-size: 10px !important; }

/* -------- v1.8 tweaks -------- */

/* Quarter buttons: pink when active */
.qbtn.active{
  background: #ec4899 !important;   /* pink */
  border-color: #db2777 !important;
  color: #fff !important;
}

/* Left column: slightly smaller stat buttons + running log */
.stat-grid.compact{
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 6px;
}
.stat-btn{
  min-height: 32px !important;
  font-size: 10px !important;
  padding: 5px 6px !important;
  border-radius: 10px !important;
}

.log{
  max-height: 210px !important;
}
.log .item{
  padding: 8px 8px !important;
  font-size: 11px !important;
}
.log .item .meta{
  font-size: 10px !important;
}

/* Tiny icon button */
.icon-btn{
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--btnText);
  border-radius: 10px;
  padding: 4px 8px;
  min-height: 28px;
  font-weight: 1000;
}
.icon-btn:hover{ filter: brightness(0.98); }
