/* ==========================================================================
   League & friends — redesign (phone base · desktop >= 721px). Pairs with js/league-ui.js. Tokens: --m-*.
   Scale: 11 label · 12 meta · 14 body · 16 title · 22 hero name · radii 14/18/24 · touch >= 44px
   ========================================================================== */
.lgx { display: none; }
@media screen {
    html.lgx-on .lgx { display: grid; gap: 14px; min-width: 0; color: var(--m-ink); font-size: 14px; line-height: 1.6; }
    html.lgx-on body #view-gamification > :not(#lgx) { display: none !important; }   /* original markup stays: Gamification keeps writing into it */
    .lgx :is(h2, h3, h4, p, small, b, strong, em) { margin: 0; min-width: 0; }
    .lgx button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .lgx :focus-visible { outline: 2px solid var(--m-accent); outline-offset: 2px; }

    /* hero */
    .lgx-hero { position: relative; overflow: hidden; display: grid; gap: 16px; padding: 18px; border-radius: 26px; color: #fff; isolation: isolate;
        background: linear-gradient(135deg, color-mix(in srgb, var(--m-accent) 62%, #170c3a), color-mix(in srgb, var(--m-accent) 30%, #0a0620)); }
    .lgx-hero::before { content: ''; position: absolute; z-index: -1; width: 280px; height: 280px; inset-inline-end: -90px; top: -120px; border-radius: 50%; background: radial-gradient(closest-side, #ffffff2e, transparent); animation: lgx-float 9s ease-in-out infinite alternate; }
    .lgx-hero::after { content: ''; position: absolute; z-index: -1; width: 200px; height: 200px; inset-inline-start: -70px; bottom: -110px; border-radius: 50%; background: radial-gradient(closest-side, #ffffff1c, transparent); }
    .lgx-hero:empty { display: none; }
    .lgx-hero-top { display: flex; align-items: center; gap: 14px; }
    .lgx-me { width: 64px; height: 64px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #ffffff26; border: 2px solid #ffffff55; font-size: 30px; overflow: hidden; }
    .lgx-me > * { max-width: 100%; max-height: 100%; }
    .lgx-hero-id { display: grid; gap: 2px; min-width: 0; }
    .lgx-hero-id small { font-size: 11.5px; opacity: .8; }
    .lgx-hero-id h2 { font-size: 21px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lgx-lvl { display: inline-flex; align-items: center; gap: 4px; width: fit-content; height: 26px; padding: 0 10px 0 8px; border-radius: 13px; background: #ffffff26; font-size: 12px; font-weight: 700; }
    .lgx-lvl .material-symbols-outlined { font-size: 17px; color: #ffd76e; font-variation-settings: 'FILL' 1; }
    .lgx-xp-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-bottom: 7px; opacity: .92; }
    .lgx-xp-top b { font-weight: 800; color: #ffe39a; }
    .lgx-xp-bar { height: 10px; border-radius: 5px; background: #ffffff2b; overflow: hidden; }
    .lgx-xp-bar i { display: block; height: 100%; width: var(--p); border-radius: 5px; background: linear-gradient(90deg, #ffe39a, #fff); box-shadow: 0 0 14px #ffe39a99; animation: lgx-fill 1.1s var(--m-ease) .15s both; }
    .lgx-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .lgx-stats > div { display: grid; justify-items: center; gap: 0; padding: 10px 4px 9px; border-radius: 16px; background: #ffffff1c; }
    .lgx-stats .material-symbols-outlined { font-size: 20px; color: #ffe39a; margin-bottom: 1px; }
    .lgx-stats strong { font-size: 18px; font-weight: 800; line-height: 1.3; } .lgx-stats small { font-size: 11px; opacity: .8; }

    /* tabs (phone) */
    .lgx-tabs { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; height: 50px; border-radius: 17px; background: var(--m-raised); border: 1px solid var(--m-line); }
    .lgx-tabs[hidden] { display: none; }
    .lgx-tabs > i { position: absolute; inset-block: 4px; inset-inline-start: 4px; width: calc((100% - 8px) / 3); border-radius: 13px; background: var(--m-surface); box-shadow: 0 2px 10px rgba(0, 0, 0, .09); transition: transform .45s var(--m-ease); }
    .lgx-tabs[data-i="1"] > i { transform: translateX(-100%); } .lgx-tabs[data-i="2"] > i { transform: translateX(-200%); }
    html[dir="ltr"] .lgx-tabs[data-i="1"] > i { transform: translateX(100%); } html[dir="ltr"] .lgx-tabs[data-i="2"] > i { transform: translateX(200%); }
    .lgx-tabs button { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 5px; border: 0; background: transparent; color: var(--m-muted); font-size: 13.5px; font-weight: 700; transition: color .25s; }
    .lgx-tabs button[aria-selected="true"] { color: var(--m-ink); }
    .lgx-tabs button .material-symbols-outlined { font-size: 19px; }
    .lgx-tabs b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--m-bad); color: #fff; font-size: 11px; display: grid; place-items: center; }
    .lgx-tabs b[hidden] { display: none; }

    .lgx-grid { display: grid; gap: 14px; min-width: 0; }
    .lgx-grid[hidden] { display: none; }
    .lgx-col { display: grid; gap: 14px; min-width: 0; align-content: start; }
    .lgx-grid[data-tab="league"] [data-pane="friends"], .lgx-grid[data-tab="league"] [data-pane="settings"],
    .lgx-grid[data-tab="friends"] .lgx-prize, .lgx-grid[data-tab="friends"] [data-pane="league"], .lgx-grid[data-tab="friends"] [data-pane="settings"],
    .lgx-grid[data-tab="settings"] .lgx-prize, .lgx-grid[data-tab="settings"] [data-pane="league"], .lgx-grid[data-tab="settings"] [data-pane="friends"] { display: none; }

    .lgx-prize { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 22px; border: 1px solid color-mix(in srgb, var(--m-warn) 35%, var(--m-line)); background: linear-gradient(135deg, color-mix(in srgb, var(--m-warn) 14%, var(--m-surface)), var(--m-surface)); }
    .lgx-prize:empty { display: none; }
    .lgx-prize > .material-symbols-outlined { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--m-warn) 22%, transparent); color: var(--m-warn); font-size: 28px; font-variation-settings: 'FILL' 1; }
    .lgx-prize small { font-size: 11.5px; color: var(--m-warn); font-weight: 700; } .lgx-prize h3 { font-size: 14.5px; font-weight: 800; line-height: 1.6; } .lgx-prize p { font-size: 12px; color: var(--m-muted); }

    .lgx-card { padding: 16px; border-radius: 24px; border: 1px solid var(--m-line); background: var(--m-surface); min-width: 0; animation: lgx-rise .5s var(--m-ease) both; }
    .lgx-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
    .lgx-card h3 { font-size: 16px; font-weight: 800; } .lgx-card > header p { font-size: 12px; color: var(--m-muted); margin-top: 1px; }
    .lgx-pill { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px 0 8px; border-radius: 14px; background: color-mix(in srgb, var(--m-good) 14%, transparent); color: var(--m-good); font-size: 12px; font-weight: 700; flex: none; }
    .lgx-pill .material-symbols-outlined { font-size: 16px; }

    /* podium */
    .lgx-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 8px; margin-bottom: 14px; padding-top: 18px; }
    .lgx-pod { position: relative; display: grid; justify-items: center; gap: 2px; text-align: center; animation: lgx-rise .6s var(--m-ease) both; animation-delay: calc(var(--d) * 120ms + 100ms); }
    .lgx-pod strong { font-size: 13px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lgx-pod small { font-size: 11.5px; color: var(--m-muted); }
    .lgx-pod .lgx-av { width: 52px; height: 52px; font-size: 26px; }
    .lgx-pod.p1 .lgx-av { width: 66px; height: 66px; font-size: 34px; box-shadow: 0 0 0 3px #f4c24e, 0 10px 24px #f4c24e55; }
    .lgx-pod.p2 .lgx-av { box-shadow: 0 0 0 3px #b8c2cf; } .lgx-pod.p3 .lgx-av { box-shadow: 0 0 0 3px #d79a68; }
    .lgx-crown { position: absolute; top: -26px; color: #f4c24e; animation: lgx-bob 2.4s ease-in-out infinite; }
    .lgx-crown .material-symbols-outlined { font-size: 28px; font-variation-settings: 'FILL' 1; }
    .lgx-step { width: 100%; margin-top: 8px; display: grid; place-items: start center; padding-top: 8px; border-radius: 14px 14px 4px 4px; font-size: 20px; font-weight: 800; color: #fff; }
    .lgx-pod.p1 .lgx-step { height: 78px; background: linear-gradient(180deg, #f4c24e, #d99a1d); }
    .lgx-pod.p2 .lgx-step { height: 58px; background: linear-gradient(180deg, #c3ccd8, #94a1b2); }
    .lgx-pod.p3 .lgx-step { height: 44px; background: linear-gradient(180deg, #e0a574, #bd7a46); }
    .lgx-pod.is-me strong { color: var(--m-accent); }
    .lgx-av { display: grid; place-items: center; width: 44px; height: 44px; flex: none; overflow: hidden; border-radius: 50%; background: color-mix(in srgb, var(--m-accent) 14%, var(--m-raised)); font-size: 22px; cursor: pointer; }
    .lgx-av > :is(img, svg) { display: block; width: 100%; height: 100%; object-fit: cover; }
    .lgx-retry { min-height: 44px; padding: 8px 18px; border: 0; border-radius: 12px; background: var(--m-accent); color: var(--m-on-accent); font-weight: 700; }

    /* rows */
    .lgx-board-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 2px 6px !important; color: var(--m-ink); font-size: 14px; font-weight: 800; }
    .lgx-board-heading small { color: var(--m-muted); font-size: 11px; font-weight: 600; }
    .lgx-rows { display: grid; gap: 6px; }
    .lgx-row { display: grid; grid-template-columns: 30px auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; border: 1px solid transparent; animation: lgx-rise .45s var(--m-ease) both; animation-delay: calc(var(--i) * 45ms + 350ms); transition: background .2s; }
    .lgx-row:hover { background: color-mix(in srgb, var(--m-ink) 4%, transparent); }
    .lgx-row.is-me { background: color-mix(in srgb, var(--m-accent) 11%, transparent); border-color: color-mix(in srgb, var(--m-accent) 40%, transparent); }
    .lgx-rank { font-size: 15px; font-weight: 800; color: var(--m-muted); text-align: center; }
    .lgx-who { display: grid; gap: 2px; min-width: 0; }
    .lgx-who strong { display: flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 700; }
    .lgx-who strong em { font-style: normal; font-size: 10.5px; font-weight: 800; padding: 1px 8px; border-radius: 9px; background: var(--m-accent); color: var(--m-on-accent); }
    .lgx-who strong em.f { background: color-mix(in srgb, var(--m-good) 18%, transparent); color: var(--m-good); }
    .lgx-who small { font-size: 11.5px; color: var(--m-muted); }
    .lgx-meter { display: block; height: 5px; margin-top: 3px; border-radius: 3px; background: color-mix(in srgb, var(--m-ink) 8%, transparent); overflow: hidden; }
    .lgx-meter u { display: block; height: 100%; border-radius: 3px; background: var(--m-accent); text-decoration: none; transition: width .8s var(--m-ease); }
    .lgx-pts { display: grid; justify-items: end; line-height: 1.3; } .lgx-pts b { font-size: 16px; font-weight: 800; } .lgx-pts small { font-size: 10.5px; color: var(--m-muted); }

    /* friends */
    .lgx-add { display: flex; gap: 8px; margin-bottom: 12px; }
    .lgx-add input { flex: 1; min-width: 0; height: 50px; padding: 0 14px; border-radius: 16px; border: 1.5px solid var(--m-line); background: color-mix(in srgb, var(--m-ink) 4%, transparent); color: var(--m-ink); font: inherit; font-size: 14.5px; direction: ltr; text-align: start; transition: border-color .2s, box-shadow .2s; }
    .lgx-add input::placeholder { direction: rtl; }
    .lgx-add input:focus { outline: 0; border-color: var(--m-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--m-accent) 17%, transparent); }
    .lgx-add button { display: inline-flex; align-items: center; gap: 6px; height: 50px; padding: 0 16px; border: 0; border-radius: 16px; background: var(--m-accent); color: var(--m-on-accent); font-size: 14px; font-weight: 800; transition: transform .2s var(--m-ease); }
    .lgx-add button:active { transform: scale(.94); } .lgx-add .material-symbols-outlined { font-size: 21px; }
    .lgx-reqs { display: grid; gap: 8px; margin-bottom: 14px; padding: 12px; border-radius: 18px; background: color-mix(in srgb, var(--m-warn) 10%, transparent); }
    .lgx-reqs h4 { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: var(--m-warn); } .lgx-reqs h4 .material-symbols-outlined { font-size: 19px; }
    .lgx-friends { display: grid; gap: 8px; }
    .lgx-person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; background: color-mix(in srgb, var(--m-ink) 4%, transparent); animation: lgx-rise .45s var(--m-ease) both; }
    .lgx-person > div { display: grid; min-width: 0; line-height: 1.5; } .lgx-person strong { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lgx-person small { font-size: 12px; color: var(--m-muted); direction: ltr; text-align: start; } .lgx-person em { font-style: normal; font-size: 12px; color: var(--m-accent); font-weight: 700; }
    .lgx-av2 { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: color-mix(in srgb, var(--m-accent) 14%, var(--m-raised)); font-size: 24px; cursor: pointer; }
    .lgx-av2 > * { max-width: 100%; max-height: 100%; }
    .lgx-acts { display: flex; gap: 6px; } .lgx-acts button { height: 38px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--m-line); background: transparent; color: var(--m-ink); font-size: 13px; font-weight: 700; }
    .lgx-acts .ok { background: var(--m-good); border-color: transparent; color: #fff; }
    .lgx-rm { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--m-muted); transition: background .2s, color .2s, width .25s; }
    .lgx-rm:hover { color: var(--m-bad); background: color-mix(in srgb, var(--m-bad) 12%, transparent); }
    .lgx-rm.armed { background: var(--m-bad); color: #fff; animation: lgx-pop .3s var(--m-ease); }

    /* settings */
    .lgx-switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--m-line); cursor: pointer; }
    .lgx-switch span { display: grid; gap: 1px; } .lgx-switch strong { font-size: 14.5px; font-weight: 700; } .lgx-switch small { font-size: 12px; color: var(--m-muted); }
    .lgx-switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
    .lgx-switch i { position: relative; flex: none; width: 52px; height: 30px; border-radius: 15px; background: color-mix(in srgb, var(--m-ink) 18%, transparent); transition: background .3s; }
    .lgx-switch i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px #0003; transition: transform .35s cubic-bezier(.3, 1.5, .5, 1); }
    .lgx-switch input:checked ~ i { background: var(--m-good); } .lgx-switch input:checked ~ i::after { transform: translateX(-22px); }
    html[dir="ltr"] .lgx-switch input:checked ~ i::after { transform: translateX(22px); }
    .lgx-switch input:focus-visible ~ i { outline: 2px solid var(--m-accent); outline-offset: 3px; }
    .lgx-field { display: grid; gap: 6px; margin-top: 14px; } .lgx-field > span { font-size: 12.5px; font-weight: 700; color: var(--m-muted); }
    .lgx-field textarea { width: 100%; box-sizing: border-box; min-height: 74px; padding: 12px 14px; resize: none; border-radius: 16px; border: 1.5px solid var(--m-line); background: color-mix(in srgb, var(--m-ink) 4%, transparent); color: var(--m-ink); font: inherit; font-size: 14.5px; line-height: 1.8; transition: border-color .2s, box-shadow .2s; }
    .lgx-field textarea:focus { outline: 0; border-color: var(--m-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--m-accent) 17%, transparent); }
    .lgx-field small { font-size: 11.5px; color: var(--m-muted); justify-self: end; }
    .lgx-save { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; margin-top: 14px; border: 0; border-radius: 17px; background: var(--m-accent); color: var(--m-on-accent); font-size: 15px; font-weight: 800; box-shadow: 0 10px 22px color-mix(in srgb, var(--m-accent) 30%, transparent); transition: transform .2s var(--m-ease); }
    .lgx-save:active { transform: scale(.97); }

    .lgx-empty { display: grid; justify-items: center; gap: 6px; padding: 26px 14px; text-align: center; border: 1.5px dashed var(--m-line); border-radius: 18px; color: var(--m-muted); font-size: 13px; }
    .lgx-empty.wide { padding: 48px 20px; } .lgx-empty > .material-symbols-outlined { font-size: 38px; color: var(--m-accent); }
    .lgx-skel { display: grid; gap: 8px; } .lgx-skel i { display: block; height: 58px; border-radius: 16px; background: linear-gradient(90deg, color-mix(in srgb, var(--m-ink) 5%, transparent), color-mix(in srgb, var(--m-ink) 10%, transparent), color-mix(in srgb, var(--m-ink) 5%, transparent)); background-size: 200% 100%; animation: lgx-shimmer 1.3s linear infinite; }

    @keyframes lgx-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
    @keyframes lgx-fill { from { width: 0; } }
    @keyframes lgx-float { to { transform: translate(-30px, 24px) scale(1.1); } }
    @keyframes lgx-bob { 50% { transform: translateY(-4px) rotate(4deg); } }
    @keyframes lgx-pop { 50% { transform: scale(1.18); } }
    @keyframes lgx-shimmer { to { background-position: -200% 0; } }
}
@media print { .lgx { display: none !important; } }

/* ---------- Desktop / tablet: no tabs, two columns ---------- */
@media screen and (min-width: 721px) {
    html.lgx-on .lgx { max-width: 1180px; margin-inline: auto; gap: 20px; font-size: 15px; }
    .lgx-hero { grid-template-columns: auto minmax(220px, 1fr) auto; align-items: center; gap: 28px; padding: 26px 30px; }
    .lgx-hero-top { gap: 18px; } .lgx-me { width: 84px; height: 84px; font-size: 40px; } .lgx-hero-id h2 { font-size: 26px; }
    .lgx-stats { min-width: 340px; gap: 10px; } .lgx-stats strong { font-size: 22px; }
    .lgx-tabs { display: none; }
    .lgx-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }
    .lgx-grid[data-tab] [data-pane], .lgx-grid[data-tab] .lgx-prize { display: block !important; }
    .lgx-grid[data-tab] .lgx-prize { display: flex !important; } .lgx-grid[data-tab] .lgx-prize:empty { display: none !important; }
    .lgx-col { gap: 20px; }
    .lgx-card { padding: 22px; } .lgx-card h3 { font-size: 17px; }
    .lgx-podium { gap: 14px; padding-top: 26px; margin-bottom: 20px; } .lgx-pod .lgx-av { width: 62px; height: 62px; font-size: 30px; } .lgx-pod.p1 .lgx-av { width: 80px; height: 80px; font-size: 40px; }
    .lgx-pod strong { font-size: 14.5px; } .lgx-pod.p1 .lgx-step { height: 96px; } .lgx-pod.p2 .lgx-step { height: 72px; } .lgx-pod.p3 .lgx-step { height: 54px; }
    .lgx-row { padding: 12px 16px; }
}
@media screen and (min-width: 721px) and (max-width: 1000px) {
    .lgx-hero { grid-template-columns: 1fr; } .lgx-stats { min-width: 0; } .lgx-grid { grid-template-columns: minmax(0, 1fr); }
}
@media screen and (hover: hover) {
    .lgx-acts button:hover { border-color: var(--m-accent); } .lgx-add button:hover, .lgx-save:hover { filter: brightness(1.07); }
    .lgx-pod:hover .lgx-av { transform: translateY(-3px) scale(1.04); } .lgx-pod .lgx-av { transition: transform .3s var(--m-ease); }
}
@media (prefers-reduced-motion: reduce) { .lgx *, .lgx *::before, .lgx *::after { animation: none !important; transition-duration: .01ms !important; } }
