:root {
  --bg: #04100a;
  --panel: rgba(8, 24, 15, 0.72);
  --panel-solid: #0b2116;
  --panel-2: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #eef7f0;
  --muted: #9db8a6;
  --dim: #6c8a76;
  --accent: #b8ff3c;
  --accent-ink: #0b1a05;
  --accent-2: #2fe3a0;
  --gold: #ffd75e;
  --danger: #ff5d6c;
  --grass-a: #2b8f47;
  --grass-b: #247c3d;
  --kit: #d7263d;
  --kit-text: #ffffff;
  --gk: #d9ff3f;
  --gk-text: #142100;
  --radius: 18px;
  color-scheme: dark;
  --display: "Bebas Neue", "Impact", "Arial Narrow", sans-serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------- Stadium backdrop ---------------- */
.stadium { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: radial-gradient(ellipse 120% 70% at 50% -10%, #17452c 0%, #08180f 50%, #030805 100%); }
.stadium .glow { position: absolute; inset: 0;
  background:
    radial-gradient(circle at 7% 6%, rgba(255, 255, 225, .55), transparent 20%),
    radial-gradient(circle at 93% 6%, rgba(255, 255, 225, .55), transparent 20%),
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(210, 255, 220, .12), transparent 70%);
  animation: flicker 9s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { opacity: 1 } 50% { opacity: .85 } }
.tower { position: absolute; top: 3%; width: 110px; height: 46px; border-radius: 6px;
  background: radial-gradient(circle, #fffef0 2.2px, transparent 3px) 0 0 / 14px 12px, #1b2a22;
  box-shadow: 0 0 40px 16px rgba(255, 255, 220, .35), 0 0 140px 60px rgba(255, 255, 220, .12); }
.tower i { position: absolute; left: 50%; top: 100%; width: 6px; height: 60vh; transform: translateX(-50%);
  background: linear-gradient(#26342c, transparent 70%); }
.tower.l { left: 3%; transform: rotate(-8deg); }
.tower.r { right: 3%; transform: rotate(8deg); }
.stands { position: absolute; left: -15%; right: -15%; top: 16%; height: 40%;
  border-radius: 50% 50% 0 0 / 40% 40% 0 0;
  background:
    radial-gradient(circle, rgba(255,255,255,.22) 1.1px, transparent 1.8px) 0 0 / 8px 7px,
    radial-gradient(circle, rgba(255,80,90,.22) 1.1px, transparent 1.8px) 3px 3px / 11px 9px,
    radial-gradient(circle, rgba(90,170,255,.2) 1.1px, transparent 1.8px) 6px 1px / 13px 11px,
    radial-gradient(circle, rgba(255,220,90,.18) 1.1px, transparent 1.8px) 2px 5px / 17px 13px,
    linear-gradient(#0d1c14, #13281c 70%, #0a1a10);
  box-shadow: inset 0 18px 30px rgba(0,0,0,.6); opacity: .9; }
.stands::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14%;
  background: linear-gradient(90deg, #c8102e, #f4f4f4, #0a3d91, #f4f4f4, #c8102e); opacity: .35; filter: blur(1px); }
.turf { position: absolute; left: -60%; right: -60%; bottom: -12%; height: 58%;
  transform: perspective(700px) rotateX(58deg); transform-origin: 50% 100%;
  background:
    linear-gradient(transparent 49.6%, rgba(255,255,255,.35) 49.6% 50.4%, transparent 50.4%),
    repeating-linear-gradient(90deg, var(--grass-a) 0 6%, var(--grass-b) 6% 12%);
  -webkit-mask-image: linear-gradient(to top, #000 55%, transparent);
          mask-image: linear-gradient(to top, #000 55%, transparent);
  filter: saturate(1.1) brightness(.75); }

/* ---------------- Top bar ---------------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; align-items: center; justify-content: space-between;
  padding: 10px clamp(16px, 3vw, 32px); background: linear-gradient(rgba(3,10,6,.85), rgba(3,10,6,.4));
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-ball { font-size: 22px; filter: drop-shadow(0 0 8px rgba(184,255,60,.6)); }
.brand-text { font-family: var(--display); font-size: 28px; letter-spacing: 1.5px; }
.brand-text b { color: var(--accent); font-weight: 400; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); transition: .15s; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

main { width: 100%; max-width: 1400px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 32px) 80px; }

/* ---------------- Buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px;
  font-weight: 700; font-size: 14px; border: 1px solid var(--line-2); background: var(--panel-2); transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(180deg, #ccff66, var(--accent)); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 6px 24px rgba(184,255,60,.25), inset 0 1px 0 rgba(255,255,255,.5); }
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.gold { background: linear-gradient(180deg, #ffe58f, var(--gold)); color: #2b1d00; border-color: transparent;
  box-shadow: 0 6px 24px rgba(255,215,94,.25); }
.btn.danger { color: var(--danger); border-color: rgba(255,93,108,.35); }
.btn.danger:hover { background: rgba(255,93,108,.12); border-color: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 15px 28px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: .45; pointer-events: none; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,.35); }

/* ---------------- Home ---------------- */
.hero { text-align: center; padding: clamp(40px, 9vh, 100px) 0 36px; }
.hero .kicker { display: inline-block; font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--accent);
  border: 1px solid rgba(184,255,60,.35); padding: 6px 14px; border-radius: 999px; background: rgba(184,255,60,.07); }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(64px, 13vw, 150px); line-height: .9; margin: 18px 0 10px;
  letter-spacing: 2px; text-shadow: 0 6px 40px rgba(0,0,0,.6); }
.hero h1 span { color: var(--accent); text-shadow: 0 0 40px rgba(184,255,60,.45); }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 28px; font-size: 16px; line-height: 1.55; }
.hero .stat-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.chip-stat { padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.chip-stat b { color: var(--text); }

.section-title { font-family: var(--display); font-size: 30px; letter-spacing: 1px; font-weight: 400; margin: 34px 0 14px; display: flex; align-items: center; gap: 12px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.team-card { position: relative; padding: 16px; text-align: left; overflow: hidden; transition: .18s; display: flex; gap: 14px; align-items: center; }
.team-card:hover { transform: translateY(-2px); border-color: rgba(184,255,60,.4); }
.team-card .mini { flex: 0 0 74px; }
.team-card h3 { margin: 0 0 4px; font-size: 17px; }
.team-card .meta { color: var(--muted); font-size: 13px; line-height: 1.5; }
.team-card .card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: .15s; }
.team-card:hover .card-actions, .team-card:focus-within .card-actions { opacity: 1; }
.card-actions button { width: 30px; height: 30px; border-radius: 9px; background: rgba(0,0,0,.4); border: 1px solid var(--line); font-size: 14px; }
.card-actions button:hover { border-color: var(--danger); color: var(--danger); }
.empty-note { color: var(--dim); text-align: center; padding: 30px; border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* Mini pitch (formation thumbnails) */
.mini-pitch { position: relative; width: 100%; aspect-ratio: 68/100; border-radius: 8px; overflow: hidden;
  background: repeating-linear-gradient(0deg, var(--grass-a) 0 12.5%, var(--grass-b) 12.5% 25%);
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); }
.mini-pitch::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(255,255,255,.35); }
.mini-pitch i { position: absolute; width: 9%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%);
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mini-pitch i.gk { background: var(--gk); }
.mini-pitch i.on { background: var(--accent); }

/* ---------------- Builder ---------------- */
.builder-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.team-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team-title h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 38px; letter-spacing: 1px; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.kit-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--kit); border: 2px solid rgba(255,255,255,.7); flex: none; }
.builder-head .spacer { flex: 1; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.assign-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; border-radius: 14px;
  background: linear-gradient(90deg, rgba(255,215,94,.18), rgba(255,215,94,.06)); border: 1px solid rgba(255,215,94,.45); }
.assign-banner .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 0 rgba(255,215,94,.7); animation: pulse 1.4s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(255,215,94,0) } 100% { box-shadow: 0 0 0 0 rgba(255,215,94,0) } }
.assign-banner .msg { flex: 1; min-width: 200px; font-size: 14px; }
.assign-banner .msg b { color: var(--gold); }

.select-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 14px;
  background: rgba(184,255,60,.08); border: 1px solid rgba(184,255,60,.35); font-size: 14px; }
.select-bar .msg { flex: 1; min-width: 180px; }
.select-bar .msg small { color: var(--muted); display: block; }

.builder { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 18px; align-items: start; }
.mtabs.seg { display: none; }

.pitch-wrap { padding: 14px; }
.pitch-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.formation-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid var(--line-2); font-weight: 700; }
.formation-btn:hover { border-color: var(--accent); }
.formation-btn small { color: var(--muted); font-weight: 500; }
.count-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.pill b { color: var(--text); }
.pill.done { border-color: rgba(184,255,60,.45); }
.pill.done b { color: var(--accent); }

