/* Box2Box — Immaculate Grid, Moroccan football edition.
   Dark arena theme aligned with the niche-foot crimson accent. Every
   surface sits on the global --bg palette so the page feels like part
   of the site, not a bolted-on game from 2019. */

.b2b-body {
  background:
    radial-gradient(ellipse at top,    rgba(255,46,87,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at bottom, rgba(160,107,255,0.1) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

.b2b-wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 18px 14px 60px;
}

.b2b-title {
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 38px);
  letter-spacing: 10px;
  font-weight: 800;
  padding: 18px 0 6px;
  background: linear-gradient(135deg, #fff 0%, var(--ma-red) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Puzzle browser (landing view) ---------- */
.b2b-browser { margin-top: 16px; }
.b2b-browser-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.b2b-solved-count {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--ma-gold);
  font-weight: 700;
}
.b2b-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.b2b-filter {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s ease, border-color .12s ease;
}
.b2b-filter:hover { background: rgba(255,200,87,0.12); border-color: var(--ma-gold); }
.b2b-filter.active { background: var(--ma-gold); color: #0a1122; border-color: var(--ma-gold); }
.b2b-random {
  background: linear-gradient(180deg, var(--ma-red), #c1293c);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 12px -3px rgba(255,46,87,0.4);
}

.b2b-browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.b2b-card {
  background: rgba(29,36,64,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .1s ease, border-color .12s ease, background .12s ease;
  position: relative;
}
.b2b-card:hover { transform: translateY(-2px); border-color: var(--ma-gold); background: rgba(40,48,80,0.65); }
.b2b-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.b2b-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}
.b2b-card-diff {
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #0a1122;
}
.b2b-card-diff.easy   { background: #3ecf8e; }
.b2b-card-diff.normal { background: #ffc857; }
.b2b-card-diff.hard   { background: #ff5c7a; color: #fff; }
.b2b-card-solved {
  position: absolute;
  top: 8px;
  right: 10px;
  color: #3ecf8e;
  font-size: 14px;
  font-weight: 800;
}
.b2b-card.solved { border-color: rgba(62,207,142,0.3); background: rgba(30,60,50,0.35); }

.b2b-back {
  background: none;
  color: var(--ma-gold);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 0 12px;
  cursor: pointer;
  letter-spacing: 1px;
}
.b2b-back:hover { color: #fff; }

/* Round switcher — sits between the title and the stat strip. Lets
   the user browse every active puzzle; "Featured" snaps back to the
   site's highlighted pick. */
.b2b-rounds {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 0 0;
  padding: 8px 10px;
  background: rgba(29,36,64,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  font-size: 13px;
}
.b2b-round-btn {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  font-family: inherit;
}
.b2b-round-btn:hover:not(:disabled) {
  background: rgba(255,200,87,0.12);
  border-color: var(--ma-gold);
}
.b2b-round-btn:disabled { opacity: .35; cursor: not-allowed; }
.b2b-round-btn.b2b-round-today { margin-left: auto; }
.b2b-round-select {
  flex: 1;
  background: rgba(10,13,26,0.7);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
}
.b2b-round-select:focus {
  outline: none;
  border-color: var(--ma-gold);
  box-shadow: 0 0 0 2px rgba(255,200,87,0.22);
}

/* Stat strip — two chips on a subtle card. */
.b2b-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(29,36,64,0.6);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 14px 0 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 2px;
}
.b2b-stats span {
  text-align: center;
  color: var(--text);
}
.b2b-stats span b {
  display: block;
  font-size: 22px;
  color: var(--ma-red);
  font-weight: 800;
  margin-bottom: 2px;
  letter-spacing: 0;
}

/* ---- 4-col grid (header row + 3 cells, header col + 3 cells). ---- */
.b2b-grid-wrap {
  border-radius: 16px;
  padding: 6px;
  background: linear-gradient(180deg, rgba(255,46,87,0.12) 0%, rgba(10,13,26,0.5) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.b2b-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 6px;
  table-layout: fixed;
}
.b2b-grid th, .b2b-grid td {
  width: 25%;
  padding: 0;
  vertical-align: middle;
}

/* Corner tile — site's logo/identity chip. */
.b2b-grid .corner {
  background: linear-gradient(135deg, var(--ma-red) 0%, var(--ma-red-dark) 100%);
  border-radius: 12px;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 11px;
  color: #fff;
  padding: 14px 4px;
  box-shadow: 0 0 24px rgba(255,46,87,0.3), 0 4px 12px rgba(0,0,0,0.4);
}

/* Category headers (row + col). Same treatment, different grid area. */
.b2b-grid .col-head, .b2b-grid .row-head {
  background: rgba(29,36,64,0.8);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  text-align: center;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.b2b-grid .col-head:hover, .b2b-grid .row-head:hover {
  border-color: rgba(255,200,87,0.55);
  box-shadow: 0 0 16px rgba(255,200,87,0.18);
}
.b2b-grid .col-head .type {
  display: block;
  font-size: 9px;
  color: var(--ma-gold);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
}
.b2b-grid .col-head .text,
.b2b-grid .row-head .text {
  display: block;
  margin-top: 6px;
  line-height: 1.15;
  font-weight: 700;
  font-size: 12px;
}

/* Logo image inside a header. Trophy/crest cues. */
.b2b-img {
  display: block;
  margin: 0 auto;
  max-width: 54px;
  max-height: 54px;
  width: auto; height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.15));
}
.b2b-grid .row-head { padding: 8px 4px; }
.b2b-grid .row-head .b2b-img { max-height: 52px; }
.b2b-grid .col-head .b2b-img { max-height: 46px; }

/* Country flags get a circular frame so they look intentional. */
.b2b-grid .b2b-img.is-nation {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: #fff;
  width: 48px; height: 48px;
  object-fit: cover;
}

/* Fallback badge when a category has no logo — coloured circle with
   the first letter. Same 48px footprint so layout doesn't shift. */
.b2b-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 800;
  color: #1a0002;
  margin: 0 auto;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15) inset, 0 4px 10px rgba(0,0,0,0.3);
  background: linear-gradient(135deg, var(--ma-gold), #c99210);
}
.b2b-badge.honour      { background: linear-gradient(135deg, #ffc857, #c99210); color: #1a1200; }
.b2b-badge.competition { background: linear-gradient(135deg, #a06bff, #6c3dd1); color: #fff; }
.b2b-badge.coach       { background: linear-gradient(135deg, #1ee37a, #0fa85a); color: #0a2016; }

/* ---- Playable cells ---- */
.b2b-grid .cell {
  background:
    radial-gradient(circle at 50% 30%, rgba(255,46,87,0.08), transparent 60%),
    rgba(29,36,64,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  aspect-ratio: 1/1;
  cursor: pointer;
  position: relative;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.b2b-grid .cell:hover {
  transform: translateY(-2px);
  border-color: rgba(255,46,87,0.45);
  box-shadow: 0 0 22px rgba(255,46,87,0.25);
}
.b2b-grid .cell .empty {
  color: rgba(255,255,255,0.55);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-align: center;
  padding-top: 38%;
  pointer-events: none;
  font-weight: 600;
  text-transform: uppercase;
}
.b2b-grid .cell .empty::before {
  content: "+";
  display: block;
  font-size: 36px;
  font-weight: 300;
  line-height: 0.8;
  margin-bottom: 6px;
  color: rgba(255,200,87,0.55);
}

/* Filled cell — card with the answer's name + "kit" badge. */
.b2b-grid .cell.filled {
  background: linear-gradient(180deg, rgba(30,227,122,0.14) 0%, rgba(29,36,64,0.85) 100%);
  border-color: rgba(30,227,122,0.4);
  cursor: default;
  animation: b2b-pop 450ms cubic-bezier(.2,.8,.2,1);
}
.b2b-grid .cell.filled:hover { transform: none; box-shadow: none; }
@keyframes b2b-pop {
  0%   { transform: scale(.7); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.b2b-grid .cell.filled .player-kit {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; padding: 8px; gap: 4px;
}
.b2b-grid .cell.filled .player-kit .num {
  background: linear-gradient(135deg, var(--ma-red), var(--ma-red-dark));
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800; color: #fff;
  clip-path: polygon(0% 10%, 18% 0%, 30% 10%, 70% 10%, 82% 0%, 100% 10%, 100% 100%, 0% 100%);
  box-shadow: 0 6px 14px rgba(255,46,87,0.4);
}
.b2b-grid .cell.filled .player-kit .name {
  font-size: 11px;
  text-align: center;
  color: var(--text);
  font-weight: 600;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Search panel ---- */
.b2b-search {
  position: relative;
  margin-top: 18px;
  background: rgba(29,36,64,0.95);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px 12px 8px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
}
.b2b-input {
  width: calc(100% - 54px);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  background: rgba(10,13,26,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.b2b-input:focus {
  outline: none;
  border-color: var(--ma-gold);
  box-shadow: 0 0 0 3px rgba(255,200,87,0.25);
}
.b2b-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 42px; height: 42px;
  background: var(--ma-red);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 800; font-size: 15px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.b2b-close:hover { background: var(--ma-red-dark); transform: scale(1.04); }

.b2b-results {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 10px;
  border-radius: 8px;
}
.b2b-results div {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  color: var(--text);
  transition: background-color .1s ease;
}
.b2b-results div:last-child { border-bottom: none; }
.b2b-results div:hover { background: rgba(255,200,87,0.1); }
.b2b-results .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Result banner (win/lose toast under the grid). */
#b2b-result:not(:empty) {
  margin-top: 16px;
  padding: 14px;
  background: rgba(29,36,64,0.8);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
}

/* Mobile polish. */
@media (max-width: 520px) {
  .b2b-title { letter-spacing: 6px; }
  .b2b-grid .col-head .text, .b2b-grid .row-head .text { font-size: 10px; }
  .b2b-img { max-width: 42px; max-height: 42px; }
  .b2b-grid .cell.filled .player-kit .num { width: 38px; height: 38px; font-size: 17px; }
}
