/* WC2026 simulator — group panels, knockout bracket, champion banner. */

.wc-sim { padding-bottom: 50px; max-width: 1200px; }
.wc-head h1 { margin: 20px 0 8px; font-size: 2rem; }
.wc-head .tagline { opacity: .85; margin: 0 0 10px; line-height: 1.5; }
.wc-head .meta { font-size: .85rem; opacity: .85; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ar-inline { font-weight: 400; opacity: .7; margin-left: 10px; font-size: 0.7em; direction: rtl; unicode-bidi: isolate; }

.wc-tabs { display: flex; gap: 4px; margin: 20px 0 10px; border-bottom: 2px solid rgba(255,255,255,0.1); }
.wc-tab {
  background: transparent; border: none; color: inherit;
  padding: 10px 16px; font-size: .95rem; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  opacity: .7; font-family: "Poppins", system-ui, sans-serif;
}
.wc-tab.active { opacity: 1; border-bottom-color: #e63946; font-weight: 600; }
.wc-tab:hover { opacity: .95; }

.wc-panel { padding: 15px 0; }

/* Groups layout */
#panel-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}
.wc-group {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 14px;
}
.wc-group h3 {
  margin: 0 0 10px; font-size: 1rem;
  text-transform: uppercase; letter-spacing: 1px;
  color: #ffd17a;
}
.wc-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.wc-team {
  display: grid; grid-template-columns: 22px 28px 1fr;
  align-items: center; gap: 6px;
}
.wc-team .seed { opacity: .6; font-family: "Menlo", monospace; font-size: .8rem; }
.wc-team .flag { width: 26px; height: auto; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.3); }
.wc-team input {
  min-width: 0;
  padding: 5px 8px; border-radius: 5px;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; font-size: .85rem;
}

/* Flag PNG everywhere else (fixtures, standings, bracket). */
.wc-match .flag, .wc-standings .flag {
  width: 18px; height: auto; border-radius: 2px; vertical-align: middle;
  margin-right: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}
.wc-match.knockout .flag { width: 20px; }
.team-name-text { display: inline-block; vertical-align: middle; }

.wc-langtoggle,
.wc-modetoggle { display: inline-flex; gap: 4px; align-items: center; margin-left: 6px; }
.wc-langtoggle .btn,
.wc-modetoggle .btn { padding: 4px 10px; min-width: 32px; }

/* Results-mode match row: 1/X/2 buttons replace score inputs. */
.wc-match.mode-results {
  grid-template-columns: 32px 1fr auto 1fr auto;
}
.wc-match.mode-results .wx2 {
  display: flex; gap: 4px; justify-content: center;
}
.wc-match.mode-results .wx2 .btn {
  padding: 3px 8px; min-width: 30px; font-weight: 700;
}
.wc-match.mode-results .score-peek {
  font-family: "Menlo", monospace; font-size: .75rem; opacity: .55;
  padding-left: 6px;
}

/* Bracket click-to-advance row (results mode) — no score input */
.wc-b-row .sc-readonly {
  display: inline-block; width: 100%; text-align: center;
  font-weight: 700; color: #7affa2;
}
.wc-b-row:hover { background: rgba(255,255,255,0.06); }

/* Thirds manual-pick toolbar */
.wc-thirds-toolbar {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  margin: 0 0 12px; padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  font-size: .9rem;
}
.wc-thirds-toolbar .count { opacity: .7; font-family: "Menlo", monospace; }
.wc-standings td.pick { text-align: center; padding: 4px; }

.wc-fixtures { margin-bottom: 10px; }
.wc-match {
  display: grid;
  grid-template-columns: 32px 1fr 38px 12px 38px 1fr;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: .85rem;
}
.wc-match .md { font-size: .7rem; opacity: .55; text-align: center; }
.wc-match .team { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wc-match .team.h { text-align: right; }
.wc-match .team.a { text-align: left; }
.wc-match .sc {
  width: 100%; text-align: center; padding: 4px 2px;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; border-radius: 4px; font-weight: 600;
}
.wc-match .vs { text-align: center; opacity: .5; }

/* Strip the native number-input spin buttons — they clutter small
   score cells and users just type the digit. */
.wc-sim input[type=number]::-webkit-inner-spin-button,
.wc-sim input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}
.wc-sim input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.wc-standings {
  width: 100%; border-collapse: collapse; font-size: .82rem;
  background: rgba(0,0,0,0.2); border-radius: 6px; overflow: hidden;
  margin-top: 8px;
}
.wc-standings th, .wc-standings td {
  padding: 6px 4px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.wc-standings th { background: rgba(0,0,0,0.25); font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
.wc-standings td.team-name { text-align: left; padding-left: 10px; font-weight: 500; }
.wc-standings td.pts { font-weight: 800; }
.wc-standings td.pos { color: #7affa2; }
.wc-standings td.neg { color: #ff9090; }
.wc-standings tr.qualified td:first-child { color: #7affa2; font-weight: 700; }
.wc-standings tr.third td:first-child { color: #ffd17a; font-weight: 700; }

.wc-note { font-size: .9rem; opacity: .85; line-height: 1.5; margin-bottom: 16px; }

/* ---- Visual bracket (tournament tree) ---- */
/* Rounds are flex columns; justify-content: space-around puts each
   match at the vertical midpoint between its two source matches,
   producing classic bracket alignment automatically. */
.wc-bracket {
  display: flex;
  gap: 30px;
  padding: 12px 6px 24px;
  overflow-x: auto;            /* horizontal scroll on mobile */
  min-height: 1000px;
}
.wc-b-round {
  display: flex; flex-direction: column;
  flex: 1 1 0; min-width: 210px;
}
.wc-b-round h4 {
  font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px;
  margin: 0 0 14px; padding: 6px 10px;
  color: #ffd17a; background: rgba(255, 209, 122, 0.08);
  border-radius: 4px; text-align: center;
}
.wc-b-matches {
  flex: 1; display: flex; flex-direction: column;
  justify-content: space-around;
  gap: 8px;
}
.wc-b-match {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: .82rem;
  line-height: 1.3;
}
.wc-b-match.pending { opacity: .5; }
.wc-b-match.is-third { max-width: 260px; margin: 0 auto; }

.wc-b-meta {
  font-family: "Menlo", monospace; font-size: .65rem;
  opacity: .55; margin-bottom: 4px;
}
.wc-b-row {
  display: grid;
  grid-template-columns: 1fr 34px;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 3px;
}
.wc-b-row.win {
  background: rgba(120, 255, 162, 0.12);
  font-weight: 700;
}
.wc-b-row .name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center;
}
.wc-b-row .name .flag { width: 18px; margin-right: 4px; }
.wc-b-row .sc {
  width: 100%; padding: 3px 2px; text-align: center;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; border-radius: 3px; font-weight: 600; font-size: .85rem;
}
.wc-b-row .sc:disabled { background: transparent; border-color: transparent; }

/* Connector lines between rounds — pure CSS. Each .wc-b-match (except
   the last column) gets a horizontal line on its right and a vertical
   half-line joining to its sibling above/below, producing the classic
   U-shape that feeds into the next round's match. */
.wc-b-match::after {
  content: ""; position: absolute;
  top: 50%; right: -15px;
  width: 15px; height: 1px;
  background: rgba(255,255,255,0.2);
}
.wc-b-match.is-last::after,
.wc-b-match.is-third::after { display: none; }

/* Vertical joiner between each pair in rounds 0..3 */
.wc-b-round:not(:last-child) .wc-b-matches .wc-b-match:nth-child(odd)::before {
  content: ""; position: absolute;
  top: 50%; right: -15px;
  width: 1px;
  background: rgba(255,255,255,0.2);
  /* Height covers from this match's midline down to the next match's
     midline. Computed dynamically in JS isn't reliable inside flex
     space-around; instead use an approximation via full-height parent. */
  height: calc(100% + 8px);
}

/* Extra-time / penalty details */
.wc-xt { margin-top: 6px; font-size: .7rem; }
.wc-xt summary {
  cursor: pointer; opacity: .7; font-size: .7rem;
  padding: 2px 0;
}
.xt-row { margin-top: 3px; }
.xt-row label {
  display: flex; align-items: center; gap: 4px;
  font-size: .7rem; opacity: .9;
}
.xt-row input {
  width: 34px; padding: 2px; text-align: center;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; border-radius: 3px; font-size: .75rem;
}

/* Third-place match on its own row below the main bracket */
.wc-thirdplace {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px dashed rgba(255,255,255,0.12);
}
.wc-thirdplace h4 {
  font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px;
  color: #ffd17a; margin: 0 0 10px; text-align: center;
}

.wc-champion {
  margin-bottom: 20px; padding: 20px;
  background: linear-gradient(135deg, rgba(255,215,0,0.2), rgba(255,100,100,0.15));
  border: 2px solid rgba(255,215,0,0.5);
  border-radius: 10px;
  display: flex; align-items: center; gap: 16px;
  font-family: "Poppins", system-ui, sans-serif;
}
.wc-champion .trophy { font-size: 2.5rem; }
.wc-champion .text { font-size: 1.1rem; }
.wc-champion strong { color: #ffd17a; }
