:root {
  --red: #c8102e;
  --red-dark: #8e0c20;
  --red-deep: #5c0814;
  --gold: #f6eb61;
  --ink: #11161c;
  --ink-soft: #2a323c;
  --paper: #f4f5f7;
  --card: #ffffff;
  --line: #e3e6ea;
  --muted: #6b7480;
  --good: #1a8c4a;
  --warn: #d8920f;
  --bad: #d23b3b;
  --shadow: 0 1px 2px rgba(17, 22, 28, 0.06), 0 8px 24px rgba(17, 22, 28, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

b, strong { font-weight: 700; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, var(--red-deep), var(--red));
  color: #fff;
  box-shadow: 0 6px 20px rgba(92, 8, 20, 0.35);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.crest {
  font-family: "Archivo", sans-serif;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.5px;
  background: var(--gold);
  color: var(--red-deep);
  padding: 8px 9px;
  border-radius: 9px;
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: "Archivo", sans-serif; font-size: 17px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11.5px; opacity: 0.78; text-transform: uppercase; letter-spacing: 1.2px; }

.meters { display: flex; gap: 8px; flex-wrap: wrap; }
.meter {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  padding: 7px 12px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  transition: background 0.2s, border-color 0.2s;
}
.meter-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px; opacity: 0.82; }
.meter-value { font-family: "Archivo", sans-serif; font-weight: 800; font-size: 18px; }
.meter.over { background: rgba(255, 220, 220, 0.95); color: var(--bad); border-color: #fff; }
.meter.tight { background: rgba(246, 235, 97, 0.92); color: var(--red-deep); border-color: var(--gold); }

.status-strip { font-size: 13px; text-align: center; padding: 0; max-height: 0; overflow: hidden; transition: all 0.25s; }
.status-strip.show { padding: 7px 16px; max-height: 80px; }
.status-strip.ok { background: var(--good); color: #fff; }
.status-strip.err { background: #3a0a12; color: var(--gold); }

.btn {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 15px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, opacity 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red-dark); }
.btn.primary:hover { background: var(--red-dark); }
.btn.ghost { background: rgba(255,255,255,0.14); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn.ghost:hover { background: rgba(255,255,255,0.24); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

/* ---------------- Tabs ---------------- */
.tabs {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  padding: 0 20px;
  max-width: 1080px;
  margin: 0 auto;
}
.tab {
  border: none;
  background: none;
  font-family: "Archivo", sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--muted);
  padding: 14px 14px 12px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ---------------- Layout ---------------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px; }
.view { animation: fade 0.2s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.briefing {
  position: relative;
  background: linear-gradient(135deg, #fff, #fff6f7);
  border: 1px solid var(--line);
  border-left: 5px solid var(--red);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.briefing h1 { font-family: "Archivo", sans-serif; font-size: 24px; margin: 0 0 8px; letter-spacing: -0.3px; }
.briefing p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.55; max-width: 70ch; }
.briefing .fine { font-size: 13px; color: var(--ink-soft); }
.briefing-close {
  position: absolute; top: 10px; right: 12px;
  border: none; background: none; font-size: 22px; line-height: 1;
  color: var(--muted); cursor: pointer;
}
.lock-inline { color: var(--red-dark); font-weight: 600; }

/* ---------------- Position groups ---------------- */
.posgroup { margin-bottom: 18px; }
.posgroup-head {
  display: flex; align-items: baseline; gap: 10px;
  font-family: "Archivo", sans-serif; font-weight: 800;
  font-size: 13px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--red-dark);
  margin: 0 2px 8px;
}
.posgroup-head .count { color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 12.5px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 10px; }

.pcard {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.08s;
}
.pcard.locked { border-left: 4px solid var(--red); background: #fffdfa; }
.pcard.added  { border-left: 4px solid var(--good); }
.pcard.out    { opacity: 0.5; }

.pavatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Archivo", sans-serif; font-weight: 800; font-size: 13px;
  background: var(--paper); color: var(--ink-soft); border: 1px solid var(--line);
}
.pinfo { min-width: 0; flex: 1 1 auto; }
.pname { font-weight: 700; font-size: 14px; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.pname .lock { font-size: 12px; margin-left: 3px; white-space: nowrap; }
.pmeta { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; min-width: 0; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 6px; border-radius: 999px; white-space: nowrap; flex: none; }
.tag.hgp  { background: #e7f4ec; color: var(--good); }
.tag.nhgp { background: #fdeaea; color: var(--bad); }
.tag.u21  { background: #eef0ff; color: #3a47c4; }
.pfee { font-family: "Archivo", sans-serif; font-weight: 800; font-size: 15px; white-space: nowrap; margin-left: auto; padding-left: 6px; flex: none; }
.paction { flex: none; }
.paction .btn { padding: 7px 12px; font-size: 12.5px; }

/* ---------------- Market controls ---------------- */
.market-controls, .xi-controls { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search, .select {
  font-family: "Inter", sans-serif; font-size: 14px;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: var(--card); color: var(--ink);
}
.search { flex: 1; min-width: 180px; }
.select { cursor: pointer; }
.xi-controls label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

/* ---------------- Pitch / XI ---------------- */
.pitch {
  background:
    repeating-linear-gradient(0deg, #1f7a3a 0 56px, #1c6f35 56px 112px);
  border: 3px solid #fff;
  border-radius: var(--radius);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow);
  position: relative;
}
.pitch::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 90px; height: 90px; border: 2px solid rgba(255,255,255,0.35);
  border-radius: 50%; transform: translate(-50%, -50%);
}
.pitch-line { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
.slot {
  width: 92px; text-align: center; cursor: pointer;
}
.slot-disc {
  width: 52px; height: 52px; margin: 0 auto 5px; border-radius: 50%;
  background: rgba(255,255,255,0.92); border: 2px solid #fff;
  display: grid; place-items: center;
  font-family: "Archivo", sans-serif; font-weight: 800; font-size: 14px; color: var(--red-deep);
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  transition: transform 0.1s;
}
.slot:hover .slot-disc { transform: scale(1.06); }
.slot.empty .slot-disc { background: rgba(255,255,255,0.2); color: rgba(255,255,255,0.8); border-style: dashed; }
.slot-name { color: #fff; font-size: 11.5px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.4); line-height: 1.2; }
.slot-role { color: var(--gold); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }

/* ---------------- Share ---------------- */
.share-card {
  margin-top: 20px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.share-card h3 { font-family: "Archivo", sans-serif; margin: 0 0 4px; font-size: 18px; }
.share-actions { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.share-preview {
  background: var(--ink); color: #d7e0ea; border-radius: 10px; padding: 14px;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; max-height: 280px; overflow: auto;
}
.fine { color: var(--muted); font-size: 13px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 20px 40px; }

/* ---------------- Modal picker ---------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(17,22,28,0.55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--card); border-radius: var(--radius); width: min(420px, 100%);
  max-height: 76vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-family: "Archivo", sans-serif; font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.modal-list { overflow: auto; padding: 8px; }
.modal-opt {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer;
}
.modal-opt:hover { background: var(--paper); }
.modal-opt.clear { color: var(--bad); font-weight: 600; justify-content: center; }

.empty-note { color: var(--muted); font-size: 14px; padding: 8px 2px; }

@media (max-width: 560px) {
  .meters .meter { min-width: 78px; padding: 6px 9px; }
  .meter-value { font-size: 15px; }
  .brand-text span { display: none; }
}
