:root{
  --bg-1:#2f3136;
  --bg-2:#202225;
  --panel:#36393f;
  --text:#dcddde;
  --muted:#b9bbbe;
  --accent:#7289da;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  padding:20px 16px;
  font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: linear-gradient(180deg,var(--bg-1), #1f2023);
  color:var(--text);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  min-height:100vh;
}

/* center wrapper that holds the panel; title stays at the top */
#center-wrap{display:flex;align-items:flex-start;justify-content:center;width:100%;margin:18px 0}
/* when centered, give it enough height to vertically center the panel without
  pushing the rest of the page down */
#center-wrap.centered{min-height:calc(100vh - 120px);align-items:center}
h2{margin:8px 0 10px;font-weight:500}
#title{cursor:pointer}
#panel{
  background:var(--panel);
  padding:16px;
  border-radius:10px;
  max-width:720px;
  width:100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  margin-bottom:12px;
}
#gameChoice{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:10px}
#gameChoice h3{margin:0 8px 0 0;font-size:16px;color:var(--text)}
#auth h3, #join h3{margin:0 0 8px;font-size:16px;color:var(--text)}
input{background:var(--bg-2);border:1px solid #27292c;color:var(--text);padding:8px 10px;border-radius:8px;outline:none}
input::placeholder{color:var(--muted)}
select{background:var(--bg-2);border:1px solid #27292c;color:var(--text);padding:8px 10px;border-radius:8px;outline:none}
button{background:var(--accent);border:none;color:white;padding:8px 12px;border-radius:8px;cursor:pointer;font-weight:500}
button:hover{filter:brightness(.95)}
#status{margin-top:12px;color:var(--muted)}
#grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(218px,1fr));gap:10px;margin-top:14px;justify-content:center;max-width:1280px;width:100%}
#grid .cell{height:350px}
.cell{background:var(--bg-2);border-radius:8px;overflow:hidden;display:flex;flex-direction:column;align-items:stretch;border:1px solid rgba(0,0,0,0.3);cursor:pointer}
.cell img{width:100%;height:321px;object-fit:cover;display:block;transition:transform .12s ease, filter .12s ease}
.cell:active img{transform:scale(.98)}
.grey{filter:grayscale(100%) brightness(.6) contrast(.9)}
#grid img.selected{outline:3px solid var(--accent);box-shadow:0 6px 18px rgba(114,137,218,0.16)}
#grid .caption{padding:6px 8px 8px;text-align:center;color:var(--muted);font-size:14px;line-height:1.1;overflow:hidden;text-overflow:ellipsis;white-space:normal}
#messages{margin-top:14px;color:var(--muted)}

#daily h3{margin:0 0 8px;font-size:16px}
#dailyState{color:var(--muted);font-size:14px}
#dailyResults{display:flex;flex-direction:column;gap:10px;max-height:60vh;overflow-y:auto;padding-right:4px;margin-top:10px}
.daily-card{background:var(--bg-2);border:1px solid rgba(0,0,0,.35);border-radius:10px;padding:10px}
.daily-card h4{margin:0 0 8px;font-weight:500}
.daily-card img{width:109px;height:160.5px;object-fit:cover;border-radius:8px;display:block;margin-bottom:8px}
.daily-criteria-list{display:flex;flex-wrap:nowrap;gap:6px;overflow-x:auto}
.daily-criterion{padding:6px 8px;border-radius:8px;font-size:13px;white-space:nowrap;flex:0 0 auto}
.daily-criterion.ok{background:#2f7d4a;color:#e9ffee}
.daily-criterion.ko{background:#7d2f3b;color:#ffe9ed}

/* Responsive grid: prefer 8 columns on wide screens, adapt downwards */
#panel input{margin-right:8px;margin-bottom:8px}
#panel #join{display:flex;align-items:center;gap:8px}

@media (min-width:1744px){
  /* 8 columns × 218px = 1744px */
  #grid{grid-template-columns:repeat(8,218px);justify-content:center;max-width:1744px}
  #grid .cell{width:218px;height:350px}
}
@media (min-width:1308px) and (max-width:1743px){
  /* 6 columns × 218px = 1308px */
  #grid{grid-template-columns:repeat(6,218px);justify-content:center;max-width:1308px}
  #grid .cell{width:218px;height:350px}
}
@media (min-width:872px) and (max-width:1307px){
  /* 4 columns × 218px = 872px */
  #grid{grid-template-columns:repeat(4,218px);justify-content:center;max-width:872px}
  #grid .cell{width:218px;height:350px}
}
@media (max-width:871px){
  #grid{grid-template-columns:repeat(auto-fill,minmax(218px,1fr));justify-content:center;max-width:872px}
  #grid .cell{height:350px}
}

/* helper for centering headings/status */
h2{align-self:center}
#status{align-self:center}
