/* Interactive Bracket — March Madness visualization */

/* Bracket picker page: use full width (no max-width constraint on main/card) */
body.bracket-picker-page main .card,
body.bracket-picker-page main .no-outer-card {
  max-width: none !important;
}

/* Constrain bracket view; allow overflow so extended cream bracket is not clipped */
body.bracket-picker-page #bracket-picker-app[data-view-mode="bracket"] {
  overflow-x: visible;
  max-width: 100% !important;
}

/* Allow bracket to extend to card edge without being clipped (card has overflow:hidden in board.css). */
body.bracket-picker-page .squares-component-card {
  overflow-x: visible;
  overflow-y: hidden;
}
body.bracket-picker-page .bracket-picker-section,
body.bracket-picker-page main.container {
  overflow-x: visible;
}

/* Stacking context isolation: hero (z-index:1) must paint above this section so
   toolrow dropdowns (share/manage) are never obscured by bracket elements that
   carry their own z-index (e.g. .ib-round-label z-index:2). Setting z-index:0 here
   creates a contained stacking context at level 0 < hero level 1. */
body.bracket-picker-page .bracket-picker-section {
  position: relative;
  z-index: 0;
}
/* ── Mobile (< 576px): full-bleed — every band goes edge-to-edge ── */
@media (max-width: 575.98px) {
  /* Strip outer section horizontal padding */
  body.bracket-picker-page .bracket-picker-section {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Strip inner app horizontal padding (board.css sets padding: 0 1rem 1rem) */
  body.bracket-picker-page #bracket-picker-app {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* All card-like bands: remove side borders + border-radius so they span edge-to-edge */
  body.bracket-picker-page .bracket-view-toggle,
  body.bracket-picker-page .your-picks-card,
  body.bracket-picker-page .bracket-ss-banner,
  body.bracket-picker-page #bracket-picker-app .round-nav-pills,
  body.bracket-picker-page .ib-root {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }

  /* Section px is now 0 — bracket fills the section naturally, no negative-margin bleed needed. */
  body.bracket-picker-page .bracket-picker-section #interactive-bracket-container {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Extend the cream bracket to the inner edge of the white card on narrow-but-not-mobile screens */
@media (min-width: 576px) and (max-width: 767px) {
  body.bracket-picker-page .bracket-picker-section #interactive-bracket-container {
    margin-left: -2rem;
    margin-right: -2rem;
    width: calc(100% + 4rem);
    max-width: none;
    box-sizing: border-box;
  }
}
@media (min-width: 768px) {
  body.bracket-picker-page .bracket-picker-section #interactive-bracket-container {
    margin-left: -2.5rem;
    margin-right: -2.5rem;
    width: calc(100% + 5rem);
    max-width: none;
    box-sizing: border-box;
  }
}

#interactive-bracket-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.ib-root {
  /* Map to --pms-* directly — set by whichever theme file is active */
  --ib-accent:          var(--pms-primary);
  --ib-accent-soft:     var(--pms-primary-soft);
  --ib-surface:         var(--pms-surface);
  --ib-surface-elevated:var(--pms-surface-elevated);
  --ib-border:          var(--pms-border);
  --ib-text:            var(--pms-text);
  --ib-text-muted:      var(--pms-text-muted);
  --ib-success:         var(--pms-success);
  --ib-success-soft:    var(--pms-success-soft);
  --ib-danger:          var(--pms-danger);
  --ib-danger-soft:     var(--pms-danger-soft);
  /* Bracket SVG lines use this so dark theme can override --pms-bracket-connector */
  --ib-bracket-line:    var(--pms-bracket-connector, var(--ib-border));
  font-family: inherit;
  background: var(--ib-surface);
  border-radius: 12px;
  border: 1px solid var(--ib-border);
  overflow: hidden;
  min-width: 0;
}

.ib-loading,
.ib-error {
  padding: 2rem;
  text-align: center;
  color: var(--ib-text-muted);
}

.ib-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--ib-surface-elevated);
  border-bottom: 1px solid var(--ib-border);
}

.ib-lock-status {
  font-size: 0.75rem;
  color: var(--ib-text-muted);
  flex-shrink: 0;
}

.ib-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--ib-text-muted);
}

.ib-lock-countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--ib-accent);
}

