:root{
  --bg:#0f1720;
  --panel:rgba(255,255,255,0.06);
  --glass:rgba(255,255,255,0.04);
  --text:#eef2f7;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body,#c{height:100%}
body{
  background:linear-gradient(180deg,var(--bg),#071019 120%);
  color:var(--text);
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  overflow:hidden;
  position:relative;
}
#c{
  width:100%;
  height:100%;
  display:block;
  touch-action:none;
  background:transparent;
}

/* UI panel at top */
#ui{
  position:absolute;
  top:12px;
  left:50%;
  transform:translateX(-50%);
  width:calc(100% - 24px);
  max-width:940px;
  pointer-events:auto;
  z-index:10;
}
#title{
  text-align:center;
  font-weight:700;
  margin-bottom:10px;
  font-size:22px;
  color:var(--text);
  text-shadow:0 1px 0 rgba(0,0,0,0.5);
}
#buttons{
  display:flex;
  gap:10px;
  justify-content:center;
  flex-wrap:wrap;
  /* prevent the button row from growing too tall and covering content:
     limit height and allow horizontal/vertical scrolling when needed */
  max-height:96px;
  padding:6px;
  overflow:auto;
  align-items:center;
  /* better touch scrolling feel */
  -webkit-overflow-scrolling:touch;
}
button.spawn{
  min-width:52px;
  height:44px;
  border-radius:8px;
  border:0;
  color:white;
  font-weight:700;
  padding:6px 8px;
  font-size:13px;
  box-shadow:0 6px 14px rgba(2,6,23,0.55), inset 0 -2px 0 rgba(0,0,0,0.14);
  touch-action:manipulation;
}
button.spawn:active{transform:translateY(1px)}
button.spawn[disabled]{
  opacity:0.35;
  filter:grayscale(30%);
  pointer-events:none;
}
#hint{
  position:absolute;
  left:14px;
  bottom:14px;
  color:#cbd5e1;
  font-size:13px;
  background:var(--panel);
  padding:10px 12px;
  border-radius:10px;
  backdrop-filter:blur(6px);
}

/* colors modal */
#colorsModal{
  position:fixed;
  left:0;top:0;right:0;bottom:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(2,6,12,0.5);
  /* keep modals above the UI panel */
  z-index:120;
  visibility:hidden;
  opacity:0;
  transition:opacity .22s ease, visibility .22s;
  padding:18px;
}
/* ensure the instructions modal sits above buttons as well and is a full-screen overlay */
#instructionsModal{
  position:fixed;
  left:0; top:0; right:0; bottom:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(2,6,12,0.5);
  z-index:121;
  visibility:hidden;
  opacity:0;
  transition:opacity .22s ease, visibility .22s;
  padding:18px;
}

/* mirror the visibility behaviour of colors modal */
#colorsModal[aria-hidden="false"], #instructionsModal[aria-hidden="false"]{ visibility:visible; opacity:1; }

#colorsModal .modal-inner{
  width:min(880px,calc(100% - 48px));
  max-height:88vh;
  background:linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  border-radius:14px;
  padding:16px;
  box-shadow:0 24px 48px rgba(2,6,23,0.6);
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:hidden;
}
.modal-header{ display:flex; align-items:center; justify-content:space-between; padding:8px 6px; }
.modal-title{ font-weight:800; font-size:18px; color:var(--text); }
#closeColors{ background:transparent;border:0;color:var(--text); font-size:20px; padding:10px; cursor:pointer; border-radius:10px; }
.modal-body{ overflow:auto; padding:10px; display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; }
.color-item{ display:flex; gap:12px; align-items:center; padding:12px; border-radius:10px; background:var(--glass); }
.color-swatch{ width:48px; height:48px; border-radius:8px; box-shadow:inset 0 -2px 0 rgba(0,0,0,0.15); flex:0 0 48px; }
.color-meta{ font-size:14px; color:var(--text); }
.color-name{ font-weight:800; margin-bottom:6px; }
.modal-footer{ font-size:12px; color:#cbd5e1; padding:6px 4px; text-align:center; }

/* Bigger instructions modal adjustments */
#instructionsModal .modal-inner{
  /* match the Colors modal size for parity, keep comfortable padding */
  width:min(880px,calc(100% - 48px));
  max-height:88vh;
  background:linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
  border-radius:14px;
  padding:16px;
  box-shadow:0 24px 48px rgba(2,6,23,0.6);
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:hidden;
}

/* make the instructions body more spacious and easier to read */
#instructionsModal .modal-body{
  /* more readable but compact so it doesn't feel tall and narrow */
  font-size:14px;
  line-height:1.45;
  padding:10px;
  overflow:auto;
  color:var(--text);
}

/* ensure modal header is visually balanced with larger inner */
#instructionsModal .modal-header{ padding:10px 8px; }
#instructionsModal .modal-title{ font-size:20px; font-weight:900; }

/* slightly larger close button target for touch */
#instructionsModal button[aria-label="Close"]{ padding:12px; font-size:20px; border-radius:10px; }

/* ensure the Colors modal keeps existing look (no regression) */
#colorsModal .modal-inner{ padding:16px; }