    :root{
      --slate:#2F4F4F; --slate-d:#243c3c; --ink:#14213d;
      --line:#e3e3e0; --muted:#6b7280; --bg:#f6f5f2; --card:#ffffff;
      --bad:#b3261e; --good:#0F6E56;
      --nav-h:58px;   /* bottom nav bar height, excluding the safe-area inset */
    }
    *{box-sizing:border-box}
    html,body{margin:0;height:100%}

    /* ---------- auth / gate screens (Phase 3 shell) ---------- */
    body{
      font-family:Arial,Helvetica,sans-serif; background:var(--bg); color:var(--ink);
    }
    body.gate{ display:flex; align-items:center; justify-content:center; padding:20px; }
    body.app{ padding:0; }

    .card{
      background:var(--card); width:100%; max-width:380px; border-radius:12px;
      box-shadow:0 4px 24px rgba(0,0,0,.10); overflow:hidden;
    }
    .ramp{height:6px; display:flex}
    .ramp i{flex:1}
    .ramp i:nth-child(1){background:#f8696b}
    .ramp i:nth-child(2){background:#fbb46e}
    .ramp i:nth-child(3){background:#ffeb84}
    .ramp i:nth-child(4){background:#b1d67f}
    .ramp i:nth-child(5){background:#63be7b}
    .inner{padding:24px}
    h1{margin:0 0 2px; font-size:22px; letter-spacing:.01em}
    .tag{margin:0 0 20px; color:var(--muted); font-size:13px}
    .inner h2{margin:0 0 4px; font-size:17px}
    p.lede{margin:0 0 18px; color:var(--muted); font-size:13px; line-height:1.5}
    .inner label{display:block; font-size:12px; color:#444; margin:0 0 5px}
    .inner input[type=text],.inner input[type=email]{
      width:100%; padding:11px 12px; font-size:15px; border:1px solid #ccc;
      border-radius:7px; font-family:inherit;
    }
    .inner input:focus-visible{outline:2px solid var(--slate); outline-offset:1px; border-color:var(--slate)}
    .inner button{
      font-family:inherit; font-size:15px; cursor:pointer; border-radius:7px;
      padding:11px 14px; border:0; width:100%;
    }
    .primary{background:var(--slate); color:#fff; font-weight:bold; margin-top:14px}
    .primary:hover{background:var(--slate-d)}
    .primary:disabled{background:#9aa5a5; cursor:default}
    .ghost{background:#fff; border:1px solid #ccc; color:var(--ink); margin-top:10px}
    .ghost:hover{background:#f3f3f1}
    .gbtn{background:#fff; border:1px solid #ccc; color:var(--ink); font-weight:bold;
          display:flex; align-items:center; justify-content:center; gap:10px}
    .gbtn:hover{background:#f3f3f1}
    .gbtn:disabled{color:#9aa5a5; cursor:default}
    .row{margin:0 0 12px}
    .msg{font-size:13px; margin-top:14px; min-height:16px; line-height:1.45}
    .msg.bad{color:var(--bad)}
    .msg.good{color:var(--good)}
    .divider{display:flex; align-items:center; gap:10px; color:var(--muted);
             font-size:12px; margin:18px 0 4px}
    .divider::before,.divider::after{content:""; flex:1; height:1px; background:var(--line)}
    .inner select{
      width:100%; padding:10px 11px; font-size:15px; border:1px solid #ccc;
      border-radius:7px; font-family:inherit; background:#fff;
    }
    .who{display:flex; justify-content:space-between; align-items:center;
         font-size:12px; color:var(--muted); margin-bottom:16px}
    .who button{width:auto; padding:6px 10px; font-size:12px}
    .stat{font-variant-numeric:tabular-nums; font-weight:bold; color:var(--ink)}
    .hidden{display:none}
    .spin{color:var(--muted); font-size:13px; text-align:center; padding:10px 0}

    /* ---------- loading splash (animated brand, no live map) ---------- */
    /* subtle static backdrop for depth — cheap, no Maps API on the gate */
    body.gate{ background:radial-gradient(120% 90% at 50% 40%, #ffffff, var(--bg)); }
    /* bigger, centred brand while loading */
    body.is-loading .inner{ text-align:center }
    body.is-loading #gate h1{
      font-size:40px; line-height:1.1; margin:6px 0 14px; letter-spacing:.005em;
    }
    /* the 5-colour ramp becomes a flowing animated loading bar (same colours) */
    body.is-loading .ramp{
      height:8px;
      background:linear-gradient(90deg,
        #f8696b,#fbb46e,#ffeb84,#b1d67f,#63be7b,#b1d67f,#ffeb84,#fbb46e,#f8696b);
      background-size:200% 100%;
      animation:rampSlide 2.2s linear infinite;
    }
    body.is-loading .ramp i{ display:none }
    @keyframes rampSlide{ from{background-position:0 0} to{background-position:-200% 0} }
    @media (prefers-reduced-motion: reduce){
      body.is-loading .ramp{ animation:none }
    }

    /* ---------- map app (ported from page.html) ---------- */
    #app{ position:fixed; inset:0; overflow:hidden; }  /* clips off-screen tab overlays mid-slide */
    #map { height: 100%; width: 100%; }

    /* leaderboard + activity panel — now lives inside the Feed tab (.feed-view) */
    #panel {
      font-size: 13px; color: var(--ink);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      display: flex; flex-direction: column; min-height: 0;
    }
    #panel h1 { margin: 0 0 14px; font-size: 18px; letter-spacing: .01em; }

    .stats { display: flex; gap: 8px; margin: 0 0 12px; }
    .stat-tile { flex: 1; background: var(--bg); border-radius: 10px; padding: 8px 6px; text-align: center; }
    .stat-tile b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; line-height: 1.1; }
    .stat-tile span { display: block; font-size: 10px; text-transform: uppercase;
                      letter-spacing: .05em; color: var(--muted); margin-top: 3px; }

    .scale { display: flex; height: 8px; border-radius: 5px; overflow: hidden; margin: 2px 0 4px; }
    .scale span { flex: 1; }
    .scale-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

    .pin {
      display: flex; align-items: center; justify-content: center;
      width: 34px; height: 34px; border-radius: 50%;
      border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4);
      color: #14213d; font-size: 12px; font-weight: bold;
      font-family: Arial, sans-serif; font-variant-numeric: tabular-nums;
      cursor: pointer;
    }
    /* live "you are here" dot (an AdvancedMarker content element). The marker
       anchors its content's bottom-centre to the coordinate, so translateY(50%)
       drops the dot's own centre onto the point. */
    .me-dot { position: relative; width: 22px; height: 22px; transform: translateY(50%); }
    .me-dot-core, .me-dot-pulse {
      position: absolute; inset: 0; margin: auto;
      width: 16px; height: 16px; border-radius: 50%;
    }
    .me-dot-core {
      background: #1a73e8; border: 2px solid #fff;
      box-shadow: 0 1px 4px rgba(0,0,0,.4);
    }
    .me-dot-pulse { background: rgba(26,115,232,.35); animation: mePulse 2s ease-out infinite; }
    @keyframes mePulse {
      0%   { transform: scale(1); opacity: .7; }
      100% { transform: scale(3); opacity: 0; }
    }

    .iw { font-family: Arial, sans-serif; font-size: 13px; line-height: 1.5; }
    .iw b { font-size: 14px; }
    .iw .sc { font-size: 20px; font-weight: bold; font-variant-numeric: tabular-nums; }
    .iw a { color: #1a73e8; text-decoration: none; }
    .iw .brk {
      margin: 8px 0 6px; padding: 6px 0; border-top: 1px solid #eee;
      border-bottom: 1px solid #eee; display: grid;
      grid-template-columns: 1fr auto; gap: 1px 10px; font-size: 12px;
    }
    .iw .brk span { color: #555; }
    .iw .brk b { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
    .iw .by { color: #777; font-size: 11px; font-style: italic; margin-bottom: 4px; }
    .iw .notes { margin: 6px 0 2px; }
    .iw .note { font-size: 12px; color: #444; line-height: 1.45; margin: 2px 0; }
    .iw .note b { font-size: 12px; color: #222; }
    #form textarea {
      width: 100%; box-sizing: border-box; padding: 10px 11px; font-size: 14px;
      border: 1px solid #ccc; border-radius: 8px; font-family: inherit;
      resize: vertical;
    }
    #form textarea:focus-visible { outline: 2px solid var(--slate); outline-offset: 1px; border-color: var(--slate); }
    .noteCount { font-size: 11px; color: #999; text-align: right; margin-top: 2px; }
    .iw .shots { display: flex; gap: 4px; margin: 6px 0 2px; flex-wrap: wrap; }
    .iw .shots figure { margin: 0; }
    .iw .shots img {
      width: 54px; height: 54px; object-fit: cover; border-radius: 5px;
      cursor: pointer; background: #eee; display: block;
    }
    .iw .shots figcaption { font-size: 9px; color: #888; text-align: center; margin-top: 1px;
      max-width: 54px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* full-image lightbox */
    #lightbox {
      position: fixed; inset: 0; z-index: 30; display: none;
      background: rgba(0,0,0,.82); align-items: center; justify-content: center;
      padding: 20px;
    }
    #lightbox.open { display: flex; }
    #lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
    #err {
      position: absolute; bottom: 12px; left: 12px; z-index: 6;
      background: #fdecea; color: #611a15; border-radius: 6px;
      padding: 8px 12px; font-size: 13px; display: none; max-width: 320px;
    }

    /* account + groups avatar menu, top-left */
    #userBar {
      position: absolute; top: 12px; left: 12px; z-index: 8;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    #avatarBtn {
      width: 44px; height: 44px; border-radius: 50%; border: 2px solid #fff;
      background: var(--slate); color: #fff; font-weight: bold; font-size: 15px;
      cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.28);
      display: flex; align-items: center; justify-content: center;
      font-family: inherit; font-variant-numeric: tabular-nums; letter-spacing: .02em;
    }
    #avatarBtn:hover { background: var(--slate-d); }
    #userMenu {
      position: absolute; top: 52px; left: 0; width: 250px; max-width: calc(100vw - 24px);
      background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.24);
      padding: 8px; font-size: 13px; color: var(--ink);
    }
    .um-head {
      display: flex; align-items: center; gap: 10px;
      padding: 8px 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
    }
    #avatarLarge {
      width: 38px; height: 38px; border-radius: 50%; background: var(--slate); color: #fff;
      display: flex; align-items: center; justify-content: center; font-weight: bold;
      font-size: 14px; flex: 0 0 auto; font-variant-numeric: tabular-nums;
    }
    .um-id { min-width: 0; }
    .um-name { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .um-sub { color: var(--muted); font-size: 11px; }
    .um-sec { padding: 4px 4px 8px; }
    .um-label {
      display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
      color: var(--muted); font-weight: bold; margin: 0 0 5px;
    }
    #userMenu select#mapGroupSel {
      width: 100%; padding: 9px 10px; font-size: 14px; border: 1px solid #ccc;
      border-radius: 8px; font-family: inherit; background: #fff;
    }
    .um-item {
      display: block; width: 100%; text-align: left; background: none; border: 0;
      border-radius: 8px; padding: 10px; font-size: 14px; font-family: inherit;
      color: var(--ink); cursor: pointer;
    }
    .um-item:hover { background: #f3f3f1; }
    .um-danger { color: var(--bad); }
    #mapCreateBox input {
      width: 100%; box-sizing: border-box; padding: 9px 10px; margin: 6px 0 0;
      font-size: 14px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit;
      transition: border-color .15s ease, box-shadow .15s ease;
    }
    #mapCreateBox input:focus-visible {
      outline: none; border-color: var(--slate); box-shadow: 0 0 0 3px rgba(47,79,79,.15);
    }
    .um-primary {
      width: 100%; margin-top: 8px; padding: 10px; border: 0; border-radius: 8px;
      background: var(--slate); color: #fff; font-weight: bold; font-size: 14px;
      font-family: inherit; cursor: pointer;
    }
    .um-primary:hover { background: var(--slate-d); }
    .um-primary:disabled { background: #9aa5a5; cursor: default; }
    .um-msg { font-size: 12px; min-height: 14px; margin-top: 6px; }
    .um-msg.bad { color: var(--bad); }
    .um-msg.good { color: var(--good); }

    /* add-a-pub */
    #fabs {
      position: absolute; top: 12px; right: 12px; z-index: 5;
      display: flex; flex-direction: row-reverse; align-items: flex-start; gap: 10px;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    #addBtn {
      cursor: pointer; border-radius: 24px; padding: 11px 18px; font-size: 14px;
      font-weight: bold; font-family: inherit; white-space: nowrap;
      background: var(--slate); color: #fff; border: 0;
      box-shadow: 0 4px 14px rgba(0,0,0,.26);
    }
    #addBtn:hover { background: var(--slate-d); }
    /* minimalist XP badge, top-right, tucked under the add-a-pub button */
    #mapXpWrap {
      position: absolute; top: 64px; right: 12px; z-index: 5;
      display: flex; flex-direction: column; align-items: flex-end; gap: 7px;
    }
    #mapXpWrap[hidden] { display: none; }
    #mapXp {
      display: flex; align-items: center; gap: 8px;
      background: #fff; border: 0; border-radius: 20px; padding: 7px 11px 7px 9px;
      box-shadow: 0 3px 12px rgba(0,0,0,.22); cursor: pointer;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    #mapXp:hover { box-shadow: 0 4px 16px rgba(0,0,0,.28); }
    #mapXp[hidden] { display: none; }
    /* your pinned badges, floating just under the XP pill */
    #mapPins {
      display: flex; align-items: center; gap: 5px;
      background: #fff; border-radius: 16px; padding: 5px 8px;
      box-shadow: 0 3px 12px rgba(0,0,0,.22);
    }
    #mapPins[hidden] { display: none; }
    #mapXp .mx-ic { font-size: 16px; line-height: 1; }
    #mapXp .mx-bar {
      width: 46px; height: 5px; border-radius: 999px;
      background: var(--line); overflow: hidden;
    }
    #mapXp .mx-fill {
      display: block; height: 100%; min-width: 2px; width: 0;
      background: linear-gradient(90deg, var(--slate), var(--slate-d));
      transition: width .4s ease;
    }
    #locateBtn {
      position: absolute; bottom: 12px; left: 12px; z-index: 5;
      width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0;
      background: #1a73e8; color: #fff; cursor: pointer;
      box-shadow: 0 4px 14px rgba(0,0,0,.26);
      display: flex; align-items: center; justify-content: center;
    }
    #locateBtn:hover { background: #1666cf; }
    /* tracking: a soft ring pulses out from the bubble */
    #locateBtn.active { box-shadow: 0 0 0 4px rgba(26,115,232,.28), 0 4px 14px rgba(0,0,0,.26); }
    #locateBtn.denied { background: #b00020; }     /* permission off */
    #form {
      position: absolute; top: 12px; right: 12px; z-index: 20; display: none;
      flex-direction: column;
      background: #fff; border-radius: 12px; width: 320px;
      box-shadow: 0 10px 34px rgba(0,0,0,.28); font-size: 13px; color: var(--ink);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      max-height: calc(100vh - 24px);
    }
    #formHead {
      display: flex; align-items: center; justify-content: space-between;
      padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
    }
    #formHead h2 { margin: 0; font-size: 16px; letter-spacing: .01em; }
    #formClose {
      background: none; border: 0; width: auto; padding: 0 2px;
      font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer;
    }
    #formClose:hover { color: var(--ink); }
    #formBody { padding: 16px; overflow-y: auto; flex: 1 1 auto; }

    .fsec { margin: 0 0 18px; }
    .fsec:last-child { margin-bottom: 0; }
    .fsec-title {
      font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
      color: var(--muted); font-weight: bold; margin: 0 0 10px;
    }
    #form label { display: block; margin: 12px 0 5px; color: #444; font-size: 12px; }
    .fsec > label:first-child { margin-top: 0; }
    #form input[type=text] {
      width: 100%; box-sizing: border-box; padding: 10px 11px; font-size: 14px;
      border: 1px solid #ccc; border-radius: 8px; font-family: inherit;
    }
    #form input[type=text]:focus-visible {
      outline: 2px solid var(--slate); outline-offset: 1px; border-color: var(--slate);
    }
    #formWho {
      font-size: 12px; color: #555; margin: 0 0 4px;
      background: #f3f4f2; border-radius: 8px; padding: 8px 10px;
    }
    #formWho b { color: var(--ink); }

    /* score sliders — coloured live-fill + value chip */
    .cat { display: grid; grid-template-columns: 1fr auto; align-items: center;
           gap: 6px 10px; margin: 0 0 16px; }
    .cat:last-child { margin-bottom: 0; }
    .cat .lab { font-size: 13px; color: #333; }
    .cat .v {
      justify-self: end; min-width: 40px; text-align: center;
      font-weight: bold; font-variant-numeric: tabular-nums; font-size: 13px;
      color: var(--ink); background: var(--muted); border-radius: 6px; padding: 2px 6px;
    }
    .cat input[type=range] {
      grid-column: 1 / -1; width: 100%; margin: 3px 0 0;
      -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
      --pct: 60; --cc: var(--muted);
    }
    .cat input[type=range]::-webkit-slider-runnable-track {
      height: 8px; border-radius: 6px;
      background: linear-gradient(to right,
        var(--cc) calc(var(--pct) * 1%), #e3e3e0 calc(var(--pct) * 1%));
    }
    .cat input[type=range]::-webkit-slider-thumb {
      -webkit-appearance: none; appearance: none; margin-top: -7px;
      width: 22px; height: 22px; border-radius: 50%;
      background: #fff; border: 2px solid var(--slate); box-shadow: 0 1px 3px rgba(0,0,0,.3);
    }
    .cat input[type=range]::-moz-range-track { height: 8px; border-radius: 6px; background: #e3e3e0; }
    .cat input[type=range]::-moz-range-progress { height: 8px; border-radius: 6px; background: var(--cc); }
    .cat input[type=range]::-moz-range-thumb {
      width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--slate);
      background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
    }

    #formFoot {
      flex: 0 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
      border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 12px 12px;
    }
    #live { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
    #live span { color: var(--muted); font-size: 12px; }
    #live b { font-size: 22px; font-variant-numeric: tabular-nums; }
    #formBtns { display: flex; gap: 10px; }
    #formBtns button {
      padding: 12px; border-radius: 8px; cursor: pointer;
      font-size: 15px; font-family: inherit; font-weight: bold; border: 0;
    }
    #save { flex: 1; background: var(--slate); color: #fff; }
    #save:hover { background: var(--slate-d); }
    #save:disabled { background: #9aa5a5; cursor: default; }
    #cancel { flex: 0 0 auto; padding: 12px 18px; background: #fff;
              border: 1px solid #ccc; color: var(--ink); font-weight: normal; }
    #cancel:hover { background: #f3f3f1; }
    #formMsg { margin-top: 8px; font-size: 12px; min-height: 15px; text-align: center; }
    #formMsg.bad { color: #b3261e; }
    #formMsg.good { color: #0F6E56; }

    /* panel tabs + swipeable pages (leaderboard / activity) */
    #panelTabs {
      display: flex; gap: 4px; background: var(--bg); border-radius: 10px;
      padding: 3px; margin: 0 0 12px;
    }
    .ptab {
      flex: 1; border: 0; background: none; cursor: pointer;
      padding: 8px 10px; border-radius: 8px; font-family: inherit; font-size: 13px;
      font-weight: bold; color: var(--muted);
    }
    .ptab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

    #panelPages { overflow: hidden; height: 46vh; }
    #panelTrack { display: flex; height: 100%; transition: transform .25s ease; touch-action: pan-y; }
    .panel-page {
      flex: 0 0 100%; width: 100%; height: 100%;
      overflow-y: auto; -webkit-overflow-scrolling: touch;
    }

    /* leaderboard */
    #board { margin-top: 12px; }
    .board-filters { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
    #city, #author, #sortBy {
      width: 100%; padding: 8px 10px; font-size: 13px;
      border: 1px solid #ccc; border-radius: 8px; font-family: inherit; background: #fff;
    }
    #city:focus-visible, #author:focus-visible, #sortBy:focus-visible {
      outline: 2px solid var(--slate); outline-offset: 1px; border-color: var(--slate);
    }

    /* modern select treatment — strip native OS chrome, add a custom caret so every
       dropdown matches the app instead of the operating system. Placed after the
       per-context rules so each select keeps its own size/padding. */
    .inner select, #userMenu select#mapGroupSel, #city, #author, #sortBy {
      -webkit-appearance: none; -moz-appearance: none; appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8 9.5 4.5'/%3E%3C/svg%3E");
      background-repeat: no-repeat; background-position: right 11px center; background-size: 12px;
      padding-right: 32px; border-color: var(--line); cursor: pointer;
      transition: border-color .15s ease, box-shadow .15s ease;
    }
    .inner select:hover, #userMenu select#mapGroupSel:hover,
    #city:hover, #author:hover, #sortBy:hover { border-color: var(--slate); }
    .inner select:focus-visible, #userMenu select#mapGroupSel:focus-visible,
    #city:focus-visible, #author:focus-visible, #sortBy:focus-visible {
      outline: none; border-color: var(--slate); box-shadow: 0 0 0 3px rgba(47,79,79,.15);
    }
    #board table { border-collapse: collapse; width: 100%; font-size: 13px; }
    #board td { padding: 6px 2px; border-bottom: 1px solid #f2f2f0; vertical-align: middle; }
    #board tr { cursor: pointer; }
    #board tr:hover td { background: var(--bg); }
    #board .pos { width: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
    #board .nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #board .sc { text-align: right; font-weight: bold; font-variant-numeric: tabular-nums; width: 38px; }
    #board .dot { width: 14px; }
    #board .dot i { display: block; width: 10px; height: 10px; border-radius: 50%; }
    #board .none { color: var(--muted); font-style: italic; padding: 8px 0; }

    /* recent activity feed — the primary Feed view */
    #activityList { padding: 2px 0; }
    .act {
      display: flex; align-items: flex-start; gap: 11px;
      padding: 12px 2px; border-bottom: 1px solid #f2f2f0; cursor: pointer;
      transition: opacity .15s ease, background .15s ease;
    }
    .act:hover { background: var(--bg); opacity: 1 !important; }   /* aged rows lift back to full on hover */
    .act-badge {
      flex: 0 0 auto; min-width: 38px; height: 38px; padding: 0 6px;
      display: flex; align-items: center; justify-content: center;
      border-radius: 9px; color: #1c2b2b; font-weight: bold; font-size: 15px;
      font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
    }
    .act .body { flex: 1; min-width: 0; }
    .act .top { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
    .act .pub { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .act .area {
      flex: 0 1 auto; color: var(--muted); font-size: 12px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .act .meta { color: var(--muted); font-size: 11px; margin-top: 1px; }
    .act .cats { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 7px; }
    .act .chip {
      display: inline-flex; align-items: baseline; gap: 4px;
      padding: 2px 7px; border-radius: 6px; background: var(--bg);
      font-size: 11px; line-height: 1.4;
    }
    .act .chip em { color: var(--muted); font-style: normal; }
    .act .chip b { font-variant-numeric: tabular-nums; }
    .act .none { color: var(--muted); font-style: italic; padding: 12px 2px; }

    /* mobile */
    @media (max-width: 640px) {
      #fabs {
        top: auto; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); right: 16px;
        flex-direction: column-reverse; align-items: flex-end;
      }
      #addBtn { padding: 13px 20px; font-size: 15px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
      #locateBtn {
        bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); left: 16px;
      }
      /* Add-a-pub moves to the bottom on mobile, so the badge rises to the top,
         mirroring the avatar (#userBar, top:12 left:12) on the right. */
      #mapXpWrap { top: 12px; right: 12px; }

      #form {
        top: 0; left: 0; right: 0; bottom: 0; width: auto;
        border-radius: 0; max-height: none;
      }
      #formHead { padding: calc(14px + env(safe-area-inset-top)) 16px 14px; }
      #formFoot { border-radius: 0; }
      #form input[type=text], #form textarea, #city, #author, #sortBy { font-size: 16px; }
      #form input[type=text] { padding: 12px; }
      .cat { margin: 0 0 22px; }
      .cat input[type=range] { touch-action: none; }
      .cat input[type=range]::-webkit-slider-thumb { width: 30px; height: 30px; margin-top: -11px; }
      .cat input[type=range]::-webkit-slider-runnable-track { height: 8px; }
      .cat input[type=range]::-moz-range-thumb { width: 30px; height: 30px; }
      .pin { width: 40px; height: 40px; font-size: 13px; }
      #board td { padding: 8px 2px; }
      #board .nm { max-width: none; }
      #formBtns button { padding: 12px; font-size: 15px; }
      #err { bottom: auto; top: 12px; left: 12px; right: 12px; }
    }

    /* ---------- bottom navigation (Clash-Royale-style tab bar) ---------- */
    /* Lives inside #app, so it is hidden with the map app on the gate. Fixed to
       the viewport and centred; on phones width:100% makes it span edge-to-edge. */
    #nav {
      position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
      z-index: 15; width: 100%; max-width: 480px;
      display: flex; align-items: flex-end; justify-content: space-around;
      background: var(--card); border: 1px solid var(--line); border-bottom: 0;
      border-radius: 18px 18px 0 0;
      padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
      box-shadow: 0 -3px 18px rgba(0,0,0,.10);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }
    .navbtn {
      flex: 1; border: 0; background: none; cursor: pointer;
      display: flex; flex-direction: column; align-items: center; gap: 3px;
      padding: 4px 2px; font-family: inherit; color: var(--muted);
      -webkit-tap-highlight-color: transparent;
    }
    .navbtn .navicon { font-size: 21px; line-height: 1; transition: transform .15s ease; }
    .navbtn .navlab { font-size: 10px; font-weight: bold; letter-spacing: .02em; }
    .navbtn:hover .navicon { transform: translateY(-1px); }
    .navbtn.active { color: var(--slate); }

    /* elevated centre button = the Map (home) tab, à la the Battle button.
       No label — its size alone marks it as the main/home screen. */
    .navbtn-center { flex: 0 0 auto; }
    .navbtn-center .navicon {
      width: 62px; height: 62px; margin-top: -30px; margin-bottom: 1px;
      border-radius: 50%; background: var(--slate); color: #fff;
      display: flex; align-items: center; justify-content: center; font-size: 30px;
      border: 3px solid var(--card); box-shadow: 0 6px 18px rgba(47,79,79,.45);
    }
    .navbtn-center.active .navicon { background: var(--slate-d); }
    .navbtn-center:hover .navicon { transform: translateY(-2px); }

    /* ---------- placeholder ("coming soon") tab views ---------- */
    /* Full-screen overlays above the map + its chrome (z 12), below the nav (15).
       They are always laid out; visibility is driven by transform + opacity so
       tab switches SLIDE rather than snap. Each view rests off-screen on the side
       its nav button sits (tabs left of the map slide in from the left, tabs to
       the right slide in from the right) and translates to 0 when active. */
    .view-ph {
      position: absolute; inset: 0; z-index: 12; display: flex;
      flex-direction: column; align-items: center; justify-content: center;
      text-align: center; padding: 24px;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 40px);
      background: radial-gradient(120% 90% at 50% 35%, #ffffff, var(--bg));
      color: var(--ink);
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
      transform: translateX(100%); pointer-events: none; will-change: transform;
      transition: transform .30s cubic-bezier(.4, 0, .2, 1);   /* smooth ease-in-out slide */
    }
    /* Off-screen resting positions, applied per-transition by the router so a
       tab always slides in from the direction of travel (a filmstrip). Panels
       are opaque, so two adjacent ones tile with no gap — no map peeks through. */
    .view-ph.slide-left  { transform: translateX(-100%); }
    .view-ph.slide-right { transform: translateX(100%); }
    .view-ph.active { transform: translateX(0); pointer-events: auto; }
    .view-ph.no-anim { transition: none; }   /* jump to the start side without animating */
    .view-ph .ph-emoji { font-size: 54px; margin-bottom: 14px; }
    .view-ph h2 { margin: 0 0 8px; font-size: 21px; letter-spacing: .01em; }
    .view-ph p { margin: 0; color: var(--muted); font-size: 14px; max-width: 300px; line-height: 1.55; }

    /* Feed tab = the relocated leaderboard + activity, as a full scrolling page */
    .view-ph.feed-view {
      align-items: stretch; justify-content: flex-start; text-align: left;
      padding: calc(env(safe-area-inset-top) + 20px) 16px 0;
      background: radial-gradient(120% 60% at 50% 0%, #ffffff, var(--bg));
    }
    .feed-view #panel h1 { text-align: center; }   /* keep the title centred */
    .feed-view #panel {
      flex: 1 1 auto; width: 100%; max-width: 480px; margin: 0 auto; min-height: 0;
    }
    .feed-view #panelPages { height: auto; flex: 1 1 auto; min-height: 0; }
    .feed-view .panel-page { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); }
    .ph-soon {
      margin-top: 18px; font-size: 11px; font-weight: bold; text-transform: uppercase;
      letter-spacing: .08em; color: var(--slate); background: #fff;
      border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px;
    }

    /* ---------- Social tab (group's people) ---------- */
    .view-ph.social-view {
      align-items: stretch; justify-content: flex-start; text-align: left;
      overflow-y: auto; -webkit-overflow-scrolling: touch;
      padding: calc(env(safe-area-inset-top) + 20px) 16px 0;
      background: radial-gradient(120% 60% at 50% 0%, #ffffff, var(--bg));
    }
    .social-page {
      width: 100%; max-width: 480px; margin: 0 auto;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
    }

    /* group header + invite */
    .social-view .ghead {
      background: var(--card); border: 1px solid var(--line); border-radius: 14px;
      padding: 14px; box-shadow: 0 1px 2px rgba(20,33,61,.04);
    }
    .social-view .ghead-row { display: flex; align-items: center; gap: 12px; }
    .social-view .gcrest {
      flex: 0 0 auto; width: 46px; height: 46px; border-radius: 13px;
      background: linear-gradient(160deg, var(--slate), var(--slate-d));
      color: #fff; display: flex; align-items: center; justify-content: center;
      font-size: 22px; box-shadow: 0 3px 10px rgba(47,79,79,.35);
    }
    .social-view .gmeta { min-width: 0; flex: 1; }
    .social-view .gname { font-size: 17px; font-weight: bold; letter-spacing: .01em;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .social-view .gsub { font-size: 12px; color: var(--muted); margin-top: 1px; }
    .social-view .invite {
      margin-top: 12px; display: flex; align-items: center; gap: 8px;
      background: var(--bg); border-radius: 10px; padding: 9px 11px;
      font-size: 12.5px; color: var(--muted); cursor: pointer;
    }
    .social-view .invite:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
    .social-view .invite .word {
      font-weight: bold; color: var(--slate); letter-spacing: .02em;
      background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px;
    }
    .social-view .invite .share { margin-left: auto; font-weight: bold; color: var(--slate); font-size: 12px; }
    .social-msg { font-size: 12px; min-height: 0; margin-top: 6px; }
    .social-msg:empty { display: none; }
    .social-msg.good { color: var(--good); }
    .social-msg.bad { color: var(--bad); }

    /* section labels (Achievements / Members) */
    .social-view .sec-label {
      font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
      color: var(--muted); font-weight: bold; margin: 22px 4px 9px;
    }

    /* achievements — locked placeholder until badges are built */
    .social-view .locked, .levels-view .locked {
      display: flex; align-items: center; gap: 13px;
      background: repeating-linear-gradient(135deg, var(--bg), var(--bg) 10px, #f1efe9 10px, #f1efe9 20px);
      border: 1px dashed #cfd2cd; border-radius: 14px; padding: 15px 16px;
    }
    .social-view .locked .lock, .levels-view .locked .lock {
      flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
      background: #fff; border: 1px solid var(--line);
      display: flex; align-items: center; justify-content: center; font-size: 18px;
    }
    .social-view .locked-body, .levels-view .locked-body { min-width: 0; }
    .social-view .locked-title, .levels-view .locked-title {
      font-size: 13.5px; font-weight: bold; color: var(--slate);
      text-transform: uppercase; letter-spacing: .06em;
    }
    .social-view .locked-sub, .levels-view .locked-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

    /* leaderboard (XP tiers) */
    .social-view .lb {
      background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
    }
    .social-view .lb-row {
      display: flex; align-items: center; gap: 11px; padding: 10px 13px;
      border-bottom: 1px solid #f2f2f0;
    }
    .social-view .lb-row:last-child { border-bottom: 0; }
    .social-view .lb-you { background: rgba(47,79,79,.05); }
    .social-view .lb-rank {
      flex: 0 0 auto; width: 18px; text-align: center; font-weight: bold;
      font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
    }
    .social-view .lb-ic { flex: 0 0 auto; font-size: 20px; line-height: 1; }
    .social-view .lb-id { flex: 1; min-width: 0; }
    .social-view .lb-name {
      font-size: 14px; font-weight: bold; color: var(--ink);
      display: flex; align-items: center; gap: 7px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .social-view .lb-tier { font-size: 11px; color: var(--muted); margin-top: 1px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .social-view .lb-row .pin-strip { margin-left: 2px; }
    .social-view .lb-xp {
      flex: 0 0 auto; font-size: 14px; font-weight: bold; color: var(--slate);
      font-variant-numeric: tabular-nums;
    }
    .social-view .lb-xp small { font-size: 9.5px; font-weight: bold; color: var(--muted);
      text-transform: uppercase; letter-spacing: .04em; margin-left: 3px; }
    .social-view .lb-more {
      display: flex; align-items: center; justify-content: center; gap: 6px;
      width: 100%; border: 0; background: none; cursor: pointer;
      padding: 11px; font-size: 12.5px; font-weight: bold; font-family: inherit;
      color: var(--slate); text-transform: uppercase; letter-spacing: .04em;
      border-top: 1px solid var(--line);
    }
    .social-view .lb-more:hover { background: var(--bg); }
    .social-view .lb-more-chev { font-weight: normal; }
    .social-view .lb-empty { padding: 16px 13px; font-size: 12.5px; color: var(--muted); }

    /* members list */
    .social-view .members {
      background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
    }
    .social-view .mitem { border-bottom: 1px solid #f2f2f0; }
    .social-view .mitem:last-child { border-bottom: 0; }
    .social-view .mrow {
      display: flex; align-items: center; gap: 12px; padding: 12px 13px; cursor: pointer;
    }
    .social-view .mrow.mrow-flat { cursor: default; }
    .social-view .mrow:active { background: var(--bg); }
    .social-view .mav {
      flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
      background: var(--slate); color: #fff; font-weight: bold; font-size: 14px;
      display: flex; align-items: center; justify-content: center;
      font-variant-numeric: tabular-nums; letter-spacing: .02em;
    }
    .social-view .mbody { flex: 1; min-width: 0; }
    .social-view .mname { font-size: 14.5px; font-weight: bold; display: flex; align-items: center; gap: 7px; }
    .social-view .youtag {
      font-size: 9.5px; font-weight: bold; text-transform: uppercase; letter-spacing: .05em;
      color: var(--slate); background: var(--bg); border-radius: 5px; padding: 1px 6px;
    }
    .social-view .mlast {
      font-size: 11.5px; color: var(--muted); margin-top: 2px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .social-view .mstats { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; }
    .social-view .mstat { text-align: center; }
    .social-view .mstat b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; line-height: 1.1; }
    .social-view .mstat span {
      display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .04em;
      color: var(--muted); margin-top: 2px;
    }
    .social-view .chip {
      display: inline-block; min-width: 34px; padding: 2px 7px; border-radius: 7px;
      font-size: 14px; font-weight: bold; color: var(--ink); font-variant-numeric: tabular-nums;
    }
    .social-view .chip-none { background: var(--bg); color: var(--muted); }
    .social-view .chev { flex: 0 0 auto; width: 10px; color: #c9ccc9; font-size: 17px; margin-left: 2px;
      transition: transform .18s ease; }
    .social-view .mitem.open .chev { transform: rotate(90deg); }

    /* expanded member detail: category profile + kindest / harshest */
    .social-view .mdetail { padding: 2px 13px 14px 65px; }
    .social-view .mbar {
      display: grid; grid-template-columns: 96px 1fr 30px; align-items: center;
      gap: 10px; margin: 0 0 6px;
    }
    .social-view .mbar-l { font-size: 12px; color: #444; }
    .social-view .mbar-t { height: 8px; border-radius: 5px; background: #eeedea; overflow: hidden; }
    .social-view .mbar-t i { display: block; height: 100%; border-radius: 5px; }
    .social-view .mbar b { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
    .social-view .mextremes {
      display: flex; flex-direction: column; gap: 6px;
      margin-top: 10px; padding-top: 10px; border-top: 1px solid #f2f2f0;
    }
    .social-view .mex { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
    .social-view .mex b {
      font-size: 12px; color: var(--ink); font-weight: bold;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .social-view .mex-sc {
      margin-left: auto; flex: 0 0 auto; padding: 1px 7px; border-radius: 6px;
      font-size: 12px; font-weight: bold; color: var(--ink); font-variant-numeric: tabular-nums;
    }

    .social-foot {
      text-align: center; font-size: 11.5px; color: var(--muted);
      margin: 16px 4px 4px; line-height: 1.5;
    }

    /* ---------- Me tab (your personal stats + plots) ---------- */
    .view-ph.me-view {
      align-items: stretch; justify-content: flex-start; text-align: left;
      overflow-y: auto; -webkit-overflow-scrolling: touch;
      padding: calc(env(safe-area-inset-top) + 20px) 16px 0;
      background: radial-gradient(120% 60% at 50% 0%, #ffffff, var(--bg));
    }
    .me-page {
      width: 100%; max-width: 480px; margin: 0 auto;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
    }
    .me-loading { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0; }

    /* ---- pinned badges (uses the shared .ach-* medallion) ---- */
    .me-view .me-pins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .me-view .me-pin { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px;
      background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px 8px 13px;
      box-shadow: 0 1px 2px rgba(20,33,61,.05); text-align: center; }
    .me-view button.me-pin { font: inherit; cursor: pointer; }
    .me-view .me-pin-name { font-size: 11.5px; font-weight: bold; color: var(--ink); line-height: 1.2; }
    .me-view .me-pin.empty { border-style: dashed; justify-content: center; min-height: 118px; }
    .me-view .me-pin.empty:hover { border-color: var(--slate); }
    .me-view .me-pin-plus { font-size: 26px; line-height: 1; color: var(--muted); }
    .me-view .me-pin-hint { font-size: 11px; color: var(--muted); }
    .me-view .me-pin-x { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
      border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 14px; line-height: 1;
      cursor: pointer; display: grid; place-items: center; padding: 0; }
    .me-view .me-pin-x:hover { color: var(--bad); border-color: var(--bad); }
    .me-view .me-pin-err { margin-top: 8px; font-size: 12px; font-weight: bold; color: var(--bad); text-align: center; }

    /* ---- pin picker (bottom-sheet modal) ---- */
    .me-pick-modal { position: fixed; inset: 0; z-index: 50; background: rgba(20,33,61,.35);
      display: flex; align-items: flex-end; justify-content: center; }
    .me-pick-card { background: var(--card); width: 100%; max-width: 480px; border-radius: 16px 16px 0 0;
      max-height: 80vh; display: flex; flex-direction: column;
      padding-bottom: calc(env(safe-area-inset-bottom) + 8px); box-shadow: 0 -6px 24px rgba(20,33,61,.2); }
    .me-pick-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
      padding: 15px 16px 11px; font-size: 14px; font-weight: bold; color: var(--ink); border-bottom: 1px solid var(--line); }
    .me-pick-close { background: var(--slate); color: #fff; border: none; border-radius: 999px;
      font: inherit; font-size: 13px; font-weight: bold; padding: 7px 16px; cursor: pointer; }
    .me-pick-close:hover { background: var(--slate-d); }
    .me-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px;
      padding: 14px 14px 4px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .me-pick { display: flex; flex-direction: column; align-items: center; gap: 5px; background: none;
      border: 1px solid transparent; border-radius: 12px; padding: 9px 4px; cursor: pointer; font: inherit; }
    .me-pick:hover:not(:disabled) { border-color: var(--line); background: var(--bg); }
    .me-pick:disabled { cursor: default; opacity: .5; }
    .me-pick-nm { font-size: 11px; font-weight: bold; color: var(--ink); line-height: 1.2; text-align: center; }
    .me-pick-tag { font-size: 9px; font-weight: bold; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); }
    .me-pick-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 13px; padding: 26px 10px; }

    /* section labels — shared look with the Social tab */
    .me-view .sec-label {
      font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
      color: var(--muted); font-weight: bold; margin: 22px 4px 9px;
    }

    /* hero: avatar + name + rank + headline count */
    .me-hero {
      display: flex; align-items: center; gap: 13px;
      background: var(--card); border: 1px solid var(--line); border-radius: 16px;
      padding: 15px; box-shadow: 0 1px 2px rgba(20,33,61,.04);
    }
    .me-av {
      flex: 0 0 auto; width: 54px; height: 54px; border-radius: 16px;
      background: linear-gradient(160deg, var(--slate), var(--slate-d));
      color: #fff; display: flex; align-items: center; justify-content: center;
      font-size: 22px; font-weight: bold; letter-spacing: .02em;
      font-variant-numeric: tabular-nums; box-shadow: 0 3px 10px rgba(47,79,79,.35);
    }
    .me-id { flex: 1; min-width: 0; }
    .me-name { font-size: 19px; font-weight: bold; letter-spacing: .01em;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .me-rank { font-size: 12.5px; color: var(--muted); margin-top: 2px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .me-rank .me-dot { color: #c9ccc9; }
    .me-hero-num { flex: 0 0 auto; text-align: center; padding-left: 6px; }
    .me-hero-num b { display: block; font-size: 26px; line-height: 1;
      font-variant-numeric: tabular-nums; color: var(--slate); }
    .me-hero-num span { display: block; font-size: 9.5px; text-transform: uppercase;
      letter-spacing: .05em; color: var(--muted); margin-top: 3px; }

    /* stat tiles (reuse the Feed tile look) */
    .me-tiles { display: flex; gap: 8px; margin-top: 12px; }
    .me-tiles .stat-tile { flex: 1; background: var(--card); border: 1px solid var(--line);
      border-radius: 12px; padding: 10px 6px; text-align: center; }
    .me-tiles .stat-tile b { display: block; font-size: 20px; font-variant-numeric: tabular-nums;
      line-height: 1.1; color: var(--ink); }
    .me-tiles .stat-tile span { display: block; font-size: 9.5px; text-transform: uppercase;
      letter-spacing: .05em; color: var(--muted); margin-top: 4px; }

    /* chart cards */
    .me-card {
      background: var(--card); border: 1px solid var(--line); border-radius: 16px;
      box-shadow: 0 1px 2px rgba(20,33,61,.04); overflow: hidden;
    }
    .me-card-pad { padding: 14px 12px 12px; }
    .me-card .chart { display: block; width: 100%; height: auto; }
    /* violins, one per category — a smooth swipeable carousel (no scrollbar).
       Snap centres each violin; overscroll-x containment keeps a horizontal
       swipe from firing the browser's back gesture. */
    .me-violins {
      display: flex; gap: 8px;
      overflow-x: auto; overflow-y: hidden;
      scroll-snap-type: x mandatory; scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
      scrollbar-width: none; padding: 2px 0;
    }
    .me-violins::-webkit-scrollbar { display: none; }
    .me-violin { flex: 0 0 auto; width: 100px; scroll-snap-align: center; text-align: center; }
    .me-violin .vln { display: block; width: 100px; height: auto; }
    .mv-lab { font-size: 11px; color: var(--muted); margin-top: 3px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mv-lab b { color: var(--ink); font-weight: 700; }

    /* superlatives grid */
    .me-supers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .me-super {
      display: flex; align-items: center; gap: 10px;
      background: var(--card); border: 1px solid var(--line); border-radius: 14px;
      padding: 11px 11px; min-width: 0;
    }
    .me-super-ic {
      flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; background: var(--bg);
      display: flex; align-items: center; justify-content: center; font-size: 17px;
    }
    .me-super-body { flex: 1; min-width: 0; }
    .me-super-lab { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em;
      color: var(--muted); font-weight: bold; }
    .me-super-name { font-size: 13.5px; font-weight: bold; color: var(--ink); margin-top: 1px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .me-super-sub { font-size: 11px; color: var(--muted); margin-top: 1px;
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .me-chip {
      flex: 0 0 auto; display: inline-block; min-width: 30px; padding: 2px 6px; border-radius: 7px;
      font-size: 13px; font-weight: bold; color: var(--ink); text-align: center;
      font-variant-numeric: tabular-nums;
    }
    .me-chip-none { background: var(--bg); color: var(--muted); }

    /* generous-vs-group diverging meter */
    .me-tend {
      margin-top: 10px; background: var(--card); border: 1px solid var(--line);
      border-radius: 14px; padding: 13px 14px;
    }
    .me-tend-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
    .me-tend-verdict { font-size: 14.5px; font-weight: bold; color: var(--ink); }
    .me-tend-num { font-size: 15px; font-weight: bold; color: var(--slate);
      font-variant-numeric: tabular-nums; }
    .me-tend-num span { font-size: 10px; font-weight: normal; color: var(--muted);
      text-transform: uppercase; letter-spacing: .04em; }
    .me-tend-track { position: relative; height: 8px; border-radius: 5px;
      background: linear-gradient(90deg, rgba(248,105,107,.18), var(--bg) 50%, rgba(99,190,123,.18));
      margin: 11px 0 9px; }
    .me-tend-mid { position: absolute; left: 50%; top: -2px; width: 2px; height: 12px;
      background: #c9ccc9; transform: translateX(-50%); }
    .me-tend-fill { position: absolute; top: 0; height: 8px; border-radius: 5px; min-width: 3px; }
    .me-tend-blurb { font-size: 12px; color: var(--muted); line-height: 1.45; }

    /* empty state */
    .me-empty { text-align: center; padding: 40px 20px 24px; }
    .me-empty-emoji { font-size: 40px; margin-bottom: 12px; }
    .me-empty-title { font-size: 16px; font-weight: bold; color: var(--ink); margin-bottom: 8px; }
    .me-empty p { font-size: 13px; color: var(--muted); line-height: 1.55; max-width: 300px; margin: 0 auto; }

    .me-foot { text-align: center; font-size: 11.5px; color: var(--muted);
      margin: 18px 4px 4px; }

    /* ---------- Levels tab (XP, tiers, recent XP) ---------- */
    .view-ph.levels-view {
      align-items: stretch; justify-content: flex-start; text-align: left;
      overflow-y: auto; -webkit-overflow-scrolling: touch;
      padding: calc(env(safe-area-inset-top) + 20px) 16px 0;
      background: radial-gradient(120% 60% at 50% 0%, #ffffff, var(--bg));
    }
    .levels-page {
      width: 100%; max-width: 480px; margin: 0 auto;
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
    }
    .lv-loading { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0; }
    .levels-view .sec-label {
      font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
      color: var(--muted); font-weight: bold; margin: 22px 4px 9px;
    }

    /* hero: crest + tier + pubs mapped */
    .lv-hero {
      display: flex; align-items: center; gap: 14px;
      background: var(--card); border: 1px solid var(--line); border-radius: 16px;
      padding: 16px; box-shadow: 0 1px 2px rgba(20,33,61,.04);
      cursor: pointer; user-select: none;
    }
    .lv-hero:hover { border-color: #d4d4cf; }
    .lv-hero:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
    .lv-chev { flex: 0 0 auto; color: var(--muted); font-size: 24px; line-height: 1;
      transition: transform .2s ease; }
    .lv-hero.open .lv-chev { transform: rotate(90deg); }
    .lv-crest {
      flex: 0 0 auto; width: 58px; height: 58px; border-radius: 16px;
      background: radial-gradient(120% 120% at 50% 20%, #ffffff, var(--bg));
      border: 1px solid var(--line);
      display: flex; align-items: center; justify-content: center; font-size: 30px;
    }
    .lv-id { flex: 1; min-width: 0; }
    .lv-tier { font-size: 20px; font-weight: bold; letter-spacing: .01em; color: var(--ink);
      white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .lv-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px;
      font-variant-numeric: tabular-nums; }

    /* progress toward the next tier */
    .lv-prog {
      margin-top: 12px; background: var(--card); border: 1px solid var(--line);
      border-radius: 16px; padding: 14px 15px; box-shadow: 0 1px 2px rgba(20,33,61,.04);
    }
    .lv-prog-head { display: flex; justify-content: space-between; gap: 10px;
      font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
      color: var(--muted); font-weight: bold; }
    .lv-prog-head span:last-child { color: var(--slate); }
    .lv-bar { position: relative; height: 14px; border-radius: 999px; background: var(--bg);
      border: 1px solid var(--line); overflow: hidden; margin: 9px 0 8px; }
    .lv-bar > i { display: block; height: 100%; border-radius: 999px; min-width: 3px;
      background: linear-gradient(90deg, var(--slate), var(--slate-d)); transition: width .5s ease; }
    .lv-prog-foot { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
    .lv-prog-foot b { color: var(--ink); font-size: 15px; }

    /* tier ladder */
    .lv-ladder { display: flex; flex-direction: column; gap: 3px; }
    .lv-rung {
      display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
      background: var(--card); border: 1px solid var(--line); border-radius: 12px;
      padding: 10px 12px;
    }
    .lv-rung.is-done { opacity: .55; }
    .lv-rung.is-current { border-color: var(--slate); box-shadow: 0 0 0 1px var(--slate) inset; }
    .lv-rung-ic { font-size: 22px; text-align: center; }
    .lv-rung-nm { font-weight: bold; color: var(--ink); font-size: 14px; min-width: 0; }
    .lv-here { display: inline-block; margin-left: 8px; font-size: 9.5px; font-weight: bold;
      text-transform: uppercase; letter-spacing: .04em; color: #fff; background: var(--slate);
      border-radius: 6px; padding: 2px 6px; vertical-align: middle; }
    .lv-rung-fig { text-align: right; font-weight: bold; color: var(--ink); font-size: 14px;
      font-variant-numeric: tabular-nums; }
    .lv-rung-fig small { display: block; font-size: 10.5px; font-weight: normal; color: var(--muted); }

    /* recent XP — momentum strip + feed */
    .lv-momentum { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
      font-size: 12px; color: var(--muted); margin: -2px 2px 8px; }
    .lv-mom-fig { font-weight: bold; color: var(--slate); font-size: 15px;
      font-variant-numeric: tabular-nums; }
    .lv-momentum b { color: var(--ink); font-weight: bold; }
    .lv-feed { display: flex; flex-direction: column;
      background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
    .lv-ev {
      display: flex; align-items: baseline; gap: 10px; padding: 8px 13px;
    }
    .lv-ev + .lv-ev { border-top: 1px solid var(--line); }
    .lv-ev-body { flex: 1; min-width: 0;
      display: flex; align-items: baseline; gap: 8px; }
    .lv-ev-title { flex: 0 1 auto; min-width: 0; font-size: 13.5px; font-weight: bold;
      color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .lv-ev-pills { flex: 0 0 auto; display: flex; gap: 3px; font-size: 12px; line-height: 1; }
    .lv-pill { display: inline-block; cursor: default; }
    .lv-ev-time { flex: 0 0 auto; margin-left: auto; font-size: 11px; color: var(--muted);
      white-space: nowrap; font-variant-numeric: tabular-nums; }
    .lv-ev-amt { flex: 0 0 auto; font-weight: bold; color: var(--slate);
      font-variant-numeric: tabular-nums; font-size: 14px; }

    /* empty state */
    .lv-empty { text-align: center; padding: 44px 20px 24px; }
    .lv-empty-emoji { font-size: 44px; margin-bottom: 12px; }
    .lv-empty-title { font-size: 17px; font-weight: bold; color: var(--ink); margin-bottom: 8px; }
    .lv-empty-sub { font-size: 13px; color: var(--muted); line-height: 1.55;
      max-width: 300px; margin: 0 auto; }

    /* ========================================================================
       Achievements grid — rarity-framed medallions (ported from the approved
       demo). Rarity + metallic-frame tokens are scoped here so they inherit to
       every badge without touching :root. See js/achievements.mjs.
       ==================================================================== */
    :root {
      --ach-common:#3f6ea6; --ach-common-bg:#eef3f9;
      --ach-rare:#d47f27;   --ach-rare-bg:#fbf1e6;
      --ach-epic:#7b4bc4;   --ach-epic-bg:#f2ecfb;
      --ach-legend:#c39a2b; --ach-legend-hi:#f0d878; --ach-legend-bg:#fbf5e2;
      --m-common:conic-gradient(from 200deg,#dbe7f4,#6f95bd,#345d8a,#8fadcf,#345d8a,#6f95bd,#dbe7f4);
      --m-rare:conic-gradient(from 200deg,#f7ddb6,#d99a4e,#a2611a,#e8b877,#a2611a,#d99a4e,#f7ddb6);
      --m-epic:conic-gradient(from 200deg,#e8d5fb,#9b6fd6,#5a33a0,#b48ee2,#5a33a0,#9b6fd6,#e8d5fb);
      --m-legend:conic-gradient(from 200deg,#fff4c9,#ecc85e,#956c11,#fbe38f,#956c11,#ecc85e,#fff4c9);
      --m-lock:conic-gradient(from 200deg,#dedcd7,#a8a6a0,#c8c6c0,#a8a6a0,#dedcd7);
      --ray-epic:rgba(123,75,196,.55); --ray-legend:rgba(230,182,60,.75);
    }
    .ach-head { display: flex; align-items: baseline; justify-content: space-between; }
    .ach-count { font-size: 12px; font-weight: bold; color: var(--muted);
      font-variant-numeric: tabular-nums; margin-right: 4px; }
    .ach-rar-label { font-size: 11px; font-weight: bold; letter-spacing: .05em;
      text-transform: uppercase; margin: 16px 4px 9px; font-variant-numeric: tabular-nums; }
    .ach-rar-label.common { color: var(--ach-common); }
    .ach-rar-label.rare { color: var(--ach-rare); }
    .ach-rar-label.epic { color: var(--ach-epic); }
    .ach-rar-label.legendary { color: var(--ach-legend); }

    .ach-grid { display: grid; gap: 12px;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    /* ---- badge card ---- */
    .ach-badge { position: relative; background: var(--card);
      border: 1px solid var(--line); border-radius: 14px; padding: 18px 12px 14px;
      text-align: center; box-shadow: 0 1px 2px rgba(20,33,61,.05); overflow: hidden; }
    .ach-name { margin-top: 13px; font-size: 13.5px; font-weight: bold;
      color: var(--ink); line-height: 1.2; }
    .ach-meta { display: flex; align-items: center; justify-content: center;
      gap: 6px; margin-top: 5px; }
    .ach-chip { font-size: 9.5px; letter-spacing: .05em; text-transform: uppercase;
      font-weight: bold; padding: 2px 7px; border-radius: 999px; }
    .ach-chip.common { color: var(--ach-common); background: var(--ach-common-bg); }
    .ach-chip.rare { color: var(--ach-rare); background: var(--ach-rare-bg); }
    .ach-chip.epic { color: var(--ach-epic); background: var(--ach-epic-bg); }
    .ach-chip.legendary { color: var(--ach-legend); background: var(--ach-legend-bg); }
    .ach-xp { font-size: 11px; color: var(--muted); font-weight: bold;
      font-variant-numeric: tabular-nums; }
    .ach-obj { margin-top: 8px; font-size: 11.5px; color: var(--muted);
      line-height: 1.4; min-height: 2.4em; }
    .ach-tag { position: relative; z-index: 1; display: inline-block; margin-top: 8px;
      font-size: 9.5px; font-weight: bold; letter-spacing: .04em; text-transform: uppercase;
      color: var(--slate); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
    /* the live Title holder — highlighted when it's you */
    .ach-tag-you { color: #fff; background: var(--slate); border-color: var(--slate); }

    /* premium card — only once unlocked */
    .ach-card-epic { background: linear-gradient(165deg, var(--ach-epic-bg), var(--card) 70%);
      border-color: rgba(123,75,196,.32); }
    .ach-card-legendary { background: linear-gradient(160deg,#2b3d3f,#1b2a2b);
      border-color: rgba(195,154,43,.5); }
    .ach-card-legendary .ach-name { color: #fff; }
    .ach-card-legendary .ach-obj { color: #c6d3d0; }
    .ach-card-legendary .ach-chip.legendary { color: #1b2a2b;
      background: linear-gradient(var(--ach-legend-hi), var(--ach-legend)); }
    .ach-card-legendary .ach-xp { color: var(--ach-legend-hi); }
    .ach-card-legendary .ach-tag { color: var(--ach-legend-hi);
      border-color: rgba(240,216,120,.4); }
    .ach-card-legendary::before { content: ""; position: absolute; inset: 0;
      pointer-events: none; background: radial-gradient(120% 80% at 50% -10%, rgba(240,216,120,.16), transparent 60%); }

    /* ---- the medallion ---- */
    .ach-medal { position: relative; width: 84px; height: 84px; margin: 0 auto;
      display: grid; place-items: center; z-index: 1; }
    .ach-rays { position: absolute; inset: -9px; border-radius: 50%; z-index: 0; opacity: 0;
      background: repeating-conic-gradient(from 0deg, var(--ray, transparent) 0deg 5deg, transparent 5deg 17deg);
      -webkit-mask: radial-gradient(circle, transparent 33%, #000 45%, transparent 72%);
              mask: radial-gradient(circle, transparent 33%, #000 45%, transparent 72%);
      animation: ach-spin 34s linear infinite; }
    .ach-ring { position: relative; z-index: 2; width: 76px; height: 76px; border-radius: 50%;
      padding: 6px; background: var(--metal, var(--m-common));
      box-shadow: 0 3px 7px rgba(0,0,0,.28), inset 0 2px 2px rgba(255,255,255,.55), inset 0 -3px 5px rgba(0,0,0,.32); }
    .ach-disc { position: relative; width: 100%; height: 100%; border-radius: 50%;
      display: grid; place-items: center; font-size: 31px; overflow: hidden;
      background: var(--disc, radial-gradient(circle at 50% 34%, #fff, var(--ach-common-bg)));
      box-shadow: inset 0 3px 6px rgba(255,255,255,.45), inset 0 -6px 9px rgba(0,0,0,.14); }
    .ach-emoji { position: relative; z-index: 2; line-height: 1;
      filter: drop-shadow(0 2px 2px rgba(0,0,0,.22)); }
    .ach-emoji.q { font-weight: bold; color: var(--muted); font-size: 30px; filter: none; }
    .ach-gloss { position: absolute; top: -42%; left: -8%; width: 116%; height: 78%;
      border-radius: 50%; z-index: 1; pointer-events: none; opacity: .7;
      background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,0)); }

    .ach-medal.common { --metal: var(--m-common); --disc: radial-gradient(circle at 50% 34%, #fff, var(--ach-common-bg)); }
    .ach-medal.rare { --metal: var(--m-rare); --disc: radial-gradient(circle at 50% 34%, #fff, var(--ach-rare-bg)); }
    .ach-medal.epic { --metal: var(--m-epic); --disc: radial-gradient(circle at 50% 34%, #fff, var(--ach-epic-bg)); }
    .ach-medal.legendary { --metal: var(--m-legend); --disc: radial-gradient(circle at 50% 34%, #fff, var(--ach-legend-bg)); }
    .ach-medal.epic .ach-rays { --ray: var(--ray-epic); opacity: .5; inset: -1px;
      -webkit-mask: radial-gradient(circle, transparent 41%, #000 47%, transparent 55%);
              mask: radial-gradient(circle, transparent 41%, #000 47%, transparent 55%); }
    .ach-medal.legendary .ach-rays { --ray: var(--ray-legend); opacity: .85; }

    /* periodic shine sweep on epic + legendary */
    .ach-medal.epic .ach-disc::after,
    .ach-medal.legendary .ach-disc::after { content: ""; position: absolute; top: 0;
      left: -70%; width: 45%; height: 100%; z-index: 3; transform: skewX(-16deg);
      background: linear-gradient(100deg, transparent, rgba(255,255,255,.6), transparent);
      animation: ach-sheen 6s ease-in-out infinite; }

    /* holographic rim — legendary only */
    .ach-medal.legendary .ach-ring::after { content: ""; position: absolute; inset: 0;
      border-radius: 50%; z-index: 3; pointer-events: none; mix-blend-mode: screen; opacity: .55;
      background: conic-gradient(from 0deg, transparent, rgba(255,208,120,.6), rgba(255,120,170,.55), rgba(150,130,255,.6), rgba(120,220,200,.6), transparent);
      -webkit-mask: radial-gradient(circle, transparent 31px, #000 32px, #000 38px, transparent 39px);
              mask: radial-gradient(circle, transparent 31px, #000 32px, #000 38px, transparent 39px);
      animation: ach-spin 9s linear infinite; }

    @keyframes ach-spin { to { transform: rotate(360deg); } }
    @keyframes ach-sheen { 0% { left: -70%; } 22% { left: 135%; } 100% { left: 135%; } }

    /* ---- mini medallion (pinned badges on the map pill + leaderboard) ---- */
    .ach-medal.mini { width: 24px; height: 24px; margin: 0; }
    .ach-medal.mini .ach-ring { width: 24px; height: 24px; padding: 2px;
      box-shadow: 0 1px 2px rgba(0,0,0,.28), inset 0 1px 1px rgba(255,255,255,.55), inset 0 -1px 2px rgba(0,0,0,.3); }
    .ach-medal.mini .ach-disc { font-size: 11px;
      box-shadow: inset 0 1px 2px rgba(255,255,255,.45), inset 0 -2px 3px rgba(0,0,0,.14); }
    .ach-medal.mini .ach-emoji { filter: drop-shadow(0 1px 1px rgba(0,0,0,.22)); }
    /* keep a row of them calm: no rays, gloss, sheen or holo rim at this size */
    .ach-medal.mini .ach-rays, .ach-medal.mini .ach-gloss,
    .ach-medal.mini .ach-disc::after, .ach-medal.mini .ach-ring::after { display: none; }
    .pin-strip { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }

    /* lock chip */
    .ach-lock { position: absolute; right: 3px; bottom: 3px; z-index: 5;
      width: 22px; height: 22px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
      display: none; place-items: center; font-size: 10.5px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }

    /* ---- locked state ---- */
    .ach-badge.ach-locked { border-style: dashed; }
    .ach-badge.ach-locked .ach-ring { background: var(--m-lock);
      box-shadow: 0 2px 4px rgba(0,0,0,.15), inset 0 1px 1px rgba(255,255,255,.4), inset 0 -2px 4px rgba(0,0,0,.2); }
    .ach-badge.ach-locked .ach-disc { background: #e7e5e1; box-shadow: inset 0 2px 5px rgba(0,0,0,.12); }
    .ach-badge.ach-locked .ach-emoji { filter: grayscale(1); opacity: .3; }
    .ach-badge.ach-locked .ach-rays,
    .ach-badge.ach-locked .ach-gloss,
    .ach-badge.ach-locked .ach-disc::after,
    .ach-badge.ach-locked .ach-ring::after { display: none; }
    .ach-badge.ach-locked .ach-lock { display: grid; }
    .ach-badge.ach-locked .ach-name { color: var(--muted); }

    /* ---- tap-to-pin: earned badges are tappable to pin to your profile ---- */
    .ach-pinhint { font-size: 11.5px; color: var(--muted); margin: 0 4px 12px; }
    .ach-pinhint b { color: var(--slate); font-variant-numeric: tabular-nums; }
    .ach-badge.ach-earned { cursor: pointer; transition: transform .1s ease, box-shadow .15s ease; }
    .ach-badge.ach-earned:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(20,33,61,.12); }
    .ach-badge.ach-earned:active { transform: translateY(0); }
    .ach-badge.ach-earned:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
    .ach-pin { position: absolute; top: 7px; right: 7px; z-index: 6; width: 26px; height: 26px;
      border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--card);
      border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.12); opacity: .5;
      transition: opacity .12s ease; }
    .ach-badge.ach-earned:hover .ach-pin { opacity: 1; }
    .ach-badge.ach-pinned { box-shadow: inset 0 0 0 2px var(--slate), 0 1px 2px rgba(20,33,61,.05); }
    .ach-badge.ach-pinned .ach-pin { opacity: 1; background: var(--slate); border-color: var(--slate); }
    .ach-badge.ach-pinned:hover { box-shadow: inset 0 0 0 2px var(--slate), 0 6px 16px rgba(20,33,61,.12); }
    .ach-card-legendary .ach-pin { background: rgba(0,0,0,.28); border-color: rgba(240,216,120,.4); }
    .ach-card-legendary.ach-pinned { box-shadow: inset 0 0 0 2px var(--ach-legend-hi); }
    .ach-card-legendary.ach-pinned .ach-pin { background: var(--ach-legend-hi); border-color: var(--ach-legend-hi); }
    .ach-card-legendary.ach-pinned:hover { box-shadow: inset 0 0 0 2px var(--ach-legend-hi), 0 6px 16px rgba(20,33,61,.12); }

    /* levels-tab pin feedback toast */
    .lv-toast { position: fixed; left: 50%; z-index: 40;
      bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
      transform: translate(-50%, 12px); background: var(--slate); color: #fff;
      font-size: 12.5px; font-weight: bold; padding: 10px 15px; border-radius: 999px;
      box-shadow: 0 8px 20px rgba(0,0,0,.28); opacity: 0; pointer-events: none; max-width: 82vw;
      text-align: center; transition: opacity .2s ease, transform .2s ease; }
    .lv-toast.show { opacity: 1; transform: translate(-50%, 0); }

    /* ======================================================================
       Achievement unlock popup (js/unlock.mjs) — fires when a rating earns a
       badge. Reuses the .ach-medal component at hero size; legendary keeps its
       dark card + gold buttons. ============================================ */
    .unlock-ov { position: fixed; inset: 0; z-index: 200; display: none;
      align-items: center; justify-content: center; padding: 24px; }
    .unlock-ov.open, .unlock-ov.closing { display: flex; }
    /* exit: mirror the spring-in with a quick fade+settle so the popup doesn't
       blink out. Budget matches the 200ms wait in dismiss() (js/unlock.mjs). */
    .unlock-ov.closing .unlock-bg { animation: unlock-fade-out .18s ease forwards; }
    .unlock-ov.closing .unlock-pop { animation: unlock-pop-out .18s cubic-bezier(.4,0,.2,1) forwards; }
    .unlock-bg { position: absolute; inset: 0; background: rgba(15,20,25,.55);
      -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); animation: unlock-fade .25s ease; }
    .unlock-pop { position: relative; z-index: 1; width: 100%; max-width: 320px; background: var(--card);
      color: var(--ink); border-radius: 22px; padding: 26px 22px 20px; text-align: center;
      box-shadow: 0 24px 60px rgba(0,0,0,.4); overflow: hidden;
      animation: unlock-pop .34s cubic-bezier(.2,.9,.3,1.2); }
    .unlock-pop.leg { background: linear-gradient(160deg,#2b3d3f,#1b2a2b); color: #fff; }
    .unlock-halo { position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
      width: 280px; height: 280px; border-radius: 50%; z-index: 0; pointer-events: none; opacity: .6;
      background: radial-gradient(circle, var(--halo, rgba(63,110,166,.35)), transparent 62%); }
    .unlock-pop > * { position: relative; z-index: 1; }
    .unlock-eyebrow { font-size: 11px; font-weight: bold; letter-spacing: .14em; text-transform: uppercase;
      color: var(--muted); margin-bottom: 14px; }
    .unlock-pop.leg .unlock-eyebrow { color: var(--ach-legend-hi); }
    .unlock-medal .ach-medal { width: 118px; height: 118px; margin: 2px auto 4px;
      animation: unlock-medal .5s .08s cubic-bezier(.2,.9,.3,1.3) both; }
    .unlock-medal .ach-ring { width: 106px; height: 106px; }
    .unlock-medal .ach-disc { font-size: 44px; }
    .unlock-medal .ach-medal.legendary .ach-ring::after {
      -webkit-mask: radial-gradient(circle, transparent 46px, #000 47px, #000 53px, transparent 54px);
              mask: radial-gradient(circle, transparent 46px, #000 47px, #000 53px, transparent 54px); }
    .unlock-name { font-size: 20px; font-weight: bold; margin-top: 6px; letter-spacing: .01em; text-wrap: balance; }
    .unlock-meta { display: inline-flex; align-items: center; gap: 8px; margin-top: 9px; }
    .unlock-pop.leg .ach-xp { color: var(--ach-legend-hi); }
    .unlock-obj { font-size: 12.5px; color: var(--muted); margin-top: 12px; line-height: 1.45; }
    .unlock-pop.leg .unlock-obj { color: #c6d3d0; }
    .unlock-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
    .unlock-btn { font-family: inherit; font-size: 14px; font-weight: bold; cursor: pointer;
      border-radius: 11px; padding: 12px 14px; border: 1px solid transparent;
      transition: transform .08s ease, filter .15s ease; }
    .unlock-btn:active { transform: translateY(1px); }
    .unlock-btn:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }
    .unlock-btn-primary { background: var(--slate); color: #fff; }
    .unlock-btn-primary:hover { filter: brightness(1.08); }
    .unlock-btn-primary:disabled { cursor: default; filter: none; opacity: .92; }
    .unlock-pop.leg .unlock-btn-primary { background: linear-gradient(var(--ach-legend-hi), var(--ach-legend)); color: #1b2a2b; }
    .unlock-btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
    .unlock-pop.leg .unlock-btn-ghost { color: #c6d3d0; border-color: rgba(255,255,255,.2); }
    @keyframes unlock-fade { from { opacity: 0; } to { opacity: 1; } }
    @keyframes unlock-pop { from { opacity: 0; transform: translateY(14px) scale(.92); } to { opacity: 1; transform: none; } }
    @keyframes unlock-medal { from { opacity: 0; transform: scale(.4) rotate(-12deg); } to { opacity: 1; transform: none; } }
    @keyframes unlock-fade-out { from { opacity: 1; } to { opacity: 0; } }
    @keyframes unlock-pop-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.96); } }

    @media (prefers-reduced-motion: reduce) {
      .ach-rays,
      .ach-medal.legendary .ach-ring::after { animation: none; }
      .ach-medal.epic .ach-disc::after,
      .ach-medal.legendary .ach-disc::after { display: none; }
      .unlock-bg, .unlock-pop, .unlock-medal .ach-medal,
      .unlock-ov.closing .unlock-bg, .unlock-ov.closing .unlock-pop { animation: none; }
    }