/* Small screens: toolbar layout */
@media (max-width: 576px) {
  .ib-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .ib-legend {
    font-size: 0.6rem;
    gap: 0.4rem 0.5rem;
    padding: 0.35rem 0.5rem;
  }
}

.ib-region-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  background: transparent;
  border: 1px solid var(--ib-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.ib-region-btn:hover {
  color: var(--ib-text);
  background: var(--pms-surface-hover);
}

.ib-region-btn.active {
  background: var(--ib-accent);
  color: var(--pms-text-on-primary);
  border-color: var(--ib-accent);
}

.ib-view-toggle {
  display: flex;
  gap: 2px;
}

.ib-view-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--ib-text-muted);
  background: transparent;
  border: 1px solid var(--ib-border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.ib-view-btn:hover {
  color: var(--ib-text);
}

.ib-view-btn.active {
  background: var(--ib-accent-soft);
  color: var(--ib-accent);
  border-color: var(--ib-accent);
}

.ib-tiebreaker-inline {
  position: absolute;
  left: 0;
  right: 0;
  padding: 0.5rem 0.6rem;
  margin-top: 0.25rem;
  background: var(--ib-surface-elevated);
  border: 1px solid var(--ib-border);
  border-radius: 8px;
  border-top: 2px solid var(--ib-border);
  font-size: 0.75rem;
  color: var(--ib-text-muted);
  z-index: 2;
  box-sizing: border-box;
}
.ib-tiebreaker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 1.5rem;
}
.ib-tiebreaker-inline .ib-tiebreaker-label {
  font-weight: 600;
  color: var(--ib-accent);
  flex-shrink: 0;
}
.ib-tiebreaker-inline .ib-tiebreaker-value {
  color: var(--ib-text);
  font-size: 0.875rem;
}
.ib-tiebreaker-input {
  width: 4.5rem;
  flex-shrink: 0;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  background: var(--ib-surface);
  border: 1px solid var(--ib-border);
  border-radius: 6px;
  color: var(--ib-text);
  text-align: center;
}
.ib-tiebreaker-input:focus {
  outline: none;
  border-color: var(--ib-accent);
}