.pitch { position: relative; width: 100%; max-width: 620px; margin: 0 auto; aspect-ratio: 68 / 100; border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0,0,0,.35) 100%),
    repeating-linear-gradient(0deg, var(--grass-a) 0 6.25%, var(--grass-b) 6.25% 12.5%);
  box-shadow: 0 25px 60px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.08); }
.pitch::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 8% 0%, rgba(255,255,230,.18), transparent 40%), radial-gradient(circle at 92% 0%, rgba(255,255,230,.18), transparent 40%); }
.pitch svg.lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.slot { position: absolute; transform: translate(-50%, -50%); width: 17%; display: flex; flex-direction: column; align-items: center; z-index: 2;
  transition: transform .15s; -webkit-tap-highlight-color: transparent; }
.slot:hover { transform: translate(-50%, -50%) scale(1.06); }
.shirt { width: 64%; max-width: 64px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); overflow: visible; }
.shirt .body { fill: var(--kit); stroke: rgba(255,255,255,.55); stroke-width: 1.4; }
.shirt .num { fill: var(--kit-text); font-family: var(--display); font-size: 26px; text-anchor: middle; }
.shirt.gk .body { fill: var(--gk); }
.shirt.gk .num { fill: var(--gk-text); }
.shirt.nonum .num { opacity: .5; }
.slot .nm { margin-top: 2px; max-width: 120%; padding: 2px 7px; border-radius: 6px; background: rgba(4,14,8,.82); font-size: clamp(9px, 1.5vw, 12px);
  font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(255,255,255,.08); }
