/* ==========================================================================
   Cobblemon Team Builder – Light theme, Pocketcraft-style
   ========================================================================== */

:root {
  --tb-space-1: 8px;
  --tb-space-2: 16px;
  --tb-space-3: 24px;
  --tb-space-4: 32px;
  --tb-primary: #3B82F6;
  --tb-gray-700: #374151;
  --tb-gray-500: #6B7280;
  --tb-gray-100: #F3F4F6;
  --tb-surface: #FFFFFF;
  --tb-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --tb-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --tb-radius: 8px;
  --tb-radius-lg: 16px;
  --tb-radius-pill: 999px;
}

body {
  background-color: #FAFAFA;
}

/* --------------------------------------------------------------------------
   Page & typography
   -------------------------------------------------------------------------- */
.team-builder-page {
  padding-top: 128px;
  padding-bottom: var(--tb-space-4);
  max-width: 1400px;
  margin: 0 auto;
  transition: opacity 0.2s ease;
}

.tb-header {
  text-align: center;
  margin-bottom: var(--tb-space-4);
}

.tb-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--tb-gray-700);
  margin-bottom: var(--tb-space-1);
  letter-spacing: -0.02em;
}

.tb-subtitle {
  color: var(--tb-gray-500);
  font-size: 16px;
  margin: 0;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.tb-internal-links {
  font-size: 0.95rem;
  color: var(--tb-gray-500);
  margin-top: 0.5rem;
  margin-bottom: 0;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.tb-internal-links a {
  color: #4aa3df;
  text-decoration: none;
}

.tb-internal-links a:hover {
  text-decoration: underline;
}

.tb-internal-links-bottom {
  margin-top: 2rem;
  margin-bottom: 0;
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

/* --------------------------------------------------------------------------
   Main team card – light surface, soft shadow
   -------------------------------------------------------------------------- */
.tb-team-card {
  background: var(--tb-surface);
  border: none;
  border-radius: var(--tb-radius-lg);
  padding: 24px;
  margin-bottom: var(--tb-space-4);
  box-shadow: var(--tb-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.tb-team-card:hover {
  box-shadow: var(--tb-shadow-hover);
}

.tb-team-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--tb-space-2);
  margin-bottom: var(--tb-space-3);
  padding-bottom: var(--tb-space-2);
  border-bottom: 1px solid var(--tb-gray-100);
}

.tb-team-name-row { margin-bottom: 0; }

.tb-team-name-row.tb-team-name-inline {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
}

.tb-team-name-inline .tb-team-name-label { margin-bottom: 0; white-space: nowrap; }

.tb-team-name-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
}

.tb-team-name-input {
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
  max-width: 320px;
  padding: var(--tb-space-1) var(--tb-space-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tb-team-name-input::placeholder { color: var(--tb-gray-500); }

.tb-team-name-input:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tb-team-card-actions {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
  flex-wrap: wrap;
}

.tb-usage-indicator {
  font-size: 12px;
  color: var(--tb-gray-500);
  margin-left: 6px;
  white-space: nowrap;
}

.tb-usage-indicator.is-limit {
  color: #b91c1c;
}

.tb-usage-indicator a {
  color: var(--tb-primary);
  text-decoration: none;
  font-weight: 600;
}

.tb-usage-indicator a:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Buttons – primary filled, secondary outline
   -------------------------------------------------------------------------- */
.btn-tb-add,
.btn-tb-share,
.btn-tb-clear,
.btn-tb-primary {
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--tb-radius-pill);
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-tb-add:hover,
.btn-tb-share:hover,
.btn-tb-clear:hover,
.btn-tb-primary:hover {
  transform: translateY(-2px);
}

.btn-tb-add {
  background: var(--tb-primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.32);
}

.btn-tb-add:hover {
  background: #2563EB;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-tb-share {
  background: var(--tb-surface);
  color: var(--tb-gray-700);
  border: 1px solid #E5E7EB;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-tb-share:hover {
  background: var(--tb-gray-100);
  border-color: var(--tb-primary);
  color: var(--tb-primary);
}

.btn-tb-clear {
  background: #DC2626;
  color: #fff;
}

.btn-tb-clear:hover {
  background: #B91C1C;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-tb-primary {
  background: var(--tb-primary);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.32);
}

.tb-feedback {
  font-size: 14px;
  color: #059669;
  opacity: 0;
  transition: opacity 0.2s;
}

.tb-feedback.tb-feedback-visible { opacity: 1; }

/* --------------------------------------------------------------------------
   Section titles
   -------------------------------------------------------------------------- */
.tb-section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--tb-gray-700);
  margin-bottom: var(--tb-space-2);
  padding-bottom: var(--tb-space-1);
  border-bottom: 2px solid var(--tb-primary);
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   Team slots grid & Pokemon cards – light cards, two-column layout
   -------------------------------------------------------------------------- */
.tb-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--tb-space-3);
}