.ib-team-gear-link {
  flex: 1;
  min-width: 0;
  color: inherit;
  transition: color 0.15s ease, opacity 0.15s ease;
  overflow: hidden;
  position: relative;
}
.ib-team-gear-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.ib-team-gear-link:hover {
  color: var(--ib-accent);
  opacity: 1;
}
.ib-gear-icon {
  font-size: 0.65em;
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.ib-team-gear-link:hover .ib-gear-icon {
  opacity: 0.85;
}
/* Affiliate disclosure: only show on hover as a small tooltip, never inline */
@media (hover: hover) {
  .ib-team-gear-link::after {
    content: "affiliate";
    position: absolute;
    left: 0;
    top: 100%;
    font-size: 0.5rem;
    line-height: 1;
    color: var(--ib-text-muted, #888);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 5;
  }
  .ib-team-gear-link:hover::after,
  .ib-team-gear-link:focus::after {
    opacity: 1;
  }
}
@media (hover: none) {
  /* Touch devices: no inline affiliate text - the bag icon is sufficient disclosure */
  .ib-team-gear-link::after {
    content: none;
  }
}

/* Round nav: tabs + prev/next arrows — visible on all screen sizes for easy bracket level movement */
.ib-round-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  background: var(--ib-surface-elevated);
  border-bottom: 1px solid var(--ib-border);
  flex-wrap: nowrap;
  min-width: 0;
}
.ib-round-arrow {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--ib-text-muted);
  background: transparent;
  border: 1px solid var(--ib-border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.ib-round-arrow:hover:not(:disabled) {
  color: var(--ib-accent);
  background: var(--ib-accent-soft);
  border-color: var(--ib-accent);
}
.ib-round-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ib-round-tabs-wrap {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-width: 0;
  flex: 1;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 0.5rem;
}
.ib-round-tabs-wrap::-webkit-scrollbar {
  display: none;
}
.ib-round-tab {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ib-text-muted);
  background: transparent;
  border: 1px solid var(--ib-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  scroll-snap-align: center;
}
.ib-tab-has-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.ib-tab-label {
  line-height: 1;
}
.ib-tab-date {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.6;
  letter-spacing: 0.01em;
  line-height: 1;
}
.ib-round-tab.active .ib-tab-date { opacity: 0.8; }
.ib-round-tab:hover {
  color: var(--ib-text);
  background: var(--pms-surface-hover);
}
.ib-round-tab.active {
  background: var(--ib-accent);
  color: var(--pms-text-on-primary);
  border-color: var(--ib-accent);
}

/* Bracket area: scrollable canvas with connecting lines */
.ib-bracket-area {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  max-width: 100%;
}

.ib-bracket-wrap {
  position: relative;
  max-height: 80vh;
  min-height: 360px;
  overflow: hidden;
  max-width: 100%;
}

/* Large screens: use more viewport so full bracket fits (layout is already viewport-sized) */
@media (min-width: 1100px) {
  .ib-bracket-wrap {
    max-height: min(90vh, 1200px);
  }
  .ib-bracket-scroll {
    max-height: min(90vh, 1200px);
  }
}

.ib-bracket-scroll {
  overflow-x: scroll !important;
  overflow-y: auto !important;
  max-height: 80vh;
  min-height: 320px;
  width: 100% !important;
  max-width: min(100%, 100vw) !important;
  min-width: 0;
  box-sizing: border-box;
  padding: 2.5rem 1rem 1rem 1rem;
  -webkit-overflow-scrolling: touch;
  /* pan-y: browser handles vertical scroll (page + bracket); JS handles horizontal pan */
  touch-action: pan-y;
  cursor: grab;
}

@media (max-width: 767px) {
  .ib-bracket-scroll {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* data-ib-firstfour-zone used by JS for optional hints; touch handled uniformly via drag */

/* Mobile-only: dedicated horizontal scroll for First Four so swiping between games is reliable */
.ib-firstfour-mobile {
  display: none;
}

@media (max-width: 767px) {
  .ib-firstfour-mobile {
    display: block;
    background: var(--ib-surface-elevated);
    border-bottom: 1px solid var(--ib-border);
    padding: 0.5rem 0;
  }
  .ib-firstfour-mobile-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ib-text-muted);
    padding: 0 0.5rem 0.35rem;
    letter-spacing: 0.02em;
  }
  .ib-firstfour-mobile-nav {
    display: flex;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0 0.25rem;
    min-height: 0;
  }
  .ib-ff-arrow {
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--ib-text-muted);
    background: var(--ib-surface);
    border: 1px solid var(--ib-border);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
  }
  .ib-ff-arrow:hover:not(:disabled) {
    color: var(--ib-accent);
    background: var(--ib-accent-soft);
  }
  .ib-ff-arrow:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .ib-firstfour-mobile-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    padding: 0;
    flex: 1;
    min-width: 0;
    scroll-snap-type: x mandatory;
    scroll-padding: 0;
  }
  .ib-firstfour-mobile-scroll::-webkit-scrollbar {
    display: none;
  }
  /* Each cell = full width of the scroll viewport so one complete game is visible */
  .ib-firstfour-mobile-cell {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    padding: 0 0.15rem;
  }
  .ib-firstfour-mobile-cell .ib-cell {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    height: auto !important;
    min-height: 76px;
  }
  .ib-firstfour-mobile-cell .ib-cell-inner {
    min-height: 76px;
  }
}

/* When using mobile First Four strip, hide play-in from main canvas and pull canvas up */
.ib-has-firstfour-mobile .ib-round-col[data-round="0"] {
  display: none !important;
}

@media (max-width: 767px) {
  .ib-has-firstfour-mobile .ib-bracket-scroll {
    padding-top: 2.5rem;
    /* Extra padding at bottom so the championship/tiebreaker can be scrolled into view */
    padding-bottom: 6rem;
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll !important;
  }
}

.ib-canvas {
  position: relative;
  display: block;
  flex-shrink: 0;
  overflow: visible;
}

.ib-round-col {
  position: absolute;
  left: 0;
  overflow: visible;
  /* top and height set per-round for compact layout */
}
.ib-round-col[data-round="1"],
.ib-round-col[data-round="2"],
.ib-round-col[data-round="3"],
.ib-round-col[data-round="4"],
.ib-round-col[data-round="5"],
.ib-round-col[data-round="6"] {
  z-index: 2;
}