.slot .ps { font-size: clamp(8px, 1.2vw, 10px); font-weight: 800; color: var(--accent); letter-spacing: .5px; margin-top: 1px; text-shadow: 0 1px 2px #000; }
.slot.empty .ring { width: 52%; max-width: 52px; aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(255,255,255,.55);
  display: grid; place-items: center; font-weight: 800; font-size: clamp(9px, 1.4vw, 12px); background: rgba(0,0,0,.18); }
.slot.empty.next .ring { border-color: var(--accent); color: var(--accent); background: rgba(184,255,60,.12); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.1); } }
.slot.selected .shirt, .card.selected .shirt { filter: drop-shadow(0 0 10px var(--accent)) drop-shadow(0 0 3px var(--accent)); }
.slot.selected .nm, .card.selected .nm { background: var(--accent); color: var(--accent-ink); }
.slot.swap-target .ring { border-color: var(--accent); }
.assigning .slot.filled.pending .shirt, .assigning .card.pending .shirt { animation: wiggle 1.8s ease-in-out infinite; }
.assigning .slot.filled.got .nm, .assigning .card.got .nm { background: var(--gold); color: #2b1d00; }
.order-badge { position: absolute; top: -4px; right: 14%; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px; display: grid; place-items: center;
  background: var(--gold); color: #2b1d00; font-size: 11px; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
@keyframes wiggle { 0%, 100% { transform: rotate(0) } 10% { transform: rotate(-4deg) } 20% { transform: rotate(4deg) } 30% { transform: rotate(0) } }

/* Substitutes / Bench strips */
.strip { margin-top: 16px; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.strip-head h4 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: 1px; }
.strip-head span { color: var(--muted); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 7px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(43,143,71,.35), rgba(15,50,28,.5)); border: 1px solid var(--line); min-height: 98px; transition: .15s; }
.card:hover { border-color: rgba(184,255,60,.5); }
.card .shirt { width: 46px; }
.card .nm { font-size: 11px; font-weight: 700; margin-top: 3px; max-width: 100%; padding: 1px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ps { font-size: 10px; color: var(--accent); font-weight: 800; }
.card.empty { background: transparent; border: 1.5px dashed var(--line-2); justify-content: center; color: var(--dim); font-size: 12px; gap: 4px; }
.card.empty .plus { font-size: 22px; line-height: 1; }
.card.empty.next { border-color: var(--accent); color: var(--accent); }
.card.bench { background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); }

/* Side panel: search */
.side { padding: 16px; position: sticky; top: 76px; max-height: calc(100vh - 92px); display: flex; flex-direction: column; }
.side h3 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; font-size: 28px; letter-spacing: 1px; }
.adding-to { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.adding-to b { color: var(--accent); }
.seg { display: flex; padding: 3px; border-radius: 11px; background: rgba(0,0,0,.3); border: 1px solid var(--line); margin-bottom: 10px; }
.seg button { flex: 1; padding: 7px 6px; border-radius: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.search { position: relative; margin-bottom: 8px; }
.search input { width: 100%; padding: 13px 14px 13px 42px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); outline: none; font-size: 15px; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,255,60,.15); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button { padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); color: var(--muted); }
.filters button.on { border-color: var(--accent); color: var(--accent); background: rgba(184,255,60,.08); }
.results-meta { font-size: 12px; color: var(--dim); margin: 0 2px 6px; display: flex; justify-content: space-between; }
.results { overflow-y: auto; flex: 1; min-height: 200px; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: #2b4a37 transparent; }
.result { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; text-align: left; border: 1px solid transparent; transition: .12s; }
.result:hover { background: rgba(255,255,255,.05); border-color: var(--line); }
.result.in { opacity: .45; }
.result .r-main { flex: 1; min-width: 0; }
.result .r-name, .result .r-meta { display: block; }
.result .r-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-nums { display: flex; gap: 4px; flex: none; }
.num-chip { min-width: 24px; height: 24px; padding: 0 5px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: rgba(255,255,255,.07); color: var(--muted); }
.num-chip.primary { background: var(--kit); color: var(--kit-text); }
.result .add { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: rgba(184,255,60,.12); color: var(--accent); font-weight: 800; flex: none; }
.result.in .add { background: transparent; color: var(--dim); }
.pos-badge { flex: none; width: 40px; padding: 4px 0; text-align: center; border-radius: 8px; font-size: 11px; font-weight: 800; letter-spacing: .3px; }
.pos-GK { background: rgba(217,255,63,.16); color: #e2ff6b; }
.pos-DEF { background: rgba(80,160,255,.16); color: #8cc2ff; }
.pos-MID { background: rgba(47,227,160,.15); color: #6ff0bf; }
.pos-FWD { background: rgba(255,93,108,.16); color: #ff8f99; }
.custom-cta { margin-top: 10px; text-align: center; font-size: 13px; color: var(--muted); }
.custom-cta button { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- Modals ---------------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(1,6,3,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0 } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px; background: linear-gradient(180deg, #0f2a1b, #0a1d12);
  border: 1px solid var(--line-2); border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pop .18s ease-out; }
.modal.wide { width: min(920px, 100%); }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0 } }
.modal h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; font-size: 34px; letter-spacing: 1px; }
.modal .sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; line-height: 1.5; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 7px; }
.field input[type=text], .field input[type=number], .field select { width: 100%; padding: 12px 14px; border-radius: 12px; background: rgba(0,0,0,.35);
  border: 1px solid var(--line-2); outline: none; }
.field input:focus, .field select:focus { border-color: var(--accent); }
.field select option { background: #0b2116; }
.field .hint { font-size: 12px; color: var(--dim); margin-top: 6px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 38px; height: 38px; border-radius: 10px; border: 2px solid transparent; position: relative; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,255,60,.25); }
.swatch span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: 18px; }

.form-groups h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.form-card { padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.2); text-align: center; transition: .12s; }
.form-card:hover { border-color: rgba(184,255,60,.5); }
.form-card.on { border-color: var(--accent); background: rgba(184,255,60,.08); }
.form-card .fname { font-size: 12px; font-weight: 700; margin-top: 6px; line-height: 1.2; }