.tb-slot {
  background: var(--tb-surface);
  border: none;
  border-radius: var(--tb-radius-lg);
  overflow: hidden;
  min-height: 280px;
  box-shadow: var(--tb-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.tb-slot:hover {
  box-shadow: var(--tb-shadow-hover);
  transform: translateY(-4px);
}

.tb-slot.tb-slot-empty-state {
  border: 2px dashed #E5E7EB;
  background: var(--tb-gray-100);
}

.tb-slot-inner {
  padding: 24px;
  height: 100%;
  min-height: 260px;
}

.tb-slot-empty .tb-slot-empty-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  width: 100%;
}

.tb-slot-add-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--tb-space-2);
  color: var(--tb-gray-500);
  transition: color 0.2s, transform 0.15s;
}

.tb-slot-add-btn:hover {
  color: var(--tb-primary);
  transform: scale(1.05);
}

.tb-slot-add-btn:focus { outline: none; color: var(--tb-primary); }

.tb-slot-add-icon {
  font-size: 2.5rem;
  color: inherit;
  margin-bottom: var(--tb-space-1);
  display: block;
}

.tb-slot-add-text { font-size: 16px; color: inherit; }

/* Filled slot – two-column layout: left = sprite, name, type, level, IV/EV inputs; right = base + final stats */
.tb-slot-filled {
  padding: 24px;
  color: var(--tb-gray-700);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.tb-slot-header {
  display: flex;
  align-items: flex-start;
  gap: var(--tb-space-2);
  margin-bottom: var(--tb-space-2);
  grid-column: 1;
}

.tb-slot-sprite {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--tb-gray-100);
  border-radius: var(--tb-radius);
}

.tb-slot-name-row { flex: 1; min-width: 0; }

.tb-slot-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--tb-gray-700);
  margin: 0 0 var(--tb-space-1) 0;
  text-transform: capitalize;
}

.tb-slot-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.tb-type-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--tb-radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.tb-slot-spawn-link {
  font-size: 14px;
  color: var(--tb-primary);
  text-decoration: none;
  transition: color 0.2s;
}

.tb-slot-spawn-link:hover { color: #2563EB; text-decoration: underline; }

.tb-slot-remove {
  color: var(--tb-gray-500);
  padding: var(--tb-space-1);
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--tb-radius);
  transition: color 0.2s, background 0.2s;
}

.tb-slot-remove:hover { color: #DC2626; background: rgba(220, 38, 38, 0.08); }

.tb-slot-ability-row {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
  margin-bottom: var(--tb-space-2);
  grid-column: 1;
}

.tb-slot-ability-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
  margin: 0;
  flex-shrink: 0;
}

.tb-slot-ability {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  padding: 8px 12px;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tb-slot-ability:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tb-slot-held-item-row {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
  margin-bottom: var(--tb-space-2);
  grid-column: 1;
}

.tb-slot-held-item-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
  margin: 0;
  flex-shrink: 0;
}

.tb-slot-held-item-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  padding: 8px 12px;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tb-slot-held-item-btn:hover {
  border-color: var(--tb-primary);
  color: var(--tb-primary);
}

.tb-slot-held-item-btn:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tb-slot-held-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-slot-held-item-caret {
  font-size: 10px;
  color: var(--tb-gray-500);
  flex-shrink: 0;
}