.ib-round-label {
  position: absolute;
  top: -1.5rem;
  left: 0;
  font-size: clamp(0.65rem, 1.2vw, 0.75rem);
  font-weight: 700;
  color: var(--ib-text-muted);
  letter-spacing: 0.02em;
  z-index: 2;
  line-height: 1.25;
}
/* Inline date appended after round name in column label: "R64 · Mar 20-21" */
.ib-round-date {
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0.7;
}
.ib-round-points {
  font-weight: 500;
  font-size: 0.65rem;
  opacity: 0.9;
  margin-left: 0.25rem;
}

/* Rounds before pool start: informational only; picks don't count */
.ib-round-not-in-pool {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--ib-text-muted);
  opacity: 0.85;
  margin-left: 0.2rem;
}
/* Shade the whole round column so "not in pool" rounds are clearly distinct */
.ib-round-col[data-before-pool-start="true"] {
  background: var(--pms-surface-secondary);
  border-radius: 8px;
  margin: 0 -4px;
  padding: 0 4px;
}
.ib-round-col[data-before-pool-start="true"] .ib-cell-inner {
  opacity: 0.92;
}

.ib-bracket-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  color: var(--ib-bracket-line);
  opacity: 0.85;
  z-index: 0;
}

.ib-bracket-lines .ib-line {
  stroke: currentColor;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* R1 slots that receive play-in winners: accent outline so it's obvious where winners go */
.ib-cell.ib-playin-slot {
  position: relative;
}
.ib-cell.ib-playin-slot::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 8px;
  border: 2px solid var(--ib-accent);
  pointer-events: none;
  z-index: 1;
}

/* First Four strip at top of bracket */
.ib-playin-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: flex-start;
  z-index: 1;
}
.ib-playin-strip .ib-round-label {
  position: absolute;
  top: -1.5rem;
  left: 0;
}
.ib-playin-strip .ib-cell {
  flex-shrink: 0;
}
/* Show the same region+status card header for First Four cells as other game cards */
.ib-playin-strip .ib-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
/* Hide the redundant region badge — region is now shown in the card header */
.ib-playin-strip .ib-playin-region-badge {
  display: none;
}
.ib-playin-region-badge {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--ib-accent);
  margin-bottom: 0.25rem;
  padding: 0.15rem 0.35rem;
  background: var(--ib-accent-soft);
  border-radius: 4px;
  display: inline-block;
}
.ib-playin-feed-label {
  font-size: 0.6rem;
  color: var(--ib-accent);
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--ib-border);
}
.ib-r1-firstfour-label {
  font-size: 0.6rem;
  color: var(--ib-accent);
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--ib-border);
  font-weight: 600;
}
.ib-cell.ib-feed-highlight,
.ib-cell.ib-playin-feed-highlight {
  box-shadow: 0 0 0 2px var(--ib-accent);
  z-index: 3;
  border-radius: 6px;
}

.ib-carousel-prev,
.ib-carousel-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ib-border);
  background: var(--ib-surface-elevated);
  color: var(--ib-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
}

.ib-carousel-prev:hover:not(:disabled),
.ib-carousel-next:hover:not(:disabled) {
  background: var(--pms-surface-secondary);
}

.ib-carousel-prev:disabled,
.ib-carousel-next:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ib-carousel-prev {
  left: 0.5rem;
}

.ib-carousel-next {
  right: 0.5rem;
}

.ib-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
}

.ib-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--ib-border);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}

.ib-carousel-dot:hover {
  background: var(--ib-text-muted);
}

.ib-carousel-dot.active {
  background: var(--ib-accent);
  transform: scale(1.2);
}

.ib-cell {
  position: absolute;
  cursor: default;
  z-index: 1;
  box-sizing: border-box;
  overflow: hidden;
}
/* Round-column cells use flow so they stack by margin-top and stay aligned */
.ib-round-col .ib-cell.ib-cell-flow {
  position: relative;
  left: auto;
  top: auto;
  flex-shrink: 0;
  margin-bottom: 10px;
  /* Let cells expand to fit header + both team rows (height set by JS is too small now) */
  height: auto !important;
  overflow: visible;
}
.ib-round-col .ib-cell.ib-cell-flow .ib-cell-inner {
  height: auto;
}
.ib-round-col .ib-cell.ib-cell-flow:last-child {
  margin-bottom: 0;
}

