/* Ranking / Friends — 941 × 1672 presentation matched to new-ui references. */
#app:has(#screen-ranking.active){background:#8fd6ee url('assets/ranking/background-v1.png') center/cover no-repeat}
#app:has(#screen-ranking.active[data-rank-tab="active"]){background-image:url('assets/ranking/background-sleep-v1.png')}
#app:has(#screen-ranking.active[data-rank-tab="friend"]){background-image:url('assets/ranking/background-friend-v1.png')}
#app:has(#screen-ranking.active) #topbar,#app:has(#screen-ranking.active) #bottomnav,#app:has(#screen-ranking.active) #pet-layer{display:none!important}
#app:has(#screen-ranking.active) .pet-region{position:absolute;inset:0}
#app:has(#screen-ranking.active) #screens{position:absolute;left:var(--ranking-left);top:var(--ranking-top);width:941px;height:1672px;transform:scale(var(--ranking-scale));transform-origin:top left;padding:0;overflow:visible}
#screen-ranking{position:relative;width:941px;height:1672px;padding:199px 26px 34px;color:#092856;font-family:Rajdhani,Sarabun,sans-serif;overflow:hidden}
#screen-ranking.active{animation:none}
.ranking-header{position:absolute;left:27px;right:27px;top:39px;height:114px;display:grid;grid-template-columns:112px 1fr 104px;align-items:center;gap:48px}
.ranking-back,.ranking-menu{width:104px;height:104px;border:3px solid #b5fbff;border-radius:52px;background:linear-gradient(145deg,rgba(23,132,166,.96),rgba(12,69,111,.98));box-shadow:inset 0 0 13px rgba(138,255,255,.55),0 7px 12px rgba(0,55,91,.35);color:#fff;cursor:pointer}
.ranking-back{font:700 104px/82px Rajdhani,sans-serif;text-shadow:0 4px 3px rgba(0,44,75,.45)}
.ranking-menu{border-radius:28px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:23px}
.ranking-menu i{display:block;width:54px;height:9px;border-radius:8px;background:#fff;box-shadow:0 2px 2px rgba(0,56,91,.35)}
.ranking-title{height:92px;border:3px solid #73f7f4;border-radius:49px;background:linear-gradient(110deg,rgba(0,123,133,.94),rgba(9,94,143,.94));box-shadow:inset 0 0 20px rgba(110,255,244,.38),0 5px 10px rgba(0,68,91,.28);display:flex;align-items:center;justify-content:center;gap:6px;color:#fff;white-space:nowrap}
.ranking-title img{width:151px;height:76px;object-fit:contain;filter:drop-shadow(0 3px 2px rgba(78,57,0,.45))}.ranking-title b{font-size:60px;letter-spacing:2px}
.ranking-board{height:1450px;margin:0;padding:24px 19px 21px;border:3px solid rgba(213,255,255,.96);border-radius:36px;background:linear-gradient(145deg,rgba(218,251,250,.78),rgba(142,216,236,.76));box-shadow:inset 0 0 33px rgba(255,255,255,.55),0 0 16px rgba(77,244,255,.66),0 10px 25px rgba(0,75,104,.28);backdrop-filter:blur(8px);overflow:hidden}
.rank-tabs{height:91px;display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin:0 0 19px}
.rank-tab{height:91px;border:2px solid rgba(238,255,255,.95);border-radius:24px;background:linear-gradient(145deg,rgba(230,253,253,.93),rgba(184,229,239,.9));box-shadow:inset 0 0 12px #fff;color:#24577b;font:700 37px Rajdhani,Sarabun,sans-serif;display:flex;align-items:center;justify-content:center;gap:20px;cursor:pointer}
.rank-tab svg{width:47px;height:47px;fill:currentColor;flex:0 0 auto}.rank-tab.active{border:4px solid #83ffff;background:linear-gradient(145deg,#08c2cf,#087aa3);box-shadow:0 0 15px rgba(45,255,244,.85),inset 0 0 18px rgba(121,255,255,.5);color:#fff}
.rank-podium{display:grid;grid-template-columns:repeat(3,1fr);align-items:end;gap:9px;margin-bottom:20px}
.rank-podium:empty{display:none}.rank-podium-card{height:336px;padding:15px 10px;border:3px solid #ecffff;border-radius:25px;background:linear-gradient(145deg,rgba(217,247,250,.92),rgba(151,213,233,.92));box-shadow:inset 0 0 22px rgba(255,255,255,.72);display:flex;flex-direction:column;align-items:center;justify-content:flex-end;text-align:center;overflow:hidden}
.rank-podium-card:only-child{grid-column:2}
.rank-podium-card.first{height:353px;border-color:#fff2a4;background:linear-gradient(145deg,rgba(255,247,191,.96),rgba(255,214,104,.92));box-shadow:0 0 15px rgba(255,215,62,.65),inset 0 0 25px #fff9d3}
.rank-medal{display:block;flex:0 0 215px;width:215px;height:215px;margin-bottom:-5px;background-image:url('assets/ranking/medals-v1.png');background-size:300% 100%;background-repeat:no-repeat;filter:drop-shadow(0 5px 4px rgba(18,69,101,.3))}.rank-podium-card.first .rank-medal{flex-basis:235px;width:235px;height:235px}.rank-2 .rank-medal{background-position:0 50%}.rank-1 .rank-medal{background-position:50% 50%}.rank-3 .rank-medal{background-position:100% 50%}.rank-podium-card b{flex:0 0 42px;width:100%;margin:0 0 4px;font-size:36px;line-height:42px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rank-podium-card em{flex:0 0 43px;min-width:128px;padding:3px 16px;border-radius:20px;background:rgba(27,104,143,.7);color:#fff;font:700 30px/37px Rajdhani,sans-serif}
.rank-table-scroll{overflow-y:auto}.rank-head{height:55px;padding:0 28px;border:2px solid rgba(235,255,255,.9);border-bottom:0;border-radius:23px 23px 0 0;background:rgba(140,213,232,.48);font-size:27px;color:#183e69;opacity:1}
#rank-rows{height:830px;padding:0 12px 12px;overflow-y:auto;scrollbar-color:#fff rgba(21,98,133,.55);scrollbar-width:thin}
.rank-row{height:70px;margin:7px 0 0;padding:0 18px;border:2px solid rgba(238,255,255,.94);border-radius:20px;background:linear-gradient(110deg,rgba(230,251,251,.84),rgba(176,224,237,.82));box-shadow:inset 0 0 12px rgba(255,255,255,.55);font-size:32px}
.rank-row.me{border-color:#ffe47b;background:linear-gradient(110deg,rgba(255,248,195,.95),rgba(255,211,91,.9));box-shadow:0 0 10px rgba(255,212,63,.56),inset 0 0 12px #fff9d5}
.rh-no,.rr-no{width:92px}.rh-val,.rr-val{width:135px}.rr-name{font-weight:700}.rr-val{font-size:33px}
.rank-mode-title{height:88px;margin:0 0 10px;border:2px solid #edffff;border-radius:24px;background:linear-gradient(100deg,rgba(56,179,226,.86),rgba(78,156,220,.82));color:#fff;text-align:center;font:700 44px/1 Rajdhani,Sarabun,sans-serif;text-shadow:0 2px 3px #376c9e;display:flex;align-items:center;justify-content:center;gap:14px}.rank-mode-title svg{width:40px;height:40px;fill:currentColor;filter:drop-shadow(0 2px 2px rgba(35,91,137,.5))}
#screen-ranking[data-rank-tab="active"] .rank-head{display:none!important}#screen-ranking[data-rank-tab="active"] #rank-rows{height:1060px;max-height:none;padding:0}
#screen-ranking[data-rank-tab="active"] .ranking-board{height:1450px}
#screen-ranking[data-rank-tab="active"] .rank-row{height:220px;padding:0 34px;border-radius:29px;font-size:39px}
#screen-ranking[data-rank-tab="active"] .rank-row:first-child{border-color:#ffe474;background:linear-gradient(110deg,rgba(255,248,195,.96),rgba(255,214,91,.91));box-shadow:0 0 12px rgba(255,216,60,.62),inset 0 0 15px #fff8cc}
#screen-ranking[data-rank-tab="active"] .rr-no{width:245px}.sleep-rank-medal{display:block;width:168px;height:168px;margin:0 auto;background:url('assets/ranking/medals-v1.png') 0 50%/300% 100% no-repeat;filter:drop-shadow(0 5px 4px rgba(18,69,101,.25))}.sleep-rank-medal.rank-1{background-position:50% 50%}.sleep-rank-medal.rank-2{background-position:0 50%}.sleep-rank-medal.rank-3{background-position:100% 50%}.sleep-rank-number{display:grid;width:112px;height:112px;margin:auto;border:5px solid #eaffff;border-radius:50%;place-items:center;background:linear-gradient(145deg,#58b9dc,#2778ae);box-shadow:inset 0 0 15px rgba(255,255,255,.72),0 5px 8px rgba(17,75,107,.25);color:#fff;font:700 42px/1 Rajdhani,sans-serif;font-style:normal}
#screen-ranking[data-rank-tab="active"] .rr-val{font-size:58px;width:120px}#screen-ranking[data-rank-tab="active"] .rr-name{display:flex;flex-direction:column;align-items:flex-start;font-size:39px;line-height:1.05}#screen-ranking[data-rank-tab="active"] .rr-name b{white-space:nowrap}#screen-ranking[data-rank-tab="active"] .rr-name em{min-width:225px;margin-top:15px;padding:8px 20px;border-radius:30px;background:rgba(31,105,145,.72);color:#fff;font-size:29px;font-style:normal;text-align:center}
#screen-ranking .offline-note{font-size:25px;line-height:1.25;color:#fff;text-shadow:0 2px 3px #25688c}#screen-ranking[data-rank-tab="active"] #rank-note{position:absolute;left:70px;right:70px;bottom:42px;z-index:3;margin:0;text-align:center}
#screen-ranking[data-rank-tab="friend"] .ranking-board{height:1450px}#friend-panel{max-height:1290px;margin-top:0;overflow-y:auto;scrollbar-width:none}#friend-panel::-webkit-scrollbar{display:none}#screen-ranking[data-rank-tab="friend"] .rank-podium,#screen-ranking[data-rank-tab="friend"] .rank-head{display:none}
#friend-panel .card{margin:0 0 17px;padding:20px 18px;border:2px solid #efffff;border-radius:26px;background:linear-gradient(145deg,rgba(229,253,252,.88),rgba(167,220,236,.86));box-shadow:inset 0 0 18px rgba(255,255,255,.65),0 4px 10px rgba(0,80,111,.16)}
#friend-search-card{padding:22px!important}#friend-search-input{height:91px!important;padding:0 28px 0 76px!important;border:3px solid #efffff!important;border-radius:26px!important;background:rgba(244,255,255,.72)!important;color:#1c5176;font:500 33px Rajdhani,Sarabun,sans-serif!important;outline:none;box-shadow:inset 0 0 14px rgba(139,222,239,.6)}
#friend-search-results:not(:empty){margin-top:16px}#friend-search-results .friend-row{background:linear-gradient(110deg,rgba(230,251,251,.94),rgba(174,231,241,.92))}.friend-search-empty{margin:14px 0 0!important;text-align:center}.friend-search-status{padding:7px 14px;border-radius:20px;background:rgba(35,111,150,.18);color:#29617f;font-size:24px;font-weight:700;white-space:nowrap}
#friend-search-card::before{content:'⌕';position:absolute;margin:11px 0 0 25px;z-index:2;color:#2c6e91;font-size:62px;line-height:1;pointer-events:none}#friend-panel .set-cat{display:flex;align-items:center;padding:0 5px 12px;color:#194d72;font-size:31px;letter-spacing:0}.friend-count{min-width:72px;margin-left:auto;padding:3px 18px;border-radius:22px;background:rgba(42,129,174,.6);color:#fff;text-align:center}.friend-row{height:126px;padding:10px 12px;display:grid;grid-template-columns:105px minmax(0,1fr) auto;align-items:center;gap:15px;border:2px solid #efffff;border-radius:22px;background:rgba(239,255,255,.68);box-shadow:inset 0 0 12px rgba(255,255,255,.58)}.friend-row+.friend-row{margin-top:8px}.friend-avatar{width:101px;height:101px;object-fit:contain;border:2px solid #fff;border-radius:20px;background:rgba(255,255,255,.52)}.friend-copy{min-width:0;display:flex;flex-direction:column;align-items:flex-start}.friend-copy b{max-width:100%;font-size:34px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.friend-copy span{min-width:128px;padding:4px 16px;border-radius:19px;background:rgba(35,111,150,.68);color:#fff;font-size:25px;text-align:center}.friend-action{display:flex;align-items:center;gap:7px}.friend-add-btn,.friend-accept-btn,.friend-decline-btn,.friend-remove-btn,.friend-remove-preview{width:auto!important;min-height:59px!important;margin:0!important;padding:8px 20px!important;border:3px solid #b4d8ea!important;border-radius:24px!important;background:linear-gradient(#f9ffff,#d9ebf2)!important;color:#245575!important;font:700 25px Rajdhani,Sarabun,sans-serif!important;white-space:nowrap}.friend-accept-btn,.friend-add-btn{background:linear-gradient(#55dce2,#159bbc)!important;color:#fff!important}
#rank-pvp{display:none!important}
body:has(#screen-ranking.active) #modal-layer:has(>.dialog){background:rgba(4,38,63,.67);backdrop-filter:blur(5px)}
body:has(#screen-ranking.active) #modal-layer>.dialog{border:3px solid #dfffff;border-radius:31px;background:linear-gradient(145deg,rgba(235,255,253,.98),rgba(174,226,239,.97));box-shadow:inset 0 0 20px rgba(255,255,255,.68),0 0 17px rgba(72,239,255,.75),0 22px 50px rgba(0,31,55,.55);color:#123b67}
body:has(#screen-ranking.active) #modal-layer>.dialog .btn-primary{background:linear-gradient(#ffd96c,#f5a51d);color:#663b00;box-shadow:inset 0 2px 4px #fff,0 4px 9px rgba(130,79,0,.28)}
body:has(#screen-ranking.active) #modal-layer>.dialog .btn-ghost{border:2px solid #eaffff;background:linear-gradient(#f3ffff,#c7e8f0);color:#245473}
@media(max-width:360px){.ranking-header{gap:28px}.ranking-title b{font-size:46px}.ranking-title img{width:135px}.rank-tab{font-size:32px}.rank-tab svg{width:40px;height:40px}}
/* Active tab (11-09, replaces Sleep): score = run x3 / brisk x2 / walk x1 steps, weekly; breakdown under the name */
#screen-ranking[data-rank-tab="active"] .rr-name{flex:1;min-width:0}#screen-ranking[data-rank-tab="active"] .rr-no{width:200px}#screen-ranking[data-rank-tab="active"] .rr-name b{max-width:100%;overflow:hidden;text-overflow:ellipsis}#screen-ranking[data-rank-tab="active"] .rr-name em{min-width:0;max-width:100%;padding:10px 28px;font-size:30px;line-height:1.2;white-space:nowrap;overflow:visible}#screen-ranking[data-rank-tab="active"] .rr-val{width:auto;min-width:120px;padding-left:12px;font-size:50px;text-align:right}#screen-ranking[data-rank-tab="active"] #rank-note{font-size:23px}
/* Active: reset date + countdown inside the title bar; rule note on a dark pill so it reads on the sky */
#screen-ranking[data-rank-tab="active"] .rank-mode-title{flex-wrap:wrap;align-content:center;row-gap:8px;height:auto;min-height:88px;padding:12px 20px}#rank-reset{flex-basis:100%;font:700 28px/1.1 Sarabun,Rajdhani,sans-serif;color:#fff;text-shadow:0 2px 2px #2a6390}#rank-reset:empty{display:none}#rank-reset b{color:#ffe46b}#screen-ranking[data-rank-tab="active"] #rank-note{padding:10px 18px;border-radius:18px;background:rgba(18,72,108,.72);font-size:24px;text-shadow:none}#screen-ranking[data-rank-tab="active"] #rank-rows{height:1080px}
/* Lv100+ / Lv999 name badge (level 999 update, 11-09) */
.lv-badge{display:inline-block;margin-left:10px;padding:2px 12px;border-radius:14px;background:linear-gradient(110deg,#2f9fd6,#1f6fae);color:#fff;font:700 22px/1.3 Rajdhani,sans-serif;font-style:normal;vertical-align:middle}.lv-badge.gold{background:linear-gradient(110deg,#ffd45a,#f0a020);color:#5a3500}

/* Active tab past-week chips (11-11) */
.rank-weeks{height:64px;display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin:-7px 0 12px}.rank-week{height:64px;padding:0 6px;border:2px solid rgba(238,255,255,.95);border-radius:20px;background:linear-gradient(145deg,rgba(230,253,253,.9),rgba(184,229,239,.86));box-shadow:inset 0 0 10px #fff;color:#24577b;font:700 26px/1 Sarabun,Rajdhani,sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.rank-week.active{border:3px solid #ffe474;background:linear-gradient(145deg,#ffd75c,#f0a52a);box-shadow:0 0 10px rgba(255,212,63,.7),inset 0 0 10px #fff3c0;color:#5a3500}
/* HR zones line (11-13): full width under the card, only on rows with per-minute HR */
#screen-ranking[data-rank-tab="active"] .rank-row.has-zone{flex-wrap:wrap;height:auto;min-height:220px;padding-top:22px;padding-bottom:18px;align-content:center}
#screen-ranking[data-rank-tab="active"] .rank-zone{flex:0 0 100%;display:flex;align-items:center;gap:14px;margin-top:10px;padding-left:20px;font:700 29px/1 Rajdhani,Sarabun,sans-serif;color:#24577b;white-space:nowrap}
#screen-ranking[data-rank-tab="active"] .rank-zone .zb{padding:6px 18px;border-radius:30px;background:rgba(196,52,84,.82);color:#fff}
#screen-ranking[data-rank-tab="active"] .rank-zone .zbar{flex:1;display:flex;height:40px;margin-right:24px;border-radius:20px;overflow:hidden;box-shadow:inset 0 0 0 2px rgba(255,255,255,.55)}
#screen-ranking[data-rank-tab="active"] .rank-zone .zbar span{display:flex;align-items:center;justify-content:center;min-width:0;color:#fff;font-size:24px;text-shadow:0 1px 2px rgba(0,0,0,.4)}
/* Zone detail popup (tap the Zone bar, 11-13) — WHOOP-style rows */
#screen-ranking[data-rank-tab="active"] .rank-zone{cursor:pointer}
.zone-detail .zd-pts{color:#c43454;font-weight:700}
.zone-detail .zd-list{margin:12px 0 8px;display:flex;flex-direction:column;gap:8px;text-align:left}
.zone-detail .zd-row{padding:8px 12px 10px;border-radius:12px;background:rgba(36,87,123,.08)}
.zone-detail .zd-head{display:flex;align-items:baseline;gap:8px;font:700 .85rem/1.2 Rajdhani,Sarabun,sans-serif;color:#24577b}
.zone-detail .zd-head span{opacity:.75}
.zone-detail .zd-head em{font-style:normal}
.zone-detail .zd-head strong{margin-left:auto;font-size:1rem}
.zone-detail .zd-track{height:10px;margin-top:6px;border-radius:6px;background:repeating-linear-gradient(135deg,rgba(36,87,123,.12) 0 6px,rgba(36,87,123,.05) 6px 12px);overflow:hidden}
.zone-detail .zd-track i{display:block;height:100%;border-radius:6px}
.zone-detail .zd-note{font-size:.72rem;color:#6b7c8c;margin-bottom:10px}
.zone-detail .zd-head{white-space:nowrap}
.zone-detail .zd-bar{display:flex;align-items:center;gap:8px;margin-top:6px}
.zone-detail .zd-bar .zd-track{flex:1;margin-top:0}
.zone-detail .zd-p{flex:0 0 auto;min-width:92px;text-align:right;font:700 .78rem/1.2 Rajdhani,Sarabun,sans-serif;color:#c43454}
.zone-detail .zd-p.none{color:#8a9aa8;font-weight:600}
/* design A (11-16): card-style summary bar, Z0 as a dashed rest row, "counted in hard steps" hint */
.zone-detail .zd-sum{display:flex;height:14px;border-radius:7px;overflow:hidden;box-shadow:inset 0 0 0 1px rgba(255,255,255,.55)}
.zone-detail .zd-sum span{min-width:0}
.zone-detail .zd-rest{background:transparent;border:1.5px dashed rgba(36,87,123,.25);padding:8px 12px}
.zone-detail .zd-rest em{color:#8a9aa8;font-weight:600}
.zone-detail .zd-p small{display:block;font-size:.66rem;color:#8a9aa8;font-weight:600}
/* 12-01: weekly prizes button on the Active title bar (stage px) + its popup */
#screen-ranking .rank-mode-title{position:relative}
#rank-bond-btn{position:absolute;left:20px;top:50%;width:86px;height:86px;margin-top:-43px;padding:0;border:4px solid #ffe6f1;border-radius:24px;background:linear-gradient(160deg,#ffb3d1,#f0568f);box-shadow:0 3px 6px #0b496455;display:grid;place-items:center;cursor:pointer}
#rank-bond-btn:active{transform:scale(.94)}
#rank-bond-btn[hidden]{display:none}
#rank-bond-btn img{width:70px;height:70px}
.bond-info .zd-list{gap:8px;max-height:calc(100dvh - 250px);overflow-y:auto}
.bond-info .zd-row{flex:none;display:flex;align-items:center;gap:6px;padding:6px 10px;font:700 1rem/1.3 Rajdhani,Sarabun,sans-serif;color:#24577b}
.bond-info .zd-row span{flex:1;white-space:nowrap}
.bond-info .zd-row img{width:24px;height:24px;object-fit:contain}
.bond-info .zd-row strong{min-width:70px;color:#b8336a;white-space:nowrap}
.bond-info .zd-row .bi-x{min-width:22px}
.bond-info .bi-no{flex:0 0 34px;height:34px;border-radius:50%;background:linear-gradient(#8fd0ea,#4f9fd6);color:#fff;font:700 1.1rem/34px Rajdhani,sans-serif;text-align:center}
.bond-info .p1{background:rgba(255,200,70,.4)}
.bond-info .p1 .bi-no{background:linear-gradient(#ffdf70,#f0a020)}
.bond-info .p2 .bi-no{background:linear-gradient(#e3ebf1,#9fb2c1)}
.bond-info .p3 .bi-no{background:linear-gradient(#f0b98a,#c0743c)}
.bond-info .bi-rules{margin:6px 0 2px;padding-left:20px;font:600 .84rem/1.6 Sarabun,sans-serif;color:#3d6680;text-align:left}
.bond-info .bi-rules b{color:#b8336a}
/* Monster Data-style scroll rail on the ranking list (12-02) — native scrollbar hidden */
#rank-rows{scrollbar-width:none;padding-right:34px!important}#rank-rows::-webkit-scrollbar{display:none}
.rank-rail{position:absolute;z-index:4;width:18px;border-radius:14px;background:rgba(5,70,112,.65);pointer-events:none}.rank-rail[hidden]{display:none}
.rank-rail i{display:block;width:14px;height:136px;margin-left:2px;border-radius:14px;background:#e6ffff;box-shadow:0 0 8px #fff;transition:transform .08s linear}