.tb-slot-advanced {
  margin: var(--tb-space-1) 0;
  border: 1px solid var(--tb-gray-100);
  border-radius: var(--tb-radius);
  background: var(--tb-gray-100);
}
.tb-slot-advanced[open] { background: var(--tb-surface); }
.tb-slot-advanced-summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--tb-gray-600);
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-slot-advanced-summary::-webkit-details-marker { display: none; }
.tb-slot-advanced-summary::before {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 10px;
  color: var(--tb-gray-500);
  transition: transform 0.2s;
}
.tb-slot-advanced[open] .tb-slot-advanced-summary::before { transform: rotate(180deg); }
.tb-slot-advanced-inner {
  padding: 0 12px 12px;
}
.tb-slot-nature-row {
  margin-bottom: var(--tb-space-2);
}
.tb-slot-nature-label,
.tb-slot-evs-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--tb-gray-500);
  display: block;
  margin-bottom: 4px;
}
.tb-slot-evs-total {
  font-weight: 600;
  color: var(--tb-gray-700);
}
.tb-slot-evs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px 6px;
}
.tb-ev-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0;
}
.tb-ev-label {
  font-size: 10px;
  color: var(--tb-gray-500);
  text-transform: uppercase;
}
.tb-ev-cell .tb-ev {
  width: 100%;
  max-width: 48px;
  padding: 4px 2px;
  font-size: 12px;
  text-align: center;
  border: 1px solid #E5E7EB;
  border-radius: 4px;
  background: var(--tb-surface);
}
.tb-slot-calc-stats {
  margin-top: var(--tb-space-2);
  padding-top: var(--tb-space-1);
  border-top: 1px solid var(--tb-gray-100);
}
.tb-slot-calc-stats .tb-slot-stat-block-label { font-size: 12px; }
.tb-slot-calc-stats .tb-stat-bar-row { margin-bottom: 4px; }
.tb-slot-calc-stats .tb-slot-stat-label,
.tb-slot-calc-stats .tb-stat-bar-num { font-size: 11px; }

.tb-item-picker-dropdown .tb-move-picker-list {
  max-height: 280px;
}

/* Left column: IVs, EVs, moves */
.tb-slot-stats-left {
  grid-column: 1;
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-2);
}

.tb-slot-stat-row {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
}

.tb-slot-stat-label {
  width: 2.5rem;
  color: var(--tb-gray-500);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.tb-slot-stat-block {
  margin-bottom: var(--tb-space-2);
}

.tb-slot-stat-block-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-gray-500);
  margin-bottom: var(--tb-space-1);
}

/* Right column: base stats + final stats in 2-col grid (HP+SpA, Atk+SpD, Def+Spe) */
.tb-slot-stats-right {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-3);
}

.tb-slot-stat-values,
.tb-slot-stat-values-calc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tb-space-1) var(--tb-space-2);
  align-items: center;
}

.tb-slot-stat-values span,
.tb-slot-stat-values-calc span {
  min-width: 1.8rem;
  text-align: center;
}

/* Stat bars – light track, 2-col grid: HP+SpA, Atk+SpD, Def+Spe */
.tb-stat-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--tb-space-1) var(--tb-space-2);
}
.tb-stat-bar-row:nth-child(1) { order: 1; }  /* HP */
.tb-stat-bar-row:nth-child(2) { order: 3; }  /* Atk */
.tb-stat-bar-row:nth-child(3) { order: 5; }  /* Def */
.tb-stat-bar-row:nth-child(4) { order: 2; }  /* SpA */
.tb-stat-bar-row:nth-child(5) { order: 4; }  /* SpD */
.tb-stat-bar-row:nth-child(6) { order: 6; }  /* Spe */

.tb-stat-bar-row {
  display: flex;
  align-items: center;
  gap: var(--tb-space-1);
}

.tb-stat-bar-row .tb-slot-stat-label {
  width: 2.25rem;
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
}

.tb-stat-bar-track {
  flex: 1;
  height: 8px;
  background: var(--tb-gray-100);
  border-radius: var(--tb-radius-pill);
  overflow: hidden;
}

.tb-stat-bar-fill {
  height: 100%;
  border-radius: var(--tb-radius-pill);
  background: linear-gradient(90deg, var(--tb-primary), #60A5FA);
  transition: width 0.3s ease;
}

.tb-stat-bar-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-gray-700);
  min-width: 1.5rem;
  text-align: right;
}

