:root {
  --a: #F4A259; --b: #7BA4F0;
  --ink: #121212; --muted: #5f5f5f; --body: #3f3f3f; --line: #d3d6da; --soft: #f3f3f1;
  --slab: 'Zilla Slab', Georgia, serif;
  --sans: 'Libre Franklin', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
button { font-family: inherit; color: inherit; }
a { color: var(--ink); }
.app { max-width: 440px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
header { position: sticky; top: 0; z-index: 5; background: #fff; height: calc(56px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top) 8px 0; border-bottom: 1px solid var(--line); }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; }
.icon-btn:focus-visible, .btn:focus-visible, .team:focus-visible, .wordmark:focus-visible { outline: 3px solid #2b5fd9; outline-offset: 2px; }
.wordmark { font-family: var(--slab); font-weight: 700; font-size: 30px; letter-spacing: -.01em; border: 0; background: none; cursor: pointer; padding: 0 6px; }
main { flex: 1; display: flex; flex-direction: column; gap: 20px; padding: 24px 20px 28px; }
.foot { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; }
.foot a { color: var(--muted); }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 0; font-family: var(--slab); font-size: 34px; line-height: 1.06; font-weight: 700; }
h2 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lede { margin: 0; font-size: 15px; line-height: 1.45; color: var(--body); }
.center { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.teams { flex: 1; min-height: 420px; display: flex; flex-direction: column; gap: 10px; position: relative; }
.team { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px;
  border: 2px solid var(--ink); border-radius: 14px; cursor: pointer; transition: transform .12s ease; }
.team:active { transform: scale(.985); }
.team[disabled] { opacity: .6; cursor: progress; }
.team .name { font-family: var(--slab); font-size: clamp(36px, 13vw, 60px); font-weight: 700; line-height: 1; text-align: center; overflow-wrap: anywhere; }
.team .sub { font-size: 14px; font-weight: 600; }
.vs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 52px; height: 52px; border-radius: 50%;
  background: #fff; border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center;
  font-family: var(--slab); font-weight: 700; font-size: 20px; pointer-events: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.meta-row { padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--body); }
.num { font-variant-numeric: tabular-nums; }
.bar { position: relative; display: flex; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.bar .fa { background: var(--a); transition: width .6s cubic-bezier(.2,.8,.2,1); display: flex; align-items: center; }
.bar .fb { flex: 1; background: var(--b); display: flex; align-items: center; justify-content: flex-end; }
.bar .mid { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px dashed var(--ink); }
.bar-big { height: 64px; }
.bar-big .pct { font-family: var(--slab); font-size: 26px; font-weight: 700; padding: 0 14px; white-space: nowrap; }
.bar-md { height: 22px; border-radius: 8px; }
.bar-sm { height: 10px; border-width: 1.5px; border-radius: 5px; }
.bar-sm .mid { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 4px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { font-size: 24px; font-weight: 700; }
.stat span { font-size: 12px; color: var(--muted); }
.note { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--soft); border-radius: 12px; }
.note p { margin: 0; }
.btn { min-height: 52px; border-radius: 26px; border: 0; background: var(--ink); color: #fff; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer; width: 100%; text-decoration: none; padding: 0 20px; }
.btn.secondary { background: #fff; color: var(--ink); border: 2px solid var(--ink); }
.hint { margin: 0; text-align: center; font-size: 13px; line-height: 1.4; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.list-row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 56px; align-items: center; gap: 10px; font-size: 14px; padding: 6px 0; }
.list-row .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .v { text-align: right; font-size: 13px; color: var(--body); }
.hist { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.hist:last-child { border-bottom: 1px solid var(--line); }
.hist .names { display: flex; justify-content: space-between; gap: 12px; font-family: var(--slab); font-size: 20px; font-weight: 700; }
.hist .names .lost { color: var(--muted); font-weight: 600; }
.scrim { position: fixed; inset: 0; background: rgba(18,18,18,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; background: #fff; border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.sheet h3 { margin: 0; font-family: var(--slab); font-size: 26px; }
.sharecard { padding: 14px; border-radius: 16px; }
.sharecard .inner { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.sharecard .big { font-family: var(--slab); font-size: 32px; font-weight: 700; line-height: 1; }
.msg { width: 100%; min-height: 76px; resize: none; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: var(--sans); font-size: 15px; line-height: 1.4; color: var(--ink); }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.45; color: var(--body); }
.sponsor { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sponsor b { color: var(--ink); }
.sponsor .tag { border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 24px; font-size: 14px; font-weight: 600; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- you, groups, chain, country map ---------- */
:root { --a1: #FCE1C4; --a2: #F7B877; --a3: #E0802F; --b1: #DCE8FC; --b2: #A9C6F6; --b3: #6A97EA; --none: #E3E3E0; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card-link { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 14px; border: 1.5px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; font-family: var(--sans); color: var(--ink); }
.card-link:hover { background: var(--soft); }
.card-link:focus-visible, .person:focus-visible, .list-row:focus-visible { outline: 3px solid #2b5fd9; outline-offset: 2px; }
.card-link.dashed { border-style: dashed; }
.card-link.wide { width: 100%; }
.lbl { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.card-link strong { font-family: var(--slab); font-size: 21px; line-height: 1.1; overflow-wrap: anywhere; }
.card-link .sub { font-size: 13px; color: var(--body); line-height: 1.35; }
.rec { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rec:last-child { border-bottom: 1px solid var(--line); }
.rec .no { font-size: 12px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 10px; background: var(--soft); color: var(--body); white-space: nowrap; }
.pill.won { background: var(--ink); color: #fff; }
.member { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 16px; }
.member:last-child { border-bottom: 1px solid var(--line); }
.member .mdot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); flex-shrink: 0; }
.member .mname { flex: 1; font-weight: 700; overflow-wrap: anywhere; }
.member .mpick { font-size: 14px; color: var(--body); }
.member.waiting { color: var(--muted); }
.member.waiting .mname { font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1.5px solid var(--ink); border-radius: 22px; padding: 3px; }
.seg button { height: 38px; border: 0; border-radius: 19px; background: transparent; font-size: 14px; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input { height: 48px; border: 1.5px solid var(--ink); border-radius: 12px; padding: 0 14px; font: 500 16px var(--sans); color: var(--ink); background: #fff; width: 100%; }
.err { color: #b3261e; font-size: 14px; margin: 0; }
.link-btn { border: 0; background: none; font: 600 14px var(--sans); text-decoration: underline; cursor: pointer; padding: 10px; color: var(--muted); align-self: center; }
.chainmap { width: 100%; aspect-ratio: 350/230; border-radius: 12px; overflow: hidden; background: #f4f4f1; }
.chainmap svg { display: block; width: 100%; height: 100%; }
.person { cursor: pointer; outline: none; }
.person .dot { transition: opacity .2s; }
#links path, #treeSvg path { transition: opacity .2s, stroke-width .2s; }
.picking [data-id]:not(.onpath) { opacity: .15; }
#chainSvg .onpath { opacity: 1 !important; }
#chainSvg path.onpath { stroke-width: 2.5px; vector-effect: non-scaling-stroke; }
#treeSvg path.onpath { stroke: #121212; stroke-width: 2.5; }
.person.sel .dot { stroke-width: 3px; vector-effect: non-scaling-stroke; }
.ldot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--ink); display: inline-block; }
.story { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.story:last-child { border-bottom: 1px solid var(--line); }
.story .txt { font-family: var(--slab); font-size: 19px; font-weight: 700; line-height: 1.2; }
.legend { display: grid; grid-template-columns: 64px repeat(3, minmax(0, 1fr)); gap: 4px 6px; align-items: center; font-size: 12px; }
.legend span.c { color: var(--muted); text-align: center; }
.legend i { height: 12px; border-radius: 3px; display: block; }
.legend strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mapwrap { position: relative; width: 100%; aspect-ratio: 350/230; border-radius: 12px; overflow: hidden; background: #f4f4f1; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.mapwrap.dragging { cursor: grabbing; }
.mapwrap svg { display: block; width: 100%; height: 100%; }
#mapg { transform-origin: 0 0; }
#mapg.anim { transition: transform .45s cubic-bezier(.2,.8,.2,1); }
#mapg path { stroke: #fff; stroke-width: .6; vector-effect: non-scaling-stroke; stroke-linejoin: round; cursor: pointer; }
#mapg path.sel { stroke: var(--ink); stroke-width: 2; }
.zoom { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.zoom button { width: 40px; height: 40px; border: 0; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.zoom button + button { border-top: 1px solid var(--line); }
.search { position: relative; }
.search label { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border: 1.5px solid var(--ink); border-radius: 23px; }
.search input { flex: 1; border: 0; outline: none; font-family: var(--sans); font-size: 16px; background: transparent; color: var(--ink); min-width: 0; }
.results { position: absolute; left: 0; right: 0; top: 50px; z-index: 4; margin: 0; padding: 6px; list-style: none; background: #fff; border: 1.5px solid var(--ink); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.results button { width: 100%; text-align: left; padding: 11px 12px; border: 0; background: none; border-radius: 8px; font-size: 15px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.results button:hover, .results button:focus-visible { background: var(--soft); outline: none; }
button.list-row { border: 0; background: none; width: 100%; text-align: left; cursor: pointer; font-family: var(--sans); color: var(--ink); }
.panel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 4px; border-top: 1px solid var(--line); }
.panel-grid div { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; }
.panel-grid div + div { padding-left: 10px; border-left: 1px solid var(--line); }
.panel-grid b { font-size: 18px; }
.panel-grid span { font-size: 12px; color: var(--muted); line-height: 1.3; }
