/* Friend challenges (challenges-ui.js). You are the accent colour, the
   other side is blue. Dark variants only under [data-theme="dark"]. */
:root { --ch-them: #60a5fa; --ch-them-rgb: 96, 165, 250; }

.ch-sec { display: flex; align-items: baseline; justify-content: space-between; }
.ch-sec .link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
#communityRoot .ch-sec .link svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.ch-cards { display: grid; gap: 10px; }
@media (min-width: 760px) { .ch-cards { grid-template-columns: 1fr 1fr; } }

/* ---------- card ---------- */
.ch-card { position: relative; background: var(--panel); border-radius: 20px; padding: 14px 14px 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(var(--n-ink-rgb), .04), 0 8px 24px rgba(var(--n-ink-rgb), .07); transition: transform .15s ease, box-shadow .15s ease; }
.ch-card:active { transform: scale(.985); }
.ch-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ch-card.is-invite { box-shadow: 0 0 0 1.5px rgba(var(--acc-500-rgb), .45), 0 10px 26px -12px rgba(var(--acc-500-rgb), .45); }
.ch-card.is-won::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 100% 0%, rgba(250, 204, 21, .16), transparent 60%); }
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; }
.ch-kick { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--acc-600); }
#communityRoot .ch-kick svg, .ch-kick svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ch-card.is-done .ch-kick { color: #b45309; }
.ch-stake { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--u-tile, var(--n-tile)); padding: 3px 8px; border-radius: 999px; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin-top: 4px; line-height: 1.25; }
.ch-name span { font-weight: 500; color: var(--muted); }
.ch-rules { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.45; }
.ch-btns { display: flex; gap: 8px; margin-top: 12px; }
.ch-btns .btn { flex: 1; justify-content: center; display: inline-flex; align-items: center; gap: 6px; }
#communityRoot .ch-btns svg, .ch-btns svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.ch-foot { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 8px; }