.tb-slot-ivs,
.tb-slot-evs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tb-slot-ivs input,
.tb-slot-evs input {
  width: 2.75rem;
  padding: 6px 8px;
  font-size: 14px;
  text-align: center;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s;
}

.tb-slot-ivs input:focus,
.tb-slot-evs input:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Moves */
.tb-slot-moves {
  grid-column: 1;
}

.tb-slot-moves label {
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
  margin-bottom: var(--tb-space-1);
  display: block;
}

.tb-slot-moves-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--tb-gray-700);
}

.tb-slot-moves-list li {
  padding: 10px 0;
  text-transform: capitalize;
  border-bottom: 1px solid var(--tb-gray-100);
  transition: background 0.15s;
}

.tb-slot-moves-list li:last-child { border-bottom: none; }

.tb-slot-moves-list li:hover { background: var(--tb-gray-100); }

.tb-slot-move-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tb-space-1);
  padding: 10px 0;
}

.tb-slot-move-text { flex: 1; text-transform: capitalize; }

.tb-slot-move-change {
  padding: 6px 12px;
  color: var(--tb-primary);
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  border-radius: var(--tb-radius-pill);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s, border-color 0.2s;
}

.tb-slot-move-change:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--tb-primary);
}

/* Move picker dropdown – light */
.tb-move-picker-dropdown {
  display: none;
  position: fixed;
  z-index: 1050;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  border-radius: var(--tb-radius-lg);
  min-width: 240px;
  max-width: 320px;
  max-height: 360px;
  box-shadow: var(--tb-shadow-hover);
  overflow: hidden;
  flex-direction: column;
}

.tb-move-picker-dropdown.show { display: flex; }

.tb-move-picker-search {
  flex-shrink: 0;
  padding: var(--tb-space-2);
  border-bottom: 1px solid var(--tb-gray-100);
}

.tb-move-picker-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  font-size: 14px;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  border-radius: var(--tb-radius);
  color: var(--tb-gray-700);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s;
}

.tb-move-picker-search input:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tb-move-picker-list {
  overflow-y: auto;
  max-height: 280px;
}

.tb-move-picker-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: none;
  border: none;
  color: var(--tb-gray-700);
  font-size: 14px;
  cursor: pointer;
  text-transform: capitalize;
  transition: background 0.15s;
}

.tb-move-picker-item:hover {
  background: var(--tb-gray-100);
  color: var(--tb-primary);
}

.tb-move-picker-item.tb-move-picker-item-hidden { display: none; }

/* --------------------------------------------------------------------------
   Analysis & recommendations – light cards
   -------------------------------------------------------------------------- */
.tb-analysis-recommendations-wrap {
  margin-top: var(--tb-space-4);
}

