/* ==========================================================
   v179.9.79 — semantic pitch colors + Wrigley action cleanup
                 + visible inning-ending rule
   Scope: visual only. No scoring/stat/storage logic changes.
   ========================================================== */

:root{
  --scorebook-ball-blue:#2387e8;
  --scorebook-strike-red:#df4b45;
  --scorebook-inning-red:#df4b46;
}

/* ----------------------------------------------------------
   PITCH SEMANTICS
   Ball is always BLUE and strike/foul is always RED, regardless
   of Default / Generic palette / Wrigley. These are baseball-state
   colors, not theme accents.
   ---------------------------------------------------------- */

/* Live Ball / Strike buttons. */
#playModal .v140-pitch-inputs button.v143-ball,
#playModal .v142-ball-strike button[data-v140-result="Ball"]{
  border-color:var(--scorebook-ball-blue)!important;
  color:var(--scorebook-ball-blue)!important;
  -webkit-text-fill-color:var(--scorebook-ball-blue)!important;
  background:color-mix(in srgb,var(--scorebook-ball-blue) 12%,var(--panel2))!important;
  box-shadow:none!important;
}
#playModal .v140-pitch-inputs button.v143-strike,
#playModal .v142-ball-strike button[data-v140-result="Called Strike"]{
  border-color:var(--scorebook-strike-red)!important;
  color:var(--scorebook-strike-red)!important;
  -webkit-text-fill-color:var(--scorebook-strike-red)!important;
  background:color-mix(in srgb,var(--scorebook-strike-red) 12%,var(--panel2))!important;
  box-shadow:none!important;
}
#playModal .v140-pitch-inputs button.v143-ball i,
#playModal .v142-ball-strike button[data-v140-result="Ball"] i{color:var(--scorebook-ball-blue)!important}
#playModal .v140-pitch-inputs button.v143-strike i,
#playModal .v142-ball-strike button[data-v140-result="Called Strike"] i{color:var(--scorebook-strike-red)!important}

/* Count lights. */
#playModal .v141-count-lights>span:first-child i.on,
#playModal .pitch-light-group:not(.strikes) i.on{
  background:var(--scorebook-ball-blue)!important;
  border-color:var(--scorebook-ball-blue)!important;
  color:var(--scorebook-ball-blue)!important;
  box-shadow:0 0 8px color-mix(in srgb,var(--scorebook-ball-blue) 30%,transparent)!important;
}
#playModal .v141-count-lights>span:last-child i.on,
#playModal .pitch-light-group.strikes i.on{
  background:var(--scorebook-strike-red)!important;
  border-color:var(--scorebook-strike-red)!important;
  color:var(--scorebook-strike-red)!important;
  box-shadow:0 0 8px color-mix(in srgb,var(--scorebook-strike-red) 30%,transparent)!important;
}

/* Active pitch sequence. */
#playModal .v141-sequence article.is-ball>span{
  background:var(--scorebook-ball-blue)!important;
  border-color:var(--scorebook-ball-blue)!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
#playModal .v141-sequence article.is-ball>em{
  border-color:var(--scorebook-ball-blue)!important;
  color:var(--scorebook-ball-blue)!important;
  -webkit-text-fill-color:var(--scorebook-ball-blue)!important;
}
#playModal .v141-sequence article.is-strike>span{
  background:var(--scorebook-strike-red)!important;
  border-color:var(--scorebook-strike-red)!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
#playModal .v141-sequence article.is-strike>em{
  border-color:var(--scorebook-strike-red)!important;
  color:var(--scorebook-strike-red)!important;
  -webkit-text-fill-color:var(--scorebook-strike-red)!important;
}

/* Legacy/live sequence chips if the compact tracker is shown. */
#playModal .pitch-chip.is-ball .pitch-chip-no,
#playModal .pitch-chip.is-ball>b{
  border-color:var(--scorebook-ball-blue)!important;
  color:var(--scorebook-ball-blue)!important;
}
#playModal .pitch-chip.is-strike .pitch-chip-no,
#playModal .pitch-chip.is-strike>b{
  border-color:var(--scorebook-strike-red)!important;
  color:var(--scorebook-strike-red)!important;
}

