${activePlayer} โ ${label}
Tap hour blocks you're free
`;
PERIODS.forEach(period=>{html+=`
`;});
html+=`
`;wrap.innerHTML=html;
PERIODS.forEach(period=>{
const container=document.getElementById(`hg-${period.key}`);
HOURS.filter(h=>h.period===period.key).forEach(h=>{
const active=availability[selectedDateKey][activePlayer].has(h.key);
const btn=document.createElement("button");btn.className="hour-btn";
btn.style.borderColor=active?period.color:"#334155";btn.style.background=active?period.color+"33":"#0f172a";btn.style.color=active?period.color:"#475569";
btn.textContent=h.label;
btn.onclick=()=>{const s=availability[selectedDateKey][activePlayer];s.has(h.key)?s.delete(h.key):s.add(h.key);saveAvail();renderCalendar();renderTimePicker();};
container.appendChild(btn);
});
});
}
function renderAll(){renderWeekNav();renderPlayerGrid();renderCalendar();renderTimePicker();}
// โโ BEST TIMES โโ
function renderSummary(){
const days=getWindowDays(summaryWeekOffset);
document.getElementById("summary-week-label").textContent=getWindowLabel(summaryWeekOffset);
document.getElementById("summary-week-sub").textContent=getWindowSub(summaryWeekOffset);
const bl=document.getElementById("best-list");bl.innerHTML="";
const results=[];
days.forEach(d=>{
const k=dateKey(d);
HOURS.forEach(h=>{
const who=PLAYERS.filter(p=>availability[k]?.[p]?.has(h.key));
if(who.length>=2)results.push({d,slot:h.key,label:h.label,count:who.length,who});
});
});
results.sort((a,b)=>b.count-a.count);
if(!results.length){
// Show how many slots each player has for debugging
const totalSlots=days.reduce((sum,d)=>{
const k=dateKey(d);
return sum+PLAYERS.reduce((ps,p)=>ps+(availability[k]?.[p]?.size||0),0);
},0);
bl.innerHTML=`