.tb-dark-card {
  background: var(--tb-surface);
  border: none;
  border-radius: var(--tb-radius-lg);
  padding: 24px;
  margin-bottom: var(--tb-space-4);
  box-shadow: var(--tb-shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.tb-dark-card:hover {
  box-shadow: var(--tb-shadow-hover);
  transform: translateY(-4px);
}

.tb-dark-card-title {
  color: var(--tb-gray-700) !important;
  border-bottom-color: var(--tb-gray-100) !important;
  margin-bottom: var(--tb-space-3) !important;
  padding-bottom: var(--tb-space-2) !important;
  font-size: 24px !important;
  font-weight: 600 !important;
}

.tb-analysis-section { margin-bottom: var(--tb-space-4); }

/* Team Score Card – premium light-theme result screen */
.tb-score-card {
  background: var(--tb-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--tb-radius-lg);
  padding: 0;
  margin-bottom: var(--tb-space-4);
  box-shadow: var(--tb-shadow);
  overflow: hidden;
}
.tb-score-card-inner {
  padding: var(--tb-space-4);
  text-align: center;
}
.tb-score-number-wrap {
  margin-bottom: var(--tb-space-2);
}
.tb-score-rank-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: var(--tb-radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: var(--tb-space-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.tb-score-card[data-rank="elite"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #E0E7FF 0%, #C7D2FE 50%, #A5B4FC 100%);
  color: #3730A3;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.tb-score-card[data-rank="master"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 50%, #FCD34D 100%);
  color: #92400E;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.tb-score-card[data-rank="expert"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #DBEAFE 0%, #93C5FD 100%);
  color: #1E40AF;
  border: 1px solid rgba(59, 130, 246, 0.25);
}
.tb-score-card[data-rank="advanced"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 50%, #6EE7B7 100%);
  color: #065F46;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.tb-score-card[data-rank="intermediate"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #FEF9C3 0%, #FEF08A 50%, #FDE047 100%);
  color: #854D0E;
  border: 1px solid rgba(234, 179, 8, 0.3);
}
.tb-score-card[data-rank="beginner"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
  color: var(--tb-gray-700);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.tb-score-card[data-rank="incomplete"] .tb-score-rank-badge {
  background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
  color: #991B1B;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.tb-score-number {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}
.tb-score-card[data-rank="elite"] .tb-score-number { color: #4F46E5; }
.tb-score-card[data-rank="master"] .tb-score-number { color: #B45309; }
.tb-score-card[data-rank="expert"] .tb-score-number { color: #2563EB; }
.tb-score-card[data-rank="advanced"] .tb-score-number { color: #047857; }
.tb-score-card[data-rank="intermediate"] .tb-score-number { color: #A16207; }
.tb-score-card[data-rank="beginner"] .tb-score-number { color: var(--tb-gray-700); }
.tb-score-card[data-rank="incomplete"] .tb-score-number { color: #B91C1C; }
.tb-score-max {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--tb-gray-500);
  margin-left: 4px;
}
.tb-score-message {
  font-size: 1.05rem;
  color: var(--tb-gray-600);
  line-height: 1.5;
  margin: 0 0 var(--tb-space-3) 0;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.tb-score-suggestions-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--tb-primary) 0%, #60A5FA 100%);
  border: none;
  border-radius: var(--tb-radius);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.tb-score-suggestions-btn:hover {
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
  transform: translateY(-1px);
}
.tb-score-suggestions-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}
.tb-score-suggestions-btn[aria-expanded="true"] {
  background: linear-gradient(135deg, #374151 0%, #4B5563 100%);
  box-shadow: 0 2px 8px rgba(55, 65, 81, 0.25);
}
.tb-score-suggestions-btn[aria-expanded="true"]:hover {
  box-shadow: 0 4px 14px rgba(55, 65, 81, 0.35);
}
.tb-rating-suggestions-block {
  border-top: 1px solid var(--tb-gray-100);
  padding: var(--tb-space-4);
  background: #FAFAFA;
}
.tb-rating-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-2);
  margin-top: var(--tb-space-4);
  margin-bottom: 0;
}
.tb-rating-bar-row {
  display: flex;
  align-items: center;
  gap: var(--tb-space-2);
}
.tb-rating-bar-label {
  width: 140px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tb-gray-500);
  flex-shrink: 0;
  padding: 12px 8px;
  margin: -12px -8px -12px -8px;
  display: inline-block;
  cursor: help;
  border-radius: 4px;
}
.tb-rating-bar-label:hover {
  color: var(--tb-gray-700);
}
.tb-rating-bar-track {
  flex: 1;
  height: 10px;
  background: var(--tb-gray-100);
  border-radius: var(--tb-radius-pill);
  overflow: hidden;
}
.tb-rating-bar-fill {
  height: 100%;
  border-radius: var(--tb-radius-pill);
  background: linear-gradient(90deg, var(--tb-primary), #60A5FA);
  transition: width 0.4s ease;
}
.tb-rating-bar-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-gray-700);
  min-width: 2rem;
  text-align: right;
}
.tb-rating-suggestions-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--tb-gray-700);
  margin: 0 0 var(--tb-space-2) 0;
}
.tb-suggestions-intro {
  font-size: 15px;
  color: var(--tb-gray-500);
  line-height: 1.5;
  margin: 0 0 var(--tb-space-2) 0;
}
.tb-rating-suggestions .tb-recommendations-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-3);
}
.tb-rating-suggestions .tb-recommendations-list .tb-suggestion-item {
  margin-bottom: var(--tb-space-2);
  padding: var(--tb-space-2) var(--tb-space-2) var(--tb-space-2) var(--tb-space-3);
  color: var(--tb-gray-700);
  line-height: 1.5;
  font-size: 14px;
  background: var(--tb-gray-100);
  border-radius: var(--tb-radius);
  border-left: 3px solid var(--tb-primary);
}
.tb-rating-suggestions .tb-recommendations-list .tb-suggestion-item:last-child {
  margin-bottom: 0;
}
.tb-rating-suggestions .tb-recommendations-list .tb-suggestion-item.tb-suggestion-solid {
  border-left-color: #10B981;
  background: rgba(16, 185, 129, 0.08);
}

/* Premium coaching cards – light theme */
.tb-coaching-card {
  background: var(--tb-surface);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--tb-radius);
  padding: var(--tb-space-3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  list-style: none;
  margin: 0;
  border-left: 4px solid var(--tb-primary);
}
.tb-coaching-card.tb-coaching-highImpact {
  border-left-color: #DC2626;
  background: linear-gradient(to right, rgba(220, 38, 38, 0.06) 0%, var(--tb-surface) 12%);
}
.tb-coaching-card.tb-coaching-mediumImpact {
  border-left-color: #CA8A04;
  background: linear-gradient(to right, rgba(202, 138, 4, 0.08) 0%, var(--tb-surface) 12%);
}
.tb-coaching-card.tb-coaching-optimization {
  border-left-color: var(--tb-primary);
  background: linear-gradient(to right, rgba(59, 130, 246, 0.06) 0%, var(--tb-surface) 12%);
}
.tb-coaching-card.tb-coaching-strength {
  border-left-color: #059669;
  background: linear-gradient(to right, rgba(5, 150, 105, 0.06) 0%, var(--tb-surface) 12%);
}
.tb-coaching-card.tb-coaching-solid {
  border-left-color: #059669;
  background: rgba(16, 185, 129, 0.06);
}
.tb-coaching-header {
  display: flex;
  align-items: center;
  gap: var(--tb-space-2);
  margin-bottom: var(--tb-space-1);
  flex-wrap: wrap;
}
.tb-coaching-priority {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tb-gray-500);
}
.tb-coaching-gain {
  font-size: 0.8rem;
  font-weight: 600;
  color: #059669;
  background: rgba(5, 150, 105, 0.1);
  padding: 2px 8px;
  border-radius: var(--tb-radius-pill);
}
.tb-coaching-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tb-gray-700);
  margin: 0 0 var(--tb-space-1) 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tb-coaching-title .fas {
  color: var(--tb-gray-500);
  flex-shrink: 0;
}
.tb-coaching-explanation {
  font-size: 0.9rem;
  color: var(--tb-gray-600);
  line-height: 1.5;
  margin: 0 0 var(--tb-space-1) 0;
}
.tb-coaching-reasoning {
  font-size: 0.85rem;
  color: var(--tb-gray-500);
  line-height: 1.5;
  margin: 0 0 var(--tb-space-1) 0;
  font-style: italic;
}
.tb-coaching-rec {
  font-size: 0.85rem;
  color: var(--tb-gray-600);
  margin: 0;
}
.tb-coaching-rec strong {
  color: var(--tb-gray-700);
}

.tb-analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--tb-space-3);
}

