* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eef0f3;
  color: #1a1a1a;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.06);
}

/* header */
.app-header {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg,#0b3d91,#1d5fd4);
  color: #fff;
  flex-wrap: wrap;
  gap: 10px;
}
.app-header .logo-title { display: flex; align-items: center; gap: 10px; }
.app-header .ball { font-size: 26px; }
.app-header h1 { margin: 0; font-size: 19px; font-weight: 800; }
.app-header .season-pill {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 700;
  background: #ffd200; color: #0b3d91; margin-left: 8px;
}
.header-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.header-right .whoami { display: flex; align-items: center; gap: 6px; }
.header-right button.link-btn {
  background: none; border: none; color: #cfe0ff; text-decoration: underline;
  font-size: 12px; cursor: pointer; padding: 0;
}

/* tabs */
.tabbar { display: flex; gap: 6px; padding: 0 24px; background: #f7f9fd; border-bottom: 1px solid #e4e9f4; }
.tabbar button {
  padding: 12px 18px; border: none; background: transparent; font-size: 14px;
  font-weight: 700; cursor: pointer; color: #6b7999; border-bottom: 3px solid transparent;
}
.tabbar button.active { color: #0b3d91; border-bottom-color: #0b3d91; }

.tabview { display: none; }
.tabview.active { display: block; }

/* team picker */
.team-picker {
  display: flex; align-items: center; gap: 8px; padding: 14px 24px; flex-wrap: wrap;
  background: #f7f9fd; border-bottom: 1px solid #e4e9f4;
}
.team-picker .lbl { font-size: 11px; font-weight: 700; color: #8b93a4; text-transform: uppercase; margin-right: 4px; }
.pick-chip {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border-radius: 999px;
  background: #fff; border: 1.5px solid #dbe6fb; font-size: 12px; font-weight: 700; color: #0b3d91; cursor: pointer;
}
.pick-chip img { width: 18px; height: 18px; object-fit: contain; }
.pick-chip.open { background: #0b3d91; border-color: #0b3d91; color: #fff; }

/* board */
.board {
  padding: 18px 24px 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}
.board-empty { color: #8b93a4; font-size: 13px; padding: 20px 0; }

.team-col {
  flex: 1 1 320px;
  min-width: 300px;
  max-width: 400px;
  border: 1px solid #eee;
  border-radius: 14px;
  overflow: hidden;
}
.team-col-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: #fff4cc; border-bottom: 1px solid #f0e0a0;
}
.team-col-head img { width: 32px; height: 32px; object-fit: contain; }
.team-col-head .name { font-weight: 800; font-size: 14px; color: #0b3d91; margin: 0; }
.team-col-head .sub { font-size: 11px; color: #6b4f00; margin: 1px 0 0; }
.team-col-head .close { margin-left: auto; border: none; background: none; color: #a8863c; font-size: 15px; cursor: pointer; }
.team-col-head .record-badge {
  margin-left: auto; flex-shrink: 0; background: #0b3d91; color: #fff; font-weight: 800;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
}

.team-col-body { padding: 10px; }

.tl-node { position: relative; padding-left: 20px; margin: 0 0 8px; }
.tl-node::before {
  content: ""; position: absolute; left: 3px; top: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: #fff; border: 3px solid #0b3d91; z-index: 1;
}
.tl-node.past::before { background: #b9c6e0; border-color: #b9c6e0; }
.tl-node.picked::before { background: #17c463; border-color: #17c463; }
.tl-node::after {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: -8px; width: 2px; background: #dbe6fb;
}
.tl-node:last-child::after { display: none; }

.tl-row {
  display: flex; align-items: center; gap: 8px; background: #f7f9fd; border-radius: 10px; padding: 7px 10px; font-size: 12px;
}
.tl-row .wk { font-weight: 800; color: #0b3d91; width: 32px; flex-shrink: 0; font-size: 11px; }
.tl-row .datebit { font-size: 9px; color: #8b93a4; width: 34px; flex-shrink: 0; }
.tl-row img { width: 20px; height: 20px; object-fit: contain; flex-shrink: 0; }
.tl-row .opp { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .loc { color: #8b93a4; margin-right: 2px; font-weight: 400; }
.tl-toggle { display: flex; gap: 3px; flex-shrink: 0; }
.tl-toggle button {
  width: 26px; height: 24px; border-radius: 5px; border: none; font-weight: 800; font-size: 10px; cursor: pointer;
}
.tl-toggle button:disabled { cursor: not-allowed; opacity: 0.55; }
.tl-toggle .w { background: #eef0f3; color: #a8adba; }
.tl-toggle .w.on { background: #17c463; color: #fff; }
.tl-toggle .l { background: #eef0f3; color: #a8adba; }
.tl-toggle .l.on { background: #ff4b4b; color: #fff; }

.tl-bye {
  background: #fff4cc; color: #6b4f00; text-align: center; font-style: italic; font-size: 11px;
  padding: 6px; border-radius: 8px; padding-left: 10px;
}

.sc-progress {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 8px 10px; background: #eef4ff; border-radius: 10px; font-size: 11px; font-weight: 700; color: #0b3d91;
}
.sc-progress .bar { flex: 1; height: 6px; background: #dbe6fb; border-radius: 99px; margin: 0 8px; overflow: hidden; }
.sc-progress .bar span { display: block; height: 100%; background: #17c463; }
.sc-progress.locked { background: #ffe9e6; color: #a32d2d; }

/* grid tab */
.grid-controls { display: flex; align-items: center; gap: 10px; padding: 18px 24px 0; flex-wrap: wrap; }
.grid-controls select {
  padding: 8px 12px; border-radius: 8px; border: 1px solid #dbe6fb; font-size: 13px; font-weight: 700; color: #0b3d91;
}
.grid-note { font-size: 12px; color: #8b93a4; padding: 6px 24px 0; }

.grid-wrap { padding: 16px 24px 32px; overflow-x: auto; }
table.pred-grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.pred-grid th, table.pred-grid td {
  padding: 6px 8px; text-align: center; border-bottom: 1px solid #eee; white-space: nowrap;
}
table.pred-grid th { color: #0b3d91; font-size: 11px; border-bottom: 2px solid #0b3d91; }
table.pred-grid td:first-child, table.pred-grid th:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.cell-pill {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  border-radius: 6px; font-weight: 800; font-size: 11px;
}
.cell-pill.w { background: #d7f7dd; color: #0a7d2c; }
.cell-pill.l { background: #fde0df; color: #c22323; }
.cell-pill.locked { background: #eef1f6; color: #a8adba; }
.cell-pill.none { background: #f4f4f4; color: #ccc; }

/* how it works (front page) */
.how-it-works { background: #eef4ff; border-radius: 14px; padding: 16px 18px; margin-bottom: 20px; }
.how-it-works h2 { font-size: 16px; color: #0b3d91; }
.how-it-works-list { margin: 10px 0 0; padding-left: 18px; }
.how-it-works-list li { margin-bottom: 10px; font-size: 13px; line-height: 1.5; }

/* scoring tab */
.scoring-card { padding: 18px 24px 32px; }
.scoring-table { margin-top: 10px; }
.scoring-table td, .scoring-table th { text-align: left; vertical-align: top; }

/* admin tab */
.admin-gate { padding: 24px; }
#admin-content { padding: 0 24px 32px; }
.admin-player-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-radius: 10px; background: #f7f9fd; margin: 0 24px 8px;
}
.admin-player-row .apr-name { font-weight: 800; color: #0b3d91; font-size: 13px; }
.admin-player-row .apr-meta { font-size: 11px; color: #8b93a4; margin-top: 2px; }
.admin-delete-btn {
  background: #ffe4e4; color: #c22323; border: none; border-radius: 8px;
  padding: 6px 12px; font-weight: 700; font-size: 12px; cursor: pointer; flex-shrink: 0;
}
.admin-delete-btn.confirm { background: #ff4b4b; color: #fff; }
.admin-delete-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* name modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,61,145,0.55); display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-card { background: #fff; border-radius: 16px; padding: 28px; width: 320px; text-align: center; }
.modal-card .ball { font-size: 32px; }
.modal-card h2 { margin: 8px 0 4px; font-size: 18px; }
.modal-card p { font-size: 13px; color: #666; margin: 0 0 16px; }
.modal-card input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1.5px solid #dbe6fb; font-size: 14px; margin-bottom: 12px;
}
.modal-card button {
  width: 100%; padding: 10px; border-radius: 8px; border: none; background: #0b3d91; color: #fff;
  font-weight: 800; font-size: 14px; cursor: pointer;
}
.hidden { display: none !important; }

/* setup tab */
.setup-panel { padding: 20px 24px 32px; max-width: 900px; }
.setup-step { margin-bottom: 26px; }
.setup-step h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setup-help { font-size: 12px; color: #6b7999; margin: 0 0 10px; }
.pts-tag { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.pts-tag.pts-3 { background: #d7f7dd; color: #0a7d2c; }
.pts-tag.pts-2 { background: #eef4ff; color: #0b3d91; }
.pts-tag.pts-1 { background: #fff4cc; color: #7a5200; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.team-grid.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.team-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
  border-radius: 10px; cursor: pointer; font-size: 10px; font-weight: 700; text-align: center;
  background: #f7f9fd; color: #0b3d91; border: 2px solid transparent;
}
.team-chip img { width: 28px; height: 28px; object-fit: contain; }
.team-chip.sel { background: #fff4cc; border-color: #ffd200; }

.setup-save-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.setup-status { font-size: 12px; color: #6b7999; }
#setup-save-btn {
  padding: 10px 20px; border-radius: 8px; border: none; background: #0b3d91; color: #fff;
  font-weight: 800; font-size: 13px; cursor: pointer;
}
#setup-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* category badges on picks board */
.cat-badge { font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 999px; margin-right: 4px; }
.cat-badge.cat-my { background: #d7f7dd; color: #0a7d2c; }
.cat-badge.cat-group { background: #eef4ff; color: #0b3d91; }
.cat-badge.cat-wild { background: #fff4cc; color: #7a5200; }

/* banker button */
.banker-btn {
  border: none; border-radius: 6px; width: 24px; height: 24px; font-size: 12px; cursor: pointer;
  background: #f4f4f4; opacity: 0.5; flex-shrink: 0;
}
.banker-btn.on { background: #ffd200; opacity: 1; }
.banker-btn:disabled { cursor: not-allowed; }

/* grid tab additions */
.section-title { font-size: 14px; margin: 0 0 8px; }
.leaderboard-wrap { padding: 18px 24px 0; }
table.leaderboard-table { width: 100%; }
.view-toggle { display: flex; gap: 4px; }
.view-toggle button {
  padding: 8px 14px; border-radius: 8px; border: 1.5px solid #dbe6fb; background: #fff;
  font-size: 12px; font-weight: 700; color: #0b3d91; cursor: pointer;
}
.view-toggle button.active { background: #0b3d91; color: #fff; border-color: #0b3d91; }
.cell-pill.bad { background: #ffdada; color: #7a1212; }

/* "By user" picks grid — 18 weeks x 5 teams, color-coded */
.upg-card { border: 1px solid #e4e9f4; border-radius: 14px; overflow: hidden; margin: 0 24px 24px; }
.upg-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid #e4e9f4;
}
.upg-card-head h3 { margin: 0; font-size: 15px; color: #0b3d91; }
.upg-total { font-size: 12px; color: #6b7999; }
.upg-total strong { color: #1a1a1a; font-variant-numeric: tabular-nums; }

.upg-scroll { overflow-x: auto; }
table.upg-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 980px; font-size: 12px; }
table.upg-table th, table.upg-table td { padding: 0; text-align: center; }

.upg-col-head {
  padding: 8px 4px; font-size: 10.5px; font-weight: 800; color: #8b93a4;
  border-bottom: 1px solid #e4e9f4; background: #fff;
}
.upg-row-head {
  position: sticky; left: 0; z-index: 2; background: #fff; text-align: left;
  padding: 0 14px 0 18px; border-right: 1px solid #e4e9f4; min-width: 210px;
}
.upg-record-col-head { min-width: 64px; border-left: 1px solid #e4e9f4; }

table.upg-table tbody tr:last-child .upg-row-head,
table.upg-table tbody tr:last-child .upg-cell,
table.upg-table tbody tr:last-child .upg-record-cell { border-bottom: none; }
table.upg-table tbody tr .upg-row-head,
table.upg-table tbody tr .upg-cell,
table.upg-table tbody tr .upg-record-cell { border-bottom: 1px solid #e4e9f4; }

.upg-team-cell {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 18px;
}
.upg-team-cell img { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.upg-meta { min-width: 0; }
.upg-tname { font-weight: 800; font-size: 12.5px; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.upg-cell { padding: 6px; }
.upg-chip {
  width: 100%; height: 34px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  gap: 3px; font-weight: 800; font-size: 10.5px; letter-spacing: 0.01em; cursor: default; position: relative;
}
.upg-icon { font-size: 8px; line-height: 1; }
/* Colorblind-safe status pair (validated against dataviz palette checks —
   the plain green/red used elsewhere in this app fails CVD separation). */
.upg-win  { background: #e6f7e3; color: #0ca30c; }
.upg-loss { background: #fbe8e6; color: #d03b3b; }
.upg-none { background: #f4f4f4; color: #a8adba; }
.upg-bye {
  background: repeating-linear-gradient(45deg, #eef0f2, #eef0f2 4px, #e4e3df 4px, #e4e3df 8px);
  color: #6b7280; font-size: 9px; font-weight: 800; letter-spacing: 0.03em;
}
/* Once a week is graded: same fill color, a ring layered on top instead of
   a different color — thin ring for a correct call, bold ring for wrong. */
.upg-correct { box-shadow: inset 0 0 0 2px rgba(10, 125, 44, 0.55); }
.upg-wrong { box-shadow: inset 0 0 0 3px rgba(192, 32, 32, 0.85); }

.upg-record-cell { padding: 0 8px; border-left: 1px solid #e4e9f4; }
.upg-rec { font-weight: 800; font-size: 12.5px; color: #0b3d91; font-variant-numeric: tabular-nums; }

.upg-legend {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center; padding: 14px 18px;
  border-top: 1px solid #e4e9f4; font-size: 11.5px; color: #6b7999;
}
.upg-legend-item { display: flex; align-items: center; gap: 6px; }
.upg-swatch { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
.upg-swatch.upg-win { background: #e6f7e3; border: 1.5px solid #0ca30c; }
.upg-swatch.upg-loss { background: #fbe8e6; border: 1.5px solid #d03b3b; }
.upg-swatch.upg-bye {
  background: repeating-linear-gradient(45deg, #eef0f2, #eef0f2 3px, #e4e3df 3px, #e4e3df 6px);
  border: 1.5px solid #c3c2b7;
}
.upg-ring-demo { width: 16px; height: 16px; border-radius: 4px; background: #eef4ff; flex-shrink: 0; }
.upg-ring-demo.upg-correct { background: #eef4ff; box-shadow: inset 0 0 0 2px rgba(10, 125, 44, 0.55); }
.upg-ring-demo.upg-wrong { background: #eef4ff; box-shadow: inset 0 0 0 3px rgba(192, 32, 32, 0.85); }

/* shared hover tooltip (picks grid) */
.viz-tooltip {
  position: fixed; pointer-events: none; z-index: 50; background: #0b0b0b; color: #fff;
  font-size: 11.5px; padding: 8px 10px; border-radius: 8px; line-height: 1.45; max-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); opacity: 0; transform: translateY(4px);
  transition: opacity 0.1s ease, transform 0.1s ease;
}
.viz-tooltip.show { opacity: 1; transform: translateY(0); }
.viz-tooltip b { display: block; margin-bottom: 2px; }
.viz-tooltip-pts { color: #ffd200; font-weight: 800; }

@media (max-width: 720px) {
  .upg-row-head { min-width: 168px; }
  .upg-tname { font-size: 11.5px; }
}

/* results sync */
.sync-row { display: flex; align-items: center; gap: 12px; padding: 0 24px 4px; }
.sync-status { font-size: 12px; color: #6b7999; }
.link-btn-solid {
  padding: 5px 12px; border-radius: 999px; border: 1.5px solid #dbe6fb; background: #fff;
  font-size: 11px; font-weight: 700; color: #0b3d91; cursor: pointer;
}

/* file:// warning */
.file-warning {
  background: #ffe4e0; color: #7a1212; padding: 14px 20px; font-size: 13px; text-align: center;
}
.file-warning code { background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 4px; }

/* wizard */
.wizard { padding: 20px 24px 32px; max-width: 900px; margin: 0 auto; }
.wizard-steps { display: flex; justify-content: center; gap: 28px; margin-bottom: 24px; flex-wrap: wrap; }
.wizard-step-dot {
  width: 32px; height: 32px; border-radius: 50%; background: #eef1f6; color: #8b93a4;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
  position: relative; cursor: pointer;
}
.wizard-step-dot span {
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%); font-size: 10px;
  font-weight: 700; color: #8b93a4; white-space: nowrap;
}
.wizard-step-dot.active { background: #0b3d91; color: #fff; }
.wizard-step-dot.done { background: #17c463; color: #fff; }
.wizard-step-dot.done span, .wizard-step-dot.active span { color: #0b3d91; }

.wizard-panel { display: none; }
.wizard-panel.active { display: block; }
.wizard-panel h2 { font-size: 17px; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.name-input-big {
  width: 100%; max-width: 320px; padding: 12px 14px; border-radius: 10px; border: 1.5px solid #dbe6fb;
  font-size: 16px; margin: 6px 0 4px;
}

/* identity gate (name recognition + PIN) */
.identity-continue-btn { display: block; margin: 10px 0 4px; }
.identity-card {
  max-width: 380px; margin: 14px 0 6px; padding: 16px 18px; border-radius: 12px;
  background: #f7f9fd; border: 1.5px solid #dbe6fb;
}
.identity-title { margin: 0 0 4px; font-weight: 800; font-size: 14px; color: #0b3d91; }
.identity-card .setup-help { margin: 0 0 12px; }
.pin-input {
  width: 90px; padding: 10px 14px; border-radius: 8px; border: 1.5px solid #dbe6fb;
  font-size: 20px; letter-spacing: 6px; text-align: center; font-weight: 800; color: #0b3d91;
}
.identity-error { font-size: 12px; color: #a32d2d; margin: 8px 0 0; }
.identity-actions { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.identity-not-me {
  background: none; border: none; color: #0b3d91; text-decoration: underline;
  font-size: 12px; font-weight: 700; cursor: pointer; padding: 0;
}

.wizard-board { margin-top: 16px; }
.wizard-nav {
  display: flex; align-items: center; gap: 14px; margin-top: 28px; padding-top: 18px; border-top: 1px solid #eee;
}
.wizard-hint { font-size: 12px; color: #a32d2d; flex: 1; text-align: center; }
.wizard-btn-primary, .wizard-btn-secondary {
  padding: 10px 22px; border-radius: 8px; font-weight: 800; font-size: 13px; cursor: pointer;
}
.wizard-btn-primary { border: none; background: #0b3d91; color: #fff; }
.wizard-btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.wizard-btn-secondary { border: 1.5px solid #dbe6fb; background: #fff; color: #0b3d91; }

/* group team mobile switcher (step 3) */
.group-switcher { display: none; gap: 6px; margin: 14px 0 4px; flex-wrap: wrap; }
.group-switch-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1.5px solid #dbe6fb; background: #fff; font-size: 11px; font-weight: 700; color: #0b3d91; cursor: pointer;
}
.group-switch-btn img { width: 16px; height: 16px; object-fit: contain; }
.group-switch-btn.active { background: #0b3d91; color: #fff; border-color: #0b3d91; }

@media (max-width: 720px) {
  .group-switcher { display: flex; }
  #wizard-board-group .team-col.mobile-hidden { display: none; }
}