.ib-cell-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--ib-surface-elevated);
  border: 1px solid var(--pms-border);
  border-radius: 8px;
  overflow: hidden;
  box-sizing: border-box;
  transition: box-shadow 0.2s, border-color 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  color: var(--ib-text);
}

.ib-live-footer {
  padding: 0.15rem 0.35rem;
  border-top: 1px solid rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.08);
  text-align: center;
  flex-shrink: 0;
}
.ib-live-badge {
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  background: var(--ib-danger);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}
.ib-cell[data-live="true"] .ib-cell-inner {
  border: 3px solid var(--ib-danger);
}

.ib-points-badge {
  padding: 0.1rem 0.35rem;
  font-size: 0.6rem;
  font-weight: 600;
  flex-shrink: 0;
  text-align: center;
  border-top: 1px solid var(--ib-border);
}
/* Correct: subtle accent so the row stays the hero — neutral bar, green text + thin left accent */
.ib-points-correct {
  color: var(--ib-success);
  background: var(--pms-success-soft);
  border-left: 2px solid var(--ib-success);
}
.ib-points-incorrect {
  color: var(--ib-text-muted);
  background: var(--pms-surface-secondary);
}

.ib-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.65rem;
  color: var(--ib-text-muted);
  background: var(--ib-surface-elevated);
  border-bottom: 1px solid var(--ib-border);
  flex-shrink: 0;
}
.ib-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.ib-legend-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.ib-legend-picked { background: var(--ib-accent); }
.ib-legend-correct { background: var(--ib-success); }
.ib-legend-incorrect { background: var(--ib-danger); }
.ib-legend-live { background: #ef4444; }

.ib-tap-hint {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.55rem;
  color: var(--ib-text-muted);
  pointer-events: none;
}

.ib-cell:hover .ib-cell-inner {
  border-color: var(--pms-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ib-team {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 7px 10px;
  font-size: 0.8125rem;
  min-height: 36px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  border-left: 3px solid transparent;
  cursor: default;
  transition: background 0.15s;
}

.ib-cell:not([data-locked="true"]) .ib-team[data-team-id]:not([data-team-id=""]) {
  cursor: pointer;
}

.ib-cell:not([data-locked="true"]):hover .ib-tap-hint {
  color: var(--ib-accent);
}

.ib-team:not(.ib-winner):not(.ib-correct):not(.ib-incorrect):hover {
  background: var(--pms-surface-hover);
}

.ib-team.ib-picked {
  background: var(--ib-accent-soft);
  border-left-color: var(--ib-accent);
  font-weight: 600;
  color: var(--ib-accent);
}

.ib-team.ib-winner {
  font-weight: 700;
  color: #15803d;
  background: rgba(34, 197, 94, 0.15);
  border-left: 4px solid #16a34a;
}
/* Loser without a pick (just the game result) - fade it */
.ib-team.ib-loser:not(.ib-incorrect) {
  opacity: 0.45;
}

/* Must override .ib-picked and .ib-loser styles */
.ib-team.ib-picked.ib-correct,
.ib-team.ib-correct {
  background: rgba(22, 163, 74, 0.18) !important;
  border-left: 4px solid #16a34a !important;
  color: #15803d !important;
  font-weight: 700;
  opacity: 1 !important;
}

.ib-team.ib-picked.ib-incorrect,
.ib-team.ib-incorrect {
  background: rgba(220, 38, 38, 0.12) !important;
  border-left: 4px solid #dc2626 !important;
  color: #991b1b !important;
  opacity: 0.7 !important;
}

/* Actual winner row when user picked wrong: make it clearly the winner */
.ib-team.ib-actual-winner-row {
  font-weight: 700;
  color: #15803d;
  background: rgba(22, 163, 74, 0.12);
  border-left: 4px solid #16a34a;
}

/* Bracket only: slot where user's pick didn't advance — show strikethrough pick + actual team */
.ib-team.ib-pick-didnt-advance {
  background: rgba(148, 163, 184, 0.15);
  border-left-color: rgba(148, 163, 184, 0.5);
}

/* First Four combo placeholder — muted italic, not clickable */
.ib-team.ib-combo-pending {
  color: var(--ib-text-muted, #64748b);
  font-style: italic;
  cursor: default;
}
.ib-team.ib-combo-pending .ib-name {
  font-style: italic;
}

.ib-pick-struck {
  text-decoration: line-through;
  color: var(--ib-text-muted);
  margin-right: 0.25rem;
}

.ib-team-name-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ib-logo {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  object-fit: contain;
}

.ib-seed {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--ib-text-muted);
  min-width: 1.1rem;
}

.ib-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ib-score-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
  min-width: 2.75rem;
  justify-content: flex-end;
}

.ib-score {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--ib-text);
}

.ib-status {
  font-weight: bold;
  line-height: 1;
  flex-shrink: 0;
}

/* Badge styles matching the list-view mockup */
.ib-check {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: #16a34a;
  color: #fff;
}

.ib-actual-winner {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--ib-text-muted);
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--pms-surface-secondary);
}