.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; }
.setting-row .txt { flex: 1; }
.setting-row .txt b { display: block; font-size: 15px; margin-bottom: 3px; }
.setting-row .txt small { color: var(--muted); font-size: 13px; line-height: 1.45; display: block; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; flex: none; }
.stepper button { width: 38px; height: 40px; font-size: 20px; font-weight: 700; color: var(--accent); }
.stepper button:hover { background: rgba(184,255,60,.1); }
.stepper output { min-width: 40px; text-align: center; font-family: var(--display); font-size: 26px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,.15); transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); background: var(--accent-ink); }
.info-box { padding: 14px 16px; border-radius: 14px; background: rgba(47,227,160,.07); border: 1px solid rgba(47,227,160,.3); font-size: 13px; line-height: 1.6; color: #cfeee0; margin: 6px 0 4px; }
.info-box b { color: var(--accent-2); }
.info-box ul { margin: 6px 0 0; padding-left: 18px; }
.radio-list { display: grid; gap: 8px; margin-top: 8px; }
.radio-list label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.radio-list label:has(input:checked) { border-color: var(--accent); background: rgba(184,255,60,.06); }
.radio-list input { accent-color: var(--accent); margin-top: 3px; }
.radio-list small { display: block; color: var(--muted); font-size: 12px; }
textarea.lineup { width: 100%; min-height: 280px; padding: 12px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); color: var(--text);
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ---------------- Toasts ---------------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(480px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 11px 16px; border-radius: 12px; background: #0f2a1b; border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgba(0,0,0,.5); font-size: 14px;
  animation: toastIn .2s ease-out; max-width: 100%; }
.toast.good { border-color: rgba(184,255,60,.5); }
.toast.warn { border-color: rgba(255,215,94,.6); }
.toast b { color: var(--accent); }
.toast.warn b { color: var(--gold); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) } }

