/* TodoPorras dual-theme contrast contract.
 * This is the final stylesheet, after ALL dark-first legacy styles.
 * Use an explicit foreground with every opaque surface (including -webkit-text-fill-color).
 * Do not recolor team shirts, hero photographs or semantic success/error badges. */
html[data-tp-theme="light"]{
  --tp-readable-surface:#ffffff;
  --tp-readable-subtle:#f3f7fb;
  --tp-readable-ink:#071c38;
  --tp-readable-muted:#52637b;
  --tp-readable-border:#d0dee8;
  --tp-readable-link:#076d43;
  --tp-readable-cta:#087c48;
}
html[data-tp-theme="dark"]{
  --tp-readable-surface:#101d17;
  --tp-readable-subtle:#17271e;
  --tp-readable-ink:#f5f8f6;
  --tp-readable-muted:#b1c5b9;
  --tp-readable-border:#40574a;
  --tp-readable-link:#a4f2ca;
  --tp-readable-cta:#62e8a8;
}
/* These are opaque cards under the gameplay sidebar and are the source of the
   reported white Uds. on white in light mode. Fix the panel AND its number. */
html[data-tp-theme] :is(
  .tp-gameplay-aside>.card,
  .tp-gameplay-aside .tp-gameplay-stat,
  .tp-gameplay-aside .tp-confidence-live-summary,
  .tp-gameplay-aside .tp-result-board,
  .tp-gameplay-shell .tp-progress-card,
  .tp-gameplay-shell .tp-season-card,
  .tp-gameplay-shell .tp-question-card,
  .tp-gameplay-shell .tp-fixture-group,
  .tp-gameplay-shell .tp-stadium-fixture,
  .tp-pool-admin-v3 .tp-admin-v3-metric,
  .tp-pool-admin-v3 .tp-admin-tab-panel,
  .tp-ledger-metrics>div,
  .tp-ledger-counterparty-card,
  .tp-ledger-table-wrap,
  .tp-profile-stats>div
){
  background:var(--tp-readable-surface)!important;
  border-color:var(--tp-readable-border)!important;
  color:var(--tp-readable-ink)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
}
/* Critical Uds., points and large monetary-looking figures; use explicit
   text-fill because historical gradients/branding set it independently of color. */
html[data-tp-theme] :is(
  .tp-gameplay-aside>.card,
  .tp-gameplay-aside .tp-gameplay-stat,
  .tp-gameplay-aside .tp-confidence-live-summary,
  .tp-pool-admin-v3 .tp-admin-v3-metric,
  .tp-ledger-metrics>div,
  .tp-ledger-counterparty-card,
  .tp-profile-stats>div
) :is(h1,h2,h3,h4,strong,b,.tp-gameplay-stat-value,.tp-units-value){
  color:var(--tp-readable-ink)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
  opacity:1!important;
}
html[data-tp-theme] :is(
  .tp-gameplay-aside>.card,.tp-gameplay-aside .tp-gameplay-stat,
  .tp-gameplay-aside .tp-confidence-live-summary,
  .tp-ledger-metrics>div,.tp-ledger-counterparty-card,
  .tp-pool-admin-v3 .tp-admin-v3-metric,.tp-profile-stats>div
) :is(small,p,.muted,.tp-muted,.tp-gameplay-stat-label){
  color:var(--tp-readable-muted)!important;
  -webkit-text-fill-color:var(--tp-readable-muted)!important;
  opacity:1!important;
}
/* Each theme owns the full fixture and question area. */
html[data-tp-theme] :is(
  .tp-gameplay-shell .tp-fixture-head,
  .tp-gameplay-shell .tp-question-row,
  .tp-gameplay-shell .tp-locked-value,
  .tp-gameplay-shell .locked-answer,
  .tp-gameplay-shell .tp-board-row,
  .tp-gameplay-shell .tp-race-game,
  .tp-results-view .tp-result-fixture,
  .tp-results-view .tp-results-ranking-row,
  .tp-pool-admin-v3 .tp-admin-rank-row,
  .tp-pool-admin-v3 .tp-admin-progression-row
){
  background:var(--tp-readable-subtle)!important;
  color:var(--tp-readable-ink)!important;
  border-color:var(--tp-readable-border)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
}
html[data-tp-theme] :is(
  .tp-gameplay-shell .tp-fixture-head,.tp-gameplay-shell .tp-question-row,
  .tp-gameplay-shell .tp-board-row,.tp-results-view .tp-results-ranking-row
) :is(h2,h3,strong,b,span:not(.pill):not(.tp-status):not(.good):not(.bad):not(.pts)){
  color:var(--tp-readable-ink)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
}
html[data-tp-theme] :is(
  .tp-gameplay-shell .tp-fixture-head,.tp-gameplay-shell .tp-question-row,
  .tp-gameplay-shell .tp-board-row,.tp-results-view .tp-results-ranking-row
) :is(p,small,.muted){
  color:var(--tp-readable-muted)!important;
  -webkit-text-fill-color:var(--tp-readable-muted)!important;
}
/* Transparent/disabled native controls and form labels receive an explicit
   ink color instead of inheriting browser dark appearance on light surfaces. */