.tb-analysis-card {
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  border-radius: var(--tb-radius-lg);
  padding: var(--tb-space-3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tb-analysis-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--tb-shadow-hover);
}

.tb-analysis-card-dark {
  background: var(--tb-surface);
  border-color: #E5E7EB;
}

.tb-analysis-card-header {
  display: flex;
  align-items: center;
  gap: var(--tb-space-2);
  margin-bottom: var(--tb-space-2);
}

.tb-analysis-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--tb-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tb-analysis-card.tb-analysis-card-dark h3 {
  color: var(--tb-gray-700) !important;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.tb-analysis-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--tb-gray-700);
}

.tb-analysis-desc {
  font-size: 14px;
  color: var(--tb-gray-500);
  margin: 0 0 var(--tb-space-2) 0;
  line-height: 1.5;
}

.tb-type-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tb-space-1);
}

.tb-type-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--tb-radius-pill);
  text-transform: capitalize;
  letter-spacing: 0.02em;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.tb-weaknesses .tb-type-tag {
  background: #FEE2E2;
  color: #B91C1C;
}

.tb-resistances .tb-type-tag {
  background: #D1FAE5;
  color: #065F46;
}

.tb-analysis-card:not(.tb-weaknesses):not(.tb-resistances) .tb-type-tag {
  background: #DBEAFE;
  color: #1E40AF;
}