/* ---------------- Responsive ---------------- */
@media (max-width: 920px) {
  .builder { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .results { max-height: 60vh; }
  .mtabs.seg { display: flex; position: sticky; top: 61px; z-index: 20; margin: 0 0 12px; }
  .builder[data-mtab="pitch"] .side { display: none; }
  .builder[data-mtab="add"] .pitch-wrap { display: none; }
  .team-title h2 { font-size: 30px; }
  .tower { width: 70px; height: 32px; }
}
@media (max-width: 520px) {
  .head-actions .btn .lbl { display: none; }
  .slot { width: 19%; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .team-card .card-actions { opacity: 1; }
}

/* ================================================================
   FC-style player cards, photos, ratings, drag & drop
   ================================================================ */
.t-icon   { --c1: #fffbea; --c2: #e8cf86; --c3: #9a7420; --ink: #2b1d00; }
.t-gold   { --c1: #fbe7a1; --c2: #d6a935; --c3: #85600d; --ink: #2b1d00; }
.t-silver { --c1: #f4f6f8; --c2: #b9c2cb; --c3: #66717d; --ink: #18202a; }
.t-bronze { --c1: #f5cfa6; --c2: #bb7d48; --c3: #6a4021; --ink: #2a1608; }
.t-none   { --c1: #dfe7e2; --c2: #93a59a; --c3: #4d5f55; --ink: #111a14; }

/* Photo / initials avatar */
.ph { position: relative; display: grid; place-items: center; overflow: hidden; background: rgba(0,0,0,.18); }
.ph b { font-family: var(--display); font-weight: 400; font-size: 1.1em; opacity: .75; letter-spacing: .5px; }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; }
.ph img:not([src]) { display: none; }
.ph.has b { display: none; }
.ph.sm { width: 38px; height: 38px; border-radius: 50%; font-size: 14px; border: 2px solid rgba(255,255,255,.15); flex: none; }

/* The card */
.fc { position: relative; display: block; width: 100%; max-width: 72px; aspect-ratio: 3 / 4.1; margin: 0 auto; color: var(--ink);
  border-radius: 10px 10px 16px 16px; background: linear-gradient(155deg, var(--c1) 0%, var(--c2) 45%, var(--c3) 100%);
  box-shadow: 0 6px 14px rgba(0,0,0,.45), inset 0 0 0 1.5px rgba(255,255,255,.45); text-align: left; }
.fc::before { content: ""; position: absolute; inset: 3px; border-radius: 8px 8px 13px 13px; border: 1px solid rgba(0,0,0,.12); pointer-events: none; }
.fc.t-icon::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%) -150% 0 / 250% 100% no-repeat; animation: sheen 4s ease-in-out infinite; }
@keyframes sheen { 60%, 100% { background-position: 150% 0; } }
.fc-top { position: absolute; left: 7%; top: 5%; z-index: 2; display: flex; flex-direction: column; align-items: center; line-height: .95; }
.fc-ovr { font-family: var(--display); font-weight: 400; font-size: clamp(15px, 2.4vw, 22px); }
.fc-pos { font-style: normal; font-size: clamp(7px, 1.1vw, 9.5px); font-weight: 800; letter-spacing: .3px; }
.fc-ph { position: absolute; right: 4%; top: 5%; width: 63%; height: 62%; border-radius: 6px; background: rgba(0,0,0,.1); font-size: clamp(12px, 2vw, 18px); color: var(--ink);
  -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.fc-name { position: absolute; left: 4px; right: 4px; bottom: 17%; text-align: center; font-weight: 800; font-size: clamp(8px, 1.25vw, 11px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px; }
.fc-num { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); min-width: 26px; height: 20px; padding: 0 5px; border-radius: 7px;
  display: grid; place-items: center; background: var(--kit); color: var(--kit-text); font-family: var(--display); font-size: 15px; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); border: 1.5px solid rgba(255,255,255,.75); z-index: 3; }
.pitch.cards-mode .slot { width: 16%; }
.slot .fc { pointer-events: none; }
.slot.selected .fc, .card.selected .fc { box-shadow: 0 0 0 3px var(--accent), 0 0 22px rgba(184,255,60,.7); }
.assigning .slot.filled.got .fc-num, .assigning .card.got .fc-num { background: var(--gold); color: #2b1d00; }
.assigning .slot.filled.pending .fc, .assigning .card.pending .fc { animation: wiggle 1.8s ease-in-out infinite; }
.fc-cards { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 14px 8px; }
.card.as-fc { background: none; border: 0; padding: 0 0 10px; min-height: 0; }
.card.as-fc:hover .fc { transform: translateY(-2px); }
.card.as-fc .fc { transition: transform .15s; }
.card.as-fc.bench .fc { filter: saturate(.75) brightness(.92); }

/* Team rating + header tools */
.formation-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill.team-ovr { background: linear-gradient(155deg, var(--c1), var(--c2) 55%, var(--c3)); color: var(--ink); border-color: transparent; font-weight: 700; }
.pill.team-ovr b { color: var(--ink); }

/* Search results with rating + photo */
.r-ovr { flex: none; width: 40px; padding: 4px 0 3px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; line-height: 1;
  background: linear-gradient(155deg, var(--c1), var(--c2) 55%, var(--c3)); color: var(--ink); }
.r-ovr b { font-family: var(--display); font-weight: 400; font-size: 19px; }
.r-ovr i { font-style: normal; font-size: 9px; font-weight: 800; }
.r-photo { flex: none; cursor: zoom-in; }
.result { touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sort-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.filters .sort-toggle button { border: 0; border-radius: 0; padding: 5px 10px; }
.filters .sort-toggle button.on { background: var(--accent); color: var(--accent-ink); }

/* Drag & drop */
[data-drag] { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.slot[data-drag], .card[data-drag] { touch-action: none; cursor: grab; }
.drag-ghost { position: fixed; left: 0; top: 0; width: 76px; z-index: 100; pointer-events: none; filter: drop-shadow(0 18px 24px rgba(0,0,0,.6)); }
.drag-ghost .fc { max-width: 76px; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.drag-src { opacity: .35; }
body.is-dragging .slot:hover { transform: translate(-50%, -50%); }
.drop-over.slot .fc, .drop-over.card .fc { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(255,215,94,.7); }
.drop-over.slot.empty .ring, .drop-over.card.empty { border-color: var(--gold); color: var(--gold); background: rgba(255,215,94,.15); }
.drop-over.slot:not(.empty), .drop-over.card:not(.empty) { transform: translate(-50%, -50%) scale(1.08); }
.drop-over.card:not(.empty) { transform: scale(1.05); }
#pitch.drop-over { box-shadow: 0 25px 60px rgba(0,0,0,.5), inset 0 0 0 3px rgba(255,215,94,.7); }
.cards.drop-over { outline: 2px dashed var(--gold); outline-offset: 4px; border-radius: 12px; }
body.is-dragging .side { outline: 0; }

/* Player details */
.details { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.details-card { flex: none; width: 150px; }
.details-card .fc { max-width: 150px; border-radius: 16px 16px 26px 26px; }
.details-card .fc-ovr { font-size: 46px; }
.details-card .fc-pos { font-size: 16px; }
.details-card .fc-name { font-size: 17px; }
.details-card .fc-ph { font-size: 34px; }
.details-info { flex: 1; min-width: 200px; }
.ovr-meter { display: inline-flex; align-items: center; gap: 12px; padding: 8px 16px 8px 8px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid var(--line); }
.ovr-meter b { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-weight: 400; font-size: 32px;
  background: linear-gradient(155deg, var(--c1), var(--c2) 55%, var(--c3)); color: var(--ink); }
.ovr-meter span { font-weight: 700; }
.mini-seg { margin: 0; flex: none; width: 170px; }
@media (max-width: 520px) {
  .pitch.cards-mode .slot { width: 18.5%; }
  .fc-num { min-width: 22px; height: 17px; font-size: 13px; bottom: -7px; }
}
.hero p.hero-tag { font-family: var(--display); font-size: clamp(22px, 4vw, 30px); letter-spacing: 3px; color: var(--gold); margin: -12px auto 26px; text-shadow: 0 0 24px rgba(255,215,94,.35); }
.linkish { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.credit { font-size: 11px; color: var(--dim); margin: 10px 0 0; line-height: 1.5; }
.home-foot { text-align: center; color: var(--dim); font-size: 12px; margin-top: 30px; }
.credits { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; max-height: 60vh; overflow-y: auto; font-size: 12px; }
.credits div { display: flex; flex-direction: column; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.credits span { color: var(--muted); overflow-wrap: anywhere; }

/* Player profile */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0 0; font-size: 14px; }
.facts dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; padding-top: 2px; }
.facts dd { margin: 0; font-weight: 600; min-width: 0; }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; margin-top: 20px; }
.profile-grid section { min-width: 0; }
.profile-grid .wide { grid-column: 1 / -1; }
.profile-grid h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.profile-grid h4 small { text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 500; margin-left: 6px; }
.pos-list, .num-list, .career { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pos-list li, .num-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.num-list li { align-items: flex-start; }
.num-list .num-chip { min-width: 32px; height: 28px; font-size: 14px; flex: none; }
.num-list li span:last-child { padding-top: 4px; min-width: 0; }
.career { counter-reset: c; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.career li { position: relative; padding: 9px 12px 9px 34px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; font-size: 14px; }
.career li::before { counter-increment: c; content: counter(c); position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.career li span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }

/* Advanced search filters */
.adv-toggle { padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); color: var(--muted); }
.adv-toggle.on, .adv-toggle:hover { border-color: var(--accent); color: var(--accent); }
.adv-toggle b { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin-left: 3px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 10px; }
.adv { margin: 0 0 10px; padding: 12px; border-radius: 14px; background: rgba(0,0,0,.28); border: 1px solid var(--line); }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.fld select, .fld input { width: 100%; min-width: 0; padding: 8px 10px; border-radius: 9px; background: rgba(0,0,0,.35); border: 1px solid var(--line-2); outline: none; font-size: 13px; }
.fld select:focus, .fld input:focus { border-color: var(--accent); }
.fld select option { background: #0b2116; }
.range { display: flex; align-items: center; gap: 6px; }
.range i { color: var(--dim); font-style: normal; }
.range input { flex: 1 1 0; }
.range select { flex: 1.4 1 0; }
.adv-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 11px; color: var(--dim); flex-wrap: wrap; }
.adv-foot .linkish { font-size: 12px; }
@media (max-width: 420px) { .adv-grid { grid-template-columns: 1fr; } }

/* Assign mode: all known numbers taken */
:root { --red: #ff4d5e; }
.assigning .blocked .fc { background: linear-gradient(155deg, #ffb3ba 0%, #e5404f 45%, #7d1420 100%); color: #2a0006;
  box-shadow: 0 0 0 2px var(--red), 0 0 18px rgba(255,77,94,.65), 0 6px 14px rgba(0,0,0,.45); }
.assigning .blocked .fc-num { background: var(--red); color: #fff; border-color: #fff; }
.assigning .slot.blocked .nm, .assigning .card.blocked .nm { background: var(--red); color: #fff; }
.assigning .blocked .shirt .body { fill: var(--red); }
.red-key { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--red); color: #fff; font-weight: 800; font-size: 12px; }

.topbar-right{display:flex;align-items:center;gap:8px}
.fad-back{color:inherit;text-decoration:none;font:600 13px/1 Inter,system-ui,sans-serif;opacity:.85;padding:8px 10px;border-radius:999px;border:1px solid rgba(255,255,255,.25)}.fad-back:hover{opacity:1}
.fad-link{display:inline-block;margin-top:10px;font-weight:600}