/* face-off: you on the left, them on the right */
.ch-face { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 12px; }
.ch-side { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; min-width: 0; }
.ch-side .ch-av { grid-row: span 2; width: 34px; height: 34px; font-size: 11.5px; }
.ch-side.b { grid-template-columns: 1fr auto; text-align: right; }
.ch-side.b .ch-av { grid-column: 2; grid-row: 1 / span 2; }
.ch-side.b .ch-who, .ch-side.b .ch-num, .ch-side.b small { grid-column: 1; }
.ch-who { font-size: 12px; font-weight: 600; color: var(--muted); grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-num { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; grid-column: 2; }
.ch-num em { font-style: normal; font-size: .5em; font-weight: 600; margin-left: 2px; color: var(--muted); letter-spacing: 0; }
.ch-face.is-dark .ch-num em { color: #a7acb4; }
.ch-side small { display: none; }
.ch-face.is-dark .ch-side .ch-av { grid-row: 1 / span 3; }
.ch-side.is-lead .ch-num { color: var(--acc-600); }
.ch-side.b.is-lead .ch-num { color: #2563eb; }
.ch-vs { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--u-tile, var(--n-tile)); border-radius: 999px; padding: 4px 7px; }
.ch-split { display: flex; gap: 3px; height: 7px; margin-top: 10px; border-radius: 999px; overflow: hidden; }
.ch-split i { display: block; height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.ch-split .a { background: linear-gradient(90deg, var(--acc-500), var(--acc-400)); }
.ch-split .b { background: linear-gradient(90deg, #93c5fd, var(--ch-them)); }

/* three or more players */
.ch-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ch-lrow { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 12px; }
.ch-lrow.is-me { background: rgba(var(--acc-500-rgb), .08); }
.ch-lrow .ch-av { width: 28px; height: 28px; font-size: 10.5px; }
.ch-rank { width: 14px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.ch-lmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ch-lname { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.ch-lname b { font-variant-numeric: tabular-nums; }
.ch-bar { height: 5px; border-radius: 999px; background: var(--u-tile, var(--n-tile)); overflow: hidden; }
.ch-bar i { display: block; height: 100%; border-radius: inherit; background: var(--ch-them); }
.ch-lrow.is-me .ch-bar i { background: var(--acc-500); }
.ch-pend { font-size: 12px; color: var(--muted); margin: 2px 8px 0; }

/* empty */
.ch-empty { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border-radius: 20px; padding: 14px;
  box-shadow: 0 1px 2px rgba(var(--n-ink-rgb), .04), 0 8px 24px rgba(var(--n-ink-rgb), .07); }
.ch-empty b { font-size: 14.5px; }
.ch-empty p { margin: 3px 0 0; line-height: 1.45; }
.ch-empty-ico, .ch-sum-ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(var(--acc-500-rgb), .12); color: var(--acc-600); }
#communityRoot .ch-empty-ico svg, .ch-empty-ico svg, .ch-sum-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Home: inside the Friends card ---------- */
.ch-home { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ch-hrow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 14px; background: var(--u-tile, var(--n-tile)); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ch-hico { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: rgba(var(--ch-them-rgb), .14); color: #2563eb; }
.ch-hico.is-new { background: rgba(var(--acc-500-rgb), .16); color: var(--acc-600); }
.ch-hico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ch-hmain { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-hmain b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-hmain small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-hval { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Friends tab: Challenge button on a friend's card */
.cm-chbtn { display: inline-flex; align-items: center; gap: 4px; background: rgba(var(--acc-500-rgb), .12); color: var(--acc-700); border: 0; }
#communityRoot .cm-chbtn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }

/* ---------- detail sheet ---------- */
.ch-hero { background: var(--tile-dark, var(--n-hero)); color: #fff; border-radius: 22px; padding: 16px; margin-top: 12px;
  box-shadow: 0 16px 32px -16px rgba(var(--n-ink-rgb), .7); }
.ch-hero-k { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--acc-400); }
.ch-hero-t { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 0; }
.ch-face.is-dark .ch-who { color: #a7acb4; }
.ch-face.is-dark .ch-num { font-size: 28px; }
.ch-face.is-dark .ch-side small { display: block; font-size: 11px; color: #a7acb4; grid-column: 2; }
.ch-face.is-dark .ch-side.b small { grid-column: 1; }
.ch-face.is-dark .ch-side.is-lead .ch-num { color: var(--acc-400); text-shadow: 0 0 18px rgba(var(--acc-400-rgb), .45); }
.ch-face.is-dark .ch-side.b.is-lead .ch-num { color: #93c5fd; text-shadow: 0 0 18px rgba(147, 197, 253, .45); }
.ch-face.is-dark .ch-vs { background: rgba(255, 255, 255, .08); color: #c9ccd1; }
.ch-face.is-dark .ch-av { box-shadow: 0 0 0 2px rgba(255, 255, 255, .12); }
.ch-hero .ch-split { background: rgba(255, 255, 255, .06); }
.ch-hero .ch-list .ch-lrow.is-me { background: rgba(255, 255, 255, .07); }
.ch-hero .ch-bar { background: rgba(255, 255, 255, .1); }
.ch-hero .ch-rank, .ch-hero .ch-pend { color: #a7acb4; }
.ch-goal { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.ch-goal-row { display: grid; grid-template-columns: 52px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; color: #c9ccd1; }
.ch-goal-row b { text-align: right; color: #fff; font-variant-numeric: tabular-nums; }
.ch-goal-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.ch-goal-bar i { display: block; height: 100%; border-radius: inherit; background: var(--acc-400); }
.ch-goal small { font-size: 11px; color: #a7acb4; }
.ch-hero-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, .07); font-size: 13px; font-weight: 600; }
.ch-hero-foot svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--acc-400); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ch-note { margin: 8px 2px 0; line-height: 1.45; }
.ch-off { font-family: inherit; display: flex; justify-content: center; width: 100%; margin-top: 4px; padding: 11px 16px; border: 0; border-radius: 999px; background: rgba(220, 38, 38, .08); color: #dc2626; font-size: 14px; font-weight: 600; }
.ch-off:hover { background: rgba(220, 38, 38, .14); }
:root[data-theme="dark"] .ch-off { background: rgba(248, 113, 113, .12); color: #f87171; }

/* day-by-day grid */
.ch-grid { padding: 10px 12px; overflow-x: auto; }
.ch-grow { display: grid; grid-template-columns: 54px repeat(var(--n), minmax(14px, 1fr)); gap: 4px; align-items: center; padding: 3px 0; }
.ch-ghead span { font-size: 10px; font-weight: 600; color: var(--muted); text-align: center; }
.ch-gname { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-grow i { display: block; justify-self: center; width: 100%; max-width: 24px; aspect-ratio: 1; border-radius: 6px; background: rgba(var(--acc-500-rgb), var(--a, 0)); box-shadow: inset 0 0 0 1px rgba(var(--n-ink-rgb), .06); }
.ch-grow i.hit { background: var(--acc-500); box-shadow: 0 0 8px rgba(var(--acc-500-rgb), .45); }
.ch-grow i.part { background: rgba(var(--acc-500-rgb), .22); }

/* ---------- new challenge ---------- */
.ch-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.ch-form .fd-chips { margin: 0; }
.ch-chipav { width: 22px; height: 22px; font-size: 9px; margin-left: -8px; }
.ch-seg button:disabled { opacity: .4; cursor: not-allowed; }
.ch-tgt { display: flex; align-items: center; gap: 8px; }
.ch-tgt input { flex: 1; }
.ch-tgt em { font-style: normal; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ch-sum { display: flex; gap: 12px; align-items: center; background: var(--tile-dark, var(--n-hero)); color: #fff; border-radius: 18px; padding: 14px; box-shadow: 0 16px 32px -16px rgba(var(--n-ink-rgb), .7); }
.ch-sum-ico { background: rgba(var(--acc-400-rgb), .16); color: var(--acc-400); }
.ch-sum div { display: flex; flex-direction: column; min-width: 0; }
.ch-sum small { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--acc-400); }
.ch-sum b { font-size: 16px; margin-top: 2px; }
.ch-sum span { font-size: 12px; color: #c9ccd1; }
.ch-sheet .qs-actions .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- dark ---------- */
:root[data-theme="dark"] .ch-card, :root[data-theme="dark"] .ch-empty { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05); }
:root[data-theme="dark"] .ch-kick { color: var(--acc-400); }
:root[data-theme="dark"] .ch-side.is-lead .ch-num { color: var(--acc-400); }
:root[data-theme="dark"] .ch-side.b.is-lead .ch-num, :root[data-theme="dark"] .ch-hico { color: #93c5fd; }
:root[data-theme="dark"] .ch-hero, :root[data-theme="dark"] .ch-sum { background: #202328; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05); }
:root[data-theme="dark"] .cm-chbtn { color: var(--acc-300); }
:root[data-theme="dark"] .ch-grow i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