/* Strike-zone / history location markers. v138 uses tone-* classes. */
:is(#playModal,#pitchHistoryModal) .v138-zone i.tone-ball{
  background:var(--scorebook-ball-blue)!important;
  border-color:#fff!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
:is(#playModal,#pitchHistoryModal) .v138-zone i:is(.tone-called,.tone-swing,.tone-foul){
  background:var(--scorebook-strike-red)!important;
  border-color:#fff!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}

/* Pitch-history rows / pitch number markers. */
#pitchHistoryModal .pitch-history-row.tone-ball .pitch-history-no{
  background:var(--scorebook-ball-blue)!important;
  border-color:var(--scorebook-ball-blue)!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
#pitchHistoryModal .pitch-history-row:is(.tone-called,.tone-swing,.tone-foul) .pitch-history-no{
  background:var(--scorebook-strike-red)!important;
  border-color:var(--scorebook-strike-red)!important;
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}

/* Plays / pitch-detail maps also use the same ball/strike semantics. */
.v162-mini-zone i.is-ball,
#v162PlayDetailModal .v1625-zone-marker.is-ball,
#v162PlayDetailModal .v1625-zone-marker.tone-ball{background:var(--scorebook-ball-blue)!important}
.v162-mini-zone i.is-strike,
#v162PlayDetailModal .v1625-zone-marker.is-strike,
#v162PlayDetailModal .v1625-zone-marker:is(.tone-called,.tone-swing,.tone-foul){background:var(--scorebook-strike-red)!important}
#v162PlayDetailModal .v1625-pitch-row.is-ball>b{box-shadow:inset 3px 0 0 var(--scorebook-ball-blue)!important}
#v162PlayDetailModal .v1625-pitch-row.is-strike>b{box-shadow:inset 3px 0 0 var(--scorebook-strike-red)!important}

/* ----------------------------------------------------------
   WRIGLEY: remove the accidental blue primary Apply button.
   Blue remains valid only for BALL semantics above.
   ---------------------------------------------------------- */
html body[data-theme-family="wrigley"] #playModal #applyPlayBtn:not(:disabled){
  background:var(--wr-green-900,#063c2a)!important;
  background-image:none!important;
  color:var(--wr-cream,#f4edda)!important;
  -webkit-text-fill-color:var(--wr-cream,#f4edda)!important;
  border:2px solid var(--wr-yellow,#efc94b)!important;
  box-shadow:none!important;
}
html body[data-theme-family="wrigley"] #playModal #applyPlayBtn:disabled{
  background:var(--wr-green-800,#0b5038)!important;
  color:var(--wr-cream-dim,#bfc6b8)!important;
  -webkit-text-fill-color:var(--wr-cream-dim,#bfc6b8)!important;
  border-color:var(--wr-line,#708979)!important;
  opacity:.66!important;
}

/* ----------------------------------------------------------
   INNING-END RULE
   Render the third-out separator as a top-layer rule so a PH/PC
   at-bat-change strip cannot cover it. When both occur in the same
   cell, the personnel strip sits immediately ABOVE the red rule.
   ---------------------------------------------------------- */
.unified-score-table .play-cell.third-out,
.scoring-only-table .play-cell.third-out{
  box-shadow:none!important;
}
.unified-score-table .play-cell.third-out::after,
.scoring-only-table .play-cell.third-out::after{
  content:""!important;
  position:absolute!important;
  left:0!important;
  right:0!important;
  bottom:0!important;
  height:3px!important;
  background:var(--scorebook-inning-red)!important;
  z-index:12!important;
  pointer-events:none!important;
}

/* Preserve PH / PC / PC-PH when the same plate appearance is the third out. */
.play-cell.third-out .event-marker.v1563-change-marker,
.play-cell.third-out .v137-grid-marker.v1563-change-marker{
  bottom:3px!important;
  z-index:10!important;
}
.play-cell.third-out .play-entry:has(.v1563-change-marker) .play-code{
  bottom:7px!important;
}