.ib-x {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  background: #dc2626;
  color: #fff;
}

.ib-minimap {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 120px;
  height: 80px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  border: 1px solid var(--ib-border);
  pointer-events: none;
  opacity: 0.7;
}


/* Pick guide — dim non-active cells, highlight active game, floating tooltip */

/* When guide is active, dim every cell except the focused one */
.ib-root.ib-pick-guide-mode .ib-cell {
  opacity: 0.25;
  transition: opacity 0.25s ease;
}
.ib-root.ib-pick-guide-mode .ib-cell.ib-pick-guide-active {
  opacity: 1;
  z-index: 10;
  position: relative;
  filter: drop-shadow(0 0 8px var(--ib-accent-soft));
}
.ib-root.ib-pick-guide-mode .ib-bracket-lines {
  opacity: 0.15;
  transition: opacity 0.25s ease;
}

.ib-cell.ib-pick-guide-active .ib-cell-inner {
  box-shadow: 0 0 0 3px var(--ib-accent);
  border-color: var(--ib-accent);
  animation: ib-pick-guide-pulse 2s ease-in-out infinite;
}
@keyframes ib-pick-guide-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--ib-accent); }
  50% { box-shadow: 0 0 0 4px var(--ib-accent), 0 0 16px var(--ib-accent-soft); }
}

/* Tooltip — fixed position, floats beside the active cell */
.ib-pick-guide-tooltip-wrap {
  position: fixed;
  z-index: 1060;
  pointer-events: none;
  transition: top 0.15s ease-out, left 0.15s ease-out;
}
.ib-pick-guide-tooltip-wrap * {
  pointer-events: auto;
}
.ib-pick-guide-tooltip {
  background: var(--ib-surface-elevated);
  border: 1px solid var(--ib-accent);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  max-width: 320px;
  white-space: nowrap;
}
.ib-pick-guide-title {
  font-weight: 600;
  color: var(--ib-accent);
  margin-bottom: 0.25rem;
}
.ib-pick-guide-progress {
  font-size: 0.8rem;
  color: var(--ib-text-muted);
  margin-bottom: 0.5rem;
}
.ib-pick-guide-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.ib-pick-guide-skip,
.ib-pick-guide-end {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--ib-border);
  background: transparent;
  color: var(--ib-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ib-pick-guide-skip:hover,
.ib-pick-guide-end:hover {
  background: var(--pms-surface-hover);
  color: var(--ib-text);
}

/* ── Card header: region (left) + status (right) ─────────────────── */
/* Hidden for absolute-positioned bracket tree cells; flex for flow cells */
.ib-card-header { display: none; }
.ib-cell-flow .ib-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 5px 10px 3px;
  background: var(--pms-surface-secondary);
  border-bottom: 1px solid var(--pms-border);
  flex-shrink: 0;
}
.ib-card-region {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ib-text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ib-card-status {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.ib-status-final {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ib-success);
}
.ib-status-live {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.6875rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ib-danger);
}
.ib-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ib-danger);
  flex-shrink: 0;
}
.ib-status-time {
  font-family: var(--pms-font-ui, 'Barlow Condensed', sans-serif);
  font-size: 0.6875rem;
  color: var(--ib-text-muted);
}
/* For flow cells showing LIVE in header, hide redundant footer strip */
.ib-cell-flow .ib-live-footer { display: none; }