.tb-recommendations-section { margin-bottom: 0; }

.tb-recommendations-list {
  margin: 0;
  padding-left: var(--tb-space-3);
  color: var(--tb-gray-700);
  line-height: 1.8;
  font-size: 16px;
}

.tb-recommendations-list li { margin-bottom: var(--tb-space-1); }

.tb-recommendations-list .tb-rec-good { color: #059669; }
.tb-recommendations-list .tb-rec-warn { color: #D97706; }
.tb-recommendations-list .tb-rec-weak { color: #DC2626; }

/* --------------------------------------------------------------------------
   Select Pokemon modal – light
   -------------------------------------------------------------------------- */
.tb-modal-content {
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-hover);
}

.tb-modal-header {
  border-bottom: 1px solid var(--tb-gray-100);
  padding: var(--tb-space-3);
}

.tb-modal-header .modal-title {
  color: var(--tb-gray-700);
  font-size: 24px;
  font-weight: 600;
}

.tb-modal-subtitle {
  color: var(--tb-gray-500);
  font-size: 14px;
  margin: 4px 0 0 0;
}

.tb-modal-search-row {
  display: flex;
  gap: var(--tb-space-2);
  flex-wrap: wrap;
  margin-bottom: var(--tb-space-2);
}

.tb-modal-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.tb-modal-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--tb-gray-500);
  pointer-events: none;
}

.tb-modal-search {
  padding-left: 2.5rem;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s;
}

.tb-modal-search:focus {
  outline: none;
  border-color: var(--tb-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tb-modal-type-filter {
  min-width: 140px;
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  color: var(--tb-gray-700);
  border-radius: var(--tb-radius);
}

.tb-modal-result-count {
  font-size: 14px;
  color: var(--tb-gray-500);
  margin: 0 0 var(--tb-space-2) 0;
}

.tb-modal-loading { color: var(--tb-gray-500); padding: var(--tb-space-2); }

.tb-modal-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--tb-space-2);
  max-height: 380px;
  overflow-y: auto;
}

.tb-modal-poke-card {
  background: var(--tb-surface);
  border: 1px solid #E5E7EB;
  border-radius: var(--tb-radius-lg);
  padding: var(--tb-space-2);
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.tb-modal-poke-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--tb-shadow-hover);
  border-color: var(--tb-primary);
}

.tb-modal-poke-card .tb-modal-poke-sprite {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
  background: var(--tb-gray-100);
  border-radius: var(--tb-radius);
}

.tb-modal-poke-card .tb-modal-poke-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tb-gray-700);
  text-transform: capitalize;
  margin-bottom: 6px;
}

.tb-modal-poke-card .tb-modal-poke-types {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.tb-modal-poke-card .tb-modal-poke-types span {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--tb-radius-pill);
  text-transform: uppercase;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.tb-modal-poke-card-hidden { display: none !important; }

.tb-modal-types-placeholder { color: var(--tb-gray-500); font-size: 14px; }

/* Modal close button – dark X on light */
.tb-modal-header .btn-close {
  filter: none;
  opacity: 0.6;
}
.tb-modal-header .btn-close:hover {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .tb-slots { grid-template-columns: repeat(2, 1fr); }
  .tb-slot-filled {
    grid-template-columns: 1fr;
  }
  .tb-slot-stats-right {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 768px) {
  .team-builder-page { padding-top: 112px; }
  .tb-header h1 { font-size: 26px; }
  .tb-slots { grid-template-columns: 1fr; }
  .tb-team-card-header {
    flex-direction: column;
    align-items: stretch;
  }
  .tb-team-name-inline { justify-content: flex-start; }
  .tb-team-card-actions { justify-content: flex-end; }
  .tb-analysis-grid { grid-template-columns: 1fr; }
}