html[data-tp-theme] :is(
  .tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view,
  #builderBody,.participant-layout,.survivor-layout,
  .tp-organizer-modal,.tp-profile-card
) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),textarea,select){
  background:var(--tp-readable-surface)!important;
  border-color:var(--tp-readable-border)!important;
  color:var(--tp-readable-ink)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
  opacity:1!important;
}
html[data-tp-theme] :is(.tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view,#builderBody)
  :is(label,legend,.tp-question-help,.tp-howto-rule dt){
  color:var(--tp-readable-ink);
}
html[data-tp-theme] :is(input,textarea)::placeholder{
  color:var(--tp-readable-muted)!important;
  -webkit-text-fill-color:var(--tp-readable-muted)!important;
  opacity:1!important;
}
/* Prediction choices cannot keep the dark-first near-black background in light. */
html[data-tp-theme] :is(
  .tp-pick-three input:not(:checked)+span,
  .tp-team-pick input:not(:checked)+span,
  .pick input:not(:checked)+span,
  .tp-shirt-picks input:not(:checked)+span
){
  background:var(--tp-readable-subtle)!important;
  color:var(--tp-readable-ink)!important;
  -webkit-text-fill-color:var(--tp-readable-ink)!important;
  border-color:var(--tp-readable-border)!important;
}
html[data-tp-theme="light"] :is(
 .tp-pick-three input:checked+span,.tp-team-pick input:checked+span,
 .pick input:checked+span,.tp-shirt-picks input:checked+span
){
  background:#e3f5ec!important;
  color:#075b38!important;
  -webkit-text-fill-color:#075b38!important;
  border-color:#27805a!important;
}
html[data-tp-theme="dark"] :is(
 .tp-pick-three input:checked+span,.tp-team-pick input:checked+span,
 .pick input:checked+span,.tp-shirt-picks input:checked+span
){
  background:#214c35!important;
  color:#ecfff5!important;
  -webkit-text-fill-color:#ecfff5!important;
  border-color:#6ee9ac!important;
}
/* Lock and result state text remains meaningful in both themes. */
html[data-tp-theme="light"] :is(.tp-gameplay-shell,.tp-results-view,.tp-ledger-table-wrap,.tp-ledger-metrics) .good,
html[data-tp-theme="light"] .tp-prediction-feedback.is-correct .tp-prediction-feedback-status{
  color:#067545!important;-webkit-text-fill-color:#067545!important;
}
html[data-tp-theme="dark"] :is(.tp-gameplay-shell,.tp-results-view,.tp-ledger-table-wrap,.tp-ledger-metrics) .good,
html[data-tp-theme="dark"] .tp-prediction-feedback.is-correct .tp-prediction-feedback-status{
  color:#8af3bc!important;-webkit-text-fill-color:#8af3bc!important;
}
html[data-tp-theme="light"] :is(.tp-gameplay-shell,.tp-results-view,.tp-ledger-table-wrap,.tp-ledger-metrics) .bad,
html[data-tp-theme="light"] .tp-prediction-feedback.is-incorrect .tp-prediction-feedback-status{
  color:#a42435!important;-webkit-text-fill-color:#a42435!important;
}
html[data-tp-theme="dark"] :is(.tp-gameplay-shell,.tp-results-view,.tp-ledger-table-wrap,.tp-ledger-metrics) .bad,
html[data-tp-theme="dark"] .tp-prediction-feedback.is-incorrect .tp-prediction-feedback-status{
  color:#ffb3b3!important;-webkit-text-fill-color:#ffb3b3!important;
}
/* Help links, score indicators and kicker text on light surfaces need
   a darker accent than the brand green (which fails AA against white). */
html[data-tp-theme] :is(
  .tp-gameplay-shell .tp-kicker,
  .tp-gameplay-shell .tp-howto-content>a,
  .tp-gameplay-shell .tp-race-game .pts,
  .tp-ledger-inline-link,
  .tp-ledger-counterparty-card a
){
  color:var(--tp-readable-link)!important;
  -webkit-text-fill-color:var(--tp-readable-link)!important;
}
/* Save bar and units panels were historically dark gradients, even in light. */
html[data-tp-theme="light"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar){
  background:#ffffff!important;border-color:#bfd9ca!important;color:#071c38!important;
}
html[data-tp-theme="light"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar)
 :is(strong,b){color:#071c38!important;-webkit-text-fill-color:#071c38!important}
html[data-tp-theme="light"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar)
 :is(p,small){color:#52637b!important;-webkit-text-fill-color:#52637b!important}
html[data-tp-theme="dark"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar){
  background:#101d17!important;border-color:#40574a!important;color:#f5f8f6!important;
}
html[data-tp-theme="dark"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar)
 :is(strong,b){color:#f5f8f6!important;-webkit-text-fill-color:#f5f8f6!important}
html[data-tp-theme="dark"] :is(.tp-gameplay-shell .tp-save-dock,.tp-gameplay-shell .save-bar)
 :is(p,small){color:#b1c5b9!important;-webkit-text-fill-color:#b1c5b9!important}
/* Disabled buttons stay readable in light AND dark without fading away.
 * Scope to application actions, not imagery, score badges or team jerseys. */
html[data-tp-theme="light"] :is(
  .tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view,.tp-shell-v2,#builderBody,
  .tp-organizer-modal,.tp-profile-card,.tp-auth-panel
) :is(button,.btn,.tp-btn):disabled{
  background:#e6edf3!important;color:#405166!important;
  -webkit-text-fill-color:#405166!important;border-color:#a9bbc9!important;
  opacity:1!important;box-shadow:none!important;
}
html[data-tp-theme="dark"] :is(
  .tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view,.tp-shell-v2,#builderBody,
  .tp-organizer-modal,.tp-profile-card,.tp-auth-panel
) :is(button,.btn,.tp-btn):disabled{
  background:#25372d!important;color:#d2e4d9!important;
  -webkit-text-fill-color:#d2e4d9!important;border-color:#4a6755!important;
  opacity:1!important;box-shadow:none!important;
}
/* Respect locked survivor selections: their team badges are still visible. */
html[data-tp-theme="dark"] button.survivor-team-choice:disabled:is(.selected-primary,.selected-reserve){
  -webkit-text-fill-color:#f5f8f6!important;
}
html[data-tp-theme="light"] button.survivor-team-choice:disabled:is(.selected-primary,.selected-reserve){
  -webkit-text-fill-color:#071c38!important;
}
/* Avoid text color and background color animating out of sync during theme changes. */
html[data-tp-theme] :is(.tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view)
 :is(button,.tp-btn,.btn,.tp-pick-three span,.tp-team-pick span){
  transition-property:transform,box-shadow!important;
}


/* Disable foreground/background interpolation in BOTH themes. At the moment
 * a submit button enters/exits disabled state, -webkit-text-fill-color changes
 * instantly while the inherited background transition is still painting the
 * previous theme. Chromium CI detected a real light-mode 1.27:1 flash. */
html[data-tp-theme] :is(
 .tp-auth-panel,.tp-gameplay-shell,.tp-pool-admin-v3,.tp-results-view,
 .tp-shell-v2,.tp-organizer-modal,.tp-profile-card,#builderBody
) :is(button,.btn,.tp-btn,.tp-link-btn,[role="button"]){
  transition-property:transform,box-shadow!important;
}
html[data-tp-theme] :is(.tp-auth-panel,.tp-gameplay-shell,.tp-pool-admin-v3,.tp-shell-v2) 
  :is(button,.btn,.tp-btn):disabled{
  transition-duration:0s!important;
}