/* Bracket completion celebration overlay */
.bracket-celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: bracket-celebration-fade-in 0.4s ease-out;
}
.bracket-celebration-overlay.d-none { display: none !important; }
.bracket-celebration-overlay:not(.d-none) { display: flex !important; }
@keyframes bracket-celebration-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.bracket-celebration-card {
  position: relative;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--pms-surface, #fff);
  border: 1px solid var(--pms-border, rgba(0,0,0,0.1));
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 1.5rem 1.75rem;
  animation: bracket-celebration-scale-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes bracket-celebration-scale-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.bracket-celebration-close {
  color: var(--pms-text-muted, #6c757d);
  text-decoration: none;
  font-size: 1.25rem;
}
.bracket-celebration-close:hover { color: var(--pms-text, #212529); }
.bracket-celebration-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  padding-right: 2rem;
}
.bracket-celebration-leaderboard .lb-entries { display: flex; flex-direction: column; gap: 0.25rem; }
.bracket-celebration-leaderboard .lb-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  background: var(--pms-surface-elevated, rgba(0,0,0,0.03));
}
.bracket-celebration-leaderboard .lb-entry.lb-you {
  background: var(--pms-primary-soft, rgba(13, 110, 253, 0.15));
  border: 1px solid var(--pms-primary, #0d6efd);
}
.bracket-celebration-leaderboard .lb-rank { font-weight: 700; min-width: 1.5rem; }
.bracket-celebration-leaderboard .lb-rank.rank-1 { color: #d4af37; }
.bracket-celebration-leaderboard .lb-rank.rank-2 { color: #c0c0c0; }
.bracket-celebration-leaderboard .lb-rank.rank-3 { color: #cd7f32; }
.bracket-celebration-leaderboard .lb-name-wrap { min-width: 0; }
.bracket-celebration-leaderboard .lb-name { font-weight: 600; }
.bracket-celebration-leaderboard .lb-you-badge { font-size: 0.7rem; margin-left: 0.35rem; }
.bracket-celebration-leaderboard .lb-stats { font-size: 0.875rem; color: var(--pms-text-muted, #6c757d); }
.bracket-celebration-leaderboard .lb-sep { margin: 0 0.25rem; }

/* ── Late picks: toolbar ─────────────────────────────────────── */
.ib-toolbar-late-picks {
  background: var(--ib-surface-elevated);
  border-bottom: 1px solid var(--ib-border);
  padding: 0.5rem 0.75rem;
}
.ib-late-picks-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
}
.ib-late-picks-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--ib-accent, #58a6ff);
  font-weight: 600;
}
.ib-late-picks-avail {
  color: var(--ib-correct, #3fb950);
  font-weight: 500;
}
.ib-late-picks-missed {
  color: var(--ib-incorrect, #f85149);
  font-weight: 500;
}

/* ── Late picks: game card states ────────────────────────────── */

/* Missed: game started without a pick */
.ib-cell.ib-missed {
  opacity: 0.6;
}
.ib-cell.ib-missed .ib-cell-inner {
  border-color: var(--ib-incorrect, #f85149) !important;
  border-width: 1.5px;
}
/* Badge sits inline in .ib-card-header between region and status */
.ib-late-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  flex-shrink: 0;
}
.ib-late-missed {
  background: var(--ib-incorrect, #f85149);
  color: #fff;
}
.ib-late-blocked {
  background: var(--ib-text-muted, #8b949e);
  color: #fff;
}

/* Blocked: all feeder branches dead */
.ib-cell.ib-blocked {
  opacity: 0.45;
}
.ib-cell.ib-blocked .ib-cell-inner {
  border-color: var(--ib-text-muted, #8b949e) !important;
  border-style: dashed;
}

/* Individual blocked team row within a partially blocked game */
.ib-team.ib-team-blocked {
  opacity: 0.45;
  cursor: default !important;
  pointer-events: none;
  position: relative;
}
.ib-team.ib-team-blocked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.05) 4px,
    rgba(255, 255, 255, 0.05) 8px
  );
  pointer-events: none;
  border-radius: inherit;
}
.ib-slot-blocked-icon {
  color: var(--ib-text-muted, #8b949e);
  font-size: 0.7rem;
}

/* Override: available games in late-picks mode get a subtle highlight */
.ib-cell:not(.ib-missed):not(.ib-blocked):not([data-locked="true"]) .ib-tap-hint {
  color: var(--ib-accent, #58a6ff);
}